本文整理匯總了PHP中CUrlRewriter::CheckPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP CUrlRewriter::CheckPath方法的具體用法?PHP CUrlRewriter::CheckPath怎麽用?PHP CUrlRewriter::CheckPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CUrlRewriter
的用法示例。
在下文中一共展示了CUrlRewriter::CheckPath方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ReindexFile
function ReindexFile($path, $SEARCH_SESS_ID = "", $max_file_size = 0)
{
global $APPLICATION;
CMain::InitPathVars($site, $path);
$DOC_ROOT = CSite::GetSiteDocRoot($site);
if (!CUrlRewriter::CheckPath($path)) {
return 0;
}
if ($max_file_size > 0 && filesize($DOC_ROOT . "/" . $path) > $max_file_size * 1024) {
return 0;
}
$filesrc = $APPLICATION->GetFileContent($DOC_ROOT . "/" . $path);
if (!$filesrc || $filesrc == "") {
return 0;
}
$arComponents = PHPParser::ParseScript($filesrc);
for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) {
if ($arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y") {
$arFields = array("SITE_ID" => $site, "CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "RULE" => "", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path);
CUrlRewriter::Add($arFields);
}
}
return true;
}
示例2: ReindexFile
public static function ReindexFile($path, $SEARCH_SESS_ID = "", $max_file_size = 0)
{
global $APPLICATION;
CMain::InitPathVars($site, $path);
$DOC_ROOT = CSite::GetSiteDocRoot($site);
if (!CUrlRewriter::CheckPath($path)) {
return 0;
}
if ($max_file_size > 0 && filesize($DOC_ROOT . "/" . $path) > $max_file_size * 1024) {
return 0;
}
$filesrc = $APPLICATION->GetFileContent($DOC_ROOT . "/" . $path);
if (!$filesrc || $filesrc == "") {
return 0;
}
$arComponents = PHPParser::ParseScript($filesrc);
for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) {
if ($arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y") {
if (array_key_exists("SEF_RULE", $arComponents[$i]["DATA"]["PARAMS"])) {
$ruleMaker = new \Bitrix\Main\UrlRewriterRuleMaker();
$ruleMaker->process($arComponents[$i]["DATA"]["PARAMS"]["SEF_RULE"]);
CUrlRewriter::Add(array("SITE_ID" => $site, "CONDITION" => $ruleMaker->getCondition(), "RULE" => $ruleMaker->getRule(), "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path));
} else {
CUrlRewriter::Add(array("SITE_ID" => $site, "CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "RULE" => "", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path));
}
}
}
return true;
}