This is a discussion on Country within the PHP Language forums, part of the PHP Programming Forums category; How can I view visitors country using php/apache?...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
> How can I view visitors country using php/apache?
Well, what you can do is find the ip address ($_SERVER['REMOTE_ADDR'] or $_SERVER['HTTP_CLIENT_IP']), find the domain (with gethostbyaddr ($ip)) and then find the tld (substr ($domain, strpos ($domain, '.') + 1)). You will get the country of his provider (unless he connects with AOL : always .com). You can also use the language ($_SERVER['HTTP_ACCEPT_LANGUAGE']) and guess the country he's from with that but it is not very accurate. -- SeeSchloß - http://www.seeschloss.net |
|
|||
|
dr. zoidberg wrote:
> T0MA wrote: > > > How can I view visitors country using php/apache? I'm interested in why you want this information? Mere idle curiosity? > You can't. All you can do is get visitors IP adress and then with that > address get visitors country. And even that's unreliable. Let's be optimistic and pretend that your IP address maps to a country-specific domain, .hr perhaps, and not .com, .net, etc. Because if it were a domain of .com or suchlike, we'd all know straight off that it's pure guesswork. However, the country-specific domain of .hr, for example, categorically does not imply that you're sitting in Croatia at that precise moment in time. You may have connected to a machine in Croatia whilst you were lazing around in neighbouring Slovenia (domain .si) or wherever, and accessed a document via that route. -- Jock |
|
|||
|
On Sun, 28 Sep 2003 18:27:59 +0200, "dr. zoidberg"
<someone@example.wrong> wrote: >T0MA wrote: > >> How can I view visitors country using php/apache? > >You can't. All you can do is get visitors IP adress and then with that >address get visitors country. > Exactly, and you can get a IP to country database from: http://ip-to-country.directi.com/ there even seems to be a PHP4 example. - allan savolainen |
|
|||
|
"T0MA" <tomaOVOIZBACIKADMISALJESMAIL@us.zzn.com> wrote in message
news:bl6skd$tdl$1@bagan.srce.hr... > How can I view visitors country using php/apache? > > Try compile Apache/PHP with GeoIP from www.maxmind.com - It does not rely on the domain name (thus it does not need to resolve the users IP address in to a domain) - In addition, performance benifits can be enhanced if you switch off Apaches hostnamelookup switch. I use Apache/PHP with GeoIP and Webalizer to get excellent logging. The GeoIP country edition is free, but the city/region specific database is avaiable for a small yearly fee. -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? |
|
|||
|
On Sun, 28 Sep 2003 21:32:24 +0100, John Dunlop wrote:
>> You can't. All you can do is get visitors IP adress and then with that >> address get visitors country. > > And even that's unreliable. > > Let's be optimistic and pretend that your IP address maps to a > country-specific domain, .hr perhaps, and not .com, .net, etc. > Because if it were a domain of .com or suchlike, we'd all know > straight off that it's pure guesswork. > > However, the country-specific domain of .hr, for example, > categorically does not imply that you're sitting in Croatia at > that precise moment in time. You may have connected to a machine > in Croatia whilst you were lazing around in neighbouring Slovenia > (domain .si) or wherever, and accessed a document via that route. No, but as a lot of other posts point out the information to convert an IP to a country is available, so you could tell from their current IP address where they are connected from. I've used ip2nation.com before (but apparently their services are on hold at the moment). Cheers, Andy |
|
|||
|
Hello,
On 09/28/2003 11:51 AM, T0MA wrote: > How can I view visitors country using php/apache? This class does exactly what you ask: http://www.phpclasses.org/netgeoclass -- Regards, Manuel Lemos Free ready to use OOP components written in PHP http://www.phpclasses.org/ |
|
|||
|
Try http://www.ip2location.com
"Randell D." <you.can.email.me.at.randelld@yahoo.com> wrote in message news:<7OLdb.38676$I36.12729@pd7tw3no>... > "T0MA" <tomaOVOIZBACIKADMISALJESMAIL@us.zzn.com> wrote in message > news:bl6skd$tdl$1@bagan.srce.hr... > > How can I view visitors country using php/apache? > > > > > > Try compile Apache/PHP with GeoIP from www.maxmind.com - It does not rely on > the domain name (thus it does not need to resolve the users IP address in to > a domain) - In addition, performance benifits can be enhanced if you switch > off Apaches hostnamelookup switch. I use Apache/PHP with GeoIP and > Webalizer to get excellent logging. The GeoIP country edition is free, but > the city/region specific database is avaiable for a small yearly fee. |