-
Notifications
You must be signed in to change notification settings - Fork 0
/
adminuseredit.php
162 lines (139 loc) · 5.06 KB
/
adminuseredit.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
<?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 - Edit 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 onload="document.forms[0].xmotd.focus();document.forms[0].xmotd.select()">
<?php
if (!$admin) {
echo "<p><font color=red><b>Must be an Administrator to do that!</b></font><p>";
echo "</BODY></HTML>";
exit;
}
settype ($gid, "integer");
$query = "SELECT * FROM users WHERE id = $q$gid$q;";
$result = pg_query($db, $query);
$num = pg_num_rows($result);
if ($num != 1) {
echo "<p><font color=red><b>User does not exist!</b></font><p>";
echo "</BODY></HTML>";
exit;
}
$row = pg_fetch_array($result, 0, PGSQL_ASSOC);
if ($xactive != 't') { $xactive = 'f'; }
if ($xadmin != 't') { $xadmin = 'f'; }
if ($xcdeditor != 't') { $xcdeditor = 'f'; }
if ($xadminbook != 't') { $xadminbook = 'f'; }
if ($gid == $cid) { $xactive = 't'; $xadmin = 't'; $xcdeditor = 't'; }
if ($xadmin == 't') { $xcdeditor = 't'; $xadminbook = 't'; }
if ($xupdate && $gid) {
$error = "";
$pwshort = "";
$pwmismatch = "";
$passwordchanged = "";
$orig = $xusername;
$xusername = trim($xusername);
$xusername = preg_replace("/[^A-Za-z0-9]/","",$xusername);
if (!$xusername || $xusername != $orig) {
$error .= "<p><font color=red><b>Not a Valid Username!</b></font>";
}
if (!$error) {
$query = "SELECT * FROM users WHERE username ~~* $q$xusername$q AND id <> $gid;";
$result = pg_query($db, $query);
$num = pg_num_rows($result);
if ($num) {
$error .= "<p><font color=red><b>That Username Already Exists!</b></font>";
}
}
if (($xpassword1 || $xpassword2) && strlen ($xpassword1) < 4)
{ $pwshort = 1; $error .= "<p><font color=red><b>Password must be at least 5 characters long - Password Not Changed</b></font>"; }
if (($xpassword1 || $xpassword2) && $xpassword1 != $xpassword2)
{ $pwmismatch = 1; $error .= "<p><font color=red><b>Entered passwords do not match - Password Not Changed</b></font>"; }
$uquery = "UPDATE users SET ";
if ($xpassword1 && !$pwshort && !$pwmismatch) {
$xpassword1 = MD5($xpassword1);
$uquery = $uquery . "password=$q$xpassword1$q, ";
$cpassword = $xpassword1;
$passwordchanged = 1;
}
if (!$error) { $uquery = $uquery . "username=$q$xusername$q, "; }
$uquery = $uquery . "
first=$q$xfirst$q,
last=$q$xlast$q,
active=$q$xactive$q,
admin=$q$xadmin$q,
cdeditor=$q$xcdeditor$q,
adminbook=$q$xadminbook$q
WHERE id = $q$gid$q;";
$result = pg_query($db, $uquery);
if (!$error) { header("Location: http://".$_SERVER['HTTP_HOST'] .dirname($_SERVER['PHP_SELF']) ."/users.php"); }
}
?>
<b>Admin Edit User</b>
<p>
<form action=adminuseredit.php method=post>
<input type=hidden name=xupdate value=1>
<input type=hidden name=gid value="<?php echo "$gid"; ?>">
<table border=1 cellspacing=0 cellpadding=2>
<tr bgcolor="#AAAAFF">
<td><b>Username</b></td>
<td><input type=text name=xusername value="<?php $a=htmlentities($row[username]); echo "$a"; ?>" size=30 maxlength=50></td>
</tr>
<tr bgcolor="#CCCCFF">
<td><b>First Name</b></td>
<td><input type=text name=xfirst value="<?php $a=htmlentities($row[first]); echo "$a"; ?>" size=30 maxlength=50></td>
</tr>
<tr bgcolor="#AAAAFF">
<td><b>Last Name</b></td>
<td><input type=text name=xlast value="<?php $a=htmlentities($row[last]); echo "$a"; ?>" size=30 maxlength=50></td>
</tr>
<tr bgcolor="#CCCCFF">
<td><b>New Password</b></td>
<td><input type=password name=xpassword1 value="" size=30 maxlength=50>
</tr>
<tr bgcolor="#CCCCFF">
<td><b>Retype Password</b></td>
<td><input type=password name=xpassword2 value="" size=30 maxlength=50>
</tr>
<tr bgcolor="#AAAAFF">
<td><b>Active</b></td>
<td>
<input type=radio id=2 name=xactive value=t<?php if ($row[active] == 't') { echo " checked"; } ?>>Yes</input>
<input type=radio id=2 name=xactive value=f<?php if ($row[active] != 't') { echo " checked"; } ?>>No</input>
</td>
</tr>
<tr bgcolor="#CCCCFF">
<td><b>Admin</b></td>
<td>
<input type=radio id=2 name=xadmin value=t<?php if ($row[admin] == 't') { echo " checked"; } ?>>Yes</input>
<input type=radio id=2 name=xadmin value=f<?php if ($row[admin] != 't') { echo " checked"; } ?>>No</input>
</td>
</tr>
<tr bgcolor="#AAAAFF">
<td><b>CD Editor</b></td>
<td>
<input type=radio id=2 name=xcdeditor value=t<?php if ($row[cdeditor] == 't') { echo " checked"; } ?>>Yes</input>
<input type=radio id=2 name=xcdeditor value=f<?php if ($row[cdeditor] != 't') { echo " checked"; } ?>>No</input>
</td>
</tr>
<tr bgcolor="#AAAAFF">
<td><b>Booking Admin</b></td>
<td>
<input type=radio id=2 name=xadminbook value=t<?php if ($row[adminbook] == 't') { echo " checked"; } ?>>Yes</input>
<input type=radio id=2 name=xadminbook value=f<?php if ($row[adminbook] != 't') { echo " checked"; } ?>>No</input>
</td>
</tr>
</table>
<p><input type="submit" name="xbutton" value="Save">
</form>
<?php if ($error) { echo $error; } ?>
</BODY>
</HTML>