Re: Finding a visitor's location

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 23 Oct 2006 19:00:08 +1000, Chris wrote:

> John Messam wrote:
>> Hello, I am trying to find out the country and possibly the city where the
>> visitors to my site are coming from.   I can capture the IP address but how
>> do I translate that to a specific locale.   Is there a way to do it or do I
>> have to ask them and map the info myself.  Thank you for you help.  This list
>> is a very useful tool.
> 
> Search for "geo-ip database" or "ip to country" or some such variant in 
> a search engine.

To quickly do a relatively simple check (do not expect high success rate,
but it doesn't require you to download/purchase databases) is do a
reverse-DNS lookup (gethostbyaddr) on $_SERVER['REMOTE_ADDR'], check if
it's the same IP address (failed), if not you've got yourself a hostname.
Grab the last piece after the dot (strrchr), and you've got the TLD...
Although it includes TLD's like com, net, org, edu and such it also
includes countries.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux