Page 1 of 1

How do u tell what country a client is browsing from ?

Posted: Sun Apr 13, 2003 10:19 pm
by lazy_yogi
Anyone know how to tell what country a client is from ?
If I use "gethostbyname" I can get the users IP address.
Any idea how to find what country this is, either from that function or any other ?

Cheers

Posted: Mon Apr 14, 2003 12:16 am
by phice
Demo: http://perfectphp.com/ipatlas/plot.php
Source: http://www.xpenguin.com/ip-atlas.php
Download: http://www.xpenguin.com/ip-atlas-1.0.zip

You can either put in a domain (http://www.aol.com) or it's ip (64.12.187.24) [any ip for that matter]

Posted: Mon Apr 14, 2003 12:25 am
by m3mn0n
That's pretty neat. But it's off by far for me. It says i'm in my nation's capital when infact i'm on the other side of the country.
You at (142.xxx.xx.xx) are located in Ottawa, Ontario (province), Canada. (45.42, -75.72)
But it's a very nice program.

Posted: Mon Apr 14, 2003 5:14 am
by volka
and I am in Amsterdam but obviously too stoned to notice ;)

Posted: Mon Apr 14, 2003 6:43 am
by lazy_yogi
OMG ! That was by far the worst code I've ever seen in my life !!

Here's some snippets from there :

Code: Select all

function stuffanalyze($stuff) {

for ($count = 0; $count < count($stuff2); $count++) {
  $stuff2[$count] = $stuff2[$count][0];
  $stuff2[$count] = ucwords(strtolower(trim(substr(substr($stuff2[$count], 15), 0, -5))));
}

}



function getstuff($address, $local) {
 .....
}
I couldn't read that <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>
Anyone have any other ideas how to look up a country from an IP ?

Cheers

Posted: Mon Apr 14, 2003 7:42 am
by bender
...last time I checked Sydney was located in Australia - not the Netherlands ?!?!?!

Posted: Mon Apr 14, 2003 10:57 am
by Rob the R
Could you use the value in the $_SERVER["HTTP_ACCEPT_LANGUAGE"] variable? This often has the country abbreviation in the value. Of course, this is entirely user-configurable (which means the user can set it to whatever they want) and is meant to identify the language and not necessarily the country.

Posted: Mon Apr 14, 2003 11:39 am
by patrikG
Check this class here:
http://www.phpclasses.org/browse.html/package/693.html

It's not working perfectly, but it's a very nice example.

Posted: Mon Apr 14, 2003 7:55 pm
by lazy_yogi
Thanx Rob, that seems to be what I'm looking for

Cheers

Posted: Sat May 03, 2003 9:11 pm
by m3mn0n
http://www.xpenguin.com/ip-atlas.php wrote: IP-Atlas 1.0 (Released July 3rd)

IP-Atlas tries to plot your location or any other host on the internet using the NetGeo data. It finds the latitude and longitude coordinates of the host and plots it on an image for you. You can try the demo and/or download it (91k). IP-Atlas requires PHP and optionally the GD library.