Country Codes

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
Slippy
Forum Contributor
Posts: 113
Joined: Sat Jul 12, 2003 11:31 pm
Location: Vancouver eh!

Country Codes

Post by Slippy »

Has anyone ever looked at the ip-to-country stuff that PHP.net has been using to direct to a closer mirror?

Demo

I wonder how well this works. Other than mirrors can anybody think of another practicle use for this?

Companies like g 8O gle are using something similar (or maybe the same thing).

Kind of cool -- and PHP based... :mrgreen:
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Some sites have more than one language version. The most common are English, French, Spanish, Italian, and German... so I guess this could be used to automatically jump to the relevant version of the site depending on the IP.

The IP does allow you to narrow down the location of the users host even futher though (London, UK for example) but It doesn't look like this does do that.. shame though.

Maybe we can start a poll or something and get people to enter their location, record the IP, and create a database of the values?
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

WHOA!!

I've just checked out that demo and downloaded the database for it.

To be frank... bollocks to it. It's 2.5 megs big and has 53,416 rows... no way! I really can't see the point of using this any more now I've found out how big the whole thing is. I'm going to stick with a few gif images on my site(s) and let the user choose their own country.

53,416!!! There aren't even that many countries in the World?!?!

This can be done a whole lot easier using JavaScript to get the country code (ie UK, JP, CA etc) and then do your thang from there.

53,416!!! They're having a laugh aren't they 8O
User avatar
Slippy
Forum Contributor
Posts: 113
Joined: Sat Jul 12, 2003 11:31 pm
Location: Vancouver eh!

Post by Slippy »

It is kind of strange eh? That's why I was wondering if there was any purpose for this other than redirection.

And if your site requires redirection -- is this how you would go about it? I can see how this might speed up downloads and stuff -- but still...
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

IP Address 192.168.1.1 belongs to Netherlands.
Smooth. This is horrible. ;\

Decent: http://www.location.com.my/free.asp
Image Image
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Gen-ik wrote: This can be done a whole lot easier using JavaScript to get the country code (ie UK, JP, CA etc) and then do your thang from there.
How?
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Code: Select all

var bl = navigation.browserLanguage;
var sl = navigator.systemLanguage;
var ul = navigator.userLanguage;
Language Codes:

http://msdn.microsoft.com/workshop/auth ... _codes.asp

Not sure if it works with all browsers but it's fine with IE4+ and NS.
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post by Coco »

you cant really use ip addresses that well

aol directs users globally into one proxy ip address (at least spain, portugal, uk and usa all using one set of proxies. It broke my ip based multi account filter :( )... and other similar companies do the same

also, its not one ip address per country

as with the last post, the most reliable method has to be getting the client machine's language setting, but even that isnt too much use, since the majority of windows users have a US english version.

the end result really has to be that the most effective one is the .gif mentioned...
just make the user select language on first visit and stuff it in a cookie. problem solved, and much easier than fannying about with some ip DB
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

You can actually let PHP handle the language recognition. Use "$_SERVER["HTTP_ACCEPT_LANGUAGE"]" (register_globals must be on) which will return a string like "en-us" (US-English) or "en-gb" (British English) or "de" (German) etc.

However, this does not always work - so you would need a default setting, most likely English.
User avatar
Slippy
Forum Contributor
Posts: 113
Joined: Sat Jul 12, 2003 11:31 pm
Location: Vancouver eh!

Post by Slippy »

Seems like IP 2 Country codes are pretty much a useless project. I don't think anybody here really has a use for them.

It looks like they spent a lot of time on that project.

I did think of one use for this tool that could prove useful. If you gather stats on your site and log IP addresses -- then you would have a pseudo acurate way of finding out which country they are from. You could compare that to what language they are using etc... maybe find out more about your target market.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

I did think of one use for this tool that could prove useful. If you gather stats on your site and log IP addresses -- then you would have a pseudo acurate way of finding out which country they are from. You could compare that to what language they are using etc... maybe find out more about your target market.
Actually, if you have a good log-parser like webalizer running, you'll get that info anyway ;)
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Slippy wrote:I did think of one use for this tool that could prove useful. If you gather stats on your site and log IP addresses -- then you would have a pseudo acurate way of finding out which country they are from. You could compare that to what language they are using etc... maybe find out more about your target market.
Yup. And it's also good for big sites and their media kits. It's nice to show your future advertisers where people are from along with the rest of the demographics.

I agree with your general view, it's not useful, but then again it's not useless either.

I'd recommend sticking with flags and/or letting users register or use cookies for the redirection pages. 8)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Google used to redirect me to the German google site and wouldn't let me override it...

The PHP site keeps redirecting me to the uk2 mirror when I prefer (and often get a better response) from the uk mirror...

I prefer to make my own choice rather than be forced to go to whatever the site decides my IP means I should get - just because you're in a particular country doesn't mean you speak their national language.

Mac
User avatar
Slippy
Forum Contributor
Posts: 113
Joined: Sat Jul 12, 2003 11:31 pm
Location: Vancouver eh!

Post by Slippy »

I prefer to make my own choice rather than be forced to go to whatever the site decides my IP means I should get - just because you're in a particular country doesn't mean you speak their national language.
Me too, it's annoying to be forced to a mirror when you don't want to (makes me feel like I'm missing out on some secret thing).

You probably already know that if you add /ncr to the end of google.com that you will override the redirection.
Post Reply