Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 86 lines (83 sloc) 3.148 kb
93c83067 »
2010-10-21 Added an user administration page
1 <?php
2 if(!force_level(2)) return;
3
4 if(isset($_POST['submit'])) {
5 foreach($_POST['user'] as $id => $change) {
5d66f359 »
2012-03-11 Added support for PostgreSQL
6 $id = intval($id);
93c83067 »
2010-10-21 Added an user administration page
7 if($id == 1) continue;
5d66f359 »
2012-03-11 Added support for PostgreSQL
8
93c83067 »
2010-10-21 Added an user administration page
9 $user = user_load('id', $id);
10 if(!$user) continue;
11 if($change['delete']) {
12 $database->exec('DELETE FROM user_data WHERE user_id = '.$id);
13 $database->exec('DELETE FROM user_feeds WHERE user_id = '.$id);
14 $database->exec('DELETE FROM users WHERE id = '.$id);
15 status_message("Benutzer " . htmlspecialchars($user->name) . " gelöscht");
16 admin_log("Benutzer " . htmlspecialchars($user->name) . " gelöscht");
17 continue;
18 }
19 if($change['pass']) {
20 $user->pass = sha1($user->salt . $change['pass']);
21 status_message("Passwort für Benutzer " . htmlspecialchars($user->name) . " geändert");
22 admin_log("Passwort für Benutzer " . htmlspecialchars($user->name) . " geändert");
23 }
24 if(isset($change['level'])) {
25 $user->level = intval($change['level']);
26 status_message("Benutzerlevel für Benutzer " . htmlspecialchars($user->name) . " auf " . $user->level . " geändert");
27 admin_log("Benutzerlevel für Benutzer " . htmlspecialchars($user->name) . " auf " . $user->level . " geändert");
28 }
29 user_save($user);
30 }
31 gotop("index.php?q=admin");
32 }
33 ?>
34 <script type="text/javascript"><!--
35 $(document).ready(function() {
36 var fields = {};
37 $("#users input, #users select").change(function() {
38 if(((this.type == "checkbox" && !this.checked) || this.value == "") && this.name in fields) {
39 fields[this.name].remove();
40 delete fields[this.name];
41 return;
42 }
43 if(this.name in fields) {
44 fields[this.name].val(this.value);
45 }
46 else {
47 fields[this.name] = $("<input type='hidden'>").attr("name", this.name).val(this.value).appendTo($("#users_form"));
48 }
49 });
50 });
51 // --> </script>
52 <div id="content">
53 <h2>Administration</h2>
54 <table id="users">
55 <thead><tr><th>Benutzername</th><th>Email</th><th>Passwort</th><th>Berechtigungen</th><th>Aktion</th></tr></thead>
56 <tbody>
57 <?php
58 $users = $database->query('SELECT id, name, level, settings FROM users WHERE id > 1');
59 foreach($users as $user):
60 $settings = unserialize($user['settings']);
61 ?>
62 <tr><td><?=htmlspecialchars($user['name'])?></td>
63 <td><?=htmlspecialchars($settings['newsletter'])?></td>
64 <td><input type="text" name="user[<?=$user['id']?>][pass]"></td>
65 <td><select name="user[<?=$user['id']?>][level]">
66 <?php foreach(user_levels() as $key => $desc): ?>
67 <option value="<?=$key?>" <?php if($user['level'] == $key) echo('selected'); ?>><?=$desc?></option>
68 <?php endforeach; ?>
69 </select></td>
70 <td><label><input type="checkbox" value="1" name="user[<?=$user['id']?>][delete]"> Löschen</label></td>
71 </tr>
72 <?php endforeach;
73 ?>
74 </tbody>
75 </table>
76 <form method="post" id="users_form" action="index.php?q=admin">
77 <input style="float: right; margin-top: 10px" type="submit" name="submit" value="Speichern">
78 </form>
79 <?php if($GLOBALS['admin_log_file']): ?>
80 <h3>Admin Log-File</h3>
81 <pre><?php
82 echo(file_get_contents($GLOBALS['admin_log_file']));
83 ?></pre>
84 <?php endif; ?>
85 </div>
Something went wrong with that request. Please try again.