Exemple #1
0
 /**
  * Extract informations
  *
  * @return boolean
  */
 protected static function extract()
 {
     if (self::$host) {
         return true;
     }
     if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] === true)) {
         $scheme = 'https';
     } else {
         $scheme = 'http';
     }
     self::$scheme = $scheme;
     if (isset($_SERVER['HTTP_HOST']) && !empty($_SERVER['HTTP_HOST'])) {
         self::$host = $_SERVER['HTTP_HOST'];
     } elseif (isset($_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'])) {
         $name = $_SERVER['SERVER_NAME'];
         $port = $_SERVER['SERVER_PORT'];
         self::$host = $name;
         self::$port = $port;
     }
     $levels = explode('.', self::$host);
     $count = count($levels);
     self::$domainLevels = array();
     foreach ($levels as $l) {
         self::$domainLevels[$count] = $l;
         $count--;
     }
     return true;
 }
Exemple #2
0
 /**
  * Extract informations
  *
  * @return boolean
  */
 protected static function extract()
 {
     if (self::$host) {
         return true;
     }
     // scheme
     if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] === true)) {
         $scheme = 'https';
     } else {
         $scheme = 'http';
     }
     self::$scheme = $scheme;
     // port
     if (isset($_SERVER['SERVER_PORT']) && !empty($_SERVER['SERVER_PORT'])) {
         $port = $_SERVER['SERVER_PORT'];
     } else {
         $port = 80;
     }
     self::$port = $port;
     // host
     $host = 'Unknown';
     if (isset($_SERVER['HTTP_HOST']) && !empty($_SERVER['HTTP_HOST'])) {
         $host = $_SERVER['HTTP_HOST'];
     } elseif (isset($_SERVER['SERVER_NAME'])) {
         $host = $_SERVER['SERVER_NAME'];
     }
     self::$host = $host;
     $levels = explode('.', self::$host);
     $count = count($levels);
     $tmpHost = str_replace('.', '', self::$host);
     self::$domainLevels = array();
     if (is_numeric($tmpHost)) {
         // hostname is IP address
     } else {
         foreach ($levels as $l) {
             self::$domainLevels[$count] = $l;
             $count--;
         }
     }
     return true;
 }