|
|
<?php
|
|
|
require_once __DIR__ . '/storage.php';
|
|
|
require_once __DIR__ . '/user-manager.php';
|
|
|
|
|
|
|
|
|
$userManager = new UserManager();
|
|
|
$authenticated = false;
|
|
|
|
|
|
if ($userManager->isLoggedIn()) {
|
|
|
$authenticated = true;
|
|
|
} else {
|
|
|
|
|
|
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:
|
|
|
.status-error { background-color:
|
|
|
.status-warning { background-color:
|
|
|
.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> |