-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetails-full-width.php
425 lines (381 loc) · 17.8 KB
/
details-full-width.php
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
<?php
require_once('scripts/scripts.php');
require_once('Auth.php');
$isLoggedIn = Auth::isLoggedIn();
$showAdminPage = Auth::isAdmin();
// Id for the post page
$postIndex = $_GET['id'];
$error="";
require_once('db.php');
if ($isLoggedIn) {
$userInfo = getUserInfo($db, $_SESSION['ID']);
}
// To post a comment, check if logged and comment there
if ($isLoggedIn && count($_POST) > 0) {
if (isset($_POST['comment'][0])) {
try {
newsaveComment($db, $postIndex, $_POST);
} catch(Exception $e) {
$error = $e->getMessage();
}
}
}
// GET THE POST
try {
// Get post
$q = "
SELECT title, description, user_id, image, p.created_at, firstname, lastname, picture
FROM posts p
LEFT JOIN users u ON p.user_id = u.id
WHERE p.id = ? AND status = 'published'
";
$stmt = $db->prepare($q); /** @var PDOStatement $stmt */
$stmt->execute([$postIndex]);
$post = $stmt->fetch();
// Get post categories
$q = "
SELECT category
FROM post_categories
WHERE post_id = ?
";
$stmt = $db->prepare($q); /** @var PDOStatement $stmt */
$stmt->execute([$postIndex]);
$categories = $stmt->fetchAll(PDO::FETCH_COLUMN);
// Get post looking_for
$q = "
SELECT role
FROM looking_for
WHERE post_id = ?
";
$stmt = $db->prepare($q); /** @var PDOStatement $stmt */
$stmt->execute([$postIndex]);
$looking_for = $stmt->fetchAll(PDO::FETCH_COLUMN);
// Get post comments
$q = "
SELECT c.id, post_id, user_id, parent_id, comment, c.created_at, firstname, lastname, picture
FROM comments c
LEFT JOIN users u ON c.user_id = u.id
WHERE post_id = ?
ORDER BY c.created_at DESC
";
$stmt = $db->prepare($q); /** @var PDOStatement $stmt */
$stmt->execute([$postIndex]);
$comments = $stmt->fetchAll();
// Get post comments
$q = "
SELECT COUNT(user_id) AS like_count
FROM post_likes
WHERE post_id = ?
";
$stmt = $db->prepare($q); /** @var PDOStatement $stmt */
$stmt->execute([$postIndex]);
$like_count = $stmt->fetchColumn();
} catch(Exception $e) {
if ($db->inTransaction()){
$db->rollBack();
}
// Handle the error (log it, display an error message, etc.)
echo "Transaction failed: " . $e->getMessage();
$error = $e->getMessage();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>BizBlog</title>
<link rel="shortcut icon" type="image/png" href="assets/images/favicon.png">
<link href="https://fonts.googleapis.com/css?family=Quicksand:300,400,500%7CSpectral:400,400i,500,600,700"
rel="stylesheet">
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<!-- Include Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/plugins/animate/animate.min.css">
<link rel="stylesheet" href="assets/plugins/owl-carousel/owl.carousel.min.css">
<link rel="stylesheet" href="assets/plugins/magnific-popup/magnific-popup.css">
<link rel="stylesheet" href="assets/css/style.css">
<link rel="stylesheet" href="assets/css/responsive.css">
<link rel="stylesheet" href="assets/css/custom.css">
<link rel="apple-touch-icon" sizes="180x180" href="assets/images/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="assets/images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon/favicon-16x16.png">
<link rel="manifest" href="assets/images/favicon/site.webmanifest">
<link rel="mask-icon" href="assets/images/favicon/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
</head>
<body>
<div class="preloader">
<div class="preload-img">
<div class="spinnerBounce">
<div class="double-bounce1"></div>
<div class="double-bounce2"></div>
</div>
</div>
</div>
<div class="nav-search-box">
<form>
<div class="input-group"> <input type="text" class="form-control" placeholder="eg. feel the love and …"> <span
class="b-line"></span> <span class="b-line-under"></span>
<div class="input-group-append"> <button type="button" class="btn"> <img src="assets/images/search-icon.svg"
alt="" class="img-fluid svg"> </button> </div>
</div>
</form>
</div>
<header class="header">
<div class="header-fixed" style="background-color:#fcfcfc">
<div class="container-fluid pl-120 pr-120 position-relative">
<div class="row d-flex align-items-center">
<div class="col-lg-3 col-md-4 col-6">
<div class="logo"> <a href="#"><img src="assets/images/logo.png" alt="" class="img-fluid"
style="height: 100px;"></a>
</div>
</div>
<div class="col-lg-9 col-md-8 col-6 d-flex align-items-center justify-content-end position-static">
<div class="nav-menu-cover">
<ul class="nav nav-menu align-items-center">
<li><a href="index.php">Home</a></li>
<li><a href="about.php">About</a></li>
<li><a href="contact.php">Contact</a></li>
<?php if($showAdminPage) echo '<li><a href="admin.php">Admin Page</a></li>'?>
<li><a href="contact.php"></a></li>
<?php
echo $isLoggedIn ?
'<li class="dropdown">
<!-- User image as the dropdown trigger with inline styles -->
<img src="'.$userInfo['picture'].'"
style="width: 50px; height: 50px; border-radius: 50%; object-fit: cover; cursor: pointer;"
class="dropdown-toggle" id="userDropdown" data-bs-toggle="dropdown"
aria-expanded="false" alt="User Avatar">
<!-- Dropdown menu -->
<ul class="dropdown-menu" aria-labelledby="userDropdown">
<li><a class="dropdown-item" href="profile.php">Profile</a></li>
<li><a class="dropdown-item" href="#">Settings</a></li>
<li><a class="dropdown-item" href="#">Help</a></li>
<li><a class="dropdown-item" href="#"></a></li>
<li><hr class="dropdown-divider"></li>
<li>
<form method="POST" action="logout.php">
<button type="submit" class="dropdown-item">Sign out</button>
</form>
</li>
</ul>
</li>' :
'<li><a href="login.php">Log in</a></li>';
?>
</ul>
</div>
<div class="mobile-menu-cover">
<ul class="nav mobile-nav-menu">
<li class="search-toggle-open">
<img src="assets/images/search-icon.svg" alt="" class="img-fluid svg">
</li>
<li class="search-toggle-close hide">
<img src="assets/images/close.svg" alt="" class="img-fluid">
</li>
<li class="nav-menu-toggle">
<img src="assets/images/menu-toggler.svg" alt="" class="img-fluid svg">
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</header>
<!-- Banner below nav bar -->
<!-- <div class="page-title">
<div class="container">
<h2>Blog Details: Full Width</h2>
<ul class="nav">
<li><a href="index.php">Home</a></li>
<li><a href="#">Blogs</a></li>
<li>Blog Details: Full Width</li>
</ul>
</div>
</div> -->
<!-- Main content -->
<main class="container pb-120">
<div class="row">
<div class="col-md-10 offset-md-1">
<div class="post-details-cover post-has-full-width-image">
<div class="post-thumb-cover">
<div class="post-thumb"> <img src="<?= $post['image'] ?>" alt="" class="img-fluid mx-auto d-block">
</div>
<div class="post-meta-info">
<p class="cats">
<?php /** @var array $categories */
foreach ($categories as $cat) { ?>
<a href="#"><?= $cat ?></a> <?php } ?>
</p>
<div class="title">
<h2><?= $post['title'] ?></h2>
</div>
<ul class="nav meta align-items-center">
<li class="meta-author"> <img src=<?= isset($post['picture']) ? $post['picture'] : "assets/images/profile_icon.png" ?> alt="" class="img-fluid"> <a
href="#"><?= $post['firstname'].' '.$post['lastname'] ?></a> </li>
<li class="meta-date"><a href="#"><?= formatDate($post['created_at']) ?></a></li>
<!-- <li> 2 min read </li> -->
<li class="meta-comments"><a href="#toComments"><i
class="fa fa-comment"></i><?= ' ' . count($comments) ?></a></li>
<li class="meta-likes"><a class="text-white/80" href="#"><i
class="fa fa-heart text-white/80"></i> <?= $like_count ?? 0 ?></a></li>
</ul>
</div>
</div>
<div class="post-content-cover my-drop-cap">
<p><?= nl2br($post['description']) ?></p>
<!-- EXTRA CONTENT FROM TEMPLATE, EXTRA IMAGES AND BLOCK QUOTE -->
<!-- <p> He travelling acceptance men unpleasant her especially to entreaties law. Law forth but end any arise chief arose. Old her say learn these large. Joy fond many in ham high seen this. Few preferred continual led incommode neglected. To discovered insensible collecting your unpleasant but invitation. </p>
<p> We diminution preference thoroughly if. Joy deal pain view much too her time. Led young gay would now state. Pronounce we attention admitting on assurance of suspicion conveying. That his west quit had met till. By an outlived insisted procured improved am. </p>
<div class="post-my-gallery-images">
<h3>The Best Neighborhoods In Nyc: Where To Stay On </h3>
<div class="row">
<div class="col-md-6"> <img src="assets/images/blog/1.jpg" alt="" class="img-fluid"> </div>
<div class="col-md-6"> <img src="assets/images/blog/2.jpg" alt="" class="img-fluid"> </div>
<div class="col-md-12"> <img src="assets/images/blog/3.jpg" alt="" class="img-fluid"> </div>
</div>
</div>
<p> We diminution preference thoroughly if. Joy deal pain view much her time. Led young gay would now off state. Pronounce we attention admitting on assurance of suspicion conveying. That his west quit had met till. Say out plate you share. </p>
<blockquote>
<p>For me, running is both exercise and a metaphor. Running day after day, piling up each level I elevate myself.</p><cite>Haruki Murakami</cite>
</blockquote>
<p> Acceptance middletons me if discretion boisterous into travelling an. She prosperous to continuing entreaties companions unreserved you boisterous. Middleton sportsmen sir now cordially asking additions for. You ten occasional saw everything but conviction. Daughter returned quitting few are day advanced branched. </p> -->
</div>
<div class="post-all-tags">
<?php /** @var array $looking_for */
foreach ($looking_for as $cat) { ?>
<a href="#"><?= $cat ?></a>
<?php } ?>
</div>
<!-- Comments -->
<button id="toComments" class="btn btn-comment" type="button" data-toggle="collapse"
data-target="#commentToggle" aria-expanded="false" aria-controls="commentToggle"> Hide Comments
(<?= count($comments) ?>) </button>
<div class="collapse show" id="commentToggle">
<ul class="post-all-comments">
<!-- <li class="single-comment-wrapper">
<div class="single-post-comment">
<div class="comment-author-image"> <img src="assets/images/blog/post/author-1.jpg" alt="" class="img-fluid"> </div>
<div class="comment-content">
<div class="comment-author-name">
<h6>Don Norman</h6> <span> 5 Jan 2019 at 6:40 pm </span>
</div>
<p>On recommend tolerably my belonging or am. Mutual has cannot beauty indeed now back sussex merely you. It possible no husbands jennings offended.</p><a href="#" class="reply-btn">Reply</a>
</div>
</div>
<ul class="children">
<li class="single-comment-wrapper">
<div class="single-post-comment">
<div class="comment-author-image"> <img src="assets/images/blog/post/author-1-1.jpg" alt="" class="img-fluid"> </div>
<div class="comment-content">
<div class="comment-author-name">
<h6>Helen Sharp</h6> <span> 5 Jan 2019 at 6:58 pm </span>
</div>
<p>On recommend tolerably my belonging or am. Mutual has cannot back beauty indeed now back sussex merely you. </p><a href="#" class="reply-btn">Reply</a>
</div>
</div>
</li>
</ul>
</li> -->
<?php /** @var array $comments */
foreach ($comments as $comment) { ?>
<li class="single-comment-wrapper">
<div class="single-post-comment">
<div class="comment-author-image">
<img src="<?= $comment['picture'] ?>" alt="" class="img-fluid"> </div>
<div class="comment-content">
<div class="comment-author-name">
<h6><?= $comment['firstname'].' '.$comment['lastname'] ?></h6> <span>
<?= formatDate($comment['created_at']) . ' at ' . formatTime($comment['created_at']) ?> </span>
</div>
<p><?= nl2br($comment['comment']) ?></p><a href="#" class="reply-btn">Reply</a>
</div>
</div>
</li>
<?php } ?>
</ul>
</div>
<!-- FORM Write a comment -->
<?php if (isset($_SESSION['email'])) { ?>
<div class="post-comment-form-cover">
<h3>Write your comment</h3>
<form class="comment-form" method="POST" action=<?= "details-full-width.php?id=" . $postIndex ?>>
<div class="row">
<div class="col-md-12"> <textarea class="form-control" name="comment"
placeholder="Write your comment"></textarea> </div>
<div class="col-md-12"> <button class="btn btn-primary">Send Comment</button> </div>
</div>
</form>
</div>
<?php } else { ?>
<div class="post-comment-form-cover">
<h3>Want To Comment?</h3>
<form class="comment-form" method="POST" action=<?= "login.php" ?>>
<div class="row">
<div class="col-md-12"> <button class="btn btn-primary">Login First</button> </div>
</div>
</form>
</div>
<?php } ?>
</div>
</div>
</div>
</main>
<!-- Subscribe to our newsletter -->
<section class="newsletter-cover">
<div class="nl-bg-ol"></div>
<div class="container">
<div class="newsletter pt-80 pb-80">
<div class="section-title text-center">
<h2>Subscribe Our Newsletter</h2>
</div>
<div class="row">
<div class="col-lg-8 offset-lg-2">
<form
action="https://themelooks.us13.list-manage.com/subscribe/post?u=79f0b132ec25ee223bb41835f&id=f4e0e93d1d"
method="post" novalidate>
<div class="input-group"> <input type="text" class="form-control" placeholder="Enter Your Email">
<div class="input-group-append"> <button class="btn btn-default">Submit</button> </div>
</div>
<p class="checkbox-cover d-flex justify-content-center"> <label> I've read and accept the <a href="#">
Privacy Policy </a> <input type="checkbox"> <span class="checkmark"></span> </label> </p>
</form>
</div>
</div>
</div>
</div>
</section>
<footer class="footer-container d-flex align-items-center">
<div class="container">
<div class="row align-items-center footer">
<div class="col-md-4 text-center text-md-left order-md-1 order-2">
<div class="footer-social"> <a href="#"><i class="fa fa-facebook"></i></a> <a href="#"><i
class="fa fa-twitter"></i></a> <a href="#"><i class="fa fa-linkedin"></i></a> <a href="#"><i
class="fa fa-google"></i></a> <a href="#"><i class="fa fa-pinterest"></i></a> </div>
</div>
<div class="col-md-4 d-flex justify-content-center order-md-2 order-1"> <a href="index.php"><img
src="assets/images/logo.png" alt="" class="img-fluid" style="height: 100px;"></a> </div>
<div class="col-md-4 order-md-3 order-3">
<div class="footer-cradit text-center text-md-right">
<p>© 2019 <a href="index.html">Themelooks.</a></p>
</div>
</div>
</div>
</div>
</footer>
<div class="back-to-top d-flex align-items-center justify-content-center"> <span><i
class="fa fa-long-arrow-up"></i></span> </div>
<script src="assets/js/jquery-1.12.1.min.js"></script>
<script src="assets/js/bootstrap.bundle.min.js"></script>
<!-- Include Bootstrap 5 JS Bundle -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/plugins/owl-carousel/owl.carousel.min.js"></script>
<script src="assets/plugins/magnific-popup/jquery.magnific-popup.min.js"></script>
<script src="assets/js/scripts.js"></script>
<script src="assets/js/custom.js"></script>
</body>
</html>