示例#1
0
文件: Lobby.php 项目: LobbyOS/server
 /**
  * Get/Make the Lobby base URL
  */
 public static function getURL()
 {
     if (self::$url !== null) {
         return self::$url;
     }
     if (self::$cli) {
         return null;
     }
     if (isset(self::$config['lobby_url'])) {
         $url_parts = parse_url(self::$config['lobby_url']);
         self::$hostname = $url_parts['host'];
         self::$url = self::$config['lobby_url'];
     } else {
         $docDir = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
         $subdir = str_replace($docDir, '', L_DIR);
         $urladdr = $_SERVER['HTTP_HOST'] . $subdir;
         $urladdr = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://" . $urladdr;
         self::$url = rtrim($urladdr, "/");
         self::$host = $_SERVER['SERVER_NAME'] . (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] != "80" ? ":{$_SERVER['SERVER_PORT']}" : "");
         self::$hostname = $_SERVER['SERVER_NAME'];
     }
     return self::$url;
 }