Country

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?...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-28-2003
T0MA
 
Posts: n/a
Default Country

How can I view visitors country using php/apache?


Reply With Quote
  #2 (permalink)  
Old 09-28-2003
dr. zoidberg
 
Posts: n/a
Default Re: Country

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.


Reply With Quote
  #3 (permalink)  
Old 09-28-2003
SeeSchloss
 
Posts: n/a
Default Re: Country

> 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

Reply With Quote
  #4 (permalink)  
Old 09-28-2003
John Dunlop
 
Posts: n/a
Default Re: Country

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
Reply With Quote
  #5 (permalink)  
Old 09-28-2003
Allan Savolainen
 
Posts: n/a
Default Re: Country

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

Reply With Quote
  #6 (permalink)  
Old 09-29-2003
Randell D.
 
Posts: n/a
Default Re: Country

"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?


Reply With Quote
  #7 (permalink)  
Old 09-29-2003
Andy Jeffries
 
Posts: n/a
Default Re: Country

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
Reply With Quote
  #8 (permalink)  
Old 09-29-2003
Manuel Lemos
 
Posts: n/a
Default Re: Country

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/

Reply With Quote
  #9 (permalink)  
Old 10-05-2003
MK Wong
 
Posts: n/a
Default Re: Country

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.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:51 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0