添加对阿里云的支持(ecs未测试)
This commit is contained in:
1 parent
cbd886bd0a
commit
8cb285866f
5 files changed
+1114
-125
No files matched your search
@@ -3,6 +3,7 @@ require_once __DIR__ . '/app/db_helper.php';
|
||||
require_once __DIR__ . '/app/logger.php';
|
||||
require_once __DIR__ . '/mofangidc.php';
|
||||
require_once __DIR__ . '/tencentcloud.php';
|
||||
require_once __DIR__ . '/aliyun.php';
|
||||
|
||||
// 存储API_PASS
|
||||
$tokenFile = __DIR__ . '/app/pass.php';
|
||||
@@ -29,12 +30,14 @@ if (!defined('API_PASS') || $pass !== API_PASS) {
|
||||
$message = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = $_POST['action'] ?? '';
|
||||
$hostId = intval($_POST['host_id'] ?? 0);
|
||||
$hostId = $_POST['host_id'] ?? '';
|
||||
$configId = intval($_POST['config_id'] ?? 0);
|
||||
|
||||
if ($action && $hostId > 0 && $configId > 0) {
|
||||
if ($action && !empty($hostId) && $configId > 0) {
|
||||
$result = null;
|
||||
|
||||
Logger::info("[操作请求] action={$action}, host_id={$hostId}, config_id={$configId}", 'index.php');
|
||||
|
||||
// 获取配置信息以确定平台类型
|
||||
$db = getVpsDB();
|
||||
$config = $db->queryOne('SELECT * FROM configs WHERE id = ?', [$configId]);
|
||||
@@ -57,6 +60,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
} elseif ($action === 'off') {
|
||||
$result = tencentSmartPowerOff($configId, $hostId);
|
||||
}
|
||||
} elseif ($config['site_type'] === 'aliyun') {
|
||||
// 阿里云ECS操作
|
||||
if ($action === 'reboot') {
|
||||
$result = aliyunReboot($configId, $hostId);
|
||||
} elseif ($action === 'on') {
|
||||
$result = aliyunPowerOn($configId, $hostId);
|
||||
} elseif ($action === 'off') {
|
||||
$result = aliyunPowerOff($configId, $hostId);
|
||||
}
|
||||
} elseif ($config['site_type'] === 'aliyun_swas') {
|
||||
// 阿里云轻量应用服务器操作
|
||||
if ($action === 'reboot') {
|
||||
$result = aliyunSwasReboot($configId, $hostId);
|
||||
} elseif ($action === 'on') {
|
||||
$result = aliyunSwasPowerOn($configId, $hostId);
|
||||
} elseif ($action === 'off') {
|
||||
$result = aliyunSwasPowerOff($configId, $hostId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +99,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$tencentCount = refreshAllTencentVpsLists();
|
||||
$count += $tencentCount;
|
||||
|
||||
// 刷新阿里云的ECS列表
|
||||
$aliyunCount = refreshAllAliyunVpsLists();
|
||||
$count += $aliyunCount;
|
||||
|
||||
$message = '<div class="success-message"><h3>✅ 刷新完成</h3><p>已成功刷新 ' . $count . ' 个配置的VPS列表</p></div>';
|
||||
|
||||
// 获取每个VPS的详细信息并更新数据库
|
||||
@@ -127,6 +152,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
} elseif ($config['site_type'] === 'tencent') {
|
||||
// 腾讯云实例已在refreshAllTencentVpsLists中更新了详细信息,这里不需要额外处理
|
||||
Logger::info("[refresh_vps_list] 腾讯云配置 {$config['id']} 已刷新", 'index.php');
|
||||
} elseif ($config['site_type'] === 'aliyun') {
|
||||
// 阿里云ECS实例已在refreshAllAliyunVpsLists中更新了详细信息,这里不需要额外处理
|
||||
Logger::info("[refresh_vps_list] 阿里云配置 {$config['id']} 已刷新", 'index.php');
|
||||
} elseif ($config['site_type'] === 'aliyun_swas') {
|
||||
// 阿里云轻量应用服务器实例已在refreshAllAliyunVpsLists中更新了详细信息,这里不需要额外处理
|
||||
Logger::info("[refresh_vps_list] 阿里云轻量配置 {$config['id']} 已刷新", 'index.php');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,6 +293,7 @@ foreach ($vpsList as $vps) {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
cursor: help;
|
||||
}
|
||||
.status-badge {
|
||||
padding: 4px 12px;
|
||||
@@ -450,10 +482,19 @@ foreach ($vpsList as $vps) {
|
||||
$statusText = '处理中';
|
||||
$statusColor = '#ffc107';
|
||||
}
|
||||
|
||||
// 处理长ID显示
|
||||
$vpsId = $vps['vps_id'];
|
||||
$displayId = $vpsId;
|
||||
$showTooltip = false;
|
||||
if (strlen($vpsId) > 12) {
|
||||
$displayId = substr($vpsId, 0, 10) . '...';
|
||||
$showTooltip = true;
|
||||
}
|
||||
?>
|
||||
<div class="vps-card">
|
||||
<div class="card-header">
|
||||
<div class="vps-id">#<?php echo $vps['vps_id']; ?></div>
|
||||
<div class="vps-id" <?php if ($showTooltip): ?>title="<?php echo htmlspecialchars($vpsId); ?>"<?php endif; ?>>#<?php echo htmlspecialchars($displayId); ?></div>
|
||||
<span class="status-badge" style="background-color: <?php echo $statusColor; ?>">
|
||||
<?php echo $statusText; ?>
|
||||
</span>
|
||||
@@ -540,6 +581,12 @@ foreach ($vpsList as $vps) {
|
||||
<button type="submit" name="action" value="reboot" class="btn btn-warning" onclick="return confirm('确认重启?')">
|
||||
🔄 重启
|
||||
</button>
|
||||
<?php } elseif ($siteType === 'aliyun' || $siteType === 'aliyun_swas') {
|
||||
// 阿里云(ECS或轻量):普通重启
|
||||
?>
|
||||
<button type="submit" name="action" value="reboot" class="btn btn-warning" onclick="return confirm('确认重启?')">
|
||||
🔄 重启
|
||||
</button>
|
||||
<?php } else {
|
||||
// 魔方等其他平台:硬重启
|
||||
?>
|
||||
|
||||
Reference in new issue
Block a user