File size: 8,887 Bytes
0c4efc3
 
5186047
0c4efc3
5186047
 
0c4efc3
5186047
 
0c4efc3
 
5186047
0c4efc3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4aaaa07
 
 
 
0c4efc3
 
4aaaa07
0c4efc3
 
 
 
 
4aaaa07
 
 
0c4efc3
 
 
 
 
 
 
 
5186047
 
 
 
 
 
 
 
0c4efc3
5186047
 
0c4efc3
5186047
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0c4efc3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5186047
0c4efc3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d35d407
5186047
 
0c4efc3
 
d35d407
5186047
 
0c4efc3
 
 
 
 
5186047
0c4efc3
5186047
0c4efc3
5186047
 
 
 
 
 
 
 
 
 
 
 
 
 
0c4efc3
 
 
4aaaa07
 
 
 
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
<?php
require_once __DIR__ . '/storage.php';
require_once __DIR__ . '/user-manager.php';

// Check authentication
$userManager = new UserManager();
$authenticated = false;

if ($userManager->isLoggedIn()) {
    $authenticated = true;
} else {
    // Fallback to Basic Auth for environment variables
    if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
        $users = StorageConfig::getUsers();
        $username = $_SERVER['PHP_AUTH_USER'];
        $password = $_SERVER['PHP_AUTH_PW'];
        
        if (isset($users[$username]) && $users[$username] === $password) {
            $authenticated = true;
        }
    }
}

if (!$authenticated) {
    header('WWW-Authenticate: Basic realm="VvvebJs Configuration"');
    header('HTTP/1.0 401 Unauthorized');
    die('Authentication required');
}

?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>VvvebJs Configuration</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .status-item { padding: 5px 10px; margin: 2px 0; border-radius: 3px; }
        .status-ok { background-color: #d4edda; color: #155724; }
        .status-error { background-color: #f8d7da; color: #721c24; }
        .status-warning { background-color: #fff3cd; color: #856404; }
        .config-section { margin-bottom: 30px; }
    </style>
</head>
<body>
    <div class="container mt-4">

        <div class="row">

            <div class="col-md-12">

                <h1>🔧 VvvebJs 配置状态</h1>

                

                <!-- User Management Section -->

                <div class="config-section">

                    <h2>👥 用户管理系统</h2>

                    <?php

                    $envUsers = StorageConfig::getUsers();

                    if (!empty($envUsers)) {
                        echo '<div class="status-item status-ok">✅ 环境变量用户系统 (简单高效)</div>';
                        echo '<div class="status-item status-ok">📊 已配置 ' . count($envUsers) . ' 个用户账号</div>';
                        foreach ($envUsers as $username => $password) {
                            echo '<div class="status-item status-ok">👤 用户: ' . htmlspecialchars($username) . '</div>';
                        }
                        
                        if ($userManager->isLoggedIn()) {
                            echo '<div class="status-item status-ok">🔐 当前登录用户: ' . htmlspecialchars($userManager->getCurrentUser()) . '</div>';
                        }
                    } else {
                        echo '<div class="status-item status-error">❌ 未找到用户配置</div>';
                        echo '<div class="status-item status-warning">请检查环境变量 USER_1_NAME, USER_1_PASSWORD 等设置</div>';
                    }
                    ?>
                    
                    <div class="mt-3">

                        <h4>💡 用户管理特性</h4>

                        <ul>

                            <li>✅ 基于环境变量配置,安全可靠</li>

                            <li>✅ 用户数据按账号隔离存储</li>

                            <li>✅ GitHub仓库按用户目录分类</li>

                            <li>✅ 支持session登录,用户体验良好</li>

                            <li>✅ 无注册功能,管理员完全控制</li>

                        </ul>

                    </div>

                </div>



                <!-- Storage Configuration -->

                <div class="config-section">

                    <h2>💾 存储配置</h2>

                    <?php

                    $configOk = true;

                    $errors = [];

                    

                    $storageType = StorageConfig::getStorageType();

                    echo '<div class="status-item status-ok">📁 Storage Type: ' . htmlspecialchars($storageType) . '</div>';

                    

                    if (in_array($storageType, ['github', 'both'])) {
                        echo '<h4>GitHub Storage</h4>';
                        $github = StorageConfig::getGitHubConfig();
                        
                        if (empty($github['token'])) {
                            echo '<div class="status-item status-error">❌ GitHub token not configured</div>';
                            $configOk = false;
                            $errors[] = 'GitHub token missing';
                        } else {
                            echo '<div class="status-item status-ok">✅ GitHub token configured</div>';
                        }
                        
                        if (empty($github['owner']) || empty($github['repo'])) {
                            echo '<div class="status-item status-error">❌ GitHub owner/repo not configured</div>';
                            $configOk = false;
                            $errors[] = 'GitHub repository not configured';
                        } else {
                            echo '<div class="status-item status-ok">✅ Repository: ' . htmlspecialchars($github['owner']) . '/' . htmlspecialchars($github['repo']) . '</div>';
                            echo '<div class="status-item status-ok">🌿 Branch: ' . htmlspecialchars($github['branch']) . '</div>';
                            echo '<div class="status-item status-ok">📂 Path: ' . htmlspecialchars($github['path']) . '</div>';
                            echo '<div class="status-item status-ok">🔗 用户文件存储结构: <code>' . htmlspecialchars($github['path']) . 'users/{username}/*.html</code></div>';
                        }
                    }
                    
                    if (in_array($storageType, ['kv', 'both'])) {
                        echo '<h4>EdgeOne KV Storage</h4>';
                        $kv = StorageConfig::getKVConfig();
                        
                        if (empty($kv['api_key'])) {
                            echo '<div class="status-item status-warning">⚠️ EdgeOne KV API key not configured</div>';
                        } else {
                            echo '<div class="status-item status-ok">✅ EdgeOne KV configured</div>';
                        }
                    }
                    ?>
                </div>

                <!-- System Status -->
                <div class="config-section">

                    <h2>⚙️ 系统状态</h2>

                    <?php

                    if ($configOk) {
                        echo '<div class="status-item status-ok">✅ 系统配置正常</div>';
                    } else {
                        echo '<div class="status-item status-error">❌ 系统配置有问题</div>';
                        foreach ($errors as $error) {
                            echo '<div class="status-item status-error"> - ' . htmlspecialchars($error) . '</div>';
                        }
                    }
                    ?>
                </div>

                <!-- Quick Actions -->
                <div class="config-section">

                    <h2>🚀 快速操作</h2>

                    <div class="row">

                        <div class="col-md-6">

                            <a href="/" class="btn btn-success btn-lg w-100">

                                🔐 用户登录

                            </a>

                        </div>

                        <div class="col-md-6">

                            <a href="editor.html" class="btn btn-primary btn-lg w-100">

                                📝 启动编辑器

                            </a>

                        </div>

                    </div>

                </div>



                <!-- File Structure Info -->

                <div class="config-section">

                    <h2>📁 文件结构说明</h2>

                    <div class="alert alert-info">

                        <h5>GitHub 存储结构</h5>

                        <pre><code>pages/

├── users/

│   ├── PS01/

│   │   ├── index.html

│   │   └── about.html

│   ├── PS02/

│   │   ├── portfolio.html

│   │   └── contact.html

│   ├── PS03/

│   │   └── blog.html

│   └── PS04/

│       └── products.html</code></pre>

                        <p><strong>说明:</strong> 每个用户只能访问和编辑自己目录下的文件,实现完全的数据隔离。</p>

                    </div>

                </div>

            </div>

        </div>

    </div>

</body>

</html>