开发者

Get domain name expiration date via PHP

Here is my current code:

function get_cmd ()
{
    if (file_exists('/usr/local/bin/whois'))
        $cmd = '/usr/local/bin/whois';
    elseif (file_exists('/usr/bin/whois'))
        $cmd = '/usr/bin/whois';
    elseif (file_exists('/bin/whois'))
开发者_如何学运维        $cmd = '/bin/whois';
    else
        die('whois shell command does not exist');

    return $cmd;
}

function get_whois ($cmd, $domain) 
{
    if (checkdnsrr($domain))
        $result = shell_exec(escapeshellcmd($cmd ." ". $domain));
    else
        $result = 'DOMAIN IS NOT REGISTERED';

    return $result;
}

$cmd = get_cmd();
echo get_whois($cmd, 'google.com');

now, is there a different method that will easily allow me to extract the expiration date of the domain without having to come up with a whole bunch of different regex? since the information will be formatted differently for every domain...


i've went ahead and just used regular expressions for this. some registrars don't even provide expiration dates in their whois.


This code will give you the expiration date

<? 
$detail = "whois " . $_GET['domain']; 
$res = shell_exec($detail); 
$start = strpos($res,"Expiration"); 
echo substr($res,$start+16,11); 
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