File size: 11,441 Bytes
e67695a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4ba9d42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e67695a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?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 = [];
    
    // 检查是否在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>