Saved,由于原有whoisAPI失效,改用WHOIS命令查询,速度更快,但是需要安装whois命令,RHEL下yum install whois即可

This commit is contained in:
2024-01-29 22:00:02 +08:00
parent 2a00928da5
commit 872eabc111
23 changed files with 274 additions and 41 deletions
+47
View File
@@ -0,0 +1,47 @@
<?php
namespace app\controller;
include_once base_path().'/vendor/laysense/dns/src/resource/ipv6.php';
use dnstools\ipv6; #用于IPv6相关
/**
* $ipv6=new IPv6;
* $ipv6->ip2bin($ip);
*/
class DnsController
{
public function DNS($type,$name,$rip,$id,$query)
{
#输出信息
#echo "\n Type:$type \n Domain: $name\n Client IP: $rip \n";
#此处请根据业务需要,通过判断$name和$rip返回正确的数据
#详情请参见 https://github.com/ywnsya/workerman-dns 尤其是 https://github.com/ywnsya/Workerman-DNS/blob/master/start.php 中的用法
if($type=='PTR'){
$send['detail']='dns.laysense.com';
$send['ttl']=30;
$send['type']='PTR';
}
if($type=='A'){
$send['type']='A';
$send['detail'][1]='119.29.29.29';
$send['detail'][2]='8.8.8.8';
$send['ttl']=30;
};
if($type=='AAAA'){
$ipv6=new IPv6;
$send['type']='AAAA';
$send['detail'][1]=bin2hex($ipv6->ip2bin("fe80::2c5f")); #此操作可以还原被简化的IPv6地址 协议内不再对IPv6地址进行处理,请按照本方式传递16进制无":"的完整16位IPv6
$send['detail'][2]=bin2hex($ipv6->ip2bin("2001:0:2851:b9d0:2c5f:f0d9:21be:4b96"));
$send['ttl']=600;
}
#此处无需修改
$send['id']=$id;
$send['query']=$query;
$return=json_encode($send);
return $return;
}
}
+17 -14
View File
@@ -11,12 +11,11 @@ use yzh52521\EasyHttp\Http;
use yzh52521\EasyHttp\Response;
use yzh52521\EasyHttp\RequestException;
class api
{
public function search(Request $request)
{
$content=$request->input('content','0');
$content=trim($request->input('content','0'));
$contenttype=v::ip()->validate($content);
if(!$contenttype){
$contenttype=v::domain(false)->validate($content);
@@ -25,20 +24,23 @@ class api
}else{
$contenttype='domain';
$msg['DNS']=dns_get_record("$content",DNS_ANY);
$msg['IP']=gethostbyname("$content");
exec("whois $content",$msg['WHOIS']);
/**
$whois = Http::get('https://api.devopsclub.cn/api/whoisquery?type=json&standard=true', ['domain' => "$content"])->body();
$whois=json_decode($whois);
if($whois->code !=0){
$msg['Whois']='Whois查询失败';
};
if($whois->data->status !=0){
$msg['Whois']='Whois查询出错,请稍后重试';
};
if($whois->data->status ==2 || $whois->data->status ==3 ){
$msg['Whois']='该域名未注册或该后缀暂不支持查询';
};
if($whois->code == 0 && $whois->data->status == 0){
$msg['Whois']=$whois->data->data;
}
if($whois->code !=0){
$msg['Whois']='Whois查询失败';
};
if($whois->data->status !=0){
$msg['Whois']='Whois查询出错,请稍后重试';
};
if($whois->data->status ==2 || $whois->data->status ==3 ){
$msg['Whois']='该域名未注册或该后缀暂不支持查询';
};
if($whois->code == 0 && $whois->data->status == 0){
$msg['Whois']=$whois->data->data;
}
$safe = Http::get('https://api.devopsclub.cn/api/dcheck', ['url' => "$content"])->body();
$safe=json_decode($safe);
if($safe->code == 0){
@@ -46,6 +48,7 @@ class api
$msg['Wx-Safe']=$safe->data->wx;
$msg['QQ-Safe']=$safe->data->qq;
}
**/
}
}else{
$contenttype='ip';
+1 -1
View File
@@ -269,7 +269,7 @@
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="mr-2 d-none d-lg-inline text-gray-600 small"><?php echo($userinfo->name);?></span>
<img class="img-profile rounded-circle"
src="<?php echo('https://cravatar.cn/avatar/' . md5(strtolower(trim( $userinfo->email ))));?>">
src="<?php echo('https://headimg.b-cdn.net/' . md5(strtolower(trim( $userinfo->email ))));?>">
</a>
<!-- Dropdown - User Information -->
<div class="dropdown-menu dropdown-menu-right shadow animated--grow-in"
+1 -1
View File
@@ -41,7 +41,7 @@ include('common_head.html');?>
<?php
foreach($user as $us){
$us=json_decode($us);
$headurl='https://cravatar.cn/avatar/' . md5(strtolower(trim( $us->email )));
$headurl='https://headimg.b-cdn.net/' . md5(strtolower(trim( $us->email )));
$name='name';
$email='email';
$password='password';