diff --git a/geo/config.php b/geo/config.php index 3ef8447..6f3bcb5 100644 --- a/geo/config.php +++ b/geo/config.php @@ -3,6 +3,7 @@ return array( // This is the IP address used if in devMode or visiting your site // from the local computer to the server. - "defaultIp"=>"190.93.246.7", + "defaultIp"=>"190.93.246.7", // Costa Rica + // "defaultIp"=>"92.111.6.18", Netherland no city or region "cacheTime"=>"43200" //seconds ); \ No newline at end of file diff --git a/geo/services/Geo_LocationService.php b/geo/services/Geo_LocationService.php index 326a721..d2f5ee2 100644 --- a/geo/services/Geo_LocationService.php +++ b/geo/services/Geo_LocationService.php @@ -76,14 +76,25 @@ private function getNekudoData($ip){ $data = json_decode($response->getBody()); + if(isset($data->subdivisions[0])){ + $regionName = $data->subdivisions[0]->names->en; + }else{ + $regionName = ""; + } + + if(isset($data->city)){ + $city = $data->city->names->en; + }else{ + $city = ""; + } $data = array( "ip"=>$data->traits->ip_address, "country_code"=>$data->country->iso_code, "country_name"=>$data->country->names->en, - "region_name"=>$data->subdivisions[0]->names->en, + "region_name"=>$regionName, // Yes i know, i am not getting postcode etc yet. - "city"=>$data->city->names->en, + "city"=>$city, "latitude"=>$data->location->latitude, "longitude"=>$data->location->longitude, "cached"=>false