function get_asn($ip) {
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}"));
return $details->org;
}
$ip = getenv('HTTP_CLIENT_IP')?:
getenv('HTTP_X_FORWARDED_FOR')?:
getenv('HTTP_X_FORWARDED')?:
getenv('HTTP_FORWARDED_FOR')?:
getenv('HTTP_FORWARDED')?:
getenv('REMOTE_ADDR');
echo "Your public IP address:
";
echo $ip;
echo "
Network: ";
echo get_asn($ip);
echo "";
?>