<?php
$ip='183.197.49.179';//$_SERVER['REMOTE_ADDR'];
if(jiaoyanip($ip)){
echo "ok";
}else{
echo "error";
}
function jiaoyanip($ip){
$url="http://m.ip138.com/ip.asp?ip=".$ip;
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
$dxycontent = curl_exec($ch);
//echo $dxycontent;
$rule = '/<p class="result">.*<\/p>/i';
preg_match($rule,$dxycontent,$result);
$osk=str_replace("本站主数据","",strip_tags($result[0]));
$ycdlen=strlen($osk);
$newlen=strlen(preg_replace("/河南|河北|北京/","",$osk));
if($newlen<$ycdlen){
return true;
}else{
return false;
}
}
?>
//其他ip接口http://ip.t086.com/?ip=*