403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/components/bitrix/search.page/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/components/bitrix/search.page/component.php
<?php
if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true)
{
	die();
}
/** @global CMain $APPLICATION */
/** @global CUser $USER */
/** @global CDatabase $DB */
/** @var CBitrixComponent $this */
/** @var array $arParams */
/** @var array $arResult */
/** @var string $componentName */
/** @var string $componentPath */
/** @var string $componentTemplate */
/** @var string $parentComponentName */
/** @var string $parentComponentPath */
/** @var string $parentComponentTemplate */
$this->setFrameMode(false);

if (!CModule::IncludeModule('search'))
{
	ShowError(GetMessage('SEARCH_MODULE_UNAVAILABLE'));
	return;
}
CPageOption::SetOptionString('main', 'nav_page_in_session', 'N');

if (!isset($arParams['CACHE_TIME']))
{
	$arParams['CACHE_TIME'] = 3600;
}

// activation rating
CRatingsComponentsMain::GetShowRating($arParams);

$arParams['SHOW_WHEN'] = isset($arParams['SHOW_WHEN']) && $arParams['SHOW_WHEN'] === 'Y';
$arParams['SHOW_WHERE'] = !isset($arParams['SHOW_WHERE']) || $arParams['SHOW_WHERE'] != 'N';
if (!isset($arParams['arrWHERE']) || !is_array($arParams['arrWHERE']))
{
	$arParams['arrWHERE'] = [];
}
$arParams['PAGE_RESULT_COUNT'] = intval($arParams['PAGE_RESULT_COUNT']);
if (!isset($arParams['PAGE_RESULT_COUNT']) || $arParams['PAGE_RESULT_COUNT'] <= 0)
{
	$arParams['PAGE_RESULT_COUNT'] = 50;
}

$arParams['PAGER_TITLE'] = trim($arParams['PAGER_TITLE'] ?? '');
if ($arParams['PAGER_TITLE'] == '')
{
	$arParams['PAGER_TITLE'] = GetMessage('SEARCH_RESULTS');
}
$arParams['PAGER_SHOW_ALWAYS'] = !isset($arParams['PAGER_SHOW_ALWAYS']) || $arParams['PAGER_SHOW_ALWAYS'] != 'N';
$arParams['USE_TITLE_RANK'] = isset($arParams['USE_TITLE_RANK']) && $arParams['USE_TITLE_RANK'] == 'Y';
$arParams['PAGER_TEMPLATE'] = trim($arParams['PAGER_TEMPLATE'] ?? '');

if (!isset($arParams['DEFAULT_SORT']) || $arParams['DEFAULT_SORT'] !== 'date')
{
	$arParams['DEFAULT_SORT'] = 'rank';
}

if (empty($arParams['FILTER_NAME']) || !preg_match('/^[A-Za-z_][A-Za-z01-9_]*$/', $arParams['FILTER_NAME']))
{
	$arFILTERCustom = [];
}
else
{
	$arFILTERCustom = $GLOBALS[$arParams['FILTER_NAME']] ?? [];
	if (!is_array($arFILTERCustom))
	{
		$arFILTERCustom = [];
	}
}

$exFILTER = CSearchParameters::ConvertParamsToFilter($arParams, 'arrFILTER');

$arParams['CHECK_DATES'] = $arParams['CHECK_DATES'] == 'Y';

//options
if (isset($_REQUEST['tags']))
{
	$tags = trim($_REQUEST['tags']);
}
else
{
	$tags = false;
}
if (isset($_REQUEST['q']))
{
	$q = trim($_REQUEST['q']);
}
else
{
	$q = false;
}

if (
	$arParams['SHOW_WHEN']
	&& isset($_REQUEST['from'])
	&& is_string($_REQUEST['from'])
	&& mb_strlen($_REQUEST['from'])
	&& CheckDateTime($_REQUEST['from'])
)
{
	$from = $_REQUEST['from'];
}
else
{
	$from = '';
}

if (
	$arParams['SHOW_WHEN']
	&& isset($_REQUEST['to'])
	&& is_string($_REQUEST['to'])
	&& mb_strlen($_REQUEST['to'])
	&& CheckDateTime($_REQUEST['to'])
)
{
	$to = $_REQUEST['to'];
}
else
{
	$to = '';
}

$where = $arParams['SHOW_WHERE'] ? trim($_REQUEST['where'] ?? '') : '';

