-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharticle.php
More file actions
191 lines (160 loc) · 6.29 KB
/
article.php
File metadata and controls
191 lines (160 loc) · 6.29 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
spl_autoload_register(function ($class)
{include"classes/".$class.".php";});
//check of the user is logged in:
$session = new UserSessionHandler();
$isLoggedIn = $session->logged_in();
// Load selected article
$newsDisplay = new NewsDisplay();
// Validate GET id
$articleId = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
if (!$articleId) {
die("Invalid article ID.");
}
$article = $newsDisplay->getNewsById($articleId);
if (!$article) {
die("Article not found.");
}
if (!$article) {
die("Article not found.");
}
// Resolve banner image
$img = $article['banner_img'];
if (empty($img)) {
$bannerPath = "images/news/placeholder.jpg";
} elseif (preg_match('/^https?:\/\//', $img)) {
$bannerPath = $img;
} else {
$bannerPath = "images/news/" . ltrim($img, "/");
}
$formattedDate = date("F j, Y", strtotime($article['release_date']));
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= htmlspecialchars($article['title']) ?> - Midnight Scream Spectacle</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Creepster&family=EB+Garamond:wght@400;700&display=swap');
body {
font-family: 'EB Garamond', serif;
background-color: #0f0a1a;
color: #e0d6eb;
}
.horror-font {
font-family: 'Creepster', cursive;
}
.purple-dark {
background-color: #1a1029;
}
.purple-light {
background-color: #2a1a4a;
}
.moss-green {
background-color: #1a2910;
}
.blood-red {
color: #ff3a3a;
}
.glow {
text-shadow: 0 0 5px #9b59b6, 0 0 10px #9b59b6;
}
</style>
</head>
<body class="min-h-screen">
<!-- Navigation -->
<nav class="purple-dark sticky top-0 z-50 shadow-lg">
<div class="container mx-auto px-6 py-3">
<div class="flex items-center justify-between">
<a href="index.php" class="horror-font text-3xl blood-red glow">Midnight Scream</a>
<div class="hidden md:flex items-center space-x-8">
<a href="index.php" class="text-white hover:text-purple-300">Home</a>
<a href="movies.php" class="text-white hover:text-purple-300">Movies</a>
<a href="news.php" class="text-white font-bold">News</a>
<a href="about.php" class="text-white hover:text-purple-300">About Us</a>
<?php if ($isLoggedIn): ?>
<a href="profile.php" class="text-white hover:text-purple-300">Profile</a>
<?php else: ?>
<a href="login.php" class="text-white hover:text-purple-300">Login</a>
<?php endif; ?>
</div>
<div class="md:hidden relative z-50">
<button id="mobile-menu-button" type="button" class="text-white focus:outline-none">
<i data-feather="menu"></i>
</button>
<div id="mobile-menu" class="hidden fixed inset-0 purple-dark z-50 pt-20">
<div class="flex flex-col items-center space-y-6 text-xl">
<a href="index.php" class="text-white hover:text-purple-300">Home</a>
<a href="movies.php" class="text-white hover:text-purple-300">Movies</a>
<a href="news.php" class="text-white hover:text-purple-300">News</a>
<a href="about.php" class="text-white hover:text-purple-300">About Us</a>
<?php if ($isLoggedIn): ?>
<a href="profile.php" class="text-white hover:text-purple-300">Profile</a>
<?php else: ?>
<a href="login.php" class="text-white hover:text-purple-300">Login</a>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</nav>
<!-- News Article Content -->
<section class="py-0">
<!-- Dynamic Banner -->
<div class="w-full h-[32rem] bg-cover bg-center"
style="background-image: url('<?= htmlspecialchars($bannerPath) ?>');">
</div>
<div class="container mx-auto px-8 lg:px-16 max-w-5xl py-16">
<h1 class="horror-font text-5xl md:text-6xl blood-red mb-6">
<?= htmlspecialchars($article['title']) ?>
</h1>
<p class="text-gray-400 mb-12 text-xl">
<?= $formattedDate ?>
</p>
<div class="prose max-w-none text-xl leading-relaxed">
<?= nl2br(htmlspecialchars($article['content'])) ?>
</div>
<div class="mt-12">
<a href="news.php"
class="inline-block moss-green hover:bg-green-900 text-white py-2 px-4 rounded transition duration-300">
← Back to News
</a>
</div>
</div>
</section>
<!-- Footer -->
<footer class="purple-dark py-8">
<div class="container mx-auto px-6 text-center md:text-left">
<span class="horror-font text-2xl blood-red">Midnight Scream</span>
<p class="text-sm mt-1">© 2023 All Rights Reserved</p>
</div>
</footer>
<script>
feather.replace();
const mobileMenuButton = document.getElementById('mobile-menu-button');
const mobileMenu = document.getElementById('mobile-menu');
if (mobileMenuButton && mobileMenu) {
mobileMenuButton.addEventListener('click', (e) => {
e.stopPropagation();
mobileMenu.classList.toggle('hidden');
});
// Close menu when clicking a link
mobileMenu.querySelectorAll('a').forEach(a => {
a.addEventListener('click', () => mobileMenu.classList.add('hidden'));
});
// Close menu when clicking outside
document.addEventListener('click', (event) => {
if (!mobileMenu.contains(event.target) && event.target !== mobileMenuButton) {
mobileMenu.classList.add('hidden');
}
});
}
</script>
</body>
</html>