AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.16.207.140
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/ui/lib/Fonts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/bitrix/www/bitrix/modules/ui/lib/Fonts/Proxy.php
<?php
namespace Bitrix\UI\Fonts;

use Bitrix\Main;
use CBitrix24;

/**
 * Class Proxy
 * @package Bitrix\UI\Fonts
 */
class Proxy
{
	private static array $sourceDomains = [
		'fonts.googleapis.com',
	];

	private static array $map = [
		'en' => '.bitrix24.com',
		'de' => '.bitrix24.de',
		'fr' => '.bitrix24.fr',
		'it' => '.bitrix24.it',
		'pl' => '.bitrix24.pl',
		'uk' => '.bitrix24.uk',
		'eu' => '.bitrix24.eu',
		'ua' => '.bitrix24.ua',
		'tr' => '.bitrix24.com.tr',
		'br' => '.bitrix24.com.br',
		'ru' => '.bitrix24.ru',
		'la' => '.bitrix24.es',
		'kz' => '.bitrix24.kz',
		'by' => '.bitrix24.by',
		'jp' => '.bitrix24.jp',
		'cn' => '.bitrix24.cn',
	];

	/**
	 * Get font proxy uri by real uri.
	 *
	 * @param string $fontUri Font uri.
	 * @param string|null $region Region.
	 * @return string
	 * @throws Main\LoaderException
	 */
	public static function makeUri(string $fontUri, ?string $region = null): string
	{
		$uri = new Main\Web\Uri($fontUri);
		$domain = self::getMap($region)[$uri->getHost()] ?? null;
		if (!$domain)
		{
			return $fontUri;
		}

		return 'https://' . $domain . $uri->getPathQuery();
	}

	/**
	 * Get domain of fonts proxy-server.
	 *
	 * @param string|null $region Region.
	 * @return string
	 * @throws Main\LoaderException
	 */
	public static function resolveDomain(?string $region = null): string
	{
		$domain = null;
		
		$region = $region ?: Main\Application::getInstance()->getLicense()->getRegion();
		if (Main\Loader::includeModule('bitrix24'))
		{
			$domain = CBitrix24::getAreaConfig($region)['DEFAULT_DOMAIN'] ?? null;
		}
		
		if (!$domain)
		{
			$domain = self::$map[$region] ?? self::$map['en'];
		}

		return "fonts{$domain}";
	}

	/**
	 * Get map of domains.
	 * [Original domain => Proxy domain]
	 *
	 * @param string|null $region Region.
	 * @return array
	 * @throws Main\LoaderException
	 */
	public static function getMap(?string $region = null): array
	{
		$map = [];
		$targetDomain = self::resolveDomain($region);
		foreach (self::$sourceDomains as $sourceDomain)
		{
			$map[$sourceDomain] = $targetDomain;
		}

		return $map;
	}
}


Anon7 - 2022
AnonSec Team