通过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');
现在,是否有一种不同的方法可以轻松地让我提取域的到期日期,而不必拿出一大堆不同的正则表达式?因为每个域的信息格式都不同......
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经继续并为此使用了正则表达式。一些注册商甚至不在其 whois 中提供过期日期。
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