All web interface pages use the page class.
authorarjen <arjen>
Thu, 13 Feb 2003 09:01:29 +0000 (09:01 +0000)
committerarjen <arjen>
Thu, 13 Feb 2003 09:01:29 +0000 (09:01 +0000)
src/web/log.php
src/web/login.php
src/web/notification.php
src/web/objects.php
src/web/parameter.php
src/web/parameter_compare.php
src/web/users.php

index 96ac2cd..aa5ca97 100644 (file)
@@ -1,96 +1,84 @@
 <?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.
-***************************************************************************/
+***************************************************************************
+** MODULE INFORMATION *
+***********************
+**      FILE NAME      : log.php
+**      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
+**      VERSION NUMBER : $Revision: 1.2 $
+**
+**  DESCRIPTION      : Logs page
+**
+**  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   : 
+**************************************************************************/
 
-/*
- *
- * Objects Administration page.
- * Input parameters: action (POST) : empty, 'Create'
- *                   objname (POST) : name of the object to create or remove
- */
+/*****************************
+   $Log: log.php,v $
+   Revision 1.2  2003-02-13 09:01:29  arjen
+   All web interface pages use the page class.
 
-session_start();
-require_once('classes/gnucomo_config.php');
-?>
+   Revision 1.2  2003/02/05 09:48:14  arjen
+   Added display and handling of notifications
 
-<!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)
-{
-   if (f.objectname.value == "")
-   {
-      alert("You must supply a name");
-      return false;
-   }
-   return true;
-}
+// RCSID = "$Id: log.php,v 1.2 2003-02-13 09:01:29 arjen Exp $";
 
-function CheckRemove(f)
-{
-   var message = "Are you sure you want to remove object ";
-   message += f.objectname.value;
-   message += " ?";
+ini_set('include_path', '.:./classes:../phpclasses');
 
-   return confirm(message);
-}
+require_once('page.class.php');
 
-</script>
 
-</head>
-<body>
-<?php
-if (empty($_SESSION['username']))
-{
-   echo "Please log in first.";
-}
-else
+class log_page extends page
 {
 
-   $config = new gnucomo_config;
-
-   $config->read("gnucomo");
-
-   //  Connect to the database
-   $conn = pg_connect($config->Database($_SESSION['username'], $_SESSION['password']));
-
-   if (!empty($_GET['oid']))
+   function Body()
    {
-      $res = pg_exec("SELECT objectname FROM object WHERE objectid=" . $_GET['oid']);
-      $obj = pg_fetch_object($res, 0);
-      echo "<h1>Log for " . $obj->objectname . "</h1><hr>";
+      if (!empty($_GET['oid']))
+      {
+         $res = pg_exec($this->database, "SELECT objectname FROM object WHERE objectid=" . $_GET['oid']);
+         $obj = pg_fetch_object($res, 0);
+         echo "<h1>Log for " . $obj->objectname . "</h1><hr>";
 
-      $res = pg_exec("SELECT object_timestamp, servicecode, rawdata FROM log "
-                     ."WHERE objectid=" . $_GET['oid']);
+         $res = pg_exec($this->database, "SELECT object_timestamp, servicecode, rawdata FROM log "
+                        ."WHERE objectid=" . $_GET['oid']);
       
-      echo "<table>";
-      $row = 0;
-      while ($row < pg_numrows($res))
-      {
-         $log = pg_fetch_object($res, $row);
-         ?>
-         <tr><td align='center'>
-            <?php echo $log->object_timestamp?>
-         </td><td>
-            <?php echo $log->servicecode?>
-         </td><td>
-            <?php echo $log->rawdata?>
-         </td></tr>
-         <?php
-         $row++;
+         echo "<table>";
+         $row = 0;
+         while ($row < pg_numrows($res))
+         {
+            $log = pg_fetch_object($res, $row);
+            ?>
+            <tr><td align='center'>
+               <?php echo $log->object_timestamp?>
+            </td><td>
+               <?php echo $log->servicecode?>
+            </td><td>
+               <?php echo $log->rawdata?>
+            </td></tr>
+            <?php
+            $row++;
+         }
+         echo "</table>";
       }
-      echo "</table>";
    }
 }
-?>
 
-</body>
-</html>
+$page = new log_page("Gnucomo system logs");
+
+$page->Showpage();
+
+?>
index a204320..ffbc65a 100755 (executable)
@@ -1,83 +1,44 @@
 <?php
-session_start();
-require_once('classes/gnucomo_config.php');
-include "functions.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>
-</head>
-<body>
-<?php
 
-if (empty($_SESSION["username"]))
-{
+/**************************************************************************
+**  (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.
+***************************************************************************
+** MODULE INFORMATION *
+***********************
+**      FILE NAME      : login.php
+**      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
+**      VERSION NUMBER : $Revision: 1.3 $
+**
+**  DESCRIPTION      : The entry page for the Gnucomo web interface
+**
+**  EXPORTED OBJECTS : 
+**  LOCAL    OBJECTS : 
+**  MODULES  USED    :
+***************************************************************************
+**  ADMINISTRATIVE INFORMATION *
+********************************
+**      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
+**      CREATION DATE   : Dec 03, 2002
+**      LAST UPDATE     : Feb 08, 2003
+**      MODIFICATIONS   : 
+**************************************************************************/
+
+/*****************************
+   $Log: login.php,v $
+   Revision 1.3  2003-02-13 09:01:29  arjen
+   All web interface pages use the page class.
 
-if( isset($_POST["username"]) and isset($_POST["password"]) and isset($_SESSION['login']) )
-{
-   $name   = $_POST["username"];   // PostgreSQL username
-   $passw  = $_POST["password"];   // PostgreSQL user password
+******************************/
 
