HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.52.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 15 06:39:08 EDT 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/barbeatleanalyti/public_html/public_html/webmail/system/Application.php
<?php
/*
 * This code is licensed under AGPLv3 license or Afterlogic Software License
 * if commercial version of the product was purchased.
 * For full statements of the licenses see LICENSE-AFTERLOGIC and LICENSE-AGPL3 files.
 */

namespace Aurora\System;

/**
 * @license https://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
 * @license https://afterlogic.com/products/common-licensing Afterlogic Software License
 * @copyright Copyright (c) 2018, Afterlogic Corp.
 *
 * @category Core
 */
class Application
{
	/**
	 * @type string
	 */
	const AUTH_TOKEN_KEY = 'AuthToken';
	
	/**
	 * @var \Aurora\System\Module\Manager
	 */
	protected $oModuleManager;

	/**
	 * @return void
	 */
	protected function __construct()
	{
		$this->oModuleManager = Api::GetModuleManager();

//		\MailSo\Config::$FixIconvByMbstring = false;
		\MailSo\Config::$SystemLogger = Api::SystemLogger();
	}

	/**
	 * @return \Aurora\System\Application
	 */
	public static function NewInstance()
	{
		return new self();
	}
	
	/**
	 * @return \Aurora\System\Application
	 */
	public static function SingletonInstance()
	{
		static $oInstance = null;
		if (null === $oInstance)
		{
			$oInstance = self::NewInstance();
		}

		return $oInstance;
	}
	
	public static function DebugMode($bDebug)
	{
		Api::$bDebug = $bDebug;
	}
	
	public static function UseDbLogs()
	{
		Api::$bUseDbLog = true;
	}
	
	public static function Start($sDefaultEntry = 'default')
	{
		try
		{
			Api::Init();
		}
		catch (\Aurora\System\Exceptions\ApiException $oEx)
		{
			\Aurora\System\Api::LogException($oEx);
		}
		
		self::RedirectToHttps();
		self::GetVersion();

		$mResult = self::SingletonInstance()->oModuleManager->RunEntry(
			\strtolower(self::GetPathItemByIndex(0, $sDefaultEntry))
		);
		if (\MailSo\Base\Http::SingletonInstance()->GetRequest('Format') !== 'Raw')
		{
			echo $mResult;
		}
		else
		{
			return $mResult;
		}
	}

	/**
	 * @return string
	 */
	public static function GetVersion()
	{
		$sVersion = @\file_get_contents(AU_APP_ROOT_PATH.'VERSION');
		\define('AU_APP_VERSION', $sVersion);
		return $sVersion;
	}
	
	public static function RedirectToHttps()
	{
		$oSettings =& Api::GetSettings();
		if ($oSettings)
		{
			$bRedirectToHttps = $oSettings->RedirectToHttps;

			$bHttps = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== "off") || 
					(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == "443"));
			if ($bRedirectToHttps && !$bHttps) 
			{
				\header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
			}
		}
	}
	
	/**
	 * @return array
	 */
	public static function GetPaths()
	{
		return Router::getItems();
	}
	
	/**
	 * 
	 * @param int $iIndex
	 */
	public static function GetPathItemByIndex($iIndex, $mDefaultValue = null)
	{
		return Router::getItemByIndex($iIndex, $mDefaultValue);
	}
}