A few threads have recently come up (again) about geolocation ( geoip ), so I thought I'd give a few pointers and an example of how easy it is.
First off, maxmind's geoip database is probably the best option as it's free.
However, it requires installation, which isn't easy and if you want to query specific IP addresses, you can't use the apache module. So you end up using the PHP or Perl modules, which are *really* frikken slow.
So, for those not wanting to go that route, geoplugin.com has a webservice that uses Maxmind's data (the free database for the webservice as maxmind refuse to allow their paid database for direct external IP lookups).
This webservice is a bit better than simply using the maxmind geoip db as it also returns data on nearby places to a location and a currency converter.
To use geoplugin, there's a really
easy to use PHP class, that even the brain-dead person can add to their pages.
Someone recently asked about GeoIP adverts for their dating site.
If anyone wants the script that displays the image below (you can choose your own images, but these ones are public domain and royalty-free images), just give me a shout and I'll send it on.
An example geo-localised advert displaying your city (as seen by maxmind's geoip db) and places around you.
[/PublicServiceAnnouncement]