- Модуль: iblock
- Путь к файлу: ~/bitrix/modules/iblock/classes/general/iblock.php
- Класс: CAllIBlock
- Вызов: CAllIBlock::makeFileArrayFromPath
static function makeFileArrayFromPath($file_path, $description = null, $options = array())
{
/** @global CMain $APPLICATION */
global $APPLICATION;
$result = false;
if (preg_match("/^https?:\/\//", $file_path))
{
$result = CFile::MakeFileArray($file_path);
}
else
{
$io = CBXVirtualIo::GetInstance();
$normPath = $io->CombinePath("/", $file_path);
$absPath = $io->CombinePath($_SERVER["DOCUMENT_ROOT"], $normPath);
if ($io->ValidatePathString($absPath) && $io->FileExists($absPath))
{
$physicalName = $io->GetPhysicalName($absPath);
$uploadDir = $io->GetPhysicalName(preg_replace("#[\\\/]+#", "/", $_SERVER['DOCUMENT_ROOT'].'/'.(COption::GetOptionString('main', 'upload_dir', 'upload')).'/'));
if (mb_strpos($physicalName, $uploadDir) === 0)
{
$result = CFile::MakeFileArray($physicalName);
}
else
{
$perm = $APPLICATION->GetFileAccessPermission($normPath);
if ($perm >= "W")
{
$result = CFile::MakeFileArray($physicalName);
}
}
}
}
if (is_array($result))
{
if (!is_null($description))
$result["description"] = $description;
}
return $result;
}