-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharticle.php
More file actions
35 lines (27 loc) · 1.08 KB
/
Copy patharticle.php
File metadata and controls
35 lines (27 loc) · 1.08 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
<?php
$id = isset($_GET['id']) ? intval($_GET['id']) : null;
$articleFile = "articles/article_$id.json";
if (!$id || !file_exists($articleFile)) {
die("Article not found.");
}
$data = json_decode(file_get_contents($articleFile), true);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><?= htmlspecialchars($data['title']) ?></title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 text-gray-800">
<div class="max-w-4xl mx-auto bg-white mt-8 rounded shadow p-6">
<a href="index.php" class="text-blue-600 hover:underline text-sm mb-4 inline-block">← Back to Blog</a>
<h1 class="text-3xl font-bold mb-2"><?= htmlspecialchars($data['title']) ?></h1>
<p class="text-gray-500 mb-4">By <?= htmlspecialchars($data['author']) ?> on <?= $data['date'] ?></p>
<img src="<?= htmlspecialchars($data['image']) ?>" class="w-full h-64 object-cover mb-6 rounded">
<div class="prose max-w-none">
<?= nl2br(htmlspecialchars($data['content'])) ?>
</div>
</div>
</body>
</html>