Пример #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;
 }
Пример #2
0
 public function direct($ssl)
 {
     $toScheme = $ssl ? 'https' : 'http';
     $scheme = Zmz_Host::getScheme();
     if ($scheme != $toScheme) {
         $request = $this->getRequest();
         $url = Zmz_Host::buildUrl(Zmz_Host::getHostname(), $toScheme, Zmz_Host::getPort());
         $url .= $request->getRequestUri();
         $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
         $redirector->gotoUrl($url);
     }
 }
Пример #3
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;
 }
Пример #4
0
 /**
  *
  * @return string $timezone
  */
 public static function findTimezone()
 {
     $locale = self::getLocale();
     if (!$locale->getRegion()) {
         try {
             $locale = new Zend_Locale($locale . '_' . strtoupper($locale));
         } catch (Exception $e) {
         }
     }
     $region = $locale->getRegion();
     if ($region) {
         $timezoneList = Zend_Locale::getTranslationList('TimezoneToTerritory');
         if (isset($timezoneList[$region])) {
             $timezone = $timezoneList[$region];
             return $timezone;
         }
     }
     $httpCookieObject = new Zend_Http_Cookie('timezone', null, Zmz_Host::getHostname());
     $cookie = new Zmz_Cookie($httpCookieObject);
     $timezoneCookieValue = $cookie->getValue();
     $timezoneArray = @explode('/', $timezoneCookieValue);
     // check valid cookie
     if (isset($timezoneArray[0]) && isset($timezoneArray[1])) {
         $offset = intval($timezoneArray[0]);
         $dts = intval($timezoneArray[1]);
         $guessedTimezone = timezone_name_from_abbr('', $offset, $dts);
         try {
             $tz = new DateTimeZone($guessedTimezone);
             $guessedLocation = $tz->getLocation();
             //                $guessedLocationCode = $guessedLocation['country_code'];
             $timezone = $guessedTimezone;
         } catch (Exception $e) {
             $timezone = self::$defaultTimezone;
         }
     } else {
         $timezone = self::$defaultTimezone;
     }
     return $timezone;
 }
Пример #5
0
 public static function getHostname()
 {
     $hostname = Zmz_Host::getHostname();
     return $hostname;
 }
Пример #6
0
 public function direct($default = null)
 {
     return Zmz_Host::getReferer($default);
 }