$how = trim($_REQUEST['how'] ?? '');
if ($how == 'd')
{
	$how = 'd';
}
elseif ($how == 'r')
{
	$how = '';
}
elseif ($arParams['DEFAULT_SORT'] == 'date')
{
	$how = 'd';
}
else
{
	$how = '';
}

if ($arParams['USE_TITLE_RANK'])
{
	if ($how == 'd')
	{
		$aSort = ['DATE_CHANGE' => 'DESC', 'CUSTOM_RANK' => 'DESC', 'TITLE_RANK' => 'DESC', 'RANK' => 'DESC'];
	}
	else
	{
		$aSort = ['CUSTOM_RANK' => 'DESC', 'TITLE_RANK' => 'DESC', 'RANK' => 'DESC', 'DATE_CHANGE' => 'DESC'];
	}
}
else
{
	if ($how == 'd')
	{
		$aSort = ['DATE_CHANGE' => 'DESC', 'CUSTOM_RANK' => 'DESC', 'RANK' => 'DESC'];
	}
	else
	{
		$aSort = ['CUSTOM_RANK' => 'DESC', 'RANK' => 'DESC', 'DATE_CHANGE' => 'DESC'];
	}
}
/*************************************************************************
			Operations with cache
*************************************************************************/
$arrDropdown = [];

$obCache = new CPHPCache;

if (
	$arParams['CACHE_TYPE'] == 'N'
	|| (
		$arParams['CACHE_TYPE'] == 'A'
		&& COption::GetOptionString('main', 'component_cache_on', 'Y') == 'N'
	)
)
{
	$arParams['CACHE_TIME'] = 0;
}

if ($obCache->StartDataCache($arParams['CACHE_TIME'], $this->GetCacheID(), '/' . SITE_ID . $this->GetRelativePath()))
{
	// Getting of the Information block types
	$arIBlockTypes = [];
	if (CModule::IncludeModule('iblock'))
	{
		$rsIBlockType = CIBlockType::GetList(['sort' => 'asc'], ['ACTIVE' => 'Y']);
		while ($arIBlockType = $rsIBlockType->Fetch())
		{
			if ($ar = CIBlockType::GetByIDLang($arIBlockType['ID'], LANGUAGE_ID))
			{
				$arIBlockTypes[$arIBlockType['ID']] = $ar['~NAME'];
			}
		}
	}

	// Creating of an array for drop-down list
	foreach ($arParams['arrWHERE'] as $code)
	{
		$parts = explode('_', $code, 2);
		$module_id = $parts[0] ?? '';
		$part_id = $parts[1] ?? '';

		if (!empty($module_id))
		{
			if ($part_id == '')
			{
				switch ($module_id)
				{
					case 'forum':
						$arrDropdown[$code] = GetMessage('SEARCH_FORUM');
						break;
					case 'blog':
						$arrDropdown[$code] = GetMessage('SEARCH_BLOG');
						break;
					case 'socialnetwork':
						$arrDropdown[$code] = GetMessage('SEARCH_SOCIALNETWORK');
						break;
					case 'intranet':
						$arrDropdown[$code] = GetMessage('SEARCH_INTRANET');
						break;
					case 'crm':
						$arrDropdown[$code] = GetMessage('SEARCH_CRM');
						break;
					case 'disk':
						$arrDropdown[$code] = GetMessage('SEARCH_DISK');
						break;
				}
			}
			else
			{
				// if there is additional information specified besides ID then
				switch ($module_id)
				{
					case 'iblock':
						if (isset($arIBlockTypes[$part_id]))
						{
							$arrDropdown[$code] = $arIBlockTypes[$part_id];
						}
						break;
				}
			}
		}
	}
	$obCache->EndDataCache($arrDropdown);
}
else
{
	$arrDropdown = $obCache->GetVars();
}

$arResult['DROPDOWN'] = htmlspecialcharsex($arrDropdown);
$arResult['REQUEST']['HOW'] = htmlspecialcharsbx($how);
$arResult['REQUEST']['~FROM'] = $from;
$arResult['REQUEST']['FROM'] = htmlspecialcharsbx($from);
$arResult['REQUEST']['~TO'] = $to;
$arResult['REQUEST']['TO'] = htmlspecialcharsbx($to);

