private static function recursiveReindex($rootPath, $path, $arSites, $maxExecutionTime = 0, &$ns) { $pathAbs = IO\Path::combine($rootPath, $path); $dir = new IO\Directory($pathAbs); if (!$dir->isExists()) { return 0; } $siteId = ""; foreach ($arSites as $site) { if (substr($pathAbs . "/", 0, strlen($site["path"] . "/")) == $site["path"] . "/") { $siteId = $site["site_id"]; break; } } if (empty($siteId)) { return 0; } $arChildren = $dir->getChildren(); foreach ($arChildren as $child) { if ($child->isDirectory()) { if ($child->isSystem()) { continue; } //this is not first step and we had stopped here, so go on to reindex if ($maxExecutionTime <= 0 || strlen($ns["FLG"]) <= 0 || strlen($ns["FLG"]) > 0 && substr($ns["ID"] . "/", 0, strlen($child->getPath() . "/")) == $child->getPath() . "/") { if (UrlRewriter::recursiveReindex($rootPath, substr($child->getPath(), strlen($rootPath)), $arSites, $maxExecutionTime, $ns) === false) { return false; } } else { continue; } } else { //not the first step and we found last file from previos one if ($maxExecutionTime > 0 && strlen($ns["FLG"]) > 0 && $ns["ID"] == $child->getPath()) { $ns["FLG"] = ""; } elseif (empty($ns["FLG"])) { $ID = UrlRewriter::reindexFile($siteId, $rootPath, substr($child->getPath(), strlen($rootPath)), $ns["max_file_size"]); if ($ID) { $ns["CNT"] = intval($ns["CNT"]) + 1; } } if ($maxExecutionTime > 0 && getmicrotime() - START_EXEC_TIME > $maxExecutionTime) { $ns["FLG"] = "Y"; $ns["ID"] = $child->getPath(); return false; } } } return true; }