25 if (
IO\File::isFileExists(
$docRoot .
"/urlrewrite.php"))
27 include(
$docRoot .
"/urlrewrite.php");
32 if (!isset($rule[
"SORT"]))
34 $rule[
"SORT"] = self::DEFAULT_SORT;
55 $data = var_export($urlRewrite,
true);
57 $event =
new Event(
"main",
"onUrlRewriteSaveRules", [
65 IO\File::putFileContents(
$filename,
"<" .
"?php\n\$arUrlRewrite=" .
$data .
";\n");
76 $urlRewrite = static::loadRules(
$siteId);
80 foreach ($resultKeys as
$key)
87 $orderKeys = array_keys(
$order);
88 $orderBy = array_shift($orderKeys);
89 $orderDir =
$order[$orderBy];
91 $orderBy = mb_strtoupper($orderBy);
92 $orderDir = mb_strtoupper($orderDir);
94 $orderDir = (($orderDir ==
"DESC") ? SORT_DESC : SORT_ASC);
112 foreach ($urlRewrite as $keyRule => $rule)
115 foreach (
$filter as $keyFilter => $valueFilter)
118 if (str_starts_with($keyFilter,
"!"))
121 $keyFilter = mb_substr($keyFilter, 1);
124 if ($keyFilter ===
'QUERY')
126 $isMatchedTmp = preg_match($rule[
"CONDITION"], $valueFilter);
128 elseif ($keyFilter ===
'CONDITION')
130 $isMatchedTmp = ($rule[
"CONDITION"] == $valueFilter);
132 elseif ($keyFilter ===
'ID')
134 $isMatchedTmp = (isset($rule[
"ID"]) && ($rule[
"ID"] == $valueFilter));
136 elseif ($keyFilter ===
'PATH')
138 $isMatchedTmp = ($rule[
"PATH"] == $valueFilter);
145 $isMatched = ($isNegative xor $isMatchedTmp);
155 $resultKeys[] = $keyRule;
164 $sortA = isset(
$a[
"SORT"]) ? intval(
$a[
"SORT"]) : self::DEFAULT_SORT;
165 $sortB = isset($b[
"SORT"]) ? intval($b[
"SORT"]) : self::DEFAULT_SORT;
176 $lenA = mb_strlen(
$a[
"CONDITION"]);
177 $lenB = mb_strlen($b[
"CONDITION"]);
199 $urlRewrite = static::loadRules(
$siteId);
202 foreach ($urlRewrite as $rule)
204 if (
$fields[
"CONDITION"] == $rule[
"CONDITION"])
211 "CONDITION" =>
$fields[
"CONDITION"],
215 "SORT" => isset(
$fields[
"SORT"]) ? intval(
$fields[
"SORT"]) : self::DEFAULT_SORT,
218 uasort($urlRewrite, [
'\Bitrix\Main\UrlRewriter',
"recordsCompare"]);
220 static::saveRules(
$siteId, $urlRewrite);
230 $urlRewrite = static::loadRules(
$siteId);
233 foreach ($resultKeys as
$key)
235 if (array_key_exists(
"CONDITION",
$fields))
237 $urlRewrite[
$key][
"CONDITION"] =
$fields[
"CONDITION"];
239 if (array_key_exists(
"RULE",
$fields))
243 if (array_key_exists(
"ID",
$fields))
247 if (array_key_exists(
"PATH",
$fields))
251 if (array_key_exists(
"SORT",
$fields))
253 $urlRewrite[
$key][
"SORT"] = intval(
$fields[
"SORT"]);
257 uasort($urlRewrite, [
'\Bitrix\Main\UrlRewriter',
"recordsCompare"]);
259 static::saveRules(
$siteId, $urlRewrite);
269 $urlRewrite = static::loadRules(
$siteId);
272 foreach ($resultKeys as
$key)
274 unset($urlRewrite[
$key]);
277 uasort($urlRewrite, [
'\Bitrix\Main\UrlRewriter',
"recordsCompare"]);
279 static::saveRules(
$siteId, $urlRewrite);
297 "SESS_ID" => md5(uniqid()),
298 "max_execution_time" => $nsOld[
"max_execution_time"],
299 "stepped" => $nsOld[
"stepped"],
300 "max_file_size" => $nsOld[
"max_file_size"],
303 if (!empty($nsOld[
"SITE_ID"]))
305 $ns[
"SITE_ID"] = $nsOld[
"SITE_ID"];
308 $ns[
"CNT"] = intval($ns[
"CNT"] ?? 0);
311 $filterRootPath =
"";
315 "select" => [
"LID",
"DOC_ROOT",
"DIR"],
316 "filter" => [
"=ACTIVE" =>
"Y"],
319 while (
$ar = $db->fetch())
321 if (empty(
$ar[
"DOC_ROOT"]))
327 "site_id" =>
$ar[
"LID"],
328 "root" =>
$ar[
"DOC_ROOT"],
329 "path" => IO\Path::combine(
$ar[
"DOC_ROOT"],
$ar[
"DIR"]),
332 if (!empty($ns[
"SITE_ID"]) && $ns[
"SITE_ID"] ==
$ar[
"LID"])
334 $filterRootPath =
$ar[
"DOC_ROOT"];
338 if (!empty($ns[
"SITE_ID"]) && !empty($filterRootPath))
341 $keys = array_keys(
$sites);
342 foreach ($keys as
$key)
354 $la = mb_strlen(
$a[
"path"]);
355 $lb = mb_strlen($b[
"path"]);
358 if (
$a[
"site_id"] == $b[
"site_id"])
364 return (
$a[
"site_id"] > $b[
"site_id"]) ? -1 : 1;
367 return ($la > $lb) ? -1 : 1;
371 if ($ns[
"CLEAR"] !=
"Y")
373 $alreadyDeleted = [];
377 if (!in_array(
$site[
"root"], $alreadyDeleted))
383 $alreadyDeleted[] =
$site[
"root"];
394 if (in_array(
$site[
"root"], $alreadyParsed))
398 $alreadyParsed[] =
$site[
"root"];
401 && mb_substr($ns[
"ID"] .
"/", 0, mb_strlen(
$site[
"root"] .
"/")) !=
$site[
"root"] .
"/")
419 $pathAbs = IO\Path::combine($rootPath,
$path);
424 if (str_starts_with($pathAbs .
"/",
$site[
"path"] .
"/"))
436 if (!
$dir->isExists())
444 if ($child->isDirectory())
446 if ($child->isSystem())
454 || str_starts_with($ns[
"ID"] .
"/", $child->getPath() .
"/")
457 if (static::recursiveReindex($rootPath, mb_substr($child->getPath(), mb_strlen($rootPath)),
$sites,
$maxExecutionTime, $ns) ===
false)
467 && $ns[
"ID"] == $child->getPath())
471 elseif (empty($ns[
"FLG"]))
473 $ID = static::reindexFile(
$siteId, $rootPath, mb_substr($child->getPath(), mb_strlen($rootPath)), $ns[
"max_file_size"]);
476 $ns[
"CNT"] = intval($ns[
"CNT"]) + 1;
484 $ns[
"ID"] = $child->getPath();
494 $pathAbs = IO\Path::combine($rootPath,
$path);
496 if (!static::checkPath($pathAbs))
501 $file =
new IO\File($pathAbs);
502 if ($maxFileSize > 0 && $file->getSize() > $maxFileSize * 1024)
507 $fileSrc = $file->getContents();
509 if (!$fileSrc || $fileSrc ==
"")
514 $components = \PHPParser::parseScript($fileSrc);
516 for (
$i = 0, $cnt =
count($components);
$i < $cnt;
$i++)
518 $sef = (isset($components[
$i][
"DATA"][
"PARAMS"][
"SEF_MODE"]) && $components[
$i][
"DATA"][
"PARAMS"][
"SEF_MODE"] ==
"Y");
523 'COMPONENT_NAME' => $components[
$i][
"DATA"][
"COMPONENT_NAME"],
524 'TEMPLATE_NAME' => $components[
$i][
"DATA"][
"TEMPLATE_NAME"],
525 'REAL_PATH' =>
$path,
526 'SEF_MODE' => ($sef ?
Component\ParametersTable::SEF_MODE :
Component\ParametersTable::NOT_SEF_MODE),
527 'SEF_FOLDER' => ($sef ? $components[
$i][
"DATA"][
"PARAMS"][
"SEF_FOLDER"] :
null),
528 'START_CHAR' => $components[
$i][
"START"],
529 'END_CHAR' => $components[
$i][
"END"],
530 'PARAMETERS' => serialize($components[
$i][
"DATA"][
"PARAMS"]),
536 if (array_key_exists(
"SEF_RULE", $components[
$i][
"DATA"][
"PARAMS"]))
539 $ruleMaker->
process($components[
$i][
"DATA"][
"PARAMS"][
"SEF_RULE"]);
542 "CONDITION" => $ruleMaker->getCondition(),
543 "RULE" => $ruleMaker->getRule(),
544 "ID" => $components[
$i][
"DATA"][
"COMPONENT_NAME"],
546 "SORT" => self::DEFAULT_SORT,
552 "CONDITION" =>
"#^" . $components[
$i][
"DATA"][
"PARAMS"][
"SEF_FOLDER"] .
"#",
554 "ID" => $components[
$i][
"DATA"][
"COMPONENT_NAME"],
556 "SORT" => self::DEFAULT_SORT,
569 static $searchMasksCache =
false;
571 if (is_array($searchMasksCache))
573 $exclude = $searchMasksCache[
"exc"];
574 $include = $searchMasksCache[
"inc"];
581 $inc = Config\Option::get(
"main",
"urlrewrite_include_mask",
"*.php");
582 $inc = str_replace(
"'",
"\\'", str_replace(
"*",
".*?", str_replace(
"?",
".", str_replace(
".",
"\\.", str_replace(
"\\",
"/", $inc)))));
583 $incTmp = explode(
";", $inc);
584 foreach ($incTmp as $pregMask)
586 if (trim($pregMask) <>
'')
588 $include[] =
"'^" . trim($pregMask) .
"$'";
592 $exc = Config\Option::get(
"main",
"urlrewrite_exclude_mask",
"/bitrix/*;");
593 $exc = str_replace(
"'",
"\\'", str_replace(
"*",
".*?", str_replace(
"?",
".", str_replace(
".",
"\\.", str_replace(
"\\",
"/", $exc)))));
594 $excTmp = explode(
";", $exc);
595 foreach ($excTmp as $pregMask)
597 if (trim($pregMask) <>
'')
599 $exclude[] =
"'^" . trim($pregMask) .
"$'";
603 $searchMasksCache = [
"exc" => $exclude,
"inc" => $include];
606 $file = IO\Path::getName(
$path);
607 if (str_starts_with($file,
"."))
612 foreach ($exclude as $pregMask)
614 if (preg_match($pregMask,
$path))
620 foreach ($include as $pregMask)
622 if (preg_match($pregMask,
$path))
static resetAccelerator(string $filename=null)
static deleteBySiteId($siteId)
static getRow(array $parameters)
static getList(array $parameters=array())
static recursiveReindex($rootPath, $path, $sites, $maxExecutionTime, &$ns)
static reindexAll($maxExecutionTime=0, $ns=[])
static recordsCompare($a, $b)
static update($siteId, $filter, $fields)
static reindexFile($siteId, $rootPath, $path, $maxFileSize=0)
static add($siteId, $fields)
static saveRules($siteId, array $urlRewrite)
static getList($siteId, $filter=[], $order=[])
static loadRules($siteId)
static filterRules(array $urlRewrite, array $filter)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"