This commit is contained in:
2022-12-24 22:10:40 +08:00
parent 84fc1030a7
commit 2a00928da5
4898 changed files with 429855 additions and 77 deletions
-21
View File
@@ -1,21 +0,0 @@
<?php
namespace app\controller;
include_once base_path().'/vendor/laysense/dns/src/resource/ipv6.php';
use dnstools\ipv6; #用于IPv6相关
class DnsController
{
public function DNS($type,$name,$rip,$id,$query)
{
$ipv6=new IPv6;
$ipv6->ip2bin($ip);
#此处无需修改
$send['id']=$id;
$send['query']=$query;
$return=json_encode($send);
return $return;
}
}
+10 -4
View File
@@ -1,19 +1,25 @@
<?php
namespace app\controller;
use support\Request;
use support\Redis;
use support\View;
class IndexController
{
public function index(Request $request)
{
return response('hello webman');
View::assign('userinfo', $request->session()->get('userinfo'));
return view('index');
}
public function view(Request $request)
public function user(Request $request)
{
return view('index/view', ['name' => 'webman']);
$redis = Redis::connection('default');
$user=$redis->hgetall('User');
View::assign('user', $user);
View::assign('userinfo', $request->session()->get('userinfo'));
return view('user');
}
public function json(Request $request)
+73
View File
@@ -0,0 +1,73 @@
<?php
namespace app\controller;
use support\Request;
use Webman\Captcha\CaptchaBuilder;
use support\View;
use Respect\Validation\Validator as v;
use support\Redis;
use GeoIp2\Database\Reader;
use yzh52521\EasyHttp\Http;
use yzh52521\EasyHttp\Response;
use yzh52521\EasyHttp\RequestException;
class api
{
public function search(Request $request)
{
$content=$request->input('content','0');
$contenttype=v::ip()->validate($content);
if(!$contenttype){
$contenttype=v::domain(false)->validate($content);
if(!$contenttype){
return '请输入合法的IP或域名';
}else{
$contenttype='domain';
$msg['DNS']=dns_get_record("$content",DNS_ANY);
$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;
}
$safe = Http::get('https://api.devopsclub.cn/api/dcheck', ['url' => "$content"])->body();
$safe=json_decode($safe);
if($safe->code == 0){
$msg['Safe']='说明:Wx-Safe和QQ-Safe为该域名的微信/QQ红白状态 danger为红 unknown未知(或白) safe安全 仅供参考';
$msg['Wx-Safe']=$safe->data->wx;
$msg['QQ-Safe']=$safe->data->qq;
}
}
}else{
$contenttype='ip';
$msg['Host']=gethostbyaddr("$content");
$reader = new Reader(base_path().'/geoip/GeoLite2-City/GeoLite2-City.mmdb');
$locate=$reader->city($content);
$country=$locate->raw['country']['names']['zh-CN'];
if(array_key_exists("city",$locate->raw)){
$city=$locate->raw['city']['names']['zh-CN'];
}else{
$city=$country;
}
$msg['Location']="$city/$country";
$msg['Network']=$locate->traits->network;
$asnreader= new Reader(base_path().'/geoip/GeoLite2-ASN/GeoLite2-ASN.mmdb');
$asn=$asnreader->Asn("$content");
$asnnumber=$asn->autonomousSystemNumber;
$msg['ASN']="<a href='//whois.ipip.net/AS$asnnumber' target='_ipip'>AS:".$asnnumber.'/'.$asn->autonomousSystemOrganization.'</a>';
}
View::assign('msg', $msg);
return view('print');
}
}
+54
View File
@@ -0,0 +1,54 @@
<?php
namespace app\controller;
use support\Request;
use Webman\Captcha\CaptchaBuilder;
use support\View;
use Respect\Validation\Validator as v;
use support\Redis;
class login
{
public function index(Request $request)
{
$to=$request->get('to', '/');
View::assign('to', $to);
return view('login');
}
public function check(Request $request)
{
$name = $request->post('name','0');
$password = $request->post('password','0');
$usernameValidator = v::StringType()->noWhitespace()->length(1, 15);
try {
$usernameValidator->setName('用户名')->check($name);
} catch (ValidationException $exception) {
return json(['code'=>500, 'msg'=>$e->getMessage()]);
}
try {
$usernameValidator->setName('密码')->check($password);
} catch (ValidationException $exception) {
return json(['code'=>500, 'msg'=>$e->getMessage()]);
}
$redis = Redis::connection('default');
$userinfo=$redis->hget('User',"$name");
if($userinfo===false){
return json(['code'=>501, 'msg'=>'No Such Username']);
}
$realpass=json_decode($userinfo)->passwd;
if(hash("sha256", $password)==$realpass){
$session = $request->session();
$session->set('userinfo', json_decode($userinfo));
$to = $request->post('to','/admin');
return json(['code'=>200, 'msg'=>'Login Successfully']);
}else{
return json(['code'=>502, 'msg'=>'Auth Failed']);
}
return json(['code'=>999, 'msg'=>'Unknown Problem']);
}
}