上传文件至「aliapi/api」

这个提交包含在:
2026-07-24 11:44:59 +08:00
父节点 591896833d
当前提交 6d17411813
修改 5 个文件,包含 292 行新增0 行删除
+60
查看文件
@@ -0,0 +1,60 @@
<?php
require_once '../config.php';
require_once '../lib/AliyunDnsClient.php';
header('Content-Type: application/json; charset=utf-8');
$config = require '../config.php';
$allowedIps = $config['api']['allowed_ips'];
$clientIp = $_SERVER['REMOTE_ADDR'];
if ($allowedIps !== '*' && !in_array($clientIp, $allowedIps)) {
echo json_encode(['code' => 403, 'message' => 'Access denied']);
exit;
}
$token = $_POST['token'] ?? $_GET['token'] ?? null;
if ($token !== $config['api']['token']) {
echo json_encode(['code' => 403, 'message' => 'Invalid token']);
exit;
}
$domainName = $_POST['domain_name'] ?? $_GET['domain_name'] ?? null;
$rr = $_POST['rr'] ?? $_GET['rr'] ?? null;
$type = $_POST['type'] ?? $_GET['type'] ?? 'A';
$value = $_POST['value'] ?? $_GET['value'] ?? null;
$ttl = intval($_POST['ttl'] ?? $_GET['ttl'] ?? 600);
$priority = $_POST['priority'] ?? $_GET['priority'] ?? null;
if ($priority !== null) $priority = intval($priority);
if (!$domainName || !$rr || !$value) {
echo json_encode(['code' => 400, 'message' => 'Missing required parameters: domain_name, rr, value']);
exit;
}
try {
$client = new AliyunDnsClient(
$config['aliyun']['access_key_id'],
$config['aliyun']['access_key_secret'],
$config['aliyun']['endpoint'],
$config['aliyun']['region_id']
);
$result = $client->addDomainRecord($domainName, $rr, $type, $value, $ttl, $priority);
echo json_encode([
'code' => 200,
'message' => 'Success',
'data' => [
'record_id' => $result['RecordId'] ?? null,
'rr' => $rr,
'type' => $type,
'value' => $value,
'ttl' => $ttl
]
]);
} catch (Exception $e) {
echo json_encode(['code' => 500, 'message' => $e->getMessage()]);
}
?>
+44
查看文件
@@ -0,0 +1,44 @@
<?php
require_once '../config.php';
require_once '../lib/AliyunDnsClient.php';
header('Content-Type: application/json; charset=utf-8');
$config = require '../config.php';
$allowedIps = $config['api']['allowed_ips'];
$clientIp = $_SERVER['REMOTE_ADDR'];
if ($allowedIps !== '*' && !in_array($clientIp, $allowedIps)) {
echo json_encode(['code' => 403, 'message' => 'Access denied']);
exit;
}
$token = $_POST['token'] ?? $_GET['token'] ?? null;
if ($token !== $config['api']['token']) {
echo json_encode(['code' => 403, 'message' => 'Invalid token']);
exit;
}
$recordId = $_POST['record_id'] ?? $_GET['record_id'] ?? null;
if (!$recordId) {
echo json_encode(['code' => 400, 'message' => 'Missing required parameter: record_id']);
exit;
}
try {
$client = new AliyunDnsClient(
$config['aliyun']['access_key_id'],
$config['aliyun']['access_key_secret'],
$config['aliyun']['endpoint'],
$config['aliyun']['region_id']
);
$client->deleteDomainRecord($recordId);
echo json_encode(['code' => 200, 'message' => 'Success', 'data' => ['record_id' => $recordId]]);
} catch (Exception $e) {
echo json_encode(['code' => 500, 'message' => $e->getMessage()]);
}
?>
+56
查看文件
@@ -0,0 +1,56 @@
<?php
require_once '../config.php';
require_once '../lib/AliyunDnsClient.php';
header('Content-Type: application/json; charset=utf-8');
$config = require '../config.php';
$allowedIps = $config['api']['allowed_ips'];
$clientIp = $_SERVER['REMOTE_ADDR'];
if ($allowedIps !== '*' && !in_array($clientIp, $allowedIps)) {
echo json_encode(['code' => 403, 'message' => 'Access denied']);
exit;
}
$token = $_POST['token'] ?? $_GET['token'] ?? null;
if ($token !== $config['api']['token']) {
echo json_encode(['code' => 403, 'message' => 'Invalid token']);
exit;
}
$recordId = $_GET['record_id'] ?? null;
if (!$recordId) {
echo json_encode(['code' => 400, 'message' => 'Missing required parameter: record_id']);
exit;
}
try {
$client = new AliyunDnsClient(
$config['aliyun']['access_key_id'],
$config['aliyun']['access_key_secret'],
$config['aliyun']['endpoint'],
$config['aliyun']['region_id']
);
$result = $client->describeRecordInfo($recordId);
$record = [
'record_id' => $result['RecordId'],
'domain_name' => $result['DomainName'],
'rr' => $result['RR'],
'type' => $result['Type'],
'value' => $result['Value'],
'ttl' => $result['TTL'],
'priority' => $result['Priority'] ?? null,
'status' => $result['Status'],
'remark' => $result['Remark'] ?? ''
];
echo json_encode(['code' => 200, 'message' => 'Success', 'data' => $record]);
} catch (Exception $e) {
echo json_encode(['code' => 500, 'message' => $e->getMessage()]);
}
?>
+72
查看文件
@@ -0,0 +1,72 @@
<?php
require_once '../config.php';
require_once '../lib/AliyunDnsClient.php';
header('Content-Type: application/json; charset=utf-8');
$config = require '../config.php';
$allowedIps = $config['api']['allowed_ips'];
$clientIp = $_SERVER['REMOTE_ADDR'];
if ($allowedIps !== '*' && !in_array($clientIp, $allowedIps)) {
echo json_encode(['code' => 403, 'message' => 'Access denied']);
exit;
}
$token = $_POST['token'] ?? $_GET['token'] ?? null;
if ($token !== $config['api']['token']) {
echo json_encode(['code' => 403, 'message' => 'Invalid token']);
exit;
}
$domainName = $_GET['domain_name'] ?? null;
$rrKeyWord = $_GET['rr_keyword'] ?? null;
$type = $_GET['type'] ?? null;
$pageNumber = $_GET['page'] ?? 1;
$pageSize = $_GET['page_size'] ?? 20;
if (!$domainName) {
echo json_encode(['code' => 400, 'message' => 'Missing required parameter: domain_name']);
exit;
}
try {
$client = new AliyunDnsClient(
$config['aliyun']['access_key_id'],
$config['aliyun']['access_key_secret'],
$config['aliyun']['endpoint'],
$config['aliyun']['region_id']
);
$result = $client->describeDomainRecords($domainName, $rrKeyWord, $type, $pageNumber, $pageSize);
$records = [];
if (isset($result['DomainRecords']['Record'])) {
foreach ($result['DomainRecords']['Record'] as $record) {
$records[] = [
'record_id' => $record['RecordId'],
'rr' => $record['RR'],
'type' => $record['Type'],
'value' => $record['Value'],
'ttl' => $record['TTL'],
'priority' => $record['Priority'] ?? null,
'status' => $record['Status']
];
}
}
echo json_encode([
'code' => 200,
'message' => 'Success',
'data' => [
'total' => $result['TotalCount'] ?? 0,
'page' => $pageNumber,
'page_size' => $pageSize,
'records' => $records
]
]);
} catch (Exception $e) {
echo json_encode(['code' => 500, 'message' => $e->getMessage()]);
}
?>
+60
查看文件
@@ -0,0 +1,60 @@
<?php
require_once '../config.php';
require_once '../lib/AliyunDnsClient.php';
header('Content-Type: application/json; charset=utf-8');
$config = require '../config.php';
$allowedIps = $config['api']['allowed_ips'];
$clientIp = $_SERVER['REMOTE_ADDR'];
if ($allowedIps !== '*' && !in_array($clientIp, $allowedIps)) {
echo json_encode(['code' => 403, 'message' => 'Access denied']);
exit;
}
$token = $_POST['token'] ?? $_GET['token'] ?? null;
if ($token !== $config['api']['token']) {
echo json_encode(['code' => 403, 'message' => 'Invalid token']);
exit;
}
$recordId = $_POST['record_id'] ?? $_GET['record_id'] ?? null;
$rr = $_POST['rr'] ?? $_GET['rr'] ?? null;
$type = $_POST['type'] ?? $_GET['type'] ?? 'A';
$value = $_POST['value'] ?? $_GET['value'] ?? null;
$ttl = intval($_POST['ttl'] ?? $_GET['ttl'] ?? 600);
$priority = $_POST['priority'] ?? $_GET['priority'] ?? null;
if ($priority !== null) $priority = intval($priority);
if (!$recordId || !$rr || !$value) {
echo json_encode(['code' => 400, 'message' => 'Missing required parameters: record_id, rr, value']);
exit;
}
try {
$client = new AliyunDnsClient(
$config['aliyun']['access_key_id'],
$config['aliyun']['access_key_secret'],
$config['aliyun']['endpoint'],
$config['aliyun']['region_id']
);
$result = $client->updateDomainRecord($recordId, $rr, $type, $value, $ttl, $priority);
echo json_encode([
'code' => 200,
'message' => 'Success',
'data' => [
'record_id' => $result['RecordId'] ?? $recordId,
'rr' => $rr,
'type' => $type,
'value' => $value,
'ttl' => $ttl
]
]);
} catch (Exception $e) {
echo json_encode(['code' => 500, 'message' => $e->getMessage()]);
}
?>