From 14700052b855bc6aaa236e93cfb9e31f34bf8565 Mon Sep 17 00:00:00 2001 From: net909 Date: Sun, 7 Jul 2024 13:39:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A1=B5=E9=9D=A2=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E9=94=99=E8=AF=AF=EF=BC=8C=E6=94=AF=E6=8C=81dnspod?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/Domain.php | 5 ++-- app/lib/dns/dnspod.php | 39 +++++++++++++++++++++++++++---- app/middleware/ViewOutput.php | 2 +- app/view/dmonitor/task.html | 4 ++-- app/view/dmonitor/taskinfo.html | 4 ++-- app/view/domain/account.html | 4 ++-- app/view/domain/domain.html | 4 ++-- app/view/domain/log.html | 4 ++-- app/view/domain/record.html | 4 ++-- app/view/optimizeip/opiplist.html | 4 ++-- app/view/user/log.html | 4 ++-- app/view/user/user.html | 4 ++-- 12 files changed, 57 insertions(+), 25 deletions(-) diff --git a/app/controller/Domain.php b/app/controller/Domain.php index 9542739..39f23d1 100644 --- a/app/controller/Domain.php +++ b/app/controller/Domain.php @@ -7,6 +7,7 @@ use think\facade\Db; use think\facade\View; use think\facade\Request; use app\lib\DnsHelper; +use Exception; class Domain extends BaseController { @@ -253,9 +254,9 @@ class Domain extends BaseController $minTTL = cache('min_ttl_'.$drow['id']); if(empty($recordLine)){ $dns = DnsHelper::getModel($drow['aid'], $drow['name'], $drow['thirdid']); - if(!$dns) return $this->alert('error', 'DNS模块不存在'); + if(!$dns) throw new Exception('DNS模块不存在'); $recordLine = $dns->getRecordLine(); - if(!$recordLine) return $this->alert('error', '获取解析线路列表失败,'.$dns->getError()); + if(!$recordLine) throw new Exception('获取解析线路列表失败,'.$dns->getError()); cache('record_line_'.$drow['id'], $recordLine, 604800); $minTTL = $dns->getMinTTL(); if($minTTL){ diff --git a/app/lib/dns/dnspod.php b/app/lib/dns/dnspod.php index 7f2af1d..81f16ec 100644 --- a/app/lib/dns/dnspod.php +++ b/app/lib/dns/dnspod.php @@ -12,6 +12,7 @@ class dnspod implements DnsInterface { private $error; private $domain; private $domainid; + private $domainInfo; function __construct($config){ $this->SecretId = $config['ak']; @@ -24,7 +25,7 @@ class dnspod implements DnsInterface { } public function check(){ - if($this->getAccountInfo() != false){ + if($this->getDomainList() != false){ return true; } return false; @@ -194,6 +195,15 @@ class dnspod implements DnsInterface { $list = []; $this->processLineList($list, $data['LineList'], null); return $list; + }else{ + $data = $this->getRecordLineByGrade(); + if($data){ + $list = []; + foreach($data as $row){ + $list[$row['LineId']] = ['name'=>$row['Name'], 'parent'=>null]; + } + return $list; + } } return false; } @@ -211,11 +221,12 @@ class dnspod implements DnsInterface { //获取域名概览信息 public function getDomainInfo(){ - $action = 'DescribeDomainPreview'; + $action = 'DescribeDomain'; $param = ['Domain' => $this->domain]; $data = $this->send_reuqest($action, $param); if($data){ - return $data['Domain']; + $this->domainInfo = $data['DomainInfo']; + return $data['DomainInfo']; } return false; } @@ -233,16 +244,36 @@ class dnspod implements DnsInterface { //获取域名最低TTL public function getMinTTL(){ + if($this->domainInfo){ + return $this->domainInfo['TTL']; + } $PurviewList = $this->getDomainPurview(); if($PurviewList){ foreach($PurviewList as $row){ - if($row['Name'] == '记录 TTL 最低'){ + if($row['Name'] == '记录 TTL 最低' || $row['Name'] == 'Min TTL value'){ return intval($row['Value']); } } } return false; } + + //获取等级允许的线路 + public function getRecordLineByGrade(){ + $action = 'DescribeRecordLineList'; + $param = ['Domain' => $this->domain, 'DomainGrade' => '']; + $data = $this->send_reuqest($action, $param); + if($data){ + $line_list = $data['LineList']; + if(!empty($data['LineGroupList'])){ + foreach($data['LineGroupList'] as $row){ + $line_list[] = ['Name' => $row['Name'], 'LineId' => $row['LineId']]; + } + return $line_list; + } + } + return false; + } //获取用户信息 public function getAccountInfo(){ diff --git a/app/middleware/ViewOutput.php b/app/middleware/ViewOutput.php index c82db13..f27facc 100644 --- a/app/middleware/ViewOutput.php +++ b/app/middleware/ViewOutput.php @@ -18,7 +18,7 @@ class ViewOutput { View::assign('islogin', $request->islogin); View::assign('user', $request->user); - View::assign('cdnpublic', '//lib.baomitu.com/'); + View::assign('cdnpublic', 'https://s4.zstatic.net/ajax/libs/'); View::assign('skin', getAdminSkin()); return $next($request); } diff --git a/app/view/dmonitor/task.html b/app/view/dmonitor/task.html index aae129e..5cdcddd 100644 --- a/app/view/dmonitor/task.html +++ b/app/view/dmonitor/task.html @@ -33,8 +33,8 @@ tbody tr>td:nth-child(2){overflow: hidden;text-overflow: ellipsis;white-space: n {/block} {block name="script"} - - + + - - + + - - + + - - + + diff --git a/app/view/domain/log.html b/app/view/domain/log.html index 3af7053..c677f2d 100644 --- a/app/view/domain/log.html +++ b/app/view/domain/log.html @@ -16,8 +16,8 @@ {/block} {block name="script"} - - + + - - + + - - + + - - + + - - + +