<?php
ob_start();
/**
 * 2026企业CMS - 后台公共头部
 */
require_once __DIR__ . '/../includes/functions.php';
require_once __DIR__ . '/../includes/auth.php';
admin_check_login();

// 授权管理仅限 barju.cn 主站，此站点跳过


$admin = current_admin();
$pageTitle = $pageTitle ?? '后台管理';
?>
<!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 xss_clean($pageTitle); ?> - 后台管理 - <?php echo SITE_NAME; ?></title>
    <link rel="stylesheet" href="/admin/style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body>
    <!-- 后台顶部栏 -->
    <div class="admin-topbar">
        <div class="admin-logo">
            <h1><?php echo SITE_NAME; ?> 后台</h1>
            <span class="admin-branding">by 长沙吧聚网络科技有限公司</span>
        </div>
        <div class="admin-user">
            <span>欢迎，<?php echo xss_clean($admin['realname'] ?: $admin['username']); ?></span>
            <a href="/admin/profile.php" title="个人设置"><i class="fas fa-user-cog"></i></a>
            <a href="/admin/login.php?action=logout" title="退出登录"><i class="fas fa-sign-out-alt"></i></a>
            <a href="/" target="_blank" title="查看网站"><i class="fas fa-external-link-alt"></i></a>
        </div>
    </div>
    
    <!-- 后台主体 -->
    <div class="admin-body">
        <!-- 左侧菜单 -->
        <div class="admin-sidebar" id="sidebar">
            <ul class="admin-menu">
                <li class="<?php echo ($_GET['p'] ?? 'dashboard')=='dashboard'?'active':''; ?>">
                    <a href="/admin/index.php"><i class="fas fa-tachometer-alt"></i> <span>仪表盘</span></a>
                </li>
                
                <li class="menu-group">内容管理</li>
                <li class="<?php echo strpos($_GET['p'] ?? '','article')===0?'active':''; ?>">
                    <a href="/admin/articles.php"><i class="fas fa-newspaper"></i> <span>文章管理</span></a>
                </li>
                <li class="<?php echo ($_GET['p'] ?? '')=='categories'?'active':''; ?>">
                    <a href="/admin/categories.php"><i class="fas fa-folder-tree"></i> <span>文章分类</span></a>
                </li>
                <li class="<?php echo strpos($_GET['p'] ?? '','product')===0?'active':''; ?>">
                    <a href="/admin/products.php"><i class="fas fa-box"></i> <span>产品管理</span></a>
                </li>
                <li class="<?php echo ($_GET['p'] ?? '')=='attributes'?'active':''; ?>">
                    <a href="/admin/attributes.php"><i class="fas fa-filter"></i> <span>产品属性</span></a>
                </li>
                <li class="<?php echo ($_GET['p'] ?? '')=='forms'?'active':''; ?>">
                    <a href="/admin/forms.php"><i class="fas fa-wpforms"></i> <span>内置表单</span></a>
                </li>
                <li class="<?php echo strpos($_GET['p'] ?? '','case')===0?'active':''; ?>">
                    <a href="/admin/cases.php"><i class="fas fa-images"></i> <span>案例管理</span></a>
                </li>
                <li class="<?php echo strpos($_GET['p'] ?? '','page')===0?'active':''; ?>">
                    <a href="/admin/pages.php"><i class="fas fa-file-alt"></i> <span>单页管理</span></a>
                </li>
                <li class="<?php echo strpos($_GET['p'] ?? '','team')===0?'active':''; ?>">
                    <a href="/admin/team.php"><i class="fas fa-users"></i> <span>团队管理</span></a>
                </li>
                
                <li class="menu-group">外观设置</li>
                <li class="<?php echo strpos($_GET['p'] ?? '','theme')===0?'active':''; ?>">
                    <a href="/admin/themes.php"><i class="fas fa-palette"></i> <span>模板管理</span></a>
                </li>
                <li class="<?php echo strpos($_GET['p'] ?? '','menu')===0?'active':''; ?>">
                    <a href="/admin/menus.php"><i class="fas fa-bars"></i> <span>导航菜单</span></a>
                </li>
                <li class="<?php echo strpos($_GET['p'] ?? '','slide')===0?'active':''; ?>">
                    <a href="/admin/slides.php"><i class="fas fa-sliders-h"></i> <span>幻灯片</span></a>
                </li>
                
                <li class="menu-group">系统设置</li>
                <li class="<?php echo strpos($_GET['p'] ?? '','setting')===0?'active':''; ?>">
                    <a href="/admin/settings.php"><i class="fas fa-cog"></i> <span>网站设置</span></a>
                </li>
                <li class="<?php echo strpos($_GET['p'] ?? '','seo')===0?'active':''; ?>">
                    <a href="/admin/seo.php"><i class="fas fa-search"></i> <span>SEO设置</span></a>
                                </li>
                <li class="<?php echo ($_GET['p'] ?? '')=='update'?'active':''; ?>">
                    <a href="/admin/update.php"><i class="fas fa-sync-alt"></i> <span>一键升级</span></a>
                </li>
                <li class="<?php echo strpos($_GET['p'] ?? '','contact')===0?'active':''; ?>">
                    <a href="/admin/contacts.php"><i class="fas fa-envelope"></i> <span>联系表单</span></a>
                </li>
                <li class="<?php echo strpos($_GET['p'] ?? '','link')===0?'active':''; ?>">
                    <a href="/admin/links.php"><i class="fas fa-link"></i> <span>友情链接</span></a>
                </li>
                <li class="<?php echo strpos($_GET['p'] ?? '','media')===0?'active':''; ?>">
                    <a href="/admin/media.php"><i class="fas fa-photo-video"></i> <span>媒体库</span></a>
                </li>
                
                <li class="menu-group">管理员</li>
                <li class="<?php echo strpos($_GET['p'] ?? '','admin')===0?'active':''; ?>">
                    <a href="/admin/admins.php"><i class="fas fa-user-shield"></i> <span>管理员</span></a>
                </li>
                <li class="<?php echo strpos($_GET['p'] ?? '','log')===0?'active':''; ?>">
                    <a href="/admin/logs.php"><i class="fas fa-history"></i> <span>操作日志</span></a>
                </li>
            </ul>
        </div>
        
        <!-- 右侧内容区 -->
        <div class="admin-content">
            <?php if (isset($_GET['msg'])): ?>
            <div class="alert alert-success"><?php echo xss_clean($_GET['msg']); ?></div>
            <?php endif; ?>
            <?php if (isset($_GET['error'])): ?>
            <div class="alert alert-danger"><?php echo xss_clean($_GET['error']); ?></div>
            <?php endif; ?>
