-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_panel.php
executable file
·43 lines (36 loc) · 1.49 KB
/
admin_panel.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
<?php
require_once('./includes/admin_redirect.inc.php');
require_once('./includes/connection.inc.php');
$successfulReset = false;
$unsuccessfulReset = false;
if (isset($_POST["reset"])) {
$conn = dbConnect("write");
$sql = "TRUNCATE TABLE attempts;";
$sql .= "TRUNCATE TABLE login_logout;";
$sql .= "TRUNCATE TABLE valid_emails;";
$sql .= "DELETE FROM users WHERE user_id <> 314 AND user_id <> 316;";
// even if tables do not exist, MySQL will not see this as an error
// it will just move on but the expected results will not be seen
if ($conn->multi_query($sql)) {
$successfulReset = true;
}
else {
$unsuccessfulReset = true;
}
}
$title = "Administrator Panel | NEO";
require_once("./includes/template_begin.inc.php");
?>
<?php if ($successfulReset) echo "Successful reset"; ?>
<?php if ($unsuccessfulReset) echo "There was an error in the end-of-year reset"; ?>
<p>
<form method="post" onsubmit="return confirm('Are you sure you want to do this? This cannot be undone.');" action="">
<label>Use this option to add valid emails to the NEO system:</label><br>
<a href="add_valid_email.php" class="btn btn-default">Add Valid Emails</a><br><br>
<label for="reset">This will reset all accounts, except for yours. Only do this at the end of each school year:</label>
<button type="submit" name="reset" id="reset" class="btn btn-danger">End-of-Year Reset (Cannot be Undone)</button>
</form>
</p>
<?php
require_once("./includes/template_end.inc.php");
?>