判断域名过期时间
程序员文章站
2022-06-03 14:42:42
...
php代码
#!/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) { $pattern = array ( '/^Registry Expiry Date:\s*(.+)$/', '/^Registrar Registration Expiration Date:\s*(.+)$/' ); $exp_date = array_values(preg_filter($pattern, "$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); }
上一篇: Docker入门之-Docker镜像