1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
backup_webservice.php
См. документацию.
1<?php
3require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/classes/general/update_client.php';
4
6{
7 private $addParams = [];
8 private $addStr = '';
9
17 protected function getActionURL($arParams = /*.(array[string]string).*/ [])
18 {
20
21 $arParams['license'] = md5(LICENSE_KEY);
22 $arParams['lang'] = LANGUAGE_ID;
23 $arParams['region'] = $license->getRegion();
24 foreach ($this->addParams as $key => $value)
25 {
26 $arParams[$key] = $value;
27 }
28
29 $url = COption::GetOptionString('bitrixcloud', 'backup_policy_url') ?: $license->getDomainStoreLicense() . '/backup.php';
30 $url = (new \Bitrix\Main\Web\Uri($url))
31 ->addParams($arParams)
32 ->getUri() . $this->addStr;
33
34 return $url;
35 }
36
44 protected function backup_action($action) /*. throws CBitrixCloudException .*/
45 {
46 $obXML = $this->action($action);
47 /* @var CDataXMLNode $node */
48 $node = $obXML->SelectNodes('/control');
49 if (is_object($node))
50 {
51 $spd = $node->getAttribute('crc_code');
52 if ($spd <> '')
53 {
54 CUpdateClient::setSpd($spd);
55 }
56 }
57 else
58 {
59 throw new CBitrixCloudException(GetMessage('BCL_BACKUP_WS_SERVER', [
60 '#STATUS#' => '-1',
61 ]), $this->getServerResult());
62 }
63
64 return $obXML;
65 }
66
72 public function actionGetInformation() /*. throws CBitrixCloudException .*/
73 {
74 $this->addStr = '';
75 $this->addParams = [];
76 return $this->backup_action('get_info');
77 }
78
86 public function actionReadFile($check_word, $file_name) /*. throws CBitrixCloudException .*/
87 {
88 $this->addStr = '';
89 $this->addParams = [
90 'check_word' => $check_word,
91 'file_name' => $file_name,
92 ];
93 return $this->backup_action('read_file');
94 }
95
103 public function actionWriteFile($check_word, $file_name) /*. throws CBitrixCloudException .*/
104 {
105 $this->addStr = '';
106 $this->addParams = [
107 'file_name' => $file_name,
108 'spd' => CUpdateClient::getSpd(),
109 'CHHB' => $_SERVER['HTTP_HOST'],
110 'CSAB' => $_SERVER['SERVER_ADDR'],
111 ];
112 return $this->backup_action('write_file');
113 }
114
124 public function actionAddBackupJob($secret_key, $url, $time = 0, $weekdays = []) /*. throws CBitrixCloudException .*/
125 {
126 if ((string)$secret_key === '')
127 {
128 throw new CBitrixCloudException(GetMessage('BCL_BACKUP_EMPTY_SECRET_KEY'), '');
129 }
130
131 $parsedUrl = parse_url($url);
132 if (
133 !is_array($parsedUrl)
134 || !($parsedUrl['scheme'] === 'http' || $parsedUrl['scheme'] === 'https')
135 || $parsedUrl['host'] == ''
136 || !(intval($parsedUrl['port']) == 0 || intval($parsedUrl['port']) == 80)
137 || $parsedUrl['path'] <> ''
138 || $parsedUrl['user'] <> ''
139 || $parsedUrl['pass'] <> ''
140 || $parsedUrl['query'] <> ''
141 || $parsedUrl['fragment'] <> ''
142 )
143 {
144 throw new CBitrixCloudException(GetMessage('BCL_BACKUP_WRONG_URL'), '');
145 }
146
147 $time = intval($time);
148 if ($time < 0 || $time >= 24 * 3600)
149 {
150 throw new CBitrixCloudException(GetMessage('BCL_BACKUP_WRONG_TIME'), '');
151 }
152
153 $weekdaysIsOk = is_array($weekdays);
154 if ($weekdaysIsOk)
155 {
156 foreach ($weekdays as $dow)
157 {
158 if (intval($dow) < 0 || intval($dow) > 6)
159 {
160 $weekdaysIsOk = false;
161 }
162 }
163 }
164 if (!$weekdaysIsOk)
165 {
166 throw new CBitrixCloudException(GetMessage('BCL_BACKUP_WRONG_WEEKDAYS'), '');
167 }
168
169 $h = intval($time / 3600);
170 $time -= $h * 3600;
171 $m = intval($time / 60);
172 $this->addParams = [
173 'secret_key' => trim($secret_key),
174 'time' => $h . ':' . $m,
175 'domain' => $parsedUrl['host'],
176 'spd' => CUpdateClient::getSpd(),
177 'CHHB' => $_SERVER['HTTP_HOST'],
178 'CSAB' => $_SERVER['SERVER_ADDR'],
179 ];
180
181 if ($parsedUrl['scheme'] === 'https')
182 {
183 $this->addParams['domain_is_https'] = 'Y';
184 }
185
186 $this->addStr = '';
187 foreach ($weekdays as $dow)
188 {
189 $this->addStr .= '&ar_weekdays[]=' . intval($dow);
190 }
191
192 return $this->backup_action('add_backup_job');
193 }
194
200 public function actionDeleteBackupJob()
201 {
202 $this->addStr = '';
203 $this->addParams = [
204 'spd' => CUpdateClient::getSpd(),
205 'CHHB' => $_SERVER['HTTP_HOST'],
206 'CSAB' => $_SERVER['SERVER_ADDR'],
207 ];
208
209 return $this->backup_action('delete_backup_job');
210 }
211
217 public function actionGetBackupJob()
218 {
219 $this->addStr = '';
220 $this->addParams = [
221 'spd' => CUpdateClient::getSpd(),
222 'CHHB' => $_SERVER['HTTP_HOST'],
223 'CSAB' => $_SERVER['SERVER_ADDR'],
224 ];
225
226 return $this->backup_action('get_backup_job');
227 }
228}
$arParams
Определения access_dialog.php:21
static getInstance()
Определения application.php:98
actionWriteFile($check_word, $file_name)
Определения backup_webservice.php:103
actionAddBackupJob($secret_key, $url, $time=0, $weekdays=[])
Определения backup_webservice.php:124
actionReadFile($check_word, $file_name)
Определения backup_webservice.php:86
getActionURL($arParams=[])
Определения backup_webservice.php:17
backup_action($action)
Определения backup_webservice.php:44
getServerResult()
Определения webservice.php:151
action($action)
Определения webservice.php:26
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
if(file_exists(( $_fname=__DIR__ . "/classes/general/update_db_updater.php"))) if(($_fname=getLocalPath("init.php")) !==false) if(( $_fname=getLocalPath("php_interface/init.php", BX_PERSONAL_ROOT)) !==false) if(($_fname=getLocalPath("php_interface/" . SITE_ID . "/init.php", BX_PERSONAL_ROOT)) !==false) if((!(defined("STATISTIC_ONLY") &&STATISTIC_ONLY &&!str_starts_with( $GLOBALS["APPLICATION"]->GetCurPage(), BX_ROOT . "/admin/"))) &&COption::GetOptionString("main", "include_charset", "Y")=="Y" &&LANG_CHARSET !='') if(COption::GetOptionString("main", "set_p3p_header", "Y")=="Y") $license
Определения include.php:158
const LICENSE_KEY($show_sql_stat=='Y')
Определения start.php:84
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$time
Определения payment.php:61
if(empty($signedUserToken)) $key
Определения quickway.php:257
$action
Определения file_dialog.php:21
$url
Определения iframe.php:7