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VER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
|
| 7 |
+
$users = StorageConfig::getUsers();
|
| 8 |
+
$testAuth = isset($users[$_SERVER['PHP_AUTH_USER']]) &&
|
| 9 |
+
$users[$_SERVER['PHP_AUTH_USER']] === $_SERVER['PHP_AUTH_PW'];
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
if (!$testAuth) {
|
| 13 |
+
header('WWW-Authenticate: Basic realm="VvvebJs Advanced Test"');
|
| 14 |
+
header('HTTP/1.0 401 Unauthorized');
|
| 15 |
+
die('Authentication required for advanced testing');
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
$github = StorageConfig::getGitHubConfig();
|
| 19 |
+
|
| 20 |
+
// 高级诊断功能
|
| 21 |
+
function testGitHubAPI($token, $endpoint, $method = 'GET', $data = null) {
|
| 22 |
+
$ch = curl_init();
|
| 23 |
+
curl_setopt($ch, CURLOPT_URL, $endpoint);
|
| 24 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
| 25 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
| 26 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
| 27 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
| 28 |
+
'Authorization: token ' . $token,
|
| 29 |
+
'User-Agent: VvvebJs-Diagnostic/1.0',
|
| 30 |
+
'Accept: application/vnd.github.v3+json'
|
| 31 |
+
]);
|
| 32 |
+
|
| 33 |
+
if ($data) {
|
| 34 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
| 35 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge(curl_getinfo($ch, CURLINFO_HEADER_OUT) ?: [], ['Content-Type: application/json']));
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
$result = curl_exec($ch);
|
| 39 |
+
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
| 40 |
+
$error = curl_error($ch);
|
| 41 |
+
curl_close($ch);
|
| 42 |
+
|
| 43 |
+
return [
|
| 44 |
+
'success' => $httpCode >= 200 && $httpCode < 300,
|
| 45 |
+
'http_code' => $httpCode,
|
| 46 |
+
'response' => $result,
|
| 47 |
+
'error' => $error
|
| 48 |
+
];
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
$diagnostics = [];
|
| 52 |
+
|
| 53 |
+
if ($_POST['run_diagnostics'] ?? false) {
|
| 54 |
+
// 测试 1: 验证 Token
|
| 55 |
+
$diagnostics['token_test'] = testGitHubAPI($github['token'], 'https://api.github.com/user');
|
| 56 |
+
|
| 57 |
+
// 测试 2: 检查仓库是否存在
|
| 58 |
+
$repoUrl = "https://api.github.com/repos/{$github['owner']}/{$github['repo']}";
|
| 59 |
+
$diagnostics['repo_test'] = testGitHubAPI($github['token'], $repoUrl);
|
| 60 |
+
|
| 61 |
+
// 测试 3: 检查分支
|
| 62 |
+
$branchUrl = "https://api.github.com/repos/{$github['owner']}/{$github['repo']}/branches/{$github['branch']}";
|
| 63 |
+
$diagnostics['branch_test'] = testGitHubAPI($github['token'], $branchUrl);
|
| 64 |
+
|
| 65 |
+
// 测试 4: 测试文件创建权限
|
| 66 |
+
$testFile = 'diagnostic-test-' . time() . '.txt';
|
| 67 |
+
$testContent = 'VvvebJs Diagnostic Test - ' . date('Y-m-d H:i:s');
|
| 68 |
+
$createUrl = "https://api.github.com/repos/{$github['owner']}/{$github['repo']}/contents/{$github['path']}{$testFile}";
|
| 69 |
+
$diagnostics['create_test'] = testGitHubAPI($github['token'], $createUrl, 'PUT', [
|
| 70 |
+
'message' => 'VvvebJs diagnostic test',
|
| 71 |
+
'content' => base64_encode($testContent),
|
| 72 |
+
'branch' => $github['branch']
|
| 73 |
+
]);
|
| 74 |
+
}
|
| 75 |
+
?>
|
| 76 |
+
|
| 77 |
+
<!DOCTYPE html>
|
| 78 |
+
<html lang="en">
|
| 79 |
+
<head>
|
| 80 |
+
<meta charset="utf-8">
|
| 81 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 82 |
+
<title>VvvebJs GitHub 高级诊断</title>
|
| 83 |
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
| 84 |
+
<style>
|
| 85 |
+
.diagnostic-result { font-family: monospace; font-size: 12px; }
|
| 86 |
+
.status-ok { color: #28a745; }
|
| 87 |
+
.status-error { color: #dc3545; }
|
| 88 |
+
.status-warning { color: #ffc107; }
|
| 89 |
+
</style>
|
| 90 |
+
</head>
|
| 91 |
+
<body>
|
| 92 |
+
<div class="container mt-5">
|
| 93 |
+
<div class="row">
|
| 94 |
+
<div class="col-md-8 mx-auto">
|
| 95 |
+
<h1 class="mb-4">🔍 VvvebJs GitHub 高级诊断</h1>
|
| 96 |
+
|
| 97 |
+
<!-- 当前配置 -->
|
| 98 |
+
<div class="card mb-4">
|
| 99 |
+
<div class="card-header">
|
| 100 |
+
<h3>📋 当前配置</h3>
|
| 101 |
+
</div>
|
| 102 |
+
<div class="card-body">
|
| 103 |
+
<div class="row">
|
| 104 |
+
<div class="col-md-6">
|
| 105 |
+
<p><strong>Token:</strong> <span class="diagnostic-result"><?= !empty($github['token']) ? substr($github['token'], 0, 8) . '...' : '❌ 缺失' ?></span></p>
|
| 106 |
+
<p><strong>Owner:</strong> <span class="diagnostic-result"><?= htmlspecialchars($github['owner']) ?></span></p>
|
| 107 |
+
<p><strong>Repo:</strong> <span class="diagnostic-result"><?= htmlspecialchars($github['repo']) ?></span></p>
|
| 108 |
+
</div>
|
| 109 |
+
<div class="col-md-6">
|
| 110 |
+
<p><strong>Branch:</strong> <span class="diagnostic-result"><?= htmlspecialchars($github['branch']) ?></span></p>
|
| 111 |
+
<p><strong>Path:</strong> <span class="diagnostic-result"><?= htmlspecialchars($github['path']) ?></span></p>
|
| 112 |
+
<p><strong>API URL:</strong> <span class="diagnostic-result">https://api.github.com/repos/<?= htmlspecialchars($github['owner']) ?>/<?= htmlspecialchars($github['repo']) ?></span></p>
|
| 113 |
+
</div>
|
| 114 |
+
</div>
|
| 115 |
+
</div>
|
| 116 |
+
</div>
|
| 117 |
+
|
| 118 |
+
<!-- 诊断控制 -->
|
| 119 |
+
<div class="card mb-4">
|
| 120 |
+
<div class="card-body text-center">
|
| 121 |
+
<form method="POST">
|
| 122 |
+
<button type="submit" name="run_diagnostics" value="1" class="btn btn-primary btn-lg">
|
| 123 |
+
🧪 运行完整诊断
|
| 124 |
+
</button>
|
| 125 |
+
</form>
|
| 126 |
+
</div>
|
| 127 |
+
</div>
|
| 128 |
+
|
| 129 |
+
<?php if (!empty($diagnostics)): ?>
|
| 130 |
+
<!-- 诊断结果 -->
|
| 131 |
+
<div class="card mb-4">
|
| 132 |
+
<div class="card-header">
|
| 133 |
+
<h3>🔬 诊断结果</h3>
|
| 134 |
+
</div>
|
| 135 |
+
<div class="card-body">
|
| 136 |
+
|
| 137 |
+
<!-- Token 验证 -->
|
| 138 |
+
<div class="mb-4">
|
| 139 |
+
<h5>1. GitHub Token 验证</h5>
|
| 140 |
+
<?php $test = $diagnostics['token_test']; ?>
|
| 141 |
+
<div class="alert alert-<?= $test['success'] ? 'success' : 'danger' ?>">
|
| 142 |
+
<strong>状态:</strong>
|
| 143 |
+
<span class="<?= $test['success'] ? 'status-ok' : 'status-error' ?>">
|
| 144 |
+
<?= $test['success'] ? '✅ 有效' : '❌ 无效' ?>
|
| 145 |
+
</span>
|
| 146 |
+
(HTTP <?= $test['http_code'] ?>)
|
| 147 |
+
|
| 148 |
+
<?php if ($test['success'] && $test['response']): ?>
|
| 149 |
+
<?php $user = json_decode($test['response'], true); ?>
|
| 150 |
+
<br><strong>用户信息:</strong> <?= htmlspecialchars($user['login'] ?? 'Unknown') ?>
|
| 151 |
+
<br><strong>用户名:</strong> <?= htmlspecialchars($user['name'] ?? 'N/A') ?>
|
| 152 |
+
<?php elseif (!$test['success']): ?>
|
| 153 |
+
<br><strong>错误:</strong> <?= htmlspecialchars($test['error'] ?: $test['response']) ?>
|
| 154 |
+
<?php endif; ?>
|
| 155 |
+
</div>
|
| 156 |
+
</div>
|
| 157 |
+
|
| 158 |
+
<!-- 仓库检查 -->
|
| 159 |
+
<div class="mb-4">
|
| 160 |
+
<h5>2. 仓库访问检查</h5>
|
| 161 |
+
<?php $test = $diagnostics['repo_test']; ?>
|
| 162 |
+
<div class="alert alert-<?= $test['success'] ? 'success' : 'danger' ?>">
|
| 163 |
+
<strong>状态:</strong>
|
| 164 |
+
<span class="<?= $test['success'] ? 'status-ok' : 'status-error' ?>">
|
| 165 |
+
<?= $test['success'] ? '✅ 可访问' : '❌ 无法访问' ?>
|
| 166 |
+
</span>
|
| 167 |
+
(HTTP <?= $test['http_code'] ?>)
|
| 168 |
+
|
| 169 |
+
<?php if ($test['success'] && $test['response']): ?>
|
| 170 |
+
<?php $repo = json_decode($test['response'], true); ?>
|
| 171 |
+
<br><strong>仓库全名:</strong> <?= htmlspecialchars($repo['full_name'] ?? 'Unknown') ?>
|
| 172 |
+
<br><strong>私有仓库:</strong> <?= $repo['private'] ? '是' : '否' ?>
|
| 173 |
+
<br><strong>默认分支:</strong> <?= htmlspecialchars($repo['default_branch'] ?? 'Unknown') ?>
|
| 174 |
+
<?php elseif ($test['http_code'] == 404): ?>
|
| 175 |
+
<br><strong>错误:</strong> 仓库不存在或无访问权限
|
| 176 |
+
<?php endif; ?>
|
| 177 |
+
</div>
|
| 178 |
+
</div>
|
| 179 |
+
|
| 180 |
+
<!-- 分支检查 -->
|
| 181 |
+
<div class="mb-4">
|
| 182 |
+
<h5>3. 分支检查</h5>
|
| 183 |
+
<?php $test = $diagnostics['branch_test']; ?>
|
| 184 |
+
<div class="alert alert-<?= $test['success'] ? 'success' : 'danger' ?>">
|
| 185 |
+
<strong>状态:</strong>
|
| 186 |
+
<span class="<?= $test['success'] ? 'status-ok' : 'status-error' ?>">
|
| 187 |
+
<?= $test['success'] ? '✅ 分支存在' : '❌ 分支不存在' ?>
|
| 188 |
+
</span>
|
| 189 |
+
(HTTP <?= $test['http_code'] ?>)
|
| 190 |
+
|
| 191 |
+
<?php if ($test['success'] && $test['response']): ?>
|
| 192 |
+
<?php $branch = json_decode($test['response'], true); ?>
|
| 193 |
+
<br><strong>分支名:</strong> <?= htmlspecialchars($branch['name'] ?? 'Unknown') ?>
|
| 194 |
+
<br><strong>最新提交:</strong> <?= htmlspecialchars(substr($branch['commit']['sha'] ?? '', 0, 7)) ?>
|
| 195 |
+
<?php endif; ?>
|
| 196 |
+
</div>
|
| 197 |
+
</div>
|
| 198 |
+
|
| 199 |
+
<!-- 文件创建权限 -->
|
| 200 |
+
<div class="mb-4">
|
| 201 |
+
<h5>4. 文件创建权限测试</h5>
|
| 202 |
+
<?php $test = $diagnostics['create_test']; ?>
|
| 203 |
+
<div class="alert alert-<?= $test['success'] ? 'success' : 'danger' ?>">
|
| 204 |
+
<strong>状态:</strong>
|
| 205 |
+
<span class="<?= $test['success'] ? 'status-ok' : 'status-error' ?>">
|
| 206 |
+
<?= $test['success'] ? '✅ 可以创建文件' : '❌ 无法创建文件' ?>
|
| 207 |
+
</span>
|
| 208 |
+
(HTTP <?= $test['http_code'] ?>)
|
| 209 |
+
|
| 210 |
+
<?php if ($test['success']): ?>
|
| 211 |
+
<br><strong>✅ 成功创建测试文件!GitHub 保存功能正常。</strong>
|
| 212 |
+
<?php else: ?>
|
| 213 |
+
<br><strong>错误详情:</strong>
|
| 214 |
+
<pre class="diagnostic-result mt-2"><?= htmlspecialchars($test['response']) ?></pre>
|
| 215 |
+
<?php endif; ?>
|
| 216 |
+
</div>
|
| 217 |
+
</div>
|
| 218 |
+
|
| 219 |
+
</div>
|
| 220 |
+
</div>
|
| 221 |
+
|
| 222 |
+
<!-- 解决方案 -->
|
| 223 |
+
<div class="card">
|
| 224 |
+
<div class="card-header">
|
| 225 |
+
<h3>🔧 问题解决方案</h3>
|
| 226 |
+
</div>
|
| 227 |
+
<div class="card-body">
|
| 228 |
+
<?php
|
| 229 |
+
$hasErrors = false;
|
| 230 |
+
foreach ($diagnostics as $test) {
|
| 231 |
+
if (!$test['success']) {
|
| 232 |
+
$hasErrors = true;
|
| 233 |
+
break;
|
| 234 |
+
}
|
| 235 |
+
}
|
| 236 |
+
?>
|
| 237 |
+
|
| 238 |
+
<?php if (!$hasErrors): ?>
|
| 239 |
+
<div class="alert alert-success">
|
| 240 |
+
<h5>🎉 所有测试通过!</h5>
|
| 241 |
+
<p>GitHub 配置完全正常。如果编辑器保存仍有问题,请检查:</p>
|
| 242 |
+
<ul>
|
| 243 |
+
<li>编辑器中的认证是否正确</li>
|
| 244 |
+
<li>浏览器控制台是否有错误</li>
|
| 245 |
+
<li>网络连接是否稳定</li>
|
| 246 |
+
</ul>
|
| 247 |
+
</div>
|
| 248 |
+
<?php else: ?>
|
| 249 |
+
<div class="alert alert-warning">
|
| 250 |
+
<h5>⚠️ 发现问题,请按以下步骤修复:</h5>
|
| 251 |
+
|
| 252 |
+
<?php if (!$diagnostics['token_test']['success']): ?>
|
| 253 |
+
<div class="mb-3">
|
| 254 |
+
<h6>🔑 Token 问题</h6>
|
| 255 |
+
<ul>
|
| 256 |
+
<li>检查 <code>GITHUB_TOKEN</code> 环境变量是否正确设置</li>
|
| 257 |
+
<li>访问 <a href="https://github.com/settings/tokens" target="_blank">GitHub Token 设置</a> 重新生成</li>
|
| 258 |
+
<li>确保 Token 有 <code>repo</code> 权限</li>
|
| 259 |
+
</ul>
|
| 260 |
+
</div>
|
| 261 |
+
<?php endif; ?>
|
| 262 |
+
|
| 263 |
+
<?php if (!$diagnostics['repo_test']['success']): ?>
|
| 264 |
+
<div class="mb-3">
|
| 265 |
+
<h6>📁 仓库问题</h6>
|
| 266 |
+
<ul>
|
| 267 |
+
<li>检查 <code>GITHUB_OWNER</code> 是否是正确的用户名(区分大小写)</li>
|
| 268 |
+
<li>检查 <code>GITHUB_REPO</code> 是否是正确的仓库名</li>
|
| 269 |
+
<li>确保仓库存在且 Token 有访问权限</li>
|
| 270 |
+
</ul>
|
| 271 |
+
</div>
|
| 272 |
+
<?php endif; ?>
|
| 273 |
+
|
| 274 |
+
<?php if (!$diagnostics['branch_test']['success']): ?>
|
| 275 |
+
<div class="mb-3">
|
| 276 |
+
<h6>🌿 分支问题</h6>
|
| 277 |
+
<ul>
|
| 278 |
+
<li>检查 <code>GITHUB_BRANCH</code> 是否正确(通常是 <code>main</code> 或 <code>master</code>)</li>
|
| 279 |
+
<li>在 GitHub 仓库中创建对应的分支</li>
|
| 280 |
+
</ul>
|
| 281 |
+
</div>
|
| 282 |
+
<?php endif; ?>
|
| 283 |
+
|
| 284 |
+
<?php if (!$diagnostics['create_test']['success']): ?>
|
| 285 |
+
<div class="mb-3">
|
| 286 |
+
<h6>✏️ 写入权限问题</h6>
|
| 287 |
+
<ul>
|
| 288 |
+
<li>确保 Token 有 <code>repo</code> 的完整权限</li>
|
| 289 |
+
<li>检查仓库是否允许写入</li>
|
| 290 |
+
<li>检查 <code>GITHUB_PATH</code> 路径格式是否正确</li>
|
| 291 |
+
</ul>
|
| 292 |
+
</div>
|
| 293 |
+
<?php endif; ?>
|
| 294 |
+
</div>
|
| 295 |
+
<?php endif; ?>
|
| 296 |
+
|
| 297 |
+
<div class="mt-4">
|
| 298 |
+
<a href="config.php" class="btn btn-secondary">返回配置页面</a>
|
| 299 |
+
<a href="github-test.php" class="btn btn-info">基础测试</a>
|
| 300 |
+
<a href="editor.html" class="btn btn-primary">返回编辑器</a>
|
| 301 |
+
</div>
|
| 302 |
+
</div>
|
| 303 |
+
</div>
|
| 304 |
+
|
| 305 |
+
<?php endif; ?>
|
| 306 |
+
</div>
|
| 307 |
+
</div>
|
| 308 |
+
</div>
|
| 309 |
+
</body>
|
| 310 |
+
</html>
|
github-test.php
CHANGED
|
@@ -147,33 +147,40 @@ if ($_POST['test_save'] ?? false) {
|
|
| 147 |
<div class="card-body">
|
| 148 |
<div style="background: #f8f9fa; padding: 15px; border-radius: 5px; font-family: monospace; font-size: 12px; max-height: 300px; overflow-y: auto;">
|
| 149 |
<?php
|
| 150 |
-
//
|
| 151 |
-
$logFiles = [
|
| 152 |
-
'/var/log/apache2/error.log',
|
| 153 |
-
'/var/log/httpd/error_log',
|
| 154 |
-
'/tmp/error.log',
|
| 155 |
-
ini_get('error_log')
|
| 156 |
-
];
|
| 157 |
-
|
| 158 |
$foundLogs = false;
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
|
|
|
|
|
|
| 165 |
foreach ($recentLines as $line) {
|
| 166 |
if (strpos($line, 'VvvebJs') !== false || strpos($line, 'GitHub') !== false) {
|
| 167 |
echo htmlspecialchars($line) . "<br>";
|
| 168 |
$foundLogs = true;
|
| 169 |
}
|
| 170 |
}
|
| 171 |
-
break;
|
| 172 |
}
|
| 173 |
}
|
| 174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
if (!$foundLogs) {
|
| 176 |
-
echo "
|
| 177 |
}
|
| 178 |
?>
|
| 179 |
</div>
|
|
|
|
| 147 |
<div class="card-body">
|
| 148 |
<div style="background: #f8f9fa; padding: 15px; border-radius: 5px; font-family: monospace; font-size: 12px; max-height: 300px; overflow-y: auto;">
|
| 149 |
<?php
|
| 150 |
+
// 显示 PHP 错误日志
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
$foundLogs = false;
|
| 152 |
+
|
| 153 |
+
// 检查 PHP 错误日志
|
| 154 |
+
$phpErrorLog = ini_get('error_log');
|
| 155 |
+
if ($phpErrorLog && file_exists($phpErrorLog) && is_readable($phpErrorLog)) {
|
| 156 |
+
echo "<strong>PHP 错误日志: $phpErrorLog</strong><br>";
|
| 157 |
+
$lines = @file($phpErrorLog);
|
| 158 |
+
if ($lines) {
|
| 159 |
+
$recentLines = array_slice($lines, -20);
|
| 160 |
foreach ($recentLines as $line) {
|
| 161 |
if (strpos($line, 'VvvebJs') !== false || strpos($line, 'GitHub') !== false) {
|
| 162 |
echo htmlspecialchars($line) . "<br>";
|
| 163 |
$foundLogs = true;
|
| 164 |
}
|
| 165 |
}
|
|
|
|
| 166 |
}
|
| 167 |
}
|
| 168 |
|
| 169 |
+
// 显示最近的保存尝试信息
|
| 170 |
+
if ($_POST['test_save'] ?? false) {
|
| 171 |
+
echo "<br><strong>最近的测试信息:</strong><br>";
|
| 172 |
+
echo "测试时间: " . date('Y-m-d H:i:s') . "<br>";
|
| 173 |
+
echo "目标仓库: {$github['owner']}/{$github['repo']}<br>";
|
| 174 |
+
echo "目标路径: {$github['path']}{$testResults['api_test']['test_file']}<br>";
|
| 175 |
+
echo "Token 长度: " . strlen($github['token']) . " 字符<br>";
|
| 176 |
+
if (isset($testResults['api_test']['output'])) {
|
| 177 |
+
echo "输出: " . htmlspecialchars($testResults['api_test']['output']) . "<br>";
|
| 178 |
+
}
|
| 179 |
+
$foundLogs = true;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
if (!$foundLogs) {
|
| 183 |
+
echo "未找到相关的错误日志。系统运行正常。";
|
| 184 |
}
|
| 185 |
?>
|
| 186 |
</div>
|