- Модуль: abtest
- Путь к файлу: ~/bitrix/modules/abtest/lib/adminhelper.php
- Класс: BitrixABTestAdminHelper
- Вызов: AdminHelper::getRealPath
static function getRealPath($site, $url)
{
$docRoot = rtrim(BitrixMainSiteTable::getDocumentRoot($site), '/');
$url = str_replace('\', '/', $url);
$url = CHTTP::urnEncode($url);
$uri = new WebUri($url);
$path = CHTTP::urnDecode($uri->getPath());
if (mb_substr($path, -1, 1) == '/')
$path .= 'index.php';
$file = new IOFile($docRoot.$path);
if ($file->isExists())
return mb_substr($file->getPath(), mb_strlen($docRoot));
if ($rewriteRules = AdminHelper::getRewriteRules($site))
{
$pathQuery = CHTTP::urnDecode($uri->getPathQuery());
foreach ($rewriteRules as &$item)
{
if (preg_match($item['CONDITION'], $pathQuery))
{
$url = empty($item['PATH']) && !empty($item['RULE'])
? preg_replace($item['CONDITION'], $item['RULE'], $pathQuery)
: $item['PATH'];
$url = CHTTP::urnEncode($url);
$uri = new WebUri($url);
$path = CHTTP::urnDecode($uri->getPath());
$file = new IOFile($docRoot.$path);
if ($file->isExists())
{
$pathTmp = str_replace('.', '', mb_strtolower(ltrim($path, '/\')));
$pathTmp7 = mb_substr($pathTmp, 0, 7);
if ($pathTmp7 == 'upload/' || $pathTmp7 == 'bitrix/')
continue;
if ($file->getExtension() != 'php')
continue;
return mb_substr($file->getPath(), mb_strlen($docRoot));
}
}
}
}
return null;
}