-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddAtt.php
More file actions
82 lines (65 loc) · 2.08 KB
/
addAtt.php
File metadata and controls
82 lines (65 loc) · 2.08 KB
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
<?php
include("util.php");
// Establishes a connection with MySQL
$sql = SQL::get_connection();
// The member
$member = null;
// Loads member from page parameters, favoring memberID over tagID. If no
// parameters were given, the script dies with an error
if (isset($_POST["memID"]))
$member = Member::SQL_Load_Member_ID($_POST["memID"]);
else if (isset($_POST["tagID"]))
$member = Member::SQL_Load_Member_Tag($_POST["tagID"]);
else
die ("No member id given");
// Leave an error message if the member wasn't able to be loaded
if ($member === false) {
echo "Not found:\n";
die ($_POST["tagID"]);
}
if($member->firstName == "Master" && $member->lastName == "Key") {
$idList = $sql->query("SELECT id FROM members");
// If mysqli->query() returned false, there was an invalid query
if ($idList === false)
die ("<p class=\"error\">Internal query error</p>");
// If no users are found, leave an error
if ($idList->num_rows === 0)
die ("<p class=\"error\">No users in database</p>");
$count = 0;
while($memberRow = $idList->fetch_assoc())
{
$member = Member::SQL_Load_Member_ID($memberRow["id"]);
$member->Refresh_Sign_Status();
if($member->signed_in == 1) {
$member->Sign_Out();
$count++;
}
}
if($count == 1) die("1 member\nsigned out");
else die("$count members\nsigned out");
}
// Refresh the user's sign in status
$member->Refresh_Sign_Status();
// Toggle the user's sign-in status
if ($member->signed_in)
$member->Sign_Out();
else
$member->Sign_In();
// Prints information depending on the output settings
if ($_POST["output"] == "formatted" || $_POST["output"] == "" || !isset($_POST["output"])) {
// Default, formatted for Arduino
echo ($member->firstName."\n".
$member->lastName."\r".
(($member->signed_in == true) ? "1" : "0"));
}
else if ($_POST["output"] == "redirect") {
// Redirects to the attendance page.
header("Location: attendance.php");
exit();
}
else if ($_POST["output"] == "redirectLive") {
// Redirects to the attendance page.
header("Location: liveAttendance.php");
exit();
}
?>