Home >php教程 >php手册 >PHP判断域名过期时间源码

PHP判断域名过期时间源码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 19:37:571261browse

通过whois信息来判断域名过期时间,利用命令行工具whois来获取相关信息,过滤出过期时间后转换为时间戳。 无 #!/usr/bin/env php?phpdefine("NOTIFY_DAYS", 30);define('EMAIL', 'youemail@qq.com');$domains = array('domain1.com','domain2.com',);function

通过whois信息来判断域名过期时间,利用命令行工具whois来获取相关信息,过滤出过期时间后转换为时间戳。
#!/usr/bin/env php
<?php

define("NOTIFY_DAYS", 30);
define(&#39;EMAIL&#39;, &#39;youemail@qq.com&#39;);

$domains = array(
	&#39;domain1.com&#39;,
	&#39;domain2.com&#39;,
);

function alert($domain,$days)
{
    mail(EMAIL, &#39;Domain Expire Waring - &#39; . $domain, sprintf("%s will expired in %s days", $domain, $days));
}

function check_doamin_expire($domain)
{
	exec(sprintf("/usr/bin/whois %s", $domain), $arr, $retCode);

	if ($retCode == 0)
	{
	    $exp_date = array_values(preg_filter(&#39;/^Registrar Registration Expiration Date:\s*(.+)$/&#39;, "$1", $arr));
	    $remain_time = strtotime($exp_date[0]) - time();
	    $days = intval($remain_time/86400);
	    if ( $remain_time < NOTIFY_DAYS*86400)
	    {
	        alert($domain,$days);
	    }
	}
}

foreach ($domains as $domain)
{
	check_doamin_expire($domain);
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn