Created
December 6, 2011 14:30
-
-
Save speedupmate/1438377 to your computer and use it in GitHub Desktop.
GeoIp test
This file contains 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 | |
/** | |
* PUT THE PATH TO GEOIP DATABASE HERE | |
*/ | |
$database ='geoip/GeoLiteCity.dat'; | |
try { | |
require_once('Net/GeoIP.php'); | |
$ipaddress = $_SERVER['REMOTE_ADDR']; | |
$database = $database; | |
$geoip = Net_GeoIP::getInstance($database); | |
$location = $geoip->lookupLocation($ipaddress); | |
/** | |
* IF PEAR NET_GEOIP IS INSTALLED AND PHP CAN ACCESS THIS THEN YOU WILL SEE YOUR COUNTRY CODE DETECTED IF NOT THEN YOU SEE ERRORS INSTEAD | |
*/ | |
echo $location->countryCode.' > CONGRATS IT IS ENABLED'; | |
} catch (Exception $e) { | |
print_r($e->getMessage()); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment