Esempio n. 1
0
 /**
  * Returns the country code, for the current visitor
  */
 static function visitor_country()
 {
     if (ereg('^dev(\\.|$)', $_SERVER['HTTP_HOST']) && isset($_GET['country'])) {
         return $_GET['country'];
     } else {
         return Geoip::ip2country($_SERVER['REMOTE_ADDR'], true);
     }
 }
Esempio n. 2
0
 /**
  * Returns the country code, for the current visitor
  *
  * @return string|bool
  */
 static function visitor_country()
 {
     if (Director::isDev() && isset($_GET['country'])) {
         $code = $_GET['country'];
     } elseif (isset($_SERVER['REMOTE_ADDR']) && self::is_enabled()) {
         $code = Geoip::ip2country($_SERVER['REMOTE_ADDR'], true);
     }
     // if geoip fails, lets default to default country code (if any)
     if (!isset($code) || !$code) {
         $code = self::get_default_country_code();
     }
     return $code ? $code : false;
 }