• Модуль: search
  • Путь к файлу: ~/bitrix/modules/search/classes/general/search.php
  • Класс: CAllSearch
  • Вызов: CAllSearch::RecurseIndex
static function RecurseIndex($path = Array(), $max_execution_time = 0, &$NS)
{
	if (!is_array($path))
		return 0;

	$site = $path[0];
	$path = $path[1];

	$DOC_ROOT = CSite::GetSiteDocRoot($site);
	$abs_path = $DOC_ROOT.$path;

	$io = CBXVirtualIo::GetInstance();

	if (!$io->DirectoryExists($abs_path))
		return 0;

	$f = $io->GetFile($abs_path);
	if (!$f->IsReadable())
		return 0;

	$d = $io->GetDirectory($abs_path);
	foreach ($d->GetChildren() as $dir_entry)
	{
		$path_file = $path."/".$dir_entry->GetName();

		if ($dir_entry->IsDirectory())
		{
			if ($path_file == "/bitrix")
				continue;

			//this is not first step and we had stopped here, so go on to reindex
			if (
				$max_execution_time <= 0
				|| $NS["MODULE"] == ''
				|| (
					$NS["MODULE"] == "main"
					&& mb_substr($NS["ID"]."/", 0, mb_strlen($site."|".$path_file."/")) == $site."|".$path_file."/"
				)
			)
			{
				if (CSearch::CheckPath($path_file."/") !== false)
				{
					if (CSearch::RecurseIndex(Array($site, $path_file), $max_execution_time, $NS) === false)
						return false;
				}
			}
			else //all done
			{
				continue;
			}
		}
		else
		{
			//not the first step and we found last file from previous one
			if (
				$max_execution_time > 0
				&& $NS["MODULE"] <> ''
				&& $NS["MODULE"] == "main"
				&& $NS["ID"] == $site."|".$path_file
			)
			{
				$NS["MODULE"] = "";
			}
			elseif ($NS["MODULE"] == '')
			{
				$ID = CSearch::ReindexFile(Array($site, $path_file), $NS["SESS_ID"]);
				if (intval($ID) > 0)
				{
					$NS["CNT"] = intval($NS["CNT"]) + 1;
				}

				if (
					$max_execution_time > 0
					&& (getmicrotime() - START_EXEC_TIME > $max_execution_time)
				)
				{
					$NS["MODULE"] = "main";
					$NS["ID"] = $site."|".$path_file;
					return false;
				}
			}
		}
	}

	return true;
}