### Install Composer Dependencies Source: https://github.com/netcccyun/dnsmgr/blob/main/README.md Run this command if you downloaded the source code package to install project dependencies. Release packages do not require this step. ```bash composer install --no-dev ``` -------------------------------- ### Dmonitor Setup and Execution Instructions Source: https://github.com/netcccyun/dnsmgr/blob/main/app/view/dmonitor/overview.html Instructions for setting up and running the Dmonitor service, including PHP Swoole component requirement, command-line execution, and process management. ```bash 1、php需要安装swoole组件 2、在命令行执行以下命令启动进程: `cd {:app()->getRootPath()} && php think dmtask` 3、也可以使用进程守护管理器,添加守护进程。 运行目录:`{:app()->getRootPath()}` 启动命令:`php think dmtask` ``` -------------------------------- ### Create Directories for Docker Compose Source: https://github.com/netcccyun/dnsmgr/blob/main/README.md Before running the docker-compose setup, create the necessary directories for persistent storage and configuration. ```bash mkdir -p ./web mkdir -p ./mysql/conf mkdir -p ./mysql/logs mkdir -p ./mysql/data ``` -------------------------------- ### Get Domain Details with Quick Login URL Source: https://context7.com/netcccyun/dnsmgr/llms.txt Retrieve detailed information about a domain, including its configuration, record lines, and a secure quick login URL for accessing the domain's management interface. ```bash // POST /domain/domain_info/{id} curl -b cookies.txt -X POST https://yourdns.com/domain/domain_info/1 \ -d "loginurl=1" ``` -------------------------------- ### Restart Docker Container Source: https://github.com/netcccyun/dnsmgr/blob/main/README.md If the failover switching feature does not start automatically after initial setup, restart the Docker container. ```bash docker restart dnsmgr ``` -------------------------------- ### Initialize Bootstrap Table for Account List Source: https://github.com/netcccyun/dnsmgr/blob/main/app/view/cert/deployaccount.html Initializes the Bootstrap Table on the listTable element to display account data. It fetches data from '/cert/account/data?deploy=1' and defines the table columns, including custom formatters for account type and actions. This setup is part of the document's ready function. ```javascript $(document).ready(function(){ updateToolbar(); const defaultPageSize = 15; const pageNumber = typeof window.$\_GET\[\'pageNumber\'\] != 'undefined' ? parseInt(window.$\_GET\[\'pageNumber\'\]) : 1; const pageSize = typeof window.$\_GET\[\'pageSize\'\] != 'undefined' ? parseInt(window.$\_GET\[\'pageSize\'\]) : defaultPageSize; $("#listTable").bootstrapTable({ url: '/cert/account/data?deploy=1', pageNumber: pageNumber, pageSize: pageSize, classes: 'table table-striped table-hover table-bordered', columns: [ { field: 'id', title: 'ID' }, { field: 'typename', title: '账户类型', formatter: function(value, row, index) { return ''+value; } }, { field: 'name', title: '账户名称' }, { field: 'remark', title: '备注' }, { field: 'addtime', title: '添加时间' }, { field: 'action', title: '操作', formatter: function(value, row, index) { var html = '编辑 删除 任务'; return html; } }, ] }) }) ``` -------------------------------- ### DnsHelper: Get DNS Platform Instance Source: https://context7.com/netcccyun/dnsmgr/llms.txt Instantiates a DNS platform driver based on account ID. This object implements `DnsInterface` and allows operations like `getDomainList`, `addDomainRecord`, etc. Ensure the DNS module exists and account credentials are valid. ```php use app\lib\DnsHelper; // 根据账户ID获取DNS模型实例 $dns = DnsHelper::getModel($accountId, 'example.com', 'domain_thirdid'); if (!$dns) { throw new Exception('DNS模块不存在'); } // 验证账户凭证 if (!$dns->check()) { echo '账户验证失败:' . $dns->getError(); exit; } // 获取域名下的所有解析记录(第1页,每页100条) $records = $dns->getDomainRecords(1, 100, '', '', '', '', '', ''); // $records['total'] = 记录总数 // $records['list'] = 记录数组,每条包含 RecordId/Name/Type/Value/Line/TTL/Status 等字段 // 获取支持的解析线路列表 $lines = $dns->getRecordLine(); // 例:['default'=>['name'=>'默认','parent'=>null],'telecom'=>['name'=>'电信','parent'=>null],...] // 添加A记录 $recordId = $dns->addDomainRecord('www', 'A', '1.2.3.4', 'default', 600, 1, 0, '主站'); if (!$recordId) { echo '添加失败:' . $dns->getError(); } // 修改记录 $ok = $dns->updateDomainRecord('rec_001', 'www', 'A', '5.6.7.8', 'default', 300, 1, 0, null); // 删除记录 $ok = $dns->deleteDomainRecord('rec_001'); // 设置记录状态('1'=启用,'0'=暂停) $ok = $dns->setDomainRecordStatus('rec_001', '0'); ``` -------------------------------- ### Initiate Batch DCV Delegation Source: https://github.com/netcccyun/dnsmgr/blob/main/app/view/cloudflare/hostnames.html Prepares for batch DCV (Domain Control Validation) delegation for selected hostnames. It checks for a pre-configured DCV delegation UUID and collects selected hostname data. Use this to start the batch DCV process. ```javascript var batchDcvHostnamesData = []; function batchDcvDelegation(){ var selectedRows = $("#listTable").bootstrapTable('getSelections'); if(selectedRows.length === 0){ layer.msg('请先选择要添加 DCV 委派的自定义主机名', {icon: 0}); return; } // 检查是否已获取 DCV 委派 UUID var uuid = $.trim($('#dcvDelegationUuid').val()); if(!uuid){ layer.msg('请先获取 DCV 委派 UUID', {icon: 0}); return; } batchDcvHostnamesData = selectedRows; // 先获取所有主机名的 DNS 信息,按实际 DNS 域名分组 var hostnamesWithDns = []; var processedCount = 0; var totalCount = selectedRows.length; selectedRows.forEach(function(row, index){ var hostname = row.hostname; var cnameFullName = '_acme-challenge.' + hostname; resolveDcvCnameTargets(cnameFullName, function(targets){ processedCount++; if(targets.length > ``` -------------------------------- ### Initialize Vue Instance for Batch Edit Source: https://github.com/netcccyun/dnsmgr/blob/main/app/view/domain/batchedit.html Sets up the Vue instance, initializes domain list from session storage, and adds a 'result' field to each domain. Handles cases where no domains are selected. ```javascript new Vue({ el: '#app', data: { domainList: [], set: { id: '', name: '', type: 'A', value: '', mx: '', ttl: '', } }, mounted() { this.domainList = JSON.parse(sessionStorage.getItem('domains')) || []; if (this.domainList.length == 0) { layer.alert('请先选中要修改解析的域名', { icon: 2 }, function() { window.location.href = '/domain'; }); } for (var i = 0; i < this.domainList.length; i++) { this.$set(this.domainList[i], 'result', '待修改'); } }, methods: { async save(id) { var that = this; return new Promise((resolve, reject) => { that.set.id = id; $.ajax({ type: "POST", url: '/record/batchedit', data: that.set, dataType: 'json', success: function(data) { resolve(data); }, error: function() { reject('服务器错误'); } }); }); }, async submit() { if (this.set.name == '') { layer.alert('请填写主机记录', { icon: 2 }); return; } if (this.set.value == '') { layer.alert('请填写记录值', { icon: 2 }); return; } var ii = layer.load(2); for (var i = 0; i < this.domainList.length; i++) { this.domainList[i].result = ' 正在修改'; var res = await this.save(this.domainList[i].id); if (res.code == 0) { this.domainList[i].result = '' + res.msg + ''; } else { this.domainList[i].result = '' + res.msg + ''; } } layer.close(ii); } }, }); ``` -------------------------------- ### Initialize CNAME Proxy Table with BootstrapTable Source: https://github.com/netcccyun/dnsmgr/blob/main/app/view/cert/cname.html Initializes a BootstrapTable to display CNAME proxy data. It fetches data from '/cert/cname/data' and configures columns for ID, domain, host, record, status, add time, and actions. Includes custom formatters for copy-to-clipboard functionality and status labels with refresh buttons. The onLoadSuccess event sets up clipboard functionality. ```javascript $(document).ready(function(){ updateToolbar(); const defaultPageSize = 15; const pageNumber = typeof window.$\_GET\[\'pageNumber\'\] != 'undefined' ? parseInt(window.$\_GET\[\'pageNumber\'\]) : 1; const pageSize = typeof window.$\_GET\[\'pageSize\'\] != 'undefined' ? parseInt(window.$\_GET\[\'pageSize\'\]) : defaultPageSize; $("#listTable").bootstrapTable({ url: '/cert/cname/data', pageNumber: pageNumber, pageSize: pageSize, classes: 'table table-striped table-hover table-bordered', uniqueId: 'id', columns: [ { field: 'id', title: 'ID' }, { field: 'domain', title: '被代理域名' }, { field: 'host', title: '主机记录', formatter: function(value, row, index) { return value + ''; } }, { field: 'record', title: 'CNAME记录值', formatter: function(value, row, index) { return value + ''; } }, { field: 'status', title: '状态', formatter: function(value, row, index) { var html = ''; if(value == 1) { html += '已验证'; } else { html += '未验证'; } html += ''; return html; } }, { field: 'addtime', title: '添加时间' }, { field: 'action', title: '操作', formatter: function(value, row, index) { var html = '编辑 删除'; return html; } }, ], onLoadSuccess: function(data){ var clipboard = new Clipboard('.copy-btn'); clipboard.on('success', function (e) { layer.msg('复制成功!', {icon: 1, time: 600}); }); clipboard.on('error', function (e) { layer.msg('复制失败', {icon: 2}); }); } }) }) ``` -------------------------------- ### Fallback Origin Management Source: https://context7.com/netcccyun/dnsmgr/llms.txt APIs for managing the fallback origin server, including getting, setting, and deleting it. ```APIDOC ## GET /cloudflare/fallback_get ### Description Retrieves the current fallback origin server configuration. ### Method POST ### Endpoint /cloudflare/fallback_get ### Response #### Success Response (200) - **code** (integer) - Response code. - **data** (object) - Object containing the fallback origin. - **origin** (string) - The fallback origin server address. ### Response Example { "code": 0, "data": { "origin": "fallback.example.com" } } ## POST /cloudflare/fallback_set ### Description Sets or updates the fallback origin server. ### Method POST ### Endpoint /cloudflare/fallback_set ### Parameters #### Request Body - **origin** (string) - Required - The fallback origin server address to set. ### Response #### Success Response (200) - **code** (integer) - Response code. - **msg** (string) - Success message. - **data** (object) - Object containing the updated fallback origin. - **origin** (string) - The updated fallback origin server address. ### Response Example { "code": 0, "msg": "更新 Fallback Origin 成功", "data": { "origin": "fallback.example.com" } } ## POST /cloudflare/fallback_delete ### Description Deletes the configured fallback origin server. ### Method POST ### Endpoint /cloudflare/fallback_delete ### Response #### Success Response (200) - **code** (integer) - Response code. - **msg** (string) - Success message. ### Response Example { "code": 0, "msg": "已清空 Fallback Origin" } ``` -------------------------------- ### 获取DNS账户列表 Source: https://context7.com/netcccyun/dnsmgr/llms.txt 获取已添加的DNS账户列表,支持关键词搜索和分页。 ```bash curl -b cookies.txt -X POST https://yourdns.com/domain/account_data \ -d "offset=0&limit=20&kw=阿里" ``` -------------------------------- ### Get Certificate Content Source: https://context7.com/netcccyun/dnsmgr/llms.txt Retrieves the content of a previously issued SSL certificate, including the certificate, private key, PFX content, and validity periods. ```APIDOC ## Get Certificate Content ### Description Retrieves the details and content of an SSL certificate. ### Method POST ### Endpoint /cert/order_info ### Parameters #### Request Body - **id** (integer) - Required - The ID of the certificate order. ### Request Example ```bash curl -b cookies.txt -X POST https://yourdns.com/cert/order_info \ -d "id=1" ``` ### Response #### Success Response (200) - **code** (integer) - 0 for success. - **data** (object) - Certificate details. - **id** (integer) - Certificate ID. - **crt** (string) - Certificate content in PEM format. - **key** (string) - Private key in PEM format. - **pfx** (string) - PFX content (Base64 encoded). - **issuetime** (string) - Issue date and time. - **expiretime** (string) - Expiration date and time. - **domains** (array of strings) - List of domains covered by the certificate. #### Response Example ```json { "code": 0, "data": { "id":1,"crt":"-----BEGIN CERTIFICATE-----\n...","key":"-----BEGIN PRIVATE KEY-----\n...", "pfx":"base64编码的PFX内容","issuetime":"2024-01-01 00:00:00","expiretime":"2024-04-01 00:00:00", "domains":["example.com","www.example.com"] } } ``` ``` -------------------------------- ### Create Database in MySQL Container Source: https://github.com/netcccyun/dnsmgr/blob/main/README.md Log into the MySQL container and create the 'dnsmgr' database. Replace '123456' with your actual root password if it differs. ```bash docker exec -it dnsmgr-mysql /bin/bash mysql -uroot -p123456 create database dnsmgr; ``` -------------------------------- ### Get Domain Details with Quick Login URL Source: https://context7.com/netcccyun/dnsmgr/llms.txt Retrieves detailed information about a domain, including its configuration, record lines, and a quick login URL. ```APIDOC ## Get Domain Details with Quick Login URL ### Description Retrieves detailed information about a domain, including its configuration, record lines, and a quick login URL. ### Method POST ### Endpoint /domain/domain_info/{id} ### Parameters #### Query Parameters - **loginurl** (integer) - Optional - Set to 1 to include the quick login URL in the response. ### Request Example ```bash curl -b cookies.txt -X POST https://yourdns.com/domain/domain_info/1 \ -d "loginurl=1" ``` ### Response #### Success Response (200) - **code** (integer) - 0 for success. - **data** (object) - Domain details. - **id** (integer) - Domain ID. - **name** (string) - Domain name. - **thirdid** (string) - Third-party ID. - **recordcount** (integer) - Number of records. - **config** (object) - Domain configuration details. - **recordLine** (array) - Available record lines. - **minTTL** (integer) - Minimum TTL. - **loginurl** (string) - Quick login URL (if requested). #### Response Example ```json { "code": 0, "data": { "id": 1, "name": "example.com", "thirdid": "12345", "recordcount": 12, "config": {"name": "阿里云", "type": "aliyun", "status": true, ...}, "recordLine": [{"id": "default", "name": "默认"}, ...], "minTTL": 1, "loginurl": "https://yourdns.com/quicklogin?domain=example.com×tamp=...&token=...&sign=..." } } ``` ``` -------------------------------- ### Get DNS Account List Source: https://context7.com/netcccyun/dnsmgr/llms.txt Retrieves a list of configured DNS provider accounts, including their names, types, and remarks. Supports keyword search and pagination. ```APIDOC ## Get DNS Account List ### Description Fetches a paginated list of DNS provider accounts configured in the system. Allows filtering by keyword and retrieving account details like ID, name, type, and remarks. ### Method `POST` ### Endpoint `/domain/account_data` ### Parameters #### Request Body - **offset** (integer) - Optional - The starting offset for pagination (default 0). - **limit** (integer) - Optional - The number of records to return per page (default 20). - **kw** (string) - Optional - Keyword to filter account names or types. ### Request Example ```bash curl -b cookies.txt -X POST https://yourdns.com/domain/account_data \ -d "offset=0&limit=20&kw=阿里" ``` ### Response #### Success Response (200) - **total** (integer) - The total number of accounts matching the query. - **rows** (array) - An array of DNS account objects: - **id** (integer) - The unique identifier for the DNS account. - **type** (string) - The type of DNS provider (e.g., 'aliyun', 'cloudflare'). - **name** (string) - The user-defined name for the account. - **remark** (string) - User-defined remarks for the account. - **typename** (string) - Display name of the DNS provider type. - **icon** (string) - Icon file name for the provider. - **addtime** (string) - Timestamp when the account was added. ``` -------------------------------- ### Initialize Bootstrap Table for Domain Logs Source: https://github.com/netcccyun/dnsmgr/blob/main/app/view/domain/log.html Initializes a Bootstrap Table to display domain operation logs. It fetches data from '/record/log/{$domainId}' and configures columns for '操作时间' (Operation Time) and '操作行为' (Operation Behavior). ```javascript $(document).ready(function(){ updateToolbar(); const defaultPageSize = 15; const pageNumber = typeof window.$\_GET\[\'pageNumber\'\] != 'undefined' ? parseInt(window.$\_GET\[\'pageNumber\'\]) : 1; const pageSize = typeof window.$\_GET\[\'pageSize\'\] != 'undefined' ? parseInt(window.$\_GET\[\'pageSize\'\]) : defaultPageSize; $("#listTable").bootstrapTable({ url: '/record/log/{$domainId}', pageNumber: pageNumber, pageSize: pageSize, classes: 'table table-striped table-hover table-bordered', columns: [ { field: 'time', title: '操作时间' }, { field: 'data', title: '操作行为' } ], }) }) ``` -------------------------------- ### Get Domain DNS Record List Source: https://context7.com/netcccyun/dnsmgr/llms.txt Retrieves the DNS records for a specific domain. Supports filtering by keyword, record type, and line (e.g., 'default', 'China'). ```APIDOC ## Get Domain DNS Record List ### Description Fetches a paginated list of DNS records for a specified domain. Allows filtering by keyword, record type, and routing line. ### Method `POST` ### Endpoint `/domain/record_data/{domainId}` ### Parameters #### Path Parameters - **domainId** (integer) - Required - The internal ID of the domain whose records are to be fetched. #### Request Body - **offset** (integer) - Optional - The starting offset for pagination (default 0). - **limit** (integer) - Optional - The number of records to return per page (default 20). - **keyword** (string) - Optional - Keyword to filter record names or values. - **type** (string) - Optional - Filter by DNS record type (e.g., 'A', 'MX', 'CNAME'). - **line** (string) - Optional - Filter by routing line (e.g., 'default', 'China', 'International'). - **status** (string) - Optional - Filter by record status (e.g., '1' for enabled). ### Request Example ```bash curl -b cookies.txt -X POST https://yourdns.com/domain/record_data/1 \ -d "offset=0&limit=20&keyword=mail&type=MX&line=&status=" ``` ### Response #### Success Response (200) - **total** (integer) - The total number of records matching the query. - **rows** (array) - An array of DNS record objects: - **RecordId** (string) - The unique identifier for the DNS record on the provider. - **Name** (string) - The hostname part of the record (e.g., 'mail', '@'). - **Type** (string) - The type of DNS record (e.g., 'MX', 'A', 'CNAME'). - **Value** (string) - The value of the DNS record (e.g., IP address, hostname). - **Line** (string) - The routing line configured for the record. - **TTL** (integer) - The Time To Live for the record in seconds. - **Status** (string) - The status of the record (e.g., '1' for enabled, '0' for disabled). - **MX** (integer) - The MX preference value (if Type is 'MX'). ``` -------------------------------- ### Initialize Bootstrap Table for Weight Configuration Source: https://github.com/netcccyun/dnsmgr/blob/main/app/view/domain/weight.html Initializes a Bootstrap Table to display DNS weight configuration data. It fetches data from '/record/weight/data/{$domainId}' and defines columns for subdomain, record type, record count, status, and operations. The 'Open' column formatter displays status with color coding, and the '操作' (operations) column provides buttons to toggle weight status and edit weights. ```javascript var dnsconfig = {$dnsconfig|json_encode|raw}; var recordLine = {$recordLine|json_encode|raw}; var domainId = {$domainId}; var weightList = []; var lineList = []; $(document).ready(function(){ updateToolbar(); const defaultPageSize = 15; const pageNumber = typeof window.$_GET['pageNumber'] != 'undefined' ? parseInt(window.$_GET['pageNumber']) : 1; const pageSize = typeof window.$_GET['pageSize'] != 'undefined' ? parseInt(window.$_GET['pageSize']) : defaultPageSize; $("#listTable").bootstrapTable({ url: '/record/weight/data/{$domainId}', pageNumber: pageNumber, pageSize: pageSize, classes: 'table table-striped table-hover table-bordered', uniqueId: 'id', columns: [ { field: 'SubDomain', title: '子域名' }, { field: 'Type', title: '记录类型' }, { field: 'RecordCount', title: '记录数量' }, { field: 'Open', title: '权重配置状态', formatter: function(value, row, index) { if(value == 1){ return '已开启'; }else{ return '已关闭'; } } }, { field: '', title: '操作', formatter: function(value, row, index) { var html = ''; if(row.Open == 1){ if(row.Type == 'CNAME'){ html += '关闭权重  '; }else{ html += '关闭权重  '; } }else{ html += '开启权重  '; } html += '设置权重'; return html; } }, ] }) }) ``` -------------------------------- ### Get Domain List Source: https://context7.com/netcccyun/dnsmgr/llms.txt Retrieves a list of domains managed within the system, associated with specific DNS accounts. Supports filtering by keyword, provider type, and account ID. ```APIDOC ## Get Domain List ### Description Fetches a paginated list of domains managed by the system. Domains can be filtered by keyword, associated DNS account type, and the specific DNS account ID. ### Method `POST` ### Endpoint `/domain/domain_data` ### Parameters #### Request Body - **offset** (integer) - Optional - The starting offset for pagination (default 0). - **limit** (integer) - Optional - The number of records to return per page (default 20). - **kw** (string) - Optional - Keyword to filter domain names. - **type** (string) - Optional - Filter by DNS provider type (e.g., 'aliyun'). - **cid** (integer) - Optional - Filter by the DNS account ID. - **order** (integer) - Optional - Sorting order parameter (specific meaning depends on backend implementation). ### Request Example ```bash curl -b cookies.txt -X POST https://yourdns.com/domain/domain_data \ -d "offset=0&limit=20&kw=example.com&type=aliyun&cid=0&order=0" ``` ### Response #### Success Response (200) - **total** (integer) - The total number of domains matching the query. - **rows** (array) - An array of domain objects: - **id** (integer) - The system's internal ID for the domain. - **aid** (integer) - The ID of the associated DNS account. - **name** (string) - The domain name. - **thirdid** (string) - The domain's ID on the third-party DNS provider. - **typename** (string) - The name of the DNS provider type. - **recordcount** (integer) - The number of DNS records for this domain. - **expiretime** (string) - The expiration time of the domain registration (if applicable). - **cid** (integer) - Account category ID (if applicable). ``` -------------------------------- ### Create SSL Certificate Order Source: https://context7.com/netcccyun/dnsmgr/llms.txt Initiate a new SSL certificate order. Specify the account ID, key type and size, and the domains to be included. Wildcard domains are supported if the CA account allows them. ```bash curl -b cookies.txt -X POST "https://yourdns.com/cert/order_op?action=add" \ -d 'aid=1&keytype=RSA&keysize=2048&domains[]=example.com&domains[]=www.example.com' ``` ```bash curl -b cookies.txt -X POST "https://yourdns.com/cert/order_op?action=add" \ -d "aid=-1&keytype=RSA&keysize=2048&fullchain=-----BEGIN CERTIFICATE-----...&privatekey=-----BEGIN PRIVATE KEY-----..." ``` -------------------------------- ### 添加DNS账户 Source: https://context7.com/netcccyun/dnsmgr/llms.txt 添加新的DNS账户,各平台凭证通过 `config` 字段以JSON形式传入。支持阿里云、Cloudflare(API令牌模式)、PowerDNS等。 ```bash curl -b cookies.txt -X POST "https://yourdns.com/domain/account_op?action=add" \ -d 'type=aliyun&name=阿里云主账户&config={"AccessKeyId":"LTAI5tXXX","AccessKeySecret":"xxxxx"}&remark=生产环境' ``` ```bash curl -b cookies.txt -X POST "https://yourdns.com/domain/account_op?action=add" \ -d 'type=cloudflare&name=CF主账户&config={"email":"user@example.com","apikey":"your_api_token","auth":"1"}' ``` ```bash curl -b cookies.txt -X POST "https://yourdns.com/domain/account_op?action=add" \ -d 'type=powerdns&name=自建DNS&config={"ip":"192.168.1.10","port":"8081","apikey":"your_pdns_key"}' ``` -------------------------------- ### Initialize Domain Addition Modal Source: https://github.com/netcccyun/dnsmgr/blob/main/app/view/domain/domain.html Shows the modal for adding a new domain and optionally triggers a change event if a domain account is already selected. ```javascript function addframe(){ $("#modal-store").modal('show'); var aid = $("#form-store select[name=aid]").val(); if(aid != ''){ $("#form-store select[name=aid]").change(); } } ``` -------------------------------- ### Generate and Display TOTP QR Code Source: https://github.com/netcccyun/dnsmgr/blob/main/app/view/index/setpwd.html Generates a TOTP secret and QR code for binding. Displays the QR code and copies the secret key to the clipboard. This function is called when the user initiates the TOTP setup. ```javascript function open_totp(){ if(!commonData.qrcode || !commonData.secret){ var ii = layer.load(2, {shade:["0.1",'#fff']}); $.post('/totp/generate', {}, function(res){ layer.close(ii); if(res.code == 0){ commonData.secret = res.data.secret; commonData.qrcode = res.data.qrcode; $('#qrcode').qrcode({ text: commonData.qrcode, width: 150, height: 150, foreground: "#000000", background: "#ffffff", typeNumber: -1 }); $("#copy-btn").attr('data-clipboard-text', commonData.secret); $('#modal-totp').modal('show'); $("#code").focus(); }else{ layer.alert(res.msg, {icon: 2}); } }); }else{ $('#modal-totp').modal('show'); $("#code").focus(); } } ``` -------------------------------- ### Quick Add TXT Record (JavaScript) Source: https://github.com/netcccyun/dnsmgr/blob/main/app/view/cloudflare/hostnames.html Initiates the process of adding a TXT record. It resolves potential TXT record targets and then either directly confirms the addition or opens a picker if multiple targets are found. Requires `resolveTxtRecordTargets`, `confirmQuickAddTxtRecord`, and `openTxtTargetPicker` functions to be defined. ```javascript function quickAddTxtRecord(btn){ var fullName = decodeURIComponent($(btn).attr('data-name') || ''); var value = decodeURIComponent($(btn).attr('data-value') || ''); var isHostnameVerification = $(btn).attr('data-hostname-verification') === 'true'; resolveTxtRecordTargets(fullName, function(targets){ if(!targets.length){ layer.alert('系统中未找到与该 TXT 主机名对应的托管域名,请手动到解析页添加', {icon: 2}); return; } if(targets.length === 1){ confirmQuickAddTxtRecord(fullName, value, targets[0], isHostnameVerification); return; } openTxtTargetPicker(fullName, value, targets, isHostnameVerification); }); } ``` -------------------------------- ### DnsHelper::$dns_config: Supported DNS Platforms Source: https://context7.com/netcccyun/dnsmgr/llms.txt Access the `dns_config` static property to get a list of all supported DNS platforms. Each platform entry includes details like name, icon, configuration options, status, and supported features such as weight resolution and record status management. ```php // 获取所有支持的DNS平台配置列表 $list = DnsHelper::getList(); // 返回键值对,键为平台标识,值包含 name/icon/config/remark/status/weight/page/add 等属性 // 支持的平台标识: // aliyun(阿里云)、dnspod(腾讯云)、huawei(华为云)、baidu(百度云) // west(西部数码)、huoshan(火山引擎)、jdcloud(京东云)、dnsla(DNSLA) // qingcloud(青云)、bt(宝塔域名)、cloudflare(Cloudflare) // namesilo(NameSilo)、spaceship(Spaceship)、powerdns(PowerDNS) // technitium(Technitium)、aliyunesa(阿里云ESA)、tencenteo(腾讯云EO) // dnsmgr(同系统对接) // 判断某平台是否支持权重解析 $supportsWeight = DnsHelper::$dns_config['dnspod']['weight']; // true // 判断是否支持暂停/启用 $supportsStatus = DnsHelper::$dns_config['aliyun']['status']; // true ``` -------------------------------- ### Initialize Bootstrap Table for Log Display Source: https://github.com/netcccyun/dnsmgr/blob/main/app/view/user/log.html Initializes a Bootstrap Table to display user operation logs. It fetches data from '/log/data' and configures columns for ID, UID, domain, action, details, and timestamp. The UID is formatted to link to user profiles. ```javascript $(document).ready(function(){ updateToolbar(); const defaultPageSize = 15; const pageNumber = typeof window.$\_GET\[\'pageNumber\'\] != 'undefined' ? parseInt(window.$\_GET\[\'pageNumber\'\]) : 1; const pageSize = typeof window.$\_GET\[\'pageSize\'\] != 'undefined' ? parseInt(window.$\_GET\[\'pageSize\'\]) : defaultPageSize; $("#listTable").bootstrapTable({ url: '/log/data', pageNumber: pageNumber, pageSize: pageSize, classes: 'table table-striped table-hover table-bordered', columns: [ { field: 'id', title: 'ID' }, { field: 'uid', title: 'UID', formatter: function(value, row, index) { return value>0?''+value+'':'管理员'; } }, { field: 'domain', title: '域名' }, { field: 'action', title: '操作类型' }, { field: 'data', title: '操作详情' }, { field: 'addtime', title: '时间' } ] }) }) ``` -------------------------------- ### Initialize Bootstrap Table for Task List Source: https://github.com/netcccyun/dnsmgr/blob/main/app/view/dmonitor/task.html Initializes the Bootstrap Table plugin to display and manage DNS monitoring tasks. Configures columns, data source, and event handlers for interactive table features. ```javascript $(document).ready(function(){ updateToolbar(); const defaultPageSize = 15; const pageNumber = typeof window.$\_GET\[\'pageNumber\'\] != 'undefined' ? parseInt(window.$\_GET\[\'pageNumber\']) : 1; const pageSize = typeof window.$\_GET\[\'pageSize\'] != 'undefined' ? parseInt(window.$\_GET\[\'pageSize\']) : defaultPageSize; $("#listTable").bootstrapTable({ url: '/dmonitor/task/data', pageNumber: pageNumber, pageSize: pageSize, classes: 'table table-striped table-hover table-bordered', columns: [ { field: '', checkbox: true }, { field: 'id', title: 'ID' }, { field: 'rr', title: '域名', formatter: function(value, row, index) { return '' + value + '.' + row.domain + ''; } }, { field: 'main\_value', title: '解析记录', formatter: function(value, row, index) { return value; } }, { field: 'type', title: '切换设置', formatter: function(value, row, index) { if(value == 1) { return '暂停解析'; } else if(value == 2) { return '切换备用'; } else if(value == 3) { return '条件开启'; } else { return '无操作'; } } }, { field: 'checktype', title: '检测协议', formatter: function(value, row, index) { if(row.type <= 2){ if(value == 1) { return 'TCP'; } else if(value == 2) { return 'HTTP(S)'; } else { return 'PING'; } } else { return '无'; } } }, { field: 'frequency', title: '检测间隔', formatter: function(value, row, index) { return value + '秒'; } }, { field: 'status', title: '健康状况', formatter: function(value, row, index) { if(value == 0) { return '正常'; } else { return '异常'; } } }, { field: 'active', title: '运行开关', formatter: function(value, row, index) { if(value == 1){ return '
'; }else{ return '
'; } } }, { field: 'checktimestr', title: '上次检测时间' }, { field: 'addtimestr', title: '添加时间', visible: false }, { field: 'remark', title: '备注', visible: false }, { field: 'action', title: '操作', formatter: function(value, row, index) { var html = '切换日志  '; html += '修改  '; html += '解析  '; html += '删除  '; return html; } }, ], onLoadSuccess: function(data) { $('[data-toggle="tooltip"]').tooltip() } }) }) ``` -------------------------------- ### Open TXT Target Picker (JavaScript) Source: https://github.com/netcccyun/dnsmgr/blob/main/app/view/cloudflare/hostnames.html Displays a modal dialog to allow the user to select a DNS provider for adding a TXT record when multiple targets are available. It dynamically generates HTML for the selection form, including details about each target. Requires `htmlEscape`, `findTxtTargetByDomainId`, and `submitQuickAddTxtRecord`. ```javascript function openTxtTargetPicker(fullName, value, targets, isHostnameVerification){ var isMobile = window.innerWidth <= 768; var dialogWidth = isMobile ? '90%' : '640px'; var html = '
'; html += '
检测到多个可用解析域名,请确认要写入哪个服务商。
'; html += '
' + htmlEscape(fullName) + '
'; html += '
'; html += '
'; for(var i = 0; i < targets.length; i++){ var target = targets[i] || {}; var providerName = target.account_type_name || target.account_type || '-'; var accountName = target.account_display_name || ('账户#' + (target.account_id || '')); html += '
'; html += '
'; } html += '
'; layer.open({ type: 1, title: '选择解析服务商', area: [dialogWidth, 'auto'], shadeClose: false, content: html, btn: ['添加 TXT', '取消'], yes: function(index){ var selectedId = $('#txtTargetPickerForm input[name=txtTarget]:checked').val(); var target = findTxtTargetByDomainId(targets, selectedId); if(!target){ layer.msg('请选择要写入的解析域名', {icon: 2}); return; } layer.close(index); submitQuickAddTxtRecord(value, target, isHostnameVerification); } }); } ```