1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
update_client_partner.php
См. документацию.
1<?php
2/**********************************************************************/
5/**********************************************************************/
6
8
9if (!defined('DEFAULT_UPDATE_SERVER'))
10{
11 define("DEFAULT_UPDATE_SERVER", "www.1c-bitrix.ru");
12}
13
14IncludeModuleLangFile(__FILE__);
15
16if (!defined("US_SHARED_KERNEL_PATH"))
17 define("US_SHARED_KERNEL_PATH", "/bitrix");
18
19if (!defined("US_CALL_TYPE"))
20 define("US_CALL_TYPE", "ALL");
21
22if (!defined("US_BASE_MODULE"))
23 define("US_BASE_MODULE", "main");
24
25require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/update_class.php");
26
27$GLOBALS["UPDATE_STRONG_UPDATE_CHECK"] = "";
28
30{
31 public static function RegisterModules(&$strError, $lang = false, $stableVersionsOnly = false)
32 {
33 $strError_tmp = '';
34 $updatesDirFull = '';
35
36 CUpdateClientPartner::AddMessage2Log("exec CUpdateClientPartner::RegisterModules");
37
39 $strError_tmp,
40 $lang,
41 $stableVersionsOnly
42 );
43 if ($strQuery == '' || $strError_tmp <> '')
44 {
45 $strError .= $strError_tmp;
46 CUpdateClientPartner::AddMessage2Log("Empty query list", "GUL01");
47 return false;
48 }
49
50 CUpdateClientPartner::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strQuery));
51
52 $stime = microtime(true);
53 $content = CUpdateClientPartner::__GetHTTPPage("REG", $strQuery, $strError_tmp);
54
55 if ($content == '')
56 {
57 if ($strError_tmp == '')
58 $strError_tmp = "[GNSU02] ".GetMessage("SUPZ_EMPTY_ANSWER").". ";
59 }
60
61 CUpdateClientPartner::AddMessage2Log("TIME RegisterModules(request) ".round(microtime(true) - $stime,3)." sec");
62
63 if ($strError_tmp == '')
64 {
65 if (!($fp1 = fopen($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", "wb")))
66 $strError_tmp .= "[URV02] ".GetMessage("SUPP_RV_ER_TEMP_FILE", ["#FILE#" => $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates"]).". ";
67 }
68
69 if ($strError_tmp == '')
70 {
71 if (!fwrite($fp1, $content))
72 $strError_tmp .= "[URV03] ".GetMessage("SUPP_RV_WRT_TEMP_FILE", ["#FILE#" => $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz"]).". ";
73
74 @fclose($fp1);
75 }
76
77 if ($strError_tmp == '')
78 {
79 $updatesDirTmp = "";
80 if (!CUpdateClientPartner::UnGzipArchive($updatesDirTmp, $strError_tmp))
81 $strError_tmp .= "[URV04] ".GetMessage("SUPP_RV_BREAK").". ";
82 }
83
84 if ($strError_tmp == '')
85 {
86 $updatesDirFull = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$updatesDirTmp;
87 if (!file_exists($updatesDirFull."/update_info.xml") || !is_file($updatesDirFull."/update_info.xml"))
88 $strError_tmp .= "[URV05] ".GetMessage("SUPP_RV_ER_DESCR_FILE", ["#FILE#" => $updatesDirFull."/update_info.xml"]).". ";
89 }
90
91 if ($strError_tmp == '')
92 {
93 if (!is_readable($updatesDirFull."/update_info.xml"))
94 $strError_tmp .= "[URV06] ".GetMessage("SUPP_RV_READ_DESCR_FILE", ["#FILE#" => $updatesDirFull."/update_info.xml"]).". ";
95 }
96
97 if ($strError_tmp == '')
98 $content = file_get_contents($updatesDirFull."/update_info.xml");
99
100 //echo "!1!".htmlspecialcharsbx($content)."!2!";
101
102 if ($strError_tmp == '')
103 {
104 $arRes = Array();
106 }
107
108 if ($strError_tmp == '')
109 {
110 if (!empty($arRes["DATA"]["#"]["ERROR"]) && is_array($arRes["DATA"]["#"]["ERROR"]))
111 {
112 for ($i = 0, $n = count($arRes["DATA"]["#"]["ERROR"]); $i < $n; $i++)
113 {
114 if ($arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"] <> '')
115 $strError_tmp .= "[".$arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"]."] ";
116
117 $strError_tmp .= $arRes["DATA"]["#"]["ERROR"][$i]["#"].". ";
118 }
119 }
120 }
121
122 if ($strError_tmp == '')
123 {
124 $handle = @opendir($updatesDirFull);
125 if ($handle)
126 {
127 while (false !== ($dir = readdir($handle)))
128 {
129 if ($dir == "." || $dir == "..")
130 continue;
131
132 if (file_exists($_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/modules/".$dir))
133 {
134 $strError_tmp1 = "";
135 CUpdateClientPartner::__CopyDirFiles($updatesDirFull."/".$dir, $_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/modules/".$dir, $strError_tmp1, false);
136 if ($strError_tmp1 <> '')
137 $strError_tmp .= $strError_tmp1;
138 }
139 }
140 closedir($handle);
141 }
142 }
143
144 if ($strError_tmp == '')
145 {
146 CUpdateClientPartner::AddMessage2Log("Modules registered successfully!", "CURV");
148 }
149
150 if ($strError_tmp <> '')
151 {
152 CUpdateClientPartner::AddMessage2Log($strError_tmp, "CURV");
153 $strError .= $strError_tmp;
154 return false;
155 }
156 else
157 return true;
158 }
159
160 public static function loadModule4Wizard($moduleId, $lang = false)
161 {
162 $errorMessage = "";
163 $arUpdateDescription = array();
164
165 $loadResult = CUpdateClientPartner::LoadModulesUpdates($errorMessage, $arUpdateDescription, $lang, "Y", array($moduleId), true);
166
167 if ($loadResult == "S")
168 {
169 CUpdateClientPartner::AddMessage2Log("loadModule4Wizard-Step", "LM4W01");
170 return "STP";
171 }
172 elseif ($loadResult == "E")
173 {
174 if ($errorMessage == '')
175 $errorMessage = "[LM4W02] ".GetMessage("SUPC_ME_PACK");
177 return "ERR".$errorMessage;
178 }
179 elseif ($loadResult == "F")
180 {
181 CUpdateClientPartner::AddMessage2Log("Finish - NOUPDATES", "LM4W03");
182 return "FIN";
183 }
184
185 $temporaryUpdatesDir = "";
186 if (!CUpdateClientPartner::UnGzipArchive($temporaryUpdatesDir, $errorMessage))
187 {
188 $errorMessage .= "[LM4W04] ".GetMessage("SUPC_ME_PACK").". ";
189 CUpdateClientPartner::AddMessage2Log(GetMessage("SUPC_ME_PACK"), "LM4W04");
190 return "ERR".$errorMessage;
191 }
192
193 if (!CUpdateClientPartner::CheckUpdatability($temporaryUpdatesDir, $errorMessage))
194 {
195 $errorMessage .= "[LM4W05] ".GetMessage("SUPC_ME_CHECK").". ";
196 CUpdateClientPartner::AddMessage2Log(GetMessage("SUPC_ME_CHECK"), "LM4W05");
197 return "ERR".$errorMessage;
198 }
199
200 $arStepUpdateInfo = $arUpdateDescription;
201
202 if (isset($arStepUpdateInfo["DATA"]["#"]["ERROR"]))
203 {
204 for ($i = 0, $cnt = count($arStepUpdateInfo["DATA"]["#"]["ERROR"]); $i < $cnt; $i++)
205 $errorMessage .= "[".$arStepUpdateInfo["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"]."] ".$arStepUpdateInfo["DATA"]["#"]["ERROR"][$i]["#"];
206 return "ERR".$errorMessage;
207 }
208
209 if (isset($arStepUpdateInfo["DATA"]["#"]["NOUPDATES"]))
210 {
211 CUpdateClientPartner::ClearUpdateFolder($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$temporaryUpdatesDir);
212 CUpdateClientPartner::AddMessage2Log("Finish - NOUPDATES", "LM4W06");
213 return "FIN";
214 }
215 else
216 {
217 if (!CUpdateClientPartner::UpdateStepModules($temporaryUpdatesDir, $errorMessage))
218 {
219 $errorMessage .= "[LM4W07] ".GetMessage("SUPC_ME_UPDATE").". ";
220 CUpdateClientPartner::AddMessage2Log(GetMessage("SUPC_ME_UPDATE"), "LM4W07");
221 return "ERR".$errorMessage;
222 }
223
224 return "STP";
225 }
226 }
227
228 public static function LoadModuleNoDemand($moduleId, &$strError, $stableVersionsOnly = "Y", $lang = false)
229 {
230 $strError_tmp = '';
231 $content = '';
232 $temporaryUpdatesDir = '';
233
234 CUpdateClientPartner::AddMessage2Log("exec CUpdateClientPartner::LoadModuleNoDemand");
235
236 $stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
237
238 if ($lang === false)
239 $lang = LANGUAGE_ID;
240
241 $strQuery = CUpdateClientPartner::__CollectRequestData($strError_tmp, $lang, $stableVersionsOnly, array($moduleId), array(), true);
242 if ($strQuery == '' || $strError_tmp <> '')
243 {
244 if ($strError_tmp == '')
245 $strError_tmp = "[GNSU01] ".GetMessage("SUPZ_NO_QSTRING").". ";
246 }
247
248 if ($strError_tmp == '')
249 {
250 CUpdateClientPartner::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strQuery));
251
252 $stime = microtime(true);
253 $content = CUpdateClientPartner::__GetHTTPPage("MODULE", $strQuery, $strError_tmp);
254 if ($content == '')
255 {
256 if ($strError_tmp == '')
257 $strError_tmp = "[GNSU02] ".GetMessage("SUPZ_EMPTY_ANSWER").". ";
258 }
259
260 CUpdateClientPartner::AddMessage2Log("TIME LoadModuleNoDemand(request) ".round(microtime(true) - $stime,3)." sec");
261 }
262
263 if ($strError_tmp == '')
264 {
265 if (!($fp1 = fopen($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", "wb")))
266 $strError_tmp = "[GNSU03] ".GetMessage("SUPP_RV_ER_TEMP_FILE", ["#FILE#" => $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates"]).". ";
267 }
268
269 if ($strError_tmp == '')
270 {
271 fwrite($fp1, $content);
272 fclose($fp1);
273 }
274
275 if ($strError_tmp == '')
276 {
277 if (!CUpdateClientPartner::UnGzipArchive($temporaryUpdatesDir, $strError_tmp))
278 {
279 $strError_tmp .= "[CL02] ".GetMessage("SUPC_ME_PACK").". ";
280 CUpdateClientPartner::AddMessage2Log(GetMessage("SUPC_ME_PACK"), "CL02");
281 }
282 }
283
284 $arStepUpdateInfo = array();
285 if ($strError_tmp == '')
286 $arStepUpdateInfo = CUpdateClientPartner::GetStepUpdateInfo($temporaryUpdatesDir, $strError_tmp);
287
288 if ($strError_tmp == '')
289 {
290 if (isset($arStepUpdateInfo["DATA"]["#"]["ERROR"]))
291 {
292 for ($i = 0, $cnt = count($arStepUpdateInfo["DATA"]["#"]["ERROR"]); $i < $cnt; $i++)
293 $strError_tmp .= "[".$arStepUpdateInfo["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"]."] ".$arStepUpdateInfo["DATA"]["#"]["ERROR"][$i]["#"];
294 }
295 }
296
297 if ($strError_tmp == '')
298 {
299 if (!CUpdateClientPartner::UpdateStepModules($temporaryUpdatesDir, $strError_tmp))
300 {
301 $strError_tmp .= "[CL04] ".GetMessage("SUPC_ME_UPDATE").". ";
302 CUpdateClientPartner::AddMessage2Log(GetMessage("SUPC_ME_UPDATE"), "CL04");
303 }
304 }
305
306 if ($strError_tmp <> '')
307 {
308 CUpdateSystem::AddMessage2Log($strError_tmp, "CURV");
309 $strError .= $strError_tmp;
310 return false;
311 }
312 else
313 return true;
314 }
315
316 public static function SearchModulesEx($arOrder, $arFilter, $searchPage, $lang, &$strError)
317 {
318 $strError_tmp = "";
319
320 CUpdateClientPartner::AddMessage2Log("exec CUpdateClientPartner::SearchModulesEx");
321
322 $arOrderKeys = array_keys($arOrder);
323
325 $strError_tmp,
326 $lang,
327 'Y',
328 array(),
329 array(
330 "search_module_id" => $arFilter["ID"] ?? '',
331 "search_module" => $arFilter["NAME"] ?? '',
332 "search_category" => (isset($arFilter["CATEGORY"]) && is_array($arFilter["CATEGORY"]) ? implode(",", $arFilter["CATEGORY"]) : $arFilter["CATEGORY"] ?? ''),
333 "search_type" => (isset($arFilter["TYPE"]) && is_array($arFilter["TYPE"]) ? implode(",", $arFilter["TYPE"]) : $arFilter["TYPE"] ?? ''),
334 "search_order" => $arOrder[$arOrderKeys[0]] ?? '',
335 "search_order_by" => $arOrderKeys[0] ?? '',
336 "search_page" => $searchPage
337 )
338 );
339 if ($strQuery == '' || $strError_tmp <> '')
340 {
341 $strError .= $strError_tmp;
342 CUpdateClientPartner::AddMessage2Log("Empty query list", "GUL01");
343 return false;
344 }
345
346 CUpdateClientPartner::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strQuery));
347
348 $stime = microtime(true);
349 $content = CUpdateClientPartner::__GetHTTPPage("SEARCH", $strQuery, $strError_tmp);
350
351 CUpdateClientPartner::AddMessage2Log("TIME SearchModulesEx(request) ".round(microtime(true) - $stime,3)." sec");
352
353 $arResult = Array();
354 if ($strError_tmp == '')
356
357 if ($strError_tmp == '')
358 {
359 if (!isset($arResult["DATA"]) || !is_array($arResult["DATA"]))
360 $strError_tmp .= "[UGAUT01] ".GetMessage("SUPP_GAUT_SYSERR").". ";
361 }
362
363 if ($strError_tmp == '')
364 {
365 $arResult = $arResult["DATA"]["#"];
366 if (!is_array($arResult["CLIENT"]) && (!isset($arResult["ERROR"]) || !is_array($arResult["ERROR"])))
367 $strError_tmp .= "[UGAUT01] ".GetMessage("SUPP_GAUT_SYSERR").". ";
368 }
369
370 if (isset($arResult["ERROR"]))
371 {
372 for ($i = 0, $cnt = count($arResult["ERROR"]); $i < $cnt; $i++)
373 $strError_tmp .= "[".$arResult["ERROR"][$i]["@"]["TYPE"]."] ".$arResult["ERROR"][$i]["#"];
374 }
375
376 if ($strError_tmp <> '')
377 {
378 CUpdateClientPartner::AddMessage2Log($strError_tmp, "GUL02");
379 $strError .= $strError_tmp;
380 return false;
381 }
382 else
383 return $arResult;
384 }
385
386 public static function SearchModules($searchModule, $lang)
387 {
388 $strError_tmp = "";
389
390 CUpdateClientPartner::AddMessage2Log("exec CUpdateClientPartner::SearchModules");
391
393 $strError_tmp,
394 $lang,
395 'Y',
396 array(),
397 array("search_module" => $searchModule)
398 );
399 if ($strQuery == '' || $strError_tmp <> '')
400 {
401 CUpdateClientPartner::AddMessage2Log("Empty query list", "GUL01");
402 return false;
403 }
404
405 CUpdateClientPartner::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strQuery));
406
407 $stime = microtime(true);
408 $content = CUpdateClientPartner::__GetHTTPPage("SEARCH", $strQuery, $strError_tmp);
409
410 CUpdateClientPartner::AddMessage2Log("TIME SearchModules(request) ".round(microtime(true) - $stime,3)." sec");
411
412 $arResult = Array();
413 if ($strError_tmp == '')
415
416 if ($strError_tmp == '')
417 {
418 if (!isset($arResult["DATA"]) || !is_array($arResult["DATA"]))
419 $strError_tmp .= "[UGAUT01] ".GetMessage("SUPP_GAUT_SYSERR").". ";
420 }
421
422 if ($strError_tmp == '')
423 {
424 $arResult = $arResult["DATA"]["#"];
425 if (!is_array($arResult["CLIENT"]) && (!isset($arResult["ERROR"]) || !is_array($arResult["ERROR"])))
426 $strError_tmp .= "[UGAUT01] ".GetMessage("SUPP_GAUT_SYSERR").". ";
427 }
428
429 if ($strError_tmp <> '')
430 {
431 CUpdateClientPartner::AddMessage2Log($strError_tmp, "GUL02");
432 return false;
433 }
434 return $arResult;
435 }
436
438 public static function AddMessage2Log($sText, $sErrorCode = "")
439 {
440 $MAX_LOG_SIZE = 1000000;
441 $READ_PSIZE = 8000;
442 $LOG_FILE = $_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/modules/updater_partner.log";
443 $LOG_FILE_TMP = $_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/modules/updater_partner_tmp1.log";
444
445 if ($sText <> '' || $sErrorCode <> '')
446 {
447 $old_abort_status = ignore_user_abort(true);
448
449 if (file_exists($LOG_FILE))
450 {
451 $log_size = @filesize($LOG_FILE);
452 $log_size = intval($log_size);
453
454 if ($log_size > $MAX_LOG_SIZE)
455 {
456 if (!($fp = @fopen($LOG_FILE, "rb")))
457 {
458 ignore_user_abort($old_abort_status);
459 return false;
460 }
461
462 if (!($fp1 = @fopen($LOG_FILE_TMP, "wb")))
463 {
464 ignore_user_abort($old_abort_status);
465 return false;
466 }
467
468 $iSeekLen = intval($log_size-$MAX_LOG_SIZE/2.0);
469 fseek($fp, $iSeekLen);
470
471 do
472 {
473 $data = fread($fp, $READ_PSIZE);
474 if ($data == '')
475 break;
476
477 @fwrite($fp1, $data);
478 }
479 while(true);
480
481 @fclose($fp);
482 @fclose($fp1);
483
484 @copy($LOG_FILE_TMP, $LOG_FILE);
485 @unlink($LOG_FILE_TMP);
486 }
487 clearstatcache();
488 }
489
490 if ($fp = @fopen($LOG_FILE, "ab+"))
491 {
492 if (flock($fp, LOCK_EX))
493 {
494 @fwrite($fp, date("Y-m-d H:i:s")." - ".$sErrorCode." - ".$sText."\n");
495 @fflush($fp);
496 @flock($fp, LOCK_UN);
497 @fclose($fp);
498 }
499 }
500 ignore_user_abort($old_abort_status);
501 }
502 return true;
503 }
504
505 public static function GetRequestedModules($strAddModule)
506 {
507 $arRequestedModules = array();
508
509 $arClientModules = CUpdateClientPartner::GetCurrentModules($strError_tmp);
510 if ($strError_tmp == '')
511 {
512 if (!empty($arClientModules))
513 {
514 foreach ($arClientModules as $key => $value)
515 {
516 if (str_contains($key, "."))
517 $arRequestedModules[] = $key;
518 }
519 }
520 }
521
522 if ($strAddModule <> '')
523 {
524 $arAddModule = explode(",", $strAddModule);
525 foreach ($arAddModule as $value)
526 {
527 $value = trim($value);
528 if ($value <> '' && str_contains($value, "."))
529 $arRequestedModules[] = $value;
530 }
531 }
532
533 return $arRequestedModules;
534 }
535
539 public static function GetLicenseKey()
540 {
541 $license = Application::getInstance()->getLicense();
542 return $license->getKey();
543 }
544
545 // Распаковывает архив файлов update_archive.gz в папкy $updatesDir
546 public static function UnGzipArchive(&$updatesDir, &$strError, $bDelArch = true)
547 {
548 $strError_tmp = '';
549 $updatesDirFull = '';
550
551 CUpdateClientPartner::AddMessage2Log("exec CUpdateClientPartner::UnGzipArchive");
552 $stime = microtime(true);
553
554 $archiveFileName = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz";
555
556 if (!file_exists($archiveFileName) || !is_file($archiveFileName))
557 $strError_tmp .= "[UUGZA01] ".GetMessage("SUPP_UGA_NO_TMP_FILE", ["#FILE#" => $archiveFileName]).". ";
558
559 if ($strError_tmp == '')
560 {
561 if (!is_readable($archiveFileName))
562 $strError_tmp .= "[UUGZA02] ".GetMessage("SUPP_UGA_NO_READ_FILE", ["#FILE#" => $archiveFileName]).". ";
563 }
564
565 if ($strError_tmp == '')
566 {
567 $updatesDir = "update_m".time();
568 $updatesDirFull = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$updatesDir;
569 CUpdateClientPartner::__CheckDirPath($updatesDirFull."/");
570
571 if (!file_exists($updatesDirFull) || !is_dir($updatesDirFull))
572 $strError_tmp .= "[UUGZA03] ".GetMessage("SUPP_UGA_NO_TMP_CAT", ["#FILE#" => $updatesDirFull]).". ";
573 elseif (!is_writable($updatesDirFull))
574 $strError_tmp .= "[UUGZA04] ".GetMessage("SUPP_UGA_WRT_TMP_CAT", ["#FILE#" => $updatesDirFull]).". ";
575 }
576
577 if ($strError_tmp == '')
578 {
579 $bCompressionUsed = true;
580
581 $fd = fopen($archiveFileName, "rb");
582 $flabel = fread($fd, mb_strlen("BITRIX"));
583 fclose($fd);
584
585 if ($flabel == "BITRIX")
586 $bCompressionUsed = false;
587 }
588
589 if ($strError_tmp == '')
590 {
591 if ($bCompressionUsed)
592 $zp = gzopen($archiveFileName, "rb9f");
593 else
594 $zp = fopen($archiveFileName, "rb");
595
596 if (!$zp)
597 $strError_tmp .= "[UUGZA05] ".GetMessage("SUPP_UGA_CANT_OPEN", ["#FILE#" => $archiveFileName]).". ";
598 }
599
600 if ($strError_tmp == '')
601 {
602 if ($bCompressionUsed)
603 $flabel = gzread($zp, mb_strlen("BITRIX"));
604 else
605 $flabel = fread($zp, mb_strlen("BITRIX"));
606
607 if ($flabel != "BITRIX")
608 {
609 $strError_tmp .= "[UUGZA06] ".GetMessage("SUPP_UGA_BAD_FORMAT", ["#FILE#" => $archiveFileName]).". ";
610
611 if ($bCompressionUsed)
612 gzclose($zp);
613 else
614 fclose($zp);
615 }
616 }
617
618 if ($strError_tmp == '')
619 {
620 $strongUpdateCheck = COption::GetOptionString("main", "strong_update_check", "Y");
621
622 while (true)
623 {
624 if ($bCompressionUsed)
625 $add_info_size = gzread($zp, 5);
626 else
627 $add_info_size = fread($zp, 5);
628
629 $add_info_size = trim($add_info_size);
630 if (intval($add_info_size) > 0 && intval($add_info_size)."!"==$add_info_size."!")
631 {
632 $add_info_size = intval($add_info_size);
633 }
634 else
635 {
636 if ($add_info_size != "RTIBE")
637 $strError_tmp .= "[UUGZA071] ".GetMessage("SUPP_UGA_BAD_FORMAT", ["#FILE#" => $archiveFileName]).". ";
638
639 break;
640 }
641
642 if ($bCompressionUsed)
643 $add_info = gzread($zp, $add_info_size);
644 else
645 $add_info = fread($zp, $add_info_size);
646
647 $add_info_arr = explode("|", $add_info);
648 if (count($add_info_arr) != 3)
649 {
650 $strError_tmp .= "[UUGZA072] ".GetMessage("SUPP_UGA_BAD_FORMAT", ["#FILE#" => $archiveFileName]).". ";
651 break;
652 }
653
654 $size = $add_info_arr[0];
655 $curpath = $add_info_arr[1];
656 $crc32 = $add_info_arr[2];
657
658 $contents = "";
659 if (intval($size) > 0)
660 {
661 if ($bCompressionUsed)
662 $contents = gzread($zp, $size);
663 else
664 $contents = fread($zp, $size);
665 }
666
667 $crc32_new = dechex(crc32($contents));
668
669 if ($crc32_new != $crc32)
670 {
671 $strError_tmp .= "[UUGZA073] ".GetMessage("SUPP_UGA_FILE_CRUSH", ["#FILE#" => $curpath]).". ";
672 break;
673 }
674 else
675 {
676 CUpdateClientPartner::__CheckDirPath($updatesDirFull.$curpath);
677
678 if (!($fp1 = fopen($updatesDirFull.$curpath, "wb")))
679 {
680 $strError_tmp .= "[UUGZA074] ".GetMessage("SUPP_UGA_CANT_OPEN_WR", ["#FILE#" => $updatesDirFull.$curpath]).". ";
681 break;
682 }
683
684 if ($contents <> '' && !fwrite($fp1, $contents))
685 {
686 $strError_tmp .= "[UUGZA075] ".GetMessage("SUPP_UGA_CANT_WRITE_F", ["#FILE#" => $updatesDirFull.$curpath]).". ";
687 @fclose($fp1);
688 break;
689 }
690 fclose($fp1);
691
692 if ($strongUpdateCheck == "Y")
693 {
694 $crc32_new = dechex(crc32(file_get_contents($updatesDirFull.$curpath)));
695 if ($crc32_new != $crc32)
696 {
697 $strError_tmp .= "[UUGZA0761] ".GetMessage("SUPP_UGA_FILE_CRUSH", ["#FILE#", $curpath]).". ";
698 break;
699 }
700 }
701 }
702 }
703
704 if ($bCompressionUsed)
705 gzclose($zp);
706 else
707 fclose($zp);
708 }
709
710 if ($strError_tmp == '')
711 {
712 if ($bDelArch)
713 @unlink($archiveFileName);
714 }
715
716 CUpdateClientPartner::AddMessage2Log("TIME UnGzipArchive ".round(microtime(true) - $stime,3)." sec");
717
718 if ($strError_tmp <> '')
719 {
720 CUpdateClientPartner::AddMessage2Log($strError_tmp, "CUUGZA");
721 $strError .= $strError_tmp;
722 return false;
723 }
724 else
725 return true;
726 }
727
728 // Возвращает информацию по загруженным в папку $updatesDir обновлениям модулей
729 public static function CheckUpdatability($updatesDir, &$strError)
730 {
731 $strError_tmp = "";
732
733 $updatesDirFull = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$updatesDir;
734 if (!file_exists($updatesDirFull) || !is_dir($updatesDirFull))
735 $strError_tmp .= "[UCU01] ".GetMessage("SUPP_CU_NO_TMP_CAT", ["#FILE#" => $updatesDirFull]).". ";
736
737 if ($strError_tmp == '')
738 if (!is_readable($updatesDirFull))
739 $strError_tmp .= "[UCU02] ".GetMessage("SUPP_CU_RD_TMP_CAT", ["#FILE#" => $updatesDirFull]).". ";
740
741 if ($handle = @opendir($updatesDirFull))
742 {
743 while (($file = readdir($handle)) !== false)
744 {
745 if ($file == "." || $file == "..")
746 continue;
747
748 if (is_dir($updatesDirFull."/".$file))
749 {
750 CUpdateClientPartner::CheckUpdatability($updatesDir."/".$file, $strError_tmp);
751 }
752 elseif (is_file($updatesDirFull."/".$file))
753 {
754 $strRealPath = $_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/modules/".mb_substr($updatesDir."/".$file, mb_strpos($updatesDir."/".$file, "/"));
755 if (file_exists($strRealPath))
756 {
757 if (!is_writeable($strRealPath))
758 $strError_tmp .= "[UCU03] ".GetMessage("SUPP_CU_MAIN_ERR_FILE", ["#FILE#" => $strRealPath]).". ";
759 }
760 else
761 {
762 $p = CUpdateClientPartner::__bxstrrpos($strRealPath, "/");
763 $strRealPath = mb_substr($strRealPath, 0, $p);
764
765 if (mb_strlen($strRealPath) > 1)
766 $strRealPath = rtrim($strRealPath, "/");
767
768 $p = CUpdateClientPartner::__bxstrrpos($strRealPath, "/");
769 while ($p > 0)
770 {
771 if (file_exists($strRealPath) && is_dir($strRealPath))
772 {
773 if (!is_writable($strRealPath))
774 $strError_tmp .= "[UCU04] ".GetMessage("SUPP_CU_MAIN_ERR_CAT", ["#FILE#" => $strRealPath]).". ";
775
776 break;
777 }
778 $strRealPath = mb_substr($strRealPath, 0, $p);
779 $p = CUpdateClientPartner::__bxstrrpos($strRealPath, "/");
780 }
781 }
782 }
783 }
784 @closedir($handle);
785 }
786
787 if ($strError_tmp <> '')
788 {
789 CUpdateClientPartner::AddMessage2Log($strError_tmp, "CUCU");
790 $strError .= $strError_tmp;
791 return false;
792 }
793 else
794 return true;
795 }
796
797 // Возвращает информацию по загруженным в папку $updatesDir обновлениям модулей
798 public static function GetStepUpdateInfo($updatesDir, &$strError)
799 {
800 $arResult = array();
801 $strError_tmp = "";
802
803 CUpdateClientPartner::AddMessage2Log("exec CUpdateClientPartner::GetStepUpdateInfo");
804
805 $updatesDirFull = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$updatesDir;
806 if (!file_exists($updatesDirFull) || !is_dir($updatesDirFull))
807 $strError_tmp .= "[UGLMU01] ".GetMessage("SUPP_CU_NO_TMP_CAT", ["#FILE#" => $updatesDirFull]).". ";
808
809 if ($strError_tmp == '')
810 if (!is_readable($updatesDirFull))
811 $strError_tmp .= "[UGLMU02] ".GetMessage("SUPP_CU_RD_TMP_CAT", ["#FILE#" => $updatesDirFull]).". ";
812
813 if ($strError_tmp == '')
814 if (!file_exists($updatesDirFull."/update_info.xml") || !is_file($updatesDirFull."/update_info.xml"))
815 $strError_tmp .= "[UGLMU03] ".GetMessage("SUPP_RV_ER_DESCR_FILE", ["#FILE#" => $updatesDirFull."/update_info.xml"]).". ";
816
817 if ($strError_tmp == '')
818 if (!is_readable($updatesDirFull."/update_info.xml"))
819 $strError_tmp .= "[UGLMU04] ".GetMessage("SUPP_RV_READ_DESCR_FILE", ["#FILE#" => $updatesDirFull."/update_info.xml"]).". ";
820
821 if ($strError_tmp == '')
822 $content = file_get_contents($updatesDirFull."/update_info.xml");
823
824 if ($strError_tmp == '')
825 {
826 $arResult = Array();
828 }
829
830 if ($strError_tmp == '')
831 {
832 if (!isset($arResult["DATA"]) || !is_array($arResult["DATA"]))
833 $strError_tmp .= "[UGSMU01] ".GetMessage("SUPP_GAUT_SYSERR").". ";
834 }
835
836 if ($strError_tmp <> '')
837 {
838 CUpdateClientPartner::AddMessage2Log($strError_tmp, "CUGLMU");
839 $strError .= $strError_tmp;
840 return false;
841 }
842 else
843 return $arResult;
844 }
845
846 public static function __CollectRequestData(&$strError, $lang = false, $stableVersionsOnly = "Y", $arRequestedModules = array(), $arAdditionalData = array(), $bStrongList = false)
847 {
848 $strError_tmp = "";
849
850 if ($lang === false)
851 $lang = LANGUAGE_ID;
852
853 $stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
854
855 CUpdateClientPartner::AddMessage2Log("exec CUpdateClientPartner::__CollectRequestData");
856
857 CUpdateClientPartner::__CheckDirPath($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/");
858
859 $arClientModules = CUpdateClientPartner::GetCurrentModules($strError_tmp);
860
861 if ($strError_tmp == '')
862 {
863 $license = Application::getInstance()->getLicense();
864
865 $dbv = $GLOBALS["DB"]->GetVersion();
866
867 $strResult = "utf=Y".
868 "&lang=".urlencode($lang).
869 "&stable=".urlencode($stableVersionsOnly).
870 "&CANGZIP=".urlencode((CUpdateClientPartner::__IsGzipInstalled()) ? "Y" : "N").
871 "&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
872 "&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
873 "&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
874 "&LICENSE_KEY=".urlencode($license->getHashLicenseKey()).
875 "&SUPD_STS=".urlencode(CUpdateClientPartner::__GetFooPath()).
876 "&SUPD_URS=".urlencode($license->getActiveUsersCount()).
877 "&TYPENC=".($license->isDemo() ? "D" : ($license->isEncoded() ? "E" : ($license->isTimeBound() ? "T" : "F"))).
878 "&CLIENT_PHPVER=".urlencode(phpversion()).
879 "&NGINX=".urlencode(COption::GetOptionString("main", "update_use_nginx", "Y")).
880 "&dbv=".urlencode($dbv ?: "");
881
882 $strResultTmp = "";
883 if (!empty($arClientModules))
884 {
885 foreach ($arClientModules as $key => $value)
886 {
887 if ($strResultTmp <> '')
888 $strResultTmp .= ";";
889 $strResultTmp .= $key.",".$value["VERSION"].",".$value["IS_DEMO"];
890 }
891 }
892 if ($strResultTmp <> '')
893 $strResult .= "&instm=".urlencode($strResultTmp);
894
895 $strResultTmp = "";
896 if (!empty($arRequestedModules))
897 {
898 for ($i = 0, $cnt = count($arRequestedModules); $i < $cnt; $i++)
899 {
900 if ($strResultTmp <> '')
901 $strResultTmp .= ",";
902 $strResultTmp .= $arRequestedModules[$i];
903 }
904 }
905 if ($strResultTmp <> '')
906 $strResult .= "&reqm=".urlencode($strResultTmp);
907
908 if ($bStrongList)
909 $strResult .= "&lim=Y";
910
911 $strResultTmp = "";
912 if (!empty($arAdditionalData))
913 {
914 foreach ($arAdditionalData as $key => $value)
915 {
916 if ($strResultTmp <> '')
917 $strResultTmp .= "&";
918 $strResultTmp .= $key."=".urlencode($value);
919 }
920 }
921 if ($strResultTmp <> '')
922 $strResult .= "&".$strResultTmp;
923
924 if (CModule::IncludeModule("cluster") && class_exists("CCluster"))
925 $strResult .= "&SUPD_SRS=".urlencode(CCluster::getServersCount());
926 else
927 $strResult .= "&SUPD_SRS=".urlencode("RU");
928
929 if (method_exists("CHTMLPagesCache", "IsOn") && method_exists("CHTMLPagesCache", "IsCompositeEnabled") && CHTMLPagesCache::IsOn() && CHTMLPagesCache::IsCompositeEnabled())
930 $strResult .= "&SUPD_CMP=".urlencode("Y");
931 else
932 $strResult .= "&SUPD_CMP=".urlencode("N");
933
934 return $strResult;
935 }
936
937 CUpdateClientPartner::AddMessage2Log($strError_tmp, "NCRD01");
938 $strError .= $strError_tmp;
939 return false;
940 }
941
943 public static function GetCurrentModules(&$strError)
944 {
945 $arClientModules = array();
946
947 if (file_exists($_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/modules/main/classes/general/version.php")
948 && is_file($_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/modules/main/classes/general/version.php"))
949 {
950 $p = file_get_contents($_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/modules/main/classes/general/version.php");
951
952 preg_match("/define\s*\‍(\s*\"SM_VERSION\"\s*,\s*\"(\d+\.\d+\.\d+)\"\s*\‍)\s*/im", $p, $arVers);
953 $arClientModules["main"] = array("VERSION" => $arVers[1], "IS_DEMO" => ((defined("DEMO") && DEMO == "Y") ? "Y" : "N"));
954 }
955
956 if (!array_key_exists("main", $arClientModules) || $arClientModules["main"]["VERSION"] == '')
957 {
958 CUpdateClientPartner::AddMessage2Log(GetMessage("SUPP_GM_ERR_DMAIN"), "Ux09");
959 $strError .= "[Ux09] ".GetMessage("SUPP_GM_ERR_DMAIN").". ";
960 return array();
961 }
962
963 if ($handle = @opendir($_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/modules"))
964 {
965 while (false !== ($dir = readdir($handle)))
966 {
967 if (is_dir($_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/modules/".$dir)
968 && $dir != "." && $dir != ".." && $dir != "main")
969 {
970 $module_dir = $_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/modules/".$dir;
971 if (file_exists($module_dir."/install/index.php"))
972 {
973 $arInfo = CUpdateClientPartner::__GetModuleInfo($module_dir);
974 if (!isset($arInfo["VERSION"]) || $arInfo["VERSION"] == '')
975 {
976 CUpdateClientPartner::AddMessage2Log(GetMessage("SUPP_GM_ERR_DMOD", ["#MODULE#" => $dir]), "Ux11");
977 $strError .= "[Ux11] ".GetMessage("SUPP_GM_ERR_DMOD", ["#MODULE#" => $dir]).". ";
978
979 return array();
980 }
981 else
982 {
983 if($arInfo["ACTIVE"] == "Y")
984 $arClientModules[$dir] = array("VERSION" => $arInfo["VERSION"], "IS_DEMO" => $arInfo["IS_DEMO"]);
985 }
986 }
987 else
988 {
989 CUpdateClientPartner::AddMessage2Log(GetMessage("SUPP_GM_ERR_DMOD", ["#MODULE#" => $dir]), "Ux12");
990 }
991 }
992 }
993 closedir($handle);
994 }
995 else
996 {
997 CUpdateClientPartner::AddMessage2Log(GetMessage("SUPP_GM_NO_KERNEL"), "Ux15");
998 $strError .= "[Ux15] ".GetMessage("SUPP_GM_NO_KERNEL").". ";
999
1000 return array();
1001 }
1002
1003 return $arClientModules;
1004 }
1005
1006 /* Получить список доступных обновлений */
1007 public static function GetUpdatesList(&$strError, $lang = false, $stableVersionsOnly = "Y", $arRequestedModules = array(), $aditData = Array())
1008 {
1009 $strError_tmp = "";
1010
1011 CUpdateClientPartner::AddMessage2Log("exec CUpdateClientPartner::GetUpdatesList");
1012
1013 $strQuery = CUpdateClientPartner::__CollectRequestData($strError_tmp, $lang, $stableVersionsOnly, $arRequestedModules, $aditData);
1014 if ($strQuery == '' || $strError_tmp <> '')
1015 {
1016 $strError .= $strError_tmp;
1017 CUpdateClientPartner::AddMessage2Log("Empty query list", "GUL01");
1018 return false;
1019 }
1020
1021 CUpdateClientPartner::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strQuery));
1022
1023 $stime = microtime(true);
1024 $content = CUpdateClientPartner::__GetHTTPPage("LIST", $strQuery, $strError_tmp);
1025
1026 CUpdateClientPartner::AddMessage2Log("TIME GetUpdatesList(request) ".round(microtime(true) - $stime,3)." sec");
1027
1028 $arResult = Array();
1029 if ($strError_tmp == '')
1031
1032 if ($strError_tmp == '')
1033 {
1034 if (!isset($arResult["DATA"]) || !is_array($arResult["DATA"]))
1035 $strError_tmp .= "[UGAUT01] ".GetMessage("SUPP_GAUT_SYSERR").". ";
1036 }
1037
1038 if ($strError_tmp == '')
1039 {
1040 $arResult = $arResult["DATA"]["#"];
1041 if (!is_array($arResult["CLIENT"]) && (!isset($arResult["ERROR"]) || !is_array($arResult["ERROR"])))
1042 $strError_tmp .= "[UGAUT01] ".GetMessage("SUPP_GAUT_SYSERR").". ";
1043 }
1044
1045 if ($strError_tmp <> '')
1046 {
1047 CUpdateClientPartner::AddMessage2Log($strError_tmp, "GUL02");
1048 $strError .= $strError_tmp;
1049 return false;
1050 }
1051 else
1052 return $arResult;
1053 }
1054
1055 public static function ClearUpdateFolder($updatesDirFull)
1056 {
1058 }
1059
1060 public static function LoadModulesUpdates(&$errorMessage, &$arUpdateDescription, $lang = false, $stableVersionsOnly = "Y", $arRequestedModules = array(), $bStrongList = false)
1061 {
1062 $arUpdateDescription = array();
1063 $updateServerQueryString = "";
1064
1065 $filename = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz";
1066 $timeout = COption::GetOptionString("main", "update_load_timeout", "30");
1067 if ($timeout < 5)
1068 $timeout = 5;
1069
1070 CUpdateClientPartner::AddMessage2Log("exec CUpdateClientPartner::LoadModulesUpdates");
1071
1072 if (file_exists($filename.".log"))
1073 {
1074 $content = file_get_contents($filename.".log");
1075 CUpdateClientPartner::__ParseServerData($content, $arUpdateDescription, $strError_tmp);
1076 }
1077
1078 if (empty($arUpdateDescription) || $errorMessage <> '')
1079 {
1080 $arUpdateDescription = array();
1081 if (file_exists($filename.".tmp"))
1082 @unlink($filename.".tmp");
1083 if (file_exists($filename.".log"))
1084 @unlink($filename.".log");
1085
1086 if ($errorMessage <> '')
1087 {
1089
1090 return "E";
1091 }
1092 }
1093
1094 if (empty($arUpdateDescription))
1095 {
1096 $updateServerQueryString = CUpdateClientPartner::__CollectRequestData(
1097 $errorMessage, $lang, $stableVersionsOnly, $arRequestedModules, array(), $bStrongList
1098 );
1099 if (empty($updateServerQueryString) || $errorMessage <> '')
1100 {
1101 if ($errorMessage == '')
1102 $errorMessage = "[GNSU01] ".GetMessage("SUPZ_NO_QSTRING").". ";
1104
1105 return "E";
1106 }
1107
1109 preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $updateServerQueryString)
1110 );
1111
1112 $stime = microtime(true);
1113
1114 $content = CUpdateClientPartner::__GetHTTPPage("STEPM", $updateServerQueryString, $errorMessage);
1115 if ($content == '')
1116 {
1117 if ($errorMessage == '')
1118 $errorMessage = "[GNSU02] ".GetMessage("SUPZ_EMPTY_ANSWER").". ";
1120
1121 return "E";
1122 }
1123
1125 "TIME LoadModulesUpdates(request) ".round(microtime(true) - $stime,3)." sec"
1126 );
1127
1129 if ($errorMessage <> '')
1130 {
1132
1133 return "E";
1134 }
1135
1136 if (isset($arUpdateDescription["DATA"]["#"]["ERROR"]))
1137 {
1138 for ($i = 0, $cnt = count($arUpdateDescription["DATA"]["#"]["ERROR"]); $i < $cnt; $i++)
1139 $errorMessage .= "[".$arUpdateDescription["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"]."] ".$arUpdateDescription["DATA"]["#"]["ERROR"][$i]["#"];
1140 }
1141
1142 if ($errorMessage <> '')
1143 {
1145
1146 return "E";
1147 }
1148
1149 if (isset($arUpdateDescription["DATA"]["#"]["NOUPDATES"]))
1150 {
1151 CUpdateClientPartner::AddMessage2Log("Finish - NOUPDATES", "STEP");
1152
1153 return "F";
1154 }
1155
1156 if (!($fp1 = fopen($filename.".log", "wb")))
1157 {
1158 $errorMessage = "[GNSU03] ".GetMessage("SUPP_RV_ER_TEMP_FILE", ["#FILE#" => $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates"]).". ";
1160
1161 return "E";
1162 }
1163
1164 fwrite($fp1, $content);
1165 fclose($fp1);
1166
1168
1169 return "S";
1170 }
1171
1172 if (isset($arUpdateDescription["DATA"]["#"]["FILE"][0]["@"]["NAME"]))
1173 {
1174 if ($updateServerQueryString == "")
1175 {
1176 $updateServerQueryString = CUpdateClientPartner::__CollectRequestData(
1177 $errorMessage, $lang, $stableVersionsOnly, $arRequestedModules, array(), $bStrongList
1178 );
1179 if (empty($updateServerQueryString) || $errorMessage <> '')
1180 {
1181 if ($errorMessage == '')
1182 $errorMessage = "[GNSU01] ".GetMessage("SUPZ_NO_QSTRING").". ";
1184
1185 return "E";
1186 }
1187 }
1188
1190 $r = static::loadFileBx(
1191 $arUpdateDescription["DATA"]["#"]["FILE"][0]["@"]["NAME"],
1192 $arUpdateDescription["DATA"]["#"]["FILE"][0]["@"]["SIZE"],
1193 $filename,
1194 $timeout,
1195 $updateServerQueryString,
1197 );
1198 }
1199 elseif ($arUpdateDescription["DATA"]["#"]["FILE"][0]["@"]["URL"])
1200 {
1202 $r = static::loadFile(
1203 $arUpdateDescription["DATA"]["#"]["FILE"][0]["@"]["URL"],
1204 $arUpdateDescription["DATA"]["#"]["FILE"][0]["@"]["SIZE"],
1205 $filename,
1206 $timeout,
1208 );
1209 }
1210 else
1211 {
1212 $r = "E";
1213 $errorMessage .= GetMessage("SUPP_PSD_BAD_RESPONSE");
1214 }
1215
1216 if ($r == "E")
1217 {
1220 }
1221 elseif ($r == "U")
1222 {
1223 @unlink($filename.".log");
1224 }
1225
1227
1228 return $r;
1229 }
1230
1231 private static function getAddr()
1232 {
1233 $serverIp = COption::GetOptionString("main", "update_site", DEFAULT_UPDATE_SERVER);
1234 $https = COption::GetOptionString("main", "update_use_https", "N") == "Y";
1235 $proxyAddr = COption::GetOptionString("main", "update_site_proxy_addr", "");
1236 $proxyPort = COption::GetOptionString("main", "update_site_proxy_port", "");
1237 $proxyUserName = COption::GetOptionString("main", "update_site_proxy_user", "");
1238 $proxyPassword = COption::GetOptionString("main", "update_site_proxy_pass", "");
1239
1240 $useProxy = ($proxyAddr <> '' && $proxyPort <> '');
1241
1242 $result = array(
1243 "USE_PROXY" => $useProxy,
1244 "IP" => $serverIp,
1245 "SOCKET_IP" => ($https ? 'tls://' : '') . $serverIp,
1246 "SOCKET_PORT" => ($https ? 443 : 80),
1247 );
1248
1249 if ($useProxy)
1250 {
1251 $proxyPort = intval($proxyPort);
1252 if ($proxyPort <= 0)
1253 $proxyPort = 80;
1254
1255 $result["SOCKET_IP"] = $proxyAddr;
1256 $result["SOCKET_PORT"] = $proxyPort;
1257 $result["PROXY_USERNAME"] = $proxyUserName;
1258 $result["PROXY_PASSWORD"] = $proxyPassword;
1259 }
1260
1261 return $result;
1262 }
1263
1264 private static function getSocketError($errstr, $errno, $addrParams)
1265 {
1266 $error = GetMessage("SUPP_GHTTP_ER").": [".$errno."] ".$errstr.". ";
1267 if (intval($errno) <= 0)
1268 $error .= GetMessage("SUPP_GHTTP_ER_DEF")." ";
1269
1271 "Error connecting to ".$addrParams["SOCKET_IP"].": [".$errno."] ".$errstr, "ERRCONN1"
1272 );
1273
1274 return $error;
1275 }
1276
1277 private static function loadFileBx($requestedUrl, $realSize, $outputFilename, $timeout, $requestQueryString, &$errorMessage)
1278 {
1279 $timeout = intval($timeout);
1280 $startTime = 0;
1281 if ($timeout > 0)
1282 $startTime = microtime(true);
1283
1284 $addrParams = static::getAddr();
1285
1286 $socketHandler = fsockopen($addrParams["SOCKET_IP"], $addrParams["SOCKET_PORT"], $errorNum, $errorMsg, 30);
1287 if (!$socketHandler)
1288 {
1289 $errorMessage .= static::getSocketError($errorMsg, $errorNum, $addrParams);
1290 return "E";
1291 }
1292
1293 $request = "";
1294 if ($addrParams["USE_PROXY"])
1295 {
1296 $request .= "POST http://".$addrParams["IP"]."/bitrix/updates/smp_updater_modules.php HTTP/1.0\r\n";
1297 if ($addrParams["PROXY_USERNAME"])
1298 $request .= "Proxy-Authorization: Basic ".base64_encode(
1299 $addrParams["PROXY_USERNAME"].":".$addrParams["PROXY_PASSWORD"]
1300 )."\r\n";
1301 }
1302 else
1303 {
1304 $request .= "POST /bitrix/updates/smp_updater_modules.php HTTP/1.0\r\n";
1305 }
1306
1307 $requestQueryString .= "&UFILE=".$requestedUrl;
1308 $startSize = (file_exists($outputFilename.".tmp") ? filesize($outputFilename.".tmp") : 0);
1309 $requestQueryString .= "&USTART=".$startSize."&verfix=2";
1310
1311 $request .= "User-Agent: BitrixSMUpdater\r\n";
1312 $request .= "Accept: */*\r\n";
1313 $request .= "Host: ".$addrParams["IP"]."\r\n";
1314 $request .= "Accept-Language: en\r\n";
1315 $request .= "Content-type: application/x-www-form-urlencoded\r\n";
1316 $request .= "Content-length: ".strlen($requestQueryString)."\r\n\r\n";
1317 $request .= $requestQueryString;
1318 $request .= "\r\n";
1319
1320 fputs($socketHandler, $request);
1321
1322 $replyHeader = "";
1323 while (($result = fgets($socketHandler, 4096)) && $result != "\r\n")
1324 $replyHeader .= $result;
1325
1326 $replyHeaderArray = preg_split("#\r\n#", $replyHeader);
1327
1328 $contentLength = 0;
1329 for ($i = 0, $cnt = count($replyHeaderArray); $i < $cnt; $i++)
1330 {
1331 if (str_contains($replyHeaderArray[$i], "Content-Length"))
1332 {
1333 $pos = mb_strpos($replyHeaderArray[$i], ":");
1334 $contentLength = intval(trim(mb_substr($replyHeaderArray[$i], $pos + 1, mb_strlen($replyHeaderArray[$i]) - $pos + 1)));
1335 }
1336 }
1337
1338 if (($contentLength + $startSize) != $realSize)
1339 {
1340 $errorMessage .= "[ELVL001] ".GetMessage("ELVL001_SIZE_ERROR").". ";
1341 return "E";
1342 }
1343
1344 @unlink($outputFilename.".tmp1");
1345
1346 if (file_exists($outputFilename.".tmp"))
1347 {
1348 if (@rename($outputFilename.".tmp", $outputFilename.".tmp1"))
1349 {
1350 $fileHandler = fopen($outputFilename.".tmp", "wb");
1351 if ($fileHandler)
1352 {
1353 $fh1 = fopen($outputFilename.".tmp1", "rb");
1354 do
1355 {
1356 $data = fread($fh1, 8192);
1357 if ($data == '')
1358 break;
1359 fwrite($fileHandler, $data);
1360 }
1361 while (true);
1362
1363 fclose($fh1);
1364 @unlink($outputFilename.".tmp1");
1365 }
1366 else
1367 {
1368 $errorMessage .= "[JUHYT002] ".GetMessage("JUHYT002_ERROR_FILE").". ";
1369 return "E";
1370 }
1371 }
1372 else
1373 {
1374 $errorMessage .= "[JUHYT003] ".GetMessage("JUHYT003_ERROR_FILE").". ";
1375 return "E";
1376 }
1377 }
1378 else
1379 {
1380 $fileHandler = fopen($outputFilename.".tmp", "wb");
1381 if (!$fileHandler)
1382 {
1383 $errorMessage .= "[JUHYT004] ".GetMessage("JUHYT004_ERROR_FILE").". ";
1384 return "E";
1385 }
1386 }
1387
1388 $isFinished = true;
1389 while (true)
1390 {
1391 if ($timeout > 0 && (microtime(true) - $startTime) > $timeout)
1392 {
1393 $isFinished = false;
1394 break;
1395 }
1396
1397 $result = fread($socketHandler, 40960);
1398 if ($result == "")
1399 break;
1400
1401 fwrite($fileHandler, $result);
1402 }
1403
1404 fclose($fileHandler);
1405 fclose($socketHandler);
1406
1407 CUpdateClientPartner::AddMessage2Log("Time - ".(microtime(true) - $startTime)." sec", "DOWNLOAD");
1408
1409 $sizeTmp = (file_exists($outputFilename.".tmp") ? filesize($outputFilename.".tmp") : 0);
1410 if ($sizeTmp == $realSize)
1411 {
1412 $isFinished = true;
1413 }
1414
1415 if ($isFinished)
1416 {
1417 @unlink($outputFilename);
1418 if (!@rename($outputFilename.".tmp", $outputFilename))
1419 {
1420 $errorMessage .= "[JUHYT005] ".GetMessage("JUHYT005_ERROR_FILE").". ";
1421 return "E";
1422 }
1423 @unlink($outputFilename.".tmp");
1424 }
1425 else
1426 {
1427 return "S";
1428 }
1429
1430 return "U";
1431 }
1432
1433 private static function loadFile($requestedUrl, $realSize, $outputFilename, $timeout, &$errorMessage)
1434 {
1435 $timeout = intval($timeout);
1436 $startTime = 0;
1437 if ($timeout > 0)
1438 $startTime = microtime(true);
1439
1440 $startSize = file_exists($outputFilename.".tmp") ? filesize($outputFilename.".tmp") : 0;
1441
1442 $addrParams = static::getAddr();
1443
1444 $socketHandler = fsockopen($addrParams["SOCKET_IP"], $addrParams["SOCKET_PORT"], $errorNum, $errorMsg, 30);
1445 if (!$socketHandler)
1446 {
1447 $errorMessage .= static::getSocketError($errorMsg, $errorNum, $addrParams);
1448 return "E";
1449 }
1450
1451 if (!$requestedUrl)
1452 $requestedUrl = "/";
1453
1454 $request = "";
1455 if (!$addrParams["USE_PROXY"])
1456 {
1457 $request .= "GET ".$requestedUrl." HTTP/1.0\r\n";
1458 $request .= "Host: ".$addrParams["IP"]."\r\n";
1459 }
1460 else
1461 {
1462 $request .= "GET http://".$addrParams["IP"].$requestedUrl." HTTP/1.0\r\n";
1463 $request .= "Host: ".$addrParams["IP"]."\r\n";
1464 if ($addrParams["PROXY_USERNAME"])
1465 $request .= "Proxy-Authorization: Basic ".base64_encode($addrParams["PROXY_USERNAME"].":".$addrParams["PROXY_PASSWORD"])."\r\n";
1466 }
1467
1468 $request .= "User-Agent: BitrixSMUpdater\r\n";
1469 if ($startSize > 0)
1470 $request .= "Range: bytes=".$startSize."-\r\n";
1471
1472 $request .= "\r\n";
1473
1474 fwrite($socketHandler, $request);
1475
1476 $replyHeader = "";
1477 while (($result = fgets($socketHandler, 4096)) && $result!="\r\n")
1478 $replyHeader .= $result;
1479
1480 $replyHeaderArray = preg_split("#\r\n#", $replyHeader);
1481
1482 $replycode = 0;
1483 $replymsg = "";
1484 if (preg_match("#([A-Z]{4})/([0-9.]{3}) ([0-9]{3})#", $replyHeaderArray[0], $regs))
1485 {
1486 $replycode = intval($regs[3]);
1487 $replymsg = mb_substr($replyHeaderArray[0], mb_strpos($replyHeaderArray[0], $replycode) + mb_strlen($replycode) + 1, mb_strlen($replyHeaderArray[0]) - mb_strpos($replyHeaderArray[0], $replycode) + 1);
1488 }
1489
1490 if ($replycode != 200 && $replycode != 204 && $replycode != 302 && $replycode != 206)
1491 {
1492 $errorMessage .= GetMessage("SUPP_PSD_BAD_RESPONSE")." (".$replycode." - ".$replymsg.")";
1493 return "E";
1494 }
1495
1496 $replyContentRange = "";
1497 $replyContentLength = 0;
1498 for ($i = 1; $i < count($replyHeaderArray); $i++)
1499 {
1500 if (str_contains($replyHeaderArray[$i], "Content-Range"))
1501 $replyContentRange = trim(mb_substr($replyHeaderArray[$i], mb_strpos($replyHeaderArray[$i], ":") + 1, mb_strlen($replyHeaderArray[$i]) - mb_strpos($replyHeaderArray[$i], ":") + 1));
1502 elseif (str_contains($replyHeaderArray[$i], "Content-Length"))
1503 $replyContentLength = doubleval(trim(mb_substr($replyHeaderArray[$i], mb_strpos($replyHeaderArray[$i], ":") + 1, mb_strlen($replyHeaderArray[$i]) - mb_strpos($replyHeaderArray[$i], ":") + 1)));
1504 }
1505
1506 $shouldReloadFile = true;
1507 if ($replyContentRange <> '')
1508 {
1509 if (preg_match("# *bytes +([0-9]*) *- *([0-9]*) */ *([0-9]*)#i", $replyContentRange, $regs))
1510 {
1511 $startBytesTmp = doubleval($regs[1]);
1512 $endBytesTmp = doubleval($regs[2]);
1513 $sizeBytesTmp = doubleval($regs[3]);
1514 if (($startBytesTmp == $startSize) && ($endBytesTmp == ($realSize - 1)) && ($sizeBytesTmp == $realSize))
1515 {
1516 $shouldReloadFile = false;
1517 }
1518 }
1519 }
1520
1521 if ($shouldReloadFile)
1522 {
1523 @unlink($outputFilename.".tmp");
1524 $startSize = 0;
1525 }
1526
1527 if (($replyContentLength + $startSize) != $realSize)
1528 {
1529 $errorMessage .= "[ELVL010] ".GetMessage("ELVL001_SIZE_ERROR").". ";
1530 return "E";
1531 }
1532
1533 $fileHandler = fopen($outputFilename.".tmp", "ab");
1534 if (!$fileHandler)
1535 {
1536 $errorMessage .= "[JUHYT010] ".GetMessage("JUHYT002_ERROR_FILE").". ";
1537 return "E";
1538 }
1539
1540 $isFinished = true;
1541 while (true)
1542 {
1543 if ($timeout > 0 && (microtime(true) - $startTime) > $timeout)
1544 {
1545 $isFinished = false;
1546 break;
1547 }
1548
1549 $result = fread($socketHandler, 256 * 1024);
1550 if ($result == "")
1551 break;
1552
1553 fwrite($fileHandler, $result);
1554 }
1555
1556 fclose($fileHandler);
1557 fclose($socketHandler);
1558
1559 $sizeTmp = (file_exists($outputFilename.".tmp") ? filesize($outputFilename.".tmp") : 0);
1560 if ($sizeTmp == $realSize)
1561 {
1562 $isFinished = true;
1563 }
1564
1565 if ($isFinished)
1566 {
1567 @unlink($outputFilename);
1568 if (!@rename($outputFilename.".tmp", $outputFilename))
1569 {
1570 $errorMessage .= "[JUHYT010] ".GetMessage("JUHYT005_ERROR_FILE").". ";
1571 return "E";
1572 }
1573 @unlink($outputFilename.".tmp");
1574 }
1575 else
1576 {
1577 return "S";
1578 }
1579
1580 return "U";
1581 }
1582
1583 public static function UpdateStepModules($updatesDir, &$strError, $bSaveUpdaters = false)
1584 {
1585 global $DB;
1586 $strError_tmp = "";
1587
1588 if (!defined("US_SAVE_UPDATERS_DIR") || US_SAVE_UPDATERS_DIR == '')
1589 $bSaveUpdaters = false;
1590
1591 $stime = microtime(true);
1592
1593 $updatesDirFull = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$updatesDir;
1594
1595 if (!file_exists($updatesDirFull) || !is_dir($updatesDirFull))
1596 $strError_tmp .= "[UUK01] ".GetMessage("SUPP_CU_NO_TMP_CAT", ["#FILE#" => $updatesDirFull]).". ";
1597
1598 if ($strError_tmp == '')
1599 if (!is_readable($updatesDirFull))
1600 $strError_tmp .= "[UUK03] ".GetMessage("SUPP_CU_RD_TMP_CAT", ["#FILE#" => $updatesDirFull]).". ";
1601
1602 $arModules = array();
1603 if ($strError_tmp == '')
1604 {
1605 $handle = @opendir($updatesDirFull);
1606 if ($handle)
1607 {
1608 while (false !== ($dir = readdir($handle)))
1609 {
1610 if ($dir == "." || $dir == "..")
1611 continue;
1612 if (is_dir($updatesDirFull."/".$dir))
1613 $arModules[] = $dir;
1614 }
1615 closedir($handle);
1616 }
1617 }
1618
1619 if (!is_array($arModules) || empty($arModules))
1620 $strError_tmp .= "[UUK02] ".GetMessage("SUPP_UK_NO_MODS").". ";
1621
1622 if ($strError_tmp == '')
1623 {
1624 for ($i = 0, $cnt = count($arModules); $i < $cnt; $i++)
1625 {
1626 $strError_tmp1 = "";
1627
1628 $updateDirFrom = $updatesDirFull."/".$arModules[$i];
1629 $updateDirTo = $_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/modules/".$arModules[$i];
1630
1631 CUpdateClientPartner::__CheckDirPath($updateDirTo."/");
1632
1633 if (!file_exists($updateDirTo) || !is_dir($updateDirTo))
1634 $strError_tmp1 .= "[UUK04] ".GetMessage("SUPP_UK_NO_MODIR", ["#MODULE_DIR#" => $updateDirTo]).". ";
1635
1636 if ($strError_tmp1 == '')
1637 if (!is_writable($updateDirTo))
1638 $strError_tmp1 .= "[UUK05] ".GetMessage("SUPP_UK_WR_MODIR", ["#MODULE_DIR#" => $updateDirTo]).". ";
1639
1640 if ($strError_tmp1 == '')
1641 if (!file_exists($updateDirFrom) || !is_dir($updateDirFrom))
1642 $strError_tmp1 .= "[UUK06] ".GetMessage("SUPP_UK_NO_FDIR", ["#DIR#" => $updateDirFrom]).". ";
1643
1644 if ($strError_tmp1 == '')
1645 if (!is_readable($updateDirFrom))
1646 $strError_tmp1 .= "[UUK07] ".GetMessage("SUPP_UK_READ_FDIR", ["#DIR#" => $updateDirFrom]).". ";
1647
1648 $arUpdaters = array();
1649 if ($strError_tmp1 == '')
1650 {
1651 $handle = @opendir($updateDirFrom);
1652 if ($handle)
1653 {
1654 while (false !== ($dir = readdir($handle)))
1655 {
1656 if (str_starts_with($dir, "updater"))
1657 {
1658 $bPostUpdater = "N";
1659 if (is_file($updateDirFrom."/".$dir))
1660 {
1661 $num = mb_substr($dir, 7, mb_strlen($dir) - 11);
1662 if (mb_substr($dir, mb_strlen($dir) - 9) == "_post.php")
1663 {
1664 $bPostUpdater = "Y";
1665 $num = mb_substr($dir, 7, mb_strlen($dir) - 16);
1666 }
1667 $arUpdaters[] = array("/".$dir, trim($num), $bPostUpdater);
1668 }
1669 elseif (file_exists($updateDirFrom."/".$dir."/index.php"))
1670 {
1671 $num = mb_substr($dir, 7);
1672 if (mb_substr($dir, mb_strlen($dir) - 5) == "_post")
1673 {
1674 $bPostUpdater = "Y";
1675 $num = mb_substr($dir, 7, mb_strlen($dir) - 12);
1676 }
1677 $arUpdaters[] = array("/".$dir."/index.php", trim($num), $bPostUpdater);
1678 }
1679
1680 if ($bSaveUpdaters)
1681 CUpdateClientPartner::__CopyDirFiles($updateDirFrom."/".$dir, $_SERVER["DOCUMENT_ROOT"].US_SAVE_UPDATERS_DIR."/".$arModules[$i]."/".$dir, $strError_tmp1, false);
1682 }
1683 }
1684 closedir($handle);
1685 }
1686
1687 $n = count($arUpdaters);
1688 for ($i1 = 0; $i1 < $n - 1; $i1++)
1689 {
1690 for ($j1 = $i1 + 1; $j1 < $n; $j1++)
1691 {
1692 if (CUpdateClientPartner::__CompareVersions($arUpdaters[$i1][1], $arUpdaters[$j1][1]) > 0)
1693 {
1694 $tmp1 = $arUpdaters[$i1];
1695 $arUpdaters[$i1] = $arUpdaters[$j1];
1696 $arUpdaters[$j1] = $tmp1;
1697 }
1698 }
1699 }
1700 }
1701
1702 if ($strError_tmp1 == '')
1703 {
1704 if ($DB->type == "MYSQL" && defined("MYSQL_TABLE_TYPE") && MYSQL_TABLE_TYPE <> '')
1705 {
1706 $DB->Query("SET storage_engine = '".MYSQL_TABLE_TYPE."'", true);
1707 }
1708 }
1709
1710 if ($strError_tmp1 == '')
1711 {
1712 for ($i1 = 0, $n = count($arUpdaters); $i1 < $n; $i1++)
1713 {
1714 if ($arUpdaters[$i1][2] == "N")
1715 {
1716 $strError_tmp2 = "";
1717 CUpdateClientPartner::__RunUpdaterScript($updateDirFrom.$arUpdaters[$i1][0], $strError_tmp2, "/bitrix/updates/".$updatesDir."/".$arModules[$i], $arModules[$i]);
1718 if ($strError_tmp2 <> '')
1719 {
1720 $strError_tmp1 .= GetMessage("SUPP_UK_UPDN_ERR", [
1721 "#VER#" => $arUpdaters[$i1][1],
1722 "#MODULE#", $arModules[$i],
1723 ])
1724 . ": "
1725 . $strError_tmp2
1726 . ". "
1727 . GetMessage("SUPP_UK_UPDN_ERR_BREAK", ["#MODULE#" => $arModules[$i]])
1728 . " ";
1729 break;
1730 }
1731 }
1732 }
1733 }
1734
1735 if ($strError_tmp1 == '')
1736 CUpdateClientPartner::__CopyDirFiles($updateDirFrom, $updateDirTo, $strError_tmp1);
1737
1738 if ($strError_tmp1 == '')
1739 {
1740 for ($i1 = 0, $n = count($arUpdaters); $i1 < $n; $i1++)
1741 {
1742 if ($arUpdaters[$i1][2]=="Y")
1743 {
1744 $strError_tmp2 = "";
1745 CUpdateClientPartner::__RunUpdaterScript($updateDirFrom.$arUpdaters[$i1][0], $strError_tmp2, "/bitrix/updates/".$updatesDir."/".$arModules[$i], $arModules[$i]);
1746 if ($strError_tmp2 <> '')
1747 {
1748 $strError_tmp1 .= GetMessage("SUPP_UK_UPDY_ERR", [
1749 "#VER#" => $arUpdaters[$i1][1],
1750 "#MODULE#" => $arModules[$i],
1751 ])
1752 . ": "
1753 . $strError_tmp2
1754 . ". "
1755 . GetMessage("SUPP_UK_UPDN_ERR_BREAK", ["#MODULE#" => $arModules[$i]])
1756 . " ";
1757 break;
1758 }
1759 }
1760 }
1761 }
1762
1763 if ($strError_tmp1 <> '')
1764 $strError_tmp .= $strError_tmp1;
1765 }
1767 }
1768
1769 CUpdateClientPartner::AddMessage2Log("TIME UpdateStepModules ".round(microtime(true) - $stime,3)." sec");
1770
1771 if ($strError_tmp <> '')
1772 {
1773 CUpdateClientPartner::AddMessage2Log($strError_tmp, "USM");
1774 $strError .= $strError_tmp;
1775 return false;
1776 }
1777 else
1778 {
1779 foreach(GetModuleEvents("main", "OnModuleUpdate", true) as $arEvent)
1780 ExecuteModuleEventEx($arEvent, array($arModules));
1781
1782 return true;
1783 }
1784 }
1785
1786 public static function ActivateCoupon($coupon, &$strError, $lang = false, $stableVersionsOnly = "Y")
1787 {
1788 $strError_tmp = "";
1789
1790 CUpdateClientPartner::AddMessage2Log("exec CUpdateClientPartner::ActivateCoupon");
1791
1792 $strQuery = CUpdateClientPartner::__CollectRequestData($strError_tmp, $lang, $stableVersionsOnly);
1793 if ($strQuery == '' || $strError_tmp <> '')
1794 {
1795 if ($strError_tmp == '')
1796 $strError_tmp = "[RV01] ".GetMessage("SUPZ_NO_QSTRING").". ";
1797 }
1798
1799 if (CModule::IncludeModule("rest") && !\Bitrix\Rest\OAuthService::getEngine()->isRegistered())
1800 {
1801 try
1802 {
1804 \Bitrix\Rest\OAuthService::getEngine()->getClient()->getApplicationList();
1805 }
1806 catch(\Bitrix\Main\SystemException)
1807 {
1808 }
1809 }
1810
1811 if ($strError_tmp == '')
1812 {
1813 $strQuery .= "&coupon=".UrlEncode($coupon)."&query_type=coupon";
1814 CUpdateClientPartner::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strQuery));
1815
1816 /*
1817 foreach ($arFields as $key => $value)
1818 $strQuery .= "&".$key."=".urlencode($value);
1819 */
1820
1821 $stime = microtime(true);
1822 $content = CUpdateClientPartner::__GetHTTPPage("ACTIV", $strQuery, $strError_tmp);
1823 if ($content == '')
1824 {
1825 if ($strError_tmp == '')
1826 $strError_tmp = "[GNSU02] ".GetMessage("SUPZ_EMPTY_ANSWER").". ";
1827 }
1828
1829 CUpdateClientPartner::AddMessage2Log("TIME ActivateCoupon(request) ".round(microtime(true) - $stime,3)." sec");
1830 }
1831
1832 if ($strError_tmp == '')
1833 {
1834 $arRes = Array();
1836 }
1837
1838 if ($strError_tmp == '')
1839 {
1840 if (!empty($arRes["DATA"]["#"]["ERROR"]) && is_array($arRes["DATA"]["#"]["ERROR"]))
1841 {
1842 for ($i = 0, $n = count($arRes["DATA"]["#"]["ERROR"]); $i < $n; $i++)
1843 {
1844 if ($arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"] <> '')
1845 $strError_tmp .= "[".$arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"]."] ";
1846
1847 $strError_tmp .= $arRes["DATA"]["#"]["ERROR"][$i]["#"].". ";
1848 }
1849 }
1850 }
1851
1852 if ($strError_tmp <> '')
1853 {
1854 CUpdateClientPartner::AddMessage2Log($strError_tmp, "AC");
1855 $strError .= $strError_tmp;
1856 return false;
1857 }
1858 else
1859 return true;
1860 }
1861
1863 public static function __RunUpdaterScript($path, &$strError, $updateDirFrom, $moduleID)
1864 {
1865 global $DBType, $DB, $APPLICATION, $USER;
1866
1867 if (!isset($GLOBALS["UPDATE_STRONG_UPDATE_CHECK"])
1868 || ($GLOBALS["UPDATE_STRONG_UPDATE_CHECK"] != "Y" && $GLOBALS["UPDATE_STRONG_UPDATE_CHECK"] != "N"))
1869 {
1870 $GLOBALS["UPDATE_STRONG_UPDATE_CHECK"] = ((US_CALL_TYPE != "DB") ? COption::GetOptionString("main", "strong_update_check", "Y") : "Y");
1871 }
1872 $strongUpdateCheck = $GLOBALS["UPDATE_STRONG_UPDATE_CHECK"];
1873
1874 $DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"];
1875
1876 $path = str_replace("\\", "/", $path);
1877 $updaterPath = dirname($path);
1878 $updaterPath = mb_substr($updaterPath, mb_strlen($_SERVER["DOCUMENT_ROOT"]));
1879 $updaterPath = trim($updaterPath," \t\n\r\0\x0B/\\");
1880 if ($updaterPath <> '')
1881 $updaterPath = "/".$updaterPath;
1882
1883 $updaterName = mb_substr($path, mb_strlen($_SERVER["DOCUMENT_ROOT"]));
1884
1885 CUpdateClientPartner::AddMessage2Log("Run updater '".$updaterName."'", "CSURUS1");
1886
1887 $updater = new CUpdater();
1888 $updater->Init($updaterPath, $DB->type, $updaterName, $updateDirFrom, $moduleID, US_CALL_TYPE);
1889
1890 $errorMessage = "";
1891
1892 include($path);
1893
1894 if ($errorMessage <> '')
1896 if (is_array($updater->errorMessage) && !empty($updater->errorMessage))
1897 $strError .= implode("\n", $updater->errorMessage);
1898
1899 unset($updater);
1900 }
1901
1906 public static function __CompareVersions($strVers1, $strVers2)
1907 {
1908 $strVers1 = trim($strVers1);
1909 $strVers2 = trim($strVers2);
1910
1911 if ($strVers1 == $strVers2)
1912 return 0;
1913
1914 $arVers1 = explode(".", $strVers1);
1915 $arVers2 = explode(".", $strVers2);
1916
1917 if (intval($arVers1[0]) > intval($arVers2[0])
1918 || intval($arVers1[0]) == intval($arVers2[0]) && intval($arVers1[1]) > intval($arVers2[1])
1919 || intval($arVers1[0]) == intval($arVers2[0]) && intval($arVers1[1]) == intval($arVers2[1]) && intval($arVers1[2]) > intval($arVers2[2]))
1920 {
1921 return 1;
1922 }
1923
1924 if (intval($arVers1[0]) == intval($arVers2[0]) && intval($arVers1[1]) == intval($arVers2[1]) && intval($arVers1[2]) == intval($arVers2[2]))
1925 {
1926 return 0;
1927 }
1928
1929 return -1;
1930 }
1931
1937 public static function __GetHTTPPage($page, $strVars, &$strError)
1938 {
1939 CUpdateClientPartner::AddMessage2Log("exec CUpdateClientPartner::GetHTTPPage");
1940
1941 if ($page == "LIST")
1942 $page = "smp_updater_list.php";
1943 elseif ($page == "STEPM")
1944 $page = "smp_updater_modules.php";
1945 elseif ($page == "SEARCH")
1946 $page = "smp_updater_search.php";
1947 elseif ($page == "MODULE")
1948 $page = "smp_updater_actions.php";
1949 elseif ($page == "REG")
1950 $page = "smp_updater_register.php";
1951 elseif ($page == "ACTIV")
1952 $page = "us_updater_actions.php";
1953 elseif ($page == "SEARCH_NEW")
1954 $page = "smp_updater_search_new.php";
1955
1956 $strVars .= "&product=".(IsModuleInstalled("intranet") ? "CORPORTAL" : "BSM")."&verfix=2";
1957
1958 $addrParams = static::getAddr();
1959
1960 $FP = fsockopen($addrParams["SOCKET_IP"], $addrParams["SOCKET_PORT"], $errno, $errstr, 120);
1961
1962 if ($FP)
1963 {
1964 $strRequest = "";
1965
1966 if ($addrParams["USE_PROXY"])
1967 {
1968 $strRequest .= "POST http://".$addrParams["IP"]."/bitrix/updates/".$page." HTTP/1.0\r\n";
1969 if ($addrParams["PROXY_USERNAME"] <> '')
1970 $strRequest .= "Proxy-Authorization: Basic ".base64_encode($addrParams["PROXY_USERNAME"].":".$addrParams["PROXY_PASSWORD"])."\r\n";
1971 }
1972 else
1973 {
1974 $strRequest .= "POST /bitrix/updates/".$page." HTTP/1.0\r\n";
1975 }
1976
1977 $strRequest .= "User-Agent: BitrixSMUpdater\r\n";
1978 $strRequest .= "Accept: */*\r\n";
1979 $strRequest .= "Host: ".$addrParams["IP"]."\r\n";
1980 $strRequest .= "Accept-Language: en\r\n";
1981 $strRequest .= "Content-type: application/x-www-form-urlencoded\r\n";
1982 $strRequest .= "Content-length: ".strlen($strVars)."\r\n\r\n";
1983 $strRequest .= $strVars;
1984 $strRequest .= "\r\n";
1985
1986 fputs($FP, $strRequest);
1987
1988 $bChunked = false;
1989 while (!feof($FP))
1990 {
1991 $line = fgets($FP, 4096);
1992 if ($line != "\r\n")
1993 {
1994 if (preg_match("/Transfer-Encoding: +chunked/i", $line))
1995 $bChunked = true;
1996 }
1997 else
1998 {
1999 break;
2000 }
2001 }
2002
2003 $content = "";
2004 if ($bChunked)
2005 {
2006 $maxReadSize = 4096;
2007
2008 $line = fgets($FP, $maxReadSize);
2009 $line = mb_strtolower($line);
2010
2011 $strChunkSize = "";
2012 $i = 0;
2013 while ($i < mb_strlen($line) && in_array($line[$i], array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f")))
2014 {
2015 $strChunkSize .= $line[$i];
2016 $i++;
2017 }
2018
2019 $chunkSize = hexdec($strChunkSize);
2020
2021 while ($chunkSize > 0)
2022 {
2023 $processedSize = 0;
2024 $readSize = (($chunkSize > $maxReadSize) ? $maxReadSize : $chunkSize);
2025
2026 while ($readSize > 0 && $line = fread($FP, $readSize))
2027 {
2028 $content .= $line;
2029 $processedSize += mb_strlen($line);
2030 $newSize = $chunkSize - $processedSize;
2031 $readSize = (($newSize > $maxReadSize) ? $maxReadSize : $newSize);
2032 }
2033
2034 fgets($FP, $maxReadSize);
2035
2036 $line = fgets($FP, $maxReadSize);
2037 $line = strtolower($line);
2038
2039 $strChunkSize = "";
2040 $i = 0;
2041 while ($i < strlen($line) && in_array($line[$i], array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f")))
2042 {
2043 $strChunkSize .= $line[$i];
2044 $i++;
2045 }
2046
2047 $chunkSize = hexdec($strChunkSize);
2048 }
2049 }
2050 else
2051 {
2052 while ($line = fread($FP, 4096))
2053 $content .= $line;
2054 }
2055
2056 fclose($FP);
2057 }
2058 else
2059 {
2060 $content = "";
2061 $strError .= GetMessage("SUPP_GHTTP_ER").": [".$errno."] ".$errstr.". ";
2062 if ($errno <= 0)
2063 $strError .= GetMessage("SUPP_GHTTP_ER_DEF")." ";
2064
2065 CUpdateClientPartner::AddMessage2Log("Error connecting to ".$addrParams["IP"].": [".$errno."] ".$errstr, "ERRCONN");
2066 }
2067
2068 return $content;
2069 }
2070
2073 public static function __ParseServerData(&$strServerOutput, &$arRes, &$strError)
2074 {
2075 $strError_tmp = "";
2076 $arRes = array();
2077
2078 CUpdateClientPartner::AddMessage2Log("exec CUpdateClientPartner::ParseServerData");
2079
2080 //CUpdateClientPartner::AddMessage2Log($strServerOutput, "!2!");
2081 //echo "strServerOutput:<br>".htmlspecialcharsbx($strServerOutput)."<br><br>";
2082
2083 if ($strServerOutput == '')
2084 $strError_tmp .= "[UPSD01] ".GetMessage("SUPP_AS_EMPTY_RESP").". ";
2085
2086 if ($strError_tmp == '')
2087 {
2088 if (!str_starts_with($strServerOutput, "<DATA>") && CUpdateClientPartner::__IsGzipInstalled())
2089 $strServerOutput = @gzuncompress($strServerOutput);
2090 if (!str_starts_with($strServerOutput, "<DATA>"))
2091 {
2092 CUpdateClientPartner::AddMessage2Log(mb_substr($strServerOutput, 0, 100), "UPSD02");
2093 $strError_tmp .= "[UPSD02] ".GetMessage("SUPP_PSD_BAD_RESPONSE").". ";
2094 }
2095 }
2096 //CUpdateClientPartner::AddMessage2Log($strServerOutput, "!3!");
2097
2098 //echo "strServerOutput:<br>".htmlspecialcharsbx($strServerOutput)."<br><br>";
2099
2100 if ($strError_tmp == '')
2101 {
2102// $arRes = CUpdateClientPartner::xmlize($strServerOutput);
2103
2104 $objXML = new CUpdatesXML();
2105 $objXML->LoadString($strServerOutput);
2106 $arRes = $objXML->GetArray();
2107
2108 if (!is_array($arRes) || !isset($arRes["DATA"]) || !is_array($arRes["DATA"]))
2109 $strError_tmp .= "[UPSD03] ".GetMessage("SUPP_PSD_BAD_TRANS").". ";
2110 }
2111
2112 if ($strError_tmp == '')
2113 {
2114 if (isset($arRes["DATA"]["#"]["RESPONSE"]))
2115 {
2116 $CRCCode = $arRes["DATA"]["#"]["RESPONSE"][0]["@"]["CRC_CODE"];
2117 if ($CRCCode <> '')
2118 COption::SetOptionString(US_BASE_MODULE, "crc_code", $CRCCode);
2119 }
2120 if (isset($arRes["DATA"]["#"]["CLIENT"][0]["@"]["DATE_TO_SOURCE"]))
2121 COption::SetOptionString(US_BASE_MODULE, "~support_finish_date", $arRes["DATA"]["#"]["CLIENT"][0]["@"]["DATE_TO_SOURCE"]);
2122 }
2123
2124 if ($strError_tmp <> '')
2125 {
2126 CUpdateClientPartner::AddMessage2Log($strError_tmp, "CUPSD");
2127 $strError .= $strError_tmp;
2128 return false;
2129 }
2130 else
2131 return true;
2132 }
2133
2135 public static function __IsGzipInstalled()
2136 {
2137 if (function_exists("gzcompress"))
2138 return COption::GetOptionString("main", "update_is_gzip_installed", "Y") == "Y";
2139
2140 return false;
2141 }
2142
2143 public static function __GetFooPath()
2144 {
2145 $db = CLang::GetList("", "", array("ACTIVE" => "Y"));
2146 $cnt = 0;
2147 while ($db->Fetch())
2148 $cnt++;
2149 return $cnt;
2150 }
2151
2153 public static function __CheckDirPath($path, $bPermission = true)
2154 {
2155 $badDirs = Array();
2156 $path = str_replace("\\", "/", $path);
2157 $path = str_replace("//", "/", $path);
2158
2159 if ($path[mb_strlen($path) - 1] != "/") //отрежем имя файла
2160 {
2162 $path = mb_substr($path, 0, $p);
2163 }
2164
2165 while (mb_strlen($path) > 1 && $path[mb_strlen($path) - 1]=="/") //отрежем / в конце, если есть
2166 $path = mb_substr($path, 0, mb_strlen($path) - 1);
2167
2169 while ($p > 0)
2170 {
2171 if (file_exists($path) && is_dir($path))
2172 {
2173 if ($bPermission)
2174 {
2175 if (!is_writable($path))
2176 @chmod($path, BX_DIR_PERMISSIONS);
2177 }
2178 break;
2179 }
2180 $badDirs[] = mb_substr($path, $p + 1);
2181 $path = mb_substr($path, 0, $p);
2183 }
2184
2185 for ($i = count($badDirs)-1; $i>=0; $i--)
2186 {
2187 $path = $path."/".$badDirs[$i];
2188 @mkdir($path, BX_DIR_PERMISSIONS);
2189 }
2190 }
2191
2193 public static function __CopyDirFiles($path_from, $path_to, &$strError, $bSkipUpdater = true)
2194 {
2195 $strError_tmp = "";
2196
2197 while (mb_strlen($path_from) > 1 && $path_from[mb_strlen($path_from) - 1] == "/")
2198 $path_from = mb_substr($path_from, 0, mb_strlen($path_from) - 1);
2199
2200 while (mb_strlen($path_to) > 1 && $path_to[mb_strlen($path_to) - 1] == "/")
2201 $path_to = mb_substr($path_to, 0, mb_strlen($path_to) - 1);
2202
2203 if (mb_strpos($path_to."/", $path_from."/") === 0)
2204 $strError_tmp .= "[UCDF01] ".GetMessage("SUPP_CDF_SELF_COPY").". ";
2205
2206 if ($strError_tmp == '')
2207 {
2208 if (!file_exists($path_from))
2209 $strError_tmp .= "[UCDF02] ".GetMessage("SUPP_CDF_NO_PATH", ["#FILE#" => $path_from]).". ";
2210 }
2211
2212 if ($strError_tmp == '')
2213 {
2214 $strongUpdateCheck = COption::GetOptionString("main", "strong_update_check", "Y");
2215
2216 if (is_dir($path_from))
2217 {
2219
2220 if (!file_exists($path_to) || !is_dir($path_to))
2221 $strError_tmp .= "[UCDF03] ".GetMessage("SUPP_CDF_CANT_CREATE", ["#FILE#" => $path_to]).". ";
2222 elseif (!is_writable($path_to))
2223 $strError_tmp .= "[UCDF04] ".GetMessage("SUPP_CDF_CANT_WRITE", ["#FILE#" => $path_to]).". ";
2224
2225 if ($strError_tmp == '')
2226 {
2227 if ($handle = @opendir($path_from))
2228 {
2229 while (($file = readdir($handle)) !== false)
2230 {
2231 if ($file == "." || $file == "..")
2232 continue;
2233
2234 if ($bSkipUpdater && str_starts_with($file, "updater"))
2235 continue;
2236
2237 if (is_dir($path_from."/".$file))
2238 {
2239 CUpdateClientPartner::__CopyDirFiles($path_from."/".$file, $path_to."/".$file, $strError_tmp);
2240 }
2241 elseif (is_file($path_from."/".$file))
2242 {
2243 if (file_exists($path_to."/".$file) && !is_writable($path_to."/".$file))
2244 {
2245 $strError_tmp .= "[UCDF05] ".GetMessage("SUPP_CDF_CANT_FILE", ["#FILE#" => $path_to."/".$file]).". ";
2246 }
2247 else
2248 {
2249 if ($strongUpdateCheck == "Y")
2250 $crc32_old = dechex(crc32(file_get_contents($path_from."/".$file)));
2251
2252 @copy($path_from."/".$file, $path_to."/".$file);
2253 @chmod($path_to."/".$file, BX_FILE_PERMISSIONS);
2254
2255 if ($strongUpdateCheck == "Y")
2256 {
2257 $crc32_new = dechex(crc32(file_get_contents($path_to."/".$file)));
2258 if ($crc32_new != $crc32_old)
2259 {
2260 $strError_tmp .= "[UCDF061] ".GetMessage("SUPP_UGA_FILE_CRUSH", ["#FILE#" => $path_to."/".$file]).". ";
2261 }
2262 }
2263 }
2264 }
2265 }
2266 @closedir($handle);
2267 }
2268 }
2269 }
2270 else
2271 {
2272 $p = CUpdateClientPartner::__bxstrrpos($path_to, "/");
2273 $path_to_dir = mb_substr($path_to, 0, $p);
2274 CUpdateClientPartner::__CheckDirPath($path_to_dir."/");
2275
2276 if (!file_exists($path_to_dir) || !is_dir($path_to_dir))
2277 $strError_tmp .= "[UCDF06] ".GetMessage("SUPP_CDF_CANT_FOLDER", ["#FILE#" => $path_to_dir]).". ";
2278 elseif (!is_writable($path_to_dir))
2279 $strError_tmp .= "[UCDF07] ".GetMessage("SUPP_CDF_CANT_FOLDER_WR", ["#FILE#" => $path_to_dir]).". ";
2280
2281 if ($strError_tmp == '')
2282 {
2283 if ($strongUpdateCheck == "Y")
2284 $crc32_old = dechex(crc32(file_get_contents($path_from)));
2285
2286 @copy($path_from, $path_to);
2287 @chmod($path_to, BX_FILE_PERMISSIONS);
2288
2289 if ($strongUpdateCheck == "Y")
2290 {
2291 $crc32_new = dechex(crc32(file_get_contents($path_to)));
2292 if ($crc32_new != $crc32_old)
2293 {
2294 $strError_tmp .= "[UCDF0611] ".GetMessage("SUPP_UGA_FILE_CRUSH", ["#FILE#" => $path_to]).". ";
2295 }
2296 }
2297 }
2298 }
2299 }
2300
2301 if ($strError_tmp <> '')
2302 {
2303 CUpdateClientPartner::AddMessage2Log($strError_tmp, "CUCDF");
2304 $strError .= $strError_tmp;
2305 return false;
2306 }
2307 else
2308 return true;
2309 }
2310
2312 public static function __DeleteDirFilesEx($path)
2313 {
2314 if (!file_exists($path))
2315 return false;
2316
2317 if (is_file($path))
2318 {
2319 @unlink($path);
2320 return true;
2321 }
2322
2323 if ($handle = @opendir($path))
2324 {
2325 while (($file = readdir($handle)) !== false)
2326 {
2327 if ($file == "." || $file == "..") continue;
2328
2329 if (is_dir($path."/".$file))
2330 {
2332 }
2333 else
2334 {
2335 @unlink($path."/".$file);
2336 }
2337 }
2338 }
2339 @closedir($handle);
2340 @rmdir($path);
2341 return true;
2342 }
2343
2344 public static function __bxstrrpos($haystack, $needle)
2345 {
2346 $index = mb_strpos(strrev($haystack), strrev($needle));
2347 if($index === false)
2348 return false;
2349 $index = mb_strlen($haystack) - mb_strlen($needle) - $index;
2350 return $index;
2351 }
2352
2354 public static function __GetModuleInfo($path)
2355 {
2356 $module_code = basename($path);
2357 $class_name = str_replace(".", "_", $module_code);
2358
2359 if (!($cls = CModule::CreateModuleObject($module_code)))
2360 {
2361 return array();
2362 }
2363
2364 if (!method_exists($cls, '__construct') && method_exists($cls, $class_name))
2365 {
2366 // old classes don't have a constructor
2367 $cls->$class_name();
2368 }
2369
2370 $result = array(
2371 "VERSION" => $cls->MODULE_VERSION,
2372 "VERSION_DATE" => $cls->MODULE_VERSION_DATE,
2373 "IS_DEMO" => ((defined($class_name."_DEMO") && constant($class_name."_DEMO")) ? "Y" : "N"),
2374 "ACTIVE" => "Y",
2375 );
2376
2377 if($result["IS_DEMO"] == "Y" && IsModuleInstalled($module_code) && CModule::IncludeModuleEx($module_code) == MODULE_DEMO_EXPIRED)
2378 $result["ACTIVE"] = "N";
2379
2380 return $result;
2381 }
2382
2386 public static function __GetMicroTime()
2387 {
2388 return microtime(true);
2389 }
2390}
$path
Определения access_edit.php:21
global $APPLICATION
Определения include.php:80
$arResult
Определения generate_coupon.php:16
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
static getEngine()
Определения oauthservice.php:49
static register()
Определения oauthservice.php:59
static getServersCount()
Определения include.php:47
static ClearUpdateFolder($updatesDirFull)
Определения update_client_partner.php:1055
static __DeleteDirFilesEx($path)
Определения update_client_partner.php:2312
static CheckUpdatability($updatesDir, &$strError)
Определения update_client_partner.php:729
static GetLicenseKey()
Определения update_client_partner.php:539
static ActivateCoupon($coupon, &$strError, $lang=false, $stableVersionsOnly="Y")
Определения update_client_partner.php:1786
static GetCurrentModules(&$strError)
Определения update_client_partner.php:943
static __CompareVersions($strVers1, $strVers2)
Определения update_client_partner.php:1906
static loadModule4Wizard($moduleId, $lang=false)
Определения update_client_partner.php:160
static __ParseServerData(&$strServerOutput, &$arRes, &$strError)
Определения update_client_partner.php:2073
static GetRequestedModules($strAddModule)
Определения update_client_partner.php:505
static GetUpdatesList(&$strError, $lang=false, $stableVersionsOnly="Y", $arRequestedModules=array(), $aditData=Array())
Определения update_client_partner.php:1007
static __GetMicroTime()
Определения update_client_partner.php:2386
static __CopyDirFiles($path_from, $path_to, &$strError, $bSkipUpdater=true)
Определения update_client_partner.php:2193
static GetStepUpdateInfo($updatesDir, &$strError)
Определения update_client_partner.php:798
static UpdateStepModules($updatesDir, &$strError, $bSaveUpdaters=false)
Определения update_client_partner.php:1583
static AddMessage2Log($sText, $sErrorCode="")
Определения update_client_partner.php:438
static __IsGzipInstalled()
Определения update_client_partner.php:2135
static __CheckDirPath($path, $bPermission=true)
Определения update_client_partner.php:2153
static SearchModules($searchModule, $lang)
Определения update_client_partner.php:386
static RegisterModules(&$strError, $lang=false, $stableVersionsOnly=false)
Определения update_client_partner.php:31
static LoadModuleNoDemand($moduleId, &$strError, $stableVersionsOnly="Y", $lang=false)
Определения update_client_partner.php:228
static __GetModuleInfo($path)
Определения update_client_partner.php:2354
static LoadModulesUpdates(&$errorMessage, &$arUpdateDescription, $lang=false, $stableVersionsOnly="Y", $arRequestedModules=array(), $bStrongList=false)
Определения update_client_partner.php:1060
static SearchModulesEx($arOrder, $arFilter, $searchPage, $lang, &$strError)
Определения update_client_partner.php:316
static __CollectRequestData(&$strError, $lang=false, $stableVersionsOnly="Y", $arRequestedModules=array(), $arAdditionalData=array(), $bStrongList=false)
Определения update_client_partner.php:846
static __GetFooPath()
Определения update_client_partner.php:2143
static __RunUpdaterScript($path, &$strError, $updateDirFrom, $moduleID)
Определения update_client_partner.php:1863
static __bxstrrpos($haystack, $needle)
Определения update_client_partner.php:2344
static __GetHTTPPage($page, $strVars, &$strError)
Определения update_client_partner.php:1937
static UnGzipArchive(&$updatesDir, &$strError, $bDelArch=true)
Определения update_client_partner.php:546
static AddMessage2Log($sText, $sErrorCode="")
Определения update_class.php:2853
Определения update_class.php:4288
Определения update_class.php:3942
$startTime
Определения sync.php:69
$moduleID
Определения options.php:7
$contents
Определения commerceml2.php:57
$content
Определения commerceml.php:144
$data['IS_AVAILABLE']
Определения .description.php:13
$filename
Определения file_edit.php:47
if(errorBox) return true
Определения file_new.php:1035
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$handle
Определения include.php:55
$result
Определения get_property_values.php:14
$moduleId
$p
Определения group_list_element_edit.php:23
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
$strError
Определения options_user_settings.php:4
$DOCUMENT_ROOT
Определения cron_frame.php:10
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
global $USER
Определения csv_new_run.php:40
const MODULE_DEMO_EXPIRED
Определения constants.php:7
if(!defined('SITE_ID')) $lang
Определения include.php:91
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
global $DBType
Определения start.php:35
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
IsModuleInstalled($module_id)
Определения tools.php:5301
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$dir
Определения quickway.php:303
if(empty($signedUserToken)) $key
Определения quickway.php:257
$errorMsg
Определения refund.php:16
$i
Определения factura.php:643
$page
Определения order_form.php:33
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$arRes
Определения options.php:104
$error
Определения subscription_card_product.php:20
$GLOBALS['_____370096793']
Определения update_client.php:1
$GLOBALS["UPDATE_STRONG_UPDATE_CHECK"]
Определения update_client_partner.php:27
if(!defined("US_SHARED_KERNEL_PATH")) define("US_SHARED_KERNEL_PATH"
Определения update_client_partner.php:16
$n
Определения update_log.php:107
$arFilter
Определения user_search.php:106