17-vm/admin.php
Flatlogic Bot 602648171f 财神
2026-02-07 15:34:20 +00:00

153 lines
6.5 KiB
PHP

<?php
session_start();
if (!isset($_SESSION['admin_logged_in'])) {
header('Location: login.php');
exit;
}
require_once __DIR__ . '/db/config.php';
$pdo = db();
$message = '';
// Handle Settings Update
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_settings'])) {
$updates = [
'site_title' => $_POST['site_title'],
'site_logo' => $_POST['site_logo'],
'tg_link' => $_POST['tg_link'],
'footer_copy' => $_POST['footer_copy'],
'watermark_text' => $_POST['watermark_text']
];
foreach ($updates as $key => $val) {
$stmt = $pdo->prepare("UPDATE settings SET setting_value = ? WHERE setting_key = ?");
$stmt->execute([$val, $key]);
}
$message = '设置更新成功!';
}
// Get current settings
$settings = [];
$stmt = $pdo->query("SELECT setting_key, setting_value FROM settings");
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$settings[$row['setting_key']] = $row['setting_value'];
}
$site_logo = $settings['site_logo'] ?? 'assets/pasted-20260207-134833-7329dc42.jpg';
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>后台管理 - <?php echo htmlspecialchars($settings['site_title'] ?? '财神组聊天框架'); ?></title>
<link rel="icon" type="image/jpeg" href="<?php echo htmlspecialchars($site_logo); ?>">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
<style>
:root { --admin-sidebar-width: 240px; }
body { background: #f8f9fa; }
.sidebar {
height: 100vh;
background: #212529;
color: #fff;
padding-top: 20px;
position: fixed;
width: var(--admin-sidebar-width);
z-index: 100;
}
.sidebar a { color: #adb5bd; text-decoration: none; padding: 12px 20px; display: block; transition: 0.2s; }
.sidebar a:hover, .sidebar a.active { background: #343a40; color: #fff; border-left: 4px solid #d4af37; }
.main-content {
margin-left: var(--admin-sidebar-width);
padding: 40px;
min-height: 100vh;
}
@media (max-width: 991px) {
.sidebar {
width: 100%;
height: auto;
position: fixed;
top: 0;
left: 0;
padding: 5px 0;
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
justify-content: flex-start;
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.main-content {
margin-left: 0;
padding: 80px 15px 20px 15px;
}
.sidebar a {
padding: 10px 15px;
white-space: nowrap;
font-size: 0.85rem;
border-left: none !important;
border-bottom: 3px solid transparent;
}
.sidebar a.active {
border-bottom: 3px solid #d4af37;
}
.sidebar hr, .sidebar .text-center { display: none !important; }
}
</style>
</head>
<body>
<div class="sidebar">
<div class="text-center mb-4 px-3">
<?php if($site_logo): ?>
<img src="<?php echo htmlspecialchars($site_logo); ?>" alt="Logo" class="img-fluid mb-2" style="max-height: 60px; border-radius: 8px;">
<?php endif; ?>
<h5 class="text-warning">财神组管理</h5>
</div>
<a href="admin.php" class="active"><i class="bi bi-gear-fill me-2"></i> 系统设置</a>
<a href="admin_steps.php"><i class="bi bi-chat-dots-fill me-2"></i> 话术管理</a>
<a href="index.php" target="_blank"><i class="bi bi-eye me-2"></i> 查看前台</a>
<a href="logout.php"><i class="bi bi-box-arrow-right me-2"></i> 退出登录</a>
</div>
<div class="main-content">
<div class="container-fluid">
<h3>系统设置</h3>
<?php if($message): ?>
<div class="alert alert-success mt-3"><?php echo $message; ?></div>
<?php endif; ?>
<div class="card shadow-sm mt-4">
<div class="card-body p-4">
<form method="POST">
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label fw-bold">网站名称</label>
<input type="text" name="site_title" class="form-control" value="<?php echo htmlspecialchars($settings['site_title'] ?? ''); ?>">
</div>
<div class="col-md-6 mb-3">
<label class="form-label fw-bold">网站 Logo/Favicon 路径</label>
<input type="text" name="site_logo" class="form-control" value="<?php echo htmlspecialchars($settings['site_logo'] ?? ''); ?>">
</div>
</div>
<div class="mb-3">
<label class="form-label fw-bold">Telegram 客服链接</label>
<input type="text" name="tg_link" class="form-control" value="<?php echo htmlspecialchars($settings['tg_link'] ?? ''); ?>">
</div>
<div class="mb-3">
<label class="form-label fw-bold">底部版权信息</label>
<textarea name="footer_copy" class="form-control" rows="2"><?php echo htmlspecialchars($settings['footer_copy'] ?? ''); ?></textarea>
</div>
<div class="mb-3">
<label class="form-label fw-bold">全屏水印文字</label>
<input type="text" name="watermark_text" class="form-control" value="<?php echo htmlspecialchars($settings['watermark_text'] ?? ''); ?>">
</div>
<div class="mt-4">
<button type="submit" name="update_settings" class="btn btn-warning px-5 fw-bold">保存全局设置</button>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>