class Domain
{
var $_whois_server;
var $_ip_address;
var $_time_out;
var
$_port_num;
var $_results;
function Domain($ip_address,
$whois_server="")
{
$this->_domain_name =
$ip_address;
$this->_port_num = 43;
$this->_time_out =
30;
if($whois_server == ""){ $this->_whois_server = "whois.internic.net";
}
else{ $this->_whois_server = $whois_server; }
}
function SetWhois($server)
{
$this->_whois_server =
trim($server);
}
function Lookup()
{
$host =
$this->_whois_server;
$port_num = $this->_port_num;
$time_out =
$this->_time_out;
$domain = $this->_domain_name;
$feed_back
= "";
if($who_sock = fsockopen($host, $port_num, $errno, $errstr,
$time_out))
{
$feeder = "$domain1512";
fputs($who_sock,
$feeder);
while(!feof($who_sock))
{
$feed_back .=
fgets($who_sock, 128) . "n";
}
fclose($who_sock);
}
else
{
print "Cannot connect to [$host]
for query.";
exit;
}
$this->_results = $feed_back;
// The
line below is a sanity checker...
// print
$feed_back;
}
function Get()
{
$res =
$this->_results;
$results = array();
$fn =
preg_match('/domain.+?:(.+?)\n/i', $res, $full_name);
$cr =
preg_match('/creat.+?:(.+?)\n/i', $res, $created);
$ex =
preg_match('/expir.+?:(.+?)\n/i', $res, $expires);
$up =
preg_match('/updated.+?:(.+?)\n/i', $res, $updated);
$wh =
preg_match('/whois.+?:(.+?)\n/i', $res, $whois);
$re =
preg_match('/referral.+?:(.+?)\n/i', $res, $referral);
$ns =
preg_match_all('/name ser.+?:(.+?)\n/i', $res, $name_server);
if($fn)
$results['fullname'] = $full_name[1];
if($cr) $results['created'] =
$created[1];
if($ex) $results['expires'] = $expires[1];
if($up)
$results['updated'] = $updated[1];
if($wh) $results['whoisserver'] =
$whois[1];
if($re) $results['nameserver'] = $name_server[1];
if($ns)
$results['referral'] = $referral[1];
return
$results;
}
}
/*
sample.php ------------------------
*/
<?
include_once("domain.class.php");
?>
<html>
<head>
<title>Domain
LookUp Example</title>
</head>
<body>
<?
$domain = new
Domain("miniwini.com"); // .com
//$domain = new
Domain("miniwini.or.kr","whois.krnic.net"); // .kr 은 이렇게
$domain->Lookup();
$info = $domain->Get();
foreach($info as $key=>$val)
{
print "$key = $val<br>";
}
if(isset($info['whoisserver']))
{
$domain->SetWhois($info['whoisserver']);
$domain->Lookup();
$info
= $domain->Get();
foreach($info as $key=>$val)
{
print
"$key = $val<br>";
}
}
else
{
foreach($info as
$key=>$val)
{
print "$key = $val<br>";
}
}
?>
</body>
</html>
'php' 카테고리의 다른 글
www. 붙었는지 파악하고 URL 리턴 (0) | 2009.10.15 |
---|---|
제로보드 4.1pl9 신규 취약점 및 배포⋅서비스 중지에 따른 주의 (0) | 2009.09.28 |
웹페이지를 압축해서 웹페이지 로딩속도를 줄여보자. Web Page gzip Content (0) | 2009.06.09 |
URL 재작성 지침서 URL REWRITING FOR BEGINNERS (0) | 2009.04.14 |
Disk quota exceeded (0) | 2008.08.28 |