Example #1
0
 public static function init()
 {
     self::$timestamp = time();
     self::$ssl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on';
     if (isset($_SERVER['REMOTE_ADDR'])) {
         self::$realip = $_SERVER['REMOTE_ADDR'];
         self::$packed_realip = ip::type(self::$realip, self::$realip_type, self::$realip2);
         if (!self::$packed_realip) {
             die('IP Address Error');
         }
         self::$ip = ip::get_ip();
         self::$packed_ip = ip::type(self::$ip, self::$ip_type, self::$ip2);
         if (isset($_SERVER['HTTP_HOST'])) {
             $hosts = explode(':', $_SERVER['HTTP_HOST']);
             $num = count($hosts) - 1;
             if ($hosts[$num] == $_SERVER['SERVER_PORT']) {
                 unset($hosts[$num]);
             }
             $host = implode(':', $hosts);
         } else {
             $host = $_SERVER['SERVER_ADDR'];
         }
         $port = self::$ssl ? $_SERVER['SERVER_PORT'] == 443 ? 0 : $_SERVER['SERVER_PORT'] : ($_SERVER['SERVER_PORT'] == 80 ? 0 : $_SERVER['SERVER_PORT']);
         self::$base_url = 'http' . (self::$ssl ? 's' : '') . '://' . $host . ($port ? ':' . $port : '');
     }
 }