[insert_php]
//$ip = $_REQUEST[‘REMOTE_ADDR’]; // the IP address to query

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’;

$query = unserialize(file_get_contents(‘http://ip-api.com/php/’.$ipaddress));
if($query && $query[‘status’] == ‘success’) {
$flag = “1”;
$country = $query[‘country’];
$city = $query[‘city’];
$lat = $query[‘lat’];
$long = $query[‘lon’];
$ip = $query[‘query’];
$countryCode = $query[‘countryCode’];
$region = $query[‘region’];
$regionName = $query[‘regionName’];
$zip = $query[‘zip’];
$timezone = $query[‘timezone’];
$isp = $query[‘isp’];
$org = $query[‘org’];
$as = $query[‘as’];

} else {
$geoplugin = unserialize( file_get_contents(‘http://www.geoplugin.net/php.gp?ip=’ . $ipaddress) );

if ( is_numeric($geoplugin[‘geoplugin_latitude’]) && is_numeric($geoplugin[‘geoplugin_longitude’]) )
{
$lat = $geoplugin[‘geoplugin_latitude’];
$long = $geoplugin[‘geoplugin_longitude’];
$city = $geoplugin[‘geoplugin_city’];
$country = $geoplugin[‘geoplugin_countryName’];
$geoplugin_countryCode = $geoplugin[‘geoplugin_countryCode’];
$geoplugin_continentCode = $geoplugin[‘geoplugin_continentCode’];
$geoplugin_currencyCode = $geoplugin[‘geoplugin_currencyCode’];
$geoplugin_currencySymbol = $geoplugin[‘geoplugin_currencySymbol’];
$currencyConverter = $geoplugin[‘currencyConverter’];
}
}

if ($flag == “1”)
{
echo “Your IP Is : $ipaddress
“;
echo “Country : $country
“;
echo “Country code : $countryCode
“;
echo “Region Code : $region
“;
echo “Region Name : $regionName
“;
echo “City : $city
“;
echo “Zip Code : $zip
“;
echo “Longitude : $long
“;
echo “Latitude : $lat
“;
echo “Time Zone : $timezone
“;
echo “ISP : $isp
“;
echo “Organization : $org
“;
echo “AS number/name : $as
“;
}
else
{
echo “Your IP Is : $ipaddress
“;
echo “City: $city
“;
echo “Country Name: $country
“;
echo “Country Code: $countryCode
“;
echo “Longitude: $long
“;
echo “Latitude: $lat
“;
echo “Continent Code: $continentCode
“;
echo “Currency Code: $currencyCode
“;
echo “Currency Symbol: $currencySymbol
“;
echo “Exchange Rate: $currencyConverter
“;

}
echo ‘SOURCE : ListOfTop.net’;
echo ”
“;

[/insert_php]