通过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('EMAIL', 'youemail@qq.com'); $domains = array( 'domain1.com', 'domain2.com', ); function alert($domain,$days) { mail(EMAIL, 'Domain Expire Waring - ' . $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('/^Registrar Registration Expiration Date:\s*(.+)$/', "$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); }