-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanageusers.php
More file actions
151 lines (128 loc) · 3.57 KB
/
manageusers.php
File metadata and controls
151 lines (128 loc) · 3.57 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
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
<?php
//
// GiftWeb: PHP/PostgreSQL online Gift Registry System
// Matthew T. Jachimstal
// Copyright (C) 2000-2008 Matthew T. Jachimstal
//
// email: matthew@jachimstal.com
//
// Snail mail: Matthew Jachimstal
// 1106 Canterbury Ct, Unit D
// Elgin, IL 60120
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
require "./main.inc";
require "./util.php";
$s = $_COOKIE["GiftWeb_Session"];
$uid = validatesession($s);
$conn = ADONewConnection($dbtype);
$conn->PConnect($dbhost, $dbuser, $dbpass, $dbname);
// Check if the user opening this page is a site admin.
// If not, exit right away
$sql = "SELECT * FROM giftweb WHERE admin='$uid'";
$result1 = $conn->Execute($sql);
if ($result1->RecordCount() == 0)
{
startpage_old("Error: Not Administrator", 0);
?>
<h2>Error: You are not the site administrator</h2>
<?php
redir("./main.php", "the main GiftWeb page", 3);
endpage_old(-1);
exit();
}
startpage_old("Site Administration", 0);
echo "<h3>Manage Users</h3>\n";
if (isset($_POST["del_users"]))
{
delete_users();
}
display_form();
function delete_users()
{
global $conn;
if (isset($_POST["userlist"]))
{
$users_selected = $_POST["userlist"];
$cnt = count($users_selected);
echo "<ul>\n";
for ($i=0; $i < $cnt; $i++)
{
$grp_sql = "SELECT * FROM groups WHERE admin='$users_selected[$i]'";
$grp_result = $conn->Execute($grp_sql);
for ($j=0; $j < $grp_result->RecordCount(); $j++)
{
$adm_grp = chop($grp_result->fields["description"]);
echo "<li>The site administrator is now the group
administrator for group $adm_grp.</li>\n"
$grp_result->MoveNext();
}
$adm_sql = "UPDATE groups SET admin='$uid' WHERE admin='$users_selected[$i]'";
$adm_result = $conn->Execute($adm_sql);
$sql = "DELETE FROM users WHERE uid='$users_selected[$i]'";
$result = $conn->Execute($sql);
?>
</ul>
<h3>Users have been deleted.</h3>
<?php
}
else
{
echo "<h3>No users have been deleted.</h3>\n";
}
}
function display_form()
{
$sql = "SELECT * FROM users WHERE uid != '$uid' ORDER BY last_name, first_name";
$result = $conn->Execute($sql);
?>
<form method="post" action="manageusers.php">
<table cellspacing=1 cellpadding=2 border=1>
<tr>
<th>Select</th>
<th>Last Name</th>
<th>First Name</th>
</tr>
<?php
$result->MoveFirst();
for ($i=0; $i < $result->RecordCount(); $i++)
{
$fname = chop($result->fields["first_name"]);
$lname = chop($result->fields["last_name"]);
$userid = chop($result->fields["uid"]);
?>
<tr>
<td><input type=checkbox name=userlist[]"
value="<?php echo $userid?>"></td>
<td><?php echo $lname?></td>
<td><?php echo $fname?></td>
</tr>
<?php
$result->MoveNext();
}
?>
</table>
<center>
<table><tr>
<td><input type=submit name=del_users value="Delete users"></td>
<td width=90%> </td>
</tr>
</table><br>
</center>
<h3><a href="./siteadmin.php">Return to Site Admin page</a></h3>
<?php
}
?>