-
Notifications
You must be signed in to change notification settings - Fork 3
/
BlogDetail.php
268 lines (232 loc) · 9.38 KB
/
BlogDetail.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
<!-- Fahimul Hoque Shubho -->
<?php
//include_once('simple_html_dom.php');
session_start(); //initializing session
//connecting to database
$con=mysqli_connect("localhost","digibd_docket","docket","digibd_docket");
//$con=mysqli_connect("localhost","root","","docket");
if($con===false)
{
echo '<script type= "text/javascript"> alert ("Database Could not connect")</script>';
}
session_start();
$loggedIn = $_SESSION['loggedIn']; //getting the login status
//Redirecting to login page if user not logged in
if($loggedIn != 1)
{
echo '<script type="text/javascript"> alert ("Please sign in first")</script>';
echo "<script> location.href='SignIn.php'; </script>";
}
// user logged in
else
{
$userID = $_SESSION['userID']; //getting user id from session to retrive additional info from database
//unset($_SESSION['db']); // clearing the session varble
//$_SESSION['db'] = $db;
$blogId = $_GET['blogId']; // receving the blog id to show details
?>
<!DOCTYPE html>
<!-- metadata and external resources -->
<head>
<title>Blog Detail</title>
<link rel='icon' href='favicon.png' type='image/x-icon'/>
<link rel="stylesheet" href='http://fonts.googleapis.com/css?family=Dosis:400,700,500|Nunito:300,400,600' />
<link rel="stylesheet" href="css/plugins.css">
<link rel="stylesheet" href="css/style_sana.css">
</head>
<body>
<div id="preloader">
<img class="logo" src="images/logo_1.png" alt="Center" >
<div id="status">
<span></span>
<span></span>
</div>
</div>
<!-- navigation bar -->
<header class="ht-header">
<div class="container">
<nav class="navbar navbar-default navbar-custom">
<div class="navbar-header logo">
<div class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only"></span>
<div id="nav-icon1">
<span></span>
<span></span>
<span></span>
</div>
</div>
<a href="UserProfile.html"><img class="logo" src="images/logo_1.png" alt="" width="150" height="60"></a>
</div>
<div class="collapse navbar-collapse flex-parent" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav flex-child-menu menu-left">
<li class="dropdown first">
<a href="movie.html"><h4>movies</h4></a>
</li>
<li class="dropdown first">
<a href="TvSeries.php" ><h4>Tv-Series</h4></a>
</li>
<li class="dropdown first">
<a href="Anime.php"><h4>Anime</h4></a>
</li>
<li class="dropdown first">
<a href="Books.php" ><h4>books</h4></a>
</li>
<li class="dropdown first">
<a href="blogList.php"> <h4>Blogs</h4></a>
</li>
<li class="dropdown first">
<a href="games.html"> <h4>games</h4></a>
</li>
</ul>
<ul class="nav navbar-nav flex-child-menu menu-right">
<li><a href="search.php"><img class="logo" src="images/search.png" alt="" width="50" height="50"></a></li>
<div class="" title="Go to Profile">
<li><a href="UserProfile.php"><img class="logo" src="images/user_1.png" alt="" width="78" height=""></a></li>
</div>
</ul>
</div>
</nav>
</header>
<!-- headline -->
<div class="hero user-heroBlog">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="hero-ct">
<img class="logo" src="images/blogs_1.png" alt="" width="50" height="">
<h1>Blog Detail</h1>
</div>
</div>
</div>
</div>
</div>
<div class="buster-light">
<div class="page-single">
<div class="container">
<div class="row ipad-width2">
<?php
$db="Blogs";
//$userID = 15;
// fetching similiar blogs from user's list
$sql = "SELECT * FROM {$db} WHERE uniqueId='$blogId' ";
$query= mysqli_query($con,$sql);
if(mysqli_num_rows($query) > 0 )
{
$info= mysqli_fetch_array($query);
$authorId= $info['authorId'];
$name = $info['authorName'];
$title = $info['blogTitle'];
$poster = $info['poster'];
$content = $info['blogText'];
$blogDate = $info['blogDate'];
}
?>
<div class="col-md-4 col-sm-12 col-xs-12">
<div class="">
<img class="book-single" src=<?php echo $poster ?> alt="">
</div>
</div>
<div class="col-md-8 col-sm-12 col-xs-12">
<div class="movie-single-ct main-content">
<h1><?php echo $title ?><br></h1>
<div><br><a classs="light-text">by</a><b> <a href=<?php echo "updateScript/userProfileRedirect.php?profileId=$authorId" ?> ><?php echo $name ?></a></b>
<!-- <span class="time"> <?php //echo date('d-m-Y', strtotime($blogDate)) ?></span> -->
<!-- formatting date -->
<span class="time"> <?php echo date('d', strtotime($blogDate)).' '.date('F', strtotime($blogDate)).' '.date('Y', strtotime($blogDate)) ?></span>
</div>
<br>
<p><?php echo $content ?></p>
</div>
</div>
<script>
// script to preventing form resubmission in case of page reload
if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}
</script>
<div class="blog-detail-ct">
<div class="comment-form">
<h4></h4>
<form method="post" action="#">
<div class="row">
<div class="col-md-12">
<textarea name="comment" id="" placeholder="Write a Comment..."></textarea>
</div>
</div>
<input class="submit" type="submit" name="button" placeholder="submit">
</form>
</div>
<?php
if(isset($_POST['button'])){
$comment=$_POST['comment']; // get the comment
$userName = $_SESSION['userName'];
//$userName = 'Fahimul Hoque';
$userPic = $_SESSION['userPic'];
//$userPic = 'images/user.png';
//echo $comment;
//inserting into database
$query = "INSERT INTO BlogComment (blogId, authorId, authorName, authorPic, content, cDate) values ('".$blogId."','".$userID."','".$userName."','".$userPic."','".$comment."',now() )";
if(mysqli_query($con,$query)){
// Do nothing. Reload the page.
}
else
{
echo '<script type= "text/javascript"> alert ("Failed to register comment")</script>'; // error message
}
}
?>
<div class="comments">
<?php
//retriving comments from database
$sql = "SELECT * FROM BlogComment WHERE blogId = '$blogId' ";
$query= mysqli_query($con,$sql);
if(mysqli_num_rows($query) > 0 )
{
$count=mysqli_num_rows($query);
$id = array();
$cName = array();
$cPic = array();
$cCommnet = array();
$cDate = array();
// storing the comment info in arrays from database
while($temp = mysqli_fetch_array($query))
{
$id[] = $temp['authorId'];
$cName[] = $temp['authorName'];
$cPic[] = $temp['authorPic'];
$cComment[] = $temp['content'];
$cDate[] = $temp['cDate'];
}
// loop to display the comments
for($i=0; $i < $count; $i++)
{
?>
<div class="cmt-item flex-it">
<img src="<?php echo $cPic[$i] ?>" alt="" width="50">
<div class="author-infor" >
<div class="flex-it2">
<h6><a href="<?php echo "updateScript/userProfileRedirect.php?profileId=$id[$i]" ?>"><?php echo $cName[$i] ?></a></h6>
<span class="time"> - <?php echo date('d', strtotime($cDate[$i])).' '.date('F', strtotime($cDate[$i])).' '.date('Y', strtotime($cDate[$i])) ?></span>
</div>
<p><?php echo $cComment[$i] ?></p>
</div>
</div>
<?php
} //end of loop
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="js/jquery.js"></script>
<script src="js/plugins.js"></script>
<script src="js/plugins2.js"></script>
<script src="js/custom.js"></script>
</body>
</html>
<?php
}
?>