How to get Real IP,ISP,Country,City and etc from Visitor using PHP
Php Get Real visiter's IP and ISP and Country and City and Country code and and Region Name
and Latitude Longitude and Timezone
How to get Real IP,ISP,Country,City and etc from Visitor using PHP |
here example code
---------------------------------------------------------------------------------------------------------------------
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
if(filter_var($client, FILTER_VALIDATE_IP))
{
$ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
$ip = $forward;
}
else
{
$ip = $remote;
}
//$correct_ip_address =$ip = $this->input->ip_address();
$query = @unserialize(file_get_contents('http://ip-api.com/php/'.$ip));
if($query && $query['status'] == 'success') {
$isp=$query['isp'];
$country=$query['country'];
$country_code=$query['countryCode'];
$region=$query['region'];
$regionName=$query['regionName'];
$city=$query['city'];
$zip=$query['zip'];
$lat=$query['lat'];
$lon=$query['lon'];
$timezone=$query['timezone'];
$org=$query['org'];
$as=$query['as'];
$org=$query['org'];
} else {
$as=$org=$timezone=$lon=$lat=$zip=$city=$regionName=$region=$country_code=$country=$isp="No";
}
-------------------------------------------------------------------------------------------------------
You use echo to Print variable
COMMENTS