function getLocationInfoByIp($ip_addr)
{
return $ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip_addr));
}
$ap_address = $_SERVER['REMOTE_ADDR'];
$location_info = getLocationInfoByIp($ap_address);
echo '<pre>';
print_r($location_info);
echo '</pre>';
stdClass Object
(
[geoplugin_request] => 103.4.146.186
[geoplugin_status] => 200
[geoplugin_credit] => Some of the returned data includes GeoLite data created by MaxMind, available from http://www.maxmind.com.
[geoplugin_city] => Dhaka
[geoplugin_region] => Dhaka
[geoplugin_areaCode] => 0
[geoplugin_dmaCode] => 0
[geoplugin_countryCode] => BD
[geoplugin_countryName] => Bangladesh
[geoplugin_continentCode] => AS
[geoplugin_latitude] => 23.7231
[geoplugin_longitude] => 90.4086
[geoplugin_regionCode] => 81
[geoplugin_regionName] => Dhaka
[geoplugin_currencyCode] => BDT
[geoplugin_currencySymbol] => Tk
[geoplugin_currencySymbol_UTF8] => Tk
[geoplugin_currencyConverter] => 79.4502
)
================================
function ip_details($ap_address)
{
$json = file_get_contents("http://ipinfo.io/{$ap_address}");
$details = json_decode($json);
return $details;
}
$ap_address = $_SERVER['REMOTE_ADDR'];
$details = ip_details($ap_address);
echo '<pre>';
print_r($details);
echo '</pre>';
stdClass Object
(
[ip] => 103.4.146.186
[hostname] => No Hostname
[city] => Dhaka
[region] => Dhaka Division
[country] => BD
[loc] => 23.7231,90.4086
[org] => AS9441 Next Online Ltd.
[postal] => 1000
)
$ip = '141.168.138.15'; // Victoria/Melbourne
$ip = '49.197.229.133'; // Queensland/Brisbane
$ip = '114.141.196.226'; // New South Wales/Sydney
$ip = '58.108.79.123'; // Western Australia/Perth