-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
205 lines (157 loc) · 5.84 KB
/
admin.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
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
204
205
<?PHP session_start(); ?>
<html>
<head>
<TITLE>OpenThesaurus</TITLE>
<link rel='stylesheet' type='text/css' href='default.css'>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script language="JavaScript" src="libjava.js"></script>
<script type="text/javascript" src="javascript/overlib.js"><!-- overLIB (c) Erik Bosrup --></script>
</head>
<body>
<script language="JavaScript" src="libjava.js"></script>
<?PHP
include("libstd.php");
include("search.php");
// connect database
$daba = new database();
$daba->connect("localhost","iggmp","1s87J37r0");
$daba->select("thesaurus");
// show login or logged user
user::show();
// headline
?>
<div id='header'>
<a href='index.php'>OpenThesaurus</a><br>
<?PHP
// show count of entries
echo " <i class='normal'>(";
echo database::count() . " Einträge mit ";
echo database::linkcount() . " Verknüpfungen";
echo ")</i>";
?>
</div>
<?PHP
if (right::read())
{
switch ($action)
{
case update:
group::set($_GET[user],$_GET[group]);
break;
case add:
if ($_GET[user] and $_GET[password]) // user and password
{
if (!user::exists($_GET[user]))
{
$user = $_GET[user];
$md5Password = md5($_GET[password]);
database::query("INSERT INTO user SET user='$user',password='$md5Password',`group`='4'");
}
else
{
echo "<div id='alert'><b>User schon vergeben</div>";
}
}
break;
case deleteuser:
if (user::exists($id))
{
echoalert("Benutzer " . user::name($id) . " gelöscht");
database::query("DELETE FROM user WHERE ID='$id'");
}
break;
}
$userArray = fetch_to_array(database::query("SELECT user.ID,user.user,user.password,user.group,user.status,`group`.name FROM user,`group` WHERE user.group=group.ID ORDER BY user"),"");
// list users
echo "<div id='infobig'>";
echo "<fieldset><legend>User</legend>";
echo "<table border='1'>";
echo "<th>User</th>";
echo "<th>Group</th>";
echo "<th></th>";
echo "<th></th>";
echo "<th>Last Login</th>";
echo "<th>Kandidaten</th>";
// edit users and groups
$bgColor = "lightblue";
foreach($userArray as $entry)
{
echo "<tr style='background-color:$bgColor'>";
// toggle backgroud color
if ($bgColor == "white") $bgColor = "lightblue";
else $bgColor = "white";
echo "<form action='admin.php' method='get' name='" . $entry[ID] . "'>";
$userID = $entry[ID];
$group = $entry[group];
echo "<td>" . $entry[user] . " <i class='bright'>ID:$userID</i></td>";
echo "<td>";
echo form::selector("group",group::get_list(),1,"",$group,"","","groupselect");
if (user::superuser($userID)) echo " <i class='red'>su</i>";
echo "</td>";
echo "<td>";
echo form::field("submit","b1","speichern","","","","","save-group");
echo "</td>";
echo "<td>";
$javaText = "Wollen Sie den Benutzer " . user::name($userID) . " wirklich löschen?";
echo form::link("deleteuser","löschen","javascript:get_confirm("$javaText","admin.php?action=deleteuser&id=$userID");");
echo "</td>";
// display last login time
echo "<td>";
$statusArray = explode(";",$entry[status]);
foreach($statusArray as $statusEntry)
{
$last = 0;
$entryArray = explode("=",$statusEntry);
if ($entryArray[0] == "stored") { $last = $entryArray[1]; break; }
}
if ($last) echo date("d.m.Y H:i:s",$last);
echo "</td>";
// display kandidate entries
echo "<td>";
if ($cnt = mysql_num_rows(database::query("SELECT entry.ID,statustype.ID FROM entry,statustype WHERE entry.owner=$userID and entry.status=statustype.ID and statustype.new='1'")))
echo "<a href='index.php?action=suchen&searchstatus=3&searchowner=$userID'>$cnt</a>";
echo "</td>";
// hidden field data
echo form::field("hidden","action","update");
echo form::field("hidden","user","$userID");
echo "</form>";
echo "</tr>";
}
echo "</table>";
echo "</fieldset>";
// add new user
echo "<p><form method='get' action='admin.php'>";
echo "<fieldset><legend>Neuer Benutzer</legend>";
echo form::field("text","user","",30,"","Username ","","new-username");
echo "<br>";
echo form::field("password","password","",30,"","Password ","","new-password");
echo "<br>";
echo form::field("submit","action","anlegen");
echo form::field("hidden","action","add");
echo "</fieldset>";
echo "</form>";
// ----------------------------------------------------------------------------
// list groups
$groupArray = group::get_list();
echo "<fieldset><legend>Gruppen</legend>";
echo "<table>";
echo "<th>group</th>";
echo "<th>rights</th>";
foreach($groupArray as $entry)
{
echo "<tr>";
echo "<td>" . $entry[text] . "</td>";
echo "<td>" . right::int2string($entry[rights],group::superuser($entry[value])) . "</td>";
echo "</tr>";
}
echo "</table>";
echo "</fieldset>";
echo "</div>";
}
else
{
form::standard();
}
?>
</body>
</html>