通过PHP获取域名过期日期 [英] Get domain name expiration date via PHP

查看:393
本文介绍了通过PHP获取域名过期日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我现在的代码:

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...

推荐答案

我已经走了,只是使用正则表达式。一些注册商甚至没有在其whois中提供有效期。

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

这篇关于通过PHP获取域名过期日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