/** * 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); } }
/** * 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; }