/**
  * @inheritdoc
  */
 public function collect()
 {
     $urlRewriterRules = UrlRewriter::getList(SITE_ID);
     foreach ($urlRewriterRules as $key => $rule) {
         $urlRewriterRules[$key] = $this->getDataFormatter()->formatVar($rule);
     }
     return $urlRewriterRules;
 }
Exemplo n.º 2
0
 public function __construct()
 {
     $this->validUrls = array("/bitrix/groupdav.php", "/index.php", "/.well-known");
     $site = \Bitrix\Main\Application::getInstance()->getContext()->getSite();
     $urls = UrlRewriter::getList($site);
     foreach ($urls as $url) {
         if (in_array($url['ID'], array('bitrix:socialnetwork_user', 'bitrix:socialnetwork_group', 'bitrix:disk.common'))) {
             $this->validUrls[] = $url['PATH'];
         }
     }
 }
Exemplo n.º 3
0
 private function reindexFile($siteId, $rootPath, $path, $maxFileSize = 0)
 {
     $pathAbs = IO\Path::combine($rootPath, $path);
     if (!UrlRewriter::checkPath($pathAbs)) {
         return 0;
     }
     $file = new IO\File($pathAbs);
     if ($maxFileSize > 0 && $file->getFileSize() > $maxFileSize * 1024) {
         return 0;
     }
     $fileSrc = $file->getContents();
     if (!$fileSrc || $fileSrc == "") {
         return 0;
     }
     $arComponents = \PHPParser::parseScript($fileSrc);
     for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) {
         $sef = is_array($arComponents[$i]["DATA"]["PARAMS"]) && $arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y";
         Component\ParametersTable::add(array('SITE_ID' => $siteId, 'COMPONENT_NAME' => $arComponents[$i]["DATA"]["COMPONENT_NAME"], 'TEMPLATE_NAME' => $arComponents[$i]["DATA"]["TEMPLATE_NAME"], 'REAL_PATH' => $path, 'SEF_MODE' => $sef ? Component\ParametersTable::SEF_MODE : Component\ParametersTable::NOT_SEF_MODE, 'SEF_FOLDER' => $sef ? $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] : null, 'START_CHAR' => $arComponents[$i]["START"], 'END_CHAR' => $arComponents[$i]["END"], 'PARAMETERS' => serialize($arComponents[$i]["DATA"]["PARAMS"])));
         if ($sef) {
             if (array_key_exists("SEF_RULE", $arComponents[$i]["DATA"]["PARAMS"])) {
                 $ruleMaker = new UrlRewriterRuleMaker();
                 $ruleMaker->process($arComponents[$i]["DATA"]["PARAMS"]["SEF_RULE"]);
                 $arFields = array("CONDITION" => $ruleMaker->getCondition(), "RULE" => $ruleMaker->getRule(), "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path, "SORT" => self::DEFAULT_SORT);
             } else {
                 $arFields = array("CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "RULE" => "", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path, "SORT" => self::DEFAULT_SORT);
             }
             UrlRewriter::add($siteId, $arFields);
         }
     }
     return true;
 }
Exemplo n.º 4
0
if (!$USER->CanDoOperation('edit_php')) {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
$res = false;
if (strlen($Reindex) > 0 && check_bitrix_sessid()) {
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_js.php";
    if (strlen($Next) <= 0 || !CheckSerializedData($_REQUEST['NS'])) {
        $NS = array("max_execution_time" => $max_execution_time, "stepped" => $stepped, "max_file_size" => $max_file_size);
        if ($site_id != "") {
            $NS["SITE_ID"] = $site_id;
        }
    } else {
        $NS = unserialize($_REQUEST['NS']);
    }
    if (class_exists("\\Bitrix\\Main\\Application", false)) {
        $res = \Bitrix\Main\UrlRewriter::reindexAll($NS["stepped"] == "Y" ? $NS["max_execution_time"] : 0, $NS);
    } else {
        $res = CUrlRewriter::ReIndexAll($NS["stepped"] == "Y" ? $NS["max_execution_time"] : 0, $NS);
    }
    if (is_array($res)) {
        //$res["STAT"]=$NS["STAT"];
        //$res["STAT"][]=$res["CNT"]-$NS["CNT"];
        //$perfomance = "<br>",implode($res["STAT"],", ");
        CAdminMessage::ShowMessage(array("MESSAGE" => GetMessage("url_rewrite_mess_title"), "DETAILS" => GetMessage("MURL_REINDEX_TOTAL") . " <b>" . $res["CNT"] . "</b>", "HTML" => true, "TYPE" => "OK"));
        ?>
		<input type="hidden" id="NS" name="NS" value="<?php 
        echo htmlspecialcharsbx(serialize($res));
        ?>
">
	<?php 
    } else {