Is there any way to accurately detect user location?
For example, I am in the country 'C', in state 'S', in the city 'X'. So, my user location should be of city 'X'.
Current situation:
In my current project, I want to redirect users to different websites based on their Geo-location. For this reason, I have bought DB of ip2location.com, for $499.
http://www.ip2location.com/databases/db ... de-zipcode
I am detecting user location from his IP, like this:
Code: Select all
function get_client_ip() {
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
$ipaddress = getenv('HTTP_CLIENT_IP');
else if (getenv('HTTP_X_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if (getenv('HTTP_X_FORWARDED'))
$ipaddress = getenv('HTTP_X_FORWARDED');
else if (getenv('HTTP_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_FORWARDED_FOR');
else if (getenv('HTTP_FORWARDED'))
$ipaddress = getenv('HTTP_FORWARDED');
else if (getenv('REMOTE_ADDR'))
$ipaddress = getenv('REMOTE_ADDR');
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
What is the most accurate way of detecting user location? I don't even mind purchasing an API if it's giving me correct result.