添加对阿里云的支持(ecs未测试)
This commit is contained in:
1 parent
cbd886bd0a
commit
8cb285866f
5 files changed
+1114
-125
No files matched your search
+41
-14
@@ -138,13 +138,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$dbSiteType = $siteType;
|
||||
if ($siteType === 'tencent_cvm' || $siteType === 'tencent_lh') {
|
||||
$dbSiteType = 'tencent';
|
||||
} elseif ($siteType === 'aliyun_swas') {
|
||||
$dbSiteType = 'aliyun_swas';
|
||||
}
|
||||
|
||||
// 验证必填字段(腾讯云需要siteUrl)
|
||||
if ($siteType === 'tencent_cvm' || $siteType === 'tencent_lh') {
|
||||
// 腾讯云:siteUrl必填(API域名)
|
||||
// 验证必填字段(腾讯云和阿里云需要siteUrl)
|
||||
if ($siteType === 'tencent_cvm' || $siteType === 'tencent_lh' || $siteType === 'aliyun' || $siteType === 'aliyun_swas') {
|
||||
// 腾讯云/阿里云:siteUrl必填(API域名)
|
||||
if (empty($apiLabel) || empty($siteType) || empty($siteUrl) || empty($account) || empty($apiKey)) {
|
||||
$message = '<div class="error-message">❌ API标识、网站类型、API地址、SecretId和SecretKey不能为空!</div>';
|
||||
$message = '<div class="error-message">❌ API标识、网站类型、API地址、AccessKey ID和AccessKey Secret不能为空!</div>';
|
||||
} else {
|
||||
|
||||
$db = getVpsDB();
|
||||
@@ -160,8 +162,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
);
|
||||
|
||||
if ($configId) {
|
||||
$typeName = ($siteType === 'tencent_cvm') ? 'CVM云服务器' : '轻量应用服务器';
|
||||
$message = '<div class="success-message">✅ 腾讯云' . $typeName . '配置添加成功!ID: ' . $configId . '</div>';
|
||||
if ($siteType === 'aliyun') {
|
||||
$message = '<div class="success-message">✅ 阿里云ECS配置添加成功!ID: ' . $configId . '</div>';
|
||||
} elseif ($siteType === 'aliyun_swas') {
|
||||
$message = '<div class="success-message">✅ 阿里云轻量应用服务器配置添加成功!ID: ' . $configId . '</div>';
|
||||
} else {
|
||||
$typeName = ($siteType === 'tencent_cvm') ? 'CVM云服务器' : '轻量应用服务器';
|
||||
$message = '<div class="success-message">✅ 腾讯云' . $typeName . '配置添加成功!ID: ' . $configId . '</div>';
|
||||
}
|
||||
|
||||
// 如果是首次添加配置,提示运行install.sh
|
||||
$configCount = $db->queryOne('SELECT COUNT(*) as count FROM configs')['count'];
|
||||
@@ -209,6 +217,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
refreshTencentLighthouseListForConfig($configId);
|
||||
}
|
||||
$message .= '<div class="info-box">✅ 已自动获取实例列表(遍历所有区域)</div>';
|
||||
} elseif ($dbSiteType === 'aliyun') {
|
||||
// 阿里云ECS
|
||||
require_once __DIR__ . '/aliyun.php';
|
||||
refreshAliyunEcsListForConfig($configId);
|
||||
$message .= '<div class="info-box">✅ 已自动获取ECS实例列表(遍历所有区域)</div>';
|
||||
} elseif ($dbSiteType === 'aliyun_swas') {
|
||||
// 阿里云轻量应用服务器
|
||||
require_once __DIR__ . '/aliyun.php';
|
||||
refreshAliyunSwasListForConfig($configId);
|
||||
$message .= '<div class="info-box">✅ 已自动获取轻量应用服务器列表(遍历所有区域)</div>';
|
||||
}
|
||||
} else {
|
||||
$message = '<div class="error-message">❌ 配置添加失败,请重试</div>';
|
||||
@@ -387,7 +405,8 @@ $configs = $db->query('SELECT * FROM configs ORDER BY id');
|
||||
<label>网站类型 *</label>
|
||||
<select name="site_type" required onchange="toggleSiteUrl(this.value)">
|
||||
<option value="mofang">魔方平台</option>
|
||||
<option value="aliyun">阿里云(暂不支持)</option>
|
||||
<option value="aliyun">阿里云 - ECS云服务器</option>
|
||||
<option value="aliyun_swas">阿里云 - 轻量应用服务器</option>
|
||||
<option value="tencent_cvm">腾讯云 - CVM云服务器</option>
|
||||
<option value="tencent_lh">腾讯云 - 轻量应用服务器</option>
|
||||
</select>
|
||||
@@ -435,7 +454,6 @@ $configs = $db->query('SELECT * FROM configs ORDER BY id');
|
||||
<table class="config-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>序号</th>
|
||||
<th>API标识</th>
|
||||
<th>网站类型</th>
|
||||
<th>网站链接</th>
|
||||
@@ -448,13 +466,13 @@ $configs = $db->query('SELECT * FROM configs ORDER BY id');
|
||||
<tbody>
|
||||
<?php foreach ($configs as $config): ?>
|
||||
<tr>
|
||||
<td><?php echo $config['id']; ?></td>
|
||||
<td><strong><?php echo htmlspecialchars($config['api_label']); ?></strong></td>
|
||||
<td>
|
||||
<?php
|
||||
$typeMap = [
|
||||
'mofang' => '魔方',
|
||||
'aliyun' => '阿里云',
|
||||
'aliyun' => '阿里云ECS',
|
||||
'aliyun_swas' => '阿里云轻量',
|
||||
'tencent' => '腾讯云'
|
||||
];
|
||||
echo $typeMap[$config['site_type']] ?? $config['site_type'];
|
||||
@@ -504,12 +522,21 @@ $configs = $db->query('SELECT * FROM configs ORDER BY id');
|
||||
accountLabel.innerHTML = '账户 * <small>(邮箱或手机号)</small>';
|
||||
keyLabel.textContent = 'API密钥 *';
|
||||
} else if (siteType === 'aliyun') {
|
||||
// 阿里云
|
||||
// 阿里云ECS
|
||||
urlGroup.style.display = 'block';
|
||||
urlInput.placeholder = '例如: https://ecs.aliyuncs.com';
|
||||
urlInput.value = 'https://ecs.aliyuncs.com';
|
||||
urlInput.placeholder = 'https://ecs.aliyuncs.com';
|
||||
urlInput.required = true;
|
||||
accountLabel.innerHTML = '账户 * <small>(AccessKey ID)</small>';
|
||||
keyLabel.textContent = 'API密钥 *';
|
||||
accountLabel.innerHTML = 'AccessKey ID * <small>(阿里云访问密钥ID)</small>';
|
||||
keyLabel.textContent = 'AccessKey Secret *';
|
||||
} else if (siteType === 'aliyun_swas') {
|
||||
// 阿里云轻量应用服务器
|
||||
urlGroup.style.display = 'block';
|
||||
urlInput.value = 'https://swas.aliyuncs.com';
|
||||
urlInput.placeholder = 'https://swas.aliyuncs.com';
|
||||
urlInput.required = true;
|
||||
accountLabel.innerHTML = 'AccessKey ID * <small>(阿里云访问密钥ID)</small>';
|
||||
keyLabel.textContent = 'AccessKey Secret *';
|
||||
} else if (siteType === 'tencent_cvm') {
|
||||
// CVM云服务器
|
||||
urlGroup.style.display = 'block';
|
||||
|
||||
Reference in new issue
Block a user