-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathadmin.php
executable file
·488 lines (406 loc) · 16.8 KB
/
admin.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
<?php
session_start();
if (isset($_POST['submit'])){
$username= $_POST['username'];
$password=$_POST['password'];
if(($username == "secy" && $password == "GYMKHANA@secy_2020")){
$_SESSION['username']='secy';
}
else if(($username == "vp" && $password == "GYMvp_2020")){
$_SESSION['username']='vp';
}
else if(($username == "facad" && $password == "facad@GYMKHANA_2020")){
$_SESSION['username']='facad';
}
// else if(($username == "facad_sports" && $password == "facad@GYMKHANA_2020")){
// $_SESSION['username']='facadsports';
// }
// else if(($username == "facad_cult" && $password == "facad@GYMKHANA_2020")){
// $_SESSION['username']='facadcult';
// }
else {
header('Location:adminlogin.php');
}
}
if (!$_SESSION['username']){
header('Location:adminlogin.php');
}
include 'config.php';
if(isset($_POST['insert'])){
try {
$conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO happenings (name, society, date, month, status)
VALUES ('".$_POST['name']."', '".$_POST['society']."', '".$_POST['date']."', '".$_POST['month']."', 'forwarded to vp')";
// use exec() because no results are returned
$conn->exec($sql);
echo "<script>alert('New record created successfully');</script>";
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>Students' Gymkhana, IIT Bhubaneswar</title>
<!-- Favicons -->
<link rel="shortcut icon" href="assets/img/logo.png">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,700,700i|Montserrat:300,400,500,700" rel="stylesheet">
<!-- Vendor CSS Files -->
<link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/vendor/icofont/icofont.min.css" rel="stylesheet">
<link href="assets/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link href="assets/vendor/ionicons/css/ionicons.min.css" rel="stylesheet">
<link href="assets/vendor/animate.css/animate.min.css" rel="stylesheet">
<link href="assets/vendor/venobox/venobox.css" rel="stylesheet">
<link href="assets/vendor/owl.carousel/assets/owl.carousel.min.css" rel="stylesheet">
<link href="assets/vendor/aos/aos.css" rel="stylesheet">
<!-- Template Main CSS File -->
<link href="assets/css/style.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="assets/css/team.css">
</head>
<body>
<!-- ======= Header ======= -->
<header id="header" class="fixed-top header-transparent">
<div class="container-fluid">
<div class="row justify-content-center">
<div class="col-xl-11 d-flex align-items-center">
<a href="https://iitbbs.ac.in/" style="border-left:0px; padding-right:14px;" class="logo"><img src="assets/img/logo.png" class="img-fluid"></a>
<a href="index.html" class="logo mr-auto"><img src="assets/img/SGLogo1.png" alt="" class="img-fluid"></a>
<nav class="nav-menu d-none d-lg-block">
<ul>
<li class="active"><a href="index.php">Home</a></li>
<li><a href="facilities.php">Facilities</a></li>
<li class="drop-down"><a href="#">Councils</a>
<ul>
<li><a href="technical.php">Technical council</a></li>
<li><a href="cultural.php">Socio-Cultural Council</a></li>
<li><a href="sports.php">Sports Council</a></li>
</ul>
</li>
<li><a href="fests.php">Fests</a></li>
<li class="drop-down"><a href="#">Meets</a>
<ul>
<li><a href="sportsmeet.php">Inter IIT Sports Meet</a></li>
<li><a href="techmeet.php">Inter IIT Tech Meet</a></li>
<li><a href="gc.php">General Championship</a></li>
<!-- <li><a href="ic.php">Innovation Challenge</a></li> -->
</ul>
</li>
<li><a href="office.php">Office</a></li>
<li><a href="assets/Constitution.pdf">Constitution</a></li>
<li><a href="contact.php">Contact Us</a></li>
</ul>
</nav><!-- .nav-menu -->
</div>
</div>
</div>
</header><!-- End Header -->
<!-- ======= Intro Section ======= -->
<section class="team">
<div class="container" id="title">
<p class="h3">ADMIN</p>
</div>
<?php
if ($_SESSION['username']== 'secy'){
?>
<div class="container align-self-center">
<form method="POST" action="">
<div clas="form-group row">
<label for="mail" class="col-sm-3 form-control-label">Name of the event</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="name" required>
</div>
</div><br>
<div class="input-group mb-3">
<select class="custom-select" name="society" id="inputGroupSelect02">
<option selected>Choose...</option>
<option value="neuromancers">Neuromancers</option>
<option value="nakshatra">Nakshatra</option>
<option value="risc">Risc</option>
<option value="webd">Web and Design</option>
<option value="aaroh">Aaroh</option>
<option value="clix">Clix</option>
<option value="cinewave">Cinewave</option>
<option value="dgang">Dgang</option>
<option value="dramatics">Drams</option>
<option value="kalakriti">Kalakriti</option>
<option value="panacea">Panacea</option>
<option value="quizclub">Quiz Club</option>
<option value="s4s">Souls For solace</option>
</select>
<div class="input-group-append">
<label class="input-group-text" for="inputGroupSelect02">Society</label>
</div>
</div><br>
<div clas="form-group row">
<label for="password" class="col-sm-3 form-control-label">Dates</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="date" required>
</div>
</div><br>
<div clas="form-group row">
<label for="password" class="col-sm-3 form-control-label">Month</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="month" required>
</div>
</div><br>
<div class="form-group row">
<div class="col-sm-3 offset-sm-2">
<button type="submit" class="btn btn-primary" name="insert">Submit</button>
</div>
</div>
</form>
</div>
<?php } ?>
<?php
if ($_SESSION['username']== 'vp'){
?>
<div class="container">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Name Of the Event</th>
<th scope="col">Society</th>
<th scope="col">Date</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<?php
try {
$conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM happenings WHERE status = 'forwarded to vp'");
$stmt->execute();
$i = 1;
while ($row = $stmt->fetch()) {
echo " <tr>
<th scope='row'>".$i."</th>
<td>".$row['name']."</td>
<td>".$row['society']."</td>
<td>".$row['date'].$row['month']."</td>
<td><form method = 'post'> <input type='submit' class='btn btn-success' value='Forward to FacAd' name='vpapprove_".$row['id']."' > <input type='submit' class='btn btn-danger' value='Deny' name='vpdeny_".$row['id']."' ></form></td>
</tr>";
$var = "vpapprove_".$row['id']."";
if(isset($_POST[$var])){
try {
$conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "UPDATE happenings SET status='forwarded to facad' WHERE id='".$row['id']."'";
// use exec() because no results are returned
$conn->exec($sql);
header("Refresh:2");
echo "<script>alert('Post approved');</script>";
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
}
$vd = "vpdeny_".$row['id']."";
if(isset($_POST[$vd])){
try {
$conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "DELETE FROM happenings WHERE id='".$row['id']."'";
// use exec() because no results are returned
$conn->exec($sql);
echo "<script>alert('Post deleted');</script>";
header("Refresh:2");
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
}
}
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
?>
</tbody>
</table>
</div>
<?php } ?>
<?php
if ($_SESSION['username']== 'facad'){
?>
<div class="container">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Name Of the Event</th>
<th scope="col">Society</th>
<th scope="col">Date</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<?php
try {
$conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM happenings WHERE status = 'forwarded to facad'");
$stmt->execute();
$i = 1;
while ($row = $stmt->fetch()) {
echo " <tr>
<th scope='row'>".$i."</th>
<td>".$row['name']."</td>
<td>".$row['society']."</td>
<td>".$row['date'].$row['month']."</td>
<td><form method = 'post'> <input type='submit' class='btn btn-success' value='Approve' name='facapprove_".$row['id']."' > <input type='submit' class='btn btn-danger' value='Deny' name='deny_".$row['id']."' ></form></td>
</tr>";
$far = "facapprove_".$row['id']."";
if(isset($_POST[$far])){
try {
$conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "UPDATE happenings SET status='approved' WHERE id='".$row['id']."'";
// use exec() because no results are returned
$conn->exec($sql);
echo "<script>alert('Post approved');</script>";
header("Refresh:2");
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
}
$fd = "deny_".$row['id']."";
if(isset($_POST[$fd])){
try {
$conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "DELETE FROM happenings WHERE id='".$row['id']."'";
// use exec() because no results are returned
$conn->exec($sql);
echo "<script>alert('Post deleted');</script>";
header("Refresh:2");
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
}
}
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
?>
</tbody>
</table>
</div>
<?php } ?>
</section>
<?php
if ($_SESSION['username']== 'vp'){
?>
<section class="team">
<div class="container" id="title">
<p class="h3">CONTACT FORM</p>
</div>
<div class="container align-self-center">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Name</th>
<th scope="col">Contact</th>
<th scope="col">Email</th>
<th scope="col">Feedback</th>
<th scope="col">TimeStamp</th>
</tr>
</thead>
<tbody>
<?php
try {
$conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM contact");
$stmt->execute();
$i = 1;
while ($row = $stmt->fetch()) {
echo " <tr>
<th scope='row'>".$i."</th>
<td>".$row['name']."</td>
<td>".$row['contact']."</td>
<td>".$row['email']."</td>
<td>".$row['feedback']."</td>
<td>".$row['created_at']."</td>
</tr>
";
}
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
?>
</tbody>
</table>
</div>
</section>
<?php } ?>
<!-- ======= Footer ======= -->
<footer id="footer">
<div class="footer-top">
<div class="container">
<div class="row">
<div class="col-lg-4 col-md-6 footer-links">
<h4>Useful Links</h4>
<ul>
<li><i class="ion-ios-arrow-right"></i> <a href="#">IIT Bhubaneswar</a></li>
<li><i class="ion-ios-arrow-right"></i> <a href="#">Gymkhana Constitution</a></li>
<li><i class="ion-ios-arrow-right"></i> <a href="#">Career Development Cell</a></li>
</ul>
</div>
<div class="col-lg-4 col-md-6 footer-contact">
<h4>Contact Us</h4>
<p>
IIT Bhubaneswar<br>
At Arugul, Jatani<br>
Khordha, Odisha - 752050<br>
</p>
</div>
<div class="col-lg-4 col-md-6 footer-newsletter">
<h4>Connect with us</h4>
<div class="social-links">
<a href="https://www.facebook.com/SG.IITBhubaneswar/" class="facebook"><i class="fa fa-facebook"></i></a>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="copyright">
Developed by Web and Design Society, IIT Bhubaneswar
</div>
</div>
</footer><!-- End Footer -->
<a href="#" class="back-to-top"><i class="fa fa-chevron-up"></i></a>
<!-- Uncomment below i you want to use a preloader -->
<!-- <div id="preloader"></div> -->
<!-- Vendor JS Files -->
<script src="assets/vendor/jquery/jquery.min.js"></script>
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/vendor/jquery.easing/jquery.easing.min.js"></script>
<script src="assets/vendor/php-email-form/validate.js"></script>
<script src="assets/vendor/waypoints/jquery.waypoints.min.js"></script>
<script src="assets/vendor/counterup/counterup.min.js"></script>
<script src="assets/vendor/isotope-layout/isotope.pkgd.min.js"></script>
<script src="assets/vendor/venobox/venobox.min.js"></script>
<script src="assets/vendor/owl.carousel/owl.carousel.min.js"></script>
<script src="assets/vendor/aos/aos.js"></script>
<!-- Template Main JS File -->
<script src="assets/js/main.js"></script>
</body>
</html>