1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
update_class.php
См. документацию.
1<?php
2/**********************************************************************/
5/**********************************************************************/
6
7if (!defined("BX_DIR_PERMISSIONS"))
8 define("BX_DIR_PERMISSIONS", 0755);
9
10if (!defined("US_SHARED_KERNEL_PATH"))
11 define("US_SHARED_KERNEL_PATH", "/bitrix");
12
14{
15 public static function IsInCommonKernel()
16 {
17 return (!defined("US_BITRIX24_MODE") || !US_BITRIX24_MODE) && file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/update_db_updater.php");
18 }
19
21 public static function SubscribeUpdates($strEmails, &$strError, $lang = false)
22 {
23 $strError_tmp = "";
24
25 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::SubscribeUpdates");
26
27 if ($lang===false)
28 $lang = LANGUAGE_ID;
29
30 $GLOBALS["DB"]->GetVersion();
31
32 $strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
33 "&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
34 "&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N").
35 "&SUPD_VER=".urlencode(UPDATE_SYSTEM_VERSION).
36 "&SUBSCR_EMAIL=".urlencode($strEmails).
37 "&SUPD_STS=".urlencode(CUpdateSystem::GetFooPath("GetList")).
38 "&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
39 "&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
40 "&CLIENT_PHPVER=".urlencode(phpversion()).
41 "&lang=".urlencode($lang);
42
43 $content = CUpdateSystem::getHTTPPage("bit_syssubscr.php", $strVars, $strError_tmp);
44
45 if ($content == '')
46 $strError_tmp .= "[USU058] Empty server response.<br>";
47
48 $strError .= $strError_tmp;
49 }
50
52 public static function AddSites($strCheck, &$strError, $lang = false, $stableVersionsOnly = "Y")
53 {
54 $strError_tmp = "";
55
56 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::AddSites");
57
58 if ($lang===false)
59 $lang = LANGUAGE_ID;
60
61 $stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
62
63 if ($strCheck == '')
64 {
65 $strError_tmp .= "[UAS01] ".GetMessage("SUPP_AS_NO_CHECK").".<br>";
66 }
67
68 if ($strError_tmp == '')
69 {
70 $GLOBALS["DB"]->GetVersion();
71
72 $strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
73 "&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
74 "&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N").
75 "&UTYPES=".urlencode("W").
76 "&COUNT_ONLY=".urlencode("Y").
77 "&SUPD_STS=".urlencode(CUpdateSystem::GetFooPath("GetList")).
78 "&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
79 "&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
80 "&SUPD_VER=".urlencode(UPDATE_SYSTEM_VERSION).
81 "&CHECK=".urlencode($strCheck).
82 "&CLIENT_PHPVER=".urlencode(phpversion()).
83 "&stable=".urlencode($stableVersionsOnly).
84 "&lang=".urlencode($lang);
85
86 CUpdateSystem::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strVars));
87
88 $stime = microtime(true);
89 $content = CUpdateSystem::getHTTPPage("bit_sysserver.php", $strVars, $strError_tmp);
90 CUpdateSystem::AddMessage2Log("TIME AddSites.getHTTPPage ".round(microtime(true)-$stime,3)." sec");
91
92 if ($content == '')
93 $strError_tmp .= "[UAS02] ".GetMessage("SUPP_AS_EMPTY_RESP").".<br>";
94 }
95
96 if ($strError_tmp == '')
97 {
98 $arRes = Array();
100 }
101
102 if ($strError_tmp == '')
103 {
104 if (isset($arRes["DATA"]["#"]["ERROR"])
105 && is_array($arRes["DATA"]["#"]["ERROR"])
106 && !empty($arRes["DATA"]["#"]["ERROR"]))
107 {
108 for ($i = 0, $n = count($arRes["DATA"]["#"]["ERROR"]); $i < $n; $i++)
109 {
110 if ($arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"] <> '')
111 $strError_tmp .= "[".$arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"]."] ";
112
113 $strError_tmp .= $arRes["DATA"]["#"]["ERROR"][$i]["#"].".<br>";
114 }
115 }
116 }
117
118 if ($strError_tmp == '')
119 {
120 CUpdateSystem::AddMessage2Log("Check applied successfully!", "CUAS");
121 }
122
123 if ($strError_tmp <> '')
124 {
125 CUpdateSystem::AddMessage2Log($strError_tmp, "CUAS");
126 $strError .= $strError_tmp;
127 return false;
128 }
129 else
130 return true;
131 }
132
133 // Регистрирует копию продукта, если можно
134 public static function RegisterVersion(&$strError, $lang = false, $stableVersionsOnly = "Y")
135 {
136 $strError_tmp = "";
137
138 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::RegisterVersion");
139
140 $stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
141
142 if ($lang===false)
143 $lang = LANGUAGE_ID;
144
145 $GLOBALS["DB"]->GetVersion();
146
147 $strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
148 "&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
149 "&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N").
150 "&UTYPES=".urlencode("R").
151 "&COUNT_ONLY=".urlencode("F").
152 "&VERSION=".urlencode(SM_VERSION).
153 "&SUPD_STS=".urlencode(CUpdateSystem::GetFooPath("GetList")).
154 "&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
155 "&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
156 "&SUPD_VER=".urlencode(UPDATE_SYSTEM_VERSION).
157 "&CLIENT_PHPVER=".urlencode(phpversion()).
158 "&stable=".urlencode($stableVersionsOnly).
159 "&lang=".urlencode($lang);
160
161 CUpdateSystem::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strVars));
162
163 $stime = microtime(true);
164 $fcontent = CUpdateSystem::getHTTPPage("bit_sysserver.php", $strVars, $strError_tmp);
165 CUpdateSystem::AddMessage2Log("TIME RegisterVersion.getHTTPPage ".round(microtime(true)-$stime, 3)." sec");
166
167 if ($fcontent == '')
168 $strError_tmp .= "[URV01] ".GetMessage("SUPP_AS_EMPTY_RESP").".<br>";
169
170 if ($strError_tmp == '')
171 {
172 if (!($fp1 = fopen($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", "wb")))
173 $strError_tmp .= "[URV02] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates", GetMessage("SUPP_RV_ER_TEMP_FILE")).".<br>";
174 }
175
176 if ($strError_tmp == '')
177 {
178 if (!fwrite($fp1, $fcontent))
179 $strError_tmp .= "[URV03] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", GetMessage("SUPP_RV_WRT_TEMP_FILE")).".<br>";
180
181 @fclose($fp1);
182 }
183
184 if ($strError_tmp == '')
185 {
186 $temporary_updates_dir = "";
187 if (!CUpdateSystem::UnGzipArchive($temporary_updates_dir, $strError_tmp, "Y"))
188 $strError_tmp .= "[URV04] ".GetMessage("SUPP_RV_BREAK").".<br>";
189 }
190
191 if ($strError_tmp == '')
192 {
193 $updates_dir_full = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$temporary_updates_dir;
194 if (!file_exists($updates_dir_full."/update_info.xml") || !is_file($updates_dir_full."/update_info.xml"))
195 {
196 $strError_tmp .= "[URV05] ".str_replace("#FILE#", $updates_dir_full."/update_info.xml", GetMessage("SUPP_RV_ER_DESCR_FILE")).".<br>";
197 }
198 }
199
200 if ($strError_tmp == '')
201 {
202 if (!is_readable($updates_dir_full."/update_info.xml"))
203 $strError_tmp .= "[URV06] ".str_replace("#FILE#", $updates_dir_full."/update_info.xml", GetMessage("SUPP_RV_READ_DESCR_FILE")).".<br>";
204 }
205
206 if ($strError_tmp == '')
207 {
208 $content = file_get_contents($updates_dir_full."/update_info.xml");
209 }
210
211 if ($strError_tmp == '')
212 {
213 $arRes = Array();
215 }
216
217 if ($strError_tmp == '')
218 {
219 if (isset($arRes["DATA"]["#"]["ERROR"])
220 && is_array($arRes["DATA"]["#"]["ERROR"])
221 && !empty($arRes["DATA"]["#"]["ERROR"]))
222 {
223 for ($i = 0, $n = count($arRes["DATA"]["#"]["ERROR"]); $i < $n; $i++)
224 {
225 if ($arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"] <> '')
226 $strError_tmp .= "[".$arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"]."] ";
227
228 $strError_tmp .= $arRes["DATA"]["#"]["ERROR"][$i]["#"].".<br>";
229 }
230 }
231 }
232
233 if ($strError_tmp == '')
234 {
235 if (!file_exists($updates_dir_full."/include.php") || !is_file($updates_dir_full."/include.php"))
236 {
237 $strError_tmp .= "[URV07] ".GetMessage("SUPP_RV_NO_FILE").".<br>";
238 }
239 }
240
241 if ($strError_tmp == '')
242 {
243 $newfilesize = @filesize($updates_dir_full."/include.php");
244 if (intval($newfilesize)!=intval($arRes["DATA"]["#"]["FILE"][0]["@"]["SIZE"]))
245 {
246 $strError_tmp .= "[URV08] ".GetMessage("SUPP_RV_ER_SIZE").".<br>";
247 }
248 }
249
250 if ($strError_tmp == '')
251 {
252 if (!is_writeable($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include.php"))
253 {
254 $strError_tmp .= "[URV09] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include.php", GetMessage("SUPP_RV_NO_WRITE")).".<br>";
255 }
256 }
257
258 if ($strError_tmp == '')
259 {
260 if (!copy($updates_dir_full."/include.php", $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include.php"))
261 $strError_tmp .= "[URV10] ".GetMessage("SUPP_RV_ERR_COPY").".<br>";
262 @chmod($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include.php", BX_FILE_PERMISSIONS);
263 }
264
265 if ($strError_tmp == '')
266 {
267 $strongUpdateCheck = COption::GetOptionString("main", "strong_update_check", "Y");
268
269 if ($strongUpdateCheck == "Y")
270 {
271 $crc32_old = dechex(crc32(file_get_contents($updates_dir_full."/include.php")));
272 $crc32_new = dechex(crc32(file_get_contents($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include.php")));
273 if ($crc32_new != $crc32_old)
274 $strError_tmp .= "[URV1011] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include.php", GetMessage("SUPP_UGA_FILE_CRUSH")).".<br>";
275 }
276 }
277
278 if ($strError_tmp == '')
279 {
280 CUpdateSystem::AddMessage2Log("Product registered successfully!", "CURV");
281 CUpdateSystem::DeleteDirFilesEx($updates_dir_full);
282 }
283
284 if ($strError_tmp <> '')
285 {
286 CUpdateSystem::AddMessage2Log($strError_tmp, "CURV");
287 $strError .= $strError_tmp;
288 return false;
289 }
290 else
291 return true;
292 }
293
294
295 // Обновляет систему обновлений
296 public static function UpdateUpdate(&$strError, $lang = false, $stableVersionsOnly = "Y")
297 {
298 $strError_tmp = "";
299
300 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::UpdateUpdate");
301
302 if ($lang===false)
303 $lang = LANGUAGE_ID;
304
305 $stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
306
307 $GLOBALS["DB"]->GetVersion();
308
309 $strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
310 "&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
311 "&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N").
312 "&UTYPES=".urlencode("U").
313 "&SUPD_STS=".urlencode(CUpdateSystem::GetFooPath("GetList")).
314 "&COUNT_ONLY=".urlencode("F").
315 "&SUPD_VER=".urlencode(UPDATE_SYSTEM_VERSION).
316 "&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
317 "&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
318 "&CLIENT_PHPVER=".urlencode(phpversion()).
319 "&stable=".urlencode($stableVersionsOnly).
320 "&lang=".urlencode($lang);
321
322 CUpdateSystem::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strVars));
323
324 $fcontent = CUpdateSystem::getHTTPPage("bit_sysserver.php", $strVars, $strError_tmp);
325
326 if ($fcontent == '')
327 $strError_tmp .= "[UUU01] ".GetMessage("SUPP_AS_EMPTY_RESP").".<br>";
328
329 if ($strError_tmp == '')
330 {
331 if (!($fp1 = fopen($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", "wb")))
332 $strError_tmp .= "[UUU02] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates", GetMessage("SUPP_RV_ER_TEMP_FILE")).".<br>";
333 }
334
335 if ($strError_tmp == '')
336 {
337 if (!fwrite($fp1, $fcontent))
338 $strError_tmp .= "[UUU03] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", GetMessage("SUPP_RV_WRT_TEMP_FILE")).".<br>";
339
340 @fclose($fp1);
341 }
342
343 if ($strError_tmp == '')
344 {
345 $temporary_updates_dir = "";
346 if (!CUpdateSystem::UnGzipArchive($temporary_updates_dir, $strError_tmp, "Y"))
347 $strError_tmp .= "[UUU04] ".GetMessage("SUPP_UU_BREAK").".<br>";
348 }
349
350 if ($strError_tmp == '')
351 {
352 $updates_dir_full = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$temporary_updates_dir;
353 if (!file_exists($updates_dir_full."/update_info.xml") || !is_file($updates_dir_full."/update_info.xml"))
354 $strError_tmp .= "[UUU05] ".str_replace("#FILE#", $updates_dir_full."/update_info.xml", GetMessage("SUPP_RV_ER_DESCR_FILE")).".<br>";
355 }
356
357 if ($strError_tmp == '')
358 {
359 if (!is_readable($updates_dir_full."/update_info.xml"))
360 $strError_tmp .= "[URV06] ".str_replace("#FILE#", $updates_dir_full."/update_info.xml", GetMessage("SUPP_RV_READ_DESCR_FILE")).".<br>";
361 }
362
363 if ($strError_tmp == '')
364 {
365 $content = file_get_contents($updates_dir_full."/update_info.xml");
366 }
367
368 if ($strError_tmp == '')
369 {
370 $arRes = Array();
372 }
373
374 if ($strError_tmp == '')
375 {
376 if (isset($arRes["DATA"]["#"]["ERROR"])
377 && is_array($arRes["DATA"]["#"]["ERROR"])
378 && !empty($arRes["DATA"]["#"]["ERROR"]))
379 {
380 for ($i = 0, $n = count($arRes["DATA"]["#"]["ERROR"]); $i < $n; $i++)
381 {
382 if ($arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"] <> '')
383 $strError_tmp .= "[".$arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"]."] ";
384
385 $strError_tmp .= $arRes["DATA"]["#"]["ERROR"][$i]["#"].".<br>";
386 }
387 }
388 }
389
390 if ($strError_tmp == '')
391 {
392 $aFiles = array(
393 "UUU072"=>"update_class.php",
394 "UUU075"=>"update_log.php",
395 );
396 foreach($aFiles as $err=>$file)
397 if(!file_exists($updates_dir_full."/main/classes/general/".$file) || !is_file($updates_dir_full."/main/classes/general/".$file))
398 $strError_tmp .= "[".$err."] ".str_replace("#FILE#", $file, GetMessage("SUPP_UU_NO_UFILE")).".<br>";
399 }
400
401 if ($strError_tmp == '')
402 {
403 if (!CUpdateSystem::CheckUpdatability($temporary_updates_dir, $strError_tmp))
404 {
405 $strError_tmp .= "[UUU08] ".GetMessage("SUPP_UU_LOAD_BREAK").".<br>";
406 }
407 }
408
409 if ($strError_tmp == '')
410 {
411 $new_updatesys_version = "";
412 if (isset($arRes["DATA"]["#"]["UPDATE_SYSTEM"])
413 && is_array($arRes["DATA"]["#"]["UPDATE_SYSTEM"])
414 && !empty($arRes["DATA"]["#"]["UPDATE_SYSTEM"])
415 && isset($arRes["DATA"]["#"]["UPDATE_SYSTEM"][0]["@"]["VERSION"]))
416 {
417 $new_updatesys_version = trim($arRes["DATA"]["#"]["UPDATE_SYSTEM"][0]["@"]["VERSION"]);
418 }
419
420 if ($new_updatesys_version == '')
421 $strError_tmp .= "[UUU080] ".GetMessage("SUPP_UU_NO_NEW_VER").".<br>";
422 }
423
424 if ($strError_tmp == '')
425 {
426 CUpdateSystem::CopyDirFiles($updates_dir_full."/main", $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main", $strError_tmp);
427 }
428
429 if ($strError_tmp == '')
430 {
431 CUpdateSystem::AddMessage2Log("Update updated successfully!", "CUUU");
432 CUpdateSystem::DeleteDirFilesEx($updates_dir_full);
433 }
434
435 if ($strError_tmp <> '')
436 {
437 CUpdateSystem::AddMessage2Log($strError_tmp, "CUUU");
438 $strError .= $strError_tmp;
439 return false;
440 }
441 else
442 return true;
443 }
444
445 // Закачивает исходники продукта, если можно
446 public static function LoadSources(&$strError, $lang = false, $stableVersionsOnly = "Y")
447 {
448 $strError_tmp = "";
449
450 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::LoadSources");
451
452 if ($lang===false)
453 $lang = LANGUAGE_ID;
454
455 $stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
456
457 $arClientModules = CUpdateSystem::GetModules($strError_tmp);
458
459 if ($strError_tmp == '')
460 {
461 $GLOBALS["DB"]->GetVersion();
462
463 $strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
464 "&lang=".urlencode($lang).
465 "&UTYPES=".urlencode("S").
466 "&SUPD_VER=".urlencode(UPDATE_SYSTEM_VERSION).
467 "&COUNT_ONLY=".urlencode("F").
468 "&SUPD_STS=".urlencode(CUpdateSystem::GetFooPath("GetList")).
469 "&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
470 "&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
471 "&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
472 "&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N").
473 "&CLIENT_PHPVER=".urlencode(phpversion()).
474 "&stable=".urlencode($stableVersionsOnly).
475 "&".CUpdateSystem::ModulesArray2Query($arClientModules, "bitm_");
476
477 CUpdateSystem::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strVars));
478
479 $stime = microtime(true);
480 $fcontent = CUpdateSystem::getHTTPPage("bit_sysserver.php", $strVars, $strError_tmp);
481 CUpdateSystem::AddMessage2Log("TIME LoadSources.getHTTPPage ".round(microtime(true)-$stime, 3)." sec");
482
483 if ($fcontent == '')
484 $strError_tmp .= "[ULS01] ".GetMessage("SUPP_AS_EMPTY_RESP").".<br>";
485 }
486
487 if ($strError_tmp == '')
488 {
489 if (!($fp1 = fopen($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", "wb")))
490 $strError_tmp .= "[ULS02] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates", GetMessage("SUPP_RV_ER_TEMP_FILE")).".<br>";
491 }
492
493 if ($strError_tmp == '')
494 {
495 if (!fwrite($fp1, $fcontent))
496 $strError_tmp .= "[ULS03] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", GetMessage("SUPP_RV_WRT_TEMP_FILE")).".<br>";
497
498 @fclose($fp1);
499 }
500
501 if ($strError_tmp == '')
502 {
503 $temporary_updates_dir = "";
504 if (!CUpdateSystem::UnGzipArchive($temporary_updates_dir, $strError_tmp, "Y"))
505 $strError_tmp .= "[ULS04] ".GetMessage("SUPP_LS_LOAD_BREAK").".<br>";
506 }
507
508 if ($strError_tmp == '')
509 {
510 $updates_dir_full = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$temporary_updates_dir;
511 if (!file_exists($updates_dir_full."/update_info.xml") || !is_file($updates_dir_full."/update_info.xml"))
512 $strError_tmp .= "[ULS05] ".str_replace("#FILE#", $updates_dir_full."/update_info.xml", GetMessage("SUPP_RV_ER_DESCR_FILE")).".<br>";
513 }
514
515 if ($strError_tmp == '')
516 {
517 if (!is_readable($updates_dir_full."/update_info.xml"))
518 $strError_tmp .= "[ULS06] ".str_replace("#FILE#", $updates_dir_full."/update_info.xml", GetMessage("SUPP_RV_READ_DESCR_FILE")).".<br>";
519 }
520
521 if ($strError_tmp == '')
522 {
523 $content = file_get_contents($updates_dir_full."/update_info.xml");
524 }
525
526 if ($strError_tmp == '')
527 {
528 $arRes = Array();
530 }
531
532 if ($strError_tmp == '')
533 {
534 if (isset($arRes["DATA"]["#"]["ERROR"])
535 && is_array($arRes["DATA"]["#"]["ERROR"])
536 && !empty($arRes["DATA"]["#"]["ERROR"]))
537 {
538 for ($i = 0, $n = count($arRes["DATA"]["#"]["ERROR"]); $i < $n; $i++)
539 {
540 if ($arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"] <> '')
541 $strError_tmp .= "[".$arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"]."] ";
542
543 $strError_tmp .= $arRes["DATA"]["#"]["ERROR"][$i]["#"].".<br>";
544 }
545 }
546 }
547
548 if ($strError_tmp == '')
549 {
550 if (!CUpdateSystem::CheckUpdatability($temporary_updates_dir, $strError_tmp))
551 $strError_tmp .= "[ULS07] ".GetMessage("SUPP_LS_LOAD_BREAK").".<br>";
552 }
553
554 if ($strError_tmp == '')
555 {
556 foreach ($arClientModules as $module_id => $version)
557 {
558 $strError_tmp1 = "";
559
560 $from_dir = $updates_dir_full."/".$module_id;
561 $to_dir = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/".$module_id;
562
563 if (!file_exists($to_dir) || !is_dir($to_dir))
564 {
565 $strError_tmp1 .= "[ULS08] ".str_replace("#MODULE#", $module_id, GetMessage("SUPP_LS_NO_MOD_CAT")).".<br>";
566 }
567 elseif (!is_writable($to_dir))
568 {
569 $strError_tmp1 .= "[ULS09] ".str_replace("#MODULE#", $module_id, GetMessage("SUPP_LS_WR_MOD_CAT")).".<br>";
570 }
571
572 if (!file_exists($from_dir) || !is_dir($from_dir))
573 {
574 $strError_tmp1 .= "[ULS10] ".str_replace("#MODULE#", $module_id, GetMessage("SUPP_LS_NO_SRC_MOD")).".<br>";
575 }
576 elseif (!is_readable($from_dir))
577 {
578 $strError_tmp1 .= "[ULS11] ".str_replace("#MODULE#", $module_id, GetMessage("SUPP_LS_RD_SRC_MOD")).".<br>";
579 }
580
581 if ($strError_tmp1 == '')
582 {
583 CUpdateSystem::CopyDirFiles($from_dir, $to_dir, $strError_tmp1);
584 }
585
586 if ($strError_tmp1 <> '')
587 {
588 CUpdateSystem::AddMessage2Log("Error loading sources for ".$module_id."!", "CULS");
589 $strError_tmp .= $strError_tmp1;
590 }
591 else
592 {
593 CUpdateSystem::AddMessage2Log("Sources loaded for ".$module_id."!", "CULS");
594 }
595 }
596 }
597
598 if ($strError_tmp == '')
599 {
600 CUpdateSystem::DeleteDirFilesEx($updates_dir_full);
601 }
602
603 if ($strError_tmp <> '')
604 {
605 CUpdateSystem::AddMessage2Log($strError_tmp, "CULS");
606 $strError .= $strError_tmp;
607 return false;
608 }
609 else
610 return true;
611 }
612
613
614 // Возвращает, что обновилось
615 public static function GetAvailableUpdateTypes(&$strError, $lang = false, $stableVersionsOnly = "Y")
616 {
617 $arResult = array();
618 $strError_tmp = "";
619
620 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::GetAvailableUpdateTypes");
621
622 if ($lang===false)
623 $lang = LANGUAGE_ID;
624
625 $stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
626
627 CUpdateSystem::CheckDirPath($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/", true);
628
629 $arClientModules = CUpdateSystem::GetModules($strError_tmp);
630 $arClientLanguages = CUpdateSystem::GetLanguages($strError_tmp);
631 $arClientHelps = CUpdateSystem::GetHelps($strError_tmp);
632
633 if ($strError_tmp == '')
634 {
635 $GLOBALS["DB"]->GetVersion();
636
637 $strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
638 "&lang=".urlencode($lang).
639 "&UTYPES=".urlencode("MLH").
640 "&SUPD_VER=".urlencode(UPDATE_SYSTEM_VERSION).
641 "&ALL_MODULES=".urlencode("Y").
642 "&TYPENC=".((defined("DEMO") && DEMO=="Y") ? "D" : ((defined("ENCODE") && ENCODE=="Y") ? "E" : "F" )).
643 "&COUNT_ONLY=".urlencode("Y").
644 "&SUPD_STS=".urlencode(CUpdateSystem::GetFooPath("GetList")).
645 "&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
646 "&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
647 "&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
648 "&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N").
649 "&CLIENT_PHPVER=".urlencode(phpversion()).
650 "&stable=".urlencode($stableVersionsOnly).
651 "&".CUpdateSystem::ModulesArray2Query($arClientModules, "bitm_").
652 "&".CUpdateSystem::ModulesArray2Query($arClientLanguages, "bitl_").
653 "&".CUpdateSystem::ModulesArray2Query($arClientHelps, "bith_");
654
655 CUpdateSystem::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strVars));
656
657 $stime = microtime(true);
658 $content = CUpdateSystem::getHTTPPage("bit_sysserver.php", $strVars, $strError_tmp);
659 CUpdateSystem::AddMessage2Log("TIME GetAvailableUpdateTypes.getHTTPPage ".round(microtime(true)-$stime, 3)." sec");
660 }
661
662 if ($strError_tmp == '')
663 {
664 $arRes = Array();
666 }
667
668 if ($strError_tmp == '')
669 {
670 if (isset($arRes["DATA"]["#"]["UPDATE_SYSTEM"])
671 && is_array($arRes["DATA"]["#"]["UPDATE_SYSTEM"])
672 && !empty($arRes["DATA"]["#"]["UPDATE_SYSTEM"]))
673 {
674 $arResult["UPDATE_SYSTEM"] = $arRes["DATA"]["#"]["UPDATE_SYSTEM"][0];
675 }
676
677 if (isset($arRes["DATA"]["#"]["MODULES"])
678 && is_array($arRes["DATA"]["#"]["MODULES"])
679 && !empty($arRes["DATA"]["#"]["MODULES"]))
680 {
681 $arResult["MODULES"] = $arRes["DATA"]["#"]["MODULES"][0];
682 }
683
684 if (isset($arRes["DATA"]["#"]["LANGS"])
685 && is_array($arRes["DATA"]["#"]["LANGS"])
686 && !empty($arRes["DATA"]["#"]["LANGS"]))
687 {
688 $arResult["LANGS"] = $arRes["DATA"]["#"]["LANGS"][0];
689 }
690
691 if (isset($arRes["DATA"]["#"]["HELPS"])
692 && is_array($arRes["DATA"]["#"]["HELPS"])
693 && !empty($arRes["DATA"]["#"]["HELPS"]))
694 {
695 $arResult["HELPS"] = $arRes["DATA"]["#"]["HELPS"][0];
696 }
697
698 if (isset($arRes["DATA"]["#"]["ERROR"])
699 && is_array($arRes["DATA"]["#"]["ERROR"])
700 && !empty($arRes["DATA"]["#"]["ERROR"]))
701 {
702 $arResult["ERROR"] = $arRes["DATA"]["#"]["ERROR"];
703 }
704
705 if (isset($arRes["DATA"]["#"]["CLIENT"])
706 && is_array($arRes["DATA"]["#"]["CLIENT"])
707 && !empty($arRes["DATA"]["#"]["CLIENT"]))
708 {
709 $arResult["CLIENT"] = $arRes["DATA"]["#"]["CLIENT"][0];
710 }
711
712 if (isset($arRes["DATA"]["#"]["SYSTEM"])
713 && is_array($arRes["DATA"]["#"]["SYSTEM"])
714 && !empty($arRes["DATA"]["#"]["SYSTEM"]))
715 {
716 $arResult["SYSTEM"] = $arRes["DATA"]["#"]["SYSTEM"][0];
717 }
718 }
719
720 if ($strError_tmp == '')
721 {
722 if ((!isset($arResult["CLIENT"]) || !is_array($arResult["CLIENT"]))
723 && (!isset($arResult["ERROR"]) || !is_array($arResult["ERROR"])))
724 {
725 $strError_tmp .= "[UGAUT01] ".GetMessage("SUPP_GAUT_SYSERR").".<br>";
726 }
727 }
728
729 if ($strError_tmp <> '')
730 {
731 CUpdateSystem::AddMessage2Log($strError_tmp, "CUGAUT");
732 $strError .= $strError_tmp;
733 return false;
734 }
735 else
736 return $arResult;
737 }
738
739 // Возвращает информацию по доступным обновлениям модулей на сервере
740 public static function GetServerModuleUpdates(&$strError, $lang = false, $stableVersionsOnly = "Y")
741 {
742 $arResult = array();
743 $strError_tmp = "";
744
745 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::GetServerModuleUpdates");
746
747 if ($lang===false)
748 $lang = LANGUAGE_ID;
749
750 $stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
751
752 $arClientModules = CUpdateSystem::GetModules($strError_tmp);
753
754 if ($strError_tmp == '')
755 {
756 $GLOBALS["DB"]->GetVersion();
757
758 $strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
759 "&lang=".urlencode($lang).
760 "&UTYPES=".urlencode("M").
761 "&SUPD_VER=".urlencode(UPDATE_SYSTEM_VERSION).
762 "&ALL_MODULES=".urlencode("Y").
763 "&TYPENC=".((defined("DEMO") && DEMO=="Y") ? "D" : ((defined("ENCODE") && ENCODE=="Y") ? "E" : "F" )).
764 "&COUNT_ONLY=".urlencode("N").
765 "&SUPD_STS=".urlencode(CUpdateSystem::GetFooPath("GetList")).
766 "&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
767 "&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
768 "&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
769 "&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N").
770 "&CLIENT_PHPVER=".urlencode(phpversion()).
771 "&stable=".urlencode($stableVersionsOnly).
772 "&".CUpdateSystem::ModulesArray2Query($arClientModules, "bitm_");
773
774 CUpdateSystem::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strVars));
775
776 $stime = microtime(true);
777 $content = CUpdateSystem::getHTTPPage("bit_sysserver.php", $strVars, $strError_tmp);
778 CUpdateSystem::AddMessage2Log("TIME GetServerModuleUpdates.getHTTPPage ".round(microtime(true)-$stime, 3)." sec");
779 }
780
781 if ($strError_tmp == '')
782 {
783 $arRes = Array();
785 }
786
787 if ($strError_tmp == '')
788 {
789 if (isset($arRes["DATA"]["#"]["UPDATE_SYSTEM"])
790 && is_array($arRes["DATA"]["#"]["UPDATE_SYSTEM"])
791 && !empty($arRes["DATA"]["#"]["UPDATE_SYSTEM"]))
792 {
793 $arResult["UPDATE_SYSTEM"] = $arRes["DATA"]["#"]["UPDATE_SYSTEM"][0];
794 }
795
796 if (isset($arRes["DATA"]["#"]["MODULES"])
797 && is_array($arRes["DATA"]["#"]["MODULES"])
798 && !empty($arRes["DATA"]["#"]["MODULES"]))
799 {
800 $arResult["MODULES"] = $arRes["DATA"]["#"]["MODULES"][0];
801 }
802
803 if (isset($arRes["DATA"]["#"]["ERROR"])
804 && is_array($arRes["DATA"]["#"]["ERROR"])
805 && !empty($arRes["DATA"]["#"]["ERROR"]))
806 {
807 $arResult["ERROR"] = $arRes["DATA"]["#"]["ERROR"];
808 }
809
810 if (isset($arRes["DATA"]["#"]["CLIENT"])
811 && is_array($arRes["DATA"]["#"]["CLIENT"])
812 && !empty($arRes["DATA"]["#"]["CLIENT"]))
813 {
814 $arResult["CLIENT"] = $arRes["DATA"]["#"]["CLIENT"][0];
815 }
816
817 if (isset($arRes["DATA"]["#"]["SYSTEM"])
818 && is_array($arRes["DATA"]["#"]["SYSTEM"])
819 && !empty($arRes["DATA"]["#"]["SYSTEM"]))
820 {
821 $arResult["SYSTEM"] = $arRes["DATA"]["#"]["SYSTEM"][0];
822 }
823 }
824
825 if ($strError_tmp == '')
826 {
827 if ((!isset($arResult["CLIENT"]) || !is_array($arResult["CLIENT"]))
828 && (!isset($arResult["ERROR"]) || !is_array($arResult["ERROR"])))
829 {
830 $strError_tmp .= "[UGSMU01] ".GetMessage("SUPP_GAUT_SYSERR").".<br>";
831 }
832 }
833
834 if ($strError_tmp <> '')
835 {
836 CUpdateSystem::AddMessage2Log($strError_tmp, "CUGSMU");
837 $strError .= $strError_tmp;
838 return false;
839 }
840 else
841 return $arResult;
842 }
843
844
845 // Возвращает информацию по доступным языкам на сервере
846 public static function GetServerLangsUpdates(&$strError, $lang = false, $stableVersionsOnly = "Y")
847 {
848 $arResult = array();
849 $strError_tmp = "";
850
851 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::GetServerLangsUpdates");
852
853 $stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
854
855 if ($lang===false)
856 $lang = LANGUAGE_ID;
857
858 $arClientLanguages = CUpdateSystem::GetLanguages($strError_tmp);
859
860 if ($strError_tmp == '')
861 {
862 $GLOBALS["DB"]->GetVersion();
863
864 $strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
865 "&lang=".urlencode($lang).
866 "&UTYPES=".urlencode("L").
867 "&SUPD_VER=".urlencode(UPDATE_SYSTEM_VERSION).
868 "&ALL_MODULES=".urlencode("Y").
869 "&COUNT_ONLY=".urlencode("N").
870 "&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
871 "&SUPD_STS=".urlencode(CUpdateSystem::GetFooPath("GetList")).
872 "&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N").
873 "&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
874 "&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
875 "&CLIENT_PHPVER=".urlencode(phpversion()).
876 "&stable=".urlencode($stableVersionsOnly).
877 "&".CUpdateSystem::ModulesArray2Query($arClientLanguages, "bitl_");
878
879 CUpdateSystem::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strVars));
880
881 $stime = microtime(true);
882 $content = CUpdateSystem::getHTTPPage("bit_sysserver.php", $strVars, $strError_tmp);
883 CUpdateSystem::AddMessage2Log("TIME GetServerLangsUpdates.getHTTPPage ".round(microtime(true)-$stime, 3)." sec");
884 }
885
886 if ($strError_tmp == '')
887 {
888 $arRes = Array();
890 }
891
892 if ($strError_tmp == '')
893 {
894 if (isset($arRes["DATA"]["#"]["UPDATE_SYSTEM"])
895 && is_array($arRes["DATA"]["#"]["UPDATE_SYSTEM"])
896 && !empty($arRes["DATA"]["#"]["UPDATE_SYSTEM"]))
897 {
898 $arResult["UPDATE_SYSTEM"] = $arRes["DATA"]["#"]["UPDATE_SYSTEM"][0];
899 }
900
901 if (isset($arRes["DATA"]["#"]["LANGS"])
902 && is_array($arRes["DATA"]["#"]["LANGS"])
903 && !empty($arRes["DATA"]["#"]["LANGS"]))
904 {
905 $arResult["LANGS"] = $arRes["DATA"]["#"]["LANGS"][0];
906 }
907
908 if (isset($arRes["DATA"]["#"]["ERROR"])
909 && is_array($arRes["DATA"]["#"]["ERROR"])
910 && !empty($arRes["DATA"]["#"]["ERROR"]))
911 {
912 $arResult["ERROR"] = $arRes["DATA"]["#"]["ERROR"];
913 }
914
915 if (isset($arRes["DATA"]["#"]["CLIENT"])
916 && is_array($arRes["DATA"]["#"]["CLIENT"])
917 && !empty($arRes["DATA"]["#"]["CLIENT"]))
918 {
919 $arResult["CLIENT"] = $arRes["DATA"]["#"]["CLIENT"][0];
920 }
921
922 if (isset($arRes["DATA"]["#"]["SYSTEM"])
923 && is_array($arRes["DATA"]["#"]["SYSTEM"])
924 && !empty($arRes["DATA"]["#"]["SYSTEM"]))
925 {
926 $arResult["SYSTEM"] = $arRes["DATA"]["#"]["SYSTEM"][0];
927 }
928 }
929
930 if ($strError_tmp == '')
931 {
932 if ((!isset($arResult["CLIENT"]) || !is_array($arResult["CLIENT"]))
933 && (!isset($arResult["ERROR"]) || !is_array($arResult["ERROR"])))
934 {
935 $strError_tmp .= "[UGSLU01] ".GetMessage("SUPP_GAUT_SYSERR").".<br>";
936 }
937 }
938
939 if ($strError_tmp <> '')
940 {
941 CUpdateSystem::AddMessage2Log($strError_tmp, "CUGSLU");
942 $strError .= $strError_tmp;
943 return false;
944 }
945 else
946 return $arResult;
947 }
948
949
950 // Возвращает информацию по доступным языкам на сервере
951 public static function GetServerHelpUpdates(&$strError, $lang = false, $stableVersionsOnly = "Y")
952 {
953 $arResult = array();
954 $strError_tmp = "";
955
956 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::GetServerHelpUpdates");
957
958 $stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
959
960 if ($lang===false)
961 $lang = LANGUAGE_ID;
962
963 $arClientHelps = CUpdateSystem::GetHelps($strError_tmp);
964
965 if ($strError_tmp == '')
966 {
967 $GLOBALS["DB"]->GetVersion();
968
969 $strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
970 "&lang=".urlencode($lang).
971 "&UTYPES=".urlencode("H").
972 "&SUPD_VER=".urlencode(UPDATE_SYSTEM_VERSION).
973 "&ALL_MODULES=".urlencode("Y").
974 "&COUNT_ONLY=".urlencode("N").
975 "&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
976 "&SUPD_STS=".urlencode(CUpdateSystem::GetFooPath("GetList")).
977 "&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N").
978 "&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
979 "&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
980 "&CLIENT_PHPVER=".urlencode(phpversion()).
981 "&stable=".urlencode($stableVersionsOnly).
982 "&".CUpdateSystem::ModulesArray2Query($arClientHelps, "bith_");
983
984 CUpdateSystem::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strVars));
985
986 $stime = microtime(true);
987 $content = CUpdateSystem::getHTTPPage("bit_sysserver.php", $strVars, $strError_tmp);
988 CUpdateSystem::AddMessage2Log("TIME GetServerHelpUpdates.getHTTPPage ".round(microtime(true)-$stime, 3)." sec");
989 }
990
991 if ($strError_tmp == '')
992 {
993 $arRes = Array();
995 }
996
997 if ($strError_tmp == '')
998 {
999 if (isset($arRes["DATA"]["#"]["UPDATE_SYSTEM"])
1000 && is_array($arRes["DATA"]["#"]["UPDATE_SYSTEM"])
1001 && !empty($arRes["DATA"]["#"]["UPDATE_SYSTEM"]))
1002 {
1003 $arResult["UPDATE_SYSTEM"] = $arRes["DATA"]["#"]["UPDATE_SYSTEM"][0];
1004 }
1005
1006 if (isset($arRes["DATA"]["#"]["HELPS"])
1007 && is_array($arRes["DATA"]["#"]["HELPS"])
1008 && !empty($arRes["DATA"]["#"]["HELPS"]))
1009 {
1010 $arResult["HELPS"] = $arRes["DATA"]["#"]["HELPS"][0];
1011 }
1012
1013 if (isset($arRes["DATA"]["#"]["ERROR"])
1014 && is_array($arRes["DATA"]["#"]["ERROR"])
1015 && !empty($arRes["DATA"]["#"]["ERROR"]))
1016 {
1017 $arResult["ERROR"] = $arRes["DATA"]["#"]["ERROR"];
1018 }
1019
1020 if (isset($arRes["DATA"]["#"]["CLIENT"])
1021 && is_array($arRes["DATA"]["#"]["CLIENT"])
1022 && !empty($arRes["DATA"]["#"]["CLIENT"]))
1023 {
1024 $arResult["CLIENT"] = $arRes["DATA"]["#"]["CLIENT"][0];
1025 }
1026
1027 if (isset($arRes["DATA"]["#"]["SYSTEM"])
1028 && is_array($arRes["DATA"]["#"]["SYSTEM"])
1029 && !empty($arRes["DATA"]["#"]["SYSTEM"]))
1030 {
1031 $arResult["SYSTEM"] = $arRes["DATA"]["#"]["SYSTEM"][0];
1032 }
1033 }
1034
1035 if ($strError_tmp == '')
1036 {
1037 if ((!isset($arResult["CLIENT"]) || !is_array($arResult["CLIENT"]))
1038 && (!isset($arResult["ERROR"]) || !is_array($arResult["ERROR"])))
1039 {
1040 $strError_tmp .= "[UGSHU01] ".GetMessage("SUPP_GAUT_SYSERR").".<br>";
1041 }
1042 }
1043
1044 if ($strError_tmp <> '')
1045 {
1046 CUpdateSystem::AddMessage2Log($strError_tmp, "CUGSHU");
1047 $strError .= $strError_tmp;
1048 return false;
1049 }
1050 else
1051 return $arResult;
1052 }
1053
1054
1055 // Загружает обновление модулей $arModules в файл update_archive.gz
1056 public static function LoadModuleUpdates($arModules, &$strError, $lang = false, $stableVersionsOnly = "Y")
1057 {
1058 $strError_tmp = "";
1059
1060 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::LoadModuleUpdates");
1061
1062 if ($lang===false)
1063 $lang = LANGUAGE_ID;
1064
1065 $stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
1066
1067 if (!is_array($arModules))
1068 {
1069 $strError_tmp .= "[ULMU01] ".GetMessage("SUPP_LMU_NO_MODS").".<br>";
1070 }
1071
1072 if ($strError_tmp == '')
1073 {
1074 $arClientModules = CUpdateSystem::GetModules($strError_tmp, $arModules);
1075 for ($i = 0, $n = count($arModules); $i < $n; $i++)
1076 {
1077 if (!array_key_exists($arModules[$i], $arClientModules))
1078 $arClientModules[$arModules[$i]] = "";
1079 }
1080 if (!is_array($arClientModules) || empty($arClientModules))
1081 {
1082 $strError_tmp .= "[ULMU02] ".GetMessage("SUPP_LMU_NO_MODS").".<br>";
1083 }
1084 }
1085
1086 if ($strError_tmp == '')
1087 {
1088 $GLOBALS["DB"]->GetVersion();
1089
1090 $strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
1091 "&lang=".urlencode($lang).
1092 "&UTYPES=".urlencode("M").
1093 "&ALL_MODULES=".urlencode("N").
1094 "&TYPENC=".((defined("DEMO") && DEMO=="Y") ? "D" : ((defined("ENCODE") && ENCODE=="Y") ? "E" : "F" )).
1095 "&SUPD_VER=".urlencode(UPDATE_SYSTEM_VERSION).
1096 "&COUNT_ONLY=".urlencode("F").
1097 "&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
1098 "&SUPD_STS=".urlencode(CUpdateSystem::GetFooPath("GetList")).
1099 "&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N").
1100 "&CLIENT_PHPVER=".urlencode(phpversion()).
1101 "&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
1102 "&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
1103 "&stable=".urlencode($stableVersionsOnly).
1104 "&".CUpdateSystem::ModulesArray2Query($arClientModules, "bitm_");
1105
1106 CUpdateSystem::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strVars));
1107
1108 $stime = microtime(true);
1109 $content = CUpdateSystem::getHTTPPage("bit_sysserver.php", $strVars, $strError_tmp);
1110 CUpdateSystem::AddMessage2Log("TIME LoadModuleUpdates.getHTTPPage ".round(microtime(true)-$stime, 3)." sec");
1111
1112 if ($content == '')
1113 $strError_tmp .= "[ULMU03] ".GetMessage("SUPP_AS_EMPTY_RESP").".<br>";
1114 }
1115
1116 if ($strError_tmp == '')
1117 {
1118 if (!($fp1 = fopen($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", "wb")))
1119 {
1120 $strError_tmp .= "[ULMU04] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates", GetMessage("SUPP_RV_ER_TEMP_FILE")).".<br>";
1121 }
1122 }
1123
1124 if ($strError_tmp == '')
1125 {
1126 fwrite($fp1, $content);
1127 fclose($fp1);
1128
1129 if (!file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz")
1130 || !is_file($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz"))
1131 {
1132 $strError_tmp .= "[ULMU05] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", GetMessage("SUPP_LMU_NO_TMP_FILE")).".<br>";
1133 }
1134 }
1135
1136 if ($strError_tmp <> '')
1137 {
1138 CUpdateSystem::AddMessage2Log($strError_tmp, "CULMU");
1139 $strError .= $strError_tmp;
1140 return false;
1141 }
1142 else
1143 return true;
1144 }
1145
1146
1147 // Загружает обновления языков $arLangs в файл update_archive.gz
1148 public static function LoadLangsUpdates($arLangs, &$strError, $lang = false, $stableVersionsOnly = "Y")
1149 {
1150 $strError_tmp = "";
1151
1152 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::LoadLangsUpdates");
1153
1154 $stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
1155
1156 if ($lang===false)
1157 $lang = LANGUAGE_ID;
1158
1159 if (!is_array($arLangs) || empty($arLangs))
1160 {
1161 $strError_tmp .= "[ULLU01] ".GetMessage("SUPP_LLU_NO_LANGS").".<br>";
1162 }
1163
1164 if ($strError_tmp == '')
1165 {
1166 $arClientLangs = CUpdateSystem::GetLanguages($strError_tmp, $arLangs);
1167 for ($i = 0, $n = count($arLangs); $i < $n; $i++)
1168 {
1169 if (!array_key_exists($arLangs[$i], $arClientLangs))
1170 $arClientLangs[$arLangs[$i]] = "";
1171 }
1172 if (!is_array($arClientLangs) || empty($arClientLangs))
1173 {
1174 $strError_tmp .= "[ULLU02] ".GetMessage("SUPP_LLU_NO_LANGS").".<br>";
1175 }
1176 }
1177
1178 if ($strError_tmp == '')
1179 {
1180 $GLOBALS["DB"]->GetVersion();
1181
1182 $strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
1183 "&lang=".urlencode($lang).
1184 "&UTYPES=".urlencode("L").
1185 "&ALL_MODULES=".urlencode("N").
1186 "&SUPD_VER=".urlencode(UPDATE_SYSTEM_VERSION).
1187 "&SUPD_STS=".urlencode(CUpdateSystem::GetFooPath("GetList")).
1188 "&COUNT_ONLY=".urlencode("F").
1189 "&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
1190 "&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N").
1191 "&CLIENT_PHPVER=".urlencode(phpversion()).
1192 "&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
1193 "&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
1194 "&stable=".urlencode($stableVersionsOnly).
1195 "&".CUpdateSystem::ModulesArray2Query($arClientLangs, "bitl_");
1196
1197 CUpdateSystem::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strVars));
1198
1199 $stime = microtime(true);
1200 $content = CUpdateSystem::getHTTPPage("bit_sysserver.php", $strVars, $strError_tmp);
1201 CUpdateSystem::AddMessage2Log("TIME LoadLangsUpdates.getHTTPPage ".round(microtime(true)-$stime, 3)." sec");
1202
1203 if ($content == '')
1204 $strError_tmp .= "[ULLU03] ".GetMessage("SUPP_AS_EMPTY_RESP").".<br>";
1205 }
1206
1207 if ($strError_tmp == '')
1208 {
1209 if (!($fp1 = fopen($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", "wb")))
1210 {
1211 $strError_tmp .= "[ULLU04] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates", GetMessage("SUPP_RV_ER_TEMP_FILE")).".<br>";
1212 }
1213 }
1214
1215 if ($strError_tmp == '')
1216 {
1217 fwrite($fp1, $content);
1218 fclose($fp1);
1219
1220 if (!file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz")
1221 || !is_file($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz"))
1222 {
1223 $strError_tmp .= "[ULLU05] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", GetMessage("SUPP_LMU_NO_TMP_FILE")).".<br>";
1224 }
1225 }
1226
1227 if ($strError_tmp <> '')
1228 {
1229 CUpdateSystem::AddMessage2Log($strError_tmp, "CULLU");
1230 $strError .= $strError_tmp;
1231 return false;
1232 }
1233 else
1234 return true;
1235 }
1236
1237
1238 // Загружает обновление помощи $load_help в файл update_archive.gz
1239 public static function LoadHelpUpdates($arHelp, &$strError, $lang = false, $stableVersionsOnly = "Y")
1240 {
1241 $strError_tmp = "";
1242
1243 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::LoadHelpUpdates");
1244
1245 if ($lang===false)
1246 $lang = LANGUAGE_ID;
1247
1248 $stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
1249
1250 if (!is_array($arHelp) || empty($arHelp))
1251 {
1252 $strError_tmp .= "[ULHU01] ".GetMessage("SUPP_LHU_NO_HELP").".<br>";
1253 }
1254
1255 if ($strError_tmp == '')
1256 {
1257 $arClientHelps = CUpdateSystem::GetHelps($strError_tmp, $arHelp);
1258 for ($i = 0, $n = count($arHelp); $i < $n; $i++)
1259 {
1260 if (!array_key_exists($arHelp[$i], $arClientHelps))
1261 $arClientHelps[$arHelp[$i]] = "";
1262 }
1263
1264 if (!is_array($arClientHelps) || empty($arClientHelps))
1265 {
1266 $strError_tmp .= "[ULHU02] ".GetMessage("SUPP_LHU_NO_HELP").".<br>";
1267 }
1268 }
1269
1270 if ($strError_tmp == '')
1271 {
1272 $GLOBALS["DB"]->GetVersion();
1273
1274 $strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
1275 "&lang=".urlencode($lang).
1276 "&UTYPES=".urlencode("H").
1277 "&ALL_MODULES=".urlencode("N").
1278 "&SUPD_VER=".urlencode(UPDATE_SYSTEM_VERSION).
1279 "&SUPD_STS=".urlencode(CUpdateSystem::GetFooPath("GetList")).
1280 "&COUNT_ONLY=".urlencode("F").
1281 "&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
1282 "&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N").
1283 "&CLIENT_PHPVER=".urlencode(phpversion()).
1284 "&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
1285 "&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
1286 "&stable=".urlencode($stableVersionsOnly).
1287 "&".CUpdateSystem::ModulesArray2Query($arClientHelps, "bith_");
1288
1289 CUpdateSystem::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strVars));
1290
1291 $stime = microtime(true);
1292 $content = CUpdateSystem::getHTTPPage("bit_sysserver.php", $strVars, $strError_tmp);
1293 CUpdateSystem::AddMessage2Log("TIME LoadHelpUpdates.getHTTPPage ".round(microtime(true)-$stime, 3)." sec");
1294
1295 if ($content == '')
1296 $strError_tmp .= "[ULHU03] ".GetMessage("SUPP_AS_EMPTY_RESP").".<br>";
1297 }
1298
1299 if ($strError_tmp == '')
1300 {
1301 if (!($fp1 = fopen($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", "wb")))
1302 $strError_tmp .= "[ULHU04] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates", GetMessage("SUPP_RV_ER_TEMP_FILE")).".<br>";
1303 }
1304
1305 if ($strError_tmp == '')
1306 {
1307 fwrite($fp1, $content);
1308 fclose($fp1);
1309
1310 if (!file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz")
1311 || !is_file($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz"))
1312 {
1313 $strError_tmp .= "[ULHU05] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", GetMessage("SUPP_LMU_NO_TMP_FILE")).".<br>";
1314 }
1315 }
1316
1317 if ($strError_tmp <> '')
1318 {
1319 CUpdateSystem::AddMessage2Log($strError_tmp, "CULHU");
1320 $strError .= $strError_tmp;
1321 return false;
1322 }
1323 else
1324 return true;
1325 }
1326
1327 // Распаковывает архив файлов update_archive.gz в папкy $updates_dir
1328 public static function UnGzipArchive(&$updates_dir, &$strError, $DelArch = "Y")
1329 {
1330 $strError_tmp = "";
1331
1332 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::UnGzipArchive");
1333 $stime = microtime(true);
1334
1335 if ($DelArch!="Y")
1336 $DelArch = "N";
1337
1338 $archiveFileName = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz";
1339
1340 if (!file_exists($archiveFileName) || !is_file($archiveFileName))
1341 {
1342 $strError_tmp .= "[UUGZA01] ".str_replace("#FILE#", $archiveFileName, GetMessage("SUPP_UGA_NO_TMP_FILE")).".<br>";
1343 }
1344
1345 if ($strError_tmp == '')
1346 {
1347 if (!is_readable($archiveFileName))
1348 $strError_tmp .= "[UUGZA02] ".str_replace("#FILE#", $archiveFileName, GetMessage("SUPP_UGA_NO_READ_FILE")).".<br>";
1349 }
1350
1351 if ($strError_tmp == '')
1352 {
1353 $updates_dir = "update_m".time();
1354 $updates_dir_full = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$updates_dir;
1355 CUpdateSystem::CheckDirPath($updates_dir_full."/", true);
1356
1357 if (!file_exists($updates_dir_full) || !is_dir($updates_dir_full))
1358 {
1359 $strError_tmp .= "[UUGZA03] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_UGA_NO_TMP_CAT")).".<br>";
1360 }
1361 elseif (!is_writable($updates_dir_full))
1362 {
1363 $strError_tmp .= "[UUGZA04] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_UGA_WRT_TMP_CAT")).".<br>";
1364 }
1365 }
1366
1367 if ($strError_tmp == '')
1368 {
1369 $bCompressionUsed = true;
1370
1371 $fd = fopen($archiveFileName, "rb");
1372 $flabel = fread($fd, strlen("BITRIX"));
1373 fclose($fd);
1374
1375 if ($flabel=="BITRIX")
1376 $bCompressionUsed = false;
1377 }
1378
1379 if ($strError_tmp == '')
1380 {
1381 if ($bCompressionUsed)
1382 $zp = gzopen($archiveFileName, "rb9f");
1383 else
1384 $zp = fopen($archiveFileName, "rb");
1385
1386 if (!$zp)
1387 {
1388 $strError_tmp .= "[UUGZA05] ".str_replace("#FILE#", $archiveFileName, GetMessage("SUPP_UGA_CANT_OPEN")).".<br>";
1389 }
1390 }
1391
1392 if ($strError_tmp == '')
1393 {
1394 if ($bCompressionUsed)
1395 $flabel = gzread($zp, strlen("BITRIX"));
1396 else
1397 $flabel = fread($zp, strlen("BITRIX"));
1398
1399 if ($flabel!="BITRIX")
1400 {
1401 $strError_tmp .= "[UUGZA06] ".str_replace("#FILE#", $archiveFileName, GetMessage("SUPP_UGA_BAD_FORMAT")).".<br>";
1402
1403 if ($bCompressionUsed)
1404 gzclose($zp);
1405 else
1406 fclose($zp);
1407 }
1408 }
1409
1410 if ($strError_tmp == '')
1411 {
1412 $strongUpdateCheck = COption::GetOptionString("main", "strong_update_check", "Y");
1413
1414 while (true)
1415 {
1416 if ($bCompressionUsed)
1417 $add_info_size = gzread($zp, 5);
1418 else
1419 $add_info_size = fread($zp, 5);
1420
1421 $add_info_size = trim($add_info_size);
1422 if (intval($add_info_size)>0
1423 && intval($add_info_size)."!"==$add_info_size."!")
1424 {
1425 $add_info_size = intval($add_info_size);
1426 }
1427 else
1428 {
1429 if ($add_info_size!="RTIBE")
1430 $strError_tmp .= "[UUGZA071] ".str_replace("#FILE#", $archiveFileName, GetMessage("SUPP_UGA_BAD_FORMAT")).".<br>";
1431
1432 break;
1433 }
1434
1435 if ($bCompressionUsed)
1436 $add_info = gzread($zp, $add_info_size);
1437 else
1438 $add_info = fread($zp, $add_info_size);
1439
1440 $add_info_arr = explode("|", $add_info);
1441 if (count($add_info_arr) != 3)
1442 {
1443 $strError_tmp .= "[UUGZA072] ".str_replace("#FILE#", $archiveFileName, GetMessage("SUPP_UGA_BAD_FORMAT")).".<br>";
1444 break;
1445 }
1446
1447 $size = $add_info_arr[0];
1448 $curpath = $add_info_arr[1];
1449 $crc32 = $add_info_arr[2];
1450
1451 $contents = "";
1452 if (intval($size) > 0)
1453 {
1454 if ($bCompressionUsed)
1455 $contents = gzread($zp, $size);
1456 else
1457 $contents = fread($zp, $size);
1458 }
1459
1460 $crc32_new = dechex(crc32($contents));
1461
1462 if ($crc32_new !== $crc32)
1463 {
1464 $strError_tmp .= "[UUGZA073] ".str_replace("#FILE#", $curpath, GetMessage("SUPP_UGA_FILE_CRUSH")).".<br>";
1465 break;
1466 }
1467 else
1468 {
1469 CUpdateSystem::CheckDirPath($updates_dir_full.$curpath, true);
1470
1471 if (!($fp1 = fopen($updates_dir_full.$curpath, "wb")))
1472 {
1473 $strError_tmp .= "[UUGZA074] ".str_replace("#FILE#", $updates_dir_full.$curpath, GetMessage("SUPP_UGA_CANT_OPEN_WR")).".<br>";
1474 break;
1475 }
1476
1477 if ($contents <> '' && !fwrite($fp1, $contents))
1478 {
1479 $strError_tmp .= "[UUGZA075] ".str_replace("#FILE#", $updates_dir_full.$curpath, GetMessage("SUPP_UGA_CANT_WRITE_F")).".<br>";
1480 @fclose($fp1);
1481 break;
1482 }
1483 fclose($fp1);
1484
1485 if ($strongUpdateCheck == "Y")
1486 {
1487 $crc32_new = dechex(crc32(file_get_contents($updates_dir_full.$curpath)));
1488 if ($crc32_new !== $crc32)
1489 {
1490 $strError_tmp .= "[UUGZA0761] ".str_replace("#FILE#", $curpath, GetMessage("SUPP_UGA_FILE_CRUSH")).".<br>";
1491 break;
1492 }
1493 }
1494 }
1495 }
1496
1497 if ($bCompressionUsed)
1498 gzclose($zp);
1499 else
1500 fclose($zp);
1501 }
1502
1503 if ($strError_tmp == '')
1504 {
1505 if ($DelArch=="Y")
1506 @unlink($archiveFileName);
1507 }
1508
1509 CUpdateSystem::AddMessage2Log("TIME UnGzipArchive ".round(microtime(true)-$stime, 3)." sec");
1510
1511 if ($strError_tmp <> '')
1512 {
1513 CUpdateSystem::AddMessage2Log($strError_tmp, "CUUGZA");
1514 $strError .= $strError_tmp;
1515 return false;
1516 }
1517 else
1518 return true;
1519 }
1520
1521
1522 // Проверяет возможность обновления модулей $arModules
1523 // на основании контроля версий VERSION_CONTROL
1524 public static function CheckVersions(&$arRes, &$strError, $arSelectedModules = false)
1525 {
1526 $strError_tmp = "";
1527
1528 $stime = microtime(true);
1529
1530 if (!is_array($arRes)
1531 || !isset($arRes["MODULES"])
1532 || !is_array($arRes["MODULES"])
1533 )
1534 {
1535 $strError_tmp .= "[UCV01] ".GetMessage("SUPP_CV_ERR_ARR").".<br>";
1536 }
1537
1538 if ($arSelectedModules!==false && (!is_array($arSelectedModules) || empty($arSelectedModules)))
1539 {
1540 $strError_tmp .= "[UCV011] ".GetMessage("SUPP_CV_NO_SELECTED").".<br>";
1541 }
1542
1543 if ($strError_tmp == '')
1544 {
1545 $arModulesList = $arRes["MODULES"]["#"]["MODULE"];
1546
1547 if (!is_array($arModulesList) || empty($arModulesList))
1548 {
1549 $strError_tmp .= "[UCV02] ".GetMessage("SUPP_CV_EMPTY_MODS").".<br>";
1550 }
1551 }
1552
1553 if ($strError_tmp == '')
1554 {
1555 for ($i = 0, $ni = count($arModulesList); $i < $ni; $i++)
1556 {
1557 if ($arSelectedModules===false || in_array($arModulesList[$i]["@"]["ID"], $arSelectedModules))
1558 {
1559 if (isset($arModulesList[$i]["#"]["VERSION_CONTROL"])
1560 && !empty($arModulesList[$i]["#"]["VERSION_CONTROL"]))
1561 {
1562 for ($j = 0, $nj = count($arModulesList[$i]["#"]["VERSION_CONTROL"]); $j < $nj; $j++)
1563 {
1564 $strModule_tmp = $arModulesList[$i]["#"]["VERSION_CONTROL"][$j]["@"]["MODUL"];
1565 $bNeedInstall = true;
1566
1567 for ($k = 0, $nk = count($arModulesList); $k < $nk; $k++)
1568 {
1569 if ($arModulesList[$k]["@"]["ID"]==$strModule_tmp
1570 && ($arSelectedModules===false
1571 || in_array($arModulesList[$k]["@"]["ID"], $arSelectedModules)))
1572 {
1574 $arModulesList[$k]["@"]["VERSION"],
1575 $arModulesList[$i]["#"]["VERSION_CONTROL"][$j]["@"]["VERSION"]
1576 ) >= 0)
1577 {
1578 $bNeedInstall = false;
1579 break;
1580 }
1581 }
1582 }
1583
1584 if ($bNeedInstall)
1585 {
1586 $strModule_tmp_dir = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/".$strModule_tmp;
1587 if (file_exists($strModule_tmp_dir) && is_dir($strModule_tmp_dir))
1588 {
1589 if ($strModule_tmp!="main")
1590 {
1591 if (file_exists($strModule_tmp_dir."/install/index.php"))
1592 {
1593 $arModule_tmp_info = CUpdateSystem::GetModuleInfo($strModule_tmp_dir);
1595 $arModule_tmp_info["VERSION"],
1596 $arModulesList[$i]["#"]["VERSION_CONTROL"][$j]["@"]["VERSION"]
1597 ) >= 0)
1598 {
1599 $bNeedInstall = false;
1600 }
1601 }
1602 }
1603 else
1604 {
1606 SM_VERSION,
1607 $arModulesList[$i]["#"]["VERSION_CONTROL"][$j]["@"]["VERSION"]
1608 ) >= 0)
1609 {
1610 $bNeedInstall = false;
1611 }
1612 }
1613 }
1614 else
1615 {
1616 $bNeedInstall = false;
1617 }
1618 }
1619
1620 if ($bNeedInstall)
1621 {
1622 $strError_tmp .= "[UCV_MER01] ".str_replace("#VERS#", $arModulesList[$i]["#"]["VERSION_CONTROL"][$j]["@"]["VERSION"], str_replace("#MODULE2#", $strModule_tmp, str_replace("#MODULE1#", $arModulesList[$i]["@"]["ID"], GetMessage("SUPP_CV_RES_ERR")))).".<br>";
1623 }
1624 }
1625 }
1626 }
1627 }
1628 }
1629
1630 CUpdateSystem::AddMessage2Log("TIME CheckVersions ".round(microtime(true)-$stime, 3)." sec");
1631
1632 if ($strError_tmp <> '')
1633 {
1634 CUpdateSystem::AddMessage2Log($strError_tmp, "CUCV");
1635 $strError .= $strError_tmp;
1636 return false;
1637 }
1638 else
1639 return true;
1640 }
1641
1642
1643 // Возвращает информацию по загруженным в папку $updates_dir обновлениям модулей
1644 public static function CheckUpdatability($updates_dir, &$strError)
1645 {
1646 $strError_tmp = "";
1647
1648 $updates_dir_full = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$updates_dir;
1649 if (!file_exists($updates_dir_full) || !is_dir($updates_dir_full))
1650 {
1651 $strError_tmp .= "[UCU01] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_NO_TMP_CAT")).".<br>";
1652 }
1653
1654 if ($strError_tmp == '')
1655 {
1656 if (!is_readable($updates_dir_full))
1657 {
1658 $strError_tmp .= "[UCU02] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_RD_TMP_CAT")).".<br>";
1659 }
1660 }
1661
1662 if ($handle = @opendir($updates_dir_full))
1663 {
1664 while (($file = readdir($handle)) !== false)
1665 {
1666 if ($file == "." || $file == "..") continue;
1667
1668 if (is_dir($updates_dir_full."/".$file))
1669 {
1670 CUpdateSystem::CheckUpdatability($updates_dir."/".$file, $strError_tmp);
1671 }
1672 elseif (is_file($updates_dir_full."/".$file))
1673 {
1674 $strRealPath = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/".substr($updates_dir."/".$file, strpos($updates_dir."/".$file, "/"));
1675 if (file_exists($strRealPath))
1676 {
1677 if (!is_writeable($strRealPath))
1678 {
1679 $strError_tmp .= "[UCU03] ".str_replace("#FILE#", $strRealPath, GetMessage("SUPP_CU_MAIN_ERR_FILE")).".<br>";
1680 }
1681 }
1682 else
1683 {
1684 $p = CUpdateSystem::bxstrrpos($strRealPath, "/");
1685 $strRealPath = substr($strRealPath, 0, $p);
1686
1687 if (strlen($strRealPath)>1)
1688 $strRealPath = rtrim($strRealPath, "/");
1689
1690 $p = CUpdateSystem::bxstrrpos($strRealPath, "/");
1691 while ($p > 0)
1692 {
1693 if (file_exists($strRealPath) && is_dir($strRealPath))
1694 {
1695 if (!is_writable($strRealPath))
1696 $strError_tmp .= "[UCU04] ".str_replace("#FILE#", $strRealPath, GetMessage("SUPP_CU_MAIN_ERR_CAT")).".<br>";
1697
1698 break;
1699 }
1700 $strRealPath = substr($strRealPath, 0, $p);
1701 $p = CUpdateSystem::bxstrrpos($strRealPath, "/");
1702 }
1703 }
1704 }
1705 }
1706 @closedir($handle);
1707 }
1708
1709 if ($strError_tmp <> '')
1710 {
1711 CUpdateSystem::AddMessage2Log($strError_tmp, "CUCU");
1712 $strError .= $strError_tmp;
1713 return false;
1714 }
1715 else
1716 return true;
1717 }
1718
1719 public static function CheckFolderUpdatability($destFolder, $srcFolder, &$strError)
1720 {
1721 $strError_tmp = "";
1722
1723 $destFolder = str_replace("\\", "/", $destFolder);
1724 $destFolder = trim($destFolder," \t\n\r\0\x0B/\\");
1725 if ($destFolder <> '')
1726 $destFolder = "/".$destFolder;
1727
1728 if ($srcFolder && $srcFolder <> '')
1729 {
1730 $srcFolder = str_replace("\\", "/", $srcFolder);
1731 $srcFolder = trim($srcFolder," \t\n\r\0\x0B/\\");
1732 if ($srcFolder <> '')
1733 $srcFolder = "/".$srcFolder;
1734
1735 $srcFolderFull = $_SERVER["DOCUMENT_ROOT"].$srcFolder;
1736 if (!file_exists($srcFolderFull) || !is_dir($srcFolderFull))
1737 $strError_tmp .= "[UCFU01] ".str_replace("#FILE#", $srcFolderFull, GetMessage("SUPN_NO_FOLDER_EX")).".<br>";
1738
1739 if ($strError_tmp == '')
1740 {
1741 if (!is_readable($srcFolderFull))
1742 $strError_tmp .= "[UCFU02] ".str_replace("#FILE#", $srcFolderFull, GetMessage("SUPN_CU_RD_TMP_CAT")).".<br>";
1743 }
1744
1745 if ($handle = @opendir($srcFolderFull))
1746 {
1747 while (($file = readdir($handle)) !== false)
1748 {
1749 if ($file == "." || $file == "..")
1750 continue;
1751
1752 if (is_dir($srcFolderFull."/".$file))
1753 {
1754 CUpdateSystem::CheckFolderUpdatability($destFolder."/".$file, $srcFolder."/".$file, $strError_tmp);
1755 }
1756 elseif (is_file($srcFolderFull."/".$file))
1757 {
1758 $destFileFull = $_SERVER["DOCUMENT_ROOT"].$destFolder."/".$file;
1759 if (file_exists($destFileFull))
1760 {
1761 if (!is_writeable($destFileFull))
1762 $strError_tmp .= "[UCFU03] ".str_replace("#FILE#", $destFileFull, GetMessage("SUPP_CU_MAIN_ERR_FILE")).".<br>";
1763 }
1764 else
1765 {
1766 $p = CUpdateSystem::bxstrrpos($destFileFull, "/");
1767 $destFileFull = substr($destFileFull, 0, $p);
1768
1769 while (strlen($destFileFull) > 1 && substr($destFileFull, strlen($destFileFull) - 1, 1) == "/")
1770 $destFileFull = substr($destFileFull, 0, strlen($destFileFull) - 1);
1771
1772 $p = CUpdateSystem::bxstrrpos($destFileFull, "/");
1773 while ($p > 0)
1774 {
1775 if (file_exists($destFileFull) && is_dir($destFileFull))
1776 {
1777 if (!is_writable($destFileFull))
1778 $strError_tmp .= "[UCFU04] ".str_replace("#FILE#", $destFileFull, GetMessage("SUPP_CU_MAIN_ERR_CAT")).".<br>";
1779
1780 break;
1781 }
1782 $destFileFull = substr($destFileFull, 0, $p);
1783 $p = CUpdateSystem::bxstrrpos($destFileFull, "/");
1784 }
1785 }
1786 }
1787 }
1788 @closedir($handle);
1789 }
1790 }
1791 else
1792 {
1793 $destFolderFull = $_SERVER["DOCUMENT_ROOT"].$destFolder;
1794 if (!file_exists($destFolderFull) || !is_dir($destFolderFull))
1795 $strError_tmp .= "[UCFU05] ".str_replace("#FILE#", $destFolderFull, GetMessage("SUPN_NO_FOLDER_EX")).".<br>";
1796
1797 if ($strError_tmp == '')
1798 {
1799 if (!is_writeable($destFolderFull))
1800 $strError_tmp .= "[UCFU06] ".str_replace("#FILE#", $destFolderFull, GetMessage("SUPP_CU_MAIN_ERR_CAT")).".<br>";
1801 }
1802
1803 if ($handle = @opendir($destFolderFull))
1804 {
1805 while (($file = readdir($handle)) !== false)
1806 {
1807 if ($file == "." || $file == "..")
1808 continue;
1809
1810 if (is_dir($destFolderFull."/".$file))
1811 {
1812 CUpdateSystem::CheckFolderUpdatability($destFolder."/".$file, "", $strError_tmp);
1813 }
1814 elseif (is_file($destFolderFull."/".$file))
1815 {
1816 if (!is_writeable($destFolderFull."/".$file))
1817 $strError_tmp .= "[UCFU07] ".str_replace("#FILE#", $destFolderFull."/".$file, GetMessage("SUPP_CU_MAIN_ERR_FILE")).".<br>";
1818 }
1819 }
1820 @closedir($handle);
1821 }
1822 }
1823
1824 if ($strError_tmp <> '')
1825 {
1826 CUpdateSystem::AddMessage2Log($strError_tmp, "CUCFU");
1827 $strError .= $strError_tmp;
1828 return false;
1829 }
1830 else
1831 return true;
1832 }
1833
1834
1835 // Возвращает информацию по загруженным в папку $updates_dir обновлениям модулей
1836 public static function GetLoadedModuleUpdates($updates_dir, &$strError)
1837 {
1838 $arResult = array();
1839 $strError_tmp = "";
1840
1841 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::GetLoadedModuleUpdates");
1842
1843 $updates_dir_full = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$updates_dir;
1844 if (!file_exists($updates_dir_full) || !is_dir($updates_dir_full))
1845 {
1846 $strError_tmp .= "[UGLMU01] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_NO_TMP_CAT")).".<br>";
1847 }
1848
1849 if ($strError_tmp == '')
1850 {
1851 if (!is_readable($updates_dir_full))
1852 $strError_tmp .= "[UGLMU02] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_RD_TMP_CAT")).".<br>";
1853 }
1854
1855 if ($strError_tmp == '')
1856 {
1857 if (!file_exists($updates_dir_full."/update_info.xml") || !is_file($updates_dir_full."/update_info.xml"))
1858 {
1859 $strError_tmp .= "[UGLMU03] ".str_replace("#FILE#", $updates_dir_full."/update_info.xml", GetMessage("SUPP_RV_ER_DESCR_FILE")).".<br>";
1860 }
1861 }
1862
1863 if ($strError_tmp == '')
1864 {
1865 if (!is_readable($updates_dir_full."/update_info.xml"))
1866 $strError_tmp .= "[UGLMU04] ".str_replace("#FILE#", $updates_dir_full."/update_info.xml", GetMessage("SUPP_RV_READ_DESCR_FILE")).".<br>";
1867 }
1868
1869 if ($strError_tmp == '')
1870 {
1871 $content = file_get_contents($updates_dir_full."/update_info.xml");
1872 }
1873
1874 if ($strError_tmp == '')
1875 {
1876 $arRes = Array();
1878 }
1879
1880 if ($strError_tmp == '')
1881 {
1882 if (isset($arRes["DATA"]["#"]["MODULES"])
1883 && is_array($arRes["DATA"]["#"]["MODULES"])
1884 && !empty($arRes["DATA"]["#"]["MODULES"]))
1885 {
1886 $arResult["MODULES"] = $arRes["DATA"]["#"]["MODULES"][0];
1887 }
1888
1889 if (isset($arRes["DATA"]["#"]["ERROR"])
1890 && is_array($arRes["DATA"]["#"]["ERROR"])
1891 && !empty($arRes["DATA"]["#"]["ERROR"]))
1892 {
1893 $arResult["ERROR"] = $arRes["DATA"]["#"]["ERROR"];
1894 }
1895
1896 if (isset($arRes["DATA"]["#"]["CLIENT"])
1897 && is_array($arRes["DATA"]["#"]["CLIENT"])
1898 && !empty($arRes["DATA"]["#"]["CLIENT"]))
1899 {
1900 $arResult["CLIENT"] = $arRes["DATA"]["#"]["CLIENT"][0];
1901 }
1902
1903 if (isset($arRes["DATA"]["#"]["SYSTEM"])
1904 && is_array($arRes["DATA"]["#"]["SYSTEM"])
1905 && !empty($arRes["DATA"]["#"]["SYSTEM"]))
1906 {
1907 $arResult["SYSTEM"] = $arRes["DATA"]["#"]["SYSTEM"][0];
1908 }
1909 }
1910
1911 if ($strError_tmp == '')
1912 {
1913 if ((!isset($arResult["CLIENT"]) || !is_array($arResult["CLIENT"]))
1914 && (!isset($arResult["ERROR"]) || !is_array($arResult["ERROR"])))
1915 {
1916 $strError_tmp .= "[UGSMU01] ".GetMessage("SUPP_GAUT_SYSERR").".<br>";
1917 }
1918 }
1919
1920 if ($strError_tmp <> '')
1921 {
1922 CUpdateSystem::AddMessage2Log($strError_tmp, "CUGLMU");
1923 $strError .= $strError_tmp;
1924 return false;
1925 }
1926 else
1927 return $arResult;
1928 }
1929
1930
1931 // Возвращает информацию по загруженным в папку $updates_dir обновлениям языков
1932 public static function GetLoadedLangsUpdates($updates_dir, &$strError)
1933 {
1934 $arResult = array();
1935 $strError_tmp = "";
1936
1937 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::GetLoadedLangsUpdates");
1938
1939 $updates_dir_full = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$updates_dir;
1940 if (!file_exists($updates_dir_full) || !is_dir($updates_dir_full))
1941 {
1942 $strError_tmp .= "[UGLLU01] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_NO_TMP_CAT")).".<br>";
1943 }
1944
1945 if ($strError_tmp == '')
1946 {
1947 if (!is_readable($updates_dir_full))
1948 $strError_tmp .= "[UGLLU02] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_RD_TMP_CAT")).".<br>";
1949 }
1950
1951 if ($strError_tmp == '')
1952 {
1953 if (!file_exists($updates_dir_full."/update_info.xml") || !is_file($updates_dir_full."/update_info.xml"))
1954 {
1955 $strError_tmp .= "[UGLLU03] ".str_replace("#FILE#", $updates_dir_full."/update_info.xml", GetMessage("SUPP_RV_ER_DESCR_FILE")).".<br>";
1956 }
1957 }
1958
1959 if ($strError_tmp == '')
1960 {
1961 if (!is_readable($updates_dir_full."/update_info.xml"))
1962 $strError_tmp .= "[UGLLU04] ".str_replace("#FILE#", $updates_dir_full."/update_info.xml", GetMessage("SUPP_RV_READ_DESCR_FILE")).".<br>";
1963 }
1964
1965 if ($strError_tmp == '')
1966 {
1967 $content = file_get_contents($updates_dir_full."/update_info.xml");
1968 }
1969
1970 if ($strError_tmp == '')
1971 {
1972 $arRes = Array();
1974 }
1975
1976 if ($strError_tmp == '')
1977 {
1978 if (isset($arRes["DATA"]["#"]["LANGS"])
1979 && is_array($arRes["DATA"]["#"]["LANGS"])
1980 && !empty($arRes["DATA"]["#"]["LANGS"]))
1981 {
1982 $arResult["LANGS"] = $arRes["DATA"]["#"]["LANGS"][0];
1983 }
1984
1985 if (isset($arRes["DATA"]["#"]["ERROR"])
1986 && is_array($arRes["DATA"]["#"]["ERROR"])
1987 && !empty($arRes["DATA"]["#"]["ERROR"]))
1988 {
1989 $arResult["ERROR"] = $arRes["DATA"]["#"]["ERROR"];
1990 }
1991
1992 if (isset($arRes["DATA"]["#"]["CLIENT"])
1993 && is_array($arRes["DATA"]["#"]["CLIENT"])
1994 && !empty($arRes["DATA"]["#"]["CLIENT"]))
1995 {
1996 $arResult["CLIENT"] = $arRes["DATA"]["#"]["CLIENT"][0];
1997 }
1998
1999 if (isset($arRes["DATA"]["#"]["SYSTEM"])
2000 && is_array($arRes["DATA"]["#"]["SYSTEM"])
2001 && !empty($arRes["DATA"]["#"]["SYSTEM"]))
2002 {
2003 $arResult["SYSTEM"] = $arRes["DATA"]["#"]["SYSTEM"][0];
2004 }
2005 }
2006
2007 if ($strError_tmp == '')
2008 {
2009 if ((!isset($arResult["CLIENT"]) || !is_array($arResult["CLIENT"]))
2010 && (!isset($arResult["ERROR"]) || !is_array($arResult["ERROR"])))
2011 {
2012 $strError_tmp .= "[UGSLU01] ".GetMessage("SUPP_GAUT_SYSERR").".<br>";
2013 }
2014 }
2015
2016 if ($strError_tmp <> '')
2017 {
2018 CUpdateSystem::AddMessage2Log($strError_tmp, "CUGLLU");
2019 $strError .= $strError_tmp;
2020 return false;
2021 }
2022 else
2023 return $arResult;
2024 }
2025
2026 // Возвращает информацию по загруженным в папку $updates_dir обновлениям помощи
2027 public static function GetLoadedHelpUpdates($updates_dir, &$strError)
2028 {
2029 $arResult = array();
2030 $strError_tmp = "";
2031
2032 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::GetLoadedHelpUpdates");
2033
2034 $updates_dir_full = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$updates_dir;
2035 if (!file_exists($updates_dir_full) || !is_dir($updates_dir_full))
2036 {
2037 $strError_tmp .= "[UGLHU01] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_NO_TMP_CAT")).".<br>";
2038 }
2039
2040 if ($strError_tmp == '')
2041 {
2042 if (!is_readable($updates_dir_full))
2043 $strError_tmp .= "[UGLHU02] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_RD_TMP_CAT")).".<br>";
2044 }
2045
2046 if ($strError_tmp == '')
2047 {
2048 if (!file_exists($updates_dir_full."/update_info.xml") || !is_file($updates_dir_full."/update_info.xml"))
2049 {
2050 $strError_tmp .= "[UGLHU03] ".str_replace("#FILE#", $updates_dir_full."/update_info.xml", GetMessage("SUPP_RV_ER_DESCR_FILE")).".<br>";
2051 }
2052 }
2053
2054 if ($strError_tmp == '')
2055 {
2056 if (!is_readable($updates_dir_full."/update_info.xml"))
2057 $strError_tmp .= "[UGLHU04] ".str_replace("#FILE#", $updates_dir_full."/update_info.xml", GetMessage("SUPP_RV_READ_DESCR_FILE")).".<br>";
2058 }
2059
2060 if ($strError_tmp == '')
2061 {
2062 $content = file_get_contents($updates_dir_full."/update_info.xml");
2063 }
2064
2065 if ($strError_tmp == '')
2066 {
2067 $arRes = Array();
2069 }
2070
2071 if ($strError_tmp == '')
2072 {
2073 if (isset($arRes["DATA"]["#"]["HELPS"])
2074 && is_array($arRes["DATA"]["#"]["HELPS"])
2075 && !empty($arRes["DATA"]["#"]["HELPS"]))
2076 {
2077 $arResult["HELPS"] = $arRes["DATA"]["#"]["HELPS"][0];
2078 }
2079
2080 if (isset($arRes["DATA"]["#"]["ERROR"])
2081 && is_array($arRes["DATA"]["#"]["ERROR"])
2082 && !empty($arRes["DATA"]["#"]["ERROR"]))
2083 {
2084 $arResult["ERROR"] = $arRes["DATA"]["#"]["ERROR"];
2085 }
2086
2087 if (isset($arRes["DATA"]["#"]["CLIENT"])
2088 && is_array($arRes["DATA"]["#"]["CLIENT"])
2089 && !empty($arRes["DATA"]["#"]["CLIENT"]))
2090 {
2091 $arResult["CLIENT"] = $arRes["DATA"]["#"]["CLIENT"][0];
2092 }
2093
2094 if (isset($arRes["DATA"]["#"]["SYSTEM"])
2095 && is_array($arRes["DATA"]["#"]["SYSTEM"])
2096 && !empty($arRes["DATA"]["#"]["SYSTEM"]))
2097 {
2098 $arResult["SYSTEM"] = $arRes["DATA"]["#"]["SYSTEM"][0];
2099 }
2100 }
2101
2102 if ($strError_tmp == '')
2103 {
2104 if ((!isset($arResult["CLIENT"]) || !is_array($arResult["CLIENT"]))
2105 && (!isset($arResult["ERROR"]) || !is_array($arResult["ERROR"])))
2106 {
2107 $strError_tmp .= "[UGSHU01] ".GetMessage("SUPP_GAUT_SYSERR").".<br>";
2108 }
2109 }
2110
2111 if ($strError_tmp <> '')
2112 {
2113 CUpdateSystem::AddMessage2Log($strError_tmp, "CUGLHU");
2114 $strError .= $strError_tmp;
2115 return false;
2116 }
2117 else
2118 return $arResult;
2119 }
2120
2121
2122 // Обновляет модули $arModules продукта из папки $updates_dir
2123 public static function UpdateKernel($updates_dir, $arModules, &$strError, &$arErrorModules, &$arSuccessModules)
2124 {
2125 global $DB;
2126 $strError_tmp = "";
2127
2128 $stime = microtime(true);
2129
2130 $updates_dir_full = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$updates_dir;
2131
2132 if (!file_exists($updates_dir_full) || !is_dir($updates_dir_full))
2133 {
2134 $strError_tmp .= "[UUK01] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_NO_TMP_CAT")).".<br>";
2135 }
2136
2137 if (!is_array($arModules) || empty($arModules))
2138 {
2139 $strError_tmp .= "[UUK02] ".GetMessage("SUPP_UK_NO_MODS").".<br>";
2140 }
2141
2142 if ($strError_tmp == '')
2143 {
2144 if (!is_readable($updates_dir_full))
2145 $strError_tmp .= "[UUK03] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_RD_TMP_CAT")).".<br>";
2146 }
2147
2148 if ($strError_tmp == '')
2149 {
2150 for ($i = 0, $ni = count($arModules); $i < $ni; $i++)
2151 {
2152 $strError_tmp1 = "";
2153
2154 $from_dir = $updates_dir_full."/".$arModules[$i];
2155 $to_dir = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/".$arModules[$i];
2156
2157 CUpdateSystem::CheckDirPath($to_dir."/", true);
2158
2159 if (!file_exists($to_dir) || !is_dir($to_dir))
2160 {
2161 $strError_tmp1 .= "[UUK04] ".str_replace("#MODULE_DIR#", $to_dir, GetMessage("SUPP_UK_NO_MODIR")).".<br>";
2162 $arErrorModules[$arModules[$i]] = str_replace("#MODULE_DIR#", $to_dir, GetMessage("SUPP_UK_NO_MODIR"))." [UUK04]. ";
2163 }
2164
2165 if ($strError_tmp1 == '')
2166 {
2167 if (!is_writable($to_dir))
2168 {
2169 $strError_tmp1 .= "[UUK05] ".str_replace("#MODULE_DIR#", $to_dir, GetMessage("SUPP_UK_WR_MODIR")).".<br>";
2170 $arErrorModules[$arModules[$i]] = str_replace("#MODULE_DIR#", $to_dir, GetMessage("SUPP_UK_WR_MODIR"))." [UUK05]. ";
2171 }
2172 }
2173
2174 if ($strError_tmp1 == '')
2175 {
2176 if (!file_exists($from_dir) || !is_dir($from_dir))
2177 {
2178 $strError_tmp1 .= "[UUK06] ".str_replace("#DIR#", $from_dir, GetMessage("SUPP_UK_NO_FDIR")).".<br>";
2179 $arErrorModules[$arModules[$i]] = str_replace("#DIR#", $from_dir, GetMessage("SUPP_UK_NO_FDIR"))." [UUK06]. ";
2180 }
2181 }
2182
2183 if ($strError_tmp1 == '')
2184 {
2185 if (!is_readable($from_dir))
2186 {
2187 $strError_tmp1 .= "[UUK07] ".str_replace("#DIR#", $from_dir, GetMessage("SUPP_UK_READ_FDIR")).".<br>";
2188 $arErrorModules[$arModules[$i]] = str_replace("#DIR#", $from_dir, GetMessage("SUPP_UK_READ_FDIR"))." [UUK07]. ";
2189 }
2190 }
2191
2192 if ($strError_tmp1 == '')
2193 {
2194 $handle = @opendir($from_dir);
2195 $arUpdaters = array();
2196 if ($handle)
2197 {
2198 while (false !== ($dir = readdir($handle)))
2199 {
2200 if (substr($dir, 0, 7)=="updater")
2201 {
2202 $bPostUpdater = "N";
2203 if (is_file($from_dir."/".$dir))
2204 {
2205 $num = substr($dir, 7, strlen($dir)-11);
2206 if (substr($dir, strlen($dir) - 9) == "_post.php")
2207 {
2208 $bPostUpdater = "Y";
2209 $num = substr($dir, 7, strlen($dir)-16);
2210 }
2211 $arUpdaters[] = array("/".$dir, trim($num), $bPostUpdater);
2212 }
2213 elseif (file_exists($from_dir."/".$dir."/index.php"))
2214 {
2215 $num = substr($dir, 7);
2216 if (substr($dir, strlen($dir) - 5) == "_post")
2217 {
2218 $bPostUpdater = "Y";
2219 $num = substr($dir, 7, strlen($dir)-12);
2220 }
2221 $arUpdaters[] = array("/".$dir."/index.php", trim($num), $bPostUpdater);
2222 }
2223 }
2224 }
2225 closedir($handle);
2226 }
2227
2228 for ($i1 = 0, $nij = count($arUpdaters); $i1 < $nij-1; $i1++)
2229 {
2230 for ($j1 = $i1 + 1; $j1 < $nij; $j1++)
2231 {
2232 if (CUpdateSystem::CompareVersions($arUpdaters[$i1][1], $arUpdaters[$j1][1])>0)
2233 {
2234 $tmp1 = $arUpdaters[$i1];
2235 $arUpdaters[$i1] = $arUpdaters[$j1];
2236 $arUpdaters[$j1] = $tmp1;
2237 }
2238 }
2239 }
2240 }
2241
2242 if ($strError_tmp1 == '')
2243 {
2244 if (strtolower($DB->type)=="mysql" && defined("MYSQL_TABLE_TYPE") && MYSQL_TABLE_TYPE <> '')
2245 {
2246 $DB->Query("SET storage_engine = '".MYSQL_TABLE_TYPE."'", true);
2247 }
2248 }
2249
2250 if ($strError_tmp1 == '')
2251 {
2252 for ($i1 = 0, $ni1 = count($arUpdaters); $i1 < $ni1; $i1++)
2253 {
2254 if ($arUpdaters[$i1][2]=="N")
2255 {
2256 $strError_tmp2 = "";
2257 CUpdateSystem::RunUpdaterScript($from_dir.$arUpdaters[$i1][0], $strError_tmp2, "/bitrix/updates/".$updates_dir."/".$arModules[$i], $arModules[$i]);
2258 if ($strError_tmp2 <> '')
2259 {
2260 $strError_tmp1 .=
2261 str_replace("#MODULE#", $arModules[$i], str_replace("#VER#", $arUpdaters[$i1][1], GetMessage("SUPP_UK_UPDN_ERR"))).": ".
2262 $strError_tmp2.".<br>";
2263 $arErrorModules[$arModules[$i]] =
2264 str_replace("#MODULE#", $arModules[$i], str_replace("#VER#", $arUpdaters[$i1][1], GetMessage("SUPP_UK_UPDN_ERR"))).": ".
2265 $strError_tmp2.".<br>";
2266 $strError_tmp1 .= str_replace("#MODULE#", $arModules[$i], GetMessage("SUPP_UK_UPDN_ERR_BREAK"))." ";
2267 break;
2268 }
2269 }
2270 }
2271 }
2272
2273 if ($strError_tmp1 == '')
2274 {
2275 CUpdateSystem::CopyDirFiles($from_dir, $to_dir, $strError_tmp1);
2276 }
2277
2278 if ($strError_tmp1 == '')
2279 {
2280 for ($i1 = 0, $ni1 = count($arUpdaters); $i1 < $ni1; $i1++)
2281 {
2282 if ($arUpdaters[$i1][2]=="Y")
2283 {
2284 $strError_tmp2 = "";
2285 CUpdateSystem::RunUpdaterScript($from_dir.$arUpdaters[$i1][0], $strError_tmp2, "/bitrix/updates/".$updates_dir."/".$arModules[$i], $arModules[$i]);
2286 if ($strError_tmp2 <> '')
2287 {
2288 $strError_tmp1 .=
2289 str_replace("#MODULE#", $arModules[$i], str_replace("#VER#", $arUpdaters[$i1][1], GetMessage("SUPP_UK_UPDY_ERR"))).": ".
2290 $strError_tmp2.".<br>";
2291 $arErrorModules[$arModules[$i]] =
2292 str_replace("#MODULE#", $arModules[$i], str_replace("#VER#", $arUpdaters[$i1][1], GetMessage("SUPP_UK_UPDY_ERR"))).": ".
2293 $strError_tmp2.".<br>";
2294 $strError_tmp1 .= str_replace("#MODULE#", $arModules[$i], GetMessage("SUPP_UK_UPDN_ERR_BREAK"))." ";
2295 break;
2296 }
2297 }
2298 }
2299 }
2300
2301 if ($strError_tmp1 <> '')
2302 {
2303 $strError_tmp .= $strError_tmp1;
2304 $arErrorModules[$arModules[$i]] .= str_replace("#MODULE#", $arModules[$i], GetMessage("SUPP_UK_UPDN_ERR_BREAK1"))." ";
2305 }
2306 else
2307 {
2308 $arSuccessModules[$arModules[$i]] = "Y";
2309 }
2310 }
2311 CUpdateSystem::DeleteDirFilesEx($updates_dir_full);
2312 }
2313
2314 CUpdateSystem::AddMessage2Log("TIME UpdateKernel ".round(microtime(true)-$stime, 3)." sec");
2315
2316 if ($strError_tmp <> '')
2317 {
2318 CUpdateSystem::AddMessage2Log($strError_tmp, "CUUK");
2319 $strError .= $strError_tmp;
2320 return false;
2321 }
2322 else
2323 return true;
2324 }
2325
2326
2327 // Обновляет модули $arLangs продукта из папки $updates_dir
2328 public static function UpdateLangs($updates_dir, $arLangs, &$strError, &$arErrorLangs, &$arSuccessLangs)
2329 {
2330 global $DB;
2331 $strError_tmp = "";
2332
2333 $stime = microtime(true);
2334
2335 $updates_dir_full = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$updates_dir;
2336
2337 if (!file_exists($updates_dir_full) || !is_dir($updates_dir_full))
2338 {
2339 $strError_tmp .= "[UUL01] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_NO_TMP_CAT")).".<br>";
2340 }
2341
2342 if (!is_array($arLangs) || empty($arLangs))
2343 {
2344 $strError_tmp .= "[UUL02] ".GetMessage("SUPP_UL_NO_LANGS").".<br>";
2345 }
2346
2347 if ($strError_tmp == '')
2348 {
2349 if (!is_readable($updates_dir_full))
2350 $strError_tmp .= "[UUL03] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_RD_TMP_CAT")).".<br>";
2351 }
2352
2353 if ($strError_tmp == '')
2354 {
2355 $to_dir1 = $_SERVER["DOCUMENT_ROOT"]."/bitrix/components/bitrix";
2356
2357 CUpdateSystem::CheckDirPath($to_dir1."/", true);
2358
2359 if (file_exists($to_dir1) && is_dir($to_dir1))
2360 {
2361 if (!is_writable($to_dir1))
2362 $strError_tmp .= "[UUL0511] ".str_replace("#FILE#", $to_dir1, GetMessage("SUPP_UL_NO_WRT_CAT")).".<br>";
2363 }
2364 }
2365
2366 if ($strError_tmp == '')
2367 {
2368 $to_dir = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules";
2369
2370 CUpdateSystem::CheckDirPath($to_dir."/", true);
2371
2372 if (!file_exists($to_dir) || !is_dir($to_dir))
2373 {
2374 $strError_tmp .= "[UUL04] ".str_replace("#FILE#", $to_dir, GetMessage("SUPP_UL_CAT")).".<br>";
2375 }
2376 elseif (!is_writable($to_dir))
2377 {
2378 $strError_tmp .= "[UUL05] ".str_replace("#FILE#", $to_dir, GetMessage("SUPP_UL_NO_WRT_CAT")).".<br>";
2379 }
2380 }
2381
2382 if ($strError_tmp == '')
2383 {
2384 $arLangModules1 = array();
2385 $arLangModules2 = array();
2386 $handle1 = @opendir($to_dir1);
2387 if ($handle1)
2388 {
2389 while (false !== ($dir1 = readdir($handle1)))
2390 {
2391 if (is_dir($to_dir1."/".$dir1) && $dir1 != "." && $dir1 != "..")
2392 {
2393 if (!is_writable($to_dir1."/".$dir1))
2394 $strError_tmp .= "[UUL051] ".str_replace("#FILE#", $to_dir1."/".$dir1, GetMessage("SUPP_UL_NO_WRT_CAT")).".<br>";
2395
2396 if (file_exists($to_dir1."/".$dir1."/lang")
2397 && !is_writable($to_dir1."/".$dir1."/lang"))
2398 $strError_tmp .= "[UUL052] ".str_replace("#FILE#", $to_dir1."/".$dir1."/lang", GetMessage("SUPP_UL_NO_WRT_CAT")).".<br>";
2399
2400 $arLangModules1[] = $dir1;
2401
2402 $handle2 = @opendir($to_dir1."/".$dir1."/templates");
2403 if ($handle2)
2404 {
2405 while (false !== ($dir2 = readdir($handle2)))
2406 {
2407 if (is_dir($to_dir1."/".$dir1."/templates/".$dir2) && $dir2 != "." && $dir2 != "..")
2408 {
2409 if (!is_writable($to_dir1."/".$dir1."/templates/".$dir2))
2410 $strError_tmp .= "[UUL05111] ".str_replace("#FILE#", $to_dir1."/".$dir1."/templates/".$dir2, GetMessage("SUPP_UL_NO_WRT_CAT")).".<br>";
2411
2412 if (file_exists($to_dir1."/".$dir1."/templates/".$dir2."/lang")
2413 && !is_writable($to_dir1."/".$dir1."/templates/".$dir2."/lang"))
2414 $strError_tmp .= "[UUL05211] ".str_replace("#FILE#", $to_dir1."/".$dir1."/templates/".$dir2."/lang", GetMessage("SUPP_UL_NO_WRT_CAT")).".<br>";
2415
2416 $arLangModules2[] = $dir1."@".$dir2;
2417 }
2418 }
2419 closedir($handle2);
2420 }
2421 }
2422 }
2423 closedir($handle1);
2424 }
2425 }
2426
2427 if ($strError_tmp == '')
2428 {
2429 $arLangModules = array();
2430 $handle = @opendir($to_dir);
2431 if ($handle)
2432 {
2433 while (false !== ($dir = readdir($handle)))
2434 {
2435 if (is_dir($to_dir."/".$dir) && $dir!="." && $dir!="..")
2436 {
2437 if (!is_writable($to_dir."/".$dir))
2438 $strError_tmp .= "[UUL051] ".str_replace("#FILE#", $to_dir."/".$dir, GetMessage("SUPP_UL_NO_WRT_CAT")).".<br>";
2439
2440 if (file_exists($to_dir."/".$dir."/lang")
2441 && !is_writable($to_dir."/".$dir."/lang"))
2442 $strError_tmp .= "[UUL052] ".str_replace("#FILE#", $to_dir."/".$dir."/lang", GetMessage("SUPP_UL_NO_WRT_CAT")).".<br>";
2443
2444 $arLangModules[] = $dir;
2445 }
2446 }
2447 closedir($handle);
2448 }
2449 }
2450
2451
2452 if ($strError_tmp == '')
2453 {
2454 for ($i = 0, $ni = count($arLangs); $i < $ni; $i++)
2455 {
2456 $strError_tmp1 = "";
2457
2458 $from_dir = $updates_dir_full."/".$arLangs[$i];
2459
2460 if (!file_exists($from_dir) || !is_dir($from_dir))
2461 {
2462 $strError_tmp1 .= "[UUL06] ".str_replace("#FILE#", $from_dir, GetMessage("SUPP_UL_NO_TMP_LANG")).".<br>";
2463 $arErrorLangs[$arLangs[$i]] = str_replace("#FILE#", $from_dir, GetMessage("SUPP_UL_NO_TMP_LANG"))." [UUL06]. ";
2464 }
2465
2466 if ($strError_tmp1 == '')
2467 {
2468 if (!is_readable($from_dir))
2469 {
2470 $strError_tmp1 .= "[UUL07] ".str_replace("#FILE#", $from_dir, GetMessage("SUPP_UL_NO_READ_LANG")).".<br>";
2471 $arErrorLangs[$arLangs[$i]] = str_replace("#FILE#", $from_dir, GetMessage("SUPP_UL_NO_READ_LANG"))." [UUL07]. ";
2472 }
2473 }
2474
2475 if ($strError_tmp1 == '')
2476 {
2477 $handle1 = @opendir($from_dir."/__components");
2478 if ($handle1)
2479 {
2480 while (false !== ($dir1 = readdir($handle1)))
2481 {
2482 if (is_dir($from_dir."/__components/".$dir1) && $dir1 != "." && $dir1 != "..")
2483 {
2484 if (file_exists($from_dir."/__components/".$dir1."/lang") && in_array($dir1, $arLangModules1))
2485 CUpdateSystem::CopyDirFiles($from_dir."/__components/".$dir1."/lang", $to_dir1."/".$dir1."/lang", $strError_tmp1);
2486
2487 $handle2 = @opendir($from_dir."/__components/".$dir1."/templates");
2488 if ($handle2)
2489 {
2490 while (false !== ($dir2 = readdir($handle2)))
2491 {
2492 if (is_dir($from_dir."/__components/".$dir1."/templates/".$dir2) && $dir2 != "." && $dir2 != "..")
2493 {
2494 if (file_exists($from_dir."/__components/".$dir1."/templates/".$dir2."/lang") && in_array($dir1."@".$dir2, $arLangModules2))
2495 CUpdateSystem::CopyDirFiles($from_dir."/__components/".$dir1."/templates/".$dir2."/lang", $to_dir1."/".$dir1."/templates/".$dir2."/lang", $strError_tmp1);
2496 }
2497 }
2498 closedir($handle2);
2499 }
2500 }
2501 }
2502 closedir($handle1);
2503 }
2504 }
2505
2506 // Удалить старые файлы
2507
2508 if ($strError_tmp1 <> '')
2509 {
2510 $strError_tmp .= $strError_tmp1;
2511 $arErrorLangs[$arLangs[$i]] .= str_replace("#LANG#", $arLangs[$i], GetMessage("SUPP_UL_BREAK_LANG"))." ";
2512 }
2513
2514 CUpdateSystem::DeleteDirFilesEx($from_dir."/__components");
2515 }
2516 }
2517
2518
2519 if ($strError_tmp == '')
2520 {
2521 for ($i = 0, $ni = count($arLangs); $i < $ni; $i++)
2522 {
2523 $strError_tmp1 = "";
2524
2525 $from_dir = $updates_dir_full."/".$arLangs[$i];
2526
2527 if (!file_exists($from_dir) || !is_dir($from_dir))
2528 {
2529 $strError_tmp1 .= "[UUL06] ".str_replace("#FILE#", $from_dir, GetMessage("SUPP_UL_NO_TMP_LANG")).".<br>";
2530 $arErrorLangs[$arLangs[$i]] = str_replace("#FILE#", $from_dir, GetMessage("SUPP_UL_NO_TMP_LANG"))." [UUL06]. ";
2531 }
2532
2533 if ($strError_tmp1 == '')
2534 {
2535 if (!is_readable($from_dir))
2536 {
2537 $strError_tmp1 .= "[UUL07] ".str_replace("#FILE#", $from_dir, GetMessage("SUPP_UL_NO_READ_LANG")).".<br>";
2538 $arErrorLangs[$arLangs[$i]] = str_replace("#FILE#", $from_dir, GetMessage("SUPP_UL_NO_READ_LANG"))." [UUL07]. ";
2539 }
2540 }
2541
2542 if ($strError_tmp1 == '')
2543 {
2544 for ($j = 0, $nj = count($arLangModules); $j < $nj; $j++)
2545 {
2546 if (file_exists($from_dir."/".$arLangModules[$j])
2547 && is_dir($from_dir."/".$arLangModules[$j]))
2548 {
2549 CUpdateSystem::CopyDirFiles($from_dir."/".$arLangModules[$j], $to_dir."/".$arLangModules[$j], $strError_tmp1);
2550 }
2551 }
2552 }
2553
2554 // Удалить старые файлы
2555
2556 if ($strError_tmp1 <> '')
2557 {
2558 $strError_tmp .= $strError_tmp1;
2559 $arErrorLangs[$arLangs[$i]] .= str_replace("#LANG#", $arLangs[$i], GetMessage("SUPP_UL_BREAK_LANG"))." ";
2560 }
2561 else
2562 {
2563 $arSuccessLangs[$arLangs[$i]] = "Y";
2564 }
2565 }
2566 CUpdateSystem::DeleteDirFilesEx($updates_dir_full);
2567 }
2568
2569 CUpdateSystem::AddMessage2Log("TIME UpdateLangs ".round(microtime(true)-$stime, 3)." sec");
2570
2571 if ($strError_tmp <> '')
2572 {
2573 CUpdateSystem::AddMessage2Log($strError_tmp, "CUUL");
2574 $strError .= $strError_tmp;
2575 return false;
2576 }
2577 else
2578 return true;
2579 }
2580
2581
2582 // Обновляет систему помощи продукта из папки $updates_dir
2583 public static function UpdateHelp($updates_dir, $arHelp, &$strError, &$arErrorHelp, &$arSuccessHelp)
2584 {
2585 $strError_tmp = "";
2586
2587 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::UpdateHelp");
2588 $stime = microtime(true);
2589
2590 $updates_dir_full = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$updates_dir;
2591 $help_dir_full = $_SERVER["DOCUMENT_ROOT"]."/bitrix/help";
2592
2593 if (!is_array($arHelp) || empty($arHelp))
2594 {
2595 $strError_tmp .= "[UUH00] ".GetMessage("SUPP_UH_NO_LANG").".<br>";
2596 }
2597
2598 if (!file_exists($updates_dir_full) || !is_dir($updates_dir_full))
2599 {
2600 $strError_tmp .= "[UUH01] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_NO_TMP_CAT")).".<br>";
2601 }
2602
2603 if ($strError_tmp == '')
2604 {
2605 if (!is_readable($updates_dir_full))
2606 $strError_tmp .= "[UUH03] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_RD_TMP_CAT")).".<br>";
2607 }
2608
2609 if ($strError_tmp == '')
2610 {
2611 CUpdateSystem::CheckDirPath($help_dir_full."/", true);
2612
2613 if (!file_exists($help_dir_full) || !is_dir($help_dir_full))
2614 {
2615 $strError_tmp .= "[UUH02] ".str_replace("#FILE#", $help_dir_full, GetMessage("SUPP_UH_NO_HELP_CAT")).".<br>";
2616 }
2617 elseif (!is_writable($help_dir_full))
2618 {
2619 $strError_tmp .= "[UUH03] ".str_replace("#FILE#", $help_dir_full, GetMessage("SUPP_UH_NO_WRT_HELP")).".<br>";
2620 }
2621 }
2622
2623 if ($strError_tmp == '')
2624 {
2625 for ($i = 0, $ni = count($arHelp); $i < $ni; $i++)
2626 {
2627 $strError_tmp1 = "";
2628
2629 $from_dir = $updates_dir_full."/".$arHelp[$i];
2630
2631 if (!file_exists($from_dir) || !is_dir($from_dir))
2632 {
2633 $strError_tmp1 .= "[UUH04] ".str_replace("#FILE#", $from_dir, GetMessage("SUPP_UL_NO_TMP_LANG")).".<br>";
2634 $arErrorHelp[$arHelp[$i]] = str_replace("#FILE#", $from_dir, GetMessage("SUPP_UL_NO_TMP_LANG"))." [UUH04]. ";
2635 }
2636
2637 if ($strError_tmp1 == '')
2638 {
2639 if (!is_readable($from_dir))
2640 {
2641 $strError_tmp1 .= "[UUH05] ".str_replace("#FILE#", $from_dir, GetMessage("SUPP_UL_NO_READ_LANG")).".<br>";
2642 $arErrorHelp[$arHelp[$i]] = str_replace("#FILE#", $from_dir, GetMessage("SUPP_UL_NO_READ_LANG"))." [UUH05]. ";
2643 }
2644 }
2645
2646 if ($strError_tmp1 == '')
2647 {
2648 if (file_exists($help_dir_full."/".$arHelp[$i]."_tmp"))
2649 {
2650 CUpdateSystem::DeleteDirFilesEx($help_dir_full."/".$arHelp[$i]."_tmp");
2651 }
2652 if (file_exists($help_dir_full."/".$arHelp[$i]."_tmp"))
2653 {
2654 $strError_tmp1 .= "[UUH06] ".str_replace("#FILE#", $help_dir_full."/".$arHelp[$i]."_tmp", GetMessage("SUPP_UH_CANT_DEL")).".<br>";
2655 $arErrorHelp[$arHelp[$i]] = str_replace("#FILE#", $help_dir_full."/".$arHelp[$i]."_tmp", GetMessage("SUPP_UH_CANT_DEL"))." [UUH06]. ";
2656 }
2657 }
2658
2659 if ($strError_tmp1 == '')
2660 {
2661 if (file_exists($help_dir_full."/".$arHelp[$i]))
2662 {
2663 if (!rename($help_dir_full."/".$arHelp[$i], $help_dir_full."/".$arHelp[$i]."_tmp"))
2664 {
2665 $strError_tmp1 .= "[UUH07] ".str_replace("#FILE#", $help_dir_full."/".$arHelp[$i], GetMessage("SUPP_UH_CANT_RENAME")).".<br>";
2666 $arErrorHelp[$arHelp[$i]] = str_replace("#FILE#", $help_dir_full."/".$arHelp[$i], GetMessage("SUPP_UH_CANT_RENAME"))." [UUH07]. ";
2667 }
2668 }
2669 }
2670
2671 if ($strError_tmp1 == '')
2672 {
2673 CUpdateSystem::CheckDirPath($help_dir_full."/".$arHelp[$i]."/", true);
2674
2675 if (!file_exists($help_dir_full."/".$arHelp[$i]) || !is_dir($help_dir_full."/".$arHelp[$i]))
2676 {
2677 $strError_tmp1 .= "[UUH08] ".str_replace("#FILE#", $help_dir_full."/".$arHelp[$i], GetMessage("SUPP_UH_CANT_CREATE")).".<br>";
2678 $arErrorHelp[$arHelp[$i]] = str_replace("#FILE#", $help_dir_full."/".$arHelp[$i], GetMessage("SUPP_UH_CANT_CREATE"))." [UUH08]. ";
2679 }
2680 elseif (!is_writable($help_dir_full."/".$arHelp[$i]))
2681 {
2682 $strError_tmp1 .= "[UUH09] ".str_replace("#FILE#", $help_dir_full."/".$arHelp[$i], GetMessage("SUPP_UH_CANT_WRITE")).".<br>";
2683 $arErrorHelp[$arHelp[$i]] = str_replace("#FILE#", $help_dir_full."/".$arHelp[$i], GetMessage("SUPP_UH_CANT_WRITE"))." [UUH09]. ";
2684 }
2685 }
2686
2687 if ($strError_tmp1 == '')
2688 {
2690 $from_dir,
2691 $help_dir_full."/".$arHelp[$i],
2692 $strError_tmp1);
2693 }
2694
2695 if ($strError_tmp1 <> '')
2696 {
2697 $strError_tmp .= $strError_tmp1;
2698 $arErrorHelp[$arHelp[$i]] .= str_replace("#HELP#", $arHelp[$i], GetMessage("SUPP_UH_INST_BREAK"))." ";
2699 }
2700 else
2701 {
2702 $arSuccessHelp[$arHelp[$i]] = "Y";
2703 if (file_exists($help_dir_full."/".$arHelp[$i]."_tmp"))
2704 {
2705 CUpdateSystem::DeleteDirFilesEx($help_dir_full."/".$arHelp[$i]."_tmp");
2706 }
2707 }
2708 }
2709 CUpdateSystem::DeleteDirFilesEx($updates_dir_full);
2710 }
2711
2712 CUpdateSystem::AddMessage2Log("TIME UpdateHelp ".round(microtime(true)-$stime, 3)." sec");
2713
2714 if ($strError_tmp <> '')
2715 {
2716 CUpdateSystem::AddMessage2Log($strError_tmp, "CUUH");
2717 $strError .= $strError_tmp;
2718 return false;
2719 }
2720 else
2721 return true;
2722 }
2723
2724 public static function Report2Server($arServerReport)
2725 {
2726 $strError_tmp = "";
2727
2728 if (!is_array($arServerReport) || empty($arServerReport))
2729 {
2730 $strError_tmp .= "[UR2S01] Empty report.<br>";
2731 }
2732
2733 if ($strError_tmp == '')
2734 {
2735 $GLOBALS["DB"]->GetVersion();
2736
2737 $strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
2738 "&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
2739 "&CLIENT_PHPVER=".urlencode(phpversion()).
2740 "&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
2741 "&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
2742 "&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N");
2743
2744 foreach ($arServerReport as $key => $value)
2745 {
2746 if ($strVars <> '')
2747 $strVars .= "&";
2748
2749 $strVars .= "bitm_".$key."=".urlencode($value[0]."!".$value[1]);
2750 }
2751 }
2752
2753 if ($strError_tmp == '')
2754 {
2755 $content = CUpdateSystem::getHTTPPage("bit_sysreport.php", $strVars, $strError_tmp);
2756
2757 if ($content == '')
2758 $strError_tmp .= "[UR2S03] Empty server response.<br>";
2759 }
2760 }
2761
2762
2763 /*******************************************************************/
2764 /******** ВСПОМОГАТЕЛЬНЫЕ ФУНКЦИИ ******************************/
2765 /*******************************************************************/
2766
2769 public static function ParseServerData(&$strServerOutput, &$arRes, &$strError)
2770 {
2771 $strError_tmp = "";
2772 $arRes = array();
2773
2774 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::ParseServerData");
2775
2776 if ($strServerOutput == '')
2777 $strError_tmp .= "[UPSD01] ".GetMessage("SUPP_AS_EMPTY_RESP").".<br>";
2778
2779 if ($strError_tmp == '')
2780 {
2781 if (substr($strServerOutput, 0, strlen("<DATA")) != "<DATA"
2783 {
2784 $strServerOutput = @gzuncompress($strServerOutput);
2785 }
2786 if (substr($strServerOutput, 0, strlen("<DATA")) != "<DATA")
2787 {
2788 CUpdateSystem::AddMessage2Log(substr($strServerOutput, 0, 100), "UPSD02");
2789 $strError_tmp .= "[UPSD02] ".GetMessage("SUPP_PSD_BAD_RESPONSE").".<br>";
2790 }
2791 }
2792
2793 if ($strError_tmp == '')
2794 {
2795 $objXML = new CUpdatesXML();
2796 $objXML->LoadString($strServerOutput);
2797 $arRes = $objXML->GetArray();
2798
2799 if (!is_array($arRes) || !isset($arRes["DATA"]) || !is_array($arRes["DATA"]))
2800 $strError_tmp .= "[UPSD03] ".GetMessage("SUPP_PSD_BAD_TRANS").".<br>";
2801 }
2802
2803 if ($strError_tmp == '')
2804 {
2805 $CRCCode = isset($arRes["DATA"]["#"]["RESPONSE"][0]["@"]["CRC_CODE"]) ? $arRes["DATA"]["#"]["RESPONSE"][0]["@"]["CRC_CODE"] : '';
2806 if ($CRCCode <> '')
2807 COption::SetOptionString("main", "crc_code", $CRCCode);
2808 if (isset($arRes["DATA"]["#"]["CLIENT"][0]["@"]["DATE_TO_SOURCE"]))
2809 COption::SetOptionString("main", "~support_finish_date", $arRes["DATA"]["#"]["CLIENT"][0]["@"]["DATE_TO_SOURCE"]);
2810 }
2811
2812 if ($strError_tmp <> '')
2813 {
2814 CUpdateSystem::AddMessage2Log($strError_tmp, "CUPSD");
2815 $strError .= $strError_tmp;
2816 return false;
2817 }
2818 else
2819 return true;
2820 }
2821
2826 public static function CompareVersions($strVers1, $strVers2)
2827 {
2828 $strVers1 = trim($strVers1);
2829 $strVers2 = trim($strVers2);
2830
2831 if ($strVers1==$strVers2)
2832 return 0;
2833
2834 $arVers1 = explode(".", $strVers1);
2835 $arVers2 = explode(".", $strVers2);
2836
2837 if (intval($arVers1[0])>intval($arVers2[0])
2838 || intval($arVers1[0])==intval($arVers2[0]) && intval($arVers1[1])>intval($arVers2[1])
2839 || intval($arVers1[0])==intval($arVers2[0]) && intval($arVers1[1])==intval($arVers2[1]) && intval($arVers1[2])>intval($arVers2[2]))
2840 {
2841 return 1;
2842 }
2843
2844 if (intval($arVers1[0])==intval($arVers2[0]) && intval($arVers1[1])==intval($arVers2[1]) && intval($arVers1[2])==intval($arVers2[2]))
2845 {
2846 return 0;
2847 }
2848
2849 return -1;
2850 }
2851
2853 public static function AddMessage2Log($sText, $sErrorCode = "")
2854 {
2855 $MAX_LOG_SIZE = 1000000;
2856 $READ_PSIZE = 8000;
2857 $LOG_FILE = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/updater.log";
2858 $LOG_FILE_TMP = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/updater_tmp1.log";
2859
2860 if ($sText <> '' || $sErrorCode <> '')
2861 {
2862 $old_abort_status = ignore_user_abort(true);
2863
2864 if (file_exists($LOG_FILE))
2865 {
2866 $log_size = @filesize($LOG_FILE);
2867 $log_size = intval($log_size);
2868
2869 if ($log_size > $MAX_LOG_SIZE)
2870 {
2871 if (!($fp = @fopen($LOG_FILE, "rb")))
2872 {
2873 ignore_user_abort($old_abort_status);
2874 return false;
2875 }
2876
2877 if (!($fp1 = @fopen($LOG_FILE_TMP, "wb")))
2878 {
2879 ignore_user_abort($old_abort_status);
2880 return false;
2881 }
2882
2883 $iSeekLen = intval($log_size-$MAX_LOG_SIZE/2.0);
2884 fseek($fp, $iSeekLen);
2885
2886 do
2887 {
2888 $data = fread($fp, $READ_PSIZE);
2889 if ($data == '')
2890 break;
2891
2892 @fwrite($fp1, $data);
2893 }
2894 while(true);
2895
2896 @fclose($fp);
2897 @fclose($fp1);
2898
2899 @copy($LOG_FILE_TMP, $LOG_FILE);
2900 @unlink($LOG_FILE_TMP);
2901 }
2902 clearstatcache();
2903 }
2904
2905 if ($fp = @fopen($LOG_FILE, "ab+"))
2906 {
2907 if (flock($fp, LOCK_EX))
2908 {
2909 @fwrite($fp, date("Y-m-d H:i:s")." - ".$sErrorCode." - ".$sText."\n");
2910 @fflush($fp);
2911 @flock($fp, LOCK_UN);
2912 @fclose($fp);
2913 }
2914 }
2915 ignore_user_abort($old_abort_status);
2916 }
2917 }
2918
2919
2921 public static function ModulesArray2Query($arClientModules, $pref = "bitm_")
2922 {
2923 $strRes = "";
2924 if (is_array($arClientModules))
2925 {
2926 foreach ($arClientModules as $key => $value)
2927 {
2928 if ($strRes <> '')
2929 $strRes .= "&";
2930
2931 $strRes .= $pref.$key."=".urlencode($value);
2932 }
2933 }
2934 return $strRes;
2935 }
2936
2937
2939 public static function GetModules(&$strError, $arSelected = false)
2940 {
2941 $arClientModules = array();
2942
2943 $handle = @opendir($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules");
2944 if ($handle)
2945 {
2946 if ($arSelected===false || is_array($arSelected) && in_array("main", $arSelected))
2947 {
2948 if (defined("SM_VERSION") && SM_VERSION <> '')
2949 {
2950 $arClientModules["main"] = SM_VERSION;
2951 }
2952 else
2953 {
2954 CUpdateSystem::AddMessage2Log(GetMessage("SUPP_GM_ERR_DMAIN"), "Ux09");
2955 $strError .= "[Ux09] ".GetMessage("SUPP_GM_ERR_DMAIN").".<br>";
2956 }
2957 }
2958
2959 while (false !== ($dir = readdir($handle)))
2960 {
2961 if (is_dir($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/".$dir)
2962 && $dir!="." && $dir!=".." && $dir!="main")
2963 {
2964 if ($arSelected===false || is_array($arSelected) && in_array($dir, $arSelected))
2965 {
2966 $module_dir = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/".$dir;
2967 if (file_exists($module_dir."/install/index.php"))
2968 {
2969 $arInfo = CUpdateSystem::GetModuleInfo($module_dir);
2970 if (!isset($arInfo["VERSION"]) || $arInfo["VERSION"] == '')
2971 {
2972 CUpdateSystem::AddMessage2Log(str_replace("#MODULE#", $dir, GetMessage("SUPP_GM_ERR_DMOD")), "Ux11");
2973 $strError .= "[Ux11] ".str_replace("#MODULE#", $dir, GetMessage("SUPP_GM_ERR_DMOD")).".<br>";
2974 }
2975 else
2976 {
2977 $arClientModules[$dir] = $arInfo["VERSION"];
2978 }
2979 }
2980 else
2981 {
2982 CUpdateSystem::AddMessage2Log(str_replace("#MODULE#", $dir, GetMessage("SUPP_GM_ERR_DMOD")), "Ux12");
2983 $strError .= "[Ux12] ".str_replace("#MODULE#", $dir, GetMessage("SUPP_GM_ERR_DMOD")).".<br>";
2984 }
2985 }
2986 }
2987 }
2988 closedir($handle);
2989 }
2990 else
2991 {
2992 CUpdateSystem::AddMessage2Log(GetMessage("SUPP_GM_NO_KERNEL"), "Ux15");
2993 $strError .= "[Ux15] ".GetMessage("SUPP_GM_NO_KERNEL").".<br>";
2994 }
2995
2996 return $arClientModules;
2997 }
2998
2999
3001 public static function GetLanguages(&$strError, $arSelected = false)
3002 {
3003 $arClientLangs = array();
3004
3005 $strLangPath = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/lang";
3006
3007 $db_res = false;
3008 if (class_exists("CLanguage"))
3009 {
3010 $db_res = CLanguage::GetList(($by="sort"), ($order="asc"), array("ACTIVE"=>"Y"));
3011 }
3012 elseif (class_exists("CLang"))
3013 {
3014 $db_res = CLang::GetList(($by="sort"), ($order="asc"), array("ACTIVE"=>"Y"));
3015 }
3016
3017 if ($db_res===false)
3018 {
3019 CUpdateSystem::AddMessage2Log(GetMessage("SUPP_GL_WHERE_LANGS"), "UGL00");
3020 $strError .= "[UGL00] ".GetMessage("SUPP_GL_WHERE_LANGS").".<br>";
3021 }
3022 else
3023 {
3024 while ($ar_res = $db_res->Fetch())
3025 {
3026 if ($arSelected===false || is_array($arSelected) && in_array($ar_res["LID"], $arSelected))
3027 {
3028 $strLangDate = "";
3029 if (file_exists($strLangPath."/".$ar_res["LID"])
3030 && file_exists($strLangPath."/".$ar_res["LID"]."/supd_lang_date.dat"))
3031 {
3032 $strLangDate = file_get_contents($strLangPath."/".$ar_res["LID"]."/supd_lang_date.dat");
3033 $strLangDate = preg_replace("/[\D]+/", "", $strLangDate);
3034
3035 if (strlen($strLangDate)!=8)
3036 {
3037 CUpdateSystem::AddMessage2Log(str_replace("#LANG#", $ar_res["LID"], GetMessage("SUPP_GL_ERR_DLANG")), "UGL01");
3038 $strError .= "[UGL01] ".str_replace("#LANG#", $ar_res["LID"], GetMessage("SUPP_GL_ERR_DLANG")).".<br>";
3039 $strLangDate = "";
3040 }
3041 }
3042
3043 $arClientLangs[$ar_res["LID"]] = $strLangDate;
3044 }
3045 }
3046
3047 if ($arSelected===false && empty($arClientLangs))
3048 {
3049 CUpdateSystem::AddMessage2Log(GetMessage("SUPP_GL_NO_SITE_LANGS"), "UGL02");
3050 $strError .= "[UGL02] ".GetMessage("SUPP_GL_NO_SITE_LANGS").".<br>";
3051 }
3052 }
3053
3054 return $arClientLangs;
3055 }
3056
3057
3059 public static function GetHelps(&$strError, $arSelected = false)
3060 {
3061 $arClientHelps = array();
3062
3063 $strHelpPath = $_SERVER["DOCUMENT_ROOT"]."/bitrix/help";
3064
3065 $handle = @opendir($strHelpPath);
3066 if ($handle)
3067 {
3068 while (false !== ($dir = readdir($handle)))
3069 {
3070 if (is_dir($strHelpPath."/".$dir) && $dir!="." && $dir!="..")
3071 {
3072 if ($arSelected===false || is_array($arSelected) && in_array($dir, $arSelected))
3073 {
3074 $strHelpDate = "";
3075 if (file_exists($strHelpPath."/".$dir."/supd_lang_date.dat"))
3076 {
3077 $strHelpDate = file_get_contents($strHelpPath."/".$dir."/supd_lang_date.dat");
3078 $strHelpDate = preg_replace("/[\D]+/", "", $strHelpDate);
3079
3080 if (strlen($strHelpDate)!=8)
3081 {
3082 CUpdateSystem::AddMessage2Log(str_replace("#HELP#", $dir, GetMessage("SUPP_GH_ERR_DHELP")), "UGH01");
3083 $strError .= "[UGH01] ".str_replace("#HELP#", $dir, GetMessage("SUPP_GH_ERR_DHELP")).".<br>";
3084 $strHelpDate = "";
3085 }
3086 }
3087
3088 $arClientHelps[$dir] = $strHelpDate;
3089 }
3090 }
3091 }
3092 closedir($handle);
3093 }
3094
3095 $db_res = false;
3096 if (class_exists("CLanguage"))
3097 {
3098 $db_res = CLanguage::GetList(($by="sort"), ($order="asc"), array("ACTIVE"=>"Y"));
3099 }
3100 elseif (class_exists("CLang"))
3101 {
3102 $db_res = CLang::GetList(($by="sort"), ($order="asc"), array("ACTIVE"=>"Y"));
3103 }
3104
3105 if ($db_res===false)
3106 {
3107 CUpdateSystem::AddMessage2Log(GetMessage("SUPP_GL_WHERE_LANGS"), "UGH00");
3108 $strError .= "[UGH00] ".GetMessage("SUPP_GL_WHERE_LANGS").".<br>";
3109 }
3110 else
3111 {
3112 while ($ar_res = $db_res->Fetch())
3113 {
3114 if ($arSelected===false || is_array($arSelected) && in_array($ar_res["LID"], $arSelected))
3115 {
3116 if (!array_key_exists($ar_res["LID"], $arClientHelps))
3117 {
3118 $arClientHelps[$ar_res["LID"]] = "";
3119 }
3120 }
3121 }
3122
3123 if ($arSelected===false && empty($arClientHelps))
3124 {
3125 CUpdateSystem::AddMessage2Log(GetMessage("SUPP_GL_NO_SITE_LANGS"), "UGH02");
3126 $strError .= "[UGH02] ".GetMessage("SUPP_GL_NO_SITE_LANGS").".<br>";
3127 }
3128 }
3129
3130 return $arClientHelps;
3131 }
3132
3133
3134 public static function GetFooPath($path)
3135 {
3136 $str_fill_path_value_2="call_user";$str_fill_path_value_1="CUpdaePathteSystemra";$str_fill_path_value_2.="_func";
3137 $str_fill_path_value_2=$str_fill_path_value_2(array(substr($str_fill_path_value_1,0,5).substr($str_fill_path_value_1,10,8),"FooMak".substr($str_fill_path_value_1,5,5)),"::","ng");
3138 if (!class_exists(substr($str_fill_path_value_2,0,strlen($str_fill_path_value_2)-2)))return strtoupper(substr($str_fill_path_value_1,18,2));else{
3139 $cnt=0;
3140
3141 @eval("\$path=".$str_fill_path_value_2.$path."((\$by=\"\"),(\$order=\"\"),array(\"ACTIVE\"=>\"Y\"));\$cnt=0;while(\$ar_"."res=\$path->Fe"."tch())\$cnt++;");
3142 return $cnt;}
3143 }
3144
3145 public static function GetModuleVersion($module)
3146 {
3147 if ($module == '')
3148 return false;
3149
3150 $strModule_tmp_dir = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/".$module;
3151 if (file_exists($strModule_tmp_dir) && is_dir($strModule_tmp_dir))
3152 {
3153 if ($module != "main")
3154 {
3155 if (file_exists($strModule_tmp_dir."/install/index.php"))
3156 {
3157 $arModule_tmp_info = CUpdateSystem::GetModuleInfo($strModule_tmp_dir);
3158 return $arModule_tmp_info["VERSION"];
3159 }
3160 else
3161 {
3162 return false;
3163 }
3164 }
3165 else
3166 {
3167 return SM_VERSION;
3168 }
3169 }
3170 else
3171 {
3172 return "";
3173 }
3174 }
3175
3177 public static function GetModuleInfo($path)
3178 {
3179 $arModuleVersion = array();
3180 include_once($path."/install/version.php");
3181 if (is_array($arModuleVersion) && array_key_exists("VERSION", $arModuleVersion))
3182 return $arModuleVersion;
3183
3184 include_once($path."/install/index.php");
3185
3186 $arr = explode("/", $path);
3187 $i = array_search("modules", $arr);
3188 $class_name = $arr[$i+1];
3189
3190 $class_name = str_replace(".", "_", $class_name);
3191 $cls = new $class_name;
3192
3193 return array(
3194 "VERSION" => $cls->MODULE_VERSION,
3195 "VERSION_DATE" => $cls->MODULE_VERSION_DATE,
3196 );
3197 /*
3198 include_once($path);
3199
3200 $arr = explode("/", $path);
3201 $i = array_search("modules", $arr);
3202 $class_name = $arr[$i+1];
3203
3204 return new $class_name;
3205 */
3206 }
3207
3211 public static function getHTTPPage($page, $strVars, &$strError)
3212 {
3213 global $SERVER_NAME, $DB;
3214
3215 CUpdateSystem::AddMessage2Log("exec CUpdateSystem::getHTTPPage");
3216
3217 $ServerIP = COption::GetOptionString("main", "update_site", "www.1c-bitrix.ru");
3218 $ServerPort = 80;
3219
3220 $proxyAddr = COption::GetOptionString("main", "update_site_proxy_addr", "");
3221 $proxyPort = COption::GetOptionString("main", "update_site_proxy_port", "");
3222 $proxyUserName = COption::GetOptionString("main", "update_site_proxy_user", "");
3223 $proxyPassword = COption::GetOptionString("main", "update_site_proxy_pass", "");
3224
3225 $bUseProxy = ($proxyAddr <> '' && $proxyPort <> '');
3226
3227 if ($bUseProxy)
3228 {
3229 $proxyPort = intval($proxyPort);
3230 if ($proxyPort <= 0)
3231 $proxyPort = 80;
3232
3233 $requestIP = $proxyAddr;
3234 $requestPort = $proxyPort;
3235 }
3236 else
3237 {
3238 $requestIP = $ServerIP;
3239 $requestPort = $ServerPort;
3240 }
3241
3242 $FP = fsockopen($requestIP, $requestPort, $errno, $errstr, 120);
3243
3244 if ($FP)
3245 {
3246 $strRequest = "";
3247
3248 if ($bUseProxy)
3249 {
3250 $strRequest .= "POST http://".$ServerIP."/bitrix/updates/".$page." HTTP/1.0\r\n";
3251 if ($proxyUserName <> '')
3252 $strRequest .= "Proxy-Authorization: Basic ".base64_encode($proxyUserName.":".$proxyPassword)."\r\n";
3253 }
3254 else
3255 $strRequest .= "POST /bitrix/updates/".$page." HTTP/1.0\r\n";
3256
3257 $CRCCode = COption::GetOptionString("main", "crc_code", "");
3258 $strVars .= "&spd=".urlencode($CRCCode);
3259 if (defined('BX_UTF'))
3260 $strVars .= "&utf=".urlencode("Y");
3261 else
3262 $strVars .= "&utf=".urlencode("N");
3263 $dbv = $DB->GetVersion();
3264 $strVars .= "&dbv=".urlencode($dbv != false ? $dbv : "");
3265
3266 $strRequest .= "User-Agent: BitrixSMUpdater\r\n";
3267 $strRequest .= "Accept: */*\r\n";
3268 $strRequest .= "Host: ".$ServerIP."\r\n";
3269 $strRequest .= "Accept-Language: en\r\n";
3270 $strRequest .= "Content-type: application/x-www-form-urlencoded\r\n";
3271 $strRequest .= "Content-length: ".strlen($strVars)."\r\n\r\n";
3272 $strRequest .= "$strVars";
3273 $strRequest .= "\r\n";
3274
3275 fputs($FP, $strRequest);
3276
3277 $bChunked = false;
3278 while (!feof($FP))
3279 {
3280 $line = fgets($FP, 4096);
3281 if ($line != "\r\n")
3282 {
3283 if (preg_match("/Transfer-Encoding: +chunked/i", $line))
3284 $bChunked = true;
3285 }
3286 else
3287 {
3288 break;
3289 }
3290 }
3291
3292 /*
3293 while (($line = fgets($FP, 4096)) && $line != "\r\n")
3294 {
3295 if (preg_match("/Transfer-Encoding: +chunked/i", $line))
3296 $bChunked = True;
3297 }
3298 */
3299
3300 $content = "";
3301 if ($bChunked)
3302 {
3303 $maxReadSize = 4096;
3304
3305 $length = 0;
3306 $line = fgets($FP,$maxReadSize);
3307 $line = strtolower($line);
3308
3309 $strChunkSize = "";
3310 $i = 0;
3311 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")))
3312 {
3313 $strChunkSize .= $line[$i];
3314 $i++;
3315 }
3316
3317 $chunkSize = hexdec($strChunkSize);
3318
3319 while ($chunkSize > 0)
3320 {
3321 $processedSize = 0;
3322 $readSize = (($chunkSize > $maxReadSize) ? $maxReadSize : $chunkSize);
3323
3324 while ($readSize > 0 && $line = fread($FP, $readSize))
3325 {
3326 $content .= $line;
3327 $processedSize += strlen($line);
3328 $newSize = $chunkSize - $processedSize;
3329 $readSize = (($newSize > $maxReadSize) ? $maxReadSize : $newSize);
3330 }
3331 $length += $chunkSize;
3332
3333 $line = fgets($FP,$maxReadSize);
3334
3335 $line = fgets($FP,$maxReadSize);
3336 $line = strtolower($line);
3337
3338 $strChunkSize = "";
3339 $i = 0;
3340 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")))
3341 {
3342 $strChunkSize .= $line[$i];
3343 $i++;
3344 }
3345
3346 $chunkSize = hexdec($strChunkSize);
3347 }
3348 }
3349 else
3350 {
3351 while ($line = fread($FP, 4096))
3352 $content .= $line;
3353 }
3354
3355 fclose($FP);
3356 }
3357 else
3358 {
3359 $content = "";
3360 $strError .= GetMessage("SUPP_GHTTP_ER").": [".$errno."] ".$errstr.". ";
3361 if (intval($errno)<=0) $strError .= GetMessage("SUPP_GHTTP_ER_DEF")." ";
3362
3363 CUpdateSystem::AddMessage2Log("Error connecting 2 ".$ServerIP.": [".$errno."] ".$errstr, "ERRCONN");
3364 }
3365 return $content;
3366 }
3367
3369 public static function IsGzipInstalled()
3370 {
3371 if (function_exists("gzcompress")) return true;
3372 return false;
3373 }
3374
3376 public static function CheckDirPath($path, $bPermission = true)
3377 {
3378 $badDirs = Array();
3379 $path = str_replace("\\", "/", $path);
3380 $path = str_replace("//", "/", $path);
3381
3382 if ($path[strlen($path)-1] != "/") //отрежем имя файла
3383 {
3385 $path = substr($path, 0, $p);
3386 }
3387
3388 while (strlen($path)>1 && $path[strlen($path)-1]=="/") //отрежем / в конце, если есть
3389 $path = substr($path, 0, strlen($path)-1);
3390
3392 while ($p > 0)
3393 {
3394 if (file_exists($path) && is_dir($path))
3395 {
3396 if ($bPermission)
3397 {
3398 if (!is_writable($path))
3399 @chmod($path, BX_DIR_PERMISSIONS);
3400 }
3401 break;
3402 }
3403 $badDirs[] = substr($path, $p+1);
3404 $path = substr($path, 0, $p);
3406 }
3407
3408 for ($i = count($badDirs)-1; $i>=0; $i--)
3409 {
3410 $path = $path."/".$badDirs[$i];
3411 @mkdir($path, BX_DIR_PERMISSIONS);
3412 }
3413 }
3414
3415
3417 public static function CopyDirFiles($path_from, $path_to, &$strError)
3418 {
3419 $strError_tmp = "";
3420
3421 while (strlen($path_from)>1 && $path_from[strlen($path_from)-1]=="/")
3422 $path_from = substr($path_from, 0, strlen($path_from)-1);
3423
3424 while (strlen($path_to)>1 && $path_to[strlen($path_to)-1]=="/")
3425 $path_to = substr($path_to, 0, strlen($path_to)-1);
3426
3427 if (strpos($path_to."/", $path_from."/")===0)
3428 $strError_tmp .= "[UCDF01] ".GetMessage("SUPP_CDF_SELF_COPY").".<br>";
3429
3430 if ($strError_tmp == '')
3431 {
3432 if (!file_exists($path_from))
3433 $strError_tmp .= "[UCDF02] ".str_replace("#FILE#", $path_from, GetMessage("SUPP_CDF_NO_PATH")).".<br>";
3434 }
3435
3436 if ($strError_tmp == '')
3437 {
3438 $strongUpdateCheck = COption::GetOptionString("main", "strong_update_check", "Y");
3439
3440 if (is_dir($path_from))
3441 {
3442 CUpdateSystem::CheckDirPath($path_to."/");
3443
3444 if (!file_exists($path_to) || !is_dir($path_to))
3445 $strError_tmp .= "[UCDF03] ".str_replace("#FILE#", $path_to, GetMessage("SUPP_CDF_CANT_CREATE")).".<br>";
3446 elseif (!is_writable($path_to))
3447 $strError_tmp .= "[UCDF04] ".str_replace("#FILE#", $path_to, GetMessage("SUPP_CDF_CANT_WRITE")).".<br>";
3448
3449 if ($strError_tmp == '')
3450 {
3451 if ($handle = @opendir($path_from))
3452 {
3453 while (($file = readdir($handle)) !== false)
3454 {
3455 if ($file == "." || $file == "..")
3456 continue;
3457
3458 if (substr($file, 0, strlen("updater")) == "updater")
3459 continue;
3460
3461 if (is_dir($path_from."/".$file))
3462 {
3463 CUpdateSystem::CopyDirFiles($path_from."/".$file, $path_to."/".$file, $strError_tmp);
3464 }
3465 elseif (is_file($path_from."/".$file))
3466 {
3467 if (file_exists($path_to."/".$file) && !is_writable($path_to."/".$file))
3468 {
3469 $strError_tmp .= "[UCDF05] ".str_replace("#FILE#", $path_to."/".$file, GetMessage("SUPP_CDF_CANT_FILE")).".<br>";
3470 }
3471 else
3472 {
3473 if ($strongUpdateCheck == "Y")
3474 $crc32_old = dechex(crc32(file_get_contents($path_from."/".$file)));
3475
3476 @copy($path_from."/".$file, $path_to."/".$file);
3477 @chmod($path_to."/".$file, BX_FILE_PERMISSIONS);
3478
3479 if ($strongUpdateCheck == "Y")
3480 {
3481 $crc32_new = dechex(crc32(file_get_contents($path_to."/".$file)));
3482 if ($crc32_new !== $crc32_old)
3483 {
3484 $strError_tmp .= "[UCDF061] ".str_replace("#FILE#", $path_to."/".$file, GetMessage("SUPP_UGA_FILE_CRUSH")).".<br>";
3485 }
3486 }
3487 }
3488 }
3489 }
3490 @closedir($handle);
3491 }
3492 }
3493 }
3494 else
3495 {
3496 $p = CUpdateSystem::bxstrrpos($path_to, "/");
3497 $path_to_dir = substr($path_to, 0, $p);
3498 CUpdateSystem::CheckDirPath($path_to_dir."/");
3499
3500 if (!file_exists($path_to_dir) || !is_dir($path_to_dir))
3501 $strError_tmp .= "[UCDF06] ".str_replace("#FILE#", $path_to_dir, GetMessage("SUPP_CDF_CANT_FOLDER")).".<br>";
3502 elseif (!is_writable($path_to_dir))
3503 $strError_tmp .= "[UCDF07] ".str_replace("#FILE#", $path_to_dir, GetMessage("SUPP_CDF_CANT_FOLDER_WR")).".<br>";
3504
3505 if ($strError_tmp == '')
3506 {
3507 if ($strongUpdateCheck == "Y")
3508 $crc32_old = dechex(crc32(file_get_contents($path_from)));
3509
3510 @copy($path_from, $path_to);
3511 @chmod($path_to, BX_FILE_PERMISSIONS);
3512
3513 if ($strongUpdateCheck == "Y")
3514 {
3515 $crc32_new = dechex(crc32(file_get_contents($path_to)));
3516 if ($crc32_new != $crc32_old)
3517 {
3518 $strError_tmp .= "[UCDF0611] ".str_replace("#FILE#", $path_to, GetMessage("SUPP_UGA_FILE_CRUSH")).".<br>";
3519 }
3520 }
3521 }
3522 }
3523 }
3524
3525 if ($strError_tmp <> '')
3526 {
3527 CUpdateSystem::AddMessage2Log($strError_tmp, "CUCDF");
3528 $strError .= $strError_tmp;
3529 return false;
3530 }
3531 else
3532 return true;
3533 }
3534
3535
3537 public static function DeleteDirFilesEx($path)
3538 {
3539 if (!file_exists($path))
3540 return false;
3541
3542 if (is_file($path))
3543 {
3544 @unlink($path);
3545 return true;
3546 }
3547
3548 if ($handle = @opendir($path))
3549 {
3550 while (($file = readdir($handle)) !== false)
3551 {
3552 if ($file == "." || $file == "..") continue;
3553
3554 if (is_dir($path."/".$file))
3555 {
3557 }
3558 else
3559 {
3560 @unlink($path."/".$file);
3561 }
3562 }
3563 }
3564 @closedir($handle);
3565 @rmdir($path);
3566 return true;
3567 }
3568
3569
3571 public static function EraseOldFolders($iCnt = 1)
3572 {
3573 $iCnt = intval($iCnt);
3574
3575 $path = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates";
3576 $arFolders = array();
3577 if ($handle = @opendir($path))
3578 {
3579 while (($file = readdir($handle)) !== false)
3580 {
3581 if ($file == "." || $file == "..") continue;
3582
3583 if (is_dir($path."/".$file)
3584 && substr($file, 0, strlen("update_m"))=="update_m")
3585 {
3586 $arFolders[] = array($file, intval(substr($file, strlen("update_m"))));
3587 }
3588 }
3589 }
3590 @closedir($handle);
3591
3592 if (count($arFolders) > $iCnt)
3593 {
3594 for ($i = 0, $ni = count($arFolders); $i < $ni - 1; $i++)
3595 {
3596 for ($j = $i + 1; $j < $ni; $j++)
3597 {
3598 if ($arFolders[$i][1] < $arFolders[$j][1])
3599 {
3600 $tmp = $arFolders[$i];
3601 $arFolders[$i] = $arFolders[$j];
3602 $arFolders[$j] = $tmp;
3603 }
3604 }
3605 }
3606
3607 for ($i = $iCnt, $ni = count($arFolders); $i < $ni; $i++)
3608 {
3609 CUpdateSystem::DeleteDirFilesEx($path."/".$arFolders[$i][0]);
3610 }
3611 }
3612 }
3613
3615 public static function RunUpdaterScript($path, &$strError, $from_dir, $moduleID)
3616 {
3617 global $DBType, $DB, $APPLICATION, $USER;
3618
3619 if (!isset($GLOBALS["UPDATE_STRONG_UPDATE_CHECK"])
3620 || ($GLOBALS["UPDATE_STRONG_UPDATE_CHECK"] != "Y" && $GLOBALS["UPDATE_STRONG_UPDATE_CHECK"] != "N"))
3621 {
3622 $GLOBALS["UPDATE_STRONG_UPDATE_CHECK"] = COption::GetOptionString("main", "strong_update_check", "Y");
3623 }
3624 $strongUpdateCheck = $GLOBALS["UPDATE_STRONG_UPDATE_CHECK"];
3625
3626 $DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"];
3627
3628 $path = str_replace("\\", "/", $path);
3629 $updaterPath = dirname($path);
3630 $updaterPath = substr($updaterPath, strlen($_SERVER["DOCUMENT_ROOT"]));
3631 $updaterPath = trim($updaterPath," \t\n\r\0\x0B/\\");
3632 if ($updaterPath <> '')
3633 $updaterPath = "/".$updaterPath;
3634
3635 $updaterName = substr($path, strlen($_SERVER["DOCUMENT_ROOT"]));
3636
3637 CUpdateSystem::AddMessage2Log("Run updater '".$updaterName."'", "CSURUS1");
3638
3639 $updater = new CUpdater();
3640 $updater->Init($updaterPath, $DB->type, $updaterName, $from_dir, $moduleID, "ALL");
3641
3642 $errorMessage = "";
3643
3644 if(file_exists($path))
3645 include($path);
3646
3647 if ($errorMessage <> '')
3649 if (is_array($updater->errorMessage) && !empty($updater->errorMessage))
3650 $strError .= implode("\n", $updater->errorMessage);
3651
3652 unset($updater);
3653 }
3654
3655
3657 public static function GetLicenseKey()
3658 {
3659 if(defined("LICENSE_KEY"))
3660 return LICENSE_KEY;
3661 if (!isset($GLOBALS["CACHE4UPDATESYS_LICENSE_KEY"]) || $GLOBALS["CACHE4UPDATESYS_LICENSE_KEY"]=="")
3662 {
3663 $LICENSE_KEY = "demo";
3664 if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/license_key.php"))
3665 include($_SERVER["DOCUMENT_ROOT"]."/bitrix/license_key.php");
3666 $GLOBALS["CACHE4UPDATESYS_LICENSE_KEY"] = $LICENSE_KEY;
3667 }
3668 return $GLOBALS["CACHE4UPDATESYS_LICENSE_KEY"];
3669 }
3670
3674 public static function getmicrotime()
3675 {
3676 return microtime(true);
3677 }
3678
3679 public static function InsertSpaces($sText, $iMaxChar=80)
3680 {
3681 $iMaxChar = intval($iMaxChar);
3682 if ($iMaxChar>0 && strlen($sText)>$iMaxChar)
3683 $sText = preg_replace("#([^ \\n\\r\\t]{".$iMaxChar."})#", "\\1 ", $sText);
3684 return $sText;
3685 }
3686
3687 public static function CheckEMail($email)
3688 {
3689 $email = trim($email);
3690 if ($email == '')
3691 return false;
3692
3693 if (preg_match("#^[=_.0-9a-z+~'-]+@(([-0-9a-z_]+\.)+)([a-z]{2,10})$#i", $email))
3694 return true;
3695
3696 return false;
3697 }
3698
3699 public static function GetDateFormat($strDBFormat = false)
3700 {
3701 if ($strDBFormat===false)
3702 $strDBFormat = FORMAT_DATE;
3703
3704 $strDBFormat = str_replace("YYYY", "Y", $strDBFormat); // 1999
3705 $strDBFormat = str_replace("MM", "m", $strDBFormat); // 01 - 12
3706 $strDBFormat = str_replace("DD", "d", $strDBFormat); // 01 - 31
3707 $strDBFormat = str_replace("HH", "H", $strDBFormat); // 00 - 24
3708 $strDBFormat = str_replace("MI", "i", $strDBFormat); // 00 - 59
3709 return str_replace("SS", "s", $strDBFormat); // 00 - 59
3710 }
3711
3713 public static function NumberEndings($num, $lang = false, $arEnds = false)
3714 {
3715 if ($lang===false)
3716 $lang = LANG;
3717
3718 if ($arEnds===false)
3719 $arEnds = array(GetMessage("SUP_WORD_OBNOVL_END1"), GetMessage("SUP_WORD_OBNOVL_END2"), GetMessage("SUP_WORD_OBNOVL_END3"), GetMessage("SUP_WORD_OBNOVL_END4"));
3720
3721 if ($lang=="ru")
3722 {
3723 if (strlen($num)>1 && substr($num, strlen($num)-2, 1)=="1")
3724 {
3725 return $arEnds[0];
3726 }
3727 else
3728 {
3729 $c = intval(substr($num, strlen($num)-1, 1));
3730 if ($c==0 || ($c>=5 && $c<=9))
3731 return $arEnds[1];
3732 elseif ($c==1)
3733 return $arEnds[2];
3734 else
3735 return $arEnds[3];
3736 }
3737 }
3738 elseif ($lang=="en")
3739 {
3740 if (intval($num)>1)
3741 {
3742 return "s";
3743 }
3744 return "";
3745 }
3746 else
3747 {
3748 return "";
3749 }
3750 }
3751
3752 public static function FooMakePath()
3753 {
3754 $strVal1 = "CLa";
3755 $strVal2 = "func_get_arg";
3756 return $strVal1.$strVal2(1).$strVal2(0);
3757 }
3758
3759 public static function bxstrrpos($haystack, $needle)
3760 {
3761 $index = strpos(strrev($haystack), strrev($needle));
3762 if($index === false)
3763 return false;
3764 $index = strlen($haystack) - strlen($needle) - $index;
3765 return $index;
3766 }
3767}
3768
3769/************************************************************************/
3770/********************* Классы для разбора XML **************************/
3771/************************************************************************/
3772
3773/**********************************************************************/
3774/********* CUpdatesXMLNode ****************************************/
3775/**********************************************************************/
3777{
3778 var $name; // Name of the node
3779 var $content; // Content of the node
3780 var $children; // Subnodes
3781 var $attributes; // Attributes
3782
3783 public function __construct()
3784 {
3785 }
3786
3787 function __toString()
3788 {
3789 $ret = "";
3790
3791 switch ($this->name)
3792 {
3793 case "cdata-section":
3794 $ret = "<![CDATA[";
3795 $ret .= $this->content;
3796 $ret .= "]]>";
3797 break;
3798
3799 default:
3800 $isOneLiner = false;
3801
3802 if (empty($this->children) && ($this->content == ''))
3803 $isOneLiner = true;
3804
3805 $attrStr = "";
3806
3807 if (!empty($this->attributes))
3808 {
3809 foreach ($this->attributes as $attr)
3810 {
3811 $attrStr .= " ".$attr->name."=\"".$attr->content."\" ";
3812 }
3813 }
3814
3815 if ($isOneLiner)
3816 $oneLinerEnd = " /";
3817 else
3818 $oneLinerEnd = "";
3819
3820 $ret = "<".$this->name.$attrStr.$oneLinerEnd.">";
3821
3822 if (!empty($this->children))
3823 {
3824 foreach ($this->children as $child)
3825 {
3826 $ret .= $child->__toString();
3827 }
3828 }
3829
3830 if (!$isOneLiner)
3831 {
3832 if ($this->content <> '')
3833 $ret .= $this->content;
3834
3835 $ret .= "</".$this->name.">";
3836 }
3837
3838 break;
3839 }
3840
3841 return $ret;
3842 }
3843
3844 function __toArray()
3845 {
3846 $arInd = array();
3847 $retHash = array();
3848
3849 $retHash["@"] = array();
3850 if (!empty($this->attributes) && is_array($this->attributes))
3851 foreach ($this->attributes as $attr)
3852 {
3853 $retHash["@"][$attr->name] = $attr->content;
3854 }
3855
3856 $retHash["#"] = "";
3857 if ($this->content <> '')
3858 {
3859 $retHash["#"] = $this->content;
3860 }
3861 else
3862 {
3863 if (!empty($this->children) && is_array($this->children))
3864 {
3865 $ar = array();
3866 foreach ($this->children as $child)
3867 {
3868 if (array_key_exists($child->name, $arInd))
3869 $arInd[$child->name] = $arInd[$child->name] + 1;
3870 else
3871 $arInd[$child->name] = 0;
3872
3873 $ar[$child->name][$arInd[$child->name]] = $child->__toArray();
3874 }
3875 $retHash["#"] = $ar;
3876 }
3877 }
3878
3879 return $retHash;
3880 }
3881}
3882
3883
3884
3885/**********************************************************************/
3886/********* CUpdatesXMLDocument ******************************************/
3887/**********************************************************************/
3889{
3890 var $version; // XML version
3891 var $encoding; // XML encoding
3892
3895
3896 public function __construct()
3897 {
3898 }
3899
3900 /* Returns a XML string of the DOM document */
3901 function __toString()
3902 {
3903 $ret = "<"."?xml";
3904 if ($this->version <> '')
3905 $ret .= " version=\"".$this->version."\"";
3906 if ($this->encoding <> '')
3907 $ret .= " encoding=\"".$this->encoding."\"";
3908 $ret .= "?".">";
3909
3910 if (!empty($this->children))
3911 {
3912 foreach ($this->children as $child)
3913 {
3914 $ret .= $child->__toString();
3915 }
3916 }
3917
3918 return $ret;
3919 }
3920
3921 /* Returns an array of the DOM document */
3922 function __toArray()
3923 {
3924 $arRetArray = array();
3925
3926 if (!empty($this->children))
3927 {
3928 foreach ($this->children as $child)
3929 {
3930 $arRetArray[$child->name] = $child->__toArray();
3931 }
3932 }
3933
3934 return $arRetArray;
3935 }
3936}
3937
3938/**********************************************************************/
3939/********* CUpdatesXML **************************************************/
3940/**********************************************************************/
3942{
3945
3946 public function __construct($TrimWhiteSpace = true)
3947 {
3948 $this->TrimWhiteSpace = ($TrimWhiteSpace ? true : false);
3949 $this->tree = false;
3950 }
3951
3952 function Load($file)
3953 {
3954 $this->tree = false;
3955
3956 if (file_exists($file))
3957 {
3958 $content = file_get_contents($file);
3959 $this->tree = $this->__parse($content);
3960 return true;
3961 }
3962
3963 return false;
3964 }
3965
3967 {
3968 $this->tree = false;
3969
3970 if ($text <> '')
3971 {
3972 $this->tree = $this->__parse($text);
3973 return true;
3974 }
3975
3976 return false;
3977 }
3978
3979 function GetTree()
3980 {
3981 return $this->tree;
3982 }
3983
3984 function GetArray()
3985 {
3986 return $this->tree->__toArray();
3987 }
3988
3989 function GetString()
3990 {
3991 return $this->tree->__toString();
3992 }
3993
3994 function SelectNodes($strNode)
3995 {
3996 if (!is_object($this->tree))
3997 return false;
3998
4000
4001 $tmp = explode("/", $strNode);
4002 for ($i = 1, $ni = count($tmp); $i < $ni; $i++)
4003 {
4004 if ($tmp[$i] != "")
4005 {
4006 if (!is_array($result->children))
4007 return false;
4008
4009 $bFound = false;
4010 for ($j = 0, $nj = count($result->children); $j < $nj; $j++)
4011 {
4012 if ($result->children[$j]->name==$tmp[$i])
4013 {
4014 $result = $result->children[$j];
4015 $bFound = true;
4016 break;
4017 }
4018 }
4019
4020 if (!$bFound)
4021 return false;
4022 }
4023 }
4024
4025 return $result;
4026 }
4027
4028
4029 /* Will return an DOM object tree from the well-formed XML. */
4030 function __parse($strXMLText)
4031 {
4032 $TagStack = array();
4033
4034 $oXMLDocument = new CUpdatesXMLDocument();
4035
4036 // stip the !doctype
4037 $strXMLText = preg_replace("%<\!DOCTYPE.*?>%is", "", $strXMLText);
4038
4039 // get document version and encoding from header
4040 preg_match_all("#<\?(.*?)\?>#i", $strXMLText, $arXMLHeader_tmp);
4041 foreach ($arXMLHeader_tmp[0] as $strXMLHeader_tmp)
4042 {
4043 preg_match_all("/([a-zA-Z:]+=\".*?\")/i", $strXMLHeader_tmp, $arXMLParam_tmp);
4044 foreach ($arXMLParam_tmp[0] as $strXMLParam_tmp)
4045 {
4046 if ($strXMLParam_tmp <> '')
4047 {
4048 $arXMLAttribute_tmp = explode("=\"", $strXMLParam_tmp);
4049 if ($arXMLAttribute_tmp[0]=="version")
4050 $oXMLDocument->version = substr($arXMLAttribute_tmp[1], 0, strlen($arXMLAttribute_tmp[1]) - 1);
4051 elseif ($arXMLAttribute_tmp[0]=="encoding")
4052 $oXMLDocument->encoding = substr($arXMLAttribute_tmp[1], 0, strlen($arXMLAttribute_tmp[1]) - 1);
4053 }
4054 }
4055 }
4056
4057 // strip header
4058 $strXMLText = preg_replace("#<\?.*?\?>#", "", $strXMLText);
4059
4060 // strip comments
4061 $strXMLText = CUpdatesXML::__stripComments($strXMLText);
4062
4063 $oXMLDocument->root = $oXMLDocument->children;
4064 $currentNode = $oXMLDocument;
4065
4066 $pos = 0;
4067 $endTagPos = 0;
4068 while ($pos < strlen($strXMLText))
4069 {
4070 $char = substr($strXMLText, $pos, 1);
4071 if ($char == "<")
4072 {
4073 // find tag name
4074 $endTagPos = strpos($strXMLText, ">", $pos);
4075
4076 // tag name with attributes
4077 $tagName = substr($strXMLText, $pos + 1, $endTagPos - ($pos + 1));
4078
4079 // check if it's an endtag </tagname>
4080 if (substr($tagName, 0, 1) == "/")
4081 {
4082 $lastNodeArray = array_pop($TagStack);
4083 $lastTag = $lastNodeArray["TagName"];
4084
4085 $lastNode = &$lastNodeArray["ParentNodeObject"];
4086
4087 unset($currentNode);
4088 $currentNode = &$lastNode;
4089
4090 $tagName = substr($tagName, 1, strlen($tagName));
4091
4092 // strip out namespace; nameSpace:Name
4093 $colonPos = strpos($tagName, ":");
4094
4095 if ($colonPos > 0)
4096 $tagName = substr($tagName, $colonPos + 1, strlen($tagName));
4097
4098 if ($lastTag != $tagName)
4099 {
4100 print("Error parsing XML, unmatched tags $tagName");
4101 return false;
4102 }
4103 }
4104 else
4105 {
4106 $firstSpaceEnd = strpos($tagName, " ");
4107 $firstNewlineEnd = strpos($tagName, "\n");
4108
4109 if ($firstNewlineEnd != false)
4110 {
4111 if ($firstSpaceEnd != false)
4112 {
4113 $tagNameEnd = min($firstSpaceEnd, $firstNewlineEnd);
4114 }
4115 else
4116 {
4117 $tagNameEnd = $firstNewlineEnd;
4118 }
4119 }
4120 else
4121 {
4122 if ($firstSpaceEnd != false)
4123 {
4124 $tagNameEnd = $firstSpaceEnd;
4125 }
4126 else
4127 {
4128 $tagNameEnd = 0;
4129 }
4130 }
4131
4132 $justName = $tagNameEnd > 0 ? substr($tagName, 0, $tagNameEnd) : $tagName;
4133
4134 // strip out namespace; nameSpace:Name
4135 $colonPos = strpos($justName, ":");
4136
4137 if ($colonPos > 0)
4138 {
4139 $justName = substr($justName, $colonPos + 1, strlen($justName));
4140 }
4141
4142 // remove trailing / from the name if exists
4143 if (substr($justName, strlen($justName) - 1, 1) == "/")
4144 {
4145 $justName = substr($justName, 0, strlen($justName) - 1);
4146 }
4147
4148 // check for CDATA
4149 $cdataSection = "";
4150 $isCDATASection = false;
4151 $cdataPos = strpos($strXMLText, "<![CDATA[", $pos);
4152 if ($cdataPos == $pos && $pos > 0)
4153 {
4154 $isCDATASection = true;
4155 $endTagPos = strpos($strXMLText, "]]>", $cdataPos);
4156 $cdataSection = substr($strXMLText, $cdataPos + 9, $endTagPos - ( $cdataPos + 9));
4157
4158 // new CDATA node
4159 unset($subNode);
4160 $subNode = new CUpdatesXMLNode();
4161 $subNode->name = "cdata-section";
4162 $subNode->content = $cdataSection;
4163
4164 $currentNode->children[] = &$subNode;
4165
4166 $pos = $endTagPos;
4167 $endTagPos += 2;
4168 }
4169 else
4170 {
4171 // normal start tag
4172 unset($subNode);
4173 $subNode = new CUpdatesXMLNode();
4174 $subNode->name = $justName;
4175
4176 $currentNode->children[] = &$subNode;
4177 }
4178
4179 // find attributes
4180 if ($tagNameEnd > 0)
4181 {
4182 $attributePart = substr($tagName, $tagNameEnd, strlen($tagName));
4183
4184 // attributes
4185 unset($attr);
4186 $attr = CUpdatesXML::__parseAttributes($attributePart);
4187
4188 if ($attr != false)
4189 $subNode->attributes = &$attr;
4190 }
4191
4192 // check it it's a oneliner: <tagname /> or a cdata section
4193 if ($isCDATASection == false)
4194 {
4195 if (substr($tagName, strlen($tagName) - 1, 1) != "/")
4196 {
4197 array_push($TagStack, array("TagName" => $justName, "ParentNodeObject" => &$currentNode));
4198
4199 unset($currentNode);
4200 $currentNode = &$subNode;
4201 }
4202 }
4203 }
4204 }
4205
4206 $pos = strpos($strXMLText, "<", $pos + 1);
4207
4208 if ($pos === false)
4209 {
4210 // end of document
4211 $pos = strlen($strXMLText);
4212 }
4213 else
4214 {
4215 // content tag
4216 $tagContent = substr($strXMLText, $endTagPos + 1, $pos - ($endTagPos + 1));
4217
4218 if (($this->TrimWhiteSpace && (trim($tagContent)!="")) || !$this->TrimWhiteSpace)
4219 {
4220 unset($subNode);
4221
4222 // convert special chars
4223 $currentNode->content = static::replaceSpecialChars($tagContent);
4224 }
4225 }
4226 }
4227
4228 return $oXMLDocument;
4229 }
4230
4231 protected function replaceSpecialChars($content)
4232 {
4233 return str_replace(
4234 array("&gt;", "&lt;", "&apos;", "&quot;", "&amp;"),
4235 array(">", "<", "'", '"', "&"),
4236 $content
4237 );
4238 }
4239
4241 {
4242 $str = preg_replace("#<\!--.*?-->#s", "", $str);
4243 return $str;
4244 }
4245
4246 /* Parses the attributes. Returns false if no attributes in the supplied string is found */
4247 function __parseAttributes($attributeString)
4248 {
4249 $ret = false;
4250
4251 preg_match_all("/(\\S+?)\\s*=\\s*[\"](.*?)[\"]/s", $attributeString, $attributeArray);
4252
4253 foreach ($attributeArray[0] as $i => $attributePart)
4254 {
4255 if (trim($attributePart) != "" && trim($attributePart) != "/")
4256 {
4257 $attributeName = $attributeArray[1][$i];
4258
4259 // strip out namespace; nameSpace:Name
4260 $colonPos = strpos($attributeName, ":");
4261
4262 if ($colonPos > 0)
4263 {
4264 $attributeName = substr($attributeName, $colonPos + 1, strlen($attributeName));
4265 }
4266
4267 $attributeValue = $attributeArray[2][$i];
4268
4269 unset($attrNode);
4270 $attrNode = new CUpdatesXMLNode();
4271 $attrNode->name = $attributeName;
4272
4273 // convert special chars
4274 $attrNode->content = static::replaceSpecialChars($attributeValue);
4275
4276 $ret[] = &$attrNode;
4277 }
4278 }
4279 return $ret;
4280 }
4281}
4282
4283/************************************************************************/
4284/********************* Класс для UPDATER'А ******************************/
4285/************************************************************************/
4286
4288{
4290 var $curPath; // Путь к скрипту updater (без имени скрипта) относительно корня сайта
4291 var $curModulePath; // Путь к папке с обновлениями модуля
4292 var $dbType; // Тип базы данных
4293 var $updater; // Путь к скрипту updater (c именем скрипта) относительно корня сайта
4294 var $moduleID; // Модуль
4295 var $callType; // Прямой вызов (ALL - все, KERNEL - ядро, PERSONAL - персональные файлы, DATABASE - база данных // DB=PERSONAL+DATABASE)
4296 var $kernelPath; // Путь к ядру
4297
4298 function Init($curPath, $dbType, $updater, $curDir, $moduleID, $callType = "ALL")
4299 {
4300 $this->errorMessage = array();
4301 $this->curPath = $curPath;
4302 $this->dbType = strtoupper($dbType);
4303 $this->updater = $updater;
4304 $this->curModulePath = $curDir;
4305 $this->moduleID = $moduleID;
4306
4307 $this->callType = array();
4308 if (!is_array($callType))
4310
4311 foreach ($callType as $val)
4312 {
4313 $val = strtoupper($val);
4314 switch ($val)
4315 {
4316 case "ALL":
4317 $this->callType = array("KERNEL", "PERSONAL", "DATABASE");
4318 break;
4319 case "KERNEL":
4320 if (!in_array("KERNEL", $this->callType))
4321 $this->callType[] = "KERNEL";
4322 break;
4323 case "PERSONAL":
4324 if (!in_array("PERSONAL", $this->callType))
4325 $this->callType[] = "PERSONAL";
4326 break;
4327 case "DATABASE":
4328 if (!in_array("DATABASE", $this->callType))
4329 $this->callType[] = "DATABASE";
4330 break;
4331 case "DB":
4332 if (!in_array("PERSONAL", $this->callType))
4333 $this->callType[] = "PERSONAL";
4334 if (!in_array("DATABASE", $this->callType))
4335 $this->callType[] = "DATABASE";
4336 break;
4337 }
4338 }
4339
4340 $this->kernelPath = US_SHARED_KERNEL_PATH;
4341 }
4342
4343 // Устанавливает все компоненты
4344 // $arDeleteFiles = array("component.name" => array("/images/1.gif", "/templates/.default/style.css"), "component.name1" => array("/style.css"));
4345 function InstallComponents($arDeleteFiles = array())
4346 {
4347 if (!in_array("KERNEL", $this->callType))
4348 return true;
4349
4350 CUpdateSystem::AddMessage2Log("Run updater '".$this->updater."': InstallComponents()", "CRUPDICS1");
4351 $errorMessage = "";
4352
4353 $bFlag = true;
4354
4355 $componentsPath = $_SERVER["DOCUMENT_ROOT"].$this->curModulePath."/install/components";
4356 if ($handle = @opendir($componentsPath))
4357 {
4358 while (($dir = readdir($handle)) !== false)
4359 {
4360 if ($dir == "." || $dir == ".." || !is_dir($componentsPath."/".$dir))
4361 continue;
4362
4363 if (file_exists($componentsPath."/".$dir."/component.php") || file_exists($componentsPath."/".$dir."/class.php"))
4364 {
4365 $bFlag = $bFlag && $this->InstallComponent($dir, (array_key_exists($dir, $arDeleteFiles) ? $arDeleteFiles[$dir] : array()));
4366 }
4367 else
4368 {
4369 if ($handle1 = @opendir($componentsPath."/".$dir))
4370 {
4371 while (($dir1 = readdir($handle1)) !== false)
4372 {
4373 if ($dir1 == "." || $dir1 == ".." || !is_dir($componentsPath."/".$dir."/".$dir1))
4374 continue;
4375
4376 if (file_exists($componentsPath."/".$dir."/".$dir1."/component.php") || file_exists($componentsPath."/".$dir."/".$dir1."/class.php"))
4377 {
4378 $bFlag = $bFlag && $this->InstallComponent($dir.":".$dir1, (array_key_exists($dir.":".$dir1, $arDeleteFiles) ? $arDeleteFiles[$dir.":".$dir1] : array()));
4379 }
4380 }
4381 @closedir($handle1);
4382 }
4383 }
4384 }
4385 @closedir($handle);
4386 }
4387
4388 return $bFlag;
4389 }
4390
4392 {
4393 if ($componentName == '' || !preg_match("#^([A-Za-z0-9_.-]+:)?([A-Za-z0-9_-]+\\.)*([A-Za-z0-9_-]+)$#i", $componentName))
4394 return "";
4395
4396 return "/".str_replace(":", "/", $componentName);
4397 }
4398
4399 // Устанавливает компонент по его имени
4400 // $arDeleteFiles - удаляет файлы из массива ( Array("/images/1.gif", "/templates/.default/style.css") )
4401 function InstallComponent($componentName, $arDeleteFiles = array())
4402 {
4403 if (!in_array("KERNEL", $this->callType))
4404 return true;
4405
4406 CUpdateSystem::AddMessage2Log("Run updater '".$this->updater."': InstallComponent(".$componentName.")", "CRUPDIC1");
4407 $errorMessage = "";
4408
4410 if ($componentPath == '')
4411 {
4412 CUpdateSystem::AddMessage2Log("Wrong component name", "CRUPDIC2");
4413 return false;
4414 }
4415
4416 if (!file_exists($_SERVER["DOCUMENT_ROOT"].$this->curModulePath."/install/components".$componentPath))
4417 {
4418 CUpdateSystem::AddMessage2Log("Component is not found", "CRUPDIC3");
4419 return false;
4420 }
4421
4422 if (!empty($arDeleteFiles))
4423 {
4424 for ($i = 0, $cnt = count($arDeleteFiles); $i < $cnt; $i++)
4425 {
4426 $path2Modules = $_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/modules/".$this->moduleID."/install/components".$componentPath;
4427 $path2Components = $_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/components/".$componentPath;
4428
4429 if (file_exists($path2Modules.$arDeleteFiles[$i]))
4430 @unlink($path2Modules.$arDeleteFiles[$i]);
4431 if (file_exists($path2Components.$arDeleteFiles[$i]))
4432 @unlink($path2Components.$arDeleteFiles[$i]);
4433 }
4434 }
4435
4436 return $this->CopyDirFiles($this->curModulePath."/install/components".$componentPath, US_SHARED_KERNEL_PATH."/components".$componentPath);
4437 }
4438
4439
4440 // Устанавливает все мастера
4441 // $arDeleteFiles = array("component.name" => array("/images/1.gif", "/templates/.default/style.css"), "component.name1" => array("/style.css"));
4442 function InstallWizards($arDeleteFiles = array())
4443 {
4444 if (!in_array("KERNEL", $this->callType))
4445 return true;
4446
4447 CUpdateSystem::AddMessage2Log("Run updater '".$this->updater."': InstallWizards()", "CRUPDICS1");
4448 $errorMessage = "";
4449
4450 $bFlag = true;
4451
4452 $wizardsPath = $_SERVER["DOCUMENT_ROOT"].$this->curModulePath."/install/wizards";
4453 if ($handle = @opendir($wizardsPath))
4454 {
4455 while (($dir = readdir($handle)) !== false)
4456 {
4457 if ($dir == "." || $dir == ".." || !is_dir($wizardsPath."/".$dir))
4458 continue;
4459
4460 if (file_exists($wizardsPath."/".$dir."/wizard.php"))
4461 {
4462 $bFlag = $bFlag && $this->InstallWizard($dir, (array_key_exists($dir, $arDeleteFiles) ? $arDeleteFiles[$dir] : array()));
4463 }
4464 else
4465 {
4466 if ($handle1 = @opendir($wizardsPath."/".$dir))
4467 {
4468 while (($dir1 = readdir($handle1)) !== false)
4469 {
4470 if ($dir1 == "." || $dir1 == ".." || !is_dir($wizardsPath."/".$dir."/".$dir1))
4471 continue;
4472
4473 if (file_exists($wizardsPath."/".$dir."/".$dir1."/wizard.php"))
4474 {
4475 $bFlag = $bFlag && $this->InstallWizard($dir.":".$dir1, (array_key_exists($dir.":".$dir1, $arDeleteFiles) ? $arDeleteFiles[$dir.":".$dir1] : array()));
4476 }
4477 }
4478 @closedir($handle1);
4479 }
4480 }
4481 }
4482 @closedir($handle);
4483 }
4484
4485 return $bFlag;
4486 }
4487
4488 // Устанавливает мастер по его имени
4489 // $arDeleteFiles - удаляет файлы из массива ( Array("/images/1.gif", "/templates/.default/style.css") )
4490 function InstallWizard($wizardName, $arDeleteFiles = array())
4491 {
4492 if (!in_array("KERNEL", $this->callType))
4493 return true;
4494
4495 CUpdateSystem::AddMessage2Log("Run updater '".$this->updater."': InstallWizard(".$wizardName.")", "CRUPDIC1");
4496 $errorMessage = "";
4497
4498 $wizardPath = $this->__MakeComponentPath($wizardName);
4499 if ($wizardPath == '')
4500 {
4501 CUpdateSystem::AddMessage2Log("Wrong wizard name", "CRUPDIC2");
4502 return false;
4503 }
4504
4505 if (!file_exists($_SERVER["DOCUMENT_ROOT"].$this->curModulePath."/install/wizards".$wizardPath))
4506 {
4507 CUpdateSystem::AddMessage2Log("Wizard is not found", "CRUPDIC3");
4508 return false;
4509 }
4510
4511 if (!empty($arDeleteFiles))
4512 {
4513 for ($i = 0, $cnt = count($arDeleteFiles); $i < $cnt; $i++)
4514 {
4515 $path2Modules = $_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/modules/".$this->moduleID."/install/wizards".$wizardPath;
4516 $path2Wizards = $_SERVER["DOCUMENT_ROOT"].US_SHARED_KERNEL_PATH."/wizards/".$wizardPath;
4517
4518 if (file_exists($path2Modules.$arDeleteFiles[$i]))
4519 @unlink($path2Modules.$arDeleteFiles[$i]);
4520 if (file_exists($path2Wizards.$arDeleteFiles[$i]))
4521 @unlink($path2Wizards.$arDeleteFiles[$i]);
4522 }
4523 }
4524
4525 return $this->CopyDirFiles($this->curModulePath."/install/wizards".$wizardPath, US_SHARED_KERNEL_PATH."/wizards".$wizardPath);
4526 }
4527
4528 function CopyFiles($fromDir, $toDir)
4529 {
4530 if (!in_array("KERNEL", $this->callType))
4531 return true;
4532
4533 CUpdateSystem::AddMessage2Log("Run updater '".$this->updater."': CopyFiles(".$fromDir.", ".$toDir.")", "CRUPDCF1");
4534
4535 $errorMessage = "";
4536
4537 if (substr($fromDir, 0, 1) != "/")
4538 $fromDir = $this->curModulePath."/".$fromDir;
4539 if (substr($toDir, 0, 1) != "/")
4540 $toDir = $this->kernelPath."/".$toDir;
4541
4542 $fromDirFull = $_SERVER["DOCUMENT_ROOT"].$fromDir;
4543 $toDirFull = $_SERVER["DOCUMENT_ROOT"].$toDir;
4544
4545 if (!file_exists($fromDirFull))
4546 return true;
4547
4548 $result = CUpdateSystem::CopyDirFiles($fromDirFull, $toDirFull, $errorMessage);
4549
4550 if (!$result)
4551 $this->errorMessage[] = $errorMessage;
4552
4553 return $result;
4554 }
4555
4556 function CopyDirFiles($fromDir, $toDir)
4557 {
4558 if (!in_array("KERNEL", $this->callType))
4559 return true;
4560
4561 CUpdateSystem::AddMessage2Log("Run updater '".$this->updater."': CopyDirFiles(".$fromDir.", ".$toDir.")", "CRUPDCDF1");
4562 $errorMessage = "";
4563
4564 if (substr($fromDir, 0, 1) != "/")
4565 $fromDir = $this->curPath."/".$fromDir;
4566
4567 $fromDirFull = $_SERVER["DOCUMENT_ROOT"].$fromDir;
4568 $toDirFull = $_SERVER["DOCUMENT_ROOT"].$toDir;
4569
4570 if (!file_exists($fromDirFull))
4571 return true;
4572
4573 $result = CUpdateSystem::CopyDirFiles($fromDirFull, $toDirFull, $errorMessage);
4574
4575 if (!$result)
4576 $this->errorMessage[] = $errorMessage;
4577
4578 return $result;
4579 }
4580
4581 function Query($query, $tableName = "")
4582 {
4583 if (!in_array("DATABASE", $this->callType))
4584 return false;
4585
4586 $bCanUpdate = true;
4587 if ($tableName <> '')
4588 if (!$this->TableExists($tableName))
4589 $bCanUpdate = false;
4590
4591 $result = false;
4592
4593 $strQuery = '';
4594 if ($bCanUpdate)
4595 {
4596 $strQuery = "";
4597
4598 if (is_array($query))
4599 {
4600 foreach ($query as $key => $value)
4601 {
4602 if ($this->dbType == strtoupper($key))
4603 {
4604 $strQuery = $value;
4605 break;
4606 }
4607 }
4608 }
4609 else
4610 {
4611 $strQuery = $query;
4612 }
4613
4614 if ($strQuery == '')
4615 $bCanUpdate = false;
4616 }
4617
4618 CUpdateSystem::AddMessage2Log("Run updater '".$this->updater."': Query(".$strQuery.", ".$tableName.")", "CRUPDCDF2");
4619
4620 if ($bCanUpdate)
4621 {
4622 $result = $GLOBALS["DB"]->Query($strQuery, true);
4623
4624 if (!$result)
4625 $this->errorMessage[] = $GLOBALS["DB"]->db_Error;
4626 }
4627
4628 return $result;
4629 }
4630
4631 function QueryBatch($queryPath, $tableName = "")
4632 {
4633 if (!in_array("DATABASE", $this->callType))
4634 return false;
4635
4636 CUpdateSystem::AddMessage2Log("Run updater '".$this->updater."': QueryBatch(".$queryPath.", ".$tableName.")", "CRUPDCDF3");
4637
4638 $bCanUpdate = true;
4639 if ($tableName <> '')
4640 if (!$this->TableExists($tableName))
4641 $bCanUpdate = false;
4642
4643 $result = false;
4644
4645 if ($bCanUpdate)
4646 {
4647 $strQueryPath = "";
4648
4649 if (is_array($queryPath))
4650 {
4651 foreach ($queryPath as $key => $value)
4652 {
4653 if ($this->dbType == strtoupper($key))
4654 {
4655 $strQueryPath = $value;
4656 break;
4657 }
4658 }
4659 }
4660 else
4661 {
4662 $strQueryPath = $queryPath;
4663 }
4664
4665 if ($strQueryPath == '')
4666 $bCanUpdate = false;
4667 }
4668
4669 if ($bCanUpdate)
4670 {
4671 if (substr($strQueryPath, 0, 1) != "/")
4672 $strQueryPath = $this->curPath."/".$strQueryPath;
4673
4674 $queryPathFull = $_SERVER["DOCUMENT_ROOT"].$strQueryPath;
4675
4676 $arError = false;
4677 if (file_exists($queryPathFull))
4678 $arError = $GLOBALS["DB"]->RunSQLBatch($queryPathFull);
4679
4680 if ($arError)
4681 {
4682 foreach ($arError as $key => $value)
4683 $this->errorMessage[] = $value;
4684 }
4685 }
4686
4687 return ($arError ? false : true);
4688 }
4689
4690 function TableExists($tableName)
4691 {
4692 global $DB;
4693
4694 if (!in_array("DATABASE", $this->callType))
4695 return false;
4696
4697 $tableName = preg_replace("/[^A-Za-z0-9%_]+/", "", $tableName);
4698 if ($tableName == '')
4699 return false;
4700
4701 if ($this->dbType == "MYSQL")
4702 $strSql = "SHOW TABLES LIKE '".strtolower($DB->ForSql($tableName))."'";
4703 elseif ($this->dbType == "ORACLE")
4704 $strSql = "SELECT TABLE_NAME FROM USER_TABLES WHERE TABLE_NAME LIKE UPPER('".strtoupper($DB->ForSql($tableName))."')";
4705 elseif ($this->dbType == "MSSQL")
4706 $strSql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE '".strtoupper($DB->ForSql($tableName))."'";
4707 elseif ($this->dbType == "PGSQL")
4708 $strSql = "SELECT tablename FROM pg_tables WHERE schemaname = 'public' AND tablename LIKE '".strtolower($DB->ForSql($tableName))."'";
4709 else
4710 $strSql = "";
4711
4712 $dbResult = $DB->Query($strSql);
4713 if ($dbResult->Fetch())
4714 return true;
4715 else
4716 return false;
4717 }
4718
4719 function ColumnExists($tableName, $columnName)
4720 {
4721 global $DB;
4722
4726
4727 if (!$this->CanUpdateDatabase() || !$this->TableExists($tableName))
4728 {
4729 return false;
4730 }
4731
4732 $re = '/[^A-Za-z0-9\_]+/';
4733 $columnName = preg_replace($re, '', $columnName);
4734 $tableName = preg_replace($re, '', $tableName);
4735 if (empty($tableName) || empty($columnName))
4736 {
4737 return false;
4738 }
4739
4740 return $DB->Query("SELECT {$columnName} FROM {$tableName} WHERE 1 = 0", true) !== false;
4741 }
4742
4744 {
4745 return (in_array("DATABASE", $this->callType));
4746 }
4747
4749 {
4750 return (in_array("KERNEL", $this->callType));
4751 }
4752
4754 {
4755 return (in_array("PERSONAL", $this->callType));
4756 }
4757}
$path
Определения access_edit.php:21
$db_res
Определения options_user_settings.php:8
$ar_res
Определения options_user_settings_set.php:16
global $APPLICATION
Определения include.php:80
xml version
Определения yandex.php:67
$module_id
Определения options.php:6
$arResult
Определения generate_coupon.php:16
static GetList($by="sort", $order="asc", $arFilter=[])
Определения language.php:12
Определения update_class.php:14
static CheckVersions(&$arRes, &$strError, $arSelectedModules=false)
Определения update_class.php:1524
static GetAvailableUpdateTypes(&$strError, $lang=false, $stableVersionsOnly="Y")
Определения update_class.php:615
static GetServerHelpUpdates(&$strError, $lang=false, $stableVersionsOnly="Y")
Определения update_class.php:951
static getmicrotime()
Определения update_class.php:3674
static Report2Server($arServerReport)
Определения update_class.php:2724
static GetLicenseKey()
Определения update_class.php:3657
static GetFooPath($path)
Определения update_class.php:3134
static ModulesArray2Query($arClientModules, $pref="bitm_")
Определения update_class.php:2921
static ParseServerData(&$strServerOutput, &$arRes, &$strError)
Определения update_class.php:2769
static FooMakePath()
Определения update_class.php:3752
static UpdateKernel($updates_dir, $arModules, &$strError, &$arErrorModules, &$arSuccessModules)
Определения update_class.php:2123
static GetLoadedLangsUpdates($updates_dir, &$strError)
Определения update_class.php:1932
static AddSites($strCheck, &$strError, $lang=false, $stableVersionsOnly="Y")
Определения update_class.php:52
static InsertSpaces($sText, $iMaxChar=80)
Определения update_class.php:3679
static UpdateHelp($updates_dir, $arHelp, &$strError, &$arErrorHelp, &$arSuccessHelp)
Определения update_class.php:2583
static LoadHelpUpdates($arHelp, &$strError, $lang=false, $stableVersionsOnly="Y")
Определения update_class.php:1239
static EraseOldFolders($iCnt=1)
Определения update_class.php:3571
static UnGzipArchive(&$updates_dir, &$strError, $DelArch="Y")
Определения update_class.php:1328
static UpdateUpdate(&$strError, $lang=false, $stableVersionsOnly="Y")
Определения update_class.php:296
static SubscribeUpdates($strEmails, &$strError, $lang=false)
Определения update_class.php:21
static CheckDirPath($path, $bPermission=true)
Определения update_class.php:3376
static NumberEndings($num, $lang=false, $arEnds=false)
Определения update_class.php:3713
static CheckUpdatability($updates_dir, &$strError)
Определения update_class.php:1644
static UpdateLangs($updates_dir, $arLangs, &$strError, &$arErrorLangs, &$arSuccessLangs)
Определения update_class.php:2328
static CompareVersions($strVers1, $strVers2)
Определения update_class.php:2826
static LoadModuleUpdates($arModules, &$strError, $lang=false, $stableVersionsOnly="Y")
Определения update_class.php:1056
static GetModuleVersion($module)
Определения update_class.php:3145
static GetModules(&$strError, $arSelected=false)
Определения update_class.php:2939
static GetServerLangsUpdates(&$strError, $lang=false, $stableVersionsOnly="Y")
Определения update_class.php:846
static AddMessage2Log($sText, $sErrorCode="")
Определения update_class.php:2853
static LoadLangsUpdates($arLangs, &$strError, $lang=false, $stableVersionsOnly="Y")
Определения update_class.php:1148
static CopyDirFiles($path_from, $path_to, &$strError)
Определения update_class.php:3417
static GetLoadedHelpUpdates($updates_dir, &$strError)
Определения update_class.php:2027
static RegisterVersion(&$strError, $lang=false, $stableVersionsOnly="Y")
Определения update_class.php:134
static GetServerModuleUpdates(&$strError, $lang=false, $stableVersionsOnly="Y")
Определения update_class.php:740
static GetLanguages(&$strError, $arSelected=false)
Определения update_class.php:3001
static GetHelps(&$strError, $arSelected=false)
Определения update_class.php:3059
static IsInCommonKernel()
Определения update_class.php:15
static GetDateFormat($strDBFormat=false)
Определения update_class.php:3699
static getHTTPPage($page, $strVars, &$strError)
Определения update_class.php:3211
static bxstrrpos($haystack, $needle)
Определения update_class.php:3759
static CheckFolderUpdatability($destFolder, $srcFolder, &$strError)
Определения update_class.php:1719
static IsGzipInstalled()
Определения update_class.php:3369
static CheckEMail($email)
Определения update_class.php:3687
static GetLoadedModuleUpdates($updates_dir, &$strError)
Определения update_class.php:1836
static GetModuleInfo($path)
Определения update_class.php:3177
static DeleteDirFilesEx($path)
Определения update_class.php:3537
static LoadSources(&$strError, $lang=false, $stableVersionsOnly="Y")
Определения update_class.php:446
static RunUpdaterScript($path, &$strError, $from_dir, $moduleID)
Определения update_class.php:3615
Определения update_class.php:4288
InstallComponent($componentName, $arDeleteFiles=array())
Определения update_class.php:4401
$updater
Определения update_class.php:4293
QueryBatch($queryPath, $tableName="")
Определения update_class.php:4631
$curModulePath
Определения update_class.php:4291
$errorMessage
Определения update_class.php:4289
InstallWizard($wizardName, $arDeleteFiles=array())
Определения update_class.php:4490
TableExists($tableName)
Определения update_class.php:4690
$dbType
Определения update_class.php:4292
CopyFiles($fromDir, $toDir)
Определения update_class.php:4528
$kernelPath
Определения update_class.php:4296
CopyDirFiles($fromDir, $toDir)
Определения update_class.php:4556
CanUpdateDatabase()
Определения update_class.php:4743
Query($query, $tableName="")
Определения update_class.php:4581
$callType
Определения update_class.php:4295
InstallWizards($arDeleteFiles=array())
Определения update_class.php:4442
$curPath
Определения update_class.php:4290
$moduleID
Определения update_class.php:4294
__MakeComponentPath($componentName)
Определения update_class.php:4391
CanUpdateKernel()
Определения update_class.php:4748
InstallComponents($arDeleteFiles=array())
Определения update_class.php:4345
Init($curPath, $dbType, $updater, $curDir, $moduleID, $callType="ALL")
Определения update_class.php:4298
CanUpdatePersonalFiles()
Определения update_class.php:4753
__construct()
Определения update_class.php:3896
__toString()
Определения update_class.php:3901
__toArray()
Определения update_class.php:3922
Определения update_class.php:3942
GetTree()
Определения update_class.php:3979
Load($file)
Определения update_class.php:3952
__parseAttributes($attributeString)
Определения update_class.php:4247
GetArray()
Определения update_class.php:3984
$tree
Определения update_class.php:3943
LoadString($text)
Определения update_class.php:3966
__parse($strXMLText)
Определения update_class.php:4030
__construct($TrimWhiteSpace=true)
Определения update_class.php:3946
SelectNodes($strNode)
Определения update_class.php:3994
GetString()
Определения update_class.php:3989
replaceSpecialChars($content)
Определения update_class.php:4231
__stripComments(&$str)
Определения update_class.php:4240
$TrimWhiteSpace
Определения update_class.php:3944
__construct()
Определения update_class.php:3783
$content
Определения update_class.php:3779
__toString()
Определения update_class.php:3787
__toArray()
Определения update_class.php:3844
$children
Определения update_class.php:3780
$name
Определения update_class.php:3778
$attributes
Определения update_class.php:3781
$moduleID
Определения options.php:7
$str
Определения commerceml2.php:63
$contents
Определения commerceml2.php:57
$content
Определения commerceml.php:144
if( $strWarning=="") if($strWarning=="") $componentPath
Определения component_props2.php:197
$componentName
Определения component_props2.php:49
if(!is_array($prop["VALUES"])) $tmp
Определения component_props.php:203
$data['IS_AVAILABLE']
Определения .description.php:13
$arr
Определения file_new.php:624
</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
$bFound
Определения get_search.php:40
$query
Определения get_search.php:11
$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 SM_VERSION
Определения version.php:2
if(!defined('SITE_ID')) $lang
Определения include.php:91
const FORMAT_DATE
Определения include.php:63
const LICENSE_KEY($show_sql_stat=='Y')
Определения start.php:84
global $DBType
Определения start.php:35
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$order
Определения payment.php:8
$email
Определения payment.php:49
$arLangs
Определения prolog_auth_admin.php:31
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$ar
Определения options.php:199
$dir
Определения quickway.php:303
if(empty($signedUserToken)) $key
Определения quickway.php:257
$text
Определения template_pdf.php:79
$strCheck
Определения result_rec.php:37
$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
$val
Определения options.php:1793
$arRes
Определения options.php:104
$k
Определения template_pdf.php:567
$GLOBALS['_____370096793']
Определения update_client.php:1
$n
Определения update_log.php:107
$dbResult
Определения updtr957.php:3