PHP Advent 2009: GeoIP Wrangling

» 21 December 2009 » In Analog, Development, PHP »

There have been a few kind words and questions about the GeoIP-based blurb that greets the visitors to our Analog holding page, so I wanted to blog about how it was made and what obstacles I ran into. However, while writing I realized that it would be the perfect candidate for this year’s edition of PHP Advent instead of the article I originally planned to write about Git and Github. So head on over and read about GeoIP Wrangling and feel free to leave your comments here.

Trackback URL

  1. andrei
    Adam Trachtenberg
    21/12/2009 at 9:48 pm Permalink

    Thanks for writing this up. I started down this path looking for ZIP/Postal Code data for (which now just defaults to eBay’s ZIP), but bailed out around the time I started poking at the GeoIP CSV files and looking at the data quality. So, I didn’t find out the end to the story until now.

  2. andrei
    22/12/2009 at 1:17 am Permalink

    Great write-up, the chatty comments definitely make this feature into what it is, one of the many things I really liked about the analog site 🙂

  3. andrei
    Ian Anderson Gray
    22/12/2009 at 1:25 am Permalink

    Fantastic article- really interesting and informative!

    I hope you don’t mind me mentioning, but I did notice on the website that it couldn’t locate my city and instead printed “, UK” (notice the comma). It might be a good idea to put “By the way, with some GeoIP guesswork, it looks like you’re in or near the UK”. You wouldn’t need to put the word “the” before all countries though because “the Germany” might look a bit silly- might be a bit tricky! Here is what it said for me…

    By the way, with some GeoIP guesswork, it looks like you’re in or near , UK. Alan and Jon are closest to you — about 200 miles away in Bristol. Jon is in Barnstaple. Andrei and Chris are in the US.

    Thanks again!

  4. andrei
    22/12/2009 at 9:32 am Permalink

    Ian, could you please go to and then email me your IP address? You can find my email on the About page.

  5. andrei
    23/12/2009 at 5:17 pm Permalink

    * GeoIP doesn’t work very well in the suburbs. There are so many in a small geographic space that its very rarely correct, while its “close” the reported location is usually mentally farther away than it is in reality. Its like saying that Russia and the United states are neighbors. Geographically sorta true ( due to Alaska), but we often don’t think of it that way (at least not those of us in the lower 48). It might make some people think your site is “buggy”.

    * GeoIP is usually used for annoying ads with dancing people in them. Using it causes me to mentally associate analog with them.

    * GeoIP is sometimes a bit spooky. Most people don’t realize what an IP address is much less that it can be tied to a geographic location. It seems like a privacy violation to some people, even though you are always disclosing this info to every website you visit.

  6. andrei
    20/07/2011 at 6:34 am Permalink

    Great article, indeed.

    Would you share your patches(d) for the original extension to support cache?

  7. andrei
    22/07/2011 at 8:09 am Permalink

    The hack I did forced cached load for all scenarios. I’ll have to write a patch that lets the user pick what kind of load to do.

Additional comments powered by BackType