/** * Returns script filename by URL * * @param string $site Site ID. * @param string $url URL. * @return string|null */ public static function getRealPath($site, $url) { $docRoot = rtrim(\Bitrix\Main\SiteTable::getDocumentRoot($site), '/'); $url = str_replace('\\', '/', $url); $url = \CHTTP::urnEncode($url); $uri = new \Bitrix\Main\Web\Uri($url); $path = \CHTTP::urnDecode($uri->getPath()); if (substr($path, -1, 1) == '/') { $path .= 'index.php'; } $file = new \Bitrix\Main\IO\File($docRoot . $path); if ($file->isExists()) { return substr($file->getPath(), 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 \Bitrix\Main\Web\Uri($url); $path = \CHTTP::urnDecode($uri->getPath()); $file = new \Bitrix\Main\IO\File($docRoot . $path); if ($file->isExists()) { $pathTmp = str_replace('.', '', strtolower(ltrim($path, '/\\'))); $pathTmp7 = substr($pathTmp, 0, 7); if ($pathTmp7 == 'upload/' || $pathTmp7 == 'bitrix/') { continue; } if ($file->getExtension() != 'php') { continue; } return substr($file->getPath(), strlen($docRoot)); } } } } return null; }
private static function onEpilogComposite() { global $USER, $APPLICATION; if (is_object($USER) && $USER->IsAuthorized()) { if (self::isCurrentUserCC()) { if ($APPLICATION->get_cookie("CC") !== "Y" || $APPLICATION->get_cookie("NCC") === "Y") { self::setCC(); } } else { if ($APPLICATION->get_cookie("NCC") !== "Y" || $APPLICATION->get_cookie("CC") === "Y") { self::setNCC(); } } } else { if ($APPLICATION->get_cookie("NCC") === "Y" || $APPLICATION->get_cookie("CC") === "Y") { self::deleteCompositeCookies(); } } if (Main\Data\Cache::shouldClearCache()) { $server = Main\Context::getCurrent()->getServer(); $queryString = DeleteParam(array("clear_cache", "clear_cache_session")); $uri = new Bitrix\Main\Web\Uri($server->getRequestUri()); $refinedUri = $queryString != "" ? $uri->getPath()."?".$queryString : $uri->getPath(); $cachedFile = self::convertUriToPath($refinedUri, self::getHttpHost()); $cacheStorage = Bitrix\Main\Data\StaticHtmlCache::getStaticHtmlStorage($cachedFile); if ($cacheStorage !== null) { $bytes = $cacheStorage->delete(); if ($bytes !== false && $cacheStorage->shouldCountQuota()) { self::updateQuota(-$bytes); } } } }