65 lines
2.1 KiB
PHP
65 lines
2.1 KiB
PHP
<?php
|
|
// 前台:公告详情
|
|
require __DIR__ . '/includes/init.php';
|
|
|
|
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
|
|
if ($id <= 0) {
|
|
header('Location: announcement');
|
|
exit;
|
|
}
|
|
|
|
$stmt = db()->prepare('SELECT * FROM ' . tn('announcements') . ' WHERE id = ? AND status = 1');
|
|
$stmt->execute([$id]);
|
|
$a = $stmt->fetch();
|
|
|
|
if (!$a) {
|
|
http_response_code(404);
|
|
$pageTitle = '公告不存在';
|
|
require 'includes/header.php';
|
|
?>
|
|
<section class="section">
|
|
<div class="auth-card">
|
|
<h2><i class="fas fa-exclamation-circle"></i> 公告不存在</h2>
|
|
<p>该公告不存在或已被隐藏。</p>
|
|
<a href="announcements" class="btn btn-primary"><i class="fas fa-arrow-left"></i> 返回公告中心</a>
|
|
</div>
|
|
</section>
|
|
<?php
|
|
require 'includes/footer.php';
|
|
exit;
|
|
}
|
|
|
|
$pageTitle = $a['title'];
|
|
require 'includes/header.php';
|
|
?>
|
|
<section class="section">
|
|
<article class="ann-detail">
|
|
<header class="ann-detail-head">
|
|
<h1 class="ann-detail-title">
|
|
<?php if (!empty($a['pinned'])): ?><span class="ann-pin"><i class="fas fa-thumbtack"></i> 置顶</span><?php endif; ?>
|
|
<?= h($a['title']) ?>
|
|
</h1>
|
|
<div class="ann-detail-time"><i class="far fa-clock"></i> 发布时间:<?= date('Y-m-d H:i', strtotime($a['created_at'])) ?></div>
|
|
</header>
|
|
<div class="ann-detail-body" id="ann-body" data-md="<?= h($a['content']) ?>"><?= nl2br(h($a['content'])) ?></div>
|
|
<div class="ann-detail-foot">
|
|
<a href="announcements" class="btn btn-ghost"><i class="fas fa-arrow-left"></i> 返回公告中心</a>
|
|
</div>
|
|
</article>
|
|
</section>
|
|
<?php
|
|
$mv = file_exists(__DIR__ . '/assets/marked.js') ? filemtime(__DIR__ . '/assets/marked.js') : time();
|
|
?>
|
|
<script src="assets/marked.js?v=<?= $mv ?>"></script>
|
|
<script>
|
|
(function () {
|
|
var el = document.getElementById('ann-body');
|
|
if (el && window.marked) {
|
|
try {
|
|
el.innerHTML = marked.parse(el.getAttribute('data-md') || '');
|
|
} catch (e) {}
|
|
}
|
|
})();
|
|
</script>
|
|
<?php require 'includes/footer.php'; ?>
|