Created
November 20, 2013 03:49
-
-
Save CrBoy/7557403 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$keys = ['REMOTE_ADDR', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR']; | |
foreach ($keys as $key) { | |
$ip = $_SERVER[$key]; | |
echo $key . ' = ' . $ip; | |
if ($ip != ''){ | |
$location = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip)); | |
if($location){ | |
echo ' (' . $location->geoplugin_city . ', ' . $location->geoplugin_countryName . ')'; | |
} | |
} | |
echo '<br>' . PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment