15 private $arErrors =
array();
19 $systemEncoding = defined(
"BX_FILE_SYSTEM_ENCODING") ? strtolower(BX_FILE_SYSTEM_ENCODING) :
"";
20 if (empty($systemEncoding))
22 if (strtoupper(substr(PHP_OS, 0, 3)) ===
"WIN")
23 $systemEncoding =
"windows-1251";
25 $systemEncoding =
"utf-8";
28 $serverEncoding =
"utf-8";
30 if ($serverEncoding == $systemEncoding)
39 defined(
'BX_IO_Compartible')
41 && (BX_IO_Compartible ===
'Y')
44 $arEventParams =
array(
45 'original' => $string,
48 'systemEncoding' => $systemEncoding,
49 'serverEncoding' => $serverEncoding
52 foreach (
GetModuleEvents(
"main",
"BXVirtualIO_ConvertCharset",
true) as $arEvent)
55 if ($evResult !==
false)
68 $numArgs = func_num_args();
73 for (
$i = 0;
$i < $numArgs;
$i++)
75 $arg = func_get_arg(
$i);
95 foreach ($arParts as $part)
109 if (empty($relativePath))
119 if ((
string)
$site ===
"")
125 $dbSite = CSite::GetByID(
$site);
127 if ($arSite = $dbSite->Fetch())
129 if ((
string)
$site ===
"")
151 if (preg_match(
"#[^\\\\/]+$#",
$path, $match))
161 private function FormatPath(
$path)
167 if(strncasecmp(PHP_OS,
"WIN", 3) == 0)
171 $tailPattern =
"\0.\\/+ ";
177 $tailPattern =
"\0/";
182 if (str_contains(
$res,
"\0"))
183 throw new \Bitrix\Main\IO\InvalidPathException(
$path);
187 $pathStack =
array();
189 for (
$i = 0;
$i < $nPath;
$i++)
193 if ((
$arPath[
$i] ===
'') && (
$i !== ($nPath - 1)) && (
$i !== 0))
197 array_pop($pathStack);
202 $res = implode(
"/", $pathStack);
206 if(str_starts_with(
$path,
"/") && !str_starts_with(
$res,
"/"))
217 if (trim(
$path) ==
'')
222 if (str_contains(
$path,
"\0"))
227 if(preg_match(
"#(".self::invalidBytes.
")#",
$path))
232 if(!mb_check_encoding(
$path))
242 if(mb_strlen(
$path) > 4096)
247 if(!static::ValidateCommon(
$path))
252 return (preg_match(
"#^([a-z]:)?/([^\x01-\x1F".preg_quote(self::invalidChars,
"#").
"]+/?)*$#isD",
$path) > 0);
262 return (preg_match(
"#^[^\x01-\x1F".preg_quote(self::invalidChars,
"#").
"]+$#isD",
$filename) > 0);
267 return preg_replace_callback(
268 "#([\x01-\x1F".preg_quote(self::invalidChars,
"#").
"]|".self::invalidBytes.
")#",
269 'CBXVirtualIoFileSystem::getRandomChar',
276 return chr(rand(97, 122));
304 return $file->Open($mode);
314 if (empty($pathTmp) || $pathTmp ==
'/')
316 $this->
AddError(
"Can not delete the root folder of the project");
324 if (is_file($pathEncoded) || is_link($pathEncoded))
326 if (@unlink($pathEncoded))
332 elseif (is_dir($pathEncoded))
334 if (
$handle = opendir($pathEncoded))
336 while (($file = readdir(
$handle)) !==
false)
338 if ($file ==
"." || $file ==
"..")
342 if (!$this->
Delete($pathDecodedTmp))
347 if (!@rmdir($pathEncoded))
349 $this->
AddError(sprintf(
"Can not delete directory '%s'",
$path));
360 private function CopyDirFiles($pathFrom, $pathTo, $bRewrite =
true, $bDeleteAfterCopy =
false)
364 if (mb_strpos($pathTo.
"/", $pathFrom.
"/") === 0)
366 $this->
AddError(
"Can not copy a file onto itself");
371 if (is_dir($pathFromEncoded))
375 elseif (is_file($pathFromEncoded))
380 if (file_exists($pathToEncoded) && !$bRewrite)
382 $this->
AddError(sprintf(
"The file '%s' already exists", $pathTo));
386 @copy($pathFromEncoded, $pathToEncoded);
387 if (is_file($pathToEncoded))
389 @chmod($pathToEncoded, BX_FILE_PERMISSIONS);
391 if ($bDeleteAfterCopy)
392 @unlink($pathFromEncoded);
396 $this->
AddError(sprintf(
"Creation of file '%s' failed", $pathTo));
408 if (
$handle = @opendir($pathFromEncoded))
410 while (($file = readdir(
$handle)) !==
false)
412 if ($file ==
"." || $file ==
"..")
415 if (is_dir($pathFromEncoded.
"/".$file))
419 CopyDirFiles($pathFromDecodedTmp, $pathToDecodedTmp, $bRewrite, $bDeleteAfterCopy);
420 if ($bDeleteAfterCopy)
421 @rmdir($pathFromEncoded.
"/".$file);
423 elseif (is_file($pathFromEncoded.
"/".$file))
425 if (file_exists($pathToEncoded.
"/".$file) && !$bRewrite)
428 @copy($pathFromEncoded.
"/".$file, $pathToEncoded.
"/".$file);
429 @chmod($pathToEncoded.
"/".$file, BX_FILE_PERMISSIONS);
431 if ($bDeleteAfterCopy)
432 @unlink($pathFromEncoded.
"/".$file);
437 if ($bDeleteAfterCopy)
438 @rmdir($pathFromEncoded);
443 $this->
AddError(sprintf(
"Can not open directory '%s'", $pathFrom));
447 public function Copy($source, $target, $bRewrite =
true)
449 return $this->CopyDirFiles($source, $target, $bRewrite,
false);
452 public function Move($source, $target, $bRewrite =
true)
454 return $this->CopyDirFiles($source, $target, $bRewrite,
true);
461 return rename($sourceEncoded, $targetEncoded);
480 return $this->arErrors;
488 $fs = (empty($errorCode) ?
"%s" :
"[%s] %s");
489 $this->arErrors[] = sprintf($fs,
$error, $errorCode);
494 $this->arErrors =
array();
505 private $arErrors =
array();
509 if (is_null($this->pathEncoded))
517 $lmode = mb_strtolower(mb_substr($mode, 0, 1));
521 ( $bExists && ($lmode !==
'x'))
522 || (!$bExists && ($lmode !==
'r'))
545 $this->
AddError(sprintf(
"Can not create directory '%s' or access denied", $this->
GetPath()));
558 if (fwrite($fd,
$data) ===
false)
620 return $io->FileExists($this->
path);
640 return $this->arErrors;
648 $fs = (empty($errorCode) ?
"%s" :
"[%s] %s");
649 $this->arErrors[] = sprintf($fs,
$error, $errorCode);
654 $this->arErrors =
array();
665 private $arErrors =
array();
669 if (is_null($this->pathEncoded))
687 while (($file = readdir(
$handle)) !==
false)
689 if ($file ==
"." || $file ==
"..")
715 return $io->DirectoryExists($this->
path);
759 while (($file = readdir(
$handle)) !==
false)
761 if ($file !=
"." && $file !=
"..")
780 return $this->arErrors;
788 $fs = (empty($errorCode) ?
"%s" :
"[%s] %s");
789 $this->arErrors[] = sprintf($fs,
$error, $errorCode);
794 $this->arErrors =
array();
static convertEncoding($data, $charsetFrom, $charsetTo)
AddError($error, $errorCode="")
AddError($error, $errorCode="")
RandomizeInvalidFilename($filename)
AddError($error, $errorCode="")
ValidateFilenameString($filename)
static ValidateCommon($path)
Move($source, $target, $bRewrite=true)
SiteRelativeToAbsolutePath($relativePath, $site=null)
RelativeToAbsolutePath($relativePath)
static ConvertCharset($string, $direction=1, $skipEvents=false)
ExtractNameFromPath($path)
ExtractPathFromPath($path)
ValidatePathString($path)
Copy($source, $target, $bRewrite=true)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$_SERVER["DOCUMENT_ROOT"]
ExecuteModuleEventEx($arEvent, $arParams=[])
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
CopyDirFiles($path_from, $path_to, $ReWrite=true, $Recursive=false, $bDeleteAfterCopy=false, $strExclude="")
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
</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."%"
if(!Loader::includeModule('sale')) $pattern