Download config-check.php from CatPtain/VvvebJs: direct link, hf CLI and curl.
- Browser
- Download file 11.4 kB
-
https://huggingface.co/spaces/CatPtain/VvvebJs/resolve/main/config-check.php
- Command line
-
hf download hf://spaces/CatPtain/VvvebJs/config-check.php
-
curl -L -o config-check.php https://huggingface.co/spaces/CatPtain/VvvebJs/resolve/main/config-check.php
11.4 kB
| 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 = []; | |
| // 检查是否在Hugging Face Space环境 | |
| if (StorageConfig::isHuggingFaceSpace()) { | |
| // 在Hugging Face Space环境中,重点检查环境变量 | |
| if (empty($github['token'])) { | |
| $issues[] = [ | |
| 'type' => 'error', | |
| 'title' => 'GitHub Token 未在Hugging Face Space中配置', | |
| 'message' => 'GITHUB_TOKEN 环境变量为空,请在Hugging Face Space的Settings中添加此私有密钥' | |
| ]; | |
| } | |
| } else { | |
| // 在本地环境中,检查.env文件配置 | |
| if (empty($github['token']) || $github['token'] === 'YOUR_ACTUAL_GITHUB_TOKEN') { | |
| $issues[] = [ | |
| 'type' => 'error', | |
| 'title' => 'GitHub Token 未配置', | |
| 'message' => 'GITHUB_TOKEN 仍然是占位符或为空,需要设置真实的GitHub Token' | |
| ]; | |
| } | |
| } | |
| // 检查GitHub基本配置 | |
| 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: #f8f9fa; padding: 2px 6px; border-radius: 3px; font-family: monospace; } | |
| .status-ok { color: #28a745; } | |
| .status-error { color: #dc3545; } | |
| .status-warning { color: #ffc107; } | |
| </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> |