3 /**************************************************************************
4 ** (c) Copyright 2003, Andromeda Technology & Automation
5 ** This is free software; you can redistribute it and/or modify it under the
6 ** terms of the GNU General Public License, see the file COPYING.
7 ***************************************************************************
8 ** MODULE INFORMATION *
9 ***********************
10 ** FILE NAME : objects.php
11 ** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
12 ** VERSION NUMBER : $Revision: 1.2 $
14 ** DESCRIPTION : Objects Administration page.
15 ** Input parameters: action (POST) : empty, 'Create'
16 ** objname (POST) : name of the object to create or remove
21 ***************************************************************************
22 ** ADMINISTRATIVE INFORMATION *
23 ********************************
24 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
25 ** CREATION DATE : Dec 04, 2002
26 ** LAST UPDATE : Feb 03, 2003
28 **************************************************************************/
30 /*****************************
32 Revision 1.2 2003-02-05 09:48:14 arjen
33 Added display and handling of notifications
35 ******************************/
37 // RCSID = "$Id: objects.php,v 1.2 2003-02-05 09:48:14 arjen Exp $";
40 require_once('classes/gnucomo_config.php');
43 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
46 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
47 <link rel='stylesheet' href='gnucomo.css' type='text/css'>
48 <title>GNUCoMo login</title>
50 <script language='JavaScript'>
51 function CheckCreate(f)
53 if (f.objectname.value == "")
55 alert("You must supply a name");
61 function CheckRemove(f)
63 var message = "Are you sure you want to remove object ";
64 message += f.objectname.value;
67 return confirm(message);
75 if (empty($_SESSION['username']))
77 echo "Please log in first.";
81 echo "<h1>Objects Administration</h1><hr>";
83 $config = new gnucomo_config;
85 $config->read("gnucomo");
87 // Connect to the database
88 $conn = pg_connect($config->Database($_SESSION['username'], $_SESSION['password']));
91 if (isset($_POST['action']) && $_POST['action'] == 'Create' && !empty($_POST['objectname']))
93 pg_exec($conn, "INSERT INTO object (objectname) VALUES ('"
94 . $_POST['objectname'] . "')");
97 if (isset($_POST['action']) && $_POST['action'] == 'Remove' && !empty($_POST['objectname']))
99 pg_exec($conn, "DELETE FROM object WHERE objectname='" . $_POST['objectname'] . "'");
102 $res = pg_exec($conn, "SELECT objectid,objectname FROM object");
106 while ($obj < pg_numrows($res))
108 $u = pg_fetch_object($res, $obj);
109 $r = pg_exec($conn, "SELECT count(logid) FROM log WHERE objectid='"
110 . $u->objectid . "'");
111 $r = pg_fetch_object($r, 0);
113 $nr_logs = $r->count;
115 $r = pg_exec ($conn, "SELECT count(paramid) FROM parameter WHERE objectid='"
116 . $u->objectid . "'");
117 $r = pg_fetch_object($r, 0);
119 $nr_params = $r->count;
121 $r = pg_exec ($conn, "SELECT count(notificationid) FROM notification WHERE objectid='"
122 . $u->objectid . "'");
123 $r = pg_fetch_object($r, 0);
125 $nr_notifications = $r->count;
127 <tr><td align='center'><img src='server.png'><br>
128 <b><?php echo $u->objectname ?></b>
130 <?php echo $nr_logs?> <a href='log.php?oid=<?php echo $u->objectid?>'>Log entries</a>
132 <?php echo $nr_params?> <a href='parameter.php?oid=<?php echo $u->objectid?>'>Parameters</a>
134 <?php echo $nr_notifications?> <a href='notification.php?oid=<?php echo $u->objectid?>'>Notifications</a>
136 <form action='objects.php' method='post' onSubmit='return CheckRemove(this)'>
137 <input type='hidden' name='objectname' value='<?php echo $u->objectname ?>'>
138 <input type='submit' name='action' value='Remove'>
149 <h2>Create new object:</h2>
152 <form action='objects.php' method='post' onSubmit='return CheckCreate(this)'>
153 Objects name (FQDN): <input name='objectname' type='text'>
155 <input type='submit' name='action' value='Create'>