115 lines
6.9 KiB
PHP
115 lines
6.9 KiB
PHP
<?php
|
||
if (!defined('IN_APP')) {
|
||
http_response_code(403);
|
||
header("HTTP/2 403 Forbidden");
|
||
exit();
|
||
}
|
||
$pageTitle = isset($pageTitle) ? $pageTitle : getSiteName();
|
||
$user = currentUser();
|
||
$cartCount = 0;
|
||
if (!empty($_SESSION['cart'])) {
|
||
$cartCount = array_sum(array_map('intval', $_SESSION['cart']));
|
||
}
|
||
$theme = currentTheme();
|
||
$cssVer = file_exists(__DIR__ . '/../assets/style.css') ? filemtime(__DIR__ . '/../assets/style.css') : time();
|
||
$verifyNotice = '';
|
||
$verifyOk = false;
|
||
if (isset($_SESSION['verify_notice'])) {
|
||
$verifyNotice = $_SESSION['verify_notice'] === 'sent'
|
||
? '验证邮件已发送至你的邮箱,请点击邮件中的链接完成验证。'
|
||
: '抱歉,验证邮件发送失败。请在「用户设置」中点击重发。';
|
||
$verifyOk = ($_SESSION['verify_notice'] === 'sent');
|
||
unset($_SESSION['verify_notice']);
|
||
}
|
||
?>
|
||
<!DOCTYPE html>
|
||
<html lang="<?= Lang::htmlLang() ?>" data-theme="<?= $theme ?>">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title><?= h($pageTitle) ?> - <?= h(getSiteName()) ?></title>
|
||
<?php
|
||
$favicon = getSetting('favicon', '');
|
||
if (!empty($favicon) && file_exists(__DIR__ . '/../' . $favicon)) {
|
||
echo '<link rel="icon" href="' . h($favicon) . '?v=' . filemtime(__DIR__ . '/../' . $favicon) . '">' . "\n ";
|
||
}
|
||
?>
|
||
<meta name="csrf" content="<?= csrfToken() ?>">
|
||
<link rel="stylesheet" href="assets/vendor/fontawesome/all.min.css">
|
||
<link rel="stylesheet" href="assets/style.css?v=<?= $cssVer ?>">
|
||
</head>
|
||
<body>
|
||
<header class="site-header">
|
||
<div class="container nav">
|
||
<button class="nav-toggle" id="navToggle" aria-label="展开菜单" aria-expanded="false"><i class="fas fa-bars"></i></button>
|
||
<a href="/" class="brand"><i class="fas fa-store"></i> <?= h(getSiteName()) ?></a>
|
||
<nav class="nav-links" id="navLinks">
|
||
<a href="/"><i class="fas fa-home"></i> <?= __('common.home') ?></a>
|
||
<a href="/#products"><i class="fas fa-tags"></i> <?= __('common.all_products') ?></a>
|
||
<a href="ticket"><i class="fas fa-ticket-alt"></i> <?= __('common.submit_ticket') ?></a>
|
||
<a href="announcements"><i class="fas fa-bullhorn"></i> <?= __('common.announcements') ?></a>
|
||
<a href="cart"><i class="fas fa-shopping-cart"></i> <?= __('common.cart') ?><?php if ($cartCount): ?><span class="badge"><?= $cartCount ?></span><?php endif; ?></a>
|
||
</nav>
|
||
<div class="nav-actions">
|
||
<button class="theme-toggle" id="themeToggle" title="<?= __('theme.switch_theme') ?>"><i class="fas fa-moon"></i></button>
|
||
<a href="lang.php?lang=<?= Lang::getLocale() === 'zh_CN' ? 'en_US' : 'zh_CN' ?>" class="lang-switch" title="<?= Lang::getLocale() === 'zh_CN' ? 'English' : '中文' ?>">
|
||
<i class="fas fa-language"></i> <span class="lang-label"><?= Lang::getLocale() === 'zh_CN' ? 'EN' : '中' ?></span>
|
||
</a>
|
||
<?php if ($user): ?>
|
||
<div class="user-menu" id="userMenu">
|
||
<button class="avatar" id="avatarBtn" aria-haspopup="true" aria-expanded="false" title="<?= h($user['nickname'] ?: $user['username']) ?>">
|
||
<?php if (!empty($user['avatar'])): ?>
|
||
<img src="<?= h($user['avatar']) ?>" alt="<?= h(avatarText($user['nickname'] ?: $user['username'])) ?>" style="width:100%;height:100%;object-fit:cover;border-radius:50%">
|
||
<?php else: ?>
|
||
<?= h(avatarText($user['nickname'] ?: $user['username'])) ?>
|
||
<?php endif; ?>
|
||
</button>
|
||
<div class="user-card" id="userCard" hidden>
|
||
<div class="uc-head">
|
||
<span class="uc-avatar">
|
||
<?php if (!empty($user['avatar'])): ?>
|
||
<img src="<?= h($user['avatar']) ?>" alt="" style="width:100%;height:100%;object-fit:cover;border-radius:50%">
|
||
<?php else: ?>
|
||
<?= h(avatarText($user['nickname'] ?: $user['username'])) ?>
|
||
<?php endif; ?>
|
||
</span>
|
||
<div class="uc-id">
|
||
<div class="uc-name"><?= h($user['nickname'] ?: $user['username']) ?></div>
|
||
<div class="uc-handle">@<?= h($user['username']) ?></div>
|
||
<?php if (empty($user['verified'])): ?>
|
||
<span class="uc-badge unverified"><i class="fas fa-times"></i> <?= __('common.email_unverified') ?></span>
|
||
<?php else: ?>
|
||
<span class="uc-badge verified"><i class="fas fa-check"></i> <?= __('common.email_verified') ?></span>
|
||
<?php endif; ?>
|
||
</div>
|
||
</div>
|
||
<div class="uc-points"><i class="fas fa-coins"></i> <?= __('common.points') ?>:<strong><?= (int) getUserPoints($user['id']) ?></strong></div>
|
||
<a class="uc-item" href="myorders"><i class="fas fa-receipt"></i> <?= __('common.my_orders') ?></a>
|
||
<a class="uc-item" href="mytickets"><i class="fas fa-ticket-alt"></i> <?= __('common.my_tickets') ?></a>
|
||
<a class="uc-item" href="sign"><i class="fas fa-calendar-days"></i> <?= __('common.sign_in') ?></a>
|
||
<a class="uc-item" href="invite"><i class="fas fa-user-plus"></i> <?= __('common.invite_friends') ?></a>
|
||
<a class="uc-item" href="settings"><i class="fas fa-gear"></i> <?= __('common.settings') ?></a>
|
||
<a class="uc-item danger" href="logout"><i class="fas fa-right-from-bracket"></i> <?= __('common.logout') ?></a>
|
||
</div>
|
||
</div>
|
||
<?php else: ?>
|
||
<a href="login" class="btn btn-primary"><i class="fas fa-sign-in"></i></a>
|
||
<?php endif; ?>
|
||
</div>
|
||
</div>
|
||
</header>
|
||
|
||
<?php if ($verifyNotice): ?>
|
||
<div class="verify-banner <?= $verifyOk ? 'ok' : 'warn' ?>">
|
||
<i class="fas <?= $verifyOk ? 'fa-circle-check' : 'fa-triangle-exclamation' ?>"></i>
|
||
<span><?= h($verifyNotice) ?></span>
|
||
</div>
|
||
<?php elseif ($user && empty($user['verified'])): ?>
|
||
<div class="verify-banner warn">
|
||
<i class="fas fa-triangle-exclamation"></i>
|
||
<span>你的邮箱尚未验证,<a href="verify?resend=1">点击重新发送验证邮件</a>。</span>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<main class="container main">
|