Find ISP(Internet Service Provider)

04/15/2012 08:56 Angellinho#1
Find the Internet Provider of your visitors.

PHP Code:
function curl$url ) {
  if ( 
in_array"curl"get_loaded_extensions() ) ) {
   
$ch curl_init() ;
   
curl_setopt$chCURLOPT_URL$url ) ;
   
curl_setopt$chCURLOPT_REFERER$url ) ;
   
curl_setopt$chCURLOPT_HEADER) ;
   
//curl_setopt( $ch, CURLOPT_FRESH_CONNECT, 1 ) ;//optional
   
curl_setopt$chCURLOPT_RETURNTRANSFER) ;
   
curl_setopt$chCURLOPT_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 
ucwordsstrtolowerstr_ireplace( array( "-""_""S.a." ), array( " "" """ ), $match["Isp"] ) ) ) ;
  } else {
   return 
"Unknown" ;
  }
 }
echo 
isp("127.1.0.0"); // or any other isp