What are the location detecting techniques for IP addresses?
I know to look at the
$_SERVER['HTTP_ACCEPT_LANGUAGE'] (not accurate but mostly useful to detect location, for example if an IP range’s users set French to their browser then it means that this range) belongs to France
and
gethostbyaddr($_SERVER['REMOTE_ADDR']) (to look country code top-level domain)
then may be to whois gethostbyaddr($_SERVER['REMOTE_ADDR'])
sometimes:
$HTTP_USER_AGENT (Firefox’s user agent string has language code, not accurate but mostly can be used to detect the location)
Also I know how to get the time zone but it does not work in the new browsers.
Moreover there is css issue that detects visitor’s history, it can be used to see what google and wikipedia pages he/she has visited (google.co.uk, google.com.tr)
But what about cities?
You can’t do this without a database that maps IP addresses to cities/countries/providers. There are commercial offerings such as ip2location that you could use.
AFAIK there is no free alternative though, as maintaining such a IP database is quite a lot of work.Free alternative: GeoIP2Update:
There are several things that allow you to create such a db, if you invest enough time:
even read the city name in plain text if you do a reverse-DNS lookup. Sometimes it is
more cryptic. For example I currently have p5dcf6c4a.dip.t-dialin.net , and I have no
idea that the naming scheme is..
the location of its uplink