-
Notifications
You must be signed in to change notification settings - Fork 154
/
index.php
387 lines (310 loc) · 20.2 KB
/
index.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
<?php
session_start();
include_once 'includes/dbh.inc.php';
define('TITLE',"Dashboard| KLiK");
$companyName = "Franklin's Fine Dining";
function strip_bad_chars( $input ){
$output = preg_replace( "/[^a-zA-Z0-9_-]/", "", $input);
return $output;
}
if(!isset($_SESSION['userId']))
{
header("Location: login.php");
exit();
}
include 'includes/HTML-head.php';
?>
<link href="css/list-page.css" rel="stylesheet">
<link href="css/loader.css" rel="stylesheet">
</head>
<body onload="pageLoad()">
<div id="loader-wrapper">
<img src='img/500.png' id='loader-logo'>
<div class="loader">
<div class="loader__bar"></div>
<div class="loader__bar"></div>
<div class="loader__bar"></div>
<div class="loader__bar"></div>
<div class="loader__bar"></div>
<div class="loader__ball"></div>
</div>
</div>
<div id="content" style="display: none">
<?php include 'includes/navbar.php'; ?>
<div class="container-fluid">
<div class="row">
<div class="col-sm-3" >
<?php include 'includes/profile-card.php'; ?>
</div>
<div class="col-sm-7" >
<div class="text-center p-3">
<img src="img/200.png">
<h2 class='text-muted'>DASHBOARD</h2>
<br>
</div>
<ul class="nav nav-tabs justify-content-center" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="forum-tab" data-toggle="tab" href="#forum" role="tab"
aria-controls="forum" aria-selected="true">Recent Forums</a>
</li>
<li class="nav-item">
<a class="nav-link" id="blog-tab" data-toggle="tab" href="#blog" role="tab"
aria-controls="blog" aria-selected="false">Recent Blogs</a>
</li>
<li class="nav-item">
<a class="nav-link" id="poll-tab" data-toggle="tab" href="#poll" role="tab"
aria-controls="poll" aria-selected="false">Recent Polls</a>
</li>
<li class="nav-item">
<a class="nav-link" id="event-tab" data-toggle="tab" href="#event" role="tab"
aria-controls="event" aria-selected="false">Recent Events</a>
</li>
</ul>
<br>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="forum" role="tabpanel" aria-labelledby="forum-tab">
<div class="d-flex align-items-center p-3 my-3 text-white-50 bg-purple rounded shadow-sm">
<img class="mr-3" src="img/200.png" alt="" width="48" height="48">
<div class="lh-100">
<h1 class="mb-0 text-white lh-100">Latest Forums</h1>
</div>
</div>
<div class="row mb-2">
<?php
$sql = "select topic_id, topic_subject, topic_date, topic_cat, topic_by, userImg, idUsers, uidUsers, cat_name, (
select sum(post_votes)
from posts
where post_topic = topic_id
) as upvotes
from topics, users, categories
where topics.topic_by = users.idUsers
and topics.topic_cat = categories.cat_id
order by topic_id desc, upvotes asc
LIMIT 6";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql))
{
die('SQL error');
}
else
{
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_assoc($result))
{
echo '<div class="col-md-6">
<div class="card flex-md-row mb-4 shadow-sm h-md-250">
<a href="posts.php?topic='.$row['topic_id'].'">
<img class="card-img-left flex-auto d-none d-lg-block blogindex-cover"
src="img/forum-cover.png" alt="Card image cap">
</a>
<div class="card-body d-flex flex-column align-items-start">
<strong class="d-inline-block mb-2 text-primary text-center ml-auto">
<i class="fa fa-chevron-up" aria-hidden="true"></i><br>'.$row['upvotes'].'
</strong>
<h6 class="mb-0">
<a class="text-dark" href="posts.php?topic='.$row['topic_id'].'">'
.substr(ucwords($row['topic_subject']),0,15).'...</a>
</h6>
<small class="mb-1 text-muted">'.date("F jS, Y", strtotime($row['topic_date'])).'</small>
<small class="card-text mb-auto">Created By: '.ucwords($row['uidUsers']).'</small>
<a href="posts.php?topic='.$row['topic_id'].'">Go To Forum</a>
</div>
</div>
</div>';
}
}
?>
</div>
</div>
<div class="tab-pane fade" id="blog" role="blog" aria-labelledby="blog-tab">
<div class="d-flex align-items-center p-3 my-3 text-white-50 bg-purple rounded shadow-sm">
<img class="mr-3" src="img/200.png" alt="" width="48" height="48">
<div class="lh-100">
<h1 class="mb-0 text-white lh-100">Latest Blogs</h1>
</div>
</div>
<div class="row mb-2">
<?php
$sql = "select * from Blogs, users
where blogs.blog_by = users.idUsers
order by blog_id desc, blog_votes asc
LIMIT 6";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql))
{
die('SQL error');
}
else
{
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_assoc($result))
{
echo '<div class="col-md-6">
<div class="card flex-md-row mb-4 shadow-sm h-md-250">
<div class="card-body d-flex flex-column align-items-start">
<strong class="d-inline-block mb-2 text-primary">
<i class="fa fa-thumbs-up" aria-hidden="true"></i> '.$row['blog_votes'].'
</strong>
<h6 class="mb-0">
<a class="text-dark" href="blog-page.php?id='.$row['blog_id'].'">'.substr($row['blog_title'],0,10).'...</a>
</h6>
<small class="mb-1 text-muted">'.date("F jS, Y", strtotime($row['blog_date'])).'</small>
<small class="card-text mb-auto">'.substr($row['blog_content'],0,40).'...</small>
<a href="blog-page.php?id='.$row['blog_id'].'">Continue reading</a>
</div>
<a href="blog-page.php?id='.$row['blog_id'].'">
<img class="card-img-right flex-auto d-none d-lg-block blogindex-cover"
src="uploads/'.$row['blog_img'].'" alt="Card image cap">
</a>
</div>
</div>';
}
}
?>
</div>
</div>
<div class="tab-pane fade" id="poll" role="poll" aria-labelledby="poll-tab">
<div class="d-flex align-items-center p-3 my-3 text-white-50 bg-purple rounded shadow-sm">
<img class="mr-3" src="img/200.png" alt="" width="48" height="48">
<div class="lh-100">
<h1 class="mb-0 text-white lh-100">Latest Polls</h1>
</div>
</div>
<div class="my-3 p-3 bg-white rounded shadow-sm">
<?php
$sql = "select p.id, p.subject, p.created, p.poll_desc, p.locked, (
select count(*)
from poll_votes v
where v.poll_id = p.id
) as votes
from polls p
order by votes desc
LIMIT 5";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql))
{
die('SQL error');
}
else
{
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_assoc($result))
{
echo '<a href="poll.php?poll='.$row['id'].'">
<div class="media text-muted pt-3">
<img src="img/poll-cover.png" alt="" class="mr-2 rounded div-img poll-img">
<p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray ">
<strong class="d-block text-gray-dark">'.ucwords($row['subject']).'</strong></a>
'.date("F jS, Y", strtotime($row['created'])).'
<br><br>
<span class="text-primary" >
'.$row['votes'].' User(s) have voted
</span>
</p>
<span class="text-right">';
if($row['locked'] === 1)
{
echo '<br><b class="small text-muted">[Locked Poll]</b>';
}
else
{
echo '<br><b class="small text-success">[Open Poll]</b>';
}
echo '</span>
</div>';
}
}
?>
</div>
</div>
<div class="tab-pane fade" id="event" role="event" aria-labelledby="event-tab">
<div class="d-flex align-items-center p-3 my-3 text-white-50 bg-purple rounded shadow-sm">
<img class="mr-3" src="img/200.png" alt="" width="48" height="48">
<div class="lh-100">
<h1 class="mb-0 text-white lh-100">Upcoming Events</h1>
</div>
</div>
<div class="my-3 p-3 bg-white rounded shadow-sm">
<?php
$sql = "select event_id, event_by, title, event_date, event_image
from events
where event_date > now()
order by event_date asc
LIMIT 5";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql))
{
die('SQL error');
}
else
{
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_assoc($result))
{
$earlier = new DateTime(date("Y-m-d"));
$later = new DateTime($row['event_date']);
$diff = $later->diff($earlier)->format("%a");
echo '<a href="event-page.php?id='.$row['event_id'].'">
<div class="media text-muted pt-3">
<img src="uploads/'.$row['event_image'].'" alt="" class="mr-2 rounded div-img poll-img">
<p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray">
<strong class="d-block text-gray-dark">'.ucwords($row['title']).'</strong></a>
'.date("F jS, Y", strtotime($row['event_date'])).'<br><br>
<span class="text-primary" >'.$diff.' days remaining </span>
</p>
<span class="text-primary text-right">';
if ($_SESSION['userLevel'] == 1 || $_SESSION['userId'] == $row['event_by'])
{
echo '<a href="includes/delete-event.php?id='.$row['event_id'].'&page=forum" >
<i class="fa fa-trash" aria-hidden="true" style="color: red;"></i>
</a>
</span>';
}
else
{
echo '</span>';
}
echo '</span>
</div>';
}
}
?>
</div>
</div>
</div>
</div>
<div class="col-sm-2">
<div class="text-center p-3 mt-5">
<a href="team.php" target="_blank">
<i class="creater-icon fa fa-users fa-5x" aria-hidden="true"></i>
</a>
<p><br>THE CREATORS</p>
</div>
<a href="forum.php" class="btn btn-warning btn-lg btn-block">KLiK Forum</a>
<a href="hub.php" class="btn btn-secondary btn-lg btn-block">KLiK Hub</a>
<br><br><br>
<a href="create-topic.php" class="btn btn-warning btn-lg btn-block">Create a Forum</a>
<a href="create-blog.php" class="btn btn-secondary btn-lg btn-block">Create a Blog</a>
</div>
</div>
</div>
<?php include 'includes/footer.php'; ?>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js" ></script>
<script>
var myVar;
function pageLoad() {
myVar = setTimeout(showPage, 4000);
}
function showPage() {
document.getElementById("loader-wrapper").style.display = "none";
document.getElementById("content").style.display = "block";
}
</script>
</body>
</html>