public static function init() { /** * Callback on fatal errors */ register_shutdown_function(function () { return \Lobby::fatalErrorHandler(); }); self::sysinfo(); self::config(); if (isset(self::$config['lobby_url'])) { $url_parts = parse_url(self::$config['lobby_url']); self::$host_name = $url_parts['host']; self::$url = self::$config['lobby_url']; } else { $base_dir = L_DIR; $doc_root = preg_replace("!{$_SERVER['SCRIPT_NAME']}\$!", '', $_SERVER['SCRIPT_FILENAME']); $base_url = preg_replace("!^{$doc_root}!", '', $base_dir); # ex: '' or '/mywebsite' $protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https'; $port = $_SERVER['SERVER_PORT']; $disp_port = $protocol == 'http' && $port == 80 || $protocol == 'https' && $port == 443 ? '' : ":{$port}"; $domain = $_SERVER['SERVER_NAME']; self::$url = "{$protocol}://{$domain}{$disp_port}{$base_url}"; self::$host_name = $domain; } }