Repository navigation
Expand file tree
/
Copy patharticle.php
More file actions
executable file
·89 lines (79 loc) · 4.52 KB
/
Copy patharticle.php
File metadata and controls
executable file
·89 lines (79 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
require_once __DIR__ . '/includes/config.php';
$slug = isset($_GET['slug']) ? trim($_GET['slug']) : '';
if (!$slug) { header('Location: /blog.php'); exit; }
$article = db()->fetchOne("SELECT * FROM vk_articles WHERE slug = :slug AND status = 1 LIMIT 1", [':slug' => $slug]);
if (!$article) {
$pageTitle = '文章不存在';
include __DIR__ . '/includes/header.php';
echo '<section style="padding:120px 0;text-align:center;"><div style="font-size:4rem;margin-bottom:20px;">🔍</div><h2 style="margin-bottom:24px;">文章不存在或已下架</h2><a href="/blog.php" class="btn btn-primary">返回教程中心</a></section>';
include __DIR__ . '/includes/footer.php';
exit;
}
// 增加浏览量
db()->query("UPDATE vk_articles SET views = views + 1 WHERE id = :id", [':id' => $article['id']]);
$pageTitle = $article['seo_title'] ?: $article['title'];
$pageDesc = $article['seo_description'] ?: $article['summary'] ?: mb_substr(strip_tags($article['content']), 0, 150);
$pageKeywords = $article['seo_keywords'] ?: '';
include __DIR__ . '/includes/header.php';
?>
<section style="padding:100px 0 60px;">
<div class="container" style="max-width:800px;margin:0 auto;">
<!-- 面包屑 -->
<div style="margin-bottom:24px;font-size:0.85rem;color:rgba(255,255,255,0.5);">
<a href="/" style="color:rgba(255,255,255,0.5);">首页</a>
<span style="margin:0 8px;">›</span>
<a href="/blog.php" style="color:rgba(255,255,255,0.5);">新闻资讯</a>
<span style="margin:0 8px;">›</span>
<span style="color:#fff;"><?= e($article['title']) ?></span>
</div>
<!-- 文章主体 -->
<article style="background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.08);border-radius:20px;padding:40px;">
<h1 style="font-size:1.8rem;font-weight:800;margin-bottom:16px;line-height:1.4;"><?= e($article['title']) ?></h1>
<div style="display:flex;gap:20px;align-items:center;margin-bottom:28px;padding-bottom:20px;border-bottom:1px solid rgba(255,255,255,0.08);font-size:0.85rem;color:rgba(255,255,255,0.5);">
<span>📅 <?= date('Y-m-d', strtotime($article['created_at'])) ?></span>
<span>👁️ <?= $article['views'] + 1 ?> 阅读</span>
<?php if ($article['author']): ?>
<span>✍️ <?= e($article['author']) ?></span>
<?php endif; ?>
</div>
<!-- 文章摘要 -->
<?php if ($article['summary']): ?>
<div style="background:rgba(131,88,255,0.08);border-left:3px solid #8358FF;padding:16px 20px;border-radius:0 12px 12px 0;margin-bottom:28px;">
<p style="color:rgba(255,255,255,0.8);line-height:1.8;font-size:0.95rem;margin:0;"><?= e($article['summary']) ?></p>
</div>
<?php endif; ?>
<!-- 文章内容 -->
<div class="article-content" style="color:rgba(255,255,255,0.75);line-height:1.9;font-size:1rem;">
<?= $article['content'] ?>
</div>
</article>
<!-- 相关推荐 -->
<div style="margin-top:40px;">
<h3 style="font-size:1.2rem;font-weight:700;margin-bottom:16px;">📖 相关推荐</h3>
<div style="display:grid;grid-template-columns:repeat(2,1fr);gap:14px;">
<?php
$related = db()->fetchAll("SELECT id, title, slug, created_at FROM vk_articles WHERE status = 1 AND id != :id ORDER BY RAND() LIMIT 2", [':id' => $article['id']]);
foreach ($related as $r):
?>
<a href="/article.php?slug=<?= e($r['slug']) ?>" style="background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.08);border-radius:14px;padding:18px;display:block;text-decoration:none;color:#fff;transition:all 0.3s;">
<div style="font-size:0.95rem;font-weight:600;margin-bottom:8px;line-height:1.4;"><?= e(mb_substr($r['title'], 0, 40)) ?>...</div>
<div style="font-size:0.8rem;color:rgba(255,255,255,0.4);"><?= date('Y-m-d', strtotime($r['created_at'])) ?></div>
</a>
<?php endforeach; ?>
</div>
</div>
</div>
</section>
<style>
.article-content h2 { font-size:1.4rem; font-weight:700; margin:28px 0 14px; color:#fff; border-left:4px solid #8358FF; padding-left:12px; }
.article-content h3 { font-size:1.15rem; font-weight:700; margin:22px 0 12px; color:#fff; }
.article-content p { margin-bottom:16px; }
.article-content ul, .article-content ol { margin:14px 0; padding-left:24px; }
.article-content li { margin-bottom:8px; }
.article-content strong { color:#fff; }
.article-content blockquote { border-left:3px solid #8358FF; padding:12px 20px; background:rgba(131,88,255,0.08); margin:16px 0; border-radius:0 8px 8px 0; }
.article-content img { max-width:100%; border-radius:12px; margin:16px 0; }
.article-content a { color:#18D2C9; text-decoration:underline; }
</style>
<?php include __DIR__ . '/includes/footer.php'; ?>