Recently, I wrote about geolocalisation of your users/visitors based on the IP to Country table. After using it for a couple of months, I found it painful to have to regularly update the table (even if some people came up with an automatic work around based on PERL scripts for example).
So, I decided to find another way to solve the problem and gave the GeoIP Apache module by MaxMind a try. The installation is as simple as can be:
aptitude install libapache2-mod-geoip
Once the module is setup, you can use the following PHP code to obtain the Country Code (2 letters)
$countryCode == $_SERVER["GEOIP_COUNTRY_CODE"];
Finally, here is a list of country codes and the associated country names.
That’s it, quick and simple.