if ($q !== false)
{
	if ((isset($arParams['USE_LANGUAGE_GUESS']) && $arParams['USE_LANGUAGE_GUESS'] == 'N') || isset($_REQUEST['spell']))
	{
		$arResult['REQUEST']['~QUERY'] = $q;
		$arResult['REQUEST']['QUERY'] = htmlspecialcharsex($q);
	}
	else
	{
		$arLang = CSearchLanguage::GuessLanguage($q);
		if (is_array($arLang) && $arLang['from'] != $arLang['to'])
		{
			$arResult['REQUEST']['~ORIGINAL_QUERY'] = $q;
			$arResult['REQUEST']['ORIGINAL_QUERY'] = htmlspecialcharsex($q);

			$arResult['REQUEST']['~QUERY'] = CSearchLanguage::ConvertKeyboardLayout($arResult['REQUEST']['~ORIGINAL_QUERY'], $arLang['from'], $arLang['to']);
			$arResult['REQUEST']['QUERY'] = htmlspecialcharsex($arResult['REQUEST']['~QUERY']);
		}
		else
		{
			$arResult['REQUEST']['~QUERY'] = $q;
			$arResult['REQUEST']['QUERY'] = htmlspecialcharsex($q);
		}
	}
}
else
{
	$arResult['REQUEST']['~QUERY'] = false;
	$arResult['REQUEST']['QUERY'] = false;
}

if ($tags !== false)
{
	$arResult['REQUEST']['~TAGS_ARRAY'] = [];
	$arTags = explode(',', $tags);
	foreach ($arTags as $tag)
	{
		$tag = trim($tag);
		if ($tag <> '')
		{
			$arResult['REQUEST']['~TAGS_ARRAY'][$tag] = $tag;
		}
	}
	$arResult['REQUEST']['TAGS_ARRAY'] = htmlspecialcharsex($arResult['REQUEST']['~TAGS_ARRAY']);
	$arResult['REQUEST']['~TAGS'] = implode(',', $arResult['REQUEST']['~TAGS_ARRAY']);
	$arResult['REQUEST']['TAGS'] = htmlspecialcharsex($arResult['REQUEST']['~TAGS']);
}
else
{
	$arResult['REQUEST']['~TAGS_ARRAY'] = [];
	$arResult['REQUEST']['TAGS_ARRAY'] = [];
	$arResult['REQUEST']['~TAGS'] = false;
	$arResult['REQUEST']['TAGS'] = false;
}
$arResult['REQUEST']['WHERE'] = htmlspecialcharsbx($where);

$arResult['URL'] = $APPLICATION->GetCurPage()
	. '?q=' . urlencode($q)
	. (isset($_REQUEST['spell']) ? '&amp;spell=1' : '')
	. '&amp;where=' . urlencode($where)
	. ($tags !== false ? '&amp;tags=' . urlencode($tags) : '')
;

if (isset($arResult['REQUEST']['~ORIGINAL_QUERY']))
{
	$arResult['ORIGINAL_QUERY_URL'] = $APPLICATION->GetCurPage()
		. '?q=' . urlencode($arResult['REQUEST']['~ORIGINAL_QUERY'])
		. '&amp;spell=1'
		. '&amp;where=' . urlencode($arResult['REQUEST']['WHERE'])
		. ($arResult['REQUEST']['HOW'] == 'd' ? '&amp;how=d' : '')
		. ($arResult['REQUEST']['FROM'] ? '&amp;from=' . urlencode($arResult['REQUEST']['~FROM']) : '')
		. ($arResult['REQUEST']['TO'] ? '&amp;to=' . urlencode($arResult['REQUEST']['~TO']) : '')
		. ($tags !== false ? '&amp;tags=' . urlencode($tags) : '')
	;
}

