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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
<?php
/*
* Identity Provider Example -- User Administration
*
* Copyright (C) 2004 Entr'ouvert
* http://lasso.entrouvert.org
*
* Authors: Christophe Nowicki <cnowicki@easter-eggs.com>
*
* 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
*/
$config = unserialize(file_get_contents('config.inc'));
require_once 'DB.php';
$number_of_users = 5;
$db = &DB::connect($config['dsn']);
if (DB::isError($db))
die($db->getMessage());
// Show XML dump
if (!empty($_GET['dump']) && !empty($_GET['type']))
{
$query = "SELECT " . ($_GET['type'] == 'user' ? 'user' : 'session') .
$query .= "_dump FROM users WHERE user_id='" . $_GET['dump'] . "'";
$res =& $db->query($query);
if (DB::isError($res))
die($res->getMessage());
$row = $res->fetchRow();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<body onLoad="window.focus();">
<table>
<caption><?php echo ($_GET['type'] == 'user' ? 'Identity' : 'Session'); ?> Dump</caption>
<tr>
<td>
<textarea rows="15" cols="50"><?php echo htmlentities($row[0], ENT_QUOTES); ?></textarea>
</td>
</tr>
<tr>
<td align="center"><a href="javascript:window.close(self)">Close</a></td>
</tr>
</table>
</body>
</html>
<?php
exit;
}
if (!empty($_GET['del'])) {
$query = "DELETE FROM nameidentifiers WHERE user_id='" . $_GET['del'] . "'" ;
$res =& $db->query($query);
if (DB::isError($res))
print $res->getMessage(). "\n";
$query = "DELETE FROM users WHERE user_id='" . $_GET['del'] . "'" ;
$res =& $db->query($query);
if (DB::isError($res))
print $res->getMessage(). "\n";
}
// Count users
$query = "SELECT COUNT(*) FROM users";
$res =& $db->query($query);
if (DB::isError($res))
die($res->getMessage());
$row = $res->fetchRow();
$count = $row[0];
$startUser = ((empty($_GET['startUser'])) ? 0 : $_GET['startUser']);
$query = "SELECT * FROM users";
if (!isset($_GET['show_all']))
$query .= " OFFSET $startUser LIMIT " . ($startUser + $number_of_users);
$res =& $db->query($query);
if (DB::isError($res))
die($res->getMessage());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Lasso Service Provider Example : Users Management</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
<script language="JavaScript" type="text/javascript">
<!--
function openpopup(popurl)
{
var winpops=window.open(popurl,"","width=400,height=300")
}
function ToggleAll()
{
for (var i = 0; i < document.frm.elements.length; i++)
{
if(document.frm.elements[i].type == 'checkbox')
document.frm.elements[i].checked = !(document.frm.elements[i].checked);
}
}
//-->
</script>
</head>
<body>
<form name='frm' method=>
<table border="1" align="center">
<caption>Users</caption>
<?php
$num_col = $res->numCols();
$tableinfo = $db->tableInfo($res);
?>
<thead>
<tr>
<td colspan='<?php echo $num_col + 1; ?>'>
<?php
if ($startUser)
echo "<a href=$PHP_SELF?startUser=" . ($startUser - $number_of_users) . ">Previous</a>";
else
echo "Previous"
?>
|
<?php
if ((($count - $startUser) > $number_of_users) && !isset($_GET['show_all']))
echo "<a href=$PHP_SELF?startUser=" . ($startUser + $number_of_users) . ">Next</a>";
else
echo "Next"
?>
<?php
for ($i = 0; $i < $count; $i += $number_of_users)
if ($i == $startUser)
echo "| " . ( $i / $number_of_users);
else
echo "| <a href=\"$PHP_SELF?startUser=$i\">" . ( $i / $number_of_users) . "</a>";
?>
|
<?php if (isset($_GET['show_all'])) { ?>
<a href="<?php echo $PHP_SELF."?startUser=0"; ?>">Paginate</a>
<?php } else { ?>
<a href="<?php echo $PHP_SELF."?show_all=1"; ?>">Show All</a>
<?php } ?>
| <a href="javascript:void(0)" onClick="ToggleAll();">Toggle All</a></td>
<td align='right'><a href="javascript:openpopup('user_add.php')">add user</a></td>
</tr>
<tr align="center">
<td> </td>
<?php
for ($i = 0; $i < $num_col; $i++) {
echo "<td>" . $tableinfo[$i]['name'] ."</td>";
}
?>
<td> </td>
</tr>
</thead>
<tbody>
<?php
while ($row =& $res->fetchRow()) {
?>
<tr align="center">
<td>
<input type='checkbox' name='uid' value='<?php $row[0]; ?>'>
</td>
<?php
for ($i = 0; $i < $num_col; $i++)
{
?>
<td>
<?php
switch ($tableinfo[$i]['name'])
{
case "user_dump":
echo "<a href=javascript:openpopup('". $PHP_SELF . '?dump=' . $row[0] . "&type=user')>view</a>";
break;
case "session_dump":
echo "<a href=javascript:openpopup('". $PHP_SELF . '?dump=' . $row[0] . "&type=session')>view</a>";
break;
default:
echo (empty($row[$i])) ? " " : $row[$i];
}
?>
</td>
<?php
}
?>
<td>
<a href="<?php echo $PHP_SELF . '?del=' . $row[0]; ?>">delete</a>
</td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<td colspan="<?php echo $num_col + 1; ?>"> </td>
<td>Total: <?php echo $count; ?> Users</td>
</tr>
</tfoot>
</table>
</form>
<br>
<p align='center'><a href='index.php'>Index</a>
</p>
<br>
<p>Copyright © 2004 Entr'ouvert</p>
</body>
</html>
<?php
$db->disconnect();
?>
|