class whoisClass
{
var $ip;
var $pattern = "^[[]+( IP 사용 기관 정보 )";
var $result;
//IP를 입력하고 결과값(한글) 배열을 반환한다.
function query_ip($ip){
$this->ip = $ip;
$str = @file(" http://whois.nic.or.kr/whois/webapisvc/?VALUE=". $this->ip);
if(!$str) return false;
$str_num = count($str);
for($i=0 ; $i<$str_num; $i++){
if(eregi("조회하신 IP주소의 사용기관 정보는 아래와 같습니다.", $str[$i]) == 1) $Start_Capture = 13;
if($Start_Capture != 0){
switch($Start_Capture){
case 11:
$result = explode("-",ereg_replace("IP 주소 : ","",$str[$i]));
$this->result["start_ip"] = $result[0];
$this->result["end_ip"] = $result[1];
break;
case 9:
$this->result["isp"] = ereg_replace("연결 ISP명 : ","",$str[$i]);
break;
case 4:
$this->result["org_id"] = ereg_replace("기관고유번호 : ","",$str[$i]);
break;
case 3:
$this->result["org_name"] = ereg_replace("기관명 : ","",$str[$i]);
break;
case 2:
$this->result["city"] = ereg_replace("시도명 : ","",$str[$i]);
break;
case 1:
$this->result["address"] = ereg_replace("주소 : ","",$str[$i]);
}
$Start_Capture--;
}
}
return $this->result;
}
}
** 설명
반환되는 배열을 $info 라고 한다면,
$info[start_ip] 해당 IP의 대역폭시작IP
$info[end_ip] 해당 IP의 대역폭끝IP
$info[isp] ISP명
$info[org_id] 기관고유번호
$info[org_name] 기관명
$info[city] 시도명
$info[address] 주소