<?php
/**************************************************************************
+** (c) Copyright 2003, Andromeda Technology & Automation
** This is free software; you can redistribute it and/or modify it under the
** terms of the GNU General Public License, see the file COPYING.
-***************************************************************************/
-
-/*
- *
- * User Administration page.
- * Input parameters: action (POST) : empty, 'Create'
- * username (POST) : name of the user to create or remove
- */
+***************************************************************************
+** MODULE INFORMATION *
+***********************
+** FILE NAME : user.php
+** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
+** VERSION NUMBER : $Revision: 1.2 $
+**
+** DESCRIPTION : User Administration page.
+** Input parameters: action (POST) : empty, 'Create'
+** username (POST) : name of the user to create or remove
+**
+** EXPORTED OBJECTS :
+** LOCAL OBJECTS :
+** MODULES USED :
+***************************************************************************
+** ADMINISTRATIVE INFORMATION *
+********************************
+** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
+** CREATION DATE : Dec 04, 2002
+** LAST UPDATE : Feb 08, 2003
+** MODIFICATIONS :
+**************************************************************************/
+
+/*****************************
+ $Log: users.php,v $
+ Revision 1.2 2003-02-13 09:01:29 arjen
+ All web interface pages use the page class.
+
+******************************/
+
+// RCSID = "$Id: users.php,v 1.2 2003-02-13 09:01:29 arjen Exp $";
+
+ini_set('include_path', '.:./classes:../phpclasses');
+
+require_once('page.class.php');
+
+function clientscripts()
+{
-session_start();
-require_once('classes/gnucomo_config.php');
?>
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel='stylesheet' href='gnucomo.css' type='text/css'>
-<title>GNUCoMo login</title>
-
<script language='JavaScript'>
function CheckCreate(f)
{
</script>
-</head>
-<body>
<?php
-if (empty($_SESSION['username']))
-{
- echo "Please log in first.";
}
-else
-{
- echo "<h1>User Administration</h1><hr>";
-
- $config = new gnucomo_config;
-
- $config->read("gnucomo");
- // Connect to the database
- $conn = pg_connect($config->Database($_SESSION['username'], $_SESSION['password']));
+class user_page extends page
+{
+ function Body()
+ {
+ echo "<h1>User Administration</h1><hr>";
if (isset($_POST['action']) && $_POST['action'] == 'Create' && !empty($_POST['username']))
{
- pg_exec($conn, "CREATE USER " . $_POST['username'] . " PASSWORD '"
+ pg_exec($this->database, "CREATE USER " . $_POST['username'] . " PASSWORD '"
. $_POST['passwd'] . "'");
- pg_exec($conn, "INSERT INTO usr (username, security_level) VALUES ('"
+ pg_exec($this->database, "INSERT INTO usr (username, security_level) VALUES ('"
. $_POST['username'] . "','" . $_POST['seclevel'] . "')");
}
if (isset($_POST['action']) && $_POST['action'] == 'Remove' && !empty($_POST['username']))
{
- pg_exec($conn, "DELETE FROM usr WHERE username='" . $_POST['username'] . "'");
- pg_exec($conn, "DROP USER " . $_POST['username']);
+ pg_exec($this->database, "DELETE FROM usr WHERE username='" . $_POST['username'] . "'");
+ pg_exec($this->database, "DROP USER " . $_POST['username']);
}
- $res = pg_exec($conn, "SELECT username, security_level FROM usr");
+ $res = pg_exec($this->database, "SELECT username, security_level FROM usr");
echo "<table>";
$usr = 0;
}
echo "</table>";
-}
?>
<h2>Create new user:</h2>
<input type='submit' name='action' value='Create'>
</form>
</p>
-</body>
-</html>
+
+<?php
+ }
+}
+
+$page = new user_page("Gnucomo User Administration");
+
+$page->Showpage();
+
+?>