Global IP List

Part of development that is fun yet tricky is developing for a global audience.  For dcshoes.com, we are having 1 single site address (www.dcshoes.com) that will act differently according to the location of the user (and language too, but I wont get into that).

At some point in time, a developer must deploy some code that will
1. Detect the users IP Address
2. Based on an IP table or related, determine the users current country

Now generally speaking, when you have a function of this nature, it will take in an IP and spit back out a 2 or 3 letter ISO country code.

During times when you want to “see how your site looks like from someone else”, usually you will put in a flag such as “?override_country=DE” if say, you want to be in Germany.  This is not a bad approach.

However for me, I like to actually a) test the Geo IP Detection is working and b) see if the appropriate action for the appropriate country is taking place

Below you will see a very dumbed down script of what I”m talking about.  Anyhoo, I think it could be helpful to some people if they need to spoof their IP and tell their code they have a different IP rather than having it detect theirs all the time.

If you look at the code above, you will see it is super basic.  What it is doing is:

1. Check to see if there is a GET variable named ‘user_override’ and if the value of that is ‘yes’
– TRUE  – If it is set to use, then use one of the IP addresses below.  In our case, we are pretending to act like we are in Azerbaijan
– FALSE – If there is no “user_override” or if it is set to anything other than use, get the location based on the users IP (so if you’re in US, you’ll have a US IP)

The above IPs DO work and I have tested them with MaxMind GeoIP Detection.  I will add to the list as I add to my own list.

Enjoy.