$templatePage = '';
$arReturn = false;
if ($this->InitComponentTemplate($templatePage))
{
	$template = &$this->GetTemplate();
	$arResult['FOLDER_PATH'] = $folderPath = $template->GetFolder();

	if ($folderPath <> '')
	{
		$arFilter = [
			'SITE_ID' => SITE_ID,
			'QUERY' => $arResult['REQUEST']['~QUERY'],
			'TAGS' => $arResult['REQUEST']['~TAGS'],
		];
		$arFilter = array_merge($arFILTERCustom, $arFilter);
		if ($where <> '')
		{
			list($module_id, $part_id) = explode('_',$where,2);
			$arFilter['MODULE_ID'] = $module_id;
			if ($part_id <> '')
			{
				$arFilter['PARAM1'] = $part_id;
			}
		}
		if ($arParams['CHECK_DATES'])
		{
			$arFilter['CHECK_DATES'] = 'Y';
		}
		if ($from)
		{
			$arFilter['>=DATE_CHANGE'] = $from;
		}
		if ($to)
		{
			$arFilter['<=DATE_CHANGE'] = $to;
		}

		$obSearch = new CSearch();

		//When restart option is set we will ignore error on query with only stop words
		$obSearch->SetOptions([
			'ERROR_ON_EMPTY_STEM' => $arParams['RESTART'] != 'Y',
			'NO_WORD_LOGIC' => isset($arParams['NO_WORD_LOGIC']) && $arParams['NO_WORD_LOGIC'] == 'Y',
		]);

		$obSearch->Search($arFilter, $aSort, $exFILTER);

		$arResult['ERROR_CODE'] = $obSearch->errorno;
		$arResult['ERROR_TEXT'] = $obSearch->error;

		$arResult['SEARCH'] = [];
		if ($obSearch->errorno == 0)
		{
			$obSearch->NavStart($arParams['PAGE_RESULT_COUNT'], false);
			$ar = $obSearch->GetNext();
			//Search restart
			if (!$ar && ($arParams['RESTART'] == 'Y') && $obSearch->Query->bStemming)
			{
				$exFILTER['STEMMING'] = false;
				$obSearch = new CSearch();
				$obSearch->Search($arFilter, $aSort, $exFILTER);

				$arResult['ERROR_CODE'] = $obSearch->errorno;
				$arResult['ERROR_TEXT'] = $obSearch->error;

				if ($obSearch->errorno == 0)
				{
					$obSearch->NavStart($arParams['PAGE_RESULT_COUNT'], false);
					$ar = $obSearch->GetNext();
				}
			}

			$arReturn = [];
			while ($ar)
			{
				$arReturn[$ar['ID']] = $ar['ITEM_ID'];
				$ar['CHAIN_PATH'] = $APPLICATION->GetNavChain($ar['URL'], 0, $folderPath . '/chain_template.php', true, false);
				$ar['URL'] = htmlspecialcharsbx($ar['URL']);
				$ar['TAGS'] = [];
				if (!empty($ar['~TAGS_FORMATED']))
				{
					foreach ($ar['~TAGS_FORMATED'] as $name => $tag)
					{
						if ($arParams['TAGS_INHERIT'] == 'Y')
						{
							$arTags = $arResult['REQUEST']['~TAGS_ARRAY'];
							$arTags[$tag] = $tag;
							$tags = implode(',' , $arTags);
						}
						else
						{
							$tags = $tag;
						}
						$ar['TAGS'][] = [
							'URL' => $APPLICATION->GetCurPageParam('tags=' . urlencode($tags), ['tags']),
							'TAG_NAME' => htmlspecialcharsex($name),
						];
					}
				}
				$arResult['SEARCH'][] = $ar;
				$ar = $obSearch->GetNext();
			}

			$navComponentObject = null;
			$arResult['NAV_STRING'] = $obSearch->GetPageNavStringEx($navComponentObject,  $arParams['PAGER_TITLE'], $arParams['PAGER_TEMPLATE'], $arParams['PAGER_SHOW_ALWAYS']);
			$arResult['NAV_CACHED_DATA'] = $navComponentObject->GetTemplateCachedData();
			$arResult['NAV_RESULT'] = $obSearch;
		}

		$arResult['TAGS_CHAIN'] = [];
		$url = [];
		foreach ($arResult['REQUEST']['~TAGS_ARRAY'] as $key => $tag)
		{
			$url_without = $arResult['REQUEST']['~TAGS_ARRAY'];
			unset($url_without[$key]);
			$url[$tag] = $tag;
			$result = [
				'TAG_NAME' => $tag,
				'TAG_PATH' => $APPLICATION->GetCurPageParam('tags=' . urlencode(implode(',', $url)), ['tags']),
				'TAG_WITHOUT' => $APPLICATION->GetCurPageParam('tags=' . urlencode(implode(',', $url_without)), ['tags']),
			];
			$arResult['TAGS_CHAIN'][] = $result;
		}

		$this->ShowComponentTemplate();
	}
}
else
{
	$this->__ShowError(str_replace('#PAGE#', $templatePage, str_replace('#NAME#', $this->__templateName, "Can not find '#NAME#' template with page '#PAGE#'")));
}
return $arReturn;

Youez - 2016 - github.com/yon3zu
LinuXploit