blob: c2e742fc31f98b6ee7cd0f1ff1ae294a0e49ee8b (
plain)
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
<h2>Users</h2>
<?php
include_once($UTIL_DIR . "/user.php");
$users = new Users($DATA_DIR. "/users.xml");
?>
<div class="small_header">Add user</div>
<?php
if($task == "adduser") {
if($password1 == $password2) {
if(!$users->findUser($newuserid)) {
$user = new User($newuserid,
sha1(md5($newpassword1)),
$newmodule_users,
$newmodule_news,
$newmodule_events,
$newmodule_guestbook,
$newmodule_gallery,
$newmodule_user,
$newmodule_newsletter);
$users->add($user);
$users->write();
echo "<p>User <em>" . $newuserid . "</em> added successfully.</p>\n";
} else {
echo "<p>ERROR: User <em>" . $newuserid . "</em> already exists.</p>\n";
}
} else {
echo "<p>ERROR: Passwords do not match.</p>\n";
}
}
?>
<form method="post" action="?page=admin&module=users&task=adduser">
<p>
UserID: <input name="newuserid" value="<?php echo $newuserid; ?>"/>
</p>
<p>
<input name="newmodule_users"
type="checkbox" <?php if($newmodule_users == "on") echo "checked"; ?>/>
Add/edit.delete users:<br/>
<input name="newmodule_user"
type="checkbox" <?php if($newmodule_user == "on") echo "checked"; ?>/>
Change password:<br/>
<input name="newmodule_news"
type="checkbox" <?php if($newmodule_news == "on") echo "checked"; ?>/>
Add news:<br/>
<input name="newmodule_events"
type="checkbox" <?php if($newmodule_events == "on") echo "checked"; ?>/>
Add events:<br/>
<input name="newmodule_gallery"
type="checkbox" <?php if($newmodule_gallery == "on") echo "checked"; ?>/>
Add images in gallery:<br/>
<input name="newmodule_newsletter"
type="checkbox" <?php if($newmodule_newsletter == "on") echo "checked"; ?>/>
Send newsletter:<br/>
<input name="newmodule_guestbook"
type="checkbox" <?php if($newmodule_guestbook == "on") echo "checked"; ?>/>
Modify guestbook
</p>
<p>
New password:
<input type="password" name="newpassword1" style="width: 100px;" value="<?php echo $newpassword1; ?>"/>
</p>
<p>
Confirm password:
<input type="password" name="newpassword2" style="width: 100px;" value="<?php echo $newpassword2; ?>"/>
</p>
<p>
<button type="submit">Add user</button>
</p>
</form>
<div class="small_header">Edit user</div>
<?php
if($task == "updateuser") {
$user = $users->findUser($edituserid);
$user->users = $module_users;
$user->user = $module_user;
$user->news = $module_news;
$user->events = $module_events;
$user->gallery = $module_gallery;
$user->newsletter = $module_newsletter;
$user->guestbook = $module_guestbook;
if($password1 != "") {
if($password1 == $password2) {
$user->password = sha1(md5($password1));
$users->add($user);
$users->write();
echo "<p>User <em>" . $edituserid . "</em> successfully updated.</p>\n";
} else {
echo "<p>ERROR: Passwords do not match</p>\n";
$task = "edituser";
}
} else {
$users->add($user);
$users->write();
echo "<p>User <em>" . $edituserid . "</em> successfully updated. Password left untouched.</p>\n";
}
}
?>
<?php
if($task == "edituser") {
$user = $users->findUser($edituserid);
?>
<form method="post" action="?page=admin&module=users&task=updateuser">
<p>
UserID: <input name="edituserid" readonly value="<?php echo $user->userid; ?>"/>
</p>
<p>
<input name="module_users"
type="checkbox" <?php if($user->users == "on") echo "checked"; ?>/>
Add/edit.delete users:<br/>
<input name="module_user"
type="checkbox" <?php if($user->user == "on") echo "checked"; ?>/>
Change password:<br/>
<input name="module_news"
type="checkbox" <?php if($user->news == "on") echo "checked"; ?>/>
Add news:<br/>
<input name="module_events"
type="checkbox" <?php if($user->events == "on") echo "checked"; ?>/>
Add events:<br/>
<input name="module_gallery"
type="checkbox" <?php if($user->gallery == "on") echo "checked"; ?>/>
Add images in gallery:<br/>
<input name="module_newsletter"
type="checkbox" <?php if($user->newsletter == "on") echo "checked"; ?>/>
Send newsletter:<br/>
<input name="module_guestbook"
type="checkbox" <?php if($user->guestbook == "on") echo "checked"; ?>/>
Modify guestbook
</p>
<p>
New password:
<input type="password" name="password1" style="width: 100px;" value=""/>
</p>
<p>
Confirm password:
<input type="password" name="password2" style="width: 100px;" value=""/>
</p>
<p>
<button type="submit">Submit changes</button>
</p>
</form>
<?php
}
?>
<form method="post" action="?page=admin&module=users&task=edituser">
<p>
Select the user you want to edit:<br/>
<select name="edituserid">
<?php
$uids = $users->useridList();
foreach($uids as $uid) {
?>
<option value="<?php echo $uid;?>"><?php echo $uid;?></option>
<?php
}
?>
</select>
<button type="submit">Edit</button>
</p>
</form>
<div class="small_header">Delete user</div>
<?php
if($task == "deleteconfirm") {
?>
Are you sure you want to delete the <em><?php echo $deleteuserid; ?></em> user?<br/>
<form method="post" action="?page=admin&module=users&task=delete">
<input name="deleteuserid" type="hidden" value="<?php echo $deleteuserid ?>"/>
<button type="submit">Yes</button>
</form>
<form method="post" action="?page=admin&module=users">
<input name="deleteuserid" type="hidden" value="<?php echo $deleteuderid; ?>"/>
<button type="submit">No</button>
</form>
<?php
}
?>
<?php
if($task == "delete") {
if($users->deleteUser($deleteuserid)) {
echo "<p>User <em>".$deleteuserid."</em> deleted successfully.</p>\n";
}
}
?>
<form method="post" action="?page=admin&module=users&task=deleteconfirm">
<p>
Select the user you want to delete:<br/>
<select name="deleteuserid">
<?php
$uids = $users->useridList();
foreach($uids as $uid) {
?>
<option value="<?php echo $uid;?>"><?php echo $uid;?></option>
<?php
}
?>
</select>
<button type="submit">Delete</button>
</p>
</form>
|