Free Tools
How does the IP address lookup tool work?
The IP Address Lookup page uses a free database provided by MaxMind. This database takes an IP address and gives geographic information about the IP address.
We use PHP and PEAR to use MaxMind's free database. You can download the database at MaxMind's website here. Once you have the database, you need to install the PEAR package that allows you to use the database:
# Because this PEAR package is considered "beta" quality, you # need to specify the full version in order to install it. pear install Net_GeoIP-1.0.0RC2
Once the PEAR package is installed, you can use it in PHP like this:
/* This code is public domain */ /* Source: http://ipaddr.es */ // First you need to include the GeoIP PEAR package require_once('Net/GeoIP.php'); // Next, you instantiate a Net_GeoIP object. // Make sure you point this at your GeoLiteCity.dat file! $geoip = Net_GeoIP::getInstance("GeoLiteCity.dat"); // Last, pass in an IP address. In this example, we are // passing in the visitor's IP. $location = $geoip->lookupLocation($_SERVER['REMOTE_ADDR']); /* Available Data */ // echo $location->VARIABLE; // EXAMPLE OUTPUT echo $location->countryCode; // US echo $location->countryCode3; // USA echo $location->countryName; // United States echo $location->region; // VA echo $location->city; // Williamsburg echo $location->postalCode; // 23185 echo $location->latitude; // 37.2438 echo $location->longitude; // -76.7276 echo $location->dmaCode; // 544 echo $location->areaCode; // 757
To display the map, we use Google's Maps API. Once you get an API key (free), you can insert a map into your own page by looking at an example page at Google.
Last updated: December 20, 2014 (3:55 PM GMT)