Page 1 of 1

Country Codes

Posted: Sun Jul 20, 2003 3:10 pm
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:

Posted: Sun Jul 20, 2003 7:03 pm
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?

Posted: Sun Jul 20, 2003 7:54 pm
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

Posted: Sun Jul 20, 2003 9:38 pm
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...

Posted: Mon Jul 21, 2003 12:48 am
by phice
IP Address 192.168.1.1 belongs to Netherlands.
Smooth. This is horrible. ;\

Decent: http://www.location.com.my/free.asp

Posted: Mon Jul 21, 2003 12:52 pm
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?

Posted: Mon Jul 21, 2003 2:01 pm
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.

Posted: Mon Jul 21, 2003 2:55 pm
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

Posted: Mon Jul 21, 2003 3:42 pm
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.

Posted: Mon Jul 21, 2003 6:47 pm
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.

Posted: Mon Jul 21, 2003 7:14 pm
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 ;)

Posted: Wed Jul 23, 2003 3:44 am
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)

Posted: Fri Jul 25, 2003 7:30 am
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

Posted: Fri Jul 25, 2003 11:43 am
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.