summaryrefslogtreecommitdiffstats
path: root/php/Attic/examples/sample-sp/admin_user.php
diff options
context:
space:
mode:
authorChristophe Nowicki <cnowicki@easter-eggs.com>2004-08-31 10:17:55 +0000
committerChristophe Nowicki <cnowicki@easter-eggs.com>2004-08-31 10:17:55 +0000
commit78bf15ec270fc853569a1b8766560105e69f8a73 (patch)
tree46682a396ce264b883c89d93cdd5740ec3491032 /php/Attic/examples/sample-sp/admin_user.php
parent10a1215399f6d4f251cb3d403f3726cb9fee5c8d (diff)
downloadlasso-78bf15ec270fc853569a1b8766560105e69f8a73.tar.gz
lasso-78bf15ec270fc853569a1b8766560105e69f8a73.tar.xz
lasso-78bf15ec270fc853569a1b8766560105e69f8a73.zip
new version of the PHP service provider made with the new Swig PHP binding
Diffstat (limited to 'php/Attic/examples/sample-sp/admin_user.php')
-rw-r--r--php/Attic/examples/sample-sp/admin_user.php162
1 files changed, 162 insertions, 0 deletions
diff --git a/php/Attic/examples/sample-sp/admin_user.php b/php/Attic/examples/sample-sp/admin_user.php
new file mode 100644
index 00000000..6893ad72
--- /dev/null
+++ b/php/Attic/examples/sample-sp/admin_user.php
@@ -0,0 +1,162 @@
+<?php
+/*
+ * Service 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';
+
+
+ $db = &DB::connect($config['dsn']);
+
+ if (DB::isError($db))
+ die($db->getMessage());
+
+ if (!empty($_GET['dump'])) {
+ $query = "SELECT identity_dump FROM users WHERE user_id='" . $_GET['dump'] . "'";
+ $res =& $db->query($query);
+ if (DB::isError($res))
+ print $res->getMessage(). "\n";
+ $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>
+<table>
+<caption>Identity 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";
+
+ }
+
+
+ $query = "SELECT * FROM users";
+ $res =& $db->query($query);
+ if (DB::isError($res))
+ print $res->getMessage(). "\n";
+?>
+<!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>
+<script type="text/javascript">
+
+ function openpopup(popurl){
+ var winpops=window.open(popurl,"","width=400,height=300")
+ }
+
+</script>
+</head>
+<body>
+
+<table border="1" align="center">
+<caption>Users</caption>
+<?php
+ $num_col = $res->numCols();
+ $tableinfo = $db->tableInfo($res);
+?>
+<thead>
+<tr align="center"><?php
+ for ($i = 0; $i < $num_col; $i++) {
+ echo "<td>" . $tableinfo[$i]['name'] ."</td>";
+ }
+?><td>&nbsp;</td>
+</tr>
+</thead>
+<tbody>
+<?php
+ while ($row =& $res->fetchRow()) {
+?>
+<tr align="center">
+<?php
+ for ($i = 0; $i < $num_col; $i++)
+ {
+ ?>
+ <td>
+ <?php
+ switch ($tableinfo[$i]['name'])
+ {
+ case "identity_dump":
+ echo "<a href=javascript:openpopup('". $PHP_SELF . '?dump=' . $row[0] . "')>view</a>";
+ break;
+
+ default:
+ echo (empty($row[$i])) ? "&nbsp;" : $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; ?>">&nbsp;</td>
+<td>Total: <?php echo $res->numRows();?> Users</td>
+</tr>
+</tfoot>
+</table>
+
+</body>
+
+</html>
+<?php
+ $db->disconnect();
+?>