This repository was archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserList.php
148 lines (115 loc) · 3.7 KB
/
userList.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
<?php
require_once('include/csp.php');
require_once('include/inisets.php');
require_once('include/secrets.php');
require_once('include/initializeDb.php');
require_once('include/utility_functions.php');
/* TODO: This code may be vulnerable to XSS
and probably a bunch of other attacks
Needs serious security review */
try
{
$highlight_tab = "USERS";
session_start();
validateAuthorization();
initializeDb();
}
catch(Exception $e)
{
switch ($e->getMessage())
{
case USER_NOT_LOGGED_IN_ERROR:
header("Location: login.php?errmsg=USER_NOT_LOGGED_IN_ERROR");
exit();
break;
default:
error_log("Error getting user list: " . $e->getMessage());
header("Location: login.php?errmsg=true");
exit();
}
}
function validateAuthorization()
{
if (!array_key_exists("admin_user_ind", $_SESSION))
{
throw new Exception(USER_NOT_LOGGED_IN_ERROR);
exit;
}
if ($_SESSION["admin_user_ind"] == FALSE)
{
throw new Exception("Requested data for unauthorized user ID. Possible parameter tampering.");
exit;
}
}
function dumpResults()
{
global $dbh;
$stmt = $dbh->prepare("CALL selectUserList();");
$stmt->execute();
if ($stmt->errorCode() != "00000")
{
$erinf = $stmt->errorInfo();
error_log("Query failed in userList.php: " . $stmt->errorCode() . " " . $erinf[2]);
throw new Exception("An unknown error was encountered (10). Please attempt to reauthenticate.");
exit();
}
while ($row = $stmt->fetch(PDO::FETCH_ASSOC))
{
printf("<tr>\n<td>%s</td>\n", htmlentities($row["person_name"]));
printf("<td>%s</td>", htmlentities($row["email"]));
printf("<td>%s</td>",($row["admin_user_ind"] ? "Yes" : "No"));
printf("<td>%s</td>",($row["active_ind"] ? "Yes" : "No"));
printf("<td><a href='user.php?user_id=%u' class='btn btn-default btn-lg'>", $row["user_id"]);
printf("<span class='glyphicon glyphicon-pencil'></span> Edit</a></td>\n</tr>\n");
}
$stmt->closeCursor();
}
//echo "<!-- \n";
//var_dump($_SESSION["orgids"]);
//echo "\n --> \n";
?>
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title><?php echo $site_brand, " - ", LOCALITY_NAME; ?> - Users</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet prefetch"
href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"
integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
<!-- <script src="js/orgList.js"></script> -->
</head>
<body>
<?php require('include/admin_nav_bar.php'); ?>
<div class="container-fluid">
<center>
<div class="page-header">
<h2>User List</h2>
</div>
</center>
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Email Address</th>
<th>Administrator?</th>
<th>Enabled?</th>
<th> </th>
</tr>
</thead>
<tbody>
<?php dumpResults(); ?>
</tbody>
</table>
<?php require('include/footer.php'); ?>
</div> <!-- Container fluid -->
</body>
</html>