域名过期时间查询代码

admin 2023年6月9日09:08:03评论14 views字数 2083阅读6分56秒阅读模式


话不多说直接上代码

<?php
header
('Content-type: application/json');
$domain
= isset($_REQUEST['domain']) ? $_REQUEST['domain'] : '';
if ($domain == '') {
exit(json_encode(['code' => 201, 'msg' => '缺少domain参数'], JSON_UNESCAPED_UNICODE));
}
if (!preg_match('/^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/', $domain)) {
exit(json_encode(['code' => 202, 'msg' => '域名格式有误'], JSON_UNESCAPED_UNICODE));
}
$data
= domain('http://whois.chinaz.com/' . $domain);
preg_match
('/创建时间</div><div class="fr WhLeList-right"><span>(.*?)</span></div></li>/', $data, $reg);
preg_match
('/过期时间</div><div class="fr WhLeList-right"><span>(.*?)</span>/', $data, $over);
$reg
= $reg[1];
$over
= $over[1];
if ($reg == '' || $over == '') {
exit(json_encode(array('code' => 203, 'msg' => '查询失败', 'domain' => $domain), JSON_UNESCAPED_UNICODE));
} else {
exit(json_encode(array('code' => 200, 'msg' => '查询成功', 'domain' => $domain, 'reg' => $reg, 'over' => $over), JSON_UNESCAPED_UNICODE));
}

function domain($url, $post = 0, $referer = 0, $cookie = 0, $header = 0, $ua = 0, $nobaody = 0)
{
$ch
= curl_init();
curl_setopt
($ch, CURLOPT_URL, $url);
curl_setopt
($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt
($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader
[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
$httpheader
[] = "Accept-Encoding: gzip, deflate, sdch, br";
$httpheader
[] = "Accept-Language: zh-CN,zh;q=0.8";
curl_setopt
($ch, CURLOPT_HTTPHEADER, $httpheader);
if ($post) {
curl_setopt
($ch, CURLOPT_POST, 1);
curl_setopt
($ch, CURLOPT_POSTFIELDS, $post);
}
if ($header) {
curl_setopt
($ch, CURLOPT_HEADER, true);
}
if ($cookie) {
curl_setopt
($ch, CURLOPT_COOKIE, $cookie);
}
if ($referer) {
if ($referer == 1) {
curl_setopt
($ch, CURLOPT_REFERER, 'http://whois.chinaz.com/');
} else {
curl_setopt
($ch, CURLOPT_REFERER, $referer);
}
}
if ($ua) {
curl_setopt
($ch, CURLOPT_USERAGENT, $ua);
} else {
curl_setopt
($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0");
}
if ($nobaody) {
curl_setopt
($ch, CURLOPT_NOBODY, 1);
}
curl_setopt
($ch, CURLOPT_TIMEOUT, 3);
curl_setopt
($ch, CURLOPT_ENCODING, "gzip");
curl_setopt
($ch, CURLOPT_RETURNTRANSFER, 1);
$ret
= curl_exec($ch);
curl_close
($ch);
return $ret;
}

原文始发于微信公众号(衡阳信安):域名过期时间查询代码

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年6月9日09:08:03
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   域名过期时间查询代码http://cn-sec.com/archives/1789656.html

发表评论

匿名网友 填写信息