NewHome/admin/_guard.php

37 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* admin/_guard.php —— 后台鉴权守卫 + 公共顶栏(所有后台页面在 $P='../' 定义后 require
*/
$P = $P ?? '../';
require_once dirname(__DIR__) . '/includes/auth.php';
require_once dirname(__DIR__) . '/includes/layout.php';
require_login('login.php');
/** 后台顶栏 */
function admin_topbar(string $active = ''): void
{
global $P;
$site = setting_get('site_name', '知识导航站');
$admin = (string)($_SESSION['admin'] ?? '');
echo '<div class="admin-nav"><div class="admin-nav-inner">';
echo '<a class="brand brand-sm" href="../index.php" title="查看前台首页">';
layout_logo_img('logo', $site);
echo '<span class="site-name">' . he($site) . ' · 后台</span></a>';
$links = [
'nav' => ['nav.php', '导航内容管理'],
'tools' => ['tools.php', '功能区管理'],
'articles' => ['articles.php', '文章管理'],
'exttools' => ['exttools.php', '外部工具'],
'content' => ['content.php', '内容与顺序'],
];
foreach ($links as $k => $lk) {
$cls = ($active === $k) ? 'active' : '';
echo '<a href="' . he($lk[0]) . '"' . ($cls ? ' class="' . $cls . '"' : '') . '>' . he($lk[1]) . '</a>';
}
echo '<span class="sp">';
echo '<span class="tip" style="color:rgba(255,255,255,.75)">管理员:' . he($admin) . '</span>';
echo '<a href="logout.php">退出登录</a>';
echo '</span>';
echo '</div></div>' . "\n";
}