-   $config = new gnucomo_config;
+// RCSID = "$Id: login.php,v 1.3 2003-02-13 09:01:29 arjen Exp $";
 
-   $config->read("gnucomo");
+ini_set('include_path', '.:./classes:../phpclasses');
+require_once('page.class.php');
 
-   // connect to the database
-   //echo "Database connection = " . $config->Database($name, $passw) . "<br>";
-   $conn = pg_connect($config->Database($name, $passw));
+$login_page = new page("Gnucomo Login");
 
-   if ( !$conn )
-   {
-      echo "Error connecting, try again.";
-      echo login_form();
-   }
-   else
-   {
-      $sql = "SELECT * FROM usr WHERE username='$name'";
-      $res = pg_exec( $conn, $sql );
-      if ($res && pg_numrows($res) == 1)
-      {
-         echo "<br> Database login OK.<br>";
-         session_register('username');
-         $_SESSION["username"] = $name;
-         session_register('password');
-         $_SESSION["password"] = $passw;
-      }
-      else
-      {
-         //  User not found in database. Check if we have any users at all.
+$login_page->Showpage();
 
-         $res = pg_exec($conn, "SELECT count(username) FROM usr");
-         $nusers = pg_fetch_object($res, 0);
-         $nusers = $nusers->count;
-         if ($nusers == 0)
-         {
-            echo "<br>No users in database. Authentication granted.<br>";
-            session_register('username');
-            $_SESSION["username"] = $name;
-            session_register('password');
-            $_SESSION["password"] = $passw;
-         }
-         else
-         {
-            echo "<br>User $name not found in database.<br>";
-         }
-      }
-   }
-}
-else
-{
-   echo login_form();
-   $_SESSION["login"] = true;
-}
-}
-else
-{
-  echo "Logged in as " . $_SESSION['username'] . "<br>";
-}
 ?>
-</body>
-</html>
index 57a3c04..c2791e8 100644 (file)
@@ -9,7 +9,7 @@
 ***********************
 **      FILE NAME      : notification.php
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.1 $
+**      VERSION NUMBER : $Revision: 1.2 $
 **
 **  DESCRIPTION      : Display and handle notifications.
 **                     There are two major views to this page: either a list of
 
 /*****************************
    $Log: notification.php,v $
-   Revision 1.1  2003-02-05 09:48:14  arjen
+   Revision 1.2  2003-02-13 09:01:29  arjen
+   All web interface pages use the page class.
+
+   Revision 1.1  2003/02/05 09:48:14  arjen
    Added display and handling of notifications
 
 ******************************/
 
-// RCSID = "$Id: notification.php,v 1.1 2003-02-05 09:48:14 arjen Exp $";
+// RCSID = "$Id: notification.php,v 1.2 2003-02-13 09:01:29 arjen Exp $";
 
-ini_set('include_path', './classes:../phpclasses');
+ini_set('include_path', '.:./classes:../phpclasses');
 
 require_once('page.class.php');
 
index 6c7120b..d7d7c33 100644 (file)
@@ -9,7 +9,7 @@
 ***********************
 **      FILE NAME      : objects.php
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.4 $
+**      VERSION NUMBER : $Revision: 1.5 $
 **
 **  DESCRIPTION      : Objects Administration page.
 **                     Input parameters: action (POST) : empty, 'Create'
 ********************************
 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
 **      CREATION DATE   : Dec 04, 2002
-**      LAST UPDATE     : Feb 03, 2003
+**      LAST UPDATE     : Feb 08, 2003
 **      MODIFICATIONS   : 
 **************************************************************************/
 
 /*****************************
    $Log: objects.php,v $
-   Revision 1.4  2003-02-13 08:48:23  arjen
+   Revision 1.5  2003-02-13 09:01:29  arjen
+   All web interface pages use the page class.
+
+   Revision 1.4  2003/02/13 08:48:23  arjen
    Added log, notification and parameter counters to the 'object' table.
    Counting these things at the time a user interface needs them is
    too slow. Other programs, like gcm_daemon en gcm_input should prepare
 
 ******************************/
 
-// RCSID = "$Id: objects.php,v 1.4 2003-02-13 08:48:23 arjen Exp $";
+// RCSID = "$Id: objects.php,v 1.5 2003-02-13 09:01:29 arjen Exp $";
 
-session_start();
-require_once('classes/gnucomo_config.php');
-?>
+ini_set('include_path', '.:./classes:../phpclasses');
+
+require_once('page.class.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>
+function clientscripts()
+{
+?>
 
 <script language='JavaScript'>
+
 function CheckCreate(f)
 {
    if (f.objectname.value == "")
@@ -78,37 +79,31 @@ function CheckRemove(f)
 
 </script>
 
-</head>
-<body>
 <?php
-if (empty($_SESSION['username']))
-{
-   echo "Please log in first.";
 }
-else
-{
-   echo "<h1>Objects Administration</h1><hr>";
 
-   $config = new gnucomo_config;
-
-   $config->read("gnucomo");
+class object_page extends page
+{
 
-   //  Connect to the database
-   $conn = pg_connect($config->Database($_SESSION['username'], $_SESSION['password']));
+   function Body()
+   {
+      clientscripts();
 
+   echo "<h1>Objects Administration</h1><hr>";
 
    if (isset($_POST['action']) && $_POST['action'] == 'Create' && !empty($_POST['objectname']))
    {
-      pg_exec($conn, "INSERT INTO object (objectname, log_count, parameter_count, notification_count) VALUES ('"
-                     . $_POST['objectname'] . "', '0', '0', '0')");
+      pg_exec($this->database, "INSERT INTO object (objectname, log_count, parameter_count, notification_count)
+                               VALUES ('" . $_POST['objectname'] . "', '0', '0', '0')");
    }
 
    if (isset($_POST['action']) && $_POST['action'] == 'Remove' && !empty($_POST['objectname']))
    {
-      pg_exec($conn, "DELETE FROM object WHERE objectname='" . $_POST['objectname'] . "'");
+      pg_exec($this->database, "DELETE FROM object WHERE objectname='" . $_POST['objectname'] . "'");
    }
 
-   $res = pg_exec($conn, "SELECT objectid,objectname, log_count, notification_count FROM object ORDER BY objectname");
+   $res = pg_exec($this->database, "SELECT objectid,objectname, log_count, notification_count
+                                    FROM object ORDER BY objectname");
 
    echo "<table>";
    $obj = 0;
@@ -124,7 +119,7 @@ else
       $nr_logs = $u->log_count;
       $count_logs = $count_logs + $nr_logs; 
 
-      $r = pg_exec ($conn, "SELECT count(paramid) FROM parameter WHERE objectid='"
+      $r = pg_exec ($this->database, "SELECT count(paramid) FROM parameter WHERE objectid='"
                            . $u->objectid . "'");
       $r = pg_fetch_object($r, 0);
 
@@ -159,7 +154,6 @@ else
    echo "<td>$count_notifications Notifications</td></tr>";
    echo "</table>";
 
-}
 ?>
 
 <h2>Create new object:</h2>
@@ -171,5 +165,14 @@ Objects name (FQDN): <input name='objectname' type='text'>
 <input type='submit' name='action' value='Create'>
 </form>
 </p>
-</body>
-</html>
+<?php
+
+   }
+}
+
+$obj_page = new object_page("Gnucomo Objects Administration");
+
+$obj_page->Showpage();
+
+?>
+
index f02148f..42a0e58 100644 (file)
@@ -9,7 +9,7 @@
 ***********************
 **      FILE NAME      : parameter.php
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.2 $
+**      VERSION NUMBER : $Revision: 1.3 $
 **
 **  DESCRIPTION      : 
 **
 ********************************
 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
 **      CREATION DATE   : Dec 04, 2002
-**      LAST UPDATE     : Feb 03, 2003
+**      LAST UPDATE     : Feb 08, 2003
 **      MODIFICATIONS   : 
 **************************************************************************/
 
 /*****************************
    $Log: parameter.php,v $
-   Revision 1.2  2003-02-05 09:47:39  arjen
+   Revision 1.3  2003-02-13 09:01:29  arjen
+   All web interface pages use the page class.
+
+   Revision 1.2  2003/02/05 09:47:39  arjen
    Display the difference of all package class parameters for two objects
 
 ******************************/
 
-// RCSID = "$Id: parameter.php,v 1.2 2003-02-05 09:47:39 arjen Exp $";
+// RCSID = "$Id: parameter.php,v 1.3 2003-02-13 09:01:29 arjen Exp $";
+
 
+ini_set('include_path', '.:./classes:../phpclasses');
+
+require_once('page.class.php');
 
-session_start();
-require_once('classes/gnucomo_config.php');
 
 /*  Local functions */
 
@@ -53,61 +58,20 @@ function object_selection($db, $skip_oid)
       echo "</option>";
    }
 }
-?>
 
-<!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)
+class param_page extends page
 {
-   if (f.objectname.value == "")
-   {
-      alert("You must supply a name");
-      return false;
-   }
-   return true;
-}
-
-function CheckRemove(f)
-{
-   var message = "Are you sure you want to remove object ";
-   message += f.objectname.value;
-   message += " ?";
-
-   return confirm(message);
-}
-
-</script>
 
-</head>
-<body>
-<?php
-if (empty($_SESSION['username']))
-{
-   echo "Please log in first.";
-}
-else
-{
-
-   $config = new gnucomo_config;
-
-   $config->read("gnucomo");
-
-   //  Connect to the database
-   $conn = pg_connect($config->Database($_SESSION['username'], $_SESSION['password']));
+   function Body()
+   {
 
    if (!empty($_GET['oid']))
    {
-      $res = pg_exec($conn, "SELECT objectname FROM object WHERE objectid=" . $_GET['oid']);
+      $res = pg_exec($this->database, "SELECT objectname FROM object WHERE objectid=" . $_GET['oid']);
       $obj = pg_fetch_object($res, 0);
       echo "<h1>Parameters for " . $obj->objectname . "</h1>";
 
-      $res = pg_exec("SELECT paramid, class, name, description FROM parameter "
+      $res = pg_exec($this->database, "SELECT paramid, class, name, description FROM parameter "
                      ."WHERE objectid=" . $_GET['oid'] . "order by class, name");
       
      ?>
@@ -115,7 +79,7 @@ else
        <input type='hidden' name='oid' value='<?php echo $_GET['oid'] ?>'>
        Compare to object:
        <select name='compare_to'>
-         <?php object_selection($conn, $_GET['oid']); ?>
+         <?php object_selection($this->database, $_GET['oid']); ?>
        </select>
        <input type='hidden' name='class' value='package'>
        <input type='submit' value=' Show Difference'>
@@ -136,7 +100,8 @@ else
             <?php echo $par->description?>
          </td><td>
             <?php
-               $r = pg_exec($conn, "SELECT name, value FROM property WHERE paramid='" . $par->paramid . "'");
+               $r = pg_exec($this->database, "SELECT name, value FROM property
+                                              WHERE paramid='" . $par->paramid . "'");
                for ($p = 0; $p < pg_numrows($r); $p++)
                {
                   $prop = pg_fetch_object($r, $p);
@@ -149,8 +114,11 @@ else
       }
       echo "</table>";
    }
+   }
 }
-?>
 
-</body>
-</html>
+$page = new param_page("Gnucomo Parameters");
+
+$page->Showpage();
+
+?>
index ea2e258..60df21c 100644 (file)
@@ -9,7 +9,7 @@
 ***********************
 **      FILE NAME      : parameter_compare.php
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.2 $
+**      VERSION NUMBER : $Revision: 1.3 $
 **
 **  DESCRIPTION      : 
 **
 
 /*****************************
    $Log: parameter_compare.php,v $
-   Revision 1.2  2003-02-05 09:47:39  arjen
+   Revision 1.3  2003-02-13 09:01:29  arjen
+   All web interface pages use the page class.
+
+   Revision 1.2  2003/02/05 09:47:39  arjen
    Display the difference of all package class parameters for two objects
 
 ******************************/
 
-// RCSID = "$Id: parameter_compare.php,v 1.2 2003-02-05 09:47:39 arjen Exp $";
-
-session_start();
-require_once('classes/gnucomo_config.php');
-?>
+// RCSID = "$Id: parameter_compare.php,v 1.3 2003-02-13 09:01:29 arjen Exp $";
 
-<!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>Parameter comparison</title>
+ini_set('include_path', '.:./classes:../phpclasses');
 
+require_once('page.class.php');
 
-</head>
-<body>
-<?php
 
 /*  Returns an associative array with all properties of a parameter (pid) */
 
@@ -113,35 +105,24 @@ function display_parameter($name, $properties, $css_class = "")
    echo "</td>";
 }
 
-if (empty($_SESSION['username']))
+class param_diff extends page
 {
-   echo "Please log in first.";
-}
-else
-{
-
-   $config = new gnucomo_config;
-
-   $config->read("gnucomo");
-
-   //  Connect to the database
-   $conn = pg_connect($config->Database($_SESSION['username'], $_SESSION['password']));
 
+   function Body()
+   {
    if (!empty($_POST['oid']))
    {
-      $res = pg_exec("SELECT objectid, objectname FROM object WHERE objectid=" . $_POST['oid']);
+      $res = pg_exec($this->database, "SELECT objectid, objectname FROM object WHERE objectid=" . $_POST['oid']);
       $obj = pg_fetch_object($res, 0);
       echo "<h1>" . $_POST['class'] . " parameters for " . $obj->objectname;
-      $res = pg_exec("SELECT objectid, objectname FROM object WHERE objectid=" . $_POST['compare_to']);
+      $res = pg_exec($this->database, "SELECT objectid, objectname FROM object WHERE objectid=" . $_POST['compare_to']);
       $cmp_obj = pg_fetch_object($res, 0);
       echo " compared to " . $cmp_obj->objectname . "</h1><hr>";
 
-      $res = pg_exec("SELECT objectid, paramid, name FROM parameter "
+      $res = pg_exec($this->database, "SELECT objectid, paramid, name FROM parameter "
                      . "WHERE objectid=" . $obj->objectid . " OR objectid=" . $cmp_obj->objectid
                      . " AND class='" . $_POST['class'] . "' ORDER BY name, objectid");
       
-     ?>
-     <?php
       echo "<table>\n";
       echo "<tr><th colspan='2'>" . $obj->objectname . "</th>";
       echo "<th colspan='2'>" . $cmp_obj->objectname . "</th></tr>\n";
@@ -162,8 +143,8 @@ else
             /*  Both objects have this parameter */
             $row++;
 
-            $pr = param_properties($conn, $par->paramid);
-            $prnext = param_properties($conn, $nextpar->paramid);
+            $pr = param_properties($this->database, $par->paramid);
+            $prnext = param_properties($this->database, $nextpar->paramid);
             if (property_compare($pr, $prnext))
             {
                display_parameter($par->name, $pr);
@@ -190,7 +171,7 @@ else
          {
             /*  Only one of the objects has this parameter */
 
-            $pr = param_properties($conn, $par->paramid);
+            $pr = param_properties($this->database, $par->paramid);
 
             if ($par->objectid == $obj->objectid)
             {
@@ -213,8 +194,11 @@ else
       }
       echo "</table>\n";
    }
+   }
 }
-?>
 
-</body>
-</html>
+$page = new param_diff("Gnucomo Parameter Comparison");
+
+$page->Showpage();
+
+?>
index 8263151..300c4fb 100644 (file)
@@ -1,28 +1,49 @@
 <?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)
 {
@@ -55,40 +76,31 @@ function CheckRemove(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;
@@ -117,7 +129,6 @@ else
    }
    echo "</table>";
 
-}
 ?>
 
 <h2>Create new user:</h2>
@@ -139,5 +150,13 @@ Verify password: <input type='password' name='pwverify'>
 <input type='submit' name='action' value='Create'>
 </form>
 </p>
-</body>
-</html>
+
+<?php
+   }
+}
+
+$page = new user_page("Gnucomo User Administration");
+
+$page->Showpage();
+
+?>