-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle-blog.php
More file actions
437 lines (381 loc) · 23.4 KB
/
single-blog.php
File metadata and controls
437 lines (381 loc) · 23.4 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
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
426
427
428
429
430
431
432
433
434
435
436
437
<?php if (!isset($_GET['e-blog'])) {
header("location: index.php");
exit;
} ?>
<?php
session_start();
include('includes/config.php');
//Genrating CSRF Token
if (empty($_SESSION['token'])) {
$_SESSION['token'] = bin2hex(random_bytes(32));
}
if (isset($_SESSION['comment'])) {
$_POST['comment'] = $_SESSION['comment'];
unset($_SESSION['comment']);
}
if (isset($_POST['comment'])) {
$_SESSION['comment'] = $_POST['comment'];
$_SESSION['cid'] = $_REQUEST['e-blog'];
if (!isset($_SESSION['user-login'])) {
$_SESSION['msg'] = "You must log in first";
header('location: users/index.php');
} else {
$username = $_SESSION['user-login'];
$user_check_query = "SELECT * FROM tblusers WHERE username='$username' LIMIT 1";
$res = mysqli_query($con, $user_check_query);
$user = mysqli_fetch_assoc($res);
$userid = $user['id'];
//Verifying CSRF Token
if (!empty($_POST['csrftoken'])) {
if (hash_equals($_SESSION['token'], $_POST['csrftoken'])) {
$comment = $_POST['comment'];
$postid = intval($_GET['e-blog']);
$st1 = '0';
$query = mysqli_query($con, "insert into tblcomments(postId,userid,comment,status) values('$postid','$userid','$comment','$st1')");
if ($query) :
echo "<script>alert('comment successfully submit. Comment will be display after admin review ');</script>";
unset($_SESSION['token']);
else :
echo "<script>alert('Something went wrong. Please try again.');</script>";
endif;
}
}
}
}
?>
<?php //code to get the item using its id
$url = $_REQUEST['e-blog'];
$query = "select tblposts.id, tblposts.likes, tblposts.PostTitle as posttitle,tblposts.PostImage,tblcategory.CategoryName as category,tblcategory.id as cid,tblsubcategory.Subcategory as subcategory,tblsubcategory.SubCategoryId as sid,tblposts.PostDetails as postdetails,tblposts.PostingDate as postingdate,tblposts.PostUrl as url from tblposts left join tblcategory on tblcategory.id=tblposts.CategoryId left join tblsubcategory on tblsubcategory.SubCategoryId=tblposts.SubCategoryId where tblposts.PostUrl='$url'";
$result = mysqli_query($con, $query) or die(((is_object($con)) ? mysqli_error($con) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : true)));
$row = mysqli_fetch_assoc($result);
$id = $row['id'];
$res = $db_handle->runQuery($query);
if (!isset($_SESSION['recent_posts'][$id])) { mysqli_query($con,"UPDATE `tblposts` SET `views` = `views` + 1 WHERE `id`= $id"); $_SESSION['recent_posts'][$id] = 1; } ?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include('includes/tag/blog-tag.php'); ?>
<!-- Title -->
<title>Explicit9ja.com | Blog Detail</title>
<!-- Favicon -->
<link rel="icon" href="../img/core-img/favicon.ico">
<!-- Stylesheet -->
<link rel="stylesheet" href="style.css">
<link href="like/like.css" rel='stylesheet' type='text/css' />
</head>
<body>
<?php include('includes/share/blog-share.php') ?>
<?php include('includes/header.php'); ?>
<!--update database on page views-->
<!--?php require_once('includes/conn.php');
require_once('libs/functions.php');
$pn = updateCounter('' . htmlentities($row['posttitle'] . '')); // Updates page hits
echo $pn;
//updateInfo(); // Updates hit info
?>
<!-- News Details Post Thumbnail Area Start -->
<section class="blog-details-post-thumbnail-area bg-overlay bg-img jarallax"
style="background-image: url(admin/postimages/<?php echo htmlentities($row['PostImage']); ?>); margin:0,10px,0,0;">
<div class="container h-100">
<div class="row h-100 align-items-center">
<div class="col-12">
<div class="post-title-text">
<h2><?php echo htmlentities($row['posttitle']); ?></h2>
<div class="post-meta">
<a href="#"><?php echo str_replace(" ", " ... ", $row['postingdate']); ?></a>
<a href="#">Post by ADMIN</a>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- News Details Post Thumbnail Area End -->
<!-- Blog Details Area Start -->
<section class="blog-details-area section-padding-80">
<div class="container">
<!-- Post Details Text -->
<div class="post-details-text">
<div class="row justify-content-center">
<div class="col-10 col-md-10 col-lg-9">
<?php echo $row['postdetails']; ?>
<!-- Post Catagories -->
<div class="d-flex align-items-center justify-content-between">
<!-- Post Catagories -->
<div class="post-catagories">
<ul class="d-flex flex-wrap align-items-center">
<li><i class="fa fa-tag"></i> Tag: </li>
<li><a
href="tagline-postc.php?tag=<?php echo htmlentities($row['cid']) ?>"><?php echo htmlentities($row['category']); ?></a>
</li>
<li><a
href="tagline-posts.php?tag=<?php echo htmlentities($row['sid']) ?>"><?php echo htmlentities($row['subcategory']); ?></a>
</li>
<li><div>
<?php
if(!empty($res)) {
$ip_address = $_SERVER['REMOTE_ADDR'];
?>
<div id="tutorial-<?php echo $res["id"]; ?>">
<input type="hidden" id="likes-<?php echo $res["id"]; ?>" value="<?php echo $res["likes"]; ?>">
<?php
$query ="SELECT * FROM tblpost_likes_map WHERE post_id = '" . $res["id"] . "' and ip_address = '" . $ip_address . "'";
$count = $db_handle->numRows($query);
$page = "blog";
$str_like = "like";
if(!empty($count)) {
$str_like = "unlike";
}
?>
<div class="btn-likes" style="float:left;"><input type="button" title="<?php echo ucwords($str_like); ?>" class="<?php echo $str_like; ?> " onClick="addLikes(<?php echo $res["id"]; ?>,'<?php echo $str_like; ?>', '<?php echo $page; ?>')" /></div>
<div class="label-likes" style="float:right; margin-top:3px;"><?php if(!empty($res["likes"])) { echo $res["likes"] . " Like(s)"; } else{echo "No Likes on this post yet";} ?></div>
</div>
<?php } ?>
</div>
</li>
</ul>
</div>
</div>
<!-- Post Share -->
<div class="social-btns">
<h4 class="h">Share this post:</h4>
<a href="<?php echo socialshare('facebook', $params); ?>" target="blank" class="social-margin">
<div class="social-icon facebook-icon">
<i class="fa fa-facebook" aria-hidden="true"></i>
</div>
</a>
<a href="<?php echo socialshare('pinterest', $params); ?>" target="blank" class="social-margin">
<div class="social-icon pinterest-icon">
<i class="fa fa-pinterest" aria-hidden="true"></i>
</div>
</a>
<a href="<?php echo socialshare('linkedin', $params); ?>" class="social-margin" target="blank">
<div class="social-icon linkedin-icon">
<i class="fa fa-linkedin" aria-hidden="true"></i>
</div>
</a>
<a href="<?php echo socialshare('whatsapp', $params); ?>" target="blank" class="social-margin">
<div class="social-icon whatsapp-icon">
<i class="fa fa-whatsapp" aria-hidden="true"></i>
</div>
</a>
<a href="<?php echo socialshare('tumblr', $params); ?>" target="blank" class="social-margin">
<div class="social-icon tumblr-icon">
<i class="fa fa-tumblr" aria-hidden="true"></i>
</div>
</a>
<a href="<?php echo socialshare('telegram', $params); ?>" target="blank" class="social-margin">
<div class="social-icon telegram-icon">
<i class="fa fa-telegram" aria-hidden="true"></i>
</div>
</a>
<a href="<?php echo socialshare('skype', $params); ?>" target="blank" class="social-margin">
<div class="social-icon skype-icon">
<i class="fa fa-skype" aria-hidden="true"></i>
</div>
</a>
<a href="<?php echo socialshare('twitter', $params); ?>" target="blank" class="social-margin">
<div class="social-icon twitter-icon">
<i class="fa fa-twitter" aria-hidden="true"></i>
</div>
</a>
</div>
<!--post share end-->
<!-- Comments Area -->
<div class="comment_area mb-50 clearfix">
<h5 class="title">
<?php $sts = 1;
$result = mysqli_query($con, "select * from tblcomments where postId='$id' and status='$sts'");
$total_rows = mysqli_num_rows($result);
if ($total_rows == 0) {
echo 'No Comments on this post yet';
} else if ($total_rows == 1) {
echo $total_rows . ' Comment';
} else {
echo $total_rows . ' Comments';
} ?>
</h5>
<ol>
<!-- Single Comment Area -->
<?php
if (isset($_SESSION['user-login'])) {
$username = $_SESSION['user-login'];
$user_check_query = "SELECT * FROM tblusers WHERE username='$username' LIMIT 1";
$res = mysqli_query($con, $user_check_query);
$user = mysqli_fetch_array($res);
$userid = $user['id'];
echo $userid;
}
?>
<?php
$sts = 1;
$query = mysqli_query($con, "select id,postId,userid,comment,postingDate from tblcomments where postId='$id' and status='$sts'");
while ($row = mysqli_fetch_array($query)) {
$userid = $row['userid'];
$user_check_query = "SELECT * FROM tblusers WHERE id='$userid'";
$res = mysqli_query($con, $user_check_query);
$user = mysqli_fetch_array($res);
$name = $user['username'];
$email = $user['email'];
$com_id = $row['id'];
$type = -1;
// Checking user status
$status_query = "SELECT count(*) as cntStatus,type FROM tblcomment_likes WHERE userid=" . $userid . " and commentid=" . $com_id;
$status_result = mysqli_query($con, $status_query);
$status_row = mysqli_fetch_array($status_result);
$count_status = $status_row['cntStatus'];
if ($count_status > 0) {
$type = $status_row['type'];
}
// Count post total likes and unlikes
$like_query = "SELECT COUNT(*) AS cntLikes FROM tblcomment_likes WHERE type=1 and commentid=" . $com_id;
$like_result = mysqli_query($con, $like_query);
$like_row = mysqli_fetch_array($like_result);
$total_likes = $like_row['cntLikes'];
$unlike_query = "SELECT COUNT(*) AS cntUnlikes FROM tblcomment_likes WHERE type=0 and commentid=" . $com_id;
$unlike_result = mysqli_query($con, $unlike_query);
$unlike_row = mysqli_fetch_array($unlike_result);
$total_unlikes = $unlike_row['cntUnlikes'];
?>
<li class="single_comment_area">
<!-- Comment Content -->
<div class="comment-content d-flex">
<!-- Comment Author -->
<div class="comment-author">
<img src="img/bg-img/15.jpg" alt="author">
</div>
<!-- Comment Meta -->
<div class="comment-meta">
<a href="#"
class="author-name"><?php $result = mysqli_query($con, "select * from tblusers where id='$userid'");
$user = mysqli_fetch_array($result);
echo htmlentities($user['username']); ?>
<span class="post-date"> #
<?php echo htmlentities($row['postingDate']); ?></span></a>
<p><?php echo htmlentities($row['comment']); ?> </p>
<input type="button" value="Like" id="like_<?php echo $com_id; ?>"
class="like"
style="<?php if ($type == 1) {
echo "color: #dc2878;";
} ?>" /><b> (<span
id="likes_<?php echo $com_id; ?>"><?php echo $total_likes; ?></span>) </b>
<input type="button" value="Unlike" id="unlike_<?php echo $com_id; ?>"
class="unlike"
style="<?php if ($type == 0) {
echo "color: #dc2878;";
} ?>" /><b> (<span
id="unlikes_<?php echo $com_id; ?>"><?php echo $total_unlikes; ?></span>)
</b>
</div>
</div>
<!--<ol class="children">
<li class="single_comment_area"> -->
<!-- Comment Content -->
<!-- <div class="comment-content d-flex"> -->
<!-- Comment Author -->
<!-- <div class="comment-author">
<img src="img/bg-img/16.jpg" alt="author">
</div> -->
<!-- Comment Meta -->
<!--<div class="comment-meta">
<a href="#" class="author-name">Milley Cyrus <span class="post-date">- May 20, 2018</span></a>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>
<a href="#" class="like">Like</a>
<a href="#" class="reply">Reply</a>
</div>
</div>
</li>
</ol> -->
</li>
<?php } ?>
</ol>
</div>
<!-- Leave A Reply -->
<div class="razo-contact-form">
<h2 class="mb-4">Leave A Comment</h2>
<!-- Form -->
<form name="Comment" method="post">
<input type="hidden" name="csrftoken"
value="<?php echo htmlentities($_SESSION['token']); ?>" />
<div class="row">
<div class="col-lg-6">
<input type="text" name="name" class="form-control mb-30"
placeholder="Full Name" required>
</div>
<div class="col-lg-6">
<input type="email" name="email" class="form-control mb-30"
placeholder="Valid Email" required>
</div>
<div class="col-12">
<textarea name="comment" class="form-control mb-30" placeholder="Comment"
required></textarea>
</div>
<div class="col-12">
<button type="submit" name="comment-submit"
class="btn razo-btn btn-3 mt-15">Post Comment</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Blog Details Area End -->
<!-- Related News Area Start -->
<div class="related-news-area">
<div class="container">
<div class="row">
<!-- Section Heading -->
<div class="col-12">
<div class="section-heading text-center">
<h2>RELATED STORIES</h2>
</div>
</div>
</div>
<!-- Blog Post -->
<div class="row">
<?php
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
$no_of_records_per_page = 8;
$offset = ($pageno-1) * $no_of_records_per_page;
$total_pages_sql = "SELECT COUNT(*) FROM tblposts";
$result = mysqli_query($con,$total_pages_sql);
$total_rows = mysqli_fetch_array($result, MYSQLI_NUM)[0];
$total_pages = ceil($total_rows / $no_of_records_per_page);
require_once('libs/functions.php');
$query=mysqli_query($con,"select tblposts.id as pid,tblposts.PostTitle as posttitle,tblposts.PostImage,tblcategory.CategoryName as category,tblcategory.id as cid,tblsubcategory.Subcategory as subcategory,tblposts.PostDetails as postdetails,tblposts.PostingDate as postingdate,tblposts.PostUrl as url from tblposts left join tblcategory on tblcategory.id=tblposts.CategoryId left join tblsubcategory on tblsubcategory.SubCategoryId=tblposts.SubCategoryId where tblposts.Is_Active=1 order by tblposts.id desc LIMIT $offset, $no_of_records_per_page");
while ($row=mysqli_fetch_array($query, MYSQLI_ASSOC)) {
?>
<!-- Single Blog Item -->
<div class="col-12 col-sm-6 col-lg-4 razo-blog-masonary-item mb-80">
<div class="razo-blog-masonary-single-item">
<!-- Post Thumbnail -->
<div class="post-thumbnail">
<a href="single-blog.php?e-blog=<?php echo htmlentities($row['url'])?>"><img src="admin/postimages/<?php echo htmlentities($row['PostImage']);?>" alt=""></a>
</div>
<!-- Post Content -->
<div class="post-content">
<div class="post-date"><i class="fa fa-calendar" aria-hidden="true"></i>
<?php echo htmlentities($row['postingdate']);?>
</div>
<a href="single-blog.php?e-blog=<?php echo htmlentities($row['url'])?>" class="post-title"><?php echo htmlentities($row['posttitle']);?></a>
<p><?php $pt=$row['postdetails']; echo (substr($pt,0,200));?><b>...</b></p>
<a href="single-blog.php?e-blog=<?php echo htmlentities($row['url'])?>" class="btn read-more-btn">Read More <i class="fa fa-angle-double-right" aria-hidden="true"></i></a>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
<!-- Related News Area End -->
<?php include('includes/footer.php'); ?>
</body>
</html>