1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
archive.php
См. документацию.
1<?php
2
3interface IBXArchive
4{
5 const StatusError = 0;
6 const StatusSuccess = 1;
7 const StatusContinue = 2;
8
9 public function Pack($arFileList, $startFile = "");
10 public function Unpack($strPath);
11 public function GetErrors();
12 public function GetOptions();
13 public function SetOptions($arOptions);
14 public function GetStartFile();
15}
16
18{
26 public static function GetArchive($strArcName, $strType = "")
27 {
28 //at first trying to detect the archive type
29 if ($strType == "")
30 {
31 $strType = self::DetectTypeByFilename($strArcName);
32
33 if (!$strType)
34 {
35 $strType = "TAR.GZ";
36 }
37 }
38
39 $arFormats = self::GetAvailableFormats();
40
41 foreach ($arFormats as $type => $data)
42 {
43 if ($strType == $type)
44 {
45 $object = new $data["classname"]($strArcName);
46 return $object;
47 }
48 }
49
50 return false;
51 }
52
59 public static function DetectTypeByFilename($filename)
60 {
61 $arFormats = self::GetAvailableFormats();
62 $filename = mb_strtolower($filename);
63
64 foreach ($arFormats as $type => $data)
65 {
66 if (in_array(GetFileExtension($filename), $data["ext"]))
67 {
68 return $type;
69 }
70 }
71 return false;
72 }
73
79 public static function GetAvailableFormats()
80 {
81 $arFormats = [
82 "TAR.GZ" => [
83 "classname" => "CArchiver",
84 "ext" => ["gz", "tgz"],
85 ]
86 ,
87 "ZIP" => [
88 "classname" => "CZip",
89 "ext" => ["zip"],
90 ]
91 ];
92
93 return $arFormats;
94 }
95
101 public static function GetArchiveExtensions()
102 {
103 $arFormats = self::GetAvailableFormats();
104 $arExt = [];
105
106 foreach ($arFormats as $data)
107 {
108 $arExt = array_merge($arExt, $data["ext"]);
109 }
110 return $arExt;
111 }
112
119 public static function IsArchive($strFilename)
120 {
121 $strFileExt = mb_strtolower(GetFileExtension($strFilename));
122 $arFormats = self::GetAvailableFormats();
123
124 foreach ($arFormats as $data)
125 {
126 if (in_array($strFileExt, $data["ext"]))
127 {
128 return true;
129 }
130 }
131 return false;
132 }
133
141 public static function HasAccess($strFilename, $isFile)
142 {
143 $result = false;
144 $path = removeDocRoot($strFilename);
145
146 global $USER;
147
148 if (!$isFile)
149 {
150 if ($USER->CanDoFileOperation("fm_view_listing", [SITE_ID, $path]))
151 {
152 $result = true;
153 }
154 }
155 else
156 {
157 if ($USER->CanDoFileOperation('fm_view_file', [SITE_ID, $path]) &&
158 ($USER->CanDoOperation('edit_php') || $USER->CanDoFileOperation('fm_lpa', [SITE_ID, $path]) ||
159 !(HasScriptExtension($path) || str_starts_with(GetFileName($path), "."))))
160 {
161 $result = true;
162 }
163 }
164 return $result;
165 }
166
167 public static function IsFileSafe(string $filename): bool
168 {
170 $logicalFilename = $io->GetLogicalName($filename);
171
172 return
175 && $io->ValidatePathString($logicalFilename)
176 && $io->ValidateFilenameString(GetFileName($logicalFilename))
177 ;
178 }
179}
$path
Определения access_edit.php:21
$type
Определения options.php:106
Определения archive.php:18
static GetAvailableFormats()
Определения archive.php:79
static IsFileSafe(string $filename)
Определения archive.php:167
static IsArchive($strFilename)
Определения archive.php:119
static HasAccess($strFilename, $isFile)
Определения archive.php:141
static DetectTypeByFilename($filename)
Определения archive.php:59
static GetArchive($strArcName, $strType="")
Определения archive.php:26
static GetArchiveExtensions()
Определения archive.php:101
static GetInstance()
Определения virtual_io.php:60
$data['IS_AVAILABLE']
Определения .description.php:13
$filename
Определения file_edit.php:47
$result
Определения get_property_values.php:14
Определения archive.php:4
SetOptions($arOptions)
const StatusSuccess
Определения archive.php:6
const StatusError
Определения archive.php:5
Unpack($strPath)
const StatusContinue
Определения archive.php:7
Pack($arFileList, $startFile="")
global $USER
Определения csv_new_run.php:40
$io
Определения csv_new_run.php:98
$arOptions
Определения structure.php:223
GetFileExtension($path)
Определения tools.php:2972
IsFileUnsafe($name)
Определения tools.php:3016
removeDocRoot($path)
Определения tools.php:3382
HasScriptExtension($check_name)
Определения tools.php:2956
GetFileName($path)
Определения tools.php:3001
const SITE_ID
Определения sonet_set_content_view.php:12