1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
tar_gz.php
См. документацию.
1<?php
2
9
10IncludeModuleLangFile(__FILE__);
11
12class CArchiver implements IBXArchive
13{
14 public $_strArchiveName = "";
15 public $_bCompress = false;
16 public $_strSeparator = " ";
17 public $_dFile = 0;
18 public $_arErrors = [];
19 public $start_time = 0;
20 public $max_exec_time = 0;
21 public $file_pos = 0;
22 public $stepped = false;
23
24 private CBXVirtualIo $io;
25 private $add_path = "";
26 private $remove_path = "";
27 private $startFile = "";
28 private $lastFile = [];
29 private $step_time = 30;
30 private $tempres = false;
31 private $replaceExistentFiles = false;
32 private $checkPermissions = true;
33
34 public function __construct($strArchiveName, $bCompress = false, $start_time = -1, $max_exec_time = -1, $pos = 0, $stepped = false)
35 {
36 $this->io = CBXVirtualIo::GetInstance();
37
38 $this->max_exec_time = $max_exec_time;
39 $this->start_time = $start_time;
40 $this->file_pos = $pos;
41 $this->_bCompress = $bCompress;
42 $this->stepped = $stepped;
43
44 if (!$bCompress)
45 {
46 if (@file_exists($this->io->GetPhysicalName($strArchiveName)))
47 {
48 if ($fp = @fopen($this->io->GetPhysicalName($strArchiveName), "rb"))
49 {
50 $data = fread($fp, 2);
51 fclose($fp);
52 if ($data == "\37\213")
53 {
54 $this->_bCompress = true;
55 }
56 }
57 }
58 else
59 {
60 if (str_ends_with($strArchiveName, 'gz'))
61 {
62 $this->_bCompress = true;
63 }
64 }
65 }
66 else
67 {
68 $this->_bCompress = true;
69 }
70
71 $this->_strArchiveName = $strArchiveName;
72 $this->_arErrors = [];
73 }
74
81 public function Pack($arFileList, $startFile = "")
82 {
83 $this->_arErrors = [];
84 $this->startFile = $this->io->GetPhysicalName($startFile);
85
86 $bNewArchive = true;
87 if (file_exists($this->io->GetPhysicalName($this->_strArchiveName))
88 && is_file($this->io->GetPhysicalName($this->_strArchiveName)) && ($startFile != ""))
89 {
90 $bNewArchive = false;
91 }
92
93 if ($bNewArchive)
94 {
95 if (!$this->_openWrite())
96 {
97 return false;
98 }
99 }
100 else
101 {
102 if (!$this->_openAppendFast())
103 {
104 return false;
105 }
106 }
107
108 $res = false;
109 $arFileList = $this->_parseFileParams($arFileList);
110
111 $arConvertedFileList = [];
112 foreach ($arFileList as $fullpath)
113 {
114 $arConvertedFileList[] = $this->io->GetPhysicalName($fullpath);
115 }
116
117 $this->tempres = null;
118
119 if (is_array($arFileList) && !empty($arFileList))
120 {
121 $res = $this->_processFiles($arConvertedFileList, $this->add_path, $this->remove_path);
122 }
123
124 if ($res !== false && $res !== "continue")
125 {
126 $this->_writeFooter();
127 }
128
129 $this->_close();
130
131 if ($bNewArchive && ($res === false))
132 {
133 $this->_cleanFile();
134 }
135
136 //if packing is not completed, remember last file
137 if ($res === 'continue')
138 {
139 $this->startFile = $this->io->GetLogicalName(array_pop($this->lastFile));
140 }
141
142 if ($res === false)
143 {
145 }
146 elseif ($res && $this->startFile == "")
147 {
149 }
150 elseif ($res && $this->startFile != "")
151 {
153 //call Pack() with $this->getStartFile() next time to continue
154 }
155 return null;
156 }
157
163 public function Unpack($strPath)
164 {
165 $this->_arErrors = [];
166
167 $v_list_detail = [];
168 $arFileList = [];
169
170 $strExtrType = "complete";
171
172 @set_time_limit(0);
173 if ($v_result = $this->_openRead())
174 {
175 $v_result = $this->_extractList($strPath, $v_list_detail, $strExtrType, $arFileList, '');
176 $this->_close();
177 }
178
179 return $v_result;
180 }
181
186 public function GetStartFile()
187 {
188 return $this->startFile;
189 }
190
191 private function _haveTime()
192 {
193 return microtime(true) - START_EXEC_TIME < $this->step_time;
194 }
195
196 private function _processFiles($arFileList, $strAddPath, $strRemovePath)
197 {
198 $strAddPath = str_replace("\\", "/", $strAddPath);
199 $strRemovePath = str_replace("\\", "/", $strRemovePath);
200
201 if (!$this->_dFile)
202 {
203 $this->_arErrors[] = ["ERR_DFILE", GetMessage("MAIN_ARCHIVE_ERR_DFILE")];
204 return false;
205 }
206
207 if (!is_array($arFileList) || empty($arFileList))
208 {
209 return true;
210 }
211
212 $j = -1;
213
214 if (!isset($this->tempres))
215 {
216 $this->tempres = "started";
217 }
218
219 //files and directory scan
220 while ($j++ < count($arFileList) && ($this->tempres === "started"))
221 {
222 $strFilename = $arFileList[$j] ?? '';
223
224 if ($this->_normalizePath($strFilename) == $this->_normalizePath($this->_strArchiveName))
225 {
226 continue;
227 }
228
229 if ($strFilename == '')
230 {
231 continue;
232 }
233
234 if (!file_exists($strFilename))
235 {
236 $this->_arErrors[] = ["NO_FILE", str_replace("#FILE_NAME#", removeDocRoot($strFilename), GetMessage("MAIN_ARCHIVE_NO_FILE"))];
237 continue;
238 }
239 //is a file
240 if (!@is_dir($strFilename))
241 {
242 $strFilename = str_replace("//", "/", $strFilename);
243
244 //jumping to startFile, if it's specified
245 if ($this->startFile <> '')
246 {
247 if ($strFilename != $this->startFile)
248 //don't pack - jump to the next file
249 {
250 continue;
251 }
252 else
253 {
254 //if startFile is found, continue to pack files and folders without startFile, starting from next
255 $this->startFile = null;
256 continue;
257 }
258 }
259
260 //check product permissions
261 if ($this->checkPermissions)
262 {
263 if (!CBXArchive::HasAccess($strFilename, true))
264 {
265 continue;
266 }
267 }
268
269 if ($this->_haveTime())
270 {
271 if (!$this->_addFile($strFilename, $this->add_path, $this->remove_path))
272 {
273 //$arErrors is filled in the _addFile method
274 $this->tempres = false;
275 }
276 else
277 {
278 //remember last file
279 $this->lastFile[] = $strFilename;
280 }
281 }
282 else
283 {
284 $this->tempres = "continue";
285 return $this->tempres;
286 }
287 }
288 //if directory
289 else
290 {
291 if (!($handle = opendir($strFilename)))
292 {
293 $this->_arErrors[] = ["NO_READ", str_replace("#DIR_NAME#", $strFilename, GetMessage("MAIN_ARCHIVE_ERR_DFILE"))];
294 continue;
295 }
296
297 if ($this->checkPermissions)
298 {
299 if (!CBXArchive::HasAccess($strFilename, false))
300 {
301 continue;
302 }
303 }
304
305 while (false !== ($dir = readdir($handle)))
306 {
307 if ($dir != "." && $dir != "..")
308 {
309 $arFileList_tmp = [];
310 if ($strFilename != ".")
311 {
312 $arFileList_tmp[] = $strFilename . '/' . $dir;
313 }
314 else
315 {
316 $arFileList_tmp[] = $dir;
317 }
318
319 $this->_processFiles($arFileList_tmp, $strAddPath, $strRemovePath);
320 }
321 }
322
323 unset($arFileList_tmp);
324 unset($dir);
325 unset($handle);
326 }
327 }
328
329 return $this->tempres;
330 }
331
337 public function SetOptions($arOptions)
338 {
339 if (array_key_exists("COMPRESS", $arOptions))
340 {
341 $this->_bCompress = $arOptions["COMPRESS"] === true;
342 }
343
344 //this is for old 'block' step-by-step writing in the addFile method
345 if (array_key_exists("STEPPED", $arOptions))
346 {
347 $this->stepped = $arOptions["STEPPED"] === true;
348 }
349
350 if (array_key_exists("START_TIME", $arOptions))
351 {
352 $this->start_time = floatval($arOptions["START_TIME"]);
353 }
354
355 if (array_key_exists("MAX_EXEC_TIME", $arOptions))
356 {
357 $this->max_exec_time = intval($arOptions["MAX_EXEC_TIME"]);
358 }
359
360 if (array_key_exists("FILE_POS", $arOptions))
361 {
362 $this->file_pos = intval($arOptions["FILE_POS"]);
363 }
364 //end
365
366 if (array_key_exists("ADD_PATH", $arOptions))
367 {
368 $this->add_path = $this->io->GetPhysicalName(str_replace("\\", "/", strval($arOptions["ADD_PATH"])));
369 }
370
371 if (array_key_exists("REMOVE_PATH", $arOptions))
372 {
373 $this->remove_path = $this->io->GetPhysicalName(str_replace("\\", "/", strval($arOptions["REMOVE_PATH"])));
374 }
375
376 //this is for 'file' step-by-step writing - used in the Pack method
377 if (array_key_exists("STEP_TIME", $arOptions))
378 {
379 $this->step_time = floatval($arOptions["STEP_TIME"]);
380 }
381
382 if (array_key_exists("UNPACK_REPLACE", $arOptions))
383 {
384 $this->replaceExistentFiles = $arOptions["UNPACK_REPLACE"] === true;
385 }
386
387 if (array_key_exists("CHECK_PERMISSIONS", $arOptions))
388 {
389 $this->checkPermissions = $arOptions["CHECK_PERMISSIONS"] === true;
390 }
391 }
392
397 public function GetOptions()
398 {
399 $arOptions = [
400 "COMPRESS" => $this->_bCompress,
401 "STEPPED" => $this->stepped,
402 "START_TIME" => $this->start_time,
403 "MAX_EXEC_TIME" => $this->max_exec_time,
404 "FILE_POS" => $this->file_pos,
405 "ADD_PATH" => $this->add_path,
406 "REMOVE_PATH" => $this->remove_path,
407 "STEP_TIME" => $this->step_time,
408 "UNPACK_REPLACE" => $this->replaceExistentFiles,
409 "CHECK_PERMISSIONS" => $this->checkPermissions,
410 ];
411
412 return $arOptions;
413 }
414
422 public function Add($vFileList, $strAddPath = false, $strRemovePath = false)
423 {
424 $this->_arErrors = [];
425
426 $bNewArchive = true;
427 if (file_exists($this->io->GetPhysicalName($this->_strArchiveName))
428 && is_file($this->io->GetPhysicalName($this->_strArchiveName)))
429 {
430 $bNewArchive = false;
431 }
432
433 if ($bNewArchive)
434 {
435 if (!$this->_openWrite())
436 {
437 return false;
438 }
439 }
440 else
441 {
442 if (!$this->_openAppend())
443 {
444 return false;
445 }
446 }
447 $res = false;
448 $arFileList = $this->_parseFileParams($vFileList);
449
450 if (is_array($arFileList) && !empty($arFileList))
451 {
452 $res = $this->_addFileList($arFileList, $strAddPath, $strRemovePath);
453 }
454
455 if ($res)
456 {
457 $this->_writeFooter();
458 }
459
460 $this->_close();
461
462 if ($bNewArchive && !$res)
463 {
464 $this->_cleanFile();
465 }
466
467 return $res;
468 }
469
477 public function addFile($strFilename, $strAddPath, $strRemovePath)
478 {
479 $strAddPath = str_replace("\\", "/", $strAddPath);
480 $strRemovePath = str_replace("\\", "/", $strRemovePath);
481
482 if (!$this->_dFile)
483 {
484 $this->_arErrors[] = ["ERR_DFILE", GetMessage("MAIN_ARCHIVE_ERR_DFILE")];
485 return false;
486 }
487
488 if ($strFilename == '')
489 {
490 return false;
491 }
492
493 if (!file_exists($this->io->GetPhysicalName($strFilename)))
494 {
495 $this->_arErrors[] = ["NO_FILE", "File '" . $strFilename . "' does not exist"];
496 return false;
497 }
498
499 if (!$this->_addFile($strFilename, $strAddPath, $strRemovePath))
500 {
501 return false;
502 }
503
504 return true;
505 }
506
513 public function addString($strFilename, $strFileContent)
514 {
515 $this->_arErrors = [];
516
517 if (!file_exists($this->io->GetPhysicalName($this->_strArchiveName))
518 || !is_file($this->io->GetPhysicalName($this->_strArchiveName)))
519 {
520 if (!$this->_openWrite())
521 {
522 return false;
523 }
524 $this->_close();
525 }
526
527 if (!$this->_openAppend())
528 {
529 return false;
530 }
531
532 $res = $this->_addString($strFilename, $strFileContent);
533
534 $this->_writeFooter();
535 $this->_close();
536 return $res;
537 }
538
545 public function extractFiles($strPath, $vFileList = false)
546 {
547 $this->_arErrors = [];
548
549 $v_list_detail = [];
550
551 $strExtrType = "complete";
552 $arFileList = 0;
553 if ($vFileList !== false)
554 {
555 $arFileList = $this->_parseFileParams($vFileList);
556 $strExtrType = "partial";
557 }
558
559 if ($v_result = $this->_openRead())
560 {
561 $v_result = $this->_extractList($strPath, $v_list_detail, $strExtrType, $arFileList, '');
562 $this->_close();
563 }
564
565 return $v_result;
566 }
567
572 public function extractContent()
573 {
574 $this->_arErrors = [];
575
576 $arRes = [];
577
578 if ($this->_openRead())
579 {
580 if (!$this->_extractList('', $arRes, "list", '', ''))
581 {
582 $arRes = false;
583 }
584 $this->_close();
585 }
586
587 return $arRes;
588 }
589
594 public function GetErrors()
595 {
596 return $this->_arErrors;
597 }
598
599 private function _addFileList($arFileList, $strAddPath, $strRemovePath)
600 {
601 $v_result = true;
602 $strAddPath = str_replace("\\", "/", $strAddPath);
603 $strRemovePath = str_replace("\\", "/", $strRemovePath);
604
605 if (!$this->_dFile)
606 {
607 $this->_arErrors[] = ["ERR_DFILE", GetMessage("MAIN_ARCHIVE_ERR_DFILE")];
608 return false;
609 }
610
611 if (!is_array($arFileList) || empty($arFileList))
612 {
613 return true;
614 }
615
616 $fileListCount = count($arFileList);
617 for ($j = 0; ($j < $fileListCount) && ($v_result); $j++)
618 {
619 $strFilename = $arFileList[$j];
620
621 if ($strFilename == $this->_strArchiveName)
622 {
623 continue;
624 }
625
626 if ($strFilename == '')
627 {
628 continue;
629 }
630
631 if (!file_exists($this->io->GetPhysicalName($strFilename)))
632 {
633 $this->_arErrors[] = ["NO_FILE", "File '" . $strFilename . "' does not exist"];
634 continue;
635 }
636
637 if (!$this->_addFile($strFilename, $strAddPath, $strRemovePath))
638 {
639 return false;
640 }
641
642 if (@is_dir($this->io->GetPhysicalName($strFilename)))
643 {
644 if (!($handle = opendir($this->io->GetPhysicalName($strFilename))))
645 {
646 $this->_arErrors[] = ["NO_READ", str_replace("#DIR_NAME#", $strFilename, GetMessage("MAIN_ARCHIVE_ERR_DFILE"))];
647 continue;
648 }
649
650 while (false !== ($dir = readdir($handle)))
651 {
652 if ($dir != "." && $dir != "..")
653 {
654 $arFileList_tmp = [];
655 if ($strFilename != ".")
656 {
657 $arFileList_tmp[] = $strFilename . '/' . $dir;
658 }
659 else
660 {
661 $arFileList_tmp[] = $dir;
662 }
663
664 $v_result = $this->_addFileList($arFileList_tmp, $strAddPath, $strRemovePath);
665 }
666 }
667
668 unset($arFileList_tmp);
669 unset($dir);
670 unset($handle);
671 }
672 }
673
674 return $v_result;
675 }
676
677 private function _addFile($strFilename, $strAddPath, $strRemovePath)
678 {
679 if (!$this->_dFile)
680 {
681 $this->_arErrors[] = ["ERR_DFILE", GetMessage("MAIN_ARCHIVE_ERR_DFILE")];
682 return false;
683 }
684
685 if ($strFilename == '')
686 {
687 $this->_arErrors[] = ["NO_FILENAME", GetMessage("MAIN_ARCHIVE_NO_FILENAME")];
688 return false;
689 }
690
691 $strFilename = str_replace("\\", "/", $strFilename);
692 $strFilename_stored = $strFilename;
693
694 if (strcmp($strFilename, $strRemovePath) == 0)
695 {
696 return true;
697 }
698
699 if ($strRemovePath <> '')
700 {
701 if (!str_ends_with($strRemovePath, '/'))
702 {
703 $strRemovePath .= '/';
704 }
705
706 if (str_starts_with($strFilename, $strRemovePath))
707 {
708 $strFilename_stored = substr($strFilename, strlen($strRemovePath));
709 }
710 }
711
712 if ($strAddPath <> '')
713 {
714 if (str_ends_with($strAddPath, '/'))
715 {
716 $strFilename_stored = $strAddPath . $strFilename_stored;
717 }
718 else
719 {
720 $strFilename_stored = $strAddPath . '/' . $strFilename_stored;
721 }
722 }
723
724 $strFilename_stored = $this->_normalizePath($strFilename_stored);
725
726 if (is_file($strFilename))
727 {
728 if (($dfile = @fopen($strFilename, "rb")) == 0)
729 {
730 $this->_arErrors[] = ["ERR_OPEN", str_replace("#FILE_NAME#", removeDocRoot($strFilename), GetMessage("MAIN_ARCHIVE_ERR_OPEN"))];
731 return true;
732 }
733
734 $istime = ((microtime(true) - $this->start_time) < round($this->max_exec_time)) || !$this->stepped;
735
736 if ($istime)
737 {
738 if (($this->file_pos == 0))
739 {
740 if (!$this->_writeHeader($strFilename, $strFilename_stored))
741 {
742 return false;
743 }
744 }
745
746 if (($this->file_pos > 0) && $this->stepped)
747 {
748 if ($this->_bCompress)
749 {
750 @gzseek($dfile, $this->file_pos);
751 }
752 else
753 {
754 @fseek($dfile, $this->file_pos);
755 }
756 }
757
758 while ($istime && ($v_buffer = fread($dfile, 512)) != '')
759 {
760 $v_binary_data = pack("a512", "$v_buffer");
761 $this->_writeBlock($v_binary_data);
762 $istime = ((microtime(true) - $this->start_time) < round($this->max_exec_time)) || !$this->stepped;
763 }
764 }
765
766 if ($istime && $this->stepped)
767 {
768 $this->file_pos = 0;
769 }
770 elseif ($this->stepped)
771 {
772 if ($this->_bCompress)
773 {
774 $this->file_pos = @gztell($dfile);
775 }
776 else
777 {
778 $this->file_pos = @ftell($dfile);
779 }
780 }
781
782 fclose($dfile);
783 }
784 elseif (!$this->_writeHeader($strFilename, $strFilename_stored))
785 {
786 return false;
787 }
788
789 return true;
790 }
791
795 public function getFilePos()
796 {
797 return $this->file_pos;
798 }
799
800 private function _addString($strFilename, $strFileContent)
801 {
802 if (!$this->_dFile)
803 {
804 $this->_arErrors[] = ["ERR_DFILE", GetMessage("MAIN_ARCHIVE_ERR_DFILE")];
805 return false;
806 }
807
808 if ($strFilename == '')
809 {
810 $this->_arErrors[] = ["NO_FILENAME", GetMessage("MAIN_ARCHIVE_NO_FILENAME")];
811 return false;
812 }
813
814 $strFilename = str_replace("\\", "/", $strFilename);
815
816 if (!$this->_writeHeaderBlock($strFilename, strlen($strFileContent)))
817 {
818 return false;
819 }
820
821 $i = 0;
822 while (($v_buffer = substr($strFileContent, (($i++) * 512), 512)) != '')
823 {
824 $v_binary_data = pack("a512", $v_buffer);
825 $this->_writeBlock($v_binary_data);
826 }
827
828 return true;
829 }
830
831 private function _extractList($p_path, &$p_list_detail, $p_mode, $p_file_list, $p_remove_path)
832 {
833 $v_nb = 0;
834 $v_extract_all = true;
835 $v_listing = false;
836
837 $p_path = str_replace("\\", "/", $p_path);
838 $p_path = $this->io->GetPhysicalName($p_path);
839
840 if ($p_path == ''
841 || (!str_starts_with($p_path, '/')
842 && !str_starts_with($p_path, "../")
843 && !mb_strpos($p_path, ':')))
844 {
845 $p_path = "./" . $p_path;
846 }
847
848 $p_remove_path = str_replace("\\", "/", $p_remove_path);
849 if (($p_remove_path != '') && (!str_ends_with($p_remove_path, '/')))
850 {
851 $p_remove_path .= '/';
852 }
853
854 switch ($p_mode)
855 {
856 case "complete" :
857 break;
858 case "partial" :
859 $v_extract_all = false;
860 break;
861 case "list" :
862 $v_extract_all = false;
863 $v_listing = true;
864 break;
865 default :
866 $this->_arErrors[] = ["ERR_PARAM", str_replace("#EXTRACT_MODE#", $p_mode, GetMessage("MAIN_ARCHIVE_ERR_PARAM"))];
867 return false;
868 }
869
870 clearstatcache();
871
872 while (strlen($v_binary_data = $this->_readBlock()) != 0)
873 {
874 $v_extract_file = false;
875
876 if (!$this->_readHeader($v_binary_data, $v_header))
877 {
878 return false;
879 }
880
881 if ($v_header['filename'] == '')
882 {
883 continue;
884 }
885
886 // ----- Look for long filename
887 if ($v_header['typeflag'] == 'L')
888 {
889 if (!$this->_readLongHeader($v_header))
890 {
891 return false;
892 }
893 }
894 if ((!$v_extract_all) && (is_array($p_file_list)))
895 {
896 // ----- By default no unzip if the file is not found
897 $l = count($p_file_list);
898 for ($i = 0; $i < $l; $i++)
899 {
900 // ----- Look if it is a directory
901 if (str_ends_with($p_file_list[$i], '/'))
902 {
903 // ----- Look if the directory is in the filename path
904 if ((mb_strlen($v_header['filename']) > mb_strlen($p_file_list[$i]))
905 && (str_starts_with($v_header['filename'], $p_file_list[$i])))
906 {
907 $v_extract_file = true;
908 break;
909 }
910 }
911 elseif ($p_file_list[$i] == $v_header['filename'])
912 {
913 // ----- It is a file, so compare the file names
914 $v_extract_file = true;
915 break;
916 }
917 }
918 }
919 else
920 {
921 $v_extract_file = true;
922 }
923
924 // ----- Look if this file need to be extracted
925 if (($v_extract_file) && (!$v_listing))
926 {
927 if (($p_remove_path != '')
928 && (str_starts_with($v_header['filename'], $p_remove_path)))
929 {
930 $v_header['filename'] = substr($v_header['filename'], strlen($p_remove_path));
931 }
932 if (($p_path != './') && ($p_path != '/'))
933 {
934 while (str_ends_with($p_path, '/'))
935 {
936 $p_path = substr($p_path, 0, -1);
937 }
938
939 if (str_starts_with($v_header['filename'], '/'))
940 {
941 $v_header['filename'] = $p_path . $v_header['filename'];
942 }
943 else
944 {
945 $v_header['filename'] = $p_path . '/' . $v_header['filename'];
946 }
947 }
948 if (file_exists($v_header['filename']))
949 {
950 if ((@is_dir($v_header['filename'])) && ($v_header['typeflag'] == ''))
951 {
952 $this->_arErrors[] = ["DIR_EXISTS", str_replace("#FILE_NAME#", removeDocRoot($this->io->GetLogicalName($v_header['filename'])), GetMessage("MAIN_ARCHIVE_DIR_EXISTS"))];
953 return false;
954 }
955
956 if ((is_file($v_header['filename'])) && ($v_header['typeflag'] == "5"))
957 {
958 $this->_arErrors[] = ["FILE_EXISTS", str_replace("#FILE_NAME#", removeDocRoot($this->io->GetLogicalName($v_header['filename'])), GetMessage("MAIN_ARCHIVE_FILE_EXISTS"))];
959 return false;
960 }
961 if (!is_writeable($v_header['filename']))
962 {
963 $this->_arErrors[] = ["FILE_PERMS", str_replace("#FILE_NAME#", removeDocRoot($this->io->GetLogicalName($v_header['filename'])), GetMessage("MAIN_ARCHIVE_FILE_PERMS"))];
964 return false;
965 }
966 }
967 elseif (($this->_dirCheck(($v_header['typeflag'] == "5" ? $v_header['filename'] : dirname($v_header['filename'])))) != 1)
968 {
969 $this->_arErrors[] = ["NO_DIR", str_replace("#FILE_NAME#", removeDocRoot($this->io->GetLogicalName($v_header['filename'])), GetMessage("MAIN_ARCHIVE_NO_DIR"))];
970 return false;
971 }
972
973 if ($this->checkPermissions && !CBXArchive::IsFileSafe($v_header['filename']))
974 {
975 $this->_jumpBlock(ceil(($v_header['size'] / 512)));
976 }
977 //should we overwrite existent files?
978 elseif ((file_exists($v_header['filename']) && $this->replaceExistentFiles) || !(file_exists($v_header['filename'])))
979 {
980 if ($v_header['typeflag'] == "5")
981 {
982 if (!@file_exists($v_header['filename']))
983 {
984 if (!@mkdir($v_header['filename'], BX_DIR_PERMISSIONS))
985 {
986 $this->_arErrors[] = ["ERR_CREATE_DIR", str_replace("#DIR_NAME#", removeDocRoot($this->io->GetLogicalName($v_header['filename'])), GetMessage("MAIN_ARCHIVE_ERR_CREATE_DIR"))];
987 return false;
988 }
989 }
990 }
991 else
992 {
993 if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0)
994 {
995 $this->_arErrors[] = ["ERR_CREATE_FILE", str_replace("#FILE_NAME#", removeDocRoot($this->io->GetLogicalName($v_header['filename'])), GetMessage("MAIN_ARCHIVE_ERR_CREATE_FILE"))];
996 return false;
997 }
998 else
999 {
1000 $n = floor($v_header['size'] / 512);
1001 for ($i = 0; $i < $n; $i++)
1002 {
1003 $v_content = $this->_readBlock();
1004 fwrite($v_dest_file, $v_content, 512);
1005 }
1006 if (($v_header['size'] % 512) != 0)
1007 {
1008 $v_content = $this->_readBlock();
1009 fwrite($v_dest_file, $v_content, ($v_header['size'] % 512));
1010 }
1011
1012 @fclose($v_dest_file);
1013
1014 @chmod($v_header['filename'], BX_FILE_PERMISSIONS);
1015 @touch($v_header['filename'], $v_header['mtime']);
1016 }
1017
1018 clearstatcache();
1019 if (filesize($v_header['filename']) != $v_header['size'])
1020 {
1021 $this->_arErrors[] = ["ERR_SIZE_CHECK", str_replace(["#FILE_NAME#", "#SIZE#", "#EXP_SIZE#"], [removeDocRoot($v_header['size']), filesize($v_header['filename']), $v_header['size']], GetMessage("MAIN_ARCHIVE_ERR_SIZE_CHECK"))];
1022 return false;
1023 }
1024 }
1025 }
1026 else
1027 {
1028 $this->_jumpBlock(ceil(($v_header['size'] / 512)));
1029 }
1030 }
1031 else
1032 {
1033 $this->_jumpBlock(ceil(($v_header['size'] / 512)));
1034 }
1035
1036 if ($v_listing || $v_extract_file)
1037 {
1038 if (($v_file_dir = dirname($v_header['filename'])) == $v_header['filename'])
1039 {
1040 $v_file_dir = '';
1041 }
1042 if ((str_starts_with($v_header['filename'], '/')) && ($v_file_dir == ''))
1043 {
1044 $v_file_dir = '/';
1045 }
1046
1047 $p_list_detail[$v_nb++] = $v_header;
1048 }
1049 }
1050
1051 return true;
1052 }
1053
1054 private function _writeHeader($strFilename, $strFilename_stored)
1055 {
1056 if ($strFilename_stored == '')
1057 {
1058 $strFilename_stored = $strFilename;
1059 }
1060
1061 $strFilename_ready = $this->_normalizePath($strFilename_stored);
1062
1063 if (strlen($strFilename_ready) > 99)
1064 {
1065 if (!$this->_writeLongHeader($strFilename_ready))
1066 {
1067 return false;
1068 }
1069 }
1070
1071 $v_info = stat($strFilename);
1072 $v_uid = sprintf("%6s ", DecOct($v_info['uid']));
1073 $v_gid = sprintf("%6s ", DecOct($v_info['gid']));
1074 $v_perms = sprintf("%6s ", DecOct(fileperms($strFilename)));
1075 $v_mtime = sprintf("%11s", DecOct(filemtime($strFilename)));
1076
1077 if (@is_dir($strFilename))
1078 {
1079 $v_typeflag = "5";
1080 $v_size = sprintf("%11s ", DecOct(0));
1081 }
1082 else
1083 {
1084 $v_typeflag = '';
1085 clearstatcache();
1086 $v_size = sprintf("%11s ", DecOct(filesize($strFilename)));
1087 }
1088
1089 $v_linkname = '';
1090 $v_magic = '';
1091 $v_version = '';
1092 $v_uname = '';
1093 $v_gname = '';
1094 $v_devmajor = '';
1095 $v_devminor = '';
1096 $v_prefix = '';
1097
1098 $v_binary_data_first = pack("a100a8a8a8a12A12", $strFilename_ready, $v_perms, $v_uid, $v_gid, $v_size, $v_mtime);
1099 $v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12", $v_typeflag, $v_linkname, $v_magic, $v_version, $v_uname, $v_gname, $v_devmajor, $v_devminor, $v_prefix, '');
1100
1101 $v_checksum = 0;
1102 for ($i = 0; $i < 148; $i++)
1103 {
1104 $v_checksum += ord(substr($v_binary_data_first, $i, 1));
1105 }
1106 for ($i = 148; $i < 156; $i++)
1107 {
1108 $v_checksum += ord(' ');
1109 }
1110 for ($i = 156, $j = 0; $i < 512; $i++, $j++)
1111 {
1112 $v_checksum += ord(substr($v_binary_data_last, $j, 1));
1113 }
1114
1115 $this->_writeBlock($v_binary_data_first, 148);
1116
1117 $v_checksum = sprintf("%6s ", DecOct($v_checksum));
1118 $v_binary_data = pack("a8", $v_checksum);
1119 $this->_writeBlock($v_binary_data, 8);
1120
1121 $this->_writeBlock($v_binary_data_last, 356);
1122
1123 return true;
1124 }
1125
1126 private function _writeLongHeader($strFilename)
1127 {
1128 $v_size = sprintf("%11s ", DecOct(mb_strlen($strFilename)));
1129 $v_typeflag = 'L';
1130 $v_linkname = '';
1131 $v_magic = '';
1132 $v_version = '';
1133 $v_uname = '';
1134 $v_gname = '';
1135 $v_devmajor = '';
1136 $v_devminor = '';
1137 $v_prefix = '';
1138 $v_binary_data_first = pack("a100a8a8a8a12A12", '././@LongLink', 0, 0, 0, $v_size, 0);
1139 $v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12", $v_typeflag, $v_linkname, $v_magic, $v_version, $v_uname, $v_gname, $v_devmajor, $v_devminor, $v_prefix, '');
1140
1141 $v_checksum = 0;
1142 for ($i = 0; $i < 148; $i++)
1143 {
1144 $v_checksum += ord(substr($v_binary_data_first, $i, 1));
1145 }
1146
1147 for ($i = 148; $i < 156; $i++)
1148 {
1149 $v_checksum += ord(' ');
1150 }
1151
1152 for ($i = 156, $j = 0; $i < 512; $i++, $j++)
1153 {
1154 $v_checksum += ord(substr($v_binary_data_last, $j, 1));
1155 }
1156
1157 $this->_writeBlock($v_binary_data_first, 148);
1158
1159 $v_checksum = sprintf("%6s ", DecOct($v_checksum));
1160 $v_binary_data = pack("a8", $v_checksum);
1161 $this->_writeBlock($v_binary_data, 8);
1162
1163 $this->_writeBlock($v_binary_data_last, 356);
1164
1165 $p_filename = $this->_normalizePath($strFilename);
1166
1167 $i = 0;
1168 while (($v_buffer = substr($p_filename, (($i++) * 512), 512)) != '')
1169 {
1170 $v_binary_data = pack("a512", "$v_buffer");
1171 $this->_writeBlock($v_binary_data);
1172 }
1173 return true;
1174 }
1175
1176 private function _writeHeaderBlock($strFilename, $iSize, $p_mtime = 0, $p_perms = 0, $p_type = '', $p_uid = 0, $p_gid = 0)
1177 {
1178 $strFilename = $this->_normalizePath($strFilename);
1179
1180 if (mb_strlen($strFilename) > 99)
1181 {
1182 if (!$this->_writeLongHeader($strFilename))
1183 {
1184 return false;
1185 }
1186 }
1187
1188 if ($p_type == "5")
1189 {
1190 $v_size = sprintf("%11s ", DecOct(0));
1191 }
1192 else
1193 {
1194 $v_size = sprintf("%11s ", DecOct($iSize));
1195 }
1196
1197 $v_uid = sprintf("%6s ", DecOct($p_uid));
1198 $v_gid = sprintf("%6s ", DecOct($p_gid));
1199 $v_perms = sprintf("%6s ", DecOct($p_perms));
1200 $v_mtime = sprintf("%11s", DecOct($p_mtime));
1201 $v_linkname = '';
1202 $v_magic = '';
1203 $v_version = '';
1204 $v_uname = '';
1205 $v_gname = '';
1206 $v_devmajor = '';
1207 $v_devminor = '';
1208 $v_prefix = '';
1209
1210 $v_binary_data_first = pack("a100a8a8a8a12A12", $strFilename, $v_perms, $v_uid, $v_gid, $v_size, $v_mtime);
1211 $v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12", $p_type, $v_linkname, $v_magic, $v_version, $v_uname, $v_gname, $v_devmajor, $v_devminor, $v_prefix, '');
1212
1213 $v_checksum = 0;
1214 for ($i = 0; $i < 148; $i++)
1215 {
1216 $v_checksum += ord(substr($v_binary_data_first, $i, 1));
1217 }
1218 for ($i = 148; $i < 156; $i++)
1219 {
1220 $v_checksum += ord(' ');
1221 }
1222 for ($i = 156, $j = 0; $i < 512; $i++, $j++)
1223 {
1224 $v_checksum += ord(substr($v_binary_data_last, $j, 1));
1225 }
1226
1227 $this->_writeBlock($v_binary_data_first, 148);
1228
1229 $v_checksum = sprintf("%6s ", DecOct($v_checksum));
1230 $v_binary_data = pack("a8", $v_checksum);
1231 $this->_writeBlock($v_binary_data, 8);
1232
1233 $this->_writeBlock($v_binary_data_last, 356);
1234
1235 return true;
1236 }
1237
1238 private function _readBlock()
1239 {
1240 $v_block = "";
1241 if (is_resource($this->_dFile))
1242 {
1243 if ($this->_bCompress)
1244 {
1245 $v_block = @gzread($this->_dFile, 512);
1246 }
1247 else
1248 {
1249 $v_block = @fread($this->_dFile, 512);
1250 }
1251 }
1252 return $v_block;
1253 }
1254
1255 private function _readHeader($v_binary_data, &$v_header)
1256 {
1257 if (strlen($v_binary_data) == 0)
1258 {
1259 $v_header['filename'] = '';
1260 return true;
1261 }
1262
1263 if (strlen($v_binary_data) != 512)
1264 {
1265 $v_header['filename'] = '';
1266 $this->_arErrors[] = ["INV_BLOCK_SIZE", str_replace("#BLOCK_SIZE#", strlen($v_binary_data), GetMessage("MAIN_ARCHIVE_INV_BLOCK_SIZE"))];
1267 return false;
1268 }
1269
1270 $v_checksum = 0;
1271 for ($i = 0; $i < 148; $i++)
1272 {
1273 $v_checksum += ord(substr($v_binary_data, $i, 1));
1274 }
1275 for ($i = 148; $i < 156; $i++)
1276 {
1277 $v_checksum += ord(' ');
1278 }
1279 for ($i = 156; $i < 512; $i++)
1280 {
1281 $v_checksum += ord(substr($v_binary_data, $i, 1));
1282 }
1283
1284 //changed
1285 $v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a131prefix", $v_binary_data);
1286
1287 $v_header['checksum'] = octdec(trim($v_data['checksum']));
1288 if ($v_header['checksum'] != $v_checksum)
1289 {
1290 $v_header['filename'] = '';
1291
1292 if (($v_checksum == 256) && ($v_header['checksum'] == 0))
1293 {
1294 return true;
1295 }
1296
1297 $this->_arErrors[] = ["INV_BLOCK_CHECK", GetMessage("MAIN_ARCHIVE_INV_BLOCK_CHECK1")];
1298 return false;
1299 }
1300
1301 // ----- Extract the properties
1302 $v_header['filename'] = trim($v_data['prefix'] . "/" . $v_data['filename']);
1303 $v_header['mode'] = octdec(trim($v_data['mode']));
1304 $v_header['uid'] = octdec(trim($v_data['uid']));
1305 $v_header['gid'] = octdec(trim($v_data['gid']));
1306 $v_header['size'] = octdec(trim($v_data['size']));
1307 $v_header['mtime'] = octdec(trim($v_data['mtime']));
1308 if (($v_header['typeflag'] = $v_data['typeflag']) == "5")
1309 {
1310 $v_header['size'] = 0;
1311 }
1312
1313 $v_header['filename'] = \Bitrix\Main\IO\Path::normalize($v_header['filename']);
1314
1315 return true;
1316 }
1317
1318 private function _readLongHeader(&$v_header)
1319 {
1320 $v_filename = '';
1321
1322 $n = floor($v_header['size'] / 512);
1323 for ($i = 0; $i < $n; $i++)
1324 {
1325 $v_content = $this->_readBlock();
1326 $v_filename .= $v_content;
1327 }
1328
1329 if (($v_header['size'] % 512) != 0)
1330 {
1331 $v_content = $this->_readBlock();
1332 $v_filename .= trim($v_content);
1333 }
1334
1335 $v_binary_data = $this->_readBlock();
1336
1337 if (!$this->_readHeader($v_binary_data, $v_header))
1338 {
1339 return false;
1340 }
1341
1342 $v_header['filename'] = \Bitrix\Main\IO\Path::normalize($v_filename);
1343
1344 return true;
1345 }
1346
1347 private function _jumpBlock($p_len = false)
1348 {
1349 if (is_resource($this->_dFile))
1350 {
1351 if ($p_len === false)
1352 {
1353 $p_len = 1;
1354 }
1355
1356 if ($this->_bCompress)
1357 {
1358 @gzseek($this->_dFile, @gztell($this->_dFile) + ($p_len * 512));
1359 }
1360 else
1361 {
1362 @fseek($this->_dFile, @ftell($this->_dFile) + ($p_len * 512));
1363 }
1364 }
1365 }
1366
1367 private function _parseFileParams($vFileList)
1368 {
1369 if (isset($vFileList) && is_array($vFileList))
1370 {
1371 return $vFileList;
1372 }
1373
1374 if (isset($vFileList) && $vFileList <> '')
1375 {
1376 if (str_starts_with($vFileList, "\""))
1377 {
1378 return [trim($vFileList,"\"")];
1379 }
1380 return explode($this->_strSeparator, $vFileList);
1381 }
1382
1383 return [];
1384 }
1385
1386 private function _openWrite()
1387 {
1388 $this->_checkDirPath($this->_strArchiveName);
1389
1390 if ($this->_bCompress)
1391 {
1392 $this->_dFile = @gzopen($this->io->GetPhysicalName($this->_strArchiveName), "wb9f");
1393 }
1394 else
1395 {
1396 $this->_dFile = @fopen($this->io->GetPhysicalName($this->_strArchiveName), "wb");
1397 }
1398
1399 if (!($this->_dFile))
1400 {
1401 $this->_arErrors[] = ["ERR_OPEN_WRITE", str_replace("#FILE_NAME#", removeDocRoot($this->_strArchiveName), GetMessage("MAIN_ARCHIVE_ERR_OPEN_WRITE"))];
1402 return false;
1403 }
1404 return true;
1405 }
1406
1407 private function _openAppendFast()
1408 {
1409 $this->_checkDirPath($this->_strArchiveName);
1410
1411 if ($this->_bCompress)
1412 {
1413 $this->_dFile = @gzopen($this->io->GetPhysicalName($this->_strArchiveName), "ab9f");
1414 }
1415 else
1416 {
1417 $this->_dFile = @fopen($this->io->GetPhysicalName($this->_strArchiveName), "ab");
1418 }
1419 if (!($this->_dFile))
1420 {
1421 $this->_arErrors[] = ["ERR_OPEN_WRITE", str_replace("#FILE_NAME#", removeDocRoot($this->_strArchiveName), GetMessage("MAIN_ARCHIVE_ERR_OPEN_WRITE"))];
1422 return false;
1423 }
1424 return true;
1425 }
1426
1427 private function _openAppend()
1428 {
1429 if (filesize($this->io->GetPhysicalName($this->_strArchiveName)) == 0)
1430 {
1431 return $this->_openWrite();
1432 }
1433
1434 $this->_checkDirPath($this->_strArchiveName);
1435
1436 if ($this->_bCompress)
1437 {
1438 $this->_close();
1439
1440 if (!@rename($this->io->GetPhysicalName($this->_strArchiveName), $this->io->GetPhysicalName($this->_strArchiveName . ".tmp")))
1441 {
1442 $this->_arErrors[] = ["ERR_RENAME", str_replace(["#FILE_NAME#", "#FILE_NAME2#"], [removeDocRoot($this->_strArchiveName), removeDocRoot($this->_strArchiveName . ".tmp")], GetMessage("MAIN_ARCHIVE_ERR_RENAME"))];
1443 return false;
1444 }
1445
1446 $dTarArch_tmp = @gzopen($this->io->GetPhysicalName($this->_strArchiveName . ".tmp"), "rb");
1447 if (!$dTarArch_tmp)
1448 {
1449 $this->_arErrors[] = ["ERR_OPEN", str_replace("#FILE_NAME#", removeDocRoot($this->_strArchiveName . ".tmp"), GetMessage("MAIN_ARCHIVE_ERR_OPEN"))];
1450 @rename($this->io->GetPhysicalName($this->_strArchiveName . ".tmp"), $this->io->GetPhysicalName($this->_strArchiveName));
1451 return false;
1452 }
1453
1454 if (!$this->_openWrite())
1455 {
1456 @rename($this->io->GetPhysicalName($this->_strArchiveName . ".tmp"), $this->io->GetPhysicalName($this->_strArchiveName));
1457 return false;
1458 }
1459
1460 $v_buffer = @gzread($dTarArch_tmp, 512);
1461
1462 if (!@gzeof($dTarArch_tmp))
1463 {
1464 do
1465 {
1466 $v_binary_data = pack("a512", $v_buffer);
1467 $this->_writeBlock($v_binary_data);
1468 $v_buffer = @gzread($dTarArch_tmp, 512);
1469 }
1470 while (!@gzeof($dTarArch_tmp));
1471 }
1472
1473 @gzclose($dTarArch_tmp);
1474
1475 @unlink($this->io->GetPhysicalName($this->_strArchiveName . ".tmp"));
1476 }
1477 else
1478 {
1479 if (!$this->_openReadWrite())
1480 {
1481 return false;
1482 }
1483
1484 clearstatcache();
1485 $iSize = filesize($this->io->GetPhysicalName($this->_strArchiveName));
1486 fseek($this->_dFile, $iSize - 512);
1487 }
1488
1489 return true;
1490 }
1491
1492 private function _openReadWrite()
1493 {
1494 if ($this->_bCompress)
1495 {
1496 $this->_dFile = @gzopen($this->io->GetPhysicalName($this->_strArchiveName), "r+b");
1497 }
1498 else
1499 {
1500 $this->_dFile = @fopen($this->io->GetPhysicalName($this->_strArchiveName), "r+b");
1501 }
1502
1503 if (!$this->_dFile)
1504 {
1505 return false;
1506 }
1507
1508 return true;
1509 }
1510
1511 private function _openRead()
1512 {
1513 if ($this->_bCompress)
1514 {
1515 $this->_dFile = @gzopen($this->io->GetPhysicalName($this->_strArchiveName), "rb");
1516 }
1517 else
1518 {
1519 $this->_dFile = @fopen($this->io->GetPhysicalName($this->_strArchiveName), "rb");
1520 }
1521
1522 if (!$this->_dFile)
1523 {
1524 $this->_arErrors[] = ["ERR_OPEN", str_replace("#FILE_NAME#", removeDocRoot($this->_strArchiveName), GetMessage("MAIN_ARCHIVE_ERR_OPEN"))];
1525
1526 return false;
1527 }
1528
1529 return true;
1530 }
1531
1532 private function _writeBlock($v_binary_data, $iLen = false)
1533 {
1534 if (is_resource($this->_dFile))
1535 {
1536 if ($iLen === false)
1537 {
1538 if ($this->_bCompress)
1539 {
1540 @gzputs($this->_dFile, $v_binary_data);
1541 }
1542 else
1543 {
1544 @fputs($this->_dFile, $v_binary_data);
1545 }
1546 }
1547 else
1548 {
1549 if ($this->_bCompress)
1550 {
1551 @gzputs($this->_dFile, $v_binary_data, $iLen);
1552 }
1553 else
1554 {
1555 @fputs($this->_dFile, $v_binary_data, $iLen);
1556 }
1557 }
1558 }
1559 }
1560
1561 private function _writeFooter()
1562 {
1563 if (is_resource($this->_dFile))
1564 {
1565 $v_binary_data = pack("a512", '');
1566 $this->_writeBlock($v_binary_data);
1567 }
1568 }
1569
1570 private function _cleanFile()
1571 {
1572 $this->_close();
1573 @unlink($this->io->GetPhysicalName($this->_strArchiveName));
1574 }
1575
1576 private function _close()
1577 {
1578 if (is_resource($this->_dFile))
1579 {
1580 if ($this->_bCompress)
1581 {
1582 @gzclose($this->_dFile);
1583 }
1584 else
1585 {
1586 @fclose($this->_dFile);
1587 }
1588
1589 $this->_dFile = 0;
1590 }
1591 }
1592
1593 private function _normalizePath($strPath)
1594 {
1595 $strResult = "";
1596 if ($strPath <> '')
1597 {
1598 $strPath = str_replace("\\", "/", $strPath);
1599
1600 while (str_contains($strPath, ".../"))
1601 {
1602 $strPath = str_replace(".../", "../", $strPath);
1603 }
1604
1605 $arPath = explode('/', $strPath);
1606 $nPath = count($arPath);
1607 for ($i = $nPath - 1; $i >= 0; $i--)
1608 {
1609 if ($arPath[$i] == ".")
1610 {
1611 ;
1612 }
1613 elseif ($arPath[$i] == "..")
1614 {
1615 $i--;
1616 }
1617 elseif (($arPath[$i] == '') && ($i != ($nPath - 1)) && ($i != 0))
1618 {
1619 ;
1620 }
1621 else
1622 {
1623 $strResult = $arPath[$i] . ($i != ($nPath - 1) ? '/' . $strResult : '');
1624 }
1625 }
1626 }
1627 return $strResult;
1628 }
1629
1630 private function _checkDirPath($path)
1631 {
1632 $path = str_replace(["\\", "//"], "/", $path);
1633
1634 //remove file name
1635 if (!str_ends_with($path, "/"))
1636 {
1637 $p = mb_strrpos($path, "/");
1638 $path = mb_substr($path, 0, $p);
1639 }
1640
1641 $path = rtrim($path, "/");
1642
1643 if (!file_exists($this->io->GetPhysicalName($path)))
1644 {
1645 return mkdir($this->io->GetPhysicalName($path), BX_DIR_PERMISSIONS, true);
1646 }
1647 else
1648 {
1649 return is_dir($this->io->GetPhysicalName($path));
1650 }
1651 }
1652
1653 private function _dirCheck($p_dir)
1654 {
1655 if ((@is_dir($p_dir)) || ($p_dir == ''))
1656 {
1657 return true;
1658 }
1659
1660 $p_parent_dir = dirname($p_dir);
1661
1662 if (($p_parent_dir != $p_dir) &&
1663 ($p_parent_dir != '') &&
1664 (!$this->_dirCheck($p_parent_dir)))
1665 {
1666 return false;
1667 }
1668
1669 if (!@mkdir($p_dir, BX_DIR_PERMISSIONS))
1670 {
1671 $this->_arErrors[] = ["CANT_CREATE_PATH", str_replace("#DIR_NAME#", $p_dir, GetMessage("MAIN_ARCHIVE_CANT_CREATE_PATH"))];;
1672 return false;
1673 }
1674
1675 return true;
1676 }
1677}
$path
Определения access_edit.php:21
Определения tar_gz.php:13
getFilePos()
Определения tar_gz.php:795
$_arErrors
Определения tar_gz.php:18
SetOptions($arOptions)
Определения tar_gz.php:337
extractContent()
Определения tar_gz.php:572
GetOptions()
Определения tar_gz.php:397
$file_pos
Определения tar_gz.php:21
GetStartFile()
Определения tar_gz.php:186
extractFiles($strPath, $vFileList=false)
Определения tar_gz.php:545
Add($vFileList, $strAddPath=false, $strRemovePath=false)
Определения tar_gz.php:422
$stepped
Определения tar_gz.php:22
Unpack($strPath)
Определения tar_gz.php:163
$_bCompress
Определения tar_gz.php:15
GetErrors()
Определения tar_gz.php:594
$start_time
Определения tar_gz.php:19
__construct($strArchiveName, $bCompress=false, $start_time=-1, $max_exec_time=-1, $pos=0, $stepped=false)
Определения tar_gz.php:34
addFile($strFilename, $strAddPath, $strRemovePath)
Определения tar_gz.php:477
$max_exec_time
Определения tar_gz.php:20
$_strArchiveName
Определения tar_gz.php:14
$_strSeparator
Определения tar_gz.php:16
Pack($arFileList, $startFile="")
Определения tar_gz.php:81
addString($strFilename, $strFileContent)
Определения tar_gz.php:513
$_dFile
Определения tar_gz.php:17
static IsFileSafe(string $filename)
Определения archive.php:167
static HasAccess($strFilename, $isFile)
Определения archive.php:141
Определения virtual_io.php:44
static GetInstance()
Определения virtual_io.php:60
$data['IS_AVAILABLE']
Определения .description.php:13
$arPath
Определения file_edit.php:72
$res
Определения filter_act.php:7
$handle
Определения include.php:55
$p
Определения group_list_element_edit.php:23
Определения archive.php:4
const StatusSuccess
Определения archive.php:6
const StatusError
Определения archive.php:5
const StatusContinue
Определения archive.php:7
$l
Определения options.php:783
$arOptions
Определения structure.php:223
const START_EXEC_TIME
Определения start.php:12
removeDocRoot($path)
Определения tools.php:3382
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$dir
Определения quickway.php:303
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$arRes
Определения options.php:104
$n
Определения update_log.php:107