3 /**************************************************************************
4 ** This is free software; you can redistribute it and/or modify it under the
5 ** terms of the GNU General Public License, see the file COPYING.
6 ***************************************************************************/
10 * Objects Administration page.
11 * Input parameters: action (POST) : empty, 'Create'
12 * objname (POST) : name of the object to create or remove
16 require_once('classes/gnucomo_config.php');
19 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
22 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
23 <link rel='stylesheet' href='gnucomo.css' type='text/css'>
24 <title>GNUCoMo login</title>
26 <script language='JavaScript'>
27 function CheckCreate(f)
29 if (f.objectname.value == "")
31 alert("You must supply a name");
37 function CheckRemove(f)
39 var message = "Are you sure you want to remove object ";
40 message += f.objectname.value;
43 return confirm(message);
51 if (empty($_SESSION['username']))
53 echo "Please log in first.";
57 echo "<h1>Objects Administration</h1><hr>";
59 $config = new gnucomo_config;
61 $config->read("gnucomo");
63 // Connect to the database
64 $conn = pg_connect($config->Database($_SESSION['username'], $_SESSION['password']));
67 if (isset($_POST['action']) && $_POST['action'] == 'Create' && !empty($_POST['objectname']))
69 pg_exec($conn, "INSERT INTO object (objectname) VALUES ('"
70 . $_POST['objectname'] . "')");
73 if (isset($_POST['action']) && $_POST['action'] == 'Remove' && !empty($_POST['objectname']))
75 pg_exec($conn, "DELETE FROM object WHERE objectname='" . $_POST['objectname'] . "'");
78 $res = pg_exec($conn, "SELECT objectid,objectname FROM object");
82 while ($obj < pg_numrows($res))
84 $u = pg_fetch_object($res, $obj);
85 $r = pg_exec($conn, "SELECT count(logid) FROM log WHERE objectid='"
86 . $u->objectid . "'");
87 $r = pg_fetch_object($r, 0);
91 $r = pg_exec ($conn, "SELECT count(paramid) FROM parameter WHERE objectid='"
92 . $u->objectid . "'");
93 $r = pg_fetch_object($r, 0);
95 $nr_params = $r->count;
97 <tr><td align='center'><img src='server.png'><br>
98 <b><?php echo $u->objectname ?></b>
100 <?php echo $nr_logs?> <a href='log.php?oid=<?php echo $u->objectid?>'>Log entries</a>
102 <?php echo $nr_params?> <a href='parameter.php?oid=<?php echo $u->objectid?>'>Parameters</a>
104 <form action='objects.php' method='post' onSubmit='return CheckRemove(this)'>
105 <input type='hidden' name='objectname' value='<?php echo $u->objectname ?>'>
106 <input type='submit' name='action' value='Remove'>
117 <h2>Create new object:</h2>
120 <form action='objects.php' method='post' onSubmit='return CheckCreate(this)'>
121 Objects name (FQDN): <input name='objectname' type='text'>
123 <input type='submit' name='action' value='Create'>