From 8d653b872a32d06ae41a88b5d383675ff97970d9 Mon Sep 17 00:00:00 2001 From: net909 Date: Sat, 20 Apr 2024 21:36:11 +0800 Subject: [PATCH] fix --- app/controller/Dmonitor.php | 3 ++- app/controller/Index.php | 2 +- app/lib/dns/huawei.php | 21 ++++++++++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/controller/Dmonitor.php b/app/controller/Dmonitor.php index b60e45e..b530f75 100644 --- a/app/controller/Dmonitor.php +++ b/app/controller/Dmonitor.php @@ -5,6 +5,7 @@ use app\BaseController; use Exception; use think\facade\Db; use think\facade\View; +use think\facade\Cache; use app\lib\DnsHelper; class Dmonitor extends BaseController @@ -222,7 +223,7 @@ class Dmonitor extends BaseController continue; } config_set($key, $value); - Cache::clear(); + Cache::delete('configs'); } return json(['code'=>0, 'msg'=>'succ']); } diff --git a/app/controller/Index.php b/app/controller/Index.php index 09612d5..0c95680 100644 --- a/app/controller/Index.php +++ b/app/controller/Index.php @@ -72,7 +72,7 @@ class Index extends BaseController cookie('admin_skin', null); } config_set('admin_skin', $skin); - Cache::clear(); + Cache::delete('configs'); }else{ cookie('admin_skin', $skin); } diff --git a/app/lib/dns/huawei.php b/app/lib/dns/huawei.php index 57c2789..8efb0ba 100644 --- a/app/lib/dns/huawei.php +++ b/app/lib/dns/huawei.php @@ -54,6 +54,7 @@ class huawei implements DnsInterface { $query = ['type' => $Type, 'line_id' => $Line, 'name' => $KeyWord, 'status' => $Status, 'offset' => $offset, 'limit' => $PageSize]; if(!isNullOrEmpty(($SubDomain))){ $query['name'] = $SubDomain; + $query['search_mode'] = 'equal'; } $data = $this->send_reuqest('GET', '/v2.1/zones/'.$this->domainid.'/recordsets', $query); if($data){ @@ -82,7 +83,7 @@ class huawei implements DnsInterface { //获取子域名解析记录列表 public function getSubDomainRecords($SubDomain, $PageNumber=1, $PageSize=20, $Type = null, $Line = null){ - if($SubDomain == '')$SubDomain='@'; + $SubDomain = $this->getHost($SubDomain); return $this->getDomainRecords($PageNumber, $PageSize, null, $SubDomain, $Type, $Line); } @@ -110,9 +111,7 @@ class huawei implements DnsInterface { //添加解析记录 public function addDomainRecord($Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ - if($Name == '@') $Name = ''; - else $Name .= '.'; - $Name .= $this->domain . '.'; + $Name = $this->getHost($Name); $params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => [$Value], 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark]; if($Type == 'MX')$param['weight'] = intval($MX); $data = $this->send_reuqest('POST', '/v2.1/zones/'.$this->domainid.'/recordsets', null, $params); @@ -121,9 +120,7 @@ class huawei implements DnsInterface { //修改解析记录 public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = '0', $TTL = 600, $MX = 1, $Remark = null){ - if($Name == '@') $Name = ''; - else $Name .= '.'; - $Name .= $this->domain . '.'; + $Name = $this->getHost($Name); $params = ['name' => $Name, 'type' => $this->convertType($Type), 'records' => [$Value], 'line'=>$Line, 'ttl' => intval($TTL), 'description' => $Remark]; if($Type == 'MX')$param['weight'] = intval($MX); $data = $this->send_reuqest('PUT', '/v2.1/zones/'.$this->domainid.'/recordsets/'.$RecordId, null, $params); @@ -199,6 +196,13 @@ class huawei implements DnsInterface { return $type; } + private function getHost($Name){ + if($Name == '@') $Name = ''; + else $Name .= '.'; + $Name .= $this->domain . '.'; + return $Name; + } + private function send_reuqest($method, $path, $query = null, $params = null){ if(!empty($query)){ $query = array_filter($query, function($a){ return $a!==null;}); @@ -324,6 +328,9 @@ class huawei implements DnsInterface { if(isset($arr['error_msg'])){ $this->setError($arr['error_msg']); return false; + }elseif(isset($arr['message'])){ + $this->setError($arr['message']); + return false; }else{ return $arr; }