• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/common.php
  • Класс: BitrixImOpenLinesCommon
  • Вызов: Common::getServerAddress
static function getServerAddress(): string
{
	$publicUrl = Option::get('imopenlines', 'portal_url');

	if (empty($publicUrl))
	{
		$context = Application::getInstance()->getContext();
		$scheme = $context->getRequest()->isHttps() ? 'https' : 'http';
		$server = $context->getServer();
		$domain = Option::get('main', 'server_name', '');
		if (empty($domain))
		{
			$domain = $server->getServerName();
		}
		if (preg_match('/^(?.+):(?d+)$/', $domain, $matches))
		{
			$domain = $matches['domain'];
			$port = (int)$matches['port'];
		}
		else
		{
			$port = (int)$server->getServerPort();
		}
		$port = in_array($port, [0, 80, 443]) ? '' : ':'.$port;

		$publicUrl = $scheme.'://'.$domain.$port;
	}
	if (!(mb_strpos($publicUrl, 'https://') === 0 || mb_strpos($publicUrl, 'http://') === 0))
	{
		$publicUrl = 'https://' . $publicUrl;
	}

	return $publicUrl;
}