-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharticle-details.php
939 lines (769 loc) · 40.8 KB
/
article-details.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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
<?php
session_start();
if(isset($_SESSION['email'])) {
//session variables for default login
$id = $_SESSION['user'];
$user = $_SESSION['username'];
$lastname = $_SESSION['lastname'];
$firstname = $_SESSION['firstname'];
$fullname = $firstname." ".$lastname;
$email = $_SESSION['email'];
$profile_image = $_SESSION['profile_image'];
}
require 'dbconn.php';
$errorss = array();
$successs = array();
$errors = array();
$success = array();
//if suscribe button is clicked
if (isset($_POST['subscribe'])) {
$name = $_POST['name'];
$subscriber_email = $_POST['subscriber_email'];
$website = $_POST['website'];
$postingdate = date("Y-m-d H:i:s", time());
if ($name === "" || $subscriber_email === "") {
$errorss['pass'] = "the name and email field are both required";
}
$query = mysqli_query($conn, "SELECT email FROM subscribers WHERE email='$subscriber_email'");
if(mysqli_num_rows($query) > 0){
$errorss['pass'] = "Hi, you've already subscribed";
}else{
$sql = 'INSERT INTO subscribers(name, email, website, PostingDate) VALUES(:name, :email, :website, :postingdate)';
$statement = $connection->prepare($sql);
if ($statement->execute([':name' => $name, ':email' => $subscriber_email, ':website' => $website, ':postingdate' => $postingdate])) {
$successs['data'] = 'Subscribed successfully';
}else{
$errorss['data'] = 'Ooops, an error occured';
}
}
}
//code for comments
if (isset($_POST['leave_comment'])) {
$post_id = $_POST['post_id'];
// $name = $_POST['name'];
// $email = $_POST['email'];
$comments = $_POST['comment'];
$postingdate = date("Y-m-d H:i:s", time());
//check if user is logged in
if(!isset($_SESSION['email'])) {
header("Location: signup.php");
}
else{
//initialize the session
$id = $_SESSION['user'];
$name = $fullname;
$email = $_SESSION['email'];
$query = mysqli_query($conn, "SELECT post_id, email FROM tblcomments WHERE email='$email' AND post_id = $post_id");
if(mysqli_num_rows($query) > 0){
$errors['pass'] = "You have already made a comment for this post <a class='ml-3' href='index.php'>view post</a>";
}else{
$sql = 'INSERT INTO tblcomments(post_id, user_id, name, email, comments, PostingDate) VALUES(:post_id, :user_id, :name, :email, :comments, :postingdate)';
$statement = $connection->prepare($sql);
if ($statement->execute([':post_id' => $post_id, ':user_id' => $id, ':name' => $name, ':email' => $email, ':comments' => $comments, ':postingdate' => $postingdate])) {
$success['data'] = "commented successfully <a class='ml-3' href='index.php'>view post</a>";
//header("Location: article-details.php");
}else{
$errors['data'] = 'Ooops, an error occured';
}
}
}
}
if (isset($_POST['reply_comment'])) {
$comment_id = $_POST['comment_id'];
$post_id = $_POST['post_id'];
$user_id = $_POST['user_id'];
$name = $_POST['name'];
$email = $_POST['email'];
$commentbox = $_POST['commentbox'];
$replied_on = date("Y-m-d H:i:s", time());
//check if user is logged in
if(!isset($_SESSION['email'])) {
header("Location: signup.php");
}
else{
$query = mysqli_query($conn, "SELECT post_id, email FROM replies WHERE email='$email' AND post_id = $post_id AND comment_id = $comment_id");
if(mysqli_num_rows($query) > 0){
$errors['pass'] = "You have already made a reply for this comment <a class='ml-3' href='index.php'>view post</a>";
}else{
$reply = 'INSERT INTO replies(comment_id, post_id, user_id, name, email, reply_comment, replied_on) VALUES(:comment_id, :post_id, :user_id, :name, :email, :commentbox, :replied_on)';
$statement = $connection->prepare($reply);
if ($statement->execute([':comment_id' => $comment_id, ':post_id' => $post_id, ':user_id' => $user_id, ':name' => $name, ':email' => $email, ':commentbox' => $commentbox, ':replied_on' => $replied_on])) {
$success['data'] = "you've replied to the comment successfully <a class='ml-3' href='index.php'>view other post</a>";
//header("Location: article-details.php");
}else{
$errors['data'] = 'Ooops, an error occured';
}
}
}
}
$sql = 'SELECT * FROM affiliate WHERE Is_Active=1';
$statement = $connection->prepare($sql);
$statement->execute();
$affiliate = $statement->fetchAll(PDO::FETCH_ASSOC);
$sql = 'SELECT * FROM announcement WHERE Is_Active=1';
$statement = $connection->prepare($sql);
$statement->execute();
$announcement = $statement->fetchAll(PDO::FETCH_ASSOC);
function timeago($time, $tense='ago'){
static $periods = array('year', 'month', 'day', 'hour', 'minute', 'second');
if (!(strtotime($time)>0)) {
//return trigger_error("wrong time format: '$time'", E_USER_ERROR);
}
$now = new DateTime('now');
$time = new DateTime($time);
$diff = $now->diff($time)->format('%y %m %d %h %i %s');
$diff = explode(' ', $diff);
$diff = array_combine($periods, $diff);
$diff = array_filter($diff);
$period = key($diff);
$value = current($diff);
if (!$value) {
$period = '';
$tense = '';
$value = 'just now';
}else{
if ($period == 'day' && $value >= 7) {
$period = 'week';
$value = floor($value/7);
}if ($value > 1) {
$period .='s';
}
}
return "$value $period $tense";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>One meta home Page</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="ratings.css">
<script type="text/javascript">
function addBookmark(url, title){
if (!url) {url = window.location}
if (!title) {title = document.title}
var browser=navigator.userAgent.toLowerCase();
if (window.sidebar) { // Mozilla, Firefox, Netscape
window.sidebar.addPanel(title, url,"");
} else if( window.external) { // IE or chrome
if (browser.indexOf('chrome')==-1){ // ie
window.external.AddFavorite( url, title);
} else { // chrome
alert('Please Press CTRL+D (or Command+D for macs) to bookmark this page');
}
}
else if(window.opera && window.print) { // Opera - automatically adds to sidebar if rel=sidebar in the tag
return true;
}
else if (browser.indexOf('konqueror')!=-1) { // Konqueror
alert('Please press CTRL+B to bookmark this page.');
}
else if (browser.indexOf('webkit')!=-1){ // safari
alert('Please press CTRL+B (or Command+D for macs) to bookmark this page.');
} else {
alert('Your browser cannot add bookmarks using this link. Please add this link manually.')
}
}
</script>
</head>
<body>
<div class="container-fluid bg-warning">
<div class="row justify-content-center">
<?php foreach($affiliate as $aff): ?>
<a href="<?php echo $aff["link"]; ?>" target = "_blank" class="btn btn-dark btn-sm text-white mr-2 mt-2 mb-2" alt="<?php echo $aff["alt"]; ?>"><?php echo $aff["alt"]; ?></a>
<?php endforeach; ?>
</div>
</div>
<section class="w-100 shadow-sm bg-dark">
<div class="container-fluid">
<nav class="navbar navbar-expand-xl navbar-light text-white bg-transparent">
<a class="navbar-brand" href="index.php">
<img src="img/Logo.png" alt="logo" class="img-responsive" height="100" width="auto">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item line">
<a class="nav-link mr-1 text-white font-weight-bold active" href="index.php">Home</a>
</li>
<li class="nav-item line">
<a class="nav-link mr-1 text-white font-weight-bold" href="#">Trends</a>
</li>
<li class="nav-item line">
<a class="nav-link mr-1 text-white font-weight-bold" href="#">Articles & Updates</a>
</li>
<li class="nav-item line">
<a class="nav-link mr-1 text-white font-weight-bold" href="#">Top Ranks</a>
</li>
<li class="nav-item line">
<a class="nav-link mr-1 text-white font-weight-bold" href="#">Reviews & Ratings</a>
</li>
<li class="nav-item line">
<a class="nav-link mr-1 text-white font-weight-bold" href="#">Genre</a>
</li>
<li class="nav-item line">
<a class="nav-link mb-2 text-white font-weight-bold" href="#">Reports</a>
</li>
<li class="nav-item line">
<a class="nav-link mb-2 text-white font-weight-bold" href="#">Commentaries</a>
</li>
<?php
if(!isset($_SESSION['email'])) {
?>
<li class="nav-item line">
<a class="nav-link mb-2 text-white font-weight-bold" href="signin.php">Signin</a>
</li>
<li class="nav-item line">
<a class="nav-link mb-2 text-white font-weight-bold" href="signup.php">Sign Up</a>
</li>
<?php
}
?>
</ul>
<?php
if(isset($_SESSION['email'])) {
?>
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<label for="" class="text-white">Hi,
<?php
echo "$user";
?>
</label>
<?php
if(isset($_SESSION['email'])) {
echo '<img src="img/avatar.jpg" width="40" height="40" class="rounded-circle ml-2">';
}
?>
</a>
<div class="dropdown-menu bg-dark text-white" aria-labelledby="navbarDropdownMenuLink">
<?php
if ($_SESSION['role'] === "admin") {
?>
<a class="dropdown-item text-white bg-transparent" href="admin/index.php">My Account</a>
<?php
}else{
?>
<a class="dropdown-item text-white bg-transparent" href="user/index.php">My Account</a>
<?php
}
?>
<a class="dropdown-item text-white bg-transparent" href="logout.php">Log Out</a>
</div>
</li>
</ul>
<?php
}
?>
</div>
</nav>
</div>
</section>
<div class="container-fluid bg-light">
<div class="row justify-content-center">
<div class="col-lg-12">
<div class="ticker w-100">
<marquee class="news-content mt-3 mb-3">
<?php foreach($announcement as $ann): ?>
<p><?php echo $ann["announcement"]; ?></p>
<?php endforeach; ?>
</marquee>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="mt-5 mb-5">
<ol class="breadcrumb mb-4 d-block" style="margin-top: 50px;">
<li class="breadcrumb-item active">Article Details</li>
</ol>
</div>
<div class="row">
<div class="container w-75">
<?php if (count($errors) > 0): ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<?php foreach($errors as $erro): ?>
<li class="text-danger"><?php echo $erro; ?></li>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if (count($success) > 0): ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<?php foreach($success as $succe): ?>
<li class="text-success"><?php echo $succe; ?></li>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<div class="col-md-7">
<?php
if(isset($_POST['btn_edit'])) {
$id = $_POST['edit_id'];
$sql = 'SELECT * FROM article WHERE id=:id';
$statement = $connection->prepare($sql);
$statement->execute([':id' => $id ]);
$article = $statement->fetchAll(PDO::FETCH_OBJ);
foreach ($article as $art) {
$media = $art->image;
$temp = array();
$media=trim($media, '/,');
$temp = explode(',', $media);
$temp = array_filter($temp);
$images = array();
foreach($temp as $image){
$images[]="article_images/".trim( str_replace(array('[',']') ,"" ,$image ) );
}
?>
<div class="card mb-4">
<div class="card-body">
<h2 class="card-title"><b><?php echo $art->title;?></b></h2>
<p><b>Category : </b><?php echo htmlentities($art->category);?><br>
<small><p><b><a href="#"><?php echo date("F j, Y", strtotime($art->created_on)); ?></a>. Posted by <?php echo htmlentities($art->author);?></b> <button class="btn btn-sm btn-link" onclick="comment_view()">Comments (<?php $article_post_id = $art->id;$count=$connection->prepare("SELECT post_id FROM tblcomments WHERE post_id = $article_post_id");$count->execute();$comments=$count->rowCount();echo $comments; ?>)</button> <a href="#">Notify Me</a></p></small>
<fieldset class="border p-2">
<legend class="w-auto"><small>social share</small></legend>
<div class="row ml-5">
<?php
$file = $_SERVER['SCRIPT_FILENAME'] == 'share.php';
$article_id = $art->id;
$article_title = $art->title;
$site_url = "http://localhost/fiverr/oneupmeta/share.php?article_id=$article_id";
?>
<a href="https://www.facebook.com/sharer.php?u=<?=$site_url?>" target="_blank" title="share to facebook" class="btn btn-primary mr-2"><i class="fab fa-facebook-f"></i></a>
<a href="https://twitter.com/share?url=<?=$site_url?>&text=Simple%20Share%20Buttons&hashtags=simplesharebuttons" target="_blank" title="share to twitter" class="btn btn-info mr-2"><i class="fab fa-twitter"></i></a>
<input type="hidden" value="<?=$site_url?>" id="myInput">
<button title="copy link" class="btn btn-warning mr-2" title="Copy to clipboard" onclick="myFunction()"><i class="fa fa-link" ></i></button>
<a href="mailto:?Subject=<?=$site_url?>&Body=I%20saw%20this%20and%20thought%20of%20you!%20 <?=$site_url?>" target="_blank" title="share to email" class="btn btn-dark mr-2"><i class="fa fa-envelope"></i></a>
<a href="https://telegram.me/share/url?url=<?=$site_url?>" target="_blank" title="share to telegram" class="btn btn-info mr-2"><i class="fab fa-telegram"></i></a>
<a href="#" onclick="addBookmark('<?=$site_url?>', '<?=$article_title?>');" title="add to bookmarks" class="btn btn-default icon mr-2"><i class="fa fa-bookmark"></i></a>
</div>
</fieldset>
<hr />
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="<?php echo $images[0];?>" alt="Card image cap" style=" height: 50vh;">
</div>
<?php
if (sizeof($images) > 1) {
?>
<div class="carousel-item">
<img class="d-block w-100" src="<?php echo $images[1];?>" alt="Card image cap" style=" height: 50vh;">
</div>
<?php
}
?>
<?php
if (sizeof($images) > 2) {
?>
<div class="carousel-item">
<img class="d-block w-100" src="<?php echo $images[2];?>" alt="Card image cap" style=" height: 50vh;">
</div>
<?php
}
?>
</div>
</div>
<p class="card-text"><?php
echo $art->description;
?></p>
</div>
<div class="card-footer justify-content-between">
<a href="index.php">Back to Homepage</a>
<div class="star-rating float-right">
<p><small>rate this article below:</small></p>
<fieldset class="rating">
<input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label>
<input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label>
<input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label>
<input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label>
<input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label>
<input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label>
<input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label>
<input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label>
<input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label>
<input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label>
</fieldset>
</div>
</div>
</div>
<?php
}
}
?>
</div>
<div class="col-md-5">
<?php
if (!empty($article)) {
foreach ($article as $art) {
$comment_id = $art->id;
//var_dump($comment_id);
$qry = "SELECT * FROM tblcomments WHERE post_id = $comment_id";
$statement = $connection->prepare($qry);
$statement->execute();
$comments = $statement->fetchAll(PDO::FETCH_ASSOC);
//var_dump($comments);
}
?>
<p>
<a class="btn btn-outline-primary" id="comment_btn_view" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
View comments
</a>
</p>
<div class="collapse mb-5" id="collapseExample">
<div class="card card-body">
<?php foreach($comments as $comment): ?>
<div class="comment mb-2">
<div class="user"><i class="fa fa-user mr-3"></i><small class="font-weight-bold text-dark"><?php echo htmlentities($comment['name']);?></small> <span class="time ml-3 text-gray"><small><?php
//date_default_timezone_set('Africa/Lagos');
$time_posted = $comment['PostingDate'];
$time = date($time_posted); //now
$timeago = timeago($time);
echo $timeago; ?></small></span></div>
<div class="userComment ml-5 mt-2"><small class="text-dark"><?php echo htmlentities($comment['comments']);?></small></div>
<?php
$id_comment = $comment['id'];
// $query=mysqli_query($conn,"SELECT tblcomments.post_id as postid,replies.post_id as repliesPostId,replies.comment_id as rcomment_id from replies join tblcomments on replies.comment_id=tblcomments.id where replies.post_id=$id");
$qry = "SELECT tblcomments.post_id as postid,replies.name as rname,replies.replied_on as rdate,replies.reply_comment as rcomment,replies.post_id as repliesPostId,replies.comment_id as rcomment_id from replies join tblcomments on replies.comment_id=tblcomments.id where replies.post_id=$id AND tblcomments.id=$id_comment";
$statement = $connection->prepare($qry);
$statement->execute();
$replies = $statement->fetchAll(PDO::FETCH_ASSOC);
//var_dump($replies);
?>
<?php foreach($replies as $reply): ?>
<div class="reply mb-2 ml-5 mt-3">
<div class="user"><i class="fa fa-user mr-3"></i><small class="font-weight-bold text-dark"><?php echo htmlentities($reply['rname']);?></small><span class="ml-2"><small>replied</small></span> <span class="time ml-3 text-gray"><small><?php
//date_default_timezone_set('Africa/Lagos');
$time_posted = $reply['rdate'];
$time = date($time_posted); //now
$timeago = timeago($time);
echo $timeago; ?></small></span></div>
<div class="userComment ml-5 mt-2"><small class="text-dark"><?php echo htmlentities($reply['rcomment']);?></small></div>
</div>
<?php endforeach; ?>
<!-- reply comment begin -->
<a class="btn btn-outline-primary btn-sm ml-5 mt-2 mb-2" data-toggle="collapse" href="#collapse<?php echo htmlentities($comment['id']);?>" role="button" aria-expanded="false" aria-controls="collapseExampl">
reply
</a>
<div class="collapse mb-5" id="collapse<?php echo htmlentities($comment['id']);?>">
<div class="card">
<div class="card-body">
<form action="article-details.php" method="post">
<input type="hidden" name="comment_id" class="form-control form-control-sm" value="<?php echo htmlentities($comment['id']);?>">
<input type="hidden" name="post_id" class="form-control form-control-sm" value="<?php echo htmlentities($id);?>">
<input type="hidden" name="user_id" class="form-control form-control-sm" value="<?php echo htmlentities($_SESSION['user'] ?? ''); ?>">
<div class="form-group">
<input type="hidden" name="name" class="form-control" value="<?= $fullname ?? '' ?>">
</div>
<div class="form-group">
<input type="hidden" name="email" class="form-control" value="<?= $email ?? '' ?>">
</div>
<div class="form-group">
<textarea name="commentbox" class="form-control" placeholder="Your comment"></textarea>
</div>
<button class="btn btn-secondary" name="reply_comment" type="submit">Go!</button>
</form>
</div>
</div>
</div>
<!-- reply comment begin -->
</div>
<?php endforeach; ?>
<button onclick="commentFunction()" id="comment_button" class="btn btn-outline-primary btn-sm mt-5">Start Discussion</button>
</div>
</div>
<?php
}
?>
<?php
if(isset($_SESSION['email']) && !empty($article)) {
?>
<div class="card mb-4">
<h5 class="card-header">Leave a comment <?= $fullname ?? '' ?></h5>
<div class="card-body">
<form name="search" action="article-details.php" method="post">
<input type="hidden" name="post_id" value="<?= $id ?? '' ?>">
<div class="form-group">
<input type="hidden" name="name" class="form-control" value="<?= $fullname ?? '' ?>">
</div>
<div class="form-group">
<input type="hidden" name="email" class="form-control" value="<?= $email ?? '' ?>">
</div>
<div class="form-group">
<textarea name="comment" id="comment" class="form-control" placeholder="Your comment"></textarea>
</div>
<button class="btn btn-secondary" name="leave_comment" type="submit">Go!</button>
</form>
</div>
</div>
<?php
}else{
?>
<?php
if (!empty($article)) {
?>
<div class="card mb-4">
<h5 class="card-header">Leave a comment</h5>
<div class="card-body">
<form name="search" action="article-details.php" method="post">
<input type="hidden" name="post_id" value="<?= $id ?? '' ?>">
<div class="form-group">
<textarea name="comment" id="comment" class="form-control" placeholder="Your comment" required></textarea>
</div>
<button class="btn btn-secondary" name="leave_comment" type="submit">Go!</button>
</form>
</div>
</div>
<?php
}
?>
<?php
}
?>
<?php
if (!empty($article)) {
foreach ($article as $art) {
$id = $art->id;
$title = $art->title;
$category = $art->category;
$author = $art->author;
$description = $art->description;
$sql_related = 'SELECT * FROM article WHERE title LIKE :title OR author LIKE :author OR description LIKE :description OR category LIKE :category LIMIT 3';
$statement = $connection->prepare($sql_related);
$statement->execute(array(':title' => '%'.$title.'%', ':author' => '%'.$author.'%', ':description' => '%'.$description.'%', ':category' => '%'.$category.'%'));
$related_article = $statement->fetchAll(PDO::FETCH_OBJ);
?>
<div class="mt-5 mb-4 justify-content-center">
<p class="text-center">Related Articles</p>
<?php
foreach ($related_article as $rel){
if ($rel->id != $id) {
$media = $rel->image;
$temp = array();
$media=trim($media, '/,');
$temp = explode(',', $media);
$temp = array_filter($temp);
$images = array();
foreach($temp as $image){
$images[]="article_images/".trim( str_replace(array('[',']') ,"" ,$image ) );
}
//var_dump($rel->id);
?>
<div class="justify-content-center">
<div class="card mb-2 text-center" >
<!-- <div class="embed-responsive embed-responsive-4by3"> -->
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="<?php echo $images[0];?>" alt="Card image cap" style=" height: 30vh;">
</div>
<?php
if (sizeof($images) > 1) {
?>
<div class="carousel-item">
<img class="d-block w-100" src="<?php echo $images[1];?>" alt="Card image cap" style=" height: 30vh;">
</div>
<?php
}
?>
<?php
if (sizeof($images) > 2) {
?>
<div class="carousel-item">
<img class="d-block w-100" src="<?php echo $images[2];?>" alt="Card image cap" style=" height: 30vh;">
</div>
<?php
}
?>
</div>
</div>
<!-- </div> -->
<div class="card-body text-left">
<h5 class="card-title article"><b><?php echo $rel->title; ?></h5></b>
<p class="card-text"><small><b><?php echo $rel->catchy_phrase; ?>
<p class="card-text"><small><b>Posted by <?php echo $rel->author; ?>,
<?php
//date_default_timezone_set('Africa/Lagos');
$time_posted = $rel->created_on;
$time = date($time_posted); //now
$timeago = timeago($time);
echo $timeago;
?>
</b></small>
<div class="star-rating">
<span class="fa divya fa-star" data-rating="1" style="font-size:13px;"></span>
<span class="fa fa-star" data-rating="2" style="font-size:13px;"></span>
<span class="fa fa-star" data-rating="3" style="font-size:13px;"></span>
<span class="fa fa-star" data-rating="4" style="font-size:13px;"></span>
<span class="fa fa-star-half" data-rating="5" style="font-size:13px;"></span>
<span class="fa" style="font-size:13px;">4.9</span>
<input type="hidden" name="whatever3" class="rating-value" value="1">
</div>
<form action="article-details.php" method="post">
<input type="hidden" name="edit_id" value="<?php echo $rel->id; ?>">
<button type="hidden" name="btn_edit" class="btn btn-sm stretched-link"></button>
</form>
</div>
</div>
</div>
<?php
}
}
}
?>
<?php
}
?>
</div>
</div>
</div>
</div>
<div class="footer bg-dark">
<div class="container-fluid">
<div class="row justify-content-center">
<div class="col-lg-4 mt-5">
<a class="navbar-brand text-center" href="index.php">
<img src="img/Logo.png" alt="logo" class="img-responsive" height="100" width="auto">
</a>
<p class="text-white footer-text">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum delenit augue duis dolore te feugait. <a class="text-decoration-none" href="aboutus.php">Read More <i class="fas fa-long-arrow-alt-right"></i></a> </p>
</div>
<div class="col-lg-2 mt-5">
<h3 class="text-white mb-5 text-justify">Explore</h3>
<li class="mb-2 text-white text-justify ml-2"><a href="#" class="text-white">About Us</a></li>
<li class="mb-2 text-white text-justify ml-2"><a href="#" class="text-white">Events</a></li>
<li class="mb-2 text-white text-justify ml-2"><a href="#" class="text-white">Publications</a></li>
<li class="mb-2 text-white text-justify ml-2"><a href="#" class="text-white">Contact</a></li>
</div>
<div class="col-lg-2 mt-5">
<h3 class="text-white mb-5 text-justify">Activities</h3>
<li class="mb-2 text-white text-justify"><a href="" class="text-white">Press Releases</a></li>
<li class="mb-2 text-white text-justify"><a href="" class="text-white">Multimedia</a></li>
<li class="mb-2 text-white text-justify"><a href="" class="text-white">art</a></li>
<li class="mb-2 text-white text-justify"><a href="" class="text-white">LSA in the Media</a></li>
</div>
<div class="col-lg-4 mt-5">
<h3 class="text-white mb-5 text-justify">Subscribe</h3>
<?php if (count($errorss) > 0): ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<?php foreach($errorss as $error): ?>
<li class="text-danger"><?php echo $error; ?></li>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if (count($successs) > 0): ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<?php foreach($successs as $succes): ?>
<li class="text-success"><?php echo $succes; ?></li>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<?php endforeach; ?>
</div>
<?php endif; ?>
<form action="article-details.php" method="post">
<div class="form-group">
<input type="text" class="form-control form-control-sm" name="name" placeholder = "Your name" required value="<?= $fullname ?? '' ?>">
</div>
<div class="form-group">
<input type="email" class="form-control form-control-sm" name="subscriber_email" placeholder = "Your email" required value="<?= $email ?? '' ?>">
</div>
<div class="form-group">
<input type="text" class="form-control form-control-sm" name="website" placeholder = "Your website (Optional)">
</div>
<input type="submit" name="subscribe" class="btn btn-primary btn-sm mb-2" value = "subscribe">
</form>
<p class="text-justify text-white mt-2 mb-2">Get latest updates and offers.</p>
<hr class="bg-white">
<div class="row justify-content-center mt-4 mb-4 text-white">
<a href="" title="link to shop" class="btn btn-default border mr-2 icon"><i class="fas fa-store-alt"></i></a>
<a href="" class="btn btn-default border mr-2 icon"><i class="fab fa-facebook-f"></i></a>
<a href="" class="btn btn-default border mr-2 icon"><i class="fab fa-twitter"></i></a>
<a href="" class="btn btn-default border mr-2 icon"><i class="fab fa-tiktok"></i></a>
<a href="" class="btn btn-default border mr-2 icon"><i class="fab fa-instagram"></i></a>
<a href="" class="btn btn-default border icon"><i class="fab fa-youtube"></i></a>
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid bg-dark">
<div class="row justify-content-center">
<?php foreach($affiliate as $aff): ?>
<a href="<?php echo $aff["link"]; ?>" target = "_blank" class="btn bg-dark btn-sm text-white mr-2 mt-2 mb-2" alt="<?php echo $aff["alt"]; ?>"><?php echo $aff["alt"]; ?></a>
<?php endforeach; ?>
</div>
</div>
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
function commentFunction() {
// document.getElementById("name").focus();
document.getElementById("comment").focus();
}
</script>
<script>
(function() {
const idleDurationSecs = 1800;
const redirectUrl = 'logout.php';
let idleTimeout;
const resetIdleTimeout = function() {
if(idleTimeout) clearTimeout(idleTimeout);
idleTimeout = setTimeout(() => location.href = redirectUrl, idleDurationSecs * 1000);
};
// Key events for reset time
resetIdleTimeout();
window.onmousemove = resetIdleTimeout;
window.onkeypress = resetIdleTimeout;
window.click = resetIdleTimeout;
window.onclick = resetIdleTimeout;
window.touchstart = resetIdleTimeout;
window.onfocus = resetIdleTimeout;
window.onchange = resetIdleTimeout;
window.onmouseover = resetIdleTimeout;
window.onmouseout = resetIdleTimeout;
window.onmousemove = resetIdleTimeout;
window.onmousedown = resetIdleTimeout;
window.onmouseup = resetIdleTimeout;
window.onkeypress = resetIdleTimeout;
window.onkeydown = resetIdleTimeout;
window.onkeyup = resetIdleTimeout;
window.onsubmit = resetIdleTimeout;
window.onreset = resetIdleTimeout;
window.onselect = resetIdleTimeout;
window.onscroll = resetIdleTimeout;
})();
</script>
<script>
function myFunction() {
/* Get the text field */
var copyText = document.getElementById("myInput");
/* Copy the text inside the text field */
navigator.clipboard.writeText(copyText.value);
/* Alert the copied text */
// alert("Copied the text: " + copyText.value);
alert("Copied successfully!");
}
</script>
<script>
function comment_view() {
// document.getElementById("name").focus();
document.getElementById("comment_btn_view").click();
}
</script>
</body>
</html>