本文整理汇总了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;
}