更新ICP备案查询与whois查询工具
This commit is contained in:
@@ -6,13 +6,19 @@
|
||||
namespace plugin\web\whois;
|
||||
|
||||
use app\Plugin;
|
||||
use think\facade\Db;
|
||||
use Iodev\Whois\Factory;
|
||||
use Iodev\Whois\Exceptions\ConnectionException;
|
||||
use Iodev\Whois\Exceptions\ServerMismatchException;
|
||||
use Iodev\Whois\Exceptions\WhoisException;
|
||||
use Exception;
|
||||
|
||||
class App extends Plugin
|
||||
{
|
||||
const CACHE_TIME = 172800;
|
||||
|
||||
// https://help.aliyun.com/document_detail/35793.html
|
||||
const status_name = ['ok'=>'正常状态', 'addPeriod'=>'域名新注册期', 'clientDeleteProhibited'=>'注册商设置禁止删除', 'serverDeleteProhibited'=>'注册局设置禁止删除', 'clientUpdateProhibited'=>'注册商设置禁止更新', 'serverUpdateProhibited'=>'注册局设置禁止更新', 'clientTransferProhibited'=>'注册商设置禁止转移', 'serverTransferProhibited'=>'注册局设置禁止转移', 'pendingVerification'=>'注册信息审核期', 'clientHold'=>'注册商设置暂停解析', 'serverHold'=>'注册局设置暂停解析', 'inactive'=>'非激活状态', 'clientRenewProhibited'=>'注册商设置禁止续费', 'serverRenewProhibited'=>'注册局设置禁止续费', 'pendingTransfer'=>'转移过程中', 'redemptionPeriod'=>'赎回期', 'pendingDelete'=>'待删除'];
|
||||
const status_name = ['ok'=>'正常状态', 'active'=>'正常状态', 'addPeriod'=>'域名新注册期', 'clientDeleteProhibited'=>'注册商设置禁止删除', 'serverDeleteProhibited'=>'注册局设置禁止删除', 'clientUpdateProhibited'=>'注册商设置禁止更新', 'serverUpdateProhibited'=>'注册局设置禁止更新', 'clientTransferProhibited'=>'注册商设置禁止转移', 'serverTransferProhibited'=>'注册局设置禁止转移', 'pendingVerification'=>'注册信息审核期', 'clientHold'=>'注册商设置暂停解析', 'serverHold'=>'注册局设置暂停解析', 'inactive'=>'非激活状态', 'clientRenewProhibited'=>'注册商设置禁止续费', 'serverRenewProhibited'=>'注册局设置禁止续费', 'pendingTransfer'=>'转移过程中', 'redemptionPeriod'=>'赎回期', 'pendingDelete'=>'待删除'];
|
||||
|
||||
public function index()
|
||||
{
|
||||
@@ -35,13 +41,58 @@ class App extends Plugin
|
||||
return msg('error', '验证失败,请重新验证');
|
||||
}
|
||||
|
||||
if(self::CACHE_TIME > 0){
|
||||
$cache = Db::name('querycache')->where('type', 'whois')->where('key', $domain)->find();
|
||||
if($cache && time() - strtotime($cache['uptime']) <= self::CACHE_TIME){
|
||||
$array = json_decode($cache['content'], true);
|
||||
return msg('ok','success',$array);
|
||||
}
|
||||
}
|
||||
|
||||
$url = 'https://whois.aite.xyz/?ajax&domain='.urlencode($domain);
|
||||
$data = get_curl($url,0,'https://whois.aite.xyz/');
|
||||
if(!$data) return msg('error', '查询失败,接口返回内容错误');
|
||||
try {
|
||||
$whois = Factory::get()->createWhois();
|
||||
$info = $whois->loadDomainInfo($domain);
|
||||
} catch (ConnectionException $e) {
|
||||
return msg('error', '查询失败,Whois服务器连接失败');
|
||||
} catch (ServerMismatchException $e) {
|
||||
return msg('error', '查询失败,Whois服务器不存在');
|
||||
} catch (WhoisException $e) {
|
||||
return msg('error', '查询失败,'.$e->getMessage());
|
||||
}
|
||||
if(!$info){
|
||||
return msg('ok','success',null);
|
||||
}
|
||||
|
||||
if(strpos($data,'For more information on')){
|
||||
$data = substr($data, 0, strpos($data,'For more information on'));
|
||||
$data = ['domainName'=>$info->domainName, 'whoisServer'=>$info->whoisServer, 'creationDate'=>$info->creationDate ? date('Y-m-d H:i:s', $info->creationDate) : null, 'expirationDate'=>$info->expirationDate ? date('Y-m-d H:i:s', $info->expirationDate) : null, 'updatedDate'=>$info->updatedDate ? date('Y-m-d H:i:s', $info->updatedDate) : $info->updatedDate, 'nameServers'=>$info->nameServers, 'states'=>$info->states, 'owner'=>$info->owner, 'registrar'=>$info->registrar, 'dnssec'=>$info->dnssec, 'rawData'=>$info->getResponse()->text];
|
||||
|
||||
if(strpos($data['rawData'],'For more information on')){
|
||||
$data['rawData'] = substr($data['rawData'], 0, strpos($data['rawData'],'For more information on'));
|
||||
}
|
||||
|
||||
$status_name = array_change_key_case(self::status_name, CASE_LOWER);
|
||||
if(!empty($data['states'])){
|
||||
$status = [];
|
||||
foreach($data['states'] as $state){
|
||||
$name = null;
|
||||
$key = str_replace(' ', '', strtolower($state));
|
||||
if(isset($status_name[$key]))
|
||||
$name = $status_name[$key];
|
||||
if(!$name) {$name = $state;$state = null;}
|
||||
$status[] = ['value'=>$state, 'name'=>$name];
|
||||
}
|
||||
$data['states'] = $status;
|
||||
}
|
||||
|
||||
if(self::CACHE_TIME > 0){
|
||||
Db::name('querycache')->duplicate([
|
||||
'content' => json_encode($data),
|
||||
'uptime' => date('Y-m-d H:i:s')
|
||||
])->insertGetId([
|
||||
'type' => 'whois',
|
||||
'key' => $domain,
|
||||
'content' => json_encode($data),
|
||||
'uptime' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
}
|
||||
|
||||
return msg('ok','success',$data);
|
||||
|
||||
@@ -5,6 +5,27 @@
|
||||
.query-title {
|
||||
text-align: right;
|
||||
}
|
||||
.whois-badge {
|
||||
display: block;
|
||||
padding: 3px 10px;
|
||||
margin: 3px 0 3px 0;
|
||||
background: #f0f4ff;
|
||||
color: #364a63;
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.whois-raw-data {
|
||||
background: #f5f6fa;
|
||||
border-radius: 4px;
|
||||
padding: 15px;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
color: #364a63;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
<div class="container-xl" id="app">
|
||||
<div class="col-sm-12 col-md-10 col-xl-8 center-block">
|
||||
@@ -29,7 +50,24 @@
|
||||
<div class="nya-title nk-ibx-action-item progress-rating">
|
||||
<span class="nk-menu-text font-weight-bold">查询结果</span>
|
||||
</div>
|
||||
<div class="border p-2" v-html="result_info" style="white-space: nowrap;overflow-x: scroll;word-break: break-all;">
|
||||
<div class="alert alert-warning text-center" v-if="!result_info"><h6><em class="icon ni ni-info"></em> 没有查询到该域名Whois信息</h6></div>
|
||||
<div class="col-sm-12 col-md-10 col-xl-8 center-block" v-if="result_info">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-bordered">
|
||||
<tbody>
|
||||
<tr><td class="query-title">域名</td><td>{{whoisData.domainName}}</td></tr>
|
||||
<tr><td class="query-title">域名所有者</td><td>{{whoisData.owner || '-'}}</td></tr>
|
||||
<tr><td class="query-title">注册商</td><td>{{whoisData.registrar}}</td></tr>
|
||||
<tr><td class="query-title">Whois服务器</td><td>{{whoisData.whoisServer}}</td></tr>
|
||||
<tr><td class="query-title">注册时间</td><td>{{whoisData.creationDate}}</td></tr>
|
||||
<tr><td class="query-title">到期时间</td><td>{{whoisData.expirationDate}}</td></tr>
|
||||
<tr><td class="query-title">更新时间</td><td>{{whoisData.updatedDate}}</td></tr>
|
||||
<tr><td class="query-title">域名状态</td><td><div v-for="(item, index) in whoisData.states" :key="index">{{item.name}}<span class="text-muted" v-if="item.value">({{item.value}})</span></div></td></tr>
|
||||
<tr><td class="query-title">DNS服务器</td><td><span class="whois-badge" v-for="(ns, index) in whoisData.nameServers" :key="index">{{ns}}</span></td></tr>
|
||||
<tr><td class="query-title">原始信息</td><td class="whois-raw-data">{{whoisData.rawData}}</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -46,7 +84,21 @@ new Vue({
|
||||
query_disabled: true,
|
||||
input: '',
|
||||
showresult: false,
|
||||
result_info: '',
|
||||
result_info: false,
|
||||
whoisData: {
|
||||
cacheTime: '',
|
||||
domainName: '',
|
||||
whoisServer: '',
|
||||
creationDate: '',
|
||||
expirationDate: '',
|
||||
updatedDate: '',
|
||||
nameServers: [],
|
||||
states: [],
|
||||
owner: '',
|
||||
registrar: '',
|
||||
dnssec: '',
|
||||
rawData: '',
|
||||
},
|
||||
captcha: null
|
||||
},
|
||||
mounted() {
|
||||
@@ -82,8 +134,28 @@ new Vue({
|
||||
success: function (data) {
|
||||
layer.closeAll();
|
||||
if(data.status=='ok'){
|
||||
if(data.data == null){
|
||||
that.result_info = false;
|
||||
that.showresult = true;
|
||||
captcha.reset();
|
||||
return;
|
||||
}
|
||||
that.result_info = true;
|
||||
that.whoisData = {
|
||||
cacheTime: data.data.cacheTime || '',
|
||||
domainName: data.data.domainName || '',
|
||||
whoisServer: data.data.whoisServer || '',
|
||||
creationDate: data.data.creationDate || '',
|
||||
expirationDate: data.data.expirationDate || '',
|
||||
updatedDate: data.data.updatedDate || '',
|
||||
nameServers: Array.isArray(data.data.nameServers) ? data.data.nameServers : [],
|
||||
states: Array.isArray(data.data.states) ? data.data.states : [],
|
||||
owner: data.data.owner !== undefined ? data.data.owner : '',
|
||||
registrar: data.data.registrar || '',
|
||||
dnssec: data.data.dnssec || '',
|
||||
rawData: data.data.rawData || '',
|
||||
};
|
||||
that.showresult = true;
|
||||
that.result_info = data.data;
|
||||
captcha.reset();
|
||||
}else{
|
||||
alert(data.message);
|
||||
|
||||
Reference in New Issue
Block a user