Show the User what he wants, with IP based locating
February 2, 2010

Wouldn’t it be nice, if you were going to the Amazee Frontpage and you see all of your friends who are already on Amazee and those from the same City or Country as you?
We’d also like that, but: How do we get the Country or even the City the User is from?
This is possible by the IP Adress, because every IP defines from which InternetServiceProvider it comes and also in which City this ISP is providing his service.
So we only need to match the IP with the list of every ISP in the world, et voilà!
For these lists there are two possibilities:
1. Sync your database with a Regional Internet Registries (RIR)
There are five big Regional Internet Registries, from where you can get lists [1] of all IP Adresses and country codes. These lists can be synched with your database and on every request we can query the Database.
But: This isn’t really nice, and if you have a lot of Page Impressions your Database won’t be very happy with it. And even there is no possibility to load the City from these RIR Lists.
If you are still interested here is a Drupal Module for this: [2]
So as I said, there is an other possibility:
2. MaxMind GeoLite City with PHP PECL Extension
MaxMind is a company which provides location technology via IP addresses. There are licence models, but also an OpenSource database!
It is possible to query the Website from MaxMind directly or with a local Database, which can be requested via a lot of different APIs [3]. There is one with a PHP PECL Extension [4], which wraps around the GeoIP C Library [5]. This library is very very fast! MaxMind says we can query over 22k request per second for cities [6], and this is exactly what we are searching for, right?
After enabling this PECL Extension in PHP we can query different informations about the user via these functions: http://www.php.net/manual/en/ref.geoip.php
So with these API we can very quickly detect the Country and City from which the User requests the Amazee Website and show the User what he wants:
The people from his City and Country!
We will implement this feature in the next release. Stay tuned for next month!


