Exemple #1
0
 public static function getTags()
 {
     $tags = CSearchTags::GetList();
     while ($tag = $tags->getNext()) {
         $key++;
         $arTags[$key] = array("TAG_NAME" => $tag["NAME"], "TAG_PATH" => "#", "CNT" => $tag["CNT"]);
     }
     return $arTags;
 }
 public function getTags($aOptions)
 {
     $mResult = array();
     $aFilter = $this->getTagsFilter();
     if (isset($this->aOptions['FILTER'])) {
         $aFilter = array_merge($this->aOptions['FILTER'], $aFilter);
     }
     if (isset($aOptions['FILTER'])) {
         $aFilter = array_merge($aOptions['FILTER'], $aFilter);
     }
     $rsTags = CSearchTags::GetList(array(), $aFilter, array(), false);
     while ($arTag = $rsTags->Fetch()) {
         $mResult[] = $arTag;
     }
     return $mResult;
 }
Exemple #3
0
 function TagsIndex($arLID, $ID, $sContent)
 {
     $DB = CDatabase::GetModuleConnection('search');
     $ID = intval($ID);
     if (!is_array($arLID)) {
         $arLID = array();
     }
     $sContent = str_replace("", "", $sContent);
     foreach ($arLID as $site_id => $url) {
         $sql_site_id = $DB->ForSQL($site_id);
         $arTags = tags_prepare($sContent, $site_id);
         if (!empty($arTags)) {
             $strSqlPrefix = "\n\t\t\t\t\t\tinsert ignore into b_search_tags\n\t\t\t\t\t\t(SEARCH_CONTENT_ID, SITE_ID, NAME)\n\t\t\t\t\t\tvalues\n\t\t\t\t";
             $maxValuesLen = 2048;
             $strSqlValues = "";
             CSearchTags::CleanCache($arTags);
             foreach ($arTags as $tag) {
                 $strSqlValues .= ",\n(" . $ID . ", '" . $sql_site_id . "', '" . $DB->ForSql($tag, 255) . "')";
                 if (strlen($strSqlValues) > $maxValuesLen) {
                     $DB->Query($strSqlPrefix . substr($strSqlValues, 2), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                     $strSqlValues = "";
                 }
             }
             if (strlen($strSqlValues) > 0) {
                 $DB->Query($strSqlPrefix . substr($strSqlValues, 2), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                 $strSqlValues = "";
             }
         }
     }
 }
Exemple #4
0
	function DeleteIndex($MODULE_ID, $ITEM_ID=false, $PARAM1=false, $PARAM2=false, $SITE_ID=false)
	{
		$DB = CDatabase::GetModuleConnection('search');
		$bIncSites = false;

		if($PARAM1 !== false && $PARAM2 !== false)
		{
			$strSqlWhere = CSearch::__PrepareFilter(array(
				"MODULE_ID" => $MODULE_ID,
				"ITEM_ID" => $ITEM_ID,
				array(
					"=PARAM1" => $PARAM1,
					"PARAM2" => $PARAM2,
				),
				"SITE_ID" => $SITE_ID,
			), $bIncSites);
		}
		else
		{
			$strSqlWhere = CSearch::__PrepareFilter(array(
				"MODULE_ID" => $MODULE_ID,
				"ITEM_ID" => $ITEM_ID,
				"PARAM1" => $PARAM1,
				"PARAM2" => $PARAM2,
				"SITE_ID" => $SITE_ID,
			), $bIncSites);
		}

		$strSql = "
			SELECT sc.ID
			FROM b_search_content sc
				".($bIncSites? "INNER JOIN b_search_content_site scsite ON sc.ID=scsite.SEARCH_CONTENT_ID" :"")."
			WHERE
			".$strSqlWhere."
		";

		$arEvents = GetModuleEvents("search", "OnBeforeIndexDelete", true);

		$rs = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		while($ar = $rs->Fetch())
		{
			foreach($arEvents as $arEvent)
				ExecuteModuleEventEx($arEvent, array("SEARCH_CONTENT_ID = ".$ar["ID"]));

			$DB->Query("DELETE FROM b_search_content_param WHERE SEARCH_CONTENT_ID = ".$ar["ID"], false, "File: ".__FILE__."<br>Line: ".__LINE__);
			$DB->Query("DELETE FROM b_search_content_right WHERE SEARCH_CONTENT_ID = ".$ar["ID"], false, "File: ".__FILE__."<br>Line: ".__LINE__);
			$DB->Query("DELETE FROM b_search_content_site WHERE SEARCH_CONTENT_ID = ".$ar["ID"], false, "File: ".__FILE__."<br>Line: ".__LINE__);
			$DB->Query("DELETE FROM b_search_content_title WHERE SEARCH_CONTENT_ID = ".$ar["ID"], false, "File: ".__FILE__."<br>Line: ".__LINE__);
			$DB->Query("DELETE FROM b_search_tags WHERE SEARCH_CONTENT_ID = ".$ar["ID"], false, "File: ".__FILE__."<br>Line: ".__LINE__);
			$DB->Query("DELETE FROM b_search_content WHERE ID = ".$ar["ID"], false, "File: ".__FILE__."<br>Line: ".__LINE__);
			CSearchFullText::getInstance()->deleteById($ar["ID"]);
		}

		CSearchTags::CleanCache();
	}
Exemple #5
0
	function Index($MODULE_ID, $ITEM_ID, $arFields, $bOverWrite=false, $SEARCH_SESS_ID="")
	{
		$DB = CDatabase::GetModuleConnection('search');

		$arFields["MODULE_ID"] = $MODULE_ID;
		$arFields["ITEM_ID"] = $ITEM_ID;
		foreach(GetModuleEvents("search", "BeforeIndex", true) as $arEvent)
		{
			$arEventResult = ExecuteModuleEventEx($arEvent, array($arFields));
			if(is_array($arEventResult))
				$arFields = $arEventResult;
		}
		unset($arFields["MODULE_ID"]);
		unset($arFields["ITEM_ID"]);

		$bTitle = array_key_exists("TITLE", $arFields);
		if($bTitle)
			$arFields["TITLE"] = trim($arFields["TITLE"]);
		$bBody = array_key_exists("BODY", $arFields);
		if($bBody)
			$arFields["BODY"] = trim($arFields["BODY"]);
		$bTags = array_key_exists("TAGS", $arFields);
		if($bTags)
			$arFields["TAGS"] = trim($arFields["TAGS"]);

		if(!array_key_exists("SITE_ID", $arFields) && array_key_exists("LID", $arFields))
			$arFields["SITE_ID"] = $arFields["LID"];

		if(array_key_exists("SITE_ID", $arFields))
		{
			if(!is_array($arFields["SITE_ID"]))
			{
				$arFields["SITE_ID"] = Array($arFields["SITE_ID"]=>"");
			}
			else
			{
				$bNotAssoc = true;
				$i = 0;
				foreach($arFields["SITE_ID"] as $k=>$val)
				{
					if("".$k!="".$i)
					{
						$bNotAssoc=false;
						break;
					}
					$i++;
				}
				if($bNotAssoc)
				{
					$x = $arFields["SITE_ID"];
					$arFields["SITE_ID"] = Array();
					foreach($x as $val)
						$arFields["SITE_ID"][$val] = "";
				}
			}

			if(count($arFields["SITE_ID"])<=0)
				return 0;

			reset($arFields["SITE_ID"]);
			list($arFields["LID"], $url) = each($arFields["SITE_ID"]);

			$arSites = array();
			foreach($arFields["SITE_ID"] as $site => $url)
			{
				$arSites[] = $DB->ForSQL($site, 2);
			}

			$strSql = "
				SELECT CR.RANK
				FROM b_search_custom_rank CR
				WHERE CR.SITE_ID in ('".implode("', '", $arSites)."')
				AND CR.MODULE_ID='".$DB->ForSQL($MODULE_ID)."'
				".(is_set($arFields, "PARAM1")?"AND (CR.PARAM1 IS NULL OR CR.PARAM1='".$DB->ForSQL($arFields["PARAM1"])."')":"")."
				".(is_set($arFields, "PARAM2")?"AND (CR.PARAM2 IS NULL OR CR.PARAM2='".$DB->ForSQL($arFields["PARAM2"])."')":"")."
				".($ITEM_ID<>""?"AND (CR.ITEM_ID IS NULL OR CR.ITEM_ID='".$DB->ForSQL($ITEM_ID)."')":"")."
				ORDER BY
					PARAM1 DESC, PARAM2 DESC, ITEM_ID DESC
			";
			$r = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			$arFields["CUSTOM_RANK_SQL"]=$strSql;
			if($arResult = $r->Fetch())
				$arFields["CUSTOM_RANK"]=$arResult["RANK"];
		}

		$arGroups = array();
		if(is_set($arFields, "PERMISSIONS"))
		{
			foreach($arFields["PERMISSIONS"] as $group_id)
			{
				if(is_numeric($group_id))
					$arGroups[$group_id] = "G".intval($group_id);
				else
					$arGroups[$group_id] = $group_id;
			}
		}

		$strSqlSelect = "";
		if($bBody) $strSqlSelect .= ",BODY";
		if($bTitle) $strSqlSelect .= ",TITLE";
		if($bTags) $strSqlSelect .= ",TAGS";

		$strSql =
			"SELECT ID, ".$DB->DateToCharFunction("DATE_CHANGE")." as DATE_CHANGE
			".$strSqlSelect."
			FROM b_search_content
			WHERE MODULE_ID = '".$DB->ForSQL($MODULE_ID)."'
				AND ITEM_ID = '".$DB->ForSQL($ITEM_ID)."' ";

		$r = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);

		if($arResult = $r->Fetch())
		{
			$ID = $arResult["ID"];

			if($bTitle && $bBody && strlen($arFields["BODY"])<=0 && strlen($arFields["TITLE"])<=0)
			{
				foreach(GetModuleEvents("search", "OnBeforeIndexDelete", true) as $arEvent)
					ExecuteModuleEventEx($arEvent, array("SEARCH_CONTENT_ID = ".$ID));

				CSearchTags::CleanCache("", $ID);
				CSearch::CleanFreqCache($ID);
				$DB->Query("DELETE FROM b_search_content_param WHERE SEARCH_CONTENT_ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("DELETE FROM b_search_content_right WHERE SEARCH_CONTENT_ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("DELETE FROM b_search_content_site WHERE SEARCH_CONTENT_ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("DELETE FROM b_search_content_title WHERE SEARCH_CONTENT_ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("DELETE FROM b_search_content_stem WHERE SEARCH_CONTENT_ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);
				if(BX_SEARCH_VERSION > 1)
					$DB->Query("DELETE FROM b_search_content_text WHERE SEARCH_CONTENT_ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("DELETE FROM b_search_tags WHERE SEARCH_CONTENT_ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);
				$DB->Query("DELETE FROM b_search_content WHERE ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);

				return 0;
			}

			if(is_set($arFields, "PARAMS"))
				CAllSearch::SetContentItemParams($ID, $arFields["PARAMS"]);

			if(count($arGroups) > 0)
				CAllSearch::SetContentItemGroups($ID, $arGroups);

			if(is_set($arFields, "SITE_ID"))
			{
				$arSITE_ID = $arFields["SITE_ID"];
				$strSql = "
					SELECT SITE_ID, URL
					FROM b_search_content_site
					WHERE SEARCH_CONTENT_ID = ".$ID."
				";
				$rsSite = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
				while($arSite = $rsSite->Fetch())
				{
					if(array_key_exists($arSite["SITE_ID"], $arSITE_ID))
					{
						if($arSite["URL"] !== $arSITE_ID[$arSite["SITE_ID"]])
							$strSql = "
								UPDATE b_search_content_site
								SET URL = '".$DB->ForSql($url, 2000)."'
								WHERE SEARCH_CONTENT_ID = ".$ID."
								AND SITE_ID = '".$DB->ForSql($arSite["SITE_ID"])."'
							";
						else
							$strSql = "";

						unset($arSITE_ID[$arSite["SITE_ID"]]);
					}
					else
					{
						$strSql = "
							DELETE FROM b_search_content_site
							WHERE SEARCH_CONTENT_ID = ".$ID."
							AND SITE_ID = '".$DB->ForSql($arSite["SITE_ID"])."'
						";
					}

					if(!empty($strSql))
						$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
				}

				foreach($arSITE_ID as $site => $url)
				{
					$strSql = "
						INSERT INTO b_search_content_site(SEARCH_CONTENT_ID, SITE_ID, URL)
						VALUES(".$ID.", '".$DB->ForSql($site, 2)."', '".$DB->ForSql($url, 2000)."')
					";
					$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
				}
			}

			if(array_key_exists("LAST_MODIFIED", $arFields))
				$arFields["~DATE_CHANGE"] = $arFields["DATE_CHANGE"] = $DATE_CHANGE = $arFields["LAST_MODIFIED"];
			elseif(array_key_exists("DATE_CHANGE", $arFields))
				$arFields["~DATE_CHANGE"] = $arFields["DATE_CHANGE"] = $DATE_CHANGE = $DB->FormatDate($arFields["DATE_CHANGE"], "DD.MM.YYYY HH:MI:SS", CLang::GetDateFormat());
			else
				$DATE_CHANGE = '';

			if(!$bOverWrite && $DATE_CHANGE == $arResult["DATE_CHANGE"])
			{
				if(strlen($SEARCH_SESS_ID)>0)
					$DB->Query("UPDATE b_search_content SET UPD='".$SEARCH_SESS_ID."' WHERE ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);
				//$DB->Commit();
				return $ID;
			}

			unset($arFields["MODULE_ID"]);
			unset($arFields["ITEM_ID"]);

			if($bBody || $bTitle || $bTags)
			{

				if(array_key_exists("INDEX_TITLE", $arFields) && $arFields["INDEX_TITLE"] === false)
				{
					$content = "";
				}
				else
				{
					if($bTitle)
						$content = $arFields["TITLE"]."\r\n";
					else
						$content = $arResult["TITLE"]."\r\n";
				}

				if($bBody)
					$content .= $arFields["BODY"]."\r\n";
				else
					$content .= $arResult["BODY"]."\r\n";

				if($bTags)
					$content .= $arFields["TAGS"];
				else
					$content .= $arResult["TAGS"];

				$content = preg_replace("'&#(\d+);'e", "chr(\\1)", $content);
				$arFields["SEARCHABLE_CONTENT"] = CSearch::KillEntities(ToUpper($content));
			}

			if(strlen($SEARCH_SESS_ID)>0)
				$arFields["UPD"] = $SEARCH_SESS_ID;

			if(array_key_exists("TITLE", $arFields))
			{
				$DB->Query("DELETE FROM b_search_content_title WHERE SEARCH_CONTENT_ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);
				if(
					!array_key_exists("INDEX_TITLE", $arFields)
					|| $arFields["INDEX_TITLE"] !== false
				)
					CSearch::IndexTitle($arFields["SITE_ID"], $ID, $arFields["TITLE"]);
			}

			if(is_set($arFields, "SEARCHABLE_CONTENT"))
			{
				if(BX_SEARCH_VERSION > 1)
				{
					$text_md5 = md5($arFields["SEARCHABLE_CONTENT"]);
					$rsText = $DB->Query("SELECT SEARCH_CONTENT_MD5 FROM b_search_content_text WHERE SEARCH_CONTENT_ID = ".$ID);
					$arText = $rsText->Fetch();
					if(!$arText || $arText["SEARCH_CONTENT_MD5"] !== $text_md5)
					{
						CSearch::CleanFreqCache($ID);
						$DB->Query("DELETE FROM b_search_content_stem WHERE SEARCH_CONTENT_ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);
						if (COption::GetOptionString("search", "agent_stemming") === "Y")
							CSearch::DelayStemIndex($ID);
						else
							CSearch::StemIndex($arFields["SITE_ID"], $ID, $arFields["SEARCHABLE_CONTENT"]);
						$DB->Query("DELETE FROM b_search_content_text WHERE SEARCH_CONTENT_ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);
						$arText = array(
							"ID" => 1,
							"SEARCH_CONTENT_ID" => $ID,
							"SEARCH_CONTENT_MD5" => $text_md5,
							"SEARCHABLE_CONTENT" => $arFields["SEARCHABLE_CONTENT"]
						);
						$DB->Add("b_search_content_text", $arText, Array("SEARCHABLE_CONTENT"));
					}
				}
				else
				{
					CSearch::CleanFreqCache($ID);
					$DB->Query("DELETE FROM b_search_content_stem WHERE SEARCH_CONTENT_ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);
					if (COption::GetOptionString("search", "agent_stemming") === "Y")
						CSearch::DelayStemIndex($ID);
					else
						CSearch::StemIndex($arFields["SITE_ID"], $ID, $arFields["SEARCHABLE_CONTENT"]);
				}
			}

			if($bTags && ($arResult["TAGS"] != $arFields["TAGS"]))
			{
				CSearchTags::CleanCache("", $ID);
				$DB->Query("DELETE FROM b_search_tags WHERE SEARCH_CONTENT_ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);
				CSearch::TagsIndex($arFields["SITE_ID"], $ID, $arFields["TAGS"]);
			}

			foreach(GetModuleEvents("search", "OnBeforeIndexUpdate", true) as $arEvent)
				ExecuteModuleEventEx($arEvent, array($ID, $arFields));

			CSearch::Update($ID, $arFields);
		}
		else
		{
			if($bTitle && $bBody && strlen($arFields["BODY"])<=0 && strlen($arFields["TITLE"])<=0)
			{
				//$DB->Commit();
				return 0;
			}

			$arFields["MODULE_ID"] = $MODULE_ID;
			$arFields["ITEM_ID"] = $ITEM_ID;

			if(array_key_exists("INDEX_TITLE", $arFields) && $arFields["INDEX_TITLE"] === false)
				$content = $arFields["BODY"]."\r\n".$arFields["TAGS"];
			else
				$content = $arFields["TITLE"]."\r\n".$arFields["BODY"]."\r\n".$arFields["TAGS"];

			$content = preg_replace ("'&#(\d+);'e", "chr(\\1)", $content);
			$arFields["SEARCHABLE_CONTENT"] = CSearch::KillEntities(ToUpper($content));

			if($SEARCH_SESS_ID!="")
				$arFields["UPD"] = $SEARCH_SESS_ID;

			$ID = CSearch::Add($arFields);

			foreach(GetModuleEvents("search", "OnAfterIndexAdd", true) as $arEvent)
				ExecuteModuleEventEx($arEvent, array($ID, $arFields));

			if(is_set($arFields, "PARAMS"))
				CAllSearch::SetContentItemParams($ID, $arFields["PARAMS"]);

			CAllSearch::SetContentItemGroups($ID, $arGroups);

			foreach($arFields["SITE_ID"] as $site=>$url)
			{
				$strSql = "
					INSERT INTO b_search_content_site(SEARCH_CONTENT_ID, SITE_ID, URL)
					VALUES(".$ID.", '".$DB->ForSql($site, 2)."', '".$DB->ForSql($url, 2000)."')";
				$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			}

			if(
				!array_key_exists("INDEX_TITLE", $arFields)
				|| $arFields["INDEX_TITLE"] !== false
			)
				CSearch::IndexTitle($arFields["SITE_ID"], $ID, $arFields["TITLE"]);

			if (COption::GetOptionString("search", "agent_stemming") === "Y")
				CSearch::DelayStemIndex($ID);
			else
				CSearch::StemIndex($arFields["SITE_ID"], $ID, $arFields["SEARCHABLE_CONTENT"]);

			if(BX_SEARCH_VERSION > 1)
			{
				$text_md5 = md5($arFields["SEARCHABLE_CONTENT"]);
				$arText = array(
					"ID" => 1,
					"SEARCH_CONTENT_ID" => $ID,
					"SEARCH_CONTENT_MD5" => $text_md5,
					"SEARCHABLE_CONTENT" => $arFields["SEARCHABLE_CONTENT"]
				);
				$DB->Add("b_search_content_text", $arText, Array("SEARCHABLE_CONTENT"));
			}

			CSearch::TagsIndex($arFields["SITE_ID"], $ID, $arFields["TAGS"]);

			CSearch::CleanFreqCache($ID);
		}
		//$DB->Commit();

		return $ID;
	}
<?php

define("STOP_STATISTICS", true);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_js.php";
if (CModule::IncludeModule("search")) {
    CUtil::decodeURIComponent($_REQUEST);
    if (!empty($_REQUEST["search"])) {
        $arResult = array();
        $order = CUserOptions::GetOption("search_tags", "order", "CNT");
        if ($_REQUEST["order_by"] == "NAME") {
            $arOrder = array("NAME" => "ASC");
            if ($order != "NAME") {
                CUserOptions::SetOption("search_tags", "order", "NAME");
            }
        } else {
            $arOrder = array("CNT" => "DESC", "NAME" => "ASC");
            if ($order != "CNT") {
                CUserOptions::SetOption("search_tags", "order", "CNT");
            }
        }
        $db_res = CSearchTags::GetList(array("NAME", "CNT"), array("TAG" => $_REQUEST["search"], "SITE_ID" => $_REQUEST["site_id"]), $arOrder, 10);
        if ($db_res) {
            while ($res = $db_res->Fetch()) {
                $arResult[] = array("NAME" => $res["NAME"], "CNT" => $res["CNT"]);
            }
        }
        echo CUtil::PhpToJSObject($arResult);
    }
}
require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog_admin_js.php";
Exemple #7
0
            $arOrder = array("CNT" => "DESC", "NAME" => "ASC");
        }
        $arFilter = array("TAG" => $_POST["search"]);
        if (empty($arParams["site_id"])) {
            $arFilter["SITE_ID"] = SITE_ID;
        } else {
            $arFilter["SITE_ID"] = $arParams["site_id"];
        }
        if (!empty($arParams["mid"])) {
            $arFilter["MODULE_ID"] = $arParams["mid"];
        }
        if (!empty($arParams["pm1"])) {
            $arFilter["PARAM1"] = $arParams["pm1"];
        }
        if (!empty($arParams["pm2"])) {
            $arFilter["PARAM2"] = $arParams["pm2"];
        }
        if (!empty($arParams["sng"])) {
            $arFilter["PARAMS"] = array("socnet_group" => $arParams["sng"]);
        }
        $db_res = CSearchTags::GetList(array("NAME", "CNT"), $arFilter, $arOrder, $arParams["pe"]);
        if ($db_res) {
            while ($res = $db_res->Fetch()) {
                $arResult[] = array("NAME" => $res["NAME"], "CNT" => $res["CNT"]);
            }
        }
        echo CUtil::PhpToJSObject($arResult);
        require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog_after.php";
        die;
    }
}
Exemple #8
0
 public static function CleanCache($arTags = "", $content_id = false)
 {
     if (CACHED_b_search_tags !== false) {
         if ($content_id !== false) {
             $DB = CDatabase::GetModuleConnection('search');
             $rs = $DB->Query("SELECT NAME FROM b_search_tags WHERE SEARCH_CONTENT_ID = " . intval($content_id), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             $arTags = array();
             while ($ar = $rs->Fetch()) {
                 if ($ar["NAME"]) {
                     $arTags[] = $ar["NAME"];
                 }
             }
             CSearchTags::CleanCache($arTags);
         } else {
             if (!is_array($arTags)) {
                 $arTags = array($arTags);
             }
             $arPath = array();
             foreach ($arTags as $tag) {
                 if (strlen($tag) > 0) {
                     $path = "b_search_tags/_" . ord(substr($tag, 0, 1));
                 } else {
                     $path = "b_search_tags";
                 }
                 $arPath[$path] = true;
             }
             global $CACHE_MANAGER;
             foreach ($arPath as $path => $value) {
                 $CACHE_MANAGER->CleanDir($path);
             }
         }
     }
 }