-
Notifications
You must be signed in to change notification settings - Fork 4
/
FullPost.php
368 lines (337 loc) · 16.6 KB
/
FullPost.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
<?php require_once("Includes/DB.php"); ?>
<?php require_once("Includes/Functions.php"); ?>
<?php require_once("Includes/Sessions.php"); ?>
<?php $SearchQueryParameter = $_GET["id"];?>
<?php
//setting connection of name submit
if(isset($_POST["Submit"])) {
$Name = $_POST["CommenterName"];
$Email = $_POST["CommenterEmail"];
$Comment = $_POST["CommenterThoughts"];
date_default_timezone_set("Asia/Kolkata");
$CurrentTime = time();
$DateTime = strftime("%B-%d-%Y %H: %M: %S", $CurrentTime);
if (empty($Name)||empty($Email)||empty($Comment)){
$_SESSION["ErrorMessage"] = "All fields must be filled out";
Redirect_to("FullPost.php?id=$SearchQueryParameter");
} elseif (strlen($Comment)>500) {
$_SESSION["ErrorMessage"] = "comment length should be less than 500 character";
Redirect_to("FullPost.php?id=$SearchQueryParameter");
} else{
//Query to insert comment in database when everything is good
global $ConnectingDB;
$sql = "INSERT INTO comments(datetime,name,email,comment,approvedby,status,post_id)VALUES(:datetime,:name ,:email,:comment,'Pending','OFF',:postIdFromURL)";
$stmt = $ConnectingDB->prepare($sql);
//binding the values
$stmt->bindValue(':datetime', $DateTime);
$stmt->bindValue(':name', $Name);
$stmt->bindValue(':email', $Email);
$stmt->bindValue(':comment', $Comment);
$stmt->bindValue(':postIdFromURL', $SearchQueryParameter);
$Execute = $stmt->execute();
if ($Execute) {
$_SESSION["SuccessMessage"] = "Comment submitted Successfully";
Redirect_to("FullPost.php?id=$SearchQueryParameter");
} else {
$_SESSION["ErrorMessage"] = "something went wrong... Try Again !";
Redirect_to("FullPost.php?id=$SearchQueryParameter");
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://kit.fontawesome.com/7f6ee3d237.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />
<link rel="stylesheet" href="css/FullPost.css">
<link rel="stylesheet" href="css/main.css">
<title>Full Post</title>
</head>
<body>
<!--NAVIGATION BAR STARTS-->
<div class="navbar navbar-expand-lg navbar-dark bg-custom cst">
<div class="container-fluid">
<a href="#" class="navbar-brand " style= "color:aliceblue; font-family: mindsagacustom;">MindSaga</a>
<button class="navbar-toggler custom-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#NavbarContent" aria-controls="NavbarContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<!-- CONTENT WHEN NAVBAR IS COLLAPSE-->
<div class="collapse navbar-collapse" id="NavbarContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a href="index.php" class="nav-link active" style= "color:white ; font-weight: bolder; ">Home</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link " style= "color:white ; font-weight: bolder; ">About Us</a>
</li>
<li class="nav-item">
<a href="index.php" class="nav-link " style= "color:white ; font-weight: bolder; ">Blog</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link" style= "color:white ; font-weight: bolder; ">Features</a>
</li>
<li class="nav-item">
<a href="Login.php" class="nav-link " style= "color:white ; font-weight: bolder; " >Log In</a>
</li>
</ul>
<ul class="navbar-nav ml-auto">
<form class="form-inline d-none d-sm-block" action="index.php">
<div class="form-group">
<input class="form-control mr-2" type="text" name="Search" placeholder="Search here" value="">
<button class="btn btn-primary" name="SearchButton">Go</button>
</div>
</form>
</ul>
</div>
</div>
</div>
<!--HEADER STARTS-->
<div class="user-info" style="font-family: 'Times New Roman';font-weight: bold;" data-aos = "fade-right">
WEBWIZ
<br>
<br>
The official Medium <br>
of WEBWIZ. <br>Learn more:
<br>
https://webwiz.xyz
<br>
<br>
<button type="button" class="btn btn-success">Follow</button>
<!-- left sidebar ends -->
<!-- comment sidebar starts... -->
<div class="sidenav" id="mySidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">
×
</a>
<section>
<div class="container">
<div class="row">
<div class="">
<h1>Comments</h1>
<?php
global $ConnectingDB;
$sql ="SELECT * FROM comments WHERE post_id='$SearchQueryParameter' AND status='ON'";
$stmt =$ConnectingDB->query($sql);
while ($DataRows = $stmt->fetch()){
$CommentDate = $DataRows['datetime'];
$CommenterName = $DataRows['name'];
$CommentContent = $DataRows['comment'];
?>
<div class="comment mt-4 text-justify float-left"> <img src="images/comment.png" alt="" class="rounded-circle" width="40" height="40">
<h4><?php echo $CommenterName; ?></h4> <span>- <?php echo $CommentDate; ?></span> <br>
<p>
<?php echo $CommentContent; ?>
</p>
</div>
<hr>
<?php } ?>
</div>
<!--ends of fetching commenting parts-->
<div class="">
<form class="" id="algin-form" action="FullPost.php?id=<?php echo $SearchQueryParameter ?>" method="post">
<div class="form-group">
<h4>Leave a comment</h4>
<label for="message">Message</label>
<textarea name="CommenterThoughts" id="" cols="30" rows="5" class="form-control" style="background-color: white;">
</textarea>
</div>
<div class="form-group">
<label for="name">Name</label>
<input type="text" name="CommenterName" id="" class="form-control" placeholder="want your name">
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="text" name="CommenterEmail" placeholder="want your Email" id="email" class="form-control">
</div>
<div class="form-group">
<button type="submit" name="Submit" class="btn btn-success" style="margin: 1rem 0 1rem 0;">Post Comment</button>
</div>
</form>
</div>
</div>
</div>
</section>
</div>
<a href="javascript:void(0)"><i class="fa fa-comment comt" aria-hidden="true" onclick="openNav()"></i></a>
</div>
<div class="container">
<div class="row justify-content-md-center">
<!--main area starts---->
<div class="col-md-6 align-self-center">
<?php
echo ErrorMessage();
echo SuccessMessage();
?>
<!-- when search button is active-->
<?php
global $ConnectingDB;
if(isset($_GET["SearchButton"])){
$Search = $_GET["Search"];
$sql="SELECT * FROM posts
WHERE datetime LIKE :Search
OR title LIKE :Search
OR category LIKE :Search
OR post LIKE :Search";
$stmt = $ConnectingDB->prepare($sql);
$stmt->bindvalue(':Search','%'.$Search.'%');
$stmt->execute();
}
// default query
else{
$PostIdFromURL = $_GET["id"];
if(!isset($PostIdFromURL)){
$_SESSION["ErrorMessage"]="Bad Request !";
Redirect_to("index.php");
}
$sql = "SELECT * FROM posts WHERE id= '$PostIdFromURL'";
$stmt = $ConnectingDB->query($sql);
}
while ($DataRows = $stmt->fetch()){
$PostId = $DataRows["id"];
$DateTime = $DataRows["datetime"];
$PostTitle = $DataRows["title"];
$Category = $DataRows["category"];
$Admin = $DataRows["author"];
$Image = $DataRows["image"];
$PostDescription = $DataRows["post"];
//
$Image2 = $DataRows["image2"];
$PostDescription2 = $DataRows["post2"];
//
$Image3 = $DataRows["image3"];
$PostDescription3 = $DataRows["post3"];
?>
<h1 class="phoenix" style="margin-left:-1.50rem;
font-family: fell, Georgia, Cambria, 'Times New Roman', Times, serif;
padding: 2rem; font-size: 48px ; letter-spacing: -0.011em;">
<?php echo htmlentities($PostTitle)?>
<br>
</h1>
<article class="blog-post">
<!--author description-->
<img alt="Sean Kernan" class="cimg" src="images/comment.png" style="width:40px; height:40px; margin-right:3px;">
<p class="blog-post-meta">
<h5 style="padding-top: 0.64rem; font-size:1rem">
<a style="color:rgba(26, 137, 23, 1);" href="Profile.php?username=<?php echo htmlentities($Admin); ?>"><?php echo htmlentities($Admin);?></a>
on <?php echo htmlentities($DateTime); ?>
</h5>
<br>
</p>
<p>
<h5 style=" font-family: sohne, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size:22px; color:rgba(117, 117, 117, 1);font-weight: 400;">This blog post shows a few different types of content that’s supported and styled with
Bootstrap. Basic typography, images, and code are all supported.
</h5>
</p>
<img src="Uploads/<?php echo htmlentities($Image); ?>" alt="" class="responsive">
<hr>
<p>
<?php echo nl2br($PostDescription) ?>
</p>
<img src="Uploads/<?php echo htmlentities($Image2); ?>" alt="" class="responsive">
<hr>
<p>
<?php echo nl2br($PostDescription2) ?>
</p>
<img src="Uploads/<?php echo htmlentities($Image3); ?>" alt="" class="responsive">
<hr>
<p>
<?php echo nl2br($PostDescription3) ?>
</p>
</article>
<div class="card-body">
<?php
global $ConnectingDB;
$sql = "SELECT *FROM category ORDER BY id desc";
$stmt = $ConnectingDB->query($sql);
while ($DataRows = $stmt->fetch()){
$categoryId = $DataRows["id"];
$CategoryName=$DataRows["title"];
?>
<a href="index.php?category=<?php echo $CategoryName; ?>">
<span class="badge" style="padding: 0.65rem; margin-bottom: 1rem; background-color:#f2f2f2; color:#757575; font-size: 13px; font-weight: 400; float: none;">
<?php echo $CategoryName; ?>
</span>
</a>
<?php }?>
</div>
</div>
<?php } ?>
<br>
<br>
<!--starting of comment part.-->
<!--fetching existing comments from database-->
<section class="mobile-comt">
<div class="container2">
<div class="row">
<div class="">
<h1>Comments</h1>
<?php
global $ConnectingDB;
$sql ="SELECT * FROM comments WHERE post_id='$SearchQueryParameter' AND status='ON'";
$stmt =$ConnectingDB->query($sql);
while ($DataRows = $stmt->fetch()){
$CommentDate = $DataRows['datetime'];
$CommenterName = $DataRows['name'];
$CommentContent = $DataRows['comment'];
?>
<div class="comment mt-4 text-justify float-left"> <img src="images/comment.png" alt="" class="rounded-circle" width="40" height="40">
<h4><?php echo $CommenterName; ?></h4> <span>- <?php echo $CommentDate; ?></span> <br>
<p>
<?php echo $CommentContent; ?>
</p>
</div>
<hr>
<?php } ?>
</div>
<!--ends of fetching commenting parts-->
<div class="">
<form id="algin-form" class=""action="FullPost.php?id=<?php echo $SearchQueryParameter ?>" method="post">
<div class="form-group">
<h4>Leave a comment</h4>
<label for="message">Message</label>
<textarea name="CommenterThoughts" id="" msg resize="none" class="form-control" style="background-color: white;">
</textarea>
</div>
<div class="form-group">
<label for="name">Name</label>
<input type="text" name="CommenterName" id="fullname" class="form-control" placeholder="want your name">
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="text" name="CommenterEmail" placeholder="want your Email" id="email" class="form-control">
</div>
<div class="form-group">
<button type="submit" name="Submit" class="btn btn-success" style="padding: 1rem;">Post Comment</button>
</div>
</form>
</div>
</div>
</div>
</section>
</div>
</div>
<script src="https://unpkg.com/aos@next/dist/aos.js"></script>
<script>
AOS.init({
offset: 500,
duration: 1000,
});
const openNav = () => {
document.getElementById('mySidenav').style.width="20rem";
}
const closeNav = () => {
document.getElementById('mySidenav').style.width="0";
}
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0"
crossorigin="anonymous"></script>
</body>
</html>