All web interface pages use the page class.
[gnucomo.git] / src / web / objects.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();
+
+?>
+