-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlogadmin.php
228 lines (188 loc) · 5.54 KB
/
Blogadmin.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
<?php require_once("connection.php");?>
<style>
.img_cont{
position: relative;
height: 70px;
width: 70px;
}
.fa {
font-size: 25px;
cursor: pointer;
user-select: none;
}
</style>
<div class="container-fluid"><!--container-->
<div class="col-sm-1"></div>
<div class="row">
<div class="col-sm-8"><!--Main blog area-->
<script>
/*function like(id)
{
window.location.href="Bloglike.php?id="+id;
}*/
function like(id){
$.ajax({
url:"../Bloglike.php",
method:"POST",
data:{like:1,postid:id},
success :function (data){
$(".badge1").html(data);
//alert(data);
}
})
}
function dislike(id){
$.ajax({
url:"../Blogdislike.php",
method:"POST",
data:{dislike:1,postid:id},
success :function (data){
//$(".badge2").html(data);
//alert(data);
}
})
}
/*function dislike(id)
{
window.location.href="Blogdislike.php?id="+id;
}*/
</script>
<?php
if(isset($_GET["category"])){
$category=$_GET["category"];
$Viewquery="select * from adminpanel where category='$category' order by id desc";
}
//The Default Query for Blog.php page page
else{
$Viewquery="select * from adminpanel order by id desc";
}
$execute=mysqli_query($conn,$Viewquery);
while($datarows=mysqli_fetch_array($execute)){
$postid=$datarows["id"];
$datetime=$datarows["datetime"];
$title=$datarows["title"];
$category=$datarows["category"];
$author=$datarows["author"];
$image=$datarows["image"];
$post=$datarows["post"];
?>
<div class = "blogpost img-thumbnail">
<?php
$imageFileType = strtolower(pathinfo($image,PATHINFO_EXTENSION));
if($imageFileType == "mp4")
{
echo"<video width='400' height='400' alt='video'>
<source src='../Upload/".$image."' type='video/webm'>
</video><div id='heading'> <b>Go to Read More To Play video</b></div>";
}
else{
?>
<img class="img-thumbnail img-responsive img-rounded" src="../Upload/<?php echo $image;?>">
<?php } ?>
<div class="caption">
<h1 id="heading">
<a href="javascript:like('<?php echo $postid; ?>')">
<i class="fa fa-thumbs-up" aria-hidden="true"></i><span class="badge">
<!--<div class="badge1"></div>-->
<?php
$q=mysqli_query($conn,"select * from likepage where postid='$postid' and likeno=1");
$r=mysqli_num_rows($q);
echo "$r";
?>
</span></a>
<a href="javascript:dislike('<?php echo $postid; ?>')">
<i class="fa fa-thumbs-down" aria-hidden="true"></i><span class="badge">
<?php
$q=mysqli_query($conn,"select * from likepage where postid='$postid' and dislikeno=1");
$r=mysqli_num_rows($q);
echo "$r";
?>
</span></a>
<?php echo htmlentities($title); ?></h1>
<p class="description">Category:<?php echo htmlentities($category) ?> published on:<?php echo htmlentities($datetime) ?>
<?php
$queryapproved="select count(*) from comments where adminpanel_id='$postid' and status='ON'";
$executeapproved=mysqli_query($conn,$queryapproved);
$rowapproved=mysqli_fetch_array($executeapproved);
$TotalApproved=array_shift($rowapproved);
if($TotalApproved>0){
?>
<button type="button" class="btn badge btn-sm float-sm-right responsive-width">
Comments:<?php echo $TotalApproved;?>
</button>
<?php } ?>
</p>
<p class="post"><?php
if(strlen($post)>150)
{
$post=substr($post,0,150).'...';
}
echo $post ?></p>
</div>
<?php echo "<Td>
<a target='_blank' href='index.php?page=fullpostadmin&post_id=".$postid."'><span class='btn btn-primary'>Read More »</span>
</a></td>"; ?>
</div>
<br><br>
<?php }?>
</div> <!--Main blog area ending-->
<div class="col-sm-offset-1 col-sm-3"><!--side area-->
<div class="panel panel-primary">
<div class="panel-heading">
<h2 class="panel-title">Categories</h2>
</div>
<div class="panel-body">
<?php
$Viewquery="select * from category order by id desc";
$execute=mysqli_query($conn,$Viewquery);
while($datarows=mysqli_fetch_array($execute)){
$id=$datarows["id"];
$category=$datarows["name"];
?>
<a href="index.php?page=Blog&category=<?php echo $category ?>">
<span style="margin-left:15px;" id="heading"><?php echo $category."<br>"; ?></span></a>
<hr>
<?php } ?>
</div>
</div>
<br><br>
<div class="panel panel-primary">
<div class="panel-heading">
<h2 class="panel-title">Recent Posts</h2>
</div>
<div class="panel-body">
<?php
$Viewquery="select * from adminpanel order by id desc limit 0,5";
$execute=mysqli_query($conn,$Viewquery);
while($datarows=mysqli_fetch_array($execute)){
$id=$datarows["id"];
$category=$datarows["title"];
$datetime=$datarows["datetime"];
$image=$datarows["image"];
if(strlen($datetime)>11){$datetime=substr($datetime,0,11);}
?>
<div>
<img class="pull-left" style="margin-top:10px; margin-left:6px; position: relative;height: 70px; width: 70px; border-radius: 50%;" class="img-responsive img-thumbnail" src="../Upload/<?php echo $image; ?>" >
<a href="index.php?page=fullpostadmin&post_id=<?php echo $id ?>">
<p id="heading"><?php echo htmlentities($category); ?></p></a>
<p class="description"><?php echo htmlentities($datetime);?></p>
</div>
<br><hr style="margin-top:1px;">
<?php } ?>
</div>
</div>
</div>
<div class="col-sm-1"></div>
<!--side area Ending-->
</div><!--Row ending-->
</div><!--container ending-->
<script>
function goBack() {
window.history.back();
}
</script>
<script>
if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}
</script>