From 9fb3764878c22567c110ed2181e635768feed5d0 Mon Sep 17 00:00:00 2001 From: net909 Date: Mon, 7 Apr 2025 21:26:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E4=B8=AA=E5=9F=9F=E5=90=8D=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E6=B7=BB=E5=8A=A0=E8=A7=A3=E6=9E=90=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/Dmonitor.php | 4 + app/controller/Domain.php | 102 ++++++++++++++++++- app/controller/Index.php | 32 ++++-- app/controller/Optimizeip.php | 4 + app/lib/client/Volcengine.php | 6 +- app/lib/dns/namesilo.php | 2 + app/view/common/layout.html | 2 +- app/view/dmonitor/task.html | 7 +- app/view/domain/batchadd.html | 3 +- app/view/domain/batchadd2.html | 162 ++++++++++++++++++++++++++++++ app/view/domain/batchedit.html | 157 +++++++++++++++++++++++++++++ app/view/domain/domain.html | 14 ++- app/view/index/index.html | 81 ++++++++++++--- app/view/optimizeip/opiplist.html | 7 +- config/app.php | 2 +- route/app.php | 2 + 16 files changed, 550 insertions(+), 37 deletions(-) create mode 100644 app/view/domain/batchadd2.html create mode 100644 app/view/domain/batchedit.html diff --git a/app/controller/Dmonitor.php b/app/controller/Dmonitor.php index 9361cb9..79d8cf7 100644 --- a/app/controller/Dmonitor.php +++ b/app/controller/Dmonitor.php @@ -39,6 +39,7 @@ class Dmonitor extends BaseController { if (!checkPermission(2)) return json(['total' => 0, 'rows' => []]); $type = input('post.type/d', 1); + $status = input('post.status', null); $kw = input('post.kw', null, 'trim'); $offset = input('post.offset/d'); $limit = input('post.limit/d'); @@ -57,6 +58,9 @@ class Dmonitor extends BaseController $select->whereLike('remark', '%' . $kw . '%'); } } + if (!isNullOrEmpty($status)) { + $select->where('status', intval($status)); + } $total = $select->count(); $list = $select->order('A.id', 'desc')->limit($offset, $limit)->field('A.*,B.name domain')->select()->toArray(); diff --git a/app/controller/Domain.php b/app/controller/Domain.php index 0bfd519..de117f0 100644 --- a/app/controller/Domain.php +++ b/app/controller/Domain.php @@ -439,7 +439,6 @@ class Domain extends BaseController public function record_list() { - if (!checkPermission(2)) return $this->alert('error', '无权限'); $id = input('post.id/d'); $rr = input('post.rr', null, 'trim'); @@ -450,16 +449,19 @@ class Domain extends BaseController if (!checkPermission(0, $drow['name'])) return json(['code' => -1, 'msg' => '无权限']); $dns = DnsHelper::getModel($drow['aid'], $drow['name'], $drow['thirdid']); - $domainRecords = $dns->getSubDomainRecords($rr, 1, 100); + $domainRecords = $dns->getSubDomainRecords($rr, 1, 99); if (!$domainRecords) return json(['code' => -1, 'msg' => '获取记录列表失败,' . $dns->getError()]); list($recordLine, $minTTL) = $this->get_line_and_ttl($drow); + $list = []; foreach ($domainRecords['list'] as &$row) { + if ($rr == '@' && ($row['Type'] == 'NS' || $row['Type'] == 'SOA')) continue; $row['LineName'] = isset($recordLine[$row['Line']]) ? $recordLine[$row['Line']]['name'] : $row['Line']; + $list[] = $row; } - return json(['code' => 0, 'data' => $domainRecords['list']]); + return json(['code' => 0, 'data' => $list]); } public function record_add() @@ -768,6 +770,9 @@ class Domain extends BaseController if (empty($record) || empty($recordlist)) { return json(['code' => -1, 'msg' => '参数不能为空']); } + if (is_null($line)) { + $line = DnsHelper::$line_name[$dnstype]['DEF']; + } $dns = DnsHelper::getModel($drow['aid'], $drow['name'], $drow['thirdid']); @@ -786,7 +791,13 @@ class Domain extends BaseController $fail++; } } - return json(['code' => 0, 'msg' => '批量添加解析,成功' . $success . '条,失败' . $fail . '条']); + if ($success > 0) { + return json(['code' => 0, 'msg' => '批量添加解析,成功' . $success . '条,失败' . $fail . '条']); + } elseif($fail > 0) { + return json(['code' => -1, 'msg' => '批量添加解析失败,' . $dns->getError()]); + } else { + return json(['code' => -1, 'msg' => '批量添加解析失败,没有可添加的记录']); + } } list($recordLine, $minTTL) = $this->get_line_and_ttl($drow); @@ -807,6 +818,89 @@ class Domain extends BaseController return view('batchadd'); } + public function record_batch_add2() + { + return view('batchadd2'); + } + + public function record_batch_edit2() + { + if (request()->isAjax()) { + $id = input('post.id/d'); + $drow = Db::name('domain')->where('id', $id)->find(); + if (!$drow) { + return json(['code' => -1, 'msg' => '域名不存在']); + } + $dnstype = Db::name('account')->where('id', $drow['aid'])->value('type'); + if (!checkPermission(0, $drow['name'])) return json(['code' => -1, 'msg' => '无权限']); + + $name = input('post.name', null, 'trim'); + $type = input('post.type', null, 'trim'); + $value = input('post.value', null, 'trim'); + $ttl = input('post.ttl/d', 0); + $mx = input('post.mx/d', 0); + + if (empty($name) || empty($type) || empty($value)) { + return json(['code' => -1, 'msg' => '必填参数不能为空']); + } + $line = DnsHelper::$line_name[$dnstype]['DEF']; + + $dns = DnsHelper::getModel($drow['aid'], $drow['name'], $drow['thirdid']); + $domainRecords = $dns->getSubDomainRecords($name, 1, 99); + if (!$domainRecords) return json(['code' => -1, 'msg' => '获取记录列表失败,' . $dns->getError()]); + if (empty($domainRecords['list'])) return json(['code' => -1, 'msg' => '没有可修改的记录']); + + if ($type == 'A' || $type == 'AAAA' || $type == 'CNAME') { + $list2 = array_filter($domainRecords['list'], function ($item) use ($type) { + return $item['Type'] == $type; + }); + if (!empty($list2)) { + $list = $list2; + } else { + $list = array_filter($domainRecords['list'], function ($item) { + return $item['Type'] == 'A' || $item['Type'] == 'AAAA' || $item['Type'] == 'CNAME'; + }); + } + } else { + $list = array_filter($domainRecords['list'], function ($item) use ($type) { + return $item['Type'] == $type; + }); + } + if (empty($list)) return json(['code' => -1, 'msg' => '没有可修改的'.$type.'记录']); + + $list2 = array_filter($domainRecords['list'], function ($item) use ($line) { + return $item['Line'] == $line; + }); + if (!empty($list2)) $list = $list2; + + $success = 0; + $fail = 0; + foreach ($list as $record) { + if ($name == '@' && ($record['Type'] == 'NS' || $record['Type'] == 'SOA')) continue; + + if ($ttl > 0) $record['TTL'] = $ttl; + if ($mx > 0) $record['MX'] = $mx; + $recordid = $dns->updateDomainRecord($record['RecordId'], $record['Name'], $type, $value, $record['Line'], $record['TTL'], $record['MX'], $record['Weight'], $record['Remark']); + if ($recordid) { + if (is_array($record['Value'])) $record['Value'] = implode(',', $record['Value']); + $this->add_log($drow['name'], '修改解析', $record['Name'].' ['.$record['Type'].'] '.$record['Value'].' → '.$record['Name'].' ['.$type.'] '.$value.' (线路:'.$record['Line'].' TTL:'.$record['TTL'].')'); + $success++; + } else { + $fail++; + } + } + if ($success > 0) { + return json(['code' => 0, 'msg' => '成功修改' . $success . '条解析记录']); + } elseif($fail > 0) { + return json(['code' => -1, 'msg' => $dns->getError()]); + } else { + return json(['code' => -1, 'msg' => '没有可修改的记录']); + } + } + + return view('batchedit'); + } + public function record_log() { $id = input('param.id/d'); diff --git a/app/controller/Index.php b/app/controller/Index.php index 4dfcb7c..237fdc9 100644 --- a/app/controller/Index.php +++ b/app/controller/Index.php @@ -19,18 +19,36 @@ class Index extends BaseController } if ($this->request->isAjax()) { if (input('post.do') == 'stat') { - $stat = ['domains' => 0, 'tasks' => 0, 'certs' => 0, 'deploys' => 0]; + $stat = []; if ($this->request->user['level'] == 2) { $stat['domains'] = Db::name('domain')->count(); - $stat['tasks'] = Db::name('dmtask')->count(); - $stat['certs'] = Db::name('cert_order')->count(); - $stat['deploys'] = Db::name('cert_deploy')->count(); } else { $stat['domains'] = Db::name('domain')->where('name', 'in', $this->request->user['permission'])->count(); - $stat['tasks'] = Db::name('dmtask')->count(); - $stat['certs'] = Db::name('cert_order')->count(); - $stat['deploys'] = Db::name('cert_deploy')->count(); } + $stat['tasks'] = Db::name('dmtask')->count(); + $stat['certs'] = Db::name('cert_order')->count(); + $stat['deploys'] = Db::name('cert_deploy')->count(); + + $run_time = config_get('run_time', null, true); + $run_state = $run_time ? (time() - strtotime($run_time) > 10 ? 0 : 1) : 0; + $stat['dmonitor_state'] = $run_state; + $stat['dmonitor_active'] = Db::name('dmtask')->where('active', 1)->count(); + $stat['dmonitor_status_0'] = Db::name('dmtask')->where('status', 0)->count(); + $stat['dmonitor_status_1'] = Db::name('dmtask')->where('status', 1)->count(); + + $stat['optimizeip_active'] = Db::name('optimizeip')->where('active', 1)->count(); + $stat['optimizeip_status_1'] = Db::name('optimizeip')->where('status', 1)->count(); + $stat['optimizeip_status_2'] = Db::name('optimizeip')->where('status', 2)->count(); + + $stat['certorder_status_3'] = Db::name('cert_order')->where('status', 3)->count(); + $stat['certorder_status_5'] = Db::name('cert_order')->where('status', '<', 0)->count(); + $stat['certorder_status_6'] = Db::name('cert_order')->where('expiretime', '<', date('Y-m-d H:i:s', time() + 86400 * 7))->where('expiretime', '>=', date('Y-m-d H:i:s'))->count(); + $stat['certorder_status_7'] = Db::name('cert_order')->where('expiretime', '<', date('Y-m-d H:i:s'))->count(); + + $stat['certdeploy_status_0'] = Db::name('cert_deploy')->where('status', 0)->count(); + $stat['certdeploy_status_1'] = Db::name('cert_deploy')->where('status', 1)->count(); + $stat['certdeploy_status_2'] = Db::name('cert_deploy')->where('status', -1)->count(); + return json($stat); } return json(['code' => -3]); diff --git a/app/controller/Optimizeip.php b/app/controller/Optimizeip.php index bf76857..b044308 100644 --- a/app/controller/Optimizeip.php +++ b/app/controller/Optimizeip.php @@ -39,6 +39,7 @@ class Optimizeip extends BaseController if (!checkPermission(2)) return json(['total' => 0, 'rows' => []]); $type = input('post.type/d', 1); $kw = input('post.kw', null, 'trim'); + $status = input('post.status', null); $offset = input('post.offset/d'); $limit = input('post.limit/d'); @@ -50,6 +51,9 @@ class Optimizeip extends BaseController $select->whereLike('remark', '%' . $kw . '%'); } } + if (!isNullOrEmpty($status)) { + $select->where('status', intval($status)); + } $total = $select->count(); $list = $select->order('A.id', 'desc')->limit($offset, $limit)->field('A.*,B.name domain')->select(); diff --git a/app/lib/client/Volcengine.php b/app/lib/client/Volcengine.php index f4f7d2c..fc31837 100644 --- a/app/lib/client/Volcengine.php +++ b/app/lib/client/Volcengine.php @@ -226,7 +226,11 @@ class Volcengine $arr = json_decode($response, true); if ($httpCode == 200) { - if (isset($arr['Result'])) { + if (isset($arr['ResponseMetadata']['Error']['MessageCN'])) { + throw new Exception($arr['ResponseMetadata']['Error']['MessageCN']); + } elseif (isset($arr['ResponseMetadata']['Error']['Message'])) { + throw new Exception($arr['ResponseMetadata']['Error']['Message']); + } elseif (isset($arr['Result'])) { return $arr['Result']; } return true; diff --git a/app/lib/dns/namesilo.php b/app/lib/dns/namesilo.php index 2ecb64a..b5ae946 100644 --- a/app/lib/dns/namesilo.php +++ b/app/lib/dns/namesilo.php @@ -120,6 +120,7 @@ class namesilo implements DnsInterface //添加解析记录 public function addDomainRecord($Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = 1, $Weight = null, $Remark = null) { + if ($Name == '@') $Name = ''; $param = ['domain' => $this->domain, 'rrtype' => $Type, 'rrhost' => $Name, 'rrvalue' => $Value, 'rrttl' => $TTL]; if ($Type == 'MX') $param['rrdistance'] = intval($MX); $data = $this->send_reuqest('dnsAddRecord', $param); @@ -129,6 +130,7 @@ class namesilo implements DnsInterface //修改解析记录 public function updateDomainRecord($RecordId, $Name, $Type, $Value, $Line = 'default', $TTL = 600, $MX = 1, $Weight = null, $Remark = null) { + if ($Name == '@') $Name = ''; $param = ['domain' => $this->domain, 'rrid' => $RecordId, 'rrtype' => $Type, 'rrhost' => $Name, 'rrvalue' => $Value, 'rrttl' => $TTL]; if ($Type == 'MX') $param['rrdistance'] = intval($MX); $data = $this->send_reuqest('dnsUpdateRecord', $param); diff --git a/app/view/common/layout.html b/app/view/common/layout.html index 3373d5d..fcc2257 100644 --- a/app/view/common/layout.html +++ b/app/view/common/layout.html @@ -103,7 +103,7 @@ {if request()->user['type'] eq 'user'}
  • 后台首页
  • {/if} -
  • +
  • 域名管理
  • {if request()->user['level'] eq 2} diff --git a/app/view/dmonitor/task.html b/app/view/dmonitor/task.html index 34efc01..7bf84c8 100644 --- a/app/view/dmonitor/task.html +++ b/app/view/dmonitor/task.html @@ -14,11 +14,16 @@ tbody tr>td:nth-child(2){overflow: hidden;text-overflow: ellipsis;white-space: n
    -
    +
    +
    +
    + +
    +
    刷新 添加 diff --git a/app/view/domain/batchadd.html b/app/view/domain/batchadd.html index 7f5f711..1c7cfba 100644 --- a/app/view/domain/batchadd.html +++ b/app/view/domain/batchadd.html @@ -49,7 +49,7 @@
    -
    +
    @@ -110,7 +110,6 @@ function save(){ if(!$("#form-store").data("bootstrapValidator").isValid()){ return; } - var act = $("#form-store input[name=action]").val(); var ii = layer.load(2); $.ajax({ type : 'POST', diff --git a/app/view/domain/batchadd2.html b/app/view/domain/batchadd2.html new file mode 100644 index 0000000..74ed860 --- /dev/null +++ b/app/view/domain/batchadd2.html @@ -0,0 +1,162 @@ +{extend name="common/layout" /} +{block name="title"}批量添加解析{/block} +{block name="main"} + +
    +
    +
    +

    返回批量添加解析

    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    解析记录添加结果

    +
    + + + + + + + + + + + + + + + +
    ID域名添加结果
    {{item.id}}{{item.name}}
    +
    +
    +{/block} +{block name="script"} + + + +{/block} \ No newline at end of file diff --git a/app/view/domain/batchedit.html b/app/view/domain/batchedit.html new file mode 100644 index 0000000..9611bda --- /dev/null +++ b/app/view/domain/batchedit.html @@ -0,0 +1,157 @@ +{extend name="common/layout" /} +{block name="title"}批量修改解析{/block} +{block name="main"} + +
    +
    +
    +

    返回批量修改解析

    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    解析记录修改结果

    +
    + + + + + + + + + + + + + + + +
    ID域名修改结果
    {{item.id}}{{item.name}}
    +
    +
    +{/block} +{block name="script"} + + + +{/block} \ No newline at end of file diff --git a/app/view/domain/domain.html b/app/view/domain/domain.html index 4100f3c..d3193c6 100644 --- a/app/view/domain/domain.html +++ b/app/view/domain/domain.html @@ -109,7 +109,7 @@ {if request()->user['level'] eq 2} 添加 {/if} @@ -351,7 +351,7 @@ function getDomainList(){ function operation(action){ var rows = $("#listTable").bootstrapTable('getSelections'); if(rows.length == 0){ - layer.msg('请选择要操作的记录'); + layer.msg('请选择要操作的域名'); return; } var ids = []; @@ -361,8 +361,16 @@ function operation(action){ if(action == 'editremark'){ batch_edit_remark(ids) return; + }else if(action == 'addrecord'){ + sessionStorage.setItem('domains', JSON.stringify(rows)); + window.location.href = '/record/batchadd'; + return; + }else if(action == 'editrecord'){ + sessionStorage.setItem('domains', JSON.stringify(rows)); + window.location.href = '/record/batchedit'; + return; } - var confirmobj = layer.confirm('确定要删除所选记录吗?', { + var confirmobj = layer.confirm('确定要删除所选域名吗?', { btn: ['确定','取消'] }, function(){ var ii = layer.load(2); diff --git a/app/view/index/index.html b/app/view/index/index.html index 2402e3d..4529629 100644 --- a/app/view/index/index.html +++ b/app/view/index/index.html @@ -71,19 +71,64 @@
    -
    -
    +
    +
    +
    +
    +
    +
    + +

    CF优选IP概览

    +
    + +
    +
    + +
    +

    服务器信息

    - - - - @@ -92,14 +137,6 @@ - - - - - - - - @@ -107,8 +144,6 @@
    框架版本{$info.framework_version}
    PHP版本 {$info.php_version}MySQL版本 {$info.mysql_version}
    WEB软件{$info.software}
    操作系统{$info.os}
    服务器时间 {$info.date}
    -
    -
    @@ -134,6 +169,20 @@ $(document).ready(function(){ $('#count2').html(data.tasks); $('#count3').html(data.certs); $('#count4').html(data.deploys); + $('#dmonitor_state').html(data.dmonitor_state==1?'正在运行':'已停止'); + $('#dmonitor_active').html(data.dmonitor_active); + $('#dmonitor_status_0').html(data.dmonitor_status_0); + $('#dmonitor_status_1').html(data.dmonitor_status_1); + $('#optimizeip_active').html(data.optimizeip_active); + $('#optimizeip_status_1').html(data.optimizeip_status_1); + $('#optimizeip_status_2').html(data.optimizeip_status_2); + $('#certorder_status_3').html(data.certorder_status_3); + $('#certorder_status_5').html(data.certorder_status_5); + $('#certorder_status_6').html(data.certorder_status_6); + $('#certorder_status_7').html(data.certorder_status_7); + $('#certdeploy_status_0').html(data.certdeploy_status_0); + $('#certdeploy_status_1').html(data.certdeploy_status_1); + $('#certdeploy_status_2').html(data.certdeploy_status_2); $.ajax({ url: '{$checkupdate}', type: 'get', diff --git a/app/view/optimizeip/opiplist.html b/app/view/optimizeip/opiplist.html index 8a283e3..ba24860 100644 --- a/app/view/optimizeip/opiplist.html +++ b/app/view/optimizeip/opiplist.html @@ -14,11 +14,16 @@ tbody tr>td:nth-child(2){overflow: hidden;text-overflow: ellipsis;white-space: n
    -
    +
    +
    +
    + +
    +
    刷新 添加 diff --git a/config/app.php b/config/app.php index ec7e6f0..67b519e 100644 --- a/config/app.php +++ b/config/app.php @@ -31,7 +31,7 @@ return [ 'show_error_msg' => true, 'exception_tmpl' => \think\facade\App::getAppPath() . 'view/exception.tpl', - 'version' => '1031', + 'version' => '1032', 'dbversion' => '1028' ]; diff --git a/route/app.php b/route/app.php index 6d10203..39c0b62 100644 --- a/route/app.php +++ b/route/app.php @@ -64,6 +64,8 @@ Route::group(function () { Route::post('/record/batch/:id', 'domain/record_batch'); Route::post('/record/batchedit/:id', 'domain/record_batch_edit'); Route::any('/record/batchadd/:id', 'domain/record_batch_add'); + Route::get('/record/batchadd', 'domain/record_batch_add2'); + Route::any('/record/batchedit', 'domain/record_batch_edit2'); Route::any('/record/log/:id', 'domain/record_log'); Route::post('/record/list', 'domain/record_list'); Route::post('/record/weight/data/:id', 'domain/weight_data');