[ 'method' => 'GET', 'header' => implode("\r\n", $headers) ] ]); $response = @file_get_contents($apiUrl, false, $context); $repoInfo = $response ? json_decode($response, true) : null; $testResults['api_connection'] = [ 'success' => $repoInfo !== null, 'response' => $repoInfo ? 'Repository found' : 'Failed to connect', 'repo_name' => $repoInfo['name'] ?? 'N/A', 'default_branch' => $repoInfo['default_branch'] ?? 'N/A' ]; // 测试2: 分支检查 if ($testResults['api_connection']['success']) { $branchUrl = "https://api.github.com/repos/{$github['owner']}/{$github['repo']}/branches/{$github['branch']}"; $branchContext = stream_context_create([ 'http' => [ 'method' => 'GET', 'header' => implode("\r\n", $headers) ] ]); $branchResponse = @file_get_contents($branchUrl, false, $branchContext); $branchInfo = $branchResponse ? json_decode($branchResponse, true) : null; $testResults['branch_check'] = [ 'success' => $branchInfo !== null, 'branch_name' => $github['branch'], 'exists' => $branchInfo !== null, 'commit_sha' => $branchInfo['commit']['sha'] ?? 'N/A' ]; } // 测试3: 目录结构检查 $testResults['directory_structure'] = []; $directories = [ 'pages' => "pages", 'users' => "pages/users", 'user_dir' => "pages/{$userPath}" ]; foreach ($directories as $key => $path) { $dirUrl = "https://api.github.com/repos/{$github['owner']}/{$github['repo']}/contents/{$path}"; $dirContext = stream_context_create([ 'http' => [ 'method' => 'GET', 'header' => implode("\r\n", $headers) ] ]); $dirResponse = @file_get_contents($dirUrl, false, $dirContext); $testResults['directory_structure'][$key] = [ 'path' => $path, 'exists' => $dirResponse !== false, 'response' => $dirResponse ? 'Found' : 'Not found' ]; } // 测试4: 文件保存测试 $storageManager = new StorageManager(); $testHtml = '
✅ GitHub API Connection: SUCCESS
✅ Branch Verification: SUCCESS
✅ Directory Structure: SUCCESS
✅ File Save Operation: SUCCESS
Test Time: ' . date('Y-m-d H:i:s') . ' UTC
User: ' . htmlspecialchars($currentUser) . '
Repository: ' . htmlspecialchars($github['owner']) . '/' . htmlspecialchars($github['repo']) . '
Branch: ' . htmlspecialchars($github['branch']) . '
User Path: ' . htmlspecialchars($userPath) . '
Your VvvebJs installation is properly configured and can successfully save files to GitHub. You can now use all editor features with confidence!
GitHub仓库: = htmlspecialchars($github['owner']) ?>/= htmlspecialchars($github['repo']) ?>
分支: = htmlspecialchars($github['branch']) ?>
基础路径: = htmlspecialchars($github['path']) ?>
当前用户: = htmlspecialchars($currentUser) ?>
用户路径: = htmlspecialchars($userPath) ?>
Token状态: = empty($github['token']) ? '❌ 未设置' : '✅ 已配置' ?>
= $testResults['summary']['passed_tests'] ?>/= $testResults['summary']['total_tests'] ?> 测试通过
状态: = htmlspecialchars($testResults['api_connection']['response']) ?>
仓库: = htmlspecialchars($testResults['api_connection']['repo_name']) ?>
默认分支: = htmlspecialchars($testResults['api_connection']['default_branch']) ?>
目标分支: = htmlspecialchars($testResults['branch_check']['branch_name']) ?>
存在状态: = $testResults['branch_check']['exists'] ? '✅ 存在' : '❌ 不存在' ?>
最新提交: = htmlspecialchars(substr($testResults['branch_check']['commit_sha'], 0, 8)) ?>...
= $dir['exists'] ? '✅' : '⚠️' ?>
= htmlspecialchars($dir['path']) ?>
文件名: = htmlspecialchars($testResults['file_save']['filename']) ?>
内容长度: = $testResults['file_save']['content_length'] ?> 字节
结果: = htmlspecialchars($testResults['file_save']['message']) ?>
在GitHub上查看读取状态: = $testResults['file_retrieve']['success'] ? '✅ 成功' : '❌ 失败' ?>
内容匹配: = $testResults['file_retrieve']['content_matches'] ? '✅ 一致' : '❌ 不一致' ?>
读取长度: = $testResults['file_retrieve']['retrieved_length'] ?> 字节