|
|
发表于 2025-6-18 09:19:24
|
显示全部楼层
|
本帖最后由 追影 于 2025-6-18 10:44 编辑
winacme软件的下载地址:
(1)写个php console形式可以调用的 里面主要根据参数有增加和删除的操作 这个是西部数码的演示实例
-
- function add_txt($sub_domain, $value) {
- $curl = curl_init();
- curl_setopt_array($curl, array(
- curlopt_url => 'https://api.west.cn/api/v2/domain/dns/?apidomainkey=密钥',
- curlopt_returntransfer => true,
- curlopt_encoding => '',
- curlopt_maxredirs => 10,
- curlopt_timeout => 0,
- curlopt_ssl_verifypeer=>false,
- curlopt_ssl_verifyhost=>false,
- curlopt_followlocation => true,
- curlopt_http_version => curl_http_version_1_1,
- curlopt_customrequest => 'get',
- curlopt_postfields => 'act=dnsrec.add&domain=damicms.com&hostname='.$sub_domain.'&record_value='.$value.'&record_type=txt',
- ));
- $response = curl_exec($curl);
- curl_close($curl);
- echo $response;
- }
- function del_txt($sub_domain) {
- $curl = curl_init();
- curl_setopt_array($curl, array(
- curlopt_url => 'https://api.west.cn/api/v2/domain/dns/?apidomainkey=密钥',
- curlopt_returntransfer => true,
- curlopt_encoding => '',
- curlopt_maxredirs => 10,
- curlopt_timeout => 0,
- curlopt_ssl_verifypeer=>false,
- curlopt_ssl_verifyhost=>false,
- curlopt_followlocation => true,
- curlopt_http_version => curl_http_version_1_1,
- curlopt_customrequest => 'get',
- curlopt_postfields => 'act=dnsrec.remove&domain=damicms.com&hostname='.$sub_domain.'&record_type=txt',
- ));
- $response = curl_exec($curl);
- curl_close($curl);
- echo $response;
- }
- // 命令行参数处理
- if (php_sapi_name() == 'cli') {
- // 移除非中文参数名
- $command = isset($argv[1]) ?$argv[1]: null;
- if ($command === 'add') {
- if (count($argv) < 4) {
- die("错误:添加操作需要子域名和值参数\n用法:php script.php add <子域名> <值>\n");
- }
- add_txt($argv[2], $argv[3]);
- }
- elseif ($command === 'del') {
- if (count($argv) < 3) {
- die("错误:删除操作需要子域名参数\n用法:php script.php del <子域名>\n");
- }
- del_txt($argv[2]);
- }
- else {
- die("无效命令\n可用命令:\n add - 添加txt记录\n del - 删除txt记录\n\n示例:\n php script.php add _acme-challenge '验证值'\n php script.php del _acme-challenge\n");
- }
- } else {
- die("本脚本仅支持命令行模式运行");
- }
- ?>
复制代码 (2)再编写一个bat,调用php执行api域名txt记录增加或删除:
- @echo off
- set mode=%1
- set host=%3
- set php_exe=d:\php\php.exe
- set php_script=d:\web\y9527\deal_domain.php
- if "%mode%" == "create" goto create
- if "%mode%" == "delete" goto delete
- echo "deal_dns create|delete subdomain [txt_value]"
- exit /b 3
- :create
- set txt_value=%4
- call "%php_exe%" "%php_script%" add "%host%" "%txt_value%"
- goto end
- :delete
- call "%php_exe%" "%php_script%" del "%host%"
- goto end
- :end
复制代码 winacem指定这个bat的路径即可 参数些都默认即可
|
|