Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silverstripe 3 fixes #7

Merged
merged 5 commits into from Jun 21, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion _config.php
@@ -1 +0,0 @@
<?php
8 changes: 4 additions & 4 deletions code/Geoip.php
Expand Up @@ -24,7 +24,7 @@ class Geoip {
protected static $iso_3166_countryCodes = array( protected static $iso_3166_countryCodes = array(
'A1' => "Anonymous Proxy", 'A1' => "Anonymous Proxy",
'A2' => "Satellite Provider", 'A2' => "Satellite Provider",
'A3' => "Internal Netwrok", 'A3' => "Internal Network",
'AD' => "Andorra", 'AD' => "Andorra",
'AE' => "United Arab Emirates", 'AE' => "United Arab Emirates",
'AF' => "Afghanistan", 'AF' => "Afghanistan",
Expand Down Expand Up @@ -366,15 +366,15 @@ static function ip2country($address, $codeOnly = false) {
* @return string|bool * @return string|bool
*/ */
static function visitor_country() { static function visitor_country() {
if(ereg('^dev(\\.|$)', $_SERVER['HTTP_HOST']) && isset($_GET['country'])){ if (Director::isDev() && isset($_GET['country'])){
$code = $_GET['country']; $code = $_GET['country'];
} }
else if(isset($_SERVER['REMOTE_ADDR']) && self::is_enabled()) { elseif (isset($_SERVER['REMOTE_ADDR']) && self::is_enabled()) {
$code = Geoip::ip2country($_SERVER['REMOTE_ADDR'], true); $code = Geoip::ip2country($_SERVER['REMOTE_ADDR'], true);
} }


// if geoip fails, lets default to default country code (if any) // if geoip fails, lets default to default country code (if any)
if(!isset($code) || !$code) { if (!isset($code) || !$code) {
$code = self::get_default_country_code(); $code = self::get_default_country_code();
} }


Expand Down
4 changes: 2 additions & 2 deletions composer.json
@@ -1,6 +1,6 @@
{ {
"name": "silverstripe/geoip", "name": "silverstripe/geoip",
"description": "GeoIP module for SivlerStripe.", "description": "GeoIP module for SilverStripe.",
"type": "silverstripe-module", "type": "silverstripe-module",
"keywords": ["silverstripe-labs", "geoip"], "keywords": ["silverstripe-labs", "geoip"],
"authors": [ "authors": [
Expand All @@ -11,6 +11,6 @@
], ],
"require": "require":
{ {
"silverstripe/framework": "2.4.*" "silverstripe/framework": ">=2.4.0"
} }
} }