1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
backup.php
См. документацию.
1<?php
2/*
3 Test tar no compression no encryption
4 /var/www/html/bitrix/backup# cat `ls -1v *.tar*` | tar tvf -
5
6 Test encrypted tar with no compression
7 /var/www/html/bitrix/backup# cat `ls -1v *.enc*` | tail -c +513 | openssl aes-256-ecb -d -in - -out - -K `php -r 'echo bin2hex(md5("passwd"));'` -nosalt -nopad | tar tvf -
8
9 Test compressed tar no encryption
10 /var/www/html/bitrix/backup# cat `ls -1v *.tar.gz*` | tar tvzf -
11
12 Test compressed and encrypted tar
13 /var/www/html/bitrix/backup# cat `ls -1v *.enc.gz*` | gunzip | tail -c +513 | openssl aes-256-ecb -d -in - -out - -K `php -r 'echo bin2hex(md5("passwd"));'` -nosalt -nopad | tar tvf -
14*/
16{
19
20 protected $strLastFile;
21 protected $LastFileSize;
22
23 public static function CheckDumpClouds()
24 {
25 $arRes = array();
26 if (IntOption('dump_do_clouds') && $arAllBucket = CBackup::GetBucketList())
27 {
28 foreach($arAllBucket as $arBucket)
29 if (IntOption('dump_cloud_'.$arBucket['ID']))
30 $arRes[] = $arBucket['ID'];
31 if (!empty($arRes))
32 return $arRes;
33 }
34 return false;
35 }
36
37 public static function CheckDumpFiles()
38 {
39 return IntOption("dump_file_public") || IntOption("dump_file_kernel");
40 }
41
42 public static function GetBucketList($arFilter = array())
43 {
44 if (CModule::IncludeModule('clouds'))
45 {
46 $arBucket = array();
48 array("SORT"=>"DESC", "ID"=>"ASC"),
49 array_merge(array('ACTIVE'=>'Y','READ_ONLY'=>'N'), $arFilter)
50 );
51 while($f = $rsData->Fetch())
52 {
53 $arBucket[] = $f;
54 }
55 return count($arBucket) ? $arBucket : false;
56 }
57 return false;
58 }
59
60 public static function ignorePath($path)
61 {
62 if (!file_exists($path)) // in case of wrong symlinks
63 return true;
64
65 if (!self::$REAL_DOCUMENT_ROOT_SITE)
66 self::$REAL_DOCUMENT_ROOT_SITE = realpath(self::$DOCUMENT_ROOT_SITE);
67
68 ## Ignore paths
69 static $ignore_path;
70 if (!$ignore_path)
71 $ignore_path = array(
72 BX_PERSONAL_ROOT."/cache",
73 BX_PERSONAL_ROOT."/cache_image",
74 BX_PERSONAL_ROOT."/managed_cache",
75 BX_PERSONAL_ROOT."/managed_flags",
76 BX_PERSONAL_ROOT."/stack_cache",
77 BX_PERSONAL_ROOT."/html_pages",
78 BX_PERSONAL_ROOT."/tmp",
79 BX_ROOT."/tmp",
80 BX_ROOT."/help",
81 BX_ROOT."/updates",
82 '/'.COption::GetOptionString("main", "upload_dir", "upload")."/tmp",
83 '/'.COption::GetOptionString("main", "upload_dir", "upload")."/resize_cache",
84 );
85
86 foreach($ignore_path as $value)
87 if(self::$DOCUMENT_ROOT_SITE.$value == $path)
88 return true;
89
90 ## Clouds
91 if (IntOption('dump_do_clouds'))
92 {
93 $clouds = self::$DOCUMENT_ROOT_SITE.BX_ROOT.'/backup/clouds/';
94 if (mb_strpos($path, $clouds) === 0 || mb_strpos($clouds, $path) === 0)
95 return false;
96 }
97
98 ## Backups
99 if (mb_strpos($path, self::$DOCUMENT_ROOT_SITE.BX_ROOT.'/backup/') === 0)
100 return true;
101
102 ## Symlinks
103 if (is_dir($path))
104 {
105 if (is_link($path))
106 {
107 if (mb_strpos(realpath($path), self::$REAL_DOCUMENT_ROOT_SITE) !== false) // если симлинк ведет на папку внутри структуры сайта
108 return true;
109 }
110 } ## File size
111 elseif (($max_file_size = IntOption("dump_max_file_size")) > 0 && filesize($path) > $max_file_size * 1024)
112 return true;
113
114 ## Skip mask
116 return true;
117
118 ## Kernel vs Public
119 $dump_file_public = IntOption('dump_file_public');
120 $dump_file_kernel = IntOption('dump_file_kernel');
121
122 if ($dump_file_public == $dump_file_kernel) // если обе опции либо включены либо выключены
123 return !$dump_file_public;
124
125 if (mb_strpos(self::$DOCUMENT_ROOT_SITE.BX_ROOT, $path) !== false) // на пути к /bitrix
126 return false;
127
128 if (mb_strpos($path, self::$DOCUMENT_ROOT_SITE.BX_ROOT) === false) // за пределами /bitrix
129 return !$dump_file_public;
130
131 $path_root = mb_substr($path, mb_strlen(self::$DOCUMENT_ROOT_SITE));
132 if (preg_match('#^/bitrix/(.settings.php|php_interface|templates)/([^/]*)#',$path_root.'/',$regs))
133 return !$dump_file_public;
134
135 if (preg_match('#^/bitrix/(activities|components|gadgets|wizards)/([^/]*)#',$path_root.'/',$regs))
136 {
137 if (!$regs[2])
138 return false;
139 if ($regs[2] == 'bitrix')
140 return !$dump_file_kernel;
141 return !$dump_file_public;
142 }
143
144 // всё остальное в папке bitrix - ядро
145 return !$dump_file_kernel;
146 }
147
148 public static function GetBucketFileList($BUCKET_ID, $path)
149 {
150 static $CACHE;
151
152 if (isset($CACHE[$BUCKET_ID]))
153 $obBucket = $CACHE[$BUCKET_ID];
154 else
155 $CACHE[$BUCKET_ID] = $obBucket = new CCloudStorageBucket($BUCKET_ID);
156
157 if ($obBucket->Init())
158 return $obBucket->ListFiles($path);
159 return false;
160 }
161
162 public static function _preg_escape($str)
163 {
164 $search = array('#','[',']','.','?','(',')','^','$','|','{','}');
165 $replace = array('\#','\[','\]','\.','\?','\‍(','\‍)','\^','\$','\|','\{','\}');
166 return str_replace($search, $replace, $str);
167 }
168
169 public static function skipMask($abs_path)
170 {
171 global $skip_mask_array;
172
173 if (!IntOption('skip_mask'))
174 return false;
175
176 if (!is_array($skip_mask_array))
177 {
178 return false;
179 }
180
181 $path = mb_substr($abs_path, mb_strlen(self::$DOCUMENT_ROOT_SITE));
182 $path = str_replace('\\','/',$path);
183
184 static $preg_mask_array;
185 if (!$preg_mask_array)
186 {
187 $preg_mask_array = array();
188 foreach($skip_mask_array as $a)
189 $preg_mask_array[] = CBackup::_preg_escape($a);
190 }
191
192 foreach($skip_mask_array as $k => $mask)
193 {
194 if (str_starts_with($mask, '/')) // absolute path
195 {
196 if (!str_contains($mask, '*')) // нет звездочки
197 {
198 if (mb_strpos($path.'/', $mask.'/') === 0)
199 return true;
200 }
201 elseif (preg_match('#^'.str_replace('*','[^/]*?',$preg_mask_array[$k]).'$#i',$path))
202 return true;
203 }
204 elseif (!str_contains($mask, '/'))
205 {
206 if (!str_contains($mask, '*'))
207 {
208 if (str_ends_with($path, $mask))
209 return true;
210 }
211 elseif (preg_match('#/[^/]*'.str_replace('*','[^/]*?',$preg_mask_array[$k]).'$#i',$path))
212 return true;
213 }
214 }
215 }
216
217 public static function GetArcName($prefix = '')
218 {
219 $arc_name = DOCUMENT_ROOT.BX_ROOT."/backup/".$prefix.date("Ymd_His");
220
221 $k = IntOption('dump_file_kernel');
222 $p = IntOption('dump_file_public');
223 $b = IntOption('dump_base');
224
225 if ($k && $p && $b)
226 $arc_name .= '_full';
227 elseif (!($p xor $b))
228 $arc_name .= '_'.($k ? '' : 'no').'core';
229 elseif (!($k xor $b))
230 $arc_name .= '_'.($p ? '' : 'no').'pub';
231 elseif (!($k xor $p))
232 $arc_name .= '_'.($b ? '' : 'no').'sql';
233
234 $arc_name .= '_' . \Bitrix\Main\Security\Random::getString(16);
235 return $arc_name;
236 }
237
238 public static function MakeDump($strDumpFile, &$arState)
239 {
240 global $DB;
241
242 $B = new CBackup;
243
244 if (!$arState)
245 {
246 if(!$B->file_put_contents_ex($strDumpFile, "-- Started: ".date('Y-m-d H:i:s')."\n"))
247 return false;
248
249 $rs = $DB->Query('SHOW VARIABLES LIKE "character_set_results"');
250 if (($f = $rs->Fetch()) && array_key_exists ('Value', $f))
251 if (!$B->file_put_contents_ex($strDumpFile, "SET NAMES '".$f['Value']."';\n"))
252 return false;
253
254 $arState = array('TABLES' => array());
255 $arTables = array();
256 $rsTables = $DB->Query("SHOW FULL TABLES WHERE TABLE_TYPE NOT LIKE 'VIEW'", false, '', array("fixed_connection"=>true));
257 while($arTable = $rsTables->Fetch())
258 {
259 $table = current($arTable);
260
261 $rsIndexes = $DB->Query("SHOW INDEX FROM `".$DB->ForSql($table)."`", true, '', array("fixed_connection"=>true));
262 if($rsIndexes)
263 {
264 $arIndexes = array();
265 while($ar = $rsIndexes->Fetch())
266 if($ar["Non_unique"] == "0")
267 $arIndexes[$ar["Key_name"]][$ar["Seq_in_index"]-1] = $ar["Column_name"];
268
269 foreach($arIndexes as $IndexName => $arIndexColumns)
270 if(count($arIndexColumns) != 1)
271 unset($arIndexes[$IndexName]);
272
273 if(!empty($arIndexes))
274 {
275 foreach($arIndexes as $IndexName => $arIndexColumns)
276 {
277 foreach($arIndexColumns as $SeqInIndex => $ColumnName)
278 $key_column = $ColumnName;
279 break;
280 }
281 }
282 else
283 {
284 $key_column = false;
285 }
286 }
287 else
288 {
289 $key_column = false;
290 }
291
292 $arState['TABLES'][$table] = array(
293 "TABLE_NAME" => $table,
294 "KEY_COLUMN" => $key_column,
295 "LAST_ID" => 0
296 );
297 }
298 $rsTables = $DB->Query("SHOW FULL TABLES WHERE TABLE_TYPE LIKE 'VIEW'", false, '', array("fixed_connection"=>true));
299 while($arTable = $rsTables->Fetch())
300 {
301 $table = current($arTable);
302
303 $arState['TABLES'][$table] = array(
304 "TABLE_NAME" => $table,
305 "KEY_COLUMN" => false,
306 "LAST_ID" => 0
307 );
308 }
309 $arState['TableCount'] = count($arState['TABLES']);
310 if (!haveTime())
311 return true;
312 }
313
314 foreach($arState['TABLES'] as $table => $arTable)
315 {
316 if(!$arTable["LAST_ID"])
317 {
318 $rs = $DB->Query("SHOW CREATE TABLE `".$DB->ForSQL($table)."`", true);
319 if ($rs === false)
320 RaiseErrorAndDie(GetMessage('DUMP_TABLE_BROKEN', array('#TABLE#' => $table)));
321
322 $row = $rs->Fetch();
323 $string = $row['Create Table'];
324 if (!$string) // VIEW
325 {
326 $string = $row['Create View'];
327 if (!$B->file_put_contents_ex($strDumpFile,
328 "-- -----------------------------------\n".
329 "-- Creating view ".$DB->ForSQL($table)."\n".
330 "-- -----------------------------------\n".
331 "DROP VIEW IF EXISTS `".$DB->ForSQL($table)."`;\n".
332 $string.";\n\n"))
333 return false;
334 unset($arState['TABLES'][$table]);
335 continue;
336 }
338 {
339 $string = str_replace('CREATE TABLE', 'CREATE TABLE IF NOT EXISTS', $string);
340 if (!$B->file_put_contents_ex($strDumpFile,
341 "-- -----------------------------------\n".
342 "-- Creating empty table ".$DB->ForSQL($table)."\n".
343 "-- -----------------------------------\n".
344 $string.";\n\n"))
345 return false;
346 unset($arState['TABLES'][$table]);
347 continue;
348 }
349
350
351 if (!$B->file_put_contents_ex($strDumpFile,
352 "-- -----------------------------------\n".
353 "-- Dumping table ".$DB->ForSQL($table)."\n".
354 "-- -----------------------------------\n".
355 "DROP TABLE IF EXISTS `".$DB->ForSQL($table)."`;\n".
356 $string.";\n\n"))
357 return false;
358
359 $arState['TABLES'][$table]['COLUMNS'] = $arTable["COLUMNS"] = CBackup::GetTableColumns($table);
360 if (($k = $arTable['KEY_COLUMN']) && $arTable['COLUMNS'][$k] > 0) // check if promary key is not numeric
361 {
362 unset($arTable['KEY_COLUMN']);
363 unset($arState['TABLES'][$table]['KEY_COLUMN']);
364 }
365 }
366
367 $strInsert = "";
368 $cnt = $LIMIT = 10000;
369 while($cnt == $LIMIT)
370 {
371 $i = $arTable['LAST_ID'];
372 if(!empty($arTable["KEY_COLUMN"]))
373 {
374 $strSelect = "
375 SELECT *
376 FROM `".$arTable["TABLE_NAME"]."`
377 ".($arTable["LAST_ID"] ? "WHERE `".$arTable["KEY_COLUMN"]."` > '".$arTable["LAST_ID"]."'": "")."
378 ORDER BY `".$arTable["KEY_COLUMN"]."`
379 LIMIT ".$LIMIT;
380 }
381 else
382 {
383 $strSelect = "
384 SELECT *
385 FROM `".$arTable["TABLE_NAME"]."`
386 LIMIT ".($arTable["LAST_ID"] ? $arTable["LAST_ID"].", ": "").$LIMIT;
387 }
388
389 if (!$rsSource = self::QueryUnbuffered($strSelect))
390 RaiseErrorAndDie('SQL Query Error');
391 while($arSource = $rsSource->Fetch())
392 {
393 if(!$strInsert)
394 $strInsert = "INSERT INTO `".$arTable["TABLE_NAME"]."` VALUES";
395 else
396 $strInsert .= ",";
397
398 foreach($arSource as $key => $value)
399 {
400 if(!isset($value) || is_null($value))
401 $arSource[$key] = 'NULL';
402 elseif($arTable["COLUMNS"][$key] == 0)
403 $arSource[$key] = $value;
404 elseif($arTable["COLUMNS"][$key] == 1)
405 {
406 if(empty($value) && $value != '0')
407 $arSource[$key] = '\'\'';
408 else
409 $arSource[$key] = '0x' . bin2hex($value);
410 }
411 elseif($arTable["COLUMNS"][$key] == 2)
412 {
413 $arSource[$key] = "'".$DB->ForSql($value)."'";
414 }
415 }
416
417 $strInsert .= "\n(".implode(", ", $arSource).")";
418
419 $arState['TABLES'][$table]['LAST_ID'] = $arTable['LAST_ID'] = !empty($arTable["KEY_COLUMN"]) ? $arSource[$arTable["KEY_COLUMN"]] : ++$i;
420
421 if (strlen($strInsert) > 1000000)
422 {
423 if(!$B->file_put_contents_ex($strDumpFile, $strInsert.";\n"))
424 return false;
425 $strInsert = "";
426 }
427
428 if (!haveTime())
429 {
431 return $strInsert ? $B->file_put_contents_ex($strDumpFile, $strInsert.";\n") : true;
432 }
433 }
434 $cnt = $rsSource->SelectedRowsCount();
436 }
437
438 if($strInsert && !$B->file_put_contents_ex($strDumpFile, $strInsert.";\n"))
439 return false;
440
441 if ($cnt < $LIMIT)
442 unset($arState['TABLES'][$table]);
443 }
444
445 if(!$B->file_put_contents_ex($strDumpFile, "-- Finished: ".date('Y-m-d H:i:s')))
446 return false;
447
448 $arState['end'] = true;
449 return true;
450 }
451
452 public static function QueryUnbuffered($q)
453 {
454 global $DB;
455
456 $DB->result = mysqli_query($DB->db_Conn, $q, MYSQLI_USE_RESULT);
457
458 $rsSource = new CDBResult($DB->result);
459 $rsSource->DB = $DB;
460 return $rsSource;
461 }
462
463 public static function FreeResult()
464 {
465 global $DB;
466
467 mysqli_free_result($DB->result);
468 }
469
470 public function file_put_contents_ex($strDumpFile, $str)
471 {
472 $LIMIT = 2000000000;
473 if (!$this->strLastFile)
474 {
475 $this->strLastFile = $strNextFile = $strDumpFile;
476 $this->LastFileSize = 0;
477 while(file_exists($strNextFile))
478 {
479 $this->LastFileSize = filesize($this->strLastFile = $strNextFile);
480 $strNextFile = self::getNextName($strNextFile);
481 }
482 }
483
484 $c = strlen($str);
485 if ($this->LastFileSize + $c >= $LIMIT)
486 {
487 $this->strLastFile = self::getNextName($this->strLastFile);
488 $this->LastFileSize = 0;
489 }
490 $this->LastFileSize += $c;
491 return file_put_contents($this->strLastFile, $str, 8);
492 }
493
494 public static function GetTableColumns($TableName)
495 {
496 global $DB;
497 $arResult = array();
498
499 $sql = "SHOW COLUMNS FROM `".$TableName."`";
500 $res = $DB->Query($sql, false, '', array("fixed_connection"=>true));
501 while($row = $res->Fetch())
502 {
503 if(preg_match("/^(\w*int|year|float|double|decimal)/", $row["Type"]))
504 $arResult[$row["Field"]] = 0;
505 elseif(preg_match("/^(\w*(binary|blob))/", $row["Type"]))
506 $arResult[$row["Field"]] = 1;
507 else
508 $arResult[$row["Field"]] = 2;
509 }
510
511 return $arResult;
512 }
513
514 public static function SkipTableData($table)
515 {
516 $table = mb_strtolower($table);
517 if (preg_match("#^b_stat#", $table) && IntOption('dump_base_skip_stat'))
518 return true;
519 elseif (preg_match("#^b_search_#", $table) && !preg_match('#^(b_search_custom_rank|b_search_phrase)$#', $table) && IntOption('dump_base_skip_search'))
520 return true;
521 elseif($table == 'b_event_log' && IntOption('dump_base_skip_log'))
522 return true;
523 return false;
524 }
525
526 public static function getNextName($file)
527 {
528 static $CACHE;
529 $c = &$CACHE[$file];
530
531 if (!$c)
532 {
533 $l = strrpos($file, '.');
534 $num = substr($file,$l+1);
535 if (is_numeric($num))
536 $file = substr($file,0,$l+1).++$num;
537 else
538 $file .= '.1';
539 $c = $file;
540 }
541 return $c;
542 }
543}
544
546{
547 var $DirCount = 0;
548 var $FileCount = 0;
549 var $err= array();
550
551 var $bFound = false;
552 var $nextPath = '';
553 var $startPath = '';
554 var $arIncludeDir = false;
555
556 function __construct()
557 {
558 }
559
561 {
562 return true;
563 }
564
566 {
567 return true;
568 }
569
570 function ProcessFile($f)
571 {
572 return true;
573 }
574
575 function Skip($f)
576 {
577 if ($this->startPath)
578 {
579 if (mb_strpos($this->startPath.'/', $f.'/') === 0)
580 {
581 if ($this->startPath == $f)
582 {
583 $this->startPath = '';
584 }
585
586 return false;
587 }
588 else
589 return true;
590 }
591 return false;
592 }
593
594 function Scan($dir)
595 {
596 $dir = str_replace('\\','/',$dir);
597
598 if ($this->Skip($dir))
599 {
600 // echo $dir."<br>\n";
601 return;
602 }
603
604 $this->nextPath = $dir;
605
606 if (is_dir($dir))
607 {
608 #############################
609 # DIR
610 #############################
611 if (!$this->startPath) // если начальный путь найден или не задан
612 {
613 $r = $this->ProcessDirBefore($dir);
614 if ($r === false)
615 return false;
616 }
617
618 if (!($handle = opendir($dir)))
619 {
620 $this->err[] = 'Error opening dir: '.$dir;
621 return false;
622 }
623
624 while (($item = readdir($handle)) !== false)
625 {
626 if ($item == '.' || $item == '..' || false !== mb_strpos($item, '\\'))
627 continue;
628
629 $f = $dir."/".$item;
630 $r = $this->Scan($f);
631 if ($r === false || $r === 'BREAK')
632 {
633 closedir($handle);
634 return $r;
635 }
636 }
637 closedir($handle);
638
639 if (!$this->startPath) // если начальный путь найден или не задан
640 {
641 if ($this->ProcessDirAfter($dir) === false)
642 return false;
643 $this->DirCount++;
644 }
645 }
646 else
647 {
648 #############################
649 # FILE
650 #############################
651 $r = $this->ProcessFile($dir);
652 if ($r === false)
653 return false;
654 elseif ($r === 'BREAK') // если файл обработан частично
655 return $r;
656 $this->FileCount++;
657 }
658 return true;
659 }
660}
661
663{
664 var $arSkip = array();
665 function ProcessFile($f)
666 {
667 global $tar;
668 while(haveTime())
669 {
670 $f = str_replace('\\', '/', $f);
671 if (preg_match('#/bitrix/(php_interface/dbconn.php|.settings.php)$#', $f, $regs))
672 {
673 if (!$arInfo = $tar->getFileInfo($f))
674 return false;
675
676 if ($regs[1] == '.settings.php')
677 {
678 if (!is_array($ar = include($f)))
679 {
680 $this->err[] = 'Can\'t parse file: '.$f;
681 return false;
682 }
683
684 if (is_array($ar['connections']['value']))
685 {
686 foreach($ar['connections']['value'] as $k => $arTmp)
687 {
688 $ar['connections']['value'][$k]['login'] = '******';
689 $ar['connections']['value'][$k]['password'] = '******';
690 $ar['connections']['value'][$k]['database'] = '******';
691 }
692 }
693
694 $strFile = "<"."?php\nreturn ".var_export($ar, true).";\n";
695 }
696 else // dbconn.php
697 {
698 if (false === $arFile = file($f))
699 {
700 $this->err[] = 'Can\'t read file: '.$f;
701 return false;
702 }
703
704 $strFile = '';
705 foreach($arFile as $line)
706 {
707 if (preg_match("#^[ \t]*".'\$'."(DB(Login|Password|Name))#",$line,$regs))
708 $strFile .= '$'.$regs[1].' = "******";'."\n";
709 else
710 $strFile .= str_replace("\r\n","\n",$line);
711 }
712 }
713
714 $arInfo['size'] = strlen($strFile);
715 if (!$tar->writeHeader($arInfo))
716 return false;
717
718 $i = 0;
719 while($i < $arInfo['size'])
720 {
721 if (!$tar->writeBlock(pack("a512", substr($strFile, $i, 512))))
722 return false;
723 $i += 512;
724 }
725
726 return true;
727 }
728
729 if ($tar->addFile($f) === false)
730 return false; // error
731 if ($tar->ReadBlockCurrent == 0)
732 return true; // finished
733 }
734 return 'BREAK';
735 }
736
738 {
739 global $tar;
740 return $tar->addFile($f);
741 }
742
743 function Skip($f)
744 {
745 static $bFoundDocumentRoot;
746 $res = false;
747 if ($this->startPath)
748 {
749 if (mb_strpos($this->startPath.'/', $f.'/') === 0)
750 {
751 if ($this->startPath == $f)
752 {
753 $this->startPath = '';
754 }
755
756 return false;
757 }
758 else
759 return true;
760 }
761 elseif (!empty($this->arSkip[$f]))
762 return true;
763 elseif ($bFoundDocumentRoot)
765
766 $bFoundDocumentRoot = true;
767 return $res;
768 }
769}
770
772{
773 const SIGN = 'CACHE_';
774
775 public static function Init()
776 {
777 return function_exists('openssl_encrypt');
778 }
779
780 public static function getEncryptKey()
781 {
782 static $key;
783
784 if ($key === null)
785 {
787 if (file_exists($file = $_SERVER['DOCUMENT_ROOT'].BX_ROOT.'/license_key.php'))
788 include($file);
789 if ($LICENSE_KEY == '')
790 $LICENSE_KEY = 'DEMO';
791
792 $key = $LICENSE_KEY;
793
794 $l = strlen($key);
795 if ($l > 56)
796 $key = substr($key, 0, 56);
797 elseif ($l < 16)
798 $key = str_repeat($key, ceil(16/$l));
799 }
800
801 return $key;
802 }
803
804 public static function Set($strName, $strVal)
805 {
806 if (!self::Init())
807 {
808 return false;
809 }
810
811 $encrypted = strlen($strVal) ? CTar::encrypt(self::SIGN . $strVal, self::getEncryptKey()) : '';
812 $encoded = base64_encode($encrypted);
813
814 return COption::SetOptionString('main', $strName, $encoded);
815 }
816
817 public static function Get($strName)
818 {
819 if (!self::Init())
820 {
821 return false;
822 }
823
824 $strVal = COption::GetOptionString('main', $strName, '');
825 $decoded = base64_decode($strVal);
826 $decrypted = '';
828 {
829 $decrypted = CTar::decrypt($decoded, self::getEncryptKey(), $method);
830 if (str_starts_with($decrypted, self::SIGN))
831 {
833 {
834 // Update with default encryption method
835 static::Set($strName, substr(rtrim($decrypted, "\x00"), strlen(self::SIGN)));
836 }
837 break;
838 }
839 }
840
841 if (str_starts_with($decrypted, self::SIGN))
842 {
843 return substr(rtrim($decrypted, "\x00"), strlen(self::SIGN));
844 }
845
846 return false;
847 }
848}
849
850class CTar
851{
852 var $gzip;
853 var $file;
854 var $err = array();
856 var $res;
857 var $Block = 0;
859 var $path;
860 var $FileCount = 0;
861 var $DirCount = 0;
862 var $ReadBlockMax = 2000;
865 var $header = null;
867 const BX_EXTRA = 'BX0000';
868 const BX_SIGNATURE = 'Bitrix Encrypted File';
874 var $prefix = '';
875
876 ##############
877 # READ
878 # {
879 function openRead($file)
880 {
881 if (!isset($this->gzip) && (substr($file,-3)=='.gz' || substr($file,-4)=='.tgz'))
882 $this->gzip = true;
883
884 $this->BufferSize = 51200;
885
886 if ($this->open($file, 'r'))
887 {
888 if ('' !== $str = $this->gzip ? gzread($this->res,512) : fread($this->res,512))
889 {
890 $data = unpack("a100empty/a90signature/a10version/a56tail/a256enc", $str);
891 if (trim($data['signature']) != self::BX_SIGNATURE)
892 {
893 if (strlen($this->EncryptKey))
894 $this->Error('Invalid encryption signature','ENC_SIGN');
895
896 // Probably archive is not encrypted
897 $this->gzip ? gzseek($this->res, 0) : fseek($this->res, 0);
898 $this->EncryptKey = null;
899
900 return $this->res;
901 }
902
903 $version = trim($data['version']);
904 if (version_compare($version, '1.2', '>'))
905 return $this->Error('Unsupported archive version: '.$version, 'ENC_VER');
906
907 $key = $this->getEncryptKey();
908 if (!$key)
909 {
910 return $this->Error('Invalid encryption key', 'ENC_KEY');
911 }
912 $this->BlockHeader = $this->Block = 1;
913
914 $this->EncryptAlgorithm = null;
915 foreach (static::getCryptoAlgorithmList() as $EncryptAlgorithm)
916 {
917 if (substr($str, 0, 256) === self::decrypt($data['enc'], $key, $EncryptAlgorithm))
918 {
919 $this->EncryptAlgorithm = $EncryptAlgorithm;
920 break;
921 }
922 }
923
924 if (!$this->EncryptAlgorithm)
925 {
926 return $this->Error('Invalid encryption key', 'ENC_KEY');
927 }
928 }
929 }
930 return $this->res;
931 }
932
933 function readBlock($bIgnoreOpenNextError = false)
934 {
935 if (!$this->Buffer)
936 {
937 $str = $this->gzip ? gzread($this->res, $this->BufferSize) : fread($this->res, $this->BufferSize);
938 if ($str === '' && $this->openNext($bIgnoreOpenNextError))
939 $str = $this->gzip ? gzread($this->res, $this->BufferSize) : fread($this->res, $this->BufferSize);
940 if ($str !== '' && $key = $this->getEncryptKey())
941 $str = self::decrypt($str, $key, $this->EncryptAlgorithm);
942 $this->Buffer = $str;
943 }
944
945 $str = '';
946 if ($this->Buffer)
947 {
948 $str = substr($this->Buffer, 0, 512);
949 $this->Buffer = substr($this->Buffer, 512);
950 $this->Block++;
951 }
952
953 return $str;
954 }
955
956 function SkipFile()
957 {
958 if ($this->Skip(ceil(intval($this->header['size'])/512)))
959 {
960 $this->header = null;
961 return true;
962 }
963 return false;
964 }
965
966 function Skip($Block)
967 {
968 if ($Block == 0)
969 return true;
970
971 $this->Block += $Block;
972 $toSkip = $Block * 512;
973
974 if (strlen($this->Buffer) > $toSkip)
975 {
976 $this->Buffer = substr($this->Buffer, $toSkip);
977 return true;
978 }
979 $this->Buffer = '';
980 $NewPos = $this->Block * 512;
981
982 if ($ArchiveSize = $this->getDataSize($file = self::getFirstName($this->file)))
983 {
984 while($NewPos > $ArchiveSize)
985 {
986 $file = $this->getNextName($file);
987 $NewPos -= $ArchiveSize;
988 }
989 }
990
991 if ($file != $this->file)
992 {
993 $this->close();
994 if (!$this->open($file, $this->mode))
995 return false;
996 }
997
998 if (0 === ($this->gzip ? gzseek($this->res, $NewPos) : fseek($this->res, $NewPos)))
999 return true;
1000 return $this->Error('File seek error (file: '.$this->file.', position: '.$NewPos.')');
1001 }
1002
1003 function SkipTo($Block)
1004 {
1005 return $this->Skip($Block - $this->Block);
1006 }
1007
1008 function readHeader($Long = false)
1009 {
1010 $str = '';
1011 while(trim($str) == '')
1012 {
1013 if (!($l = strlen($str = $this->readBlock($bIgnoreOpenNextError = true))))
1014 return 0; // finish
1015 }
1016
1017 if (!$Long)
1018 $this->BlockHeader = $this->Block - 1;
1019
1020 if ($l != 512)
1021 return $this->Error('Wrong block size: '.strlen($str).' (block '.$this->Block.')');
1022
1023
1024 $data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix", $str);
1025 $chk = trim($data['devmajor'].$data['devminor']);
1026
1027 if (!is_numeric(trim($data['checksum'])) || !empty($chk))
1028 {
1029 return $this->Error('Archive is corrupted, wrong block: '.($this->Block-1).', file: '.$this->file.', md5sum: '.md5_file($this->file));
1030 }
1031
1032 $header['filename'] = trim(trim($data['prefix'], "\x00").'/'.trim($data['filename'], "\x00"),'/');
1033 $header['mode'] = OctDec($data['mode']);
1034 $header['uid'] = OctDec($data['uid']);
1035 $header['gid'] = OctDec($data['gid']);
1036 $header['size'] = OctDec($data['size']);
1037 $header['mtime'] = OctDec($data['mtime']);
1038 $header['type'] = trim($data['type'], "\x00");
1039// $header['link'] = $data['link'];
1040
1041 if (str_starts_with($header['filename'], './'))
1042 $header['filename'] = substr($header['filename'], 2);
1043
1044 if ($header['type']=='L') // Long header
1045 {
1046 $filename = '';
1047 $n = ceil($header['size']/512);
1048 for ($i = 0; $i < $n; $i++)
1049 $filename .= $this->readBlock();
1050
1051 if (!is_array($header = $this->readHeader($Long = true)))
1052 return $this->Error('Wrong long header, block: '.$this->Block);
1053 $header['filename'] = substr($filename, 0, strpos($filename, chr(0)));
1054 }
1055
1056 if (str_starts_with($header['filename'], '/')) // trailing slash
1057 $header['type'] = 5; // Directory
1058
1059 if ($header['type']=='5')
1060 $header['size'] = '';
1061
1062 if ($header['filename']=='')
1063 return $this->Error('Filename is empty, wrong block: '.($this->Block-1));
1064
1065 if (!$this->checkCRC($str, $data))
1066 return $this->Error('Checksum error on file: '.$header['filename']);
1067
1068 $this->header = $header;
1069
1070 return $header;
1071 }
1072
1074 {
1075 $checksum = $this->checksum($str);
1076 $res = octdec($data['checksum']) == $checksum || $data['checksum']===0 && $checksum==256;
1077 return $res;
1078 }
1079
1080 function extractFile()
1081 {
1082 if ($this->header === null)
1083 {
1084 if(($header = $this->readHeader()) === false || $header === 0 || $header === true)
1085 {
1086 if ($header === true && $this->SkipFile() === false)
1087 return false;
1088 return $header;
1089 }
1090
1091 $this->lastPath = $f = $this->path.'/'.$header['filename'];
1092
1093 if ($this->ReadBlockCurrent == 0)
1094 {
1095 if ($header['type']==5) // dir
1096 {
1097 if(!file_exists($f) && !self::xmkdir($f))
1098 return $this->ErrorAndSkip('Can\'t create folder: '.$f);
1099 //chmod($f, $header['mode']);
1100 }
1101 else // file
1102 {
1103 if (!self::xmkdir($dirname = dirname($f)))
1104 return $this->ErrorAndSkip('Can\'t create folder: '.$dirname);
1105 elseif (($rs = fopen($f, 'wb'))===false)
1106 return $this->ErrorAndSkip('Can\'t create file: '.$f);
1107 }
1108 }
1109 else
1110 return $this->Skip($this->ReadBlockCurrent);
1111 }
1112 else // файл уже частично распакован, продолжаем на том же хите
1113 {
1114 $header = $this->header;
1115 $this->lastPath = $f = $this->path.'/'.$header['filename'];
1116 }
1117
1118 if ($header['type'] != 5) // пишем контент в файл
1119 {
1120 if (!$rs)
1121 {
1122 if (($rs = fopen($f, 'ab'))===false)
1123 return $this->ErrorAndSkip('Can\'t open file: '.$f);
1124 }
1125
1126 $i = 0;
1127 $FileBlockCount = ceil($header['size'] / 512);
1128 while(++$this->ReadBlockCurrent <= $FileBlockCount && ($contents = $this->readBlock()))
1129 {
1130 if ($this->ReadBlockCurrent == $FileBlockCount && ($chunk = $header['size'] % 512))
1131 $contents = substr($contents, 0, $chunk);
1132
1133 fwrite($rs,$contents);
1134
1135 if ($this->ReadBlockMax && ++$i >= $this->ReadBlockMax)
1136 {
1137 fclose($rs);
1138 return true; // Break
1139 }
1140 }
1141 fclose($rs);
1142
1143 if (($s = filesize($f)) != $header['size'])
1144 return $this->Error('File size is wrong: '.$header['filename'].' (real: '.$s.' expected: '.$header['size'].')');
1145
1146 //chmod($f, $header['mode']);
1147 }
1148
1149 if ($this->header['type']==5)
1150 $this->DirCount++;
1151 else
1152 $this->FileCount++;
1153
1154 $this->debug_header = $this->header;
1155 $this->BlockHeader = $this->Block;
1156 $this->ReadBlockCurrent = 0;
1157 $this->header = null;
1158
1159 return true;
1160 }
1161
1162 function openNext($bIgnoreOpenNextError)
1163 {
1164 if (file_exists($file = $this->getNextName()))
1165 {
1166 $this->close();
1167 return $this->open($file,$this->mode);
1168 }
1169 elseif (!$bIgnoreOpenNextError)
1170 return $this->Error("File doesn't exist: ".$file);
1171 return false;
1172 }
1173
1174 public static function getLastNum($file)
1175 {
1176 $file = self::getFirstName($file);
1177
1178 if (!file_exists($file))
1179 return false;
1180 $f = fopen($file, 'rb');
1181 fseek($f, 12);
1182 if (fread($f, 2) == 'LN')
1183 $res = end(unpack('va',fread($f, 2)));
1184 else
1185 $res = false;
1186 fclose($f);
1187 return $res;
1188 }
1189
1190 # }
1191 ##############
1192
1193 ##############
1194 # WRITE
1195 # {
1197 {
1198 if (!isset($this->gzip) && (substr($file,-3)=='.gz' || substr($file,-4)=='.tgz'))
1199 $this->gzip = true;
1200
1201 $this->BufferSize = 51200;
1202
1203 if (intval($this->ArchiveSizeLimit) <= 0)
1204 $this->ArchiveSizeLimit = 1024 * 1024 * 1024; // 1Gb
1205
1206
1207 $this->Block = 0;
1208 while(file_exists($file1 = $this->getNextName($file))) // находим последний архив
1209 {
1210 $this->Block += ceil($this->ArchiveSizeLimit / 512);
1211 $file = $file1;
1212 }
1213
1214 $size = 0;
1215 if (file_exists($file) && !$size = $this->getDataSize($file))
1216 {
1217 return $this->Error('Can\'t get data size: '.$file);
1218 }
1219
1220 $this->Block += $size / 512;
1221 if ($size >= $this->ArchiveSizeLimit) // если последний архив полон
1222 {
1223 $file = $file1;
1224 $size = 0;
1225 }
1226 $this->ArchiveSizeCurrent = $size;
1227
1228 $res = $this->open($file, 'a');
1229 if ($res && $this->Block == 0 && ($key = $this->getEncryptKey())) // запишем служебный заголовок для зашифрованного архива
1230 {
1231 $ver = function_exists('openssl_encrypt') ? '1.2' : '1.1';
1232 $enc = pack("a100a90a10a56",md5(uniqid(rand(), true)), self::BX_SIGNATURE, $ver, "");
1233 $enc .= $this->encrypt($enc, $key);
1234 if (!($this->gzip ? gzwrite($this->res, $enc) : fwrite($this->res, $enc)))
1235 {
1236 return $this->Error('Error writing to file');
1237 }
1238 $this->Block = 1;
1239 $this->ArchiveSizeCurrent = 512;
1240 }
1241 return $res;
1242 }
1243
1244 // создадим пустой gzip с экстра полем
1246 {
1247 if (file_exists($file))
1248 {
1249 return $this->Error('File already exists: '.$file);
1250 }
1251
1252 if (!($f = gzopen($file,'wb')))
1253 {
1254 return $this->Error('Can\'t open file: '.$file);
1255 }
1256
1257 gzwrite($f,'');
1258 gzclose($f);
1259
1260 $data = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\xff\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00"; // buggy zlib 1.2.7
1261
1262 if (!($f = fopen($file, 'w')))
1263 {
1264 return $this->Error('Can\'t open file for writing: '.$file);
1265 }
1266
1267 $ar = unpack('A3bin0/c1FLG/A6bin1', substr($data,0,10));
1268
1269 $EXTRA = "\x00\x00\x00\x00".self::BX_EXTRA; // 10 байт
1270 fwrite($f,$ar['bin0']."\x04".$ar['bin1'].chr(strlen($EXTRA))."\x00".$EXTRA.substr($data,10));
1271 fclose($f);
1272 return true;
1273 }
1274
1276 {
1277 $l = strlen($str);
1278 if ($l!=512)
1279 return $this->Error('Wrong block size: '.$l);
1280
1281 if ($this->ArchiveSizeCurrent >= $this->ArchiveSizeLimit)
1282 {
1283 $file = $this->getNextName();
1284 $this->close();
1285
1286 if (!$this->open($file,$this->mode))
1287 return false;
1288
1289 $this->ArchiveSizeCurrent = 0;
1290 }
1291
1292 $this->Buffer .= $str;
1293
1294 $this->Block++;
1295 $this->ArchiveSizeCurrent += 512;
1296
1297 if (strlen($this->Buffer) == $this->BufferSize)
1298 return $this->flushBuffer();
1299
1300 return true;
1301 }
1302
1303 function flushBuffer()
1304 {
1305 if (!$str = $this->Buffer)
1306 return true;
1307 $this->Buffer = '';
1308
1309 if ($key = $this->getEncryptKey())
1310 $str = $this->encrypt($str, $key);
1311
1312 return $this->gzip ? gzwrite($this->res, $str) : fwrite($this->res, $str);
1313 }
1314
1316 {
1317 $header0 = pack("a100a8a8a8a12a12", $ar['filename'], decoct($ar['mode']), decoct($ar['uid']), decoct($ar['gid']), decoct($ar['size']), decoct($ar['mtime']));
1318 $header1 = pack("a1a100a6a2a32a32a8a8a155", $ar['type'],'','','','','','', '', $ar['prefix'] ?? null);
1319
1320 $checksum = pack("a8",decoct($this->checksum($header0.' '.$header1)));
1321 $header = pack("a512", $header0.$checksum.$header1);
1322 return $this->writeBlock($header) || $this->Error('Error writing header');
1323 }
1324
1325 function addFile($f)
1326 {
1327 $f = str_replace('\\', '/', $f);
1328 $path = $this->prefix.substr($f, strlen($this->path) + 1);
1329 if ($path == '')
1330 return true;
1331 if (strlen($path) > 512)
1332 return $this->Error('Path is too long: '.$path);
1333 if (is_link($f) && !file_exists($f)) // broken link
1334 return true;
1335
1336 if (!$ar = $this->getFileInfo($f))
1337 return false;
1338
1339 if ($this->ReadBlockCurrent == 0) // read from start
1340 {
1341 $this->ReadFileSize = $ar['size'];
1342 if (strlen($path) > 100) // Long header
1343 {
1344 $ar0 = $ar;
1345 $ar0['type'] = 'L';
1346 $ar0['filename'] = '././@LongLink';
1347 $ar0['size'] = strlen($path);
1348 if (!$this->writeHeader($ar0))
1349 return $this->Error('Can\'t write header to file: '.$this->file);
1350
1351 if (!$this->writeBlock(pack("a512",$path)))
1352 return $this->Error('Can\'t write to file: '.$this->file);
1353
1354 $ar['filename'] = substr($path,0,100);
1355 }
1356
1357 if (!$this->writeHeader($ar))
1358 return $this->Error('Can\'t write header to file: '.$this->file);
1359 }
1360
1361 if ($ar['type'] == 0 && $ar['size'] > 0) // File
1362 {
1363 if (!($rs = fopen($f, 'rb')))
1364 return $this->Error('Error opening file: '.$f);
1365
1366 if ($this->ReadBlockCurrent)
1367 fseek($rs, $this->ReadBlockCurrent * 512);
1368
1369 $i = 0;
1370 while(!feof($rs) && ('' !== $str = fread($rs,512)))
1371 {
1372 if ($this->ReadFileSize && $this->ReadBlockCurrent * 512 > $this->ReadFileSize)
1373 return $this->Error('File has changed while reading: '.$f);
1374 $this->ReadBlockCurrent++;
1375 if (feof($rs))
1376 {
1377 $str = pack("a512", $str);
1378 }
1379 elseif (strlen($str) != 512)
1380 {
1381 return $this->Error('Error reading from file: '.$f);
1382 }
1383
1384 if (!$this->writeBlock($str))
1385 {
1386 fclose($rs);
1387 return $this->Error('Error processing file: '.$f);
1388 }
1389
1390 if ($this->ReadBlockMax && ++$i >= $this->ReadBlockMax)
1391 {
1392 fclose($rs);
1393 return true;
1394 }
1395 }
1396 fclose($rs);
1397 $this->ReadBlockCurrent = 0;
1398 }
1399 return true;
1400 }
1401
1402 # }
1403 ##############
1404
1405 ##############
1406 # BASE
1407 # {
1408 function open($file, $mode='r')
1409 {
1410 $this->file = $file;
1411 $this->mode = $mode;
1412
1413 if (is_dir($file))
1414 return $this->Error('File is directory: '.$file);
1415
1416 if ($this->EncryptKey && !function_exists('openssl_encrypt'))
1417 return $this->Error('Function openssl_encrypt is not available');
1418
1419 if ($mode == 'r' && !file_exists($file))
1420 return $this->Error('File does not exist: '.$file);
1421
1422 if ($this->gzip)
1423 {
1424 if(!function_exists('gzopen'))
1425 {
1426 return $this->Error('Function &quot;gzopen&quot; is not available');
1427 }
1428 else
1429 {
1430 if ($mode == 'a' && !file_exists($file) && !$this->createEmptyGzipExtra($file))
1431 {
1432 return false;
1433 }
1434 $this->res = gzopen($file,$mode."b");
1435 }
1436 }
1437 else
1438 {
1439 $this->res = fopen($file,$mode."b");
1440 }
1441
1442 return $this->res;
1443 }
1444
1445 function close()
1446 {
1447 if ($this->mode == 'a')
1448 $this->flushBuffer();
1449
1450 if ($this->gzip)
1451 {
1452 gzclose($this->res);
1453
1454 if ($this->mode == 'a')
1455 {
1456 // добавим фактический размер всех несжатых данных в extra поле
1457 $f = fopen($this->file, 'rb+');
1458 fseek($f, 18);
1459 fwrite($f, pack("V", $this->ArchiveSizeCurrent));
1460 fclose($f);
1461
1462 $this->dataSizeCache[$this->file] = $this->ArchiveSizeCurrent;
1463
1464 // сохраним номер последней части в первый архив для многотомных архивов
1465 if (preg_match('#^(.+)\.([0-9]+)$#', $this->file, $regs))
1466 {
1467 $f = fopen($regs[1], 'rb+');
1468 fseek($f, 12);
1469 fwrite($f, 'LN'.pack("v",$regs[2]));
1470 fclose($f);
1471 }
1472 }
1473 }
1474 else
1475 fclose($this->res);
1476 clearstatcache();
1477 }
1478
1479 public function getNextName($file = '')
1480 {
1481 if (!$file)
1482 $file = $this->file;
1483
1484 static $CACHE;
1485 $c = &$CACHE[$file];
1486
1487 if (!$c)
1488 {
1489 $l = strrpos($file, '.');
1490 $num = substr($file,$l+1);
1491 if (is_numeric($num))
1492 $file = substr($file,0,$l+1).++$num;
1493 else
1494 $file .= '.1';
1495 $c = $file;
1496 }
1497 return $c;
1498 }
1499
1500 function checksum($s)
1501 {
1502 $chars = count_chars(substr($s,0,148).' '.substr($s,156,356));
1503 $sum = 0;
1504 foreach($chars as $ch => $cnt)
1505 $sum += $ch*$cnt;
1506 return $sum;
1507 }
1508
1510 {
1511 $size = &$this->dataSizeCache[$file];
1512 if (!$size)
1513 {
1514 if (!file_exists($file))
1515 $size = false;
1516 else
1517 {
1518 if (preg_match('#\.gz(\.[0-9]+)?$#',$file))
1519 {
1520 $f = fopen($file, "rb");
1521 fseek($f, 16);
1522 if (fread($f, 2) == 'BX')
1523 $size = end(unpack("V", fread($f, 4)));
1524 else
1525 {
1526// $this->Error('Wrong GZIP Extra Field');
1527 $size = false;
1528 }
1529 fclose($f);
1530 }
1531 else
1532 $size = filesize($file);
1533 }
1534 }
1535
1536 return $size;
1537 }
1538
1539 function Error($str = '', $code = '')
1540 {
1541 if ($code)
1542 $this->LastErrCode = $code;
1543 $this->err[] = $str;
1544 return false;
1545 }
1546
1547 function ErrorAndSkip($str = '', $code = '')
1548 {
1549 $this->Error($str, $code);
1550 $this->SkipFile();
1551 if ($this->readHeader() === 0)
1552 $this->BlockHeader = $this->Block;
1553 return false;
1554 }
1555
1556 public static function xmkdir($dir)
1557 {
1558 if (!file_exists($dir))
1559 {
1560 $upper_dir = dirname($dir);
1561 if (!file_exists($upper_dir) && !self::xmkdir($upper_dir))
1562 return false;
1563
1564 return mkdir($dir);
1565 }
1566
1567 return is_dir($dir);
1568 }
1569
1570 function getEncryptKey()
1571 {
1572 if (!$this->EncryptKey)
1573 return false;
1574 static $key;
1575 if (!$key)
1576 $key = md5($this->EncryptKey);
1577 return $key;
1578 }
1579
1580 function getFileInfo($f)
1581 {
1582 $f = str_replace('\\', '/', $f);
1583 $path = substr($f, strlen($this->path) + 1);
1584
1585 $ar = array();
1586
1587 if (is_dir($f))
1588 {
1589 $ar['type'] = 5;
1590 $path .= '/';
1591 }
1592 else
1593 $ar['type'] = 0;
1594
1595 if (!$info = stat($f))
1596 return $this->Error('Can\'t get file info: '.$f);
1597
1598 if ($info['size'] < 0)
1599 return $this->Error('File is too large: '.$f);
1600
1601 $ar['mode'] = 0777 & $info['mode'];
1602 $ar['uid'] = $info['uid'];
1603 $ar['gid'] = $info['gid'];
1604 $ar['size'] = $ar['type']==5 ? 0 : $info['size'];
1605 $ar['mtime'] = $info['mtime'];
1606 $ar['filename'] = $this->prefix.$path;
1607
1608 return $ar;
1609 }
1610
1611 public static function getCheckword($key)
1612 {
1613 return md5('BITRIXCLOUDSERVICE'.$key);
1614 }
1615
1616 public static function getFirstName($file)
1617 {
1618 return preg_replace('#\.[0-9]+$#','',$file);
1619 }
1620
1621 // List of all ever used cipher methods
1622 // It is critical to use ECB family because crypto stream might be interrupted.
1623 public static function getCryptoAlgorithmList()
1624 {
1625 return ['aes-256-ecb', 'bf-ecb'];
1626 }
1627
1628 public static function getDefaultCryptoAlgorithm()
1629 {
1630 return static::getCryptoAlgorithmList()[0];
1631 }
1632
1633 public static function encrypt($data, $md5_key)
1634 {
1635 $m = strlen($data) % 16;
1636 if ($m)
1637 {
1638 $data .= str_repeat("\x00", 16 - $m);
1639 }
1640
1641 return openssl_encrypt($data, static::getDefaultCryptoAlgorithm(), $md5_key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING);
1642 }
1643
1644 public static function decrypt($data, $md5_key, $method = null)
1645 {
1646 if ($method === null)
1647 {
1648 $method = static::getDefaultCryptoAlgorithm();
1649 }
1650 $result = openssl_decrypt($data, $method, $md5_key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING);
1651 if ($result === false && $method === 'bf-ecb')
1652 {
1653 $result = static::bf_ecb_decrypt($md5_key, $data);
1654 }
1655
1656 return $result;
1657 }
1658
1659 protected static function bf_ecb_decrypt($key, $ciphertext)
1660 {
1661 static $sbox0 = [
1662 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
1663 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
1664 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
1665 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
1666 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
1667 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
1668 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
1669 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
1670 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
1671 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
1672 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
1673 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
1674 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
1675 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
1676 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
1677 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
1678 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
1679 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
1680 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
1681 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
1682 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
1683 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
1684 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
1685 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
1686 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
1687 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
1688 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
1689 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
1690 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
1691 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
1692 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
1693 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a,
1694 ];
1695 static $sbox1 = [
1696 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
1697 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
1698 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
1699 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
1700 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
1701 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
1702 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
1703 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
1704 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
1705 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
1706 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
1707 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
1708 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
1709 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
1710 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
1711 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
1712 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
1713 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
1714 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
1715 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
1716 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
1717 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
1718 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
1719 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
1720 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
1721 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
1722 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
1723 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
1724 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
1725 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
1726 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
1727 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7,
1728 ];
1729 static $sbox2 = [
1730 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
1731 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
1732 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
1733 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
1734 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
1735 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
1736 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
1737 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
1738 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
1739 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
1740 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
1741 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
1742 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
1743 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
1744 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
1745 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
1746 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
1747 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
1748 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
1749 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
1750 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
1751 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
1752 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
1753 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
1754 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
1755 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
1756 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
1757 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
1758 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
1759 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
1760 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
1761 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0,
1762 ];
1763 static $sbox3 = [
1764 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
1765 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
1766 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
1767 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
1768 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
1769 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
1770 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
1771 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
1772 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
1773 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
1774 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
1775 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
1776 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
1777 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
1778 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
1779 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
1780 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
1781 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
1782 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
1783 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
1784 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
1785 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
1786 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
1787 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
1788 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
1789 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
1790 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
1791 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
1792 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
1793 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
1794 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
1795 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6,
1796 ];
1797 static $parray = [
1798 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0,
1799 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
1800 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b,
1801 ];
1802
1803 $encryptFast = function (int $x0, int $x1, array $sbox0, array $sbox1, array $sbox2, array $sbox3, array $p)
1804 {
1805 $x0 ^= $p[0];
1806 $x1 ^= ((($sbox0[($x0 & 0xFF000000) >> 24] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[1];
1807 $x0 ^= ((($sbox0[($x1 & 0xFF000000) >> 24] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[2];
1808 $x1 ^= ((($sbox0[($x0 & 0xFF000000) >> 24] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[3];
1809 $x0 ^= ((($sbox0[($x1 & 0xFF000000) >> 24] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[4];
1810 $x1 ^= ((($sbox0[($x0 & 0xFF000000) >> 24] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[5];
1811 $x0 ^= ((($sbox0[($x1 & 0xFF000000) >> 24] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[6];
1812 $x1 ^= ((($sbox0[($x0 & 0xFF000000) >> 24] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[7];
1813 $x0 ^= ((($sbox0[($x1 & 0xFF000000) >> 24] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[8];
1814 $x1 ^= ((($sbox0[($x0 & 0xFF000000) >> 24] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[9];
1815 $x0 ^= ((($sbox0[($x1 & 0xFF000000) >> 24] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[10];
1816 $x1 ^= ((($sbox0[($x0 & 0xFF000000) >> 24] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[11];
1817 $x0 ^= ((($sbox0[($x1 & 0xFF000000) >> 24] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[12];
1818 $x1 ^= ((($sbox0[($x0 & 0xFF000000) >> 24] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[13];
1819 $x0 ^= ((($sbox0[($x1 & 0xFF000000) >> 24] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[14];
1820 $x1 ^= ((($sbox0[($x0 & 0xFF000000) >> 24] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[15];
1821 $x0 ^= ((($sbox0[($x1 & 0xFF000000) >> 24] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[16];
1822
1823 return [$x1 & 0xFFFFFFFF ^ $p[17], $x0 & 0xFFFFFFFF];
1824 };
1825 $encryptSlow = function(int $x0, int $x1, array $sbox0, array $sbox1, array $sbox2, array $sbox3, array $p)
1826 {
1827 // -16777216 == intval(0xFF000000) on 32-bit PHP installs
1828 $x0 ^= $p[0];
1829 $x1 ^= intval((intval($sbox0[(($x0 & -16777216) >> 24) & 0xFF] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[1];
1830 $x0 ^= intval((intval($sbox0[(($x1 & -16777216) >> 24) & 0xFF] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[2];
1831 $x1 ^= intval((intval($sbox0[(($x0 & -16777216) >> 24) & 0xFF] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[3];
1832 $x0 ^= intval((intval($sbox0[(($x1 & -16777216) >> 24) & 0xFF] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[4];
1833 $x1 ^= intval((intval($sbox0[(($x0 & -16777216) >> 24) & 0xFF] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[5];
1834 $x0 ^= intval((intval($sbox0[(($x1 & -16777216) >> 24) & 0xFF] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[6];
1835 $x1 ^= intval((intval($sbox0[(($x0 & -16777216) >> 24) & 0xFF] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[7];
1836 $x0 ^= intval((intval($sbox0[(($x1 & -16777216) >> 24) & 0xFF] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[8];
1837 $x1 ^= intval((intval($sbox0[(($x0 & -16777216) >> 24) & 0xFF] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[9];
1838 $x0 ^= intval((intval($sbox0[(($x1 & -16777216) >> 24) & 0xFF] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[10];
1839 $x1 ^= intval((intval($sbox0[(($x0 & -16777216) >> 24) & 0xFF] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[11];
1840 $x0 ^= intval((intval($sbox0[(($x1 & -16777216) >> 24) & 0xFF] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[12];
1841 $x1 ^= intval((intval($sbox0[(($x0 & -16777216) >> 24) & 0xFF] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[13];
1842 $x0 ^= intval((intval($sbox0[(($x1 & -16777216) >> 24) & 0xFF] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[14];
1843 $x1 ^= intval((intval($sbox0[(($x0 & -16777216) >> 24) & 0xFF] + $sbox1[($x0 & 0xFF0000) >> 16]) ^ $sbox2[($x0 & 0xFF00) >> 8]) + $sbox3[$x0 & 0xFF]) ^ $p[15];
1844 $x0 ^= intval((intval($sbox0[(($x1 & -16777216) >> 24) & 0xFF] + $sbox1[($x1 & 0xFF0000) >> 16]) ^ $sbox2[($x1 & 0xFF00) >> 8]) + $sbox3[$x1 & 0xFF]) ^ $p[16];
1845
1846 return [$x1 ^ $p[17], $x0];
1847 };
1848
1849 $bctx = [
1850 'p' => [],
1851 'sb' => [
1852 $sbox0,
1853 $sbox1,
1854 $sbox2,
1855 $sbox3,
1856 ],
1857 ];
1858
1859 $key = array_values(unpack('C*', $key));
1860 $keyl = count($key);
1861 for ($j = 0, $i = 0; $i < 18; ++$i)
1862 {
1863 for ($data = 0, $k = 0; $k < 4; ++$k)
1864 {
1865 $data = ($data << 8) | $key[$j];
1866 if (++$j >= $keyl)
1867 {
1868 $j = 0;
1869 }
1870 }
1871 $bctx['p'][] = $parray[$i] ^ intval($data);
1872 }
1873
1874 $data = "\0\0\0\0\0\0\0\0";
1875 for ($i = 0; $i < 18; $i += 2)
1876 {
1877 $in = unpack('N*', $data);
1878 $l = $in[1];
1879 $r = $in[2];
1880
1881 [$r, $l] = PHP_INT_SIZE == 4 ?
1882 $encryptSlow($l, $r, $bctx['sb'][0], $bctx['sb'][1], $bctx['sb'][2], $bctx['sb'][3], $bctx['p']) :
1883 $encryptFast($l, $r, $bctx['sb'][0], $bctx['sb'][1], $bctx['sb'][2], $bctx['sb'][3], $bctx['p']);
1884
1885 $data = pack("N*", $r, $l);
1886
1887 [$l, $r] = array_values(unpack('N*', $data));
1888 $bctx['p'][$i ] = $l;
1889 $bctx['p'][$i + 1] = $r;
1890 }
1891 for ($i = 0; $i < 4; ++$i)
1892 {
1893 for ($j = 0; $j < 256; $j += 2)
1894 {
1895 $in = unpack('N*', $data);
1896 $l = $in[1];
1897 $r = $in[2];
1898
1899 [$r, $l] = PHP_INT_SIZE == 4 ?
1900 $encryptSlow($l, $r, $bctx['sb'][0], $bctx['sb'][1], $bctx['sb'][2], $bctx['sb'][3], $bctx['p']) :
1901 $encryptFast($l, $r, $bctx['sb'][0], $bctx['sb'][1], $bctx['sb'][2], $bctx['sb'][3], $bctx['p']);
1902
1903 $data = pack("N*", $r, $l);
1904
1905 [$l, $r] = array_values(unpack('N*', $data));
1906 $bctx['sb'][$i][$j ] = $l;
1907 $bctx['sb'][$i][$j + 1] = $r;
1908 }
1909 }
1910
1911 $block_size = 8;
1912 $result = '';
1913 for ($i = 0; $i < strlen($ciphertext); $i += $block_size)
1914 {
1915 $p = $bctx['p'];
1916 $sb_0 = $bctx['sb'][0];
1917 $sb_1 = $bctx['sb'][1];
1918 $sb_2 = $bctx['sb'][2];
1919 $sb_3 = $bctx['sb'][3];
1920
1921 $in = unpack('N*', substr($ciphertext, $i, $block_size));
1922 $l = $in[1];
1923 $r = $in[2];
1924
1925 for ($j = 17; $j > 2; $j -= 2)
1926 {
1927 $l ^= $p[$j];
1928 $r ^= intval((intval($sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff])
1929 ^ $sb_2[$l >> 8 & 0xff]) + $sb_3[$l & 0xff]
1930 );
1931
1932 $r ^= $p[$j - 1];
1933 $l ^= intval((intval($sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff])
1934 ^ $sb_2[$r >> 8 & 0xff]) + $sb_3[$r & 0xff]
1935 );
1936 }
1937 $result .= pack('N*', $r ^ $p[0], $l ^ $p[1]);
1938 }
1939
1940 return $result;
1941 }
1942
1943 # }
1944 ##############
1945}
1946
1947class CTarCheck extends CTar
1948{
1949 function extractFile()
1950 {
1951 $header = $this->readHeader();
1952 if($header === false || $header === 0)
1953 return $header;
1954
1955 return $this->SkipFile();
1956 }
1957}
1958
1960{
1961 function __construct($id)
1962 {
1963 $this->id = $id;
1964 $this->last_bucket_path = '';
1965 $this->arSkipped = array();
1966 $this->path = '';
1967 $this->download_cnt = 0;
1968 $this->download_size = 0;
1969
1970 $this->obBucket = new CCloudStorageBucket($id);
1971 if (!$this->obBucket->Init())
1972 return;
1973 }
1974
1975 function Scan($path)
1976 {
1977 $this->path = $path;
1978
1979 if ($arCloudFiles = CBackup::GetBucketFileList($this->id, $path))
1980 {
1981 foreach($arCloudFiles['file'] as $k=>$file)
1982 {
1983 if ($this->last_bucket_path)
1984 {
1985 if ($path.'/'.$file == $this->last_bucket_path)
1986 $this->last_bucket_path = '';
1987 else
1988 continue;
1989 }
1990
1991 $name = $this->path = $path.'/'.$file;
1992 if (!haveTime()) // Сохраняется путь файла, который еще предстоит сохранить, TODO: пошаговое скачивание больших файлов
1993 return false;
1994
1995 $http = new \Bitrix\Main\Web\HttpClient();
1996 if ($http->download($this->obBucket->GetFileSRC(array("URN" => $name)), DOCUMENT_ROOT.BX_ROOT.'/backup/clouds/'.$this->id.$name))
1997 {
1998 $this->download_size += $arCloudFiles['file_size'][$k];
1999 $this->download_cnt++;
2000 }
2001 else
2002 $this->arSkipped[] = $name;
2003 }
2004 }
2005
2006 foreach($arCloudFiles['dir'] as $dir)
2007 {
2008 if ($this->last_bucket_path)
2009 {
2010 if ($path.'/'.$dir == $this->last_bucket_path)
2011 $this->last_bucket_path = '';
2012 elseif (mb_strpos($this->last_bucket_path, $path.'/'.$dir) !== 0)
2013 continue;
2014 }
2015
2016 if ($path.'/'.$dir == '/bitrix/backup')
2017 continue;
2018
2019 if ($path.'/'.$dir == '/tmp')
2020 continue;
2021
2022 if (!$this->Scan($path.'/'.$dir)) // partial
2023 return false;
2024 }
2025
2026 return true;
2027 }
2028}
2029
2030function HumanTime($t)
2031{
2032 $ar = array(GetMessage('TIME_S'),GetMessage('TIME_M'),GetMessage('TIME_H'));
2033 if ($t < 60)
2034 return sprintf('%d '.$ar[0], $t);
2035 if ($t < 3600)
2036 return sprintf('%d '.$ar[1], floor($t/60));
2037// return sprintf('%d '.$ar[1].' %d '.$ar[0], floor($t/60), $t%60);
2038 return sprintf('%d '.$ar[2].' %d '.$ar[1], floor($t/3600), floor($t%3600/60));
2039// return sprintf('%d '.$ar[2].' %d '.$ar[1].' %d '.$ar[0], floor($t/3600), floor($t%3600/60), $t%60);
2040}
$path
Определения access_edit.php:21
$sum
Определения checkout.php:6
const BX_ROOT
Определения bx_root.php:3
$strVal
Определения options.php:1786
$arResult
Определения generate_coupon.php:16
static getString($length, $caseSensitive=false)
Определения random.php:76
Определения backup.php:16
static SkipTableData($table)
Определения backup.php:514
static FreeResult()
Определения backup.php:463
static CheckDumpClouds()
Определения backup.php:23
$LastFileSize
Определения backup.php:21
static $DOCUMENT_ROOT_SITE
Определения backup.php:17
static MakeDump($strDumpFile, &$arState)
Определения backup.php:238
static skipMask($abs_path)
Определения backup.php:169
static ignorePath($path)
Определения backup.php:60
static $REAL_DOCUMENT_ROOT_SITE
Определения backup.php:18
static CheckDumpFiles()
Определения backup.php:37
static GetTableColumns($TableName)
Определения backup.php:494
static GetArcName($prefix='')
Определения backup.php:217
static GetBucketFileList($BUCKET_ID, $path)
Определения backup.php:148
static GetBucketList($arFilter=array())
Определения backup.php:42
static QueryUnbuffered($q)
Определения backup.php:452
static _preg_escape($str)
Определения backup.php:162
static getNextName($file)
Определения backup.php:526
file_put_contents_ex($strDumpFile, $str)
Определения backup.php:470
$strLastFile
Определения backup.php:20
static GetList($arOrder=[], $arFilter=[], $arSelect=[])
Определения storage_bucket.php:791
Определения backup.php:663
ProcessFile($f)
Определения backup.php:665
Skip($f)
Определения backup.php:743
ProcessDirBefore($f)
Определения backup.php:737
$arSkip
Определения backup.php:664
Определения backup.php:546
__construct()
Определения backup.php:556
ProcessFile($f)
Определения backup.php:570
Skip($f)
Определения backup.php:575
$FileCount
Определения backup.php:548
ProcessDirAfter($f)
Определения backup.php:565
$startPath
Определения backup.php:553
$arIncludeDir
Определения backup.php:554
$nextPath
Определения backup.php:552
$bFound
Определения backup.php:551
$err
Определения backup.php:549
$DirCount
Определения backup.php:547
ProcessDirBefore($f)
Определения backup.php:560
Scan($dir)
Определения backup.php:594
Определения backup.php:772
static Get($strName)
Определения backup.php:817
const SIGN
Определения backup.php:773
static Set($strName, $strVal)
Определения backup.php:804
static Init()
Определения backup.php:775
Определения backup.php:1948
extractFile()
Определения backup.php:1949
Определения backup.php:851
addFile($f)
Определения backup.php:1325
checksum($s)
Определения backup.php:1500
flushBuffer()
Определения backup.php:1303
$prefix
Определения backup.php:874
$path
Определения backup.php:859
getDataSize($file)
Определения backup.php:1509
$Block
Определения backup.php:857
Skip($Block)
Определения backup.php:966
writeBlock($str)
Определения backup.php:1275
extractFile()
Определения backup.php:1080
$LastErrCode
Определения backup.php:855
static decrypt($data, $md5_key, $method=null)
Определения backup.php:1644
checkCRC($str, $data)
Определения backup.php:1073
static encrypt($data, $md5_key)
Определения backup.php:1633
static getFirstName($file)
Определения backup.php:1616
ErrorAndSkip($str='', $code='')
Определения backup.php:1547
readHeader($Long=false)
Определения backup.php:1008
writeHeader($ar)
Определения backup.php:1315
$FileCount
Определения backup.php:860
$EncryptKey
Определения backup.php:872
const BX_SIGNATURE
Определения backup.php:868
static getCryptoAlgorithmList()
Определения backup.php:1623
openRead($file)
Определения backup.php:879
static getCheckword($key)
Определения backup.php:1611
$res
Определения backup.php:856
static bf_ecb_decrypt($key, $ciphertext)
Определения backup.php:1659
$header
Определения backup.php:865
$ReadFileSize
Определения backup.php:864
$gzip
Определения backup.php:852
$BlockHeader
Определения backup.php:858
getEncryptKey()
Определения backup.php:1570
createEmptyGzipExtra($file)
Определения backup.php:1245
$Buffer
Определения backup.php:870
static xmkdir($dir)
Определения backup.php:1556
SkipFile()
Определения backup.php:956
$BufferSize
Определения backup.php:869
$ReadBlockMax
Определения backup.php:862
static getLastNum($file)
Определения backup.php:1174
openNext($bIgnoreOpenNextError)
Определения backup.php:1162
const BX_EXTRA
Определения backup.php:867
SkipTo($Block)
Определения backup.php:1003
$ArchiveSizeLimit
Определения backup.php:866
Error($str='', $code='')
Определения backup.php:1539
$file
Определения backup.php:853
$dataSizeCache
Определения backup.php:871
close()
Определения backup.php:1445
open($file, $mode='r')
Определения backup.php:1408
getFileInfo($f)
Определения backup.php:1580
getNextName($file='')
Определения backup.php:1479
openWrite($file)
Определения backup.php:1196
$err
Определения backup.php:854
$ReadBlockCurrent
Определения backup.php:863
$DirCount
Определения backup.php:861
$EncryptAlgorithm
Определения backup.php:873
readBlock($bIgnoreOpenNextError=false)
Определения backup.php:933
static getDefaultCryptoAlgorithm()
Определения backup.php:1628
Определения backup.php:1960
__construct($id)
Определения backup.php:1961
Scan($path)
Определения backup.php:1975
$str
Определения commerceml2.php:63
$contents
Определения commerceml2.php:57
$abs_path
Определения component_props2.php:76
$f
Определения component_props.php:52
$data['IS_AVAILABLE']
Определения .description.php:13
$filename
Определения file_edit.php:47
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$handle
Определения include.php:55
$result
Определения get_property_values.php:14
else $ch
Определения group_list_element_edit.php:27
$p
Определения group_list_element_edit.php:23
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
if(! $ar_profile) $strFile
Определения cron_frame.php:59
global $DB
Определения cron_frame.php:29
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
HumanTime($t)
Определения backup.php:2030
$l
Определения options.php:783
RaiseErrorAndDie($strError, $errCode=0, $ITEM_ID='', $delete=false)
Определения backup.php:996
IntOption($name, $def=0)
Определения backup.php:950
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
Определения backup.php:924
$skip_mask_array
Определения backup.php:227
haveTime()
Определения backup.php:978
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$name
Определения menu_edit.php:35
if(intval($iTestTransaction) > 0) $arTmp
Определения payment.php:22
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
$LIMIT
Определения rss.php:28
$i
Определения factura.php:643
font size
Определения invoice.php:442
</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
$x0
Определения pdf.php:452
else $a
Определения template.php:137
$method
Определения index.php:27
$arRes
Определения options.php:104
$rs
Определения action.php:82
$k
Определения template_pdf.php:567
path
Определения template_copy.php:201
if(file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/updater.log") &&is_file($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/updater.log") &&is_readable($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/updater.log")) $rsData
Определения update_log.php:102
$n
Определения update_log.php:107
$arFilter
Определения user_search.php:106
$x1
Определения template_pdf.php:419