웹에서 사용방법 : http://ulovem.com/project/whois/whois.php?domain=ulovem.com
쉘에서 사용방법 : #>php -q whois.php ulovem.com
클래스 형식으로 만들었습니다.
if (!$domain)
{
$domain = $argv[1];
}
$GetExpire = new GetExpireDate;
$GetExpire->GetInfo($domain);
이렇게 해주시면 사용 가능 합니다. 다운 받아서 보십시요…
<?
// vi:ts=8 sts=4 sw=4:
// Using Shell : php -q whois.php ulovem.com
// Using web : http://www.ulovem.com/project/whois/whois.php?domain=ulovem.com
// When Require national domain Search “whois” shell command
if (!$domain)
{
$domain = $argv[1];
}
$GetExpire = new GetExpireDate;
$GetExpire->GetInfo($domain);
class GetExpireDate
{
var $askNameServerURL = “”;
var $ExpireDate = “”; // Set Days
var $Today = “”;
var $AfterExpireDays = “Don’t”;
function GetExpireDate()
{
$this->today = $this->getDate();
}
function GetInfo($domain)
{
$expDate = $this->GetHtmlRtnDate($domain);
if ( $expDate == “none” ) {
echo “$domain Domain is not existn”;
exit;
}
//Test//$DiffDay = $this->DateDiff( $expDate, $this->getDate());
$this->AfterExpireDays = $this->DateDiff( $this->getDate() , $expDate);
if ($this->AfterExpireDays < 0 ) { // 만료
echo “$domain is Before $this->AfterExpireDays days was expired n”;
} else {
echo “$domain is After $this->AfterExpireDays days will expired n”;
}
}
function getDate()
{
$date = getdate();
return sprintf(“%04d-%02d-%02d”,$date[year],$date[mon],$date[mday]);
}
function GetHtmlRtnDate($domain)
{
$buffer = “”;
$stDate = “none”;
switch ( $this->GetURL($domain) )
{
case “kr”: // Korea Domain
$fp = fopen($this->askNameServerURL,”r”);
while($line = fgets($fp,1000)){
if (!is_bool(strpos($line,”Expiration Date”))){
$stDate = $this->GetDateFromExpDate($line);
fclose($fp);
break;
}
}
break;
case “com”:
case “net”:
case “org”:
$line = shell_exec($this->askNameServerURL .” | grep “Expiration””);
if ($line == “”) break;
$stDate = $this->GetDateFromExpDate($line);
$stDate = date(“Y-m-d”, strtotime($stDate)) ;
break;
default : // non Korea Domain com.net.org etc…
exit;
break;
}
return $stDate;
}
function GetDateFromExpDate($string)
{
preg_match(“/[^:/]+$/”,$string,$arr);
$arr[0] = str_replace(“.”,”-“,$arr[0]); // korea domain using date seperater dot(.)
$arr[0] = str_replace(” “,””,$arr[0]);
return $arr[0];
}
function GetURL($domain)
{
preg_match(“/[^./]+$/”,$domain, $arr);
switch($arr[0])
{
case “kr”:
$this->askNameServerURL = “http://whois.nic.or.kr/whois/webapisvc?VALUE=$domain”;
break;
case “com”:
case “net”:
case “org”:
$this->askNameServerURL = “whois $domain | grep “Expiration Date””;
break;
default:
echo “Don’t Supporting whoisn”;
exit;
break;
}
return $arr[0];
}
function DateDiff($todate, $expdate)
{
$time = (strtotime($expdate) – strtotime($todate)) / 86400;
return $time;
}
}
?>
http://www.nzeo.com/bbs/zboard.php?id=p_etc&no=1065
쉘에서 사용방법 : #>php -q whois.php ulovem.com
클래스 형식으로 만들었습니다.
if (!$domain)
{
$domain = $argv[1];
}
$GetExpire = new GetExpireDate;
$GetExpire->GetInfo($domain);
이렇게 해주시면 사용 가능 합니다. 다운 받아서 보십시요…
<?
// vi:ts=8 sts=4 sw=4:
// Using Shell : php -q whois.php ulovem.com
// Using web : http://www.ulovem.com/project/whois/whois.php?domain=ulovem.com
// When Require national domain Search “whois” shell command
if (!$domain)
{
$domain = $argv[1];
}
$GetExpire = new GetExpireDate;
$GetExpire->GetInfo($domain);
class GetExpireDate
{
var $askNameServerURL = “”;
var $ExpireDate = “”; // Set Days
var $Today = “”;
var $AfterExpireDays = “Don’t”;
function GetExpireDate()
{
$this->today = $this->getDate();
}
function GetInfo($domain)
{
$expDate = $this->GetHtmlRtnDate($domain);
if ( $expDate == “none” ) {
echo “$domain Domain is not existn”;
exit;
}
//Test//$DiffDay = $this->DateDiff( $expDate, $this->getDate());
$this->AfterExpireDays = $this->DateDiff( $this->getDate() , $expDate);
if ($this->AfterExpireDays < 0 ) { // 만료
echo “$domain is Before $this->AfterExpireDays days was expired n”;
} else {
echo “$domain is After $this->AfterExpireDays days will expired n”;
}
}
function getDate()
{
$date = getdate();
return sprintf(“%04d-%02d-%02d”,$date[year],$date[mon],$date[mday]);
}
function GetHtmlRtnDate($domain)
{
$buffer = “”;
$stDate = “none”;
switch ( $this->GetURL($domain) )
{
case “kr”: // Korea Domain
$fp = fopen($this->askNameServerURL,”r”);
while($line = fgets($fp,1000)){
if (!is_bool(strpos($line,”Expiration Date”))){
$stDate = $this->GetDateFromExpDate($line);
fclose($fp);
break;
}
}
break;
case “com”:
case “net”:
case “org”:
$line = shell_exec($this->askNameServerURL .” | grep “Expiration””);
if ($line == “”) break;
$stDate = $this->GetDateFromExpDate($line);
$stDate = date(“Y-m-d”, strtotime($stDate)) ;
break;
default : // non Korea Domain com.net.org etc…
exit;
break;
}
return $stDate;
}
function GetDateFromExpDate($string)
{
preg_match(“/[^:/]+$/”,$string,$arr);
$arr[0] = str_replace(“.”,”-“,$arr[0]); // korea domain using date seperater dot(.)
$arr[0] = str_replace(” “,””,$arr[0]);
return $arr[0];
}
function GetURL($domain)
{
preg_match(“/[^./]+$/”,$domain, $arr);
switch($arr[0])
{
case “kr”:
$this->askNameServerURL = “http://whois.nic.or.kr/whois/webapisvc?VALUE=$domain”;
break;
case “com”:
case “net”:
case “org”:
$this->askNameServerURL = “whois $domain | grep “Expiration Date””;
break;
default:
echo “Don’t Supporting whoisn”;
exit;
break;
}
return $arr[0];
}
function DateDiff($todate, $expdate)
{
$time = (strtotime($expdate) – strtotime($todate)) / 86400;
return $time;
}
}
?>
http://www.nzeo.com/bbs/zboard.php?id=p_etc&no=1065