|
|
<?php
|
|
|
require_once __DIR__ . '/storage.php';
|
|
|
|
|
|
|
|
|
$testAuth = false;
|
|
|
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
|
|
|
$users = StorageConfig::getUsers();
|
|
|
$testAuth = isset($users[$_SERVER['PHP_AUTH_USER']]) &&
|
|
|
$users[$_SERVER['PHP_AUTH_USER']] === $_SERVER['PHP_AUTH_PW'];
|
|
|
}
|
|
|
|
|
|
if (!$testAuth) {
|
|
|
header('WWW-Authenticate: Basic realm="VvvebJs Config Check"');
|
|
|
header('HTTP/1.0 401 Unauthorized');
|
|
|
die('Authentication required for config check');
|
|
|
}
|
|
|
|
|
|
$github = StorageConfig::getGitHubConfig();
|
|
|
$kv = StorageConfig::getKVConfig();
|
|
|
$storageType = StorageConfig::getStorageType();
|
|
|
|
|
|
|
|
|
function checkConfig() {
|
|
|
$github = StorageConfig::getGitHubConfig();
|
|
|
$issues = [];
|
|
|
|
|
|
|
|
|
if (StorageConfig::isHuggingFaceSpace()) {
|
|
|
|
|
|
if (empty($github['token'])) {
|
|
|
$issues[] = [
|
|
|
'type' => 'error',
|
|
|
'title' => 'GitHub Token 未在Hugging Face Space中配置',
|
|
|
'message' => 'GITHUB_TOKEN 环境变量为空,请在Hugging Face Space的Settings中添加此私有密钥'
|
|
|
];
|
|
|
}
|
|
|
} else {
|
|
|
|
|
|
if (empty($github['token']) || $github['token'] === 'YOUR_ACTUAL_GITHUB_TOKEN') {
|
|
|
$issues[] = [
|
|
|
'type' => 'error',
|
|
|
'title' => 'GitHub Token 未配置',
|
|
|
'message' => 'GITHUB_TOKEN 仍然是占位符或为空,需要设置真实的GitHub Token'
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (empty($github['owner'])) {
|
|
|
$issues[] = [
|
|
|
'type' => 'error',
|
|
|
'title' => 'GitHub Owner 未配置',
|
|
|
'message' => 'GITHUB_OWNER 为空'
|
|
|
];
|
|
|
}
|
|
|
|
|
|
if (empty($github['repo'])) {
|
|
|
$issues[] = [
|
|
|
'type' => 'error',
|
|
|
'title' => 'GitHub Repo 未配置',
|
|
|
'message' => 'GITHUB_REPO 为空'
|
|
|
];
|
|
|
}
|
|
|
|
|
|
return $issues;
|
|
|
}
|
|
|
|
|
|
$configIssues = checkConfig();
|
|
|
?>
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
<html lang="en">
|
|
|
<head>
|
|
|
<meta charset="utf-8">
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
<title>VvvebJs 配置检查</title>
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
|
<style>
|
|
|
.config-value { background-color:
|
|
|
.status-ok { color:
|
|
|
.status-error { color:
|
|
|
.status-warning { color:
|
|
|
</style>
|
|
|
</head>
|
|
|
<body>
|
|
|
<div class="container mt-5">
|
|
|
<div class="row">
|
|
|
<div class="col-md-10 mx-auto">
|
|
|
<h1 class="mb-4">🔧 VvvebJs 配置检查</h1>
|
|
|
|
|
|
<!-- 配置问题检查 -->
|
|
|
<?php if (!empty($configIssues)): ?>
|
|
|
<div class="card mb-4">
|
|
|
<div class="card-header">
|
|
|
<h3 class="status-error">❌ 发现配置问题</h3>
|
|
|
</div>
|
|
|
<div class="card-body">
|
|
|
<?php foreach ($configIssues as $issue): ?>
|
|
|
<div class="alert alert-<?= $issue['type'] === 'error' ? 'danger' : 'warning' ?> mb-3">
|
|
|
<h5><?= htmlspecialchars($issue['title']) ?></h5>
|
|
|
<p><?= htmlspecialchars($issue['message']) ?></p>
|
|
|
</div>
|
|
|
<?php endforeach; ?>
|
|
|
|
|
|
<div class="alert alert-info">
|
|
|
<h5>🔑 如何修复GitHub Token问题:</h5>
|
|
|
<ol>
|
|
|
<li>访问 <a href="https://github.com/settings/tokens" target="_blank">GitHub Token 设置页面</a></li>
|
|
|
<li>点击 "Generate new token (classic)"</li>
|
|
|
<li>选择 <strong>repo</strong> 权限(包括完整的仓库访问权限)</li>
|
|
|
<li>复制生成的Token</li>
|
|
|
<li>在 <code>.env</code> 文件中将 <code>GITHUB_TOKEN=YOUR_ACTUAL_GITHUB_TOKEN</code> 替换为 <code>GITHUB_TOKEN=你的真实Token</code></li>
|
|
|
</ol>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<?php else: ?>
|
|
|
<div class="alert alert-success">
|
|
|
<h3 class="status-ok">✅ 配置检查通过</h3>
|
|
|
<p>基本配置项都已正确设置。</p>
|
|
|
</div>
|
|
|
<?php endif; ?>
|
|
|
|
|
|
<!-- 当前配置详情 -->
|
|
|
<div class="card mb-4">
|
|
|
<div class="card-header">
|
|
|
<h3>📋 当前配置详情</h3>
|
|
|
</div>
|
|
|
<div class="card-body">
|
|
|
<div class="row">
|
|
|
<div class="col-md-6">
|
|
|
<h5>存储配置</h5>
|
|
|
<p><strong>存储类型:</strong> <span class="config-value"><?= htmlspecialchars($storageType) ?></span></p>
|
|
|
|
|
|
<h5 class="mt-4">GitHub 配置</h5>
|
|
|
<p><strong>Token:</strong>
|
|
|
<span class="config-value <?= empty($github['token']) || $github['token'] === 'YOUR_ACTUAL_GITHUB_TOKEN' ? 'status-error' : 'status-ok' ?>">
|
|
|
<?php
|
|
|
if (empty($github['token'])) {
|
|
|
echo '❌ 未设置';
|
|
|
} elseif ($github['token'] === 'YOUR_ACTUAL_GITHUB_TOKEN') {
|
|
|
echo '❌ 占位符';
|
|
|
} else {
|
|
|
echo '✅ ' . substr($github['token'], 0, 8) . '...';
|
|
|
}
|
|
|
?>
|
|
|
</span>
|
|
|
</p>
|
|
|
<p><strong>Owner:</strong> <span class="config-value"><?= htmlspecialchars($github['owner']) ?></span></p>
|
|
|
<p><strong>Repo:</strong> <span class="config-value"><?= htmlspecialchars($github['repo']) ?></span></p>
|
|
|
<p><strong>Branch:</strong> <span class="config-value"><?= htmlspecialchars($github['branch']) ?></span></p>
|
|
|
<p><strong>Path:</strong> <span class="config-value"><?= htmlspecialchars($github['path']) ?></span></p>
|
|
|
</div>
|
|
|
<div class="col-md-6">
|
|
|
<h5>EdgeOne KV 配置</h5>
|
|
|
<p><strong>API Key:</strong>
|
|
|
<span class="config-value">
|
|
|
<?= !empty($kv['api_key']) ? '✅ ' . substr($kv['api_key'], 0, 8) . '...' : '❌ 未设置' ?>
|
|
|
</span>
|
|
|
</p>
|
|
|
<p><strong>Secret Key:</strong>
|
|
|
<span class="config-value">
|
|
|
<?= !empty($kv['secret_key']) ? '✅ ' . substr($kv['secret_key'], 0, 8) . '...' : '❌ 未设置' ?>
|
|
|
</span>
|
|
|
</p>
|
|
|
<p><strong>Zone ID:</strong> <span class="config-value"><?= htmlspecialchars($kv['zone_id']) ?></span></p>
|
|
|
<p><strong>Namespace:</strong> <span class="config-value"><?= htmlspecialchars($kv['namespace']) ?></span></p>
|
|
|
<p><strong>Endpoint:</strong> <span class="config-value"><?= htmlspecialchars($kv['endpoint']) ?></span></p>
|
|
|
|
|
|
<h5 class="mt-4">用户配置</h5>
|
|
|
<p><strong>当前用户:</strong> <span class="config-value"><?= htmlspecialchars(StorageConfig::getCurrentUser()) ?></span></p>
|
|
|
<p><strong>用户路径:</strong> <span class="config-value"><?= htmlspecialchars(StorageConfig::getUserPath()) ?></span></p>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<!-- 测试连接 -->
|
|
|
<div class="card mb-4">
|
|
|
<div class="card-header">
|
|
|
<h3>🧪 快速测试</h3>
|
|
|
</div>
|
|
|
<div class="card-body">
|
|
|
<div class="row">
|
|
|
<div class="col-md-4">
|
|
|
<a href="github-advanced-test.php" class="btn btn-primary w-100">GitHub 完整测试</a>
|
|
|
</div>
|
|
|
<div class="col-md-4">
|
|
|
<a href="github-test.php" class="btn btn-info w-100">GitHub 基础测试</a>
|
|
|
</div>
|
|
|
<div class="col-md-4">
|
|
|
<a href="editor.html" class="btn btn-success w-100">返回编辑器</a>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<!-- 环境变量文件状态 -->
|
|
|
<div class="card">
|
|
|
<div class="card-header">
|
|
|
<h3>📄 环境变量文件状态</h3>
|
|
|
</div>
|
|
|
<div class="card-body">
|
|
|
<p><strong>.env 文件:</strong>
|
|
|
<span class="<?= file_exists(__DIR__ . '/.env') ? 'status-ok' : 'status-error' ?>">
|
|
|
<?= file_exists(__DIR__ . '/.env') ? '✅ 存在' : '❌ 不存在' ?>
|
|
|
</span>
|
|
|
</p>
|
|
|
<p><strong>.env.example 文件:</strong>
|
|
|
<span class="<?= file_exists(__DIR__ . '/.env.example') ? 'status-ok' : 'status-warning' ?>">
|
|
|
<?= file_exists(__DIR__ . '/.env.example') ? '✅ 存在' : '⚠️ 不存在' ?>
|
|
|
</span>
|
|
|
</p>
|
|
|
|
|
|
<?php if (!file_exists(__DIR__ . '/.env')): ?>
|
|
|
<div class="alert alert-warning mt-3">
|
|
|
<h5>⚠️ .env 文件不存在</h5>
|
|
|
<p>请从 .env.example 复制创建 .env 文件:</p>
|
|
|
<code>copy .env.example .env</code>
|
|
|
</div>
|
|
|
<?php endif; ?>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</body>
|
|
|
</html> |