- Модуль: sender
- Путь к файлу: ~/bitrix/modules/sender/lib/internals/postfiles.php
- Класс: Bitrix\Sender\Internals\PostFiles
- Вызов: PostFiles::checkAbsolutePath
static function checkAbsolutePath($filePath)
{
$isCheckedSuccess = false;
$io = \CBXVirtualIo::GetInstance();
$docRoot = Application::getDocumentRoot();
if(mb_strpos($filePath, \CTempFile::GetAbsoluteRoot()) === 0)
{
$absPath = $filePath;
}
elseif(mb_strpos($io->CombinePath($docRoot, $filePath), \CTempFile::GetAbsoluteRoot()) === 0)
{
$absPath = $io->CombinePath($docRoot, $filePath);
}
else
{
$absPath = $io->CombinePath(\CTempFile::GetAbsoluteRoot(), $filePath);
$isCheckedSuccess = true;
}
$absPath = realpath(str_replace("\\", "/", $absPath));
if (mb_strpos($absPath, realpath(\CTempFile::GetAbsoluteRoot())) !== 0)
{
return null;
}
if (!$isCheckedSuccess && $io->ValidatePathString($absPath) && $io->FileExists($absPath))
{
$docRoot = $io->CombinePath($docRoot, '/');
$relPath = str_replace($docRoot, '', $absPath);
$perm = $GLOBALS['APPLICATION']->GetFileAccessPermission($relPath);
if ($perm >= "W")
{
$isCheckedSuccess = true;
}
}
return [
'isSuccess' => $isCheckedSuccess,
'absPath' => $absPath
];
}