-
Notifications
You must be signed in to change notification settings - Fork 0
/
users.php
153 lines (129 loc) · 4.49 KB
/
users.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
<?php require("verify.php");
#### User has logged in and been verified ####
header("Cache-Control: no-cache");
header("Pragma: no-cache");
header("Expires: 0");?>
<HTML>
<head>
<TITLE>ThreeD - Users</TITLE>
<LINK REL="StyleSheet" HREF="style.css" TYPE="text/css">
<META HTTP-EQUIV="Expires" CONTENT="Fri, Jun 12 1981 08:20:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
</head>
<BODY>
<?php
if (!$admin) {
echo "<p><font color=red><b>Must be an Administrator to do that!</b></font><p>";
echo "</BODY></HTML>";
exit;
}
settype ($xid, "integer");
if ($togactive && $xid != $cid) {
$query = "SELECT * FROM users WHERE id = $q$xid$q;";
$result = pg_query($db, $query);
$num = pg_num_rows($result);
if ($num == 1) {
$row = pg_Fetch_array($result, 0, PGSQL_ASSOC);
if ($row[active] == 't') { $newin = 'f'; } else { $newin = 't'; }
$uquery = "UPDATE users SET active = $q$newin$q WHERE id = $q$xid$q;";
$uresult = pg_query($db, $uquery);
}
}
if ($togadmin && $xid != $cid) {
$query = "SELECT * FROM users WHERE id = $q$xid$q;";
$result = pg_query($db, $query);
$num = pg_num_rows($result);
if ($num == 1) {
$row = pg_Fetch_array($result, 0, PGSQL_ASSOC);
if ($row[admin] == 't') { $admin = 'f'; } else { $admin = 't'; }
$uquery = "UPDATE users SET admin = $q$admin$q, cdeditor = 't', adminbook = 't' WHERE id = $q$xid$q;";
$uresult = pg_query($db, $uquery);
}
}
if ($togcdeditor) {
$query = "SELECT * FROM users WHERE id = $q$xid$q;";
$result = pg_query($db, $query);
$num = pg_num_rows($result);
if ($num == 1) {
$row = pg_Fetch_array($result, 0, PGSQL_ASSOC);
if ($row[cdeditor] == 't') { $newin = 'f'; } else { $newin = 't'; }
if ($row[admin] == 't') { $newin = 't'; }
$uquery = "UPDATE users SET cdeditor = $q$newin$q WHERE id = $q$xid$q;";
$uresult = pg_query($db, $uquery);
}
}
if ($togadminbook) {
$query = "SELECT * FROM users WHERE id = $q$xid$q;";
$result = pg_query($db, $query);
$num = pg_num_rows($result);
if ($num == 1) {
$row = pg_Fetch_array($result, 0, PGSQL_ASSOC);
if ($row[adminbook] == 't') { $newin = 'f'; } else { $newin = 't'; }
if ($row[admin] == 't') { $newin = 't'; }
$uquery = "UPDATE users SET adminbook = $q$newin$q WHERE id = $q$xid$q;";
$uresult = pg_query($db, $uquery);
}
}
echo "<b>USER LIST</b>";
$query = "SELECT * FROM users";
$query = $query . " ORDER by UPPER(username);";
$result = pg_query($db, $query);
$num = pg_num_rows($result);
if ($num) {
echo "<p>\n";
echo "<p><TABLE border=1 cellpadding=2 cellspacing=0 bgcolor=#CCCCCC>\n";
echo "<tr valign=top><td align=left><b>Username</b></td><td align=left><b>First Name</b></td><td align=left><b>Last Name</b></td><td align=center><b>Active</b></td><td align=center><b>Admin</b></td><td align=center><b>CD Editor</b></td><td align=center><b>Booking<br>Admin</b></td><td align=center><b>Action</b></td></tr>\n";
for ($i=0;$i<$num;$i++) {
echo "<TR valign=top bgcolor=#";
if ($i % 2 == 0) { echo "AAAAFF"; } else { echo "CCCCFF"; }
echo ">";
$r = pg_Fetch_array($result, $i, PGSQL_ASSOC);
$a = htmlentities($r[username]);
echo "<td>";
if ($a) { echo "$a"; }
else { echo " "; }
echo "</td>\n";
$a = htmlentities($r[first]);
echo "<td>";
if ($a) { echo "$a"; }
else { echo " "; }
echo "</td>\n";
$a = htmlentities($r[last]);
echo "<td>";
if ($a) { echo "$a"; }
else { echo " "; }
echo "</td>\n";
$a = "no";
if ($r[active] == 't') { $a = "<font color=red>yes</font>"; }
echo "<td align=center>";
echo '<A HREF="users.php?xid='.$r[id].'&togactive=1'.'">'.$a.'</A>';
echo "</td>\n";
$a = "no";
if ($r[admin] == 't') { $a = "<font color=red>yes</font>"; }
echo "<td align=center>";
echo '<A HREF="users.php?xid='.$r[id].'&togadmin=1'.'">'.$a.'</A>';
echo "</td>\n";
$a = "no";
if ($r[cdeditor] == 't') { $a = "<font color=red>yes</font>"; }
echo "<td align=center>";
echo '<A HREF="users.php?xid='.$r[id].'&togcdeditor=1'.'">'.$a.'</A>';
echo "</td>\n";
$a = "no";
if ($r[adminbook] == 't') { $a = "<font color=red>yes</font>"; }
echo "<td align=center>";
echo '<A HREF="users.php?xid='.$r[id].'&togadminbook=1'.'">'.$a.'</A>';
echo "</td>\n";
echo "<td align=center>";
echo "<a HREF=adminuseredit.php?";
echo 'gid=' . $r[id] . ">Edit<a>";
echo "</td></TR>\n";
echo "</TR>\n";
}
echo "</TABLE>\n";
}
else { echo "<p><b><font color=red>NO USERS FOUND</font></b>\n"; }
?>
<p><B><a href=adminusernew.php target=main>CREATE NEW USER</a></B>
</BODY>
</HTML>