From 940387504493f16f8361553d6aa2599cb5adb250 Mon Sep 17 00:00:00 2001 From: net909 Date: Sat, 2 May 2026 20:49:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=95=8C=E9=9D=A2=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/Domain.php | 102 +- app/view/common/layout.html | 6 - app/view/domain/category.html | 204 ++++ app/view/domain/dnscheck.html | 262 ----- app/view/domain/domain.html | 16 +- app/view/domain/record.html | 11 +- app/view/domain/smartparse.html | 1649 ++----------------------------- config/app.php | 2 +- 8 files changed, 286 insertions(+), 1966 deletions(-) create mode 100644 app/view/domain/category.html delete mode 100644 app/view/domain/dnscheck.html diff --git a/app/controller/Domain.php b/app/controller/Domain.php index 5da1d84..b68bf80 100644 --- a/app/controller/Domain.php +++ b/app/controller/Domain.php @@ -1328,108 +1328,12 @@ class Domain extends BaseController } $dns_records = array_map('strtolower', $dns_records); - $expected_value = strtolower(trim($value)); + $expected_value = strtolower(rtrim(trim($value), '.')); if (in_array($expected_value, $dns_records)) { - return json(['code' => 0, 'data' => ['status' => 'active', 'message' => '解析已生效', 'actual' => $dns_records]]); + return json(['code' => 0, 'data' => ['status' => 'active', 'actual' => $dns_records]]); } else { - return json(['code' => 0, 'data' => ['status' => 'mismatch', 'message' => '解析值不匹配', 'expected' => $expected_value, 'actual' => $dns_records]]); - } - } - - public function dnscheck() - { - if (!checkPermission(1)) return $this->alert('error', '无权限'); - - if (request()->isAjax()) { - $domain = input('post.domain', null, 'trim'); - $type = input('post.type', null, 'trim'); - $dns_server = input('post.dns_server', 'default', 'trim'); - - if (empty($domain) || empty($type)) { - return json(['code' => -1, 'msg' => '域名和记录类型不能为空']); - } - - $domain = strtolower($domain); - - $supported_types = ['A', 'AAAA', 'CNAME', 'MX', 'TXT', 'NS', 'SOA', 'SRV', 'CAA', 'PTR']; - if (!in_array($type, $supported_types)) { - return json(['code' => -1, 'msg' => '该记录类型暂不支持检测']); - } - - $result = $this->query_dns_with_server($domain, $type, $dns_server); - - return json($result); - } - - return view(); - } - - private function query_dns_with_server($domain, $type, $dns_server) - { - $dns_servers = [ - 'alidns' => ['223.5.5.5', '223.6.6.6'], - 'dnspod' => ['119.29.29.29', '182.254.116.116'], - 'google' => ['8.8.8.8', '8.8.4.4'], - 'cloudflare' => ['1.1.1.1', '1.0.0.1'], - ]; - - $server_names = [ - 'default' => '系统默认', - 'alidns' => '阿里DNS', - 'dnspod' => 'DNSPod', - 'google' => 'Google DNS', - 'cloudflare' => 'Cloudflare', - ]; - - if ($dns_server != 'default' && isset($dns_servers[$dns_server])) { - $records = $this->query_dns_custom_server($domain, $type, $dns_servers[$dns_server][0]); - } else { - $records = DnsQueryUtils::get_dns_records($domain, $type); - if ($records === false || empty($records)) { - $records = DnsQueryUtils::query_dns_doh($domain, $type); - } - } - - if ($records === false) { - return ['code' => 0, 'data' => ['status' => 'error', 'message' => '查询失败', 'dns_server' => $server_names[$dns_server] ?? $dns_server]]; - } - - if (empty($records)) { - return ['code' => 0, 'data' => ['status' => 'not_found', 'message' => '未找到该类型的DNS记录', 'dns_server' => $server_names[$dns_server] ?? $dns_server]]; - } - - return ['code' => 0, 'data' => ['status' => 'success', 'records' => $records, 'dns_server' => $server_names[$dns_server] ?? $dns_server]]; - } - - private function query_dns_custom_server($domain, $type, $server) - { - $dns_type = ['A' => DNS_A, 'AAAA' => DNS_AAAA, 'CNAME' => DNS_CNAME, 'MX' => DNS_MX, 'TXT' => DNS_TXT, 'NS' => DNS_NS, 'SOA' => DNS_SOA, 'PTR' => DNS_PTR, 'SRV' => DNS_SRV, 'CAA' => DNS_CAA]; - - if (!array_key_exists($type, $dns_type)) { - return false; - } - - try { - $cmd = 'dig +short +time=5 @' . escapeshellarg($server) . ' ' . escapeshellarg($domain) . ' ' . escapeshellarg($type) . ' 2>/dev/null'; - $output = shell_exec($cmd); - - if (empty($output)) { - return false; - } - - $lines = explode("\n", trim($output)); - $result = []; - foreach ($lines as $line) { - $line = trim($line); - if (!empty($line)) { - $result[] = $line; - } - } - - return empty($result) ? false : $result; - } catch (Exception $e) { - return false; + return json(['code' => 0, 'data' => ['status' => 'mismatch', 'expected' => $expected_value, 'actual' => $dns_records]]); } } diff --git a/app/view/common/layout.html b/app/view/common/layout.html index 4b8434e..2804f6c 100644 --- a/app/view/common/layout.html +++ b/app/view/common/layout.html @@ -109,12 +109,6 @@
  • 域名管理
  • -
  • - DNS检测工具 -
  • -
  • - 智能解析 -
  • {if request()->user['level'] eq 2}
  • 域名账户 diff --git a/app/view/domain/category.html b/app/view/domain/category.html new file mode 100644 index 0000000..99448a7 --- /dev/null +++ b/app/view/domain/category.html @@ -0,0 +1,204 @@ +{extend name="common/layout" /} +{block name="title"}域名分类管理{/block} +{block name="main"} + + +
    +
    +
    +
    +

    域名分类管理

    +
    + +
    +
    +
    +{/block} +{block name="script"} + + + + + + +{/block} diff --git a/app/view/domain/dnscheck.html b/app/view/domain/dnscheck.html deleted file mode 100644 index 5db9539..0000000 --- a/app/view/domain/dnscheck.html +++ /dev/null @@ -1,262 +0,0 @@ -{extend name="common/layout" /} -{block name="title"}DNS解析检测工具{/block} -{block name="main"} - -
    -
    -
    -
    -

    DNS解析检测工具

    -
    -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - - - - - -
    -
    -
    -
    - - -
    -
    -
    - - -
    -
    - -
    -
    -

    使用说明

    -
    -
    -
      -
    • A记录:检测域名解析到的IPv4地址
    • -
    • AAAA记录:检测域名解析到的IPv6地址
    • -
    • CNAME记录:检测域名的别名指向
    • -
    • MX记录:检测邮件服务器配置
    • -
    • TXT记录:检测文本记录内容(常用于SPF、DKIM验证)
    • -
    • NS记录:检测域名的DNS服务器
    • -
    • SOA记录:检测域名的授权信息
    • -
    • SRV记录:检测服务定位记录
    • -
    • CAA记录:检测证书颁发机构授权
    • -
    • PTR记录:检测反向解析记录
    • -
    -

    提示:可以选择不同的DNS服务器来检测解析是否在全球生效。

    -
    -
    -
    -
    -{/block} -{block name="script"} - - -{/block} diff --git a/app/view/domain/domain.html b/app/view/domain/domain.html index dcdd868..c3ae3a7 100644 --- a/app/view/domain/domain.html +++ b/app/view/domain/domain.html @@ -163,7 +163,7 @@ {if $user['level'] eq 2} 添加 到期提醒设置{/if} @@ -215,13 +215,6 @@ $(document).ready(function(){ return ''+(row.aremark?row.aremark:value+'('+row.aid+')'); } }, - { - field: 'category_name', - title: '分类', - formatter: function(value, row, index) { - return value ? '' + value + '' : '-'; - } - }, { field: 'name', title: '域名', @@ -305,6 +298,13 @@ $(document).ready(function(){ return value==1?'':''; } }, + { + field: 'category_name', + title: '分类', + formatter: function(value, row, index) { + return value ? '' + value + '' : '-'; + } + }, { field: 'remark', title: '备注' diff --git a/app/view/domain/record.html b/app/view/domain/record.html index 9cc4813..0148fe8 100644 --- a/app/view/domain/record.html +++ b/app/view/domain/record.html @@ -735,20 +735,19 @@ function checkRecord(recordid) { $.ajax({ type : 'POST', url : '/record/check/{$domainId}', - data : {recordid: recordid, name: row.Name, type: row.Type, value: row.Value}, + data : {recordid: recordid, name: row.Name, type: row.Type, value: Array.isArray(row.Value) ? row.Value[0] : row.Value}, dataType : 'json', success : function(data) { layer.close(ii); if(data.code == 0){ var result = data.data; - var icon = result.status === 'active' ? 1 : (result.status === 'not_found' ? 0 : 2); - var title = result.status === 'active' ? '解析已生效' : (result.status === 'not_found' ? '未查询到解析' : '解析值不匹配'); - var content = '
    '; + var title = result.status === 'active' ? ' 解析已生效' : (result.status === 'not_found' ? ' 未查询到解析' : ' 解析值不匹配'); + var content = '
    '; content += '

    主机记录:' + row.Name + '

    '; content += '

    记录类型:' + row.Type + '

    '; content += '

    记录值:' + htmlEscape(row.Value) + '

    '; content += '
    '; - content += '

    检测结果:' + result.message + '

    '; + content += '

    检测结果:' + title + '

    '; if(result.actual && result.actual.length > 0){ content += '

    实际解析值:

    '; content += '
      '; @@ -761,7 +760,7 @@ function checkRecord(recordid) { content += '

      期望解析值:' + htmlEscape(result.expected) + '

      '; } content += '
    '; - layer.alert(content, {title: title, icon: icon, area: ['450px']}); + layer.alert(content, {title: 'DNS解析检测', area: ['450px'], shadeClose: true}); }else{ layer.alert(data.msg, {icon: 2}); } diff --git a/app/view/domain/smartparse.html b/app/view/domain/smartparse.html index 16ff64c..1531ae4 100644 --- a/app/view/domain/smartparse.html +++ b/app/view/domain/smartparse.html @@ -1,104 +1,7 @@ {extend name="common/layout" /} -{block name="title"}智能解析助手{/block} +{block name="title"}智能批量添加{/block} {block name="main"} -
    -
    -

    智能解析助手

    - -
    - - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -

    填写域名前缀,支持多级

    -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    - -
    - -

    单位:秒,默认600秒

    -
    -
    - - -
    -
    - - -
    -
    -
    -
    - -
    +
    +
    +
    +
    +

    返回智能批量添加解析

    +
    +
    - -
    + +

    每行一条记录,支持混合输入多个域名的记录

    @@ -314,16 +105,16 @@
    - -
    + +

    留空则不使用格式4

    - -
    + +
    @@ -353,8 +144,8 @@
    - -
    + +
    @@ -363,251 +154,43 @@
    - -
    + +

    默认TTL时间(秒)

    -
    - - - +
    + + +
    - - - -
    - - - -