PHP Code:
function curl( $url ) {
if ( in_array( "curl", get_loaded_extensions() ) ) {
$ch = curl_init() ;
curl_setopt( $ch, CURLOPT_URL, $url ) ;
curl_setopt( $ch, CURLOPT_REFERER, $url ) ;
curl_setopt( $ch, CURLOPT_HEADER, 0 ) ;
//curl_setopt( $ch, CURLOPT_FRESH_CONNECT, 1 ) ;//optional
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ) ;
curl_setopt( $ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] ) ;
$result = curl_exec( $ch ) ;
curl_close( $ch ) ;
return $result ;
} else {
$result = file_get_contents( $url ) ;
return $result ;
}
}
----------
function isp( $ip ) {
$data = curl( "http://whatismyipaddress.com/ip/" . $ip ) ;
if ( preg_match( "/ISP:<\/th><td>(?P<Isp>.+)<\/td><\/tr><tr><th>Organization:/i", $data, $match ) ) {
return ucwords( strtolower( str_ireplace( array( "-", "_", "S.a." ), array( " ", " ", "" ), $match["Isp"] ) ) ) ;
} else {
return "Unknown" ;
}
}
echo isp("127.1.0.0"); // replace with any other ip