Skip to content

Instantly share code, notes, and snippets.

@musoftware
Created March 4, 2014 22:29
Show Gist options
  • Save musoftware/e445bf6a5a7a6f0a3b25 to your computer and use it in GitHub Desktop.
Save musoftware/e445bf6a5a7a6f0a3b25 to your computer and use it in GitHub Desktop.
visitor_country
<?php
function visitor_country() {
$ip = $this->getRealIpAddr();
$ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip));
if ($ip_data && $ip_data->geoplugin_countryName != null) {
$result = $ip_data->geoplugin_countryName;
return $result;
} else {
return 'Un Known';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment