AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 18.216.5.226
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/bitrix/www/bitrix/modules/main/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/bitrix/www/bitrix/modules/main/lib//httpcontext.php
<?php

namespace Bitrix\Main;

use Bitrix\Main\Config;
use Bitrix\Main\Localization;

/**
 * Class HttpContext extends Context with http specific methods.
 * @package Bitrix\Main
 */
class HttpContext extends Context
{
	public const CACHE_TTL = 86400;

	/**
	 * Creates new instance of context.
	 *
	 * @param HttpApplication $application
	 */
	public function __construct(HttpApplication $application)
	{
		parent::__construct($application);
	}

	public function rewriteUri($url, $queryString, $redirectStatus = null)
	{
		$request = $this->request;
		$request->modifyByQueryString($queryString);

		$this->server->rewriteUri($url, $queryString, $redirectStatus);
	}

	public function transferUri($url, $queryString)
	{
		$request = $this->request;
		$request->modifyByQueryString($queryString);

		$this->server->transferUri($url, $queryString);
	}

	/**
	 * @param string | null $definedSite
	 * @param string | null $definedLanguage
	 * @return void
	 * @throws SystemException
	 */
	public function initializeCulture($definedSite = null, $definedLanguage = null): void
	{
		$request = $this->getRequest();

		$language = null;
		$culture = null;
		$site = null;

		if ($definedSite === null && $request->isAdminSection())
		{
			$lang = $request->get('lang');
			if ($lang == '')
			{
				$lang = Config\Option::get('main', 'admin_lid', 'ru');
			}

			if ($lang != '')
			{
				$language = Localization\LanguageTable::getList([
					'filter' => ['=LID' => $lang, '=ACTIVE' => 'Y'],
					'cache' => ['ttl' => static::CACHE_TTL],
				])->fetchObject();
			}

			if (!$language)
			{
				// no language found - get default
				$language = Localization\LanguageTable::getList([
					'filter' => ['=ACTIVE' => 'Y'],
					'order' => ['DEF' => 'DESC'],
					'cache' => ['ttl' => static::CACHE_TTL],
				])->fetchObject();
			}

			if ($language)
			{
				$culture = Localization\CultureTable::getByPrimary($language->getCultureId(), ['cache' => ['ttl' => static::CACHE_TTL]])->fetchObject();
			}
		}
		else
		{
			if ($definedSite !== null)
			{
				$site = SiteTable::getByPrimary($definedSite, ['cache' => ['ttl' => static::CACHE_TTL]])->fetch();
				if (!$site)
				{
					throw new SystemException('Incorrect site: ' . $definedSite . '.');
				}
			}
			else
			{
				// get the site by domain or path
				$site = SiteTable::getByDomain($request->getHttpHost(), $request->getRequestedPageDirectory());
			}

			if ($site)
			{
				$languageId = $definedLanguage ?? $site['LANGUAGE_ID'];
				$language = Localization\LanguageTable::getByPrimary($languageId, ['cache' => ['ttl' => static::CACHE_TTL]])->fetchObject();

				$culture = Localization\CultureTable::getByPrimary($site['CULTURE_ID'], ['cache' => ['ttl' => static::CACHE_TTL]])->fetchObject();
			}
		}

		if ($culture === null || $language === null)
		{
			throw new SystemException("Culture not found, or there are no active sites or languages.");
		}

		$this->setLanguage($language);
		$this->setCulture($culture);

		if ($site)
		{
			$this->setSite(SiteTable::wakeUpObject($site));
		}
	}
}

Anon7 - 2022
AnonSec Team