database, "SELECT statvalue FROM object_statistics WHERE objectid=CAST('"
. $objectid . "' AS BIGINT) AND statname='parameters'");
$stat = pg_fetch_object($r, 0);
$this->nr_parameters = $stat->statvalue;
$r = pg_exec ($this->database, "SELECT statvalue FROM object_statistics WHERE objectid=CAST('"
. $objectid . "' AS BIGINT) AND statname='removed_parameters'");
$stat = pg_fetch_object($r, 0);
$this->removed_parameters = $stat->statvalue;
// Gather statistics on notifications
$r = pg_exec ($this->database, "SELECT statvalue FROM object_statistics WHERE objectid=CAST('"
. $objectid . "' AS BIGINT) AND statname='notifications'");
$stat = pg_fetch_object($r, 0);
$this->nr_notifications = $stat->statvalue;
$r = pg_exec ($this->database, "SELECT statvalue FROM object_statistics WHERE objectid=CAST('"
. $objectid . "' AS BIGINT) AND statname='closed_notifications'");
$stat = pg_fetch_object($r, 0);
$this->closed_notifications = $stat->statvalue;
// Gather statistics on log entries
$r = pg_exec ($this->database, "SELECT statvalue FROM object_statistics WHERE objectid=CAST('"
. $objectid . "' AS BIGINT) AND statname='logs'");
$stat = pg_fetch_object($r, 0);
$this->nr_logs = $stat->statvalue;
}
function Body()
{
clientscripts();
if (isset($_POST['action']) && $_POST['action'] == 'Create' && !empty($_POST['objectname']))
{
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($this->database, "DELETE FROM object WHERE objectname='" . $_POST['objectname'] . "'");
}
if (isset($_GET['oid']))
{
echo "
Detailed information for object " . $_GET['oid'] . "
";
if (isset($_POST['action']) && $_POST['action'] == 'Save Changes')
{
$qry = "UPDATE object SET objectname='" . $_POST['oname'] . "'";
$qry .= ", objectcode='" . $_POST['ocode'] . "'";
$qry .= ", object_description='" . $_POST['odescription'] . "'";
$qry .= ", object_owner='" . $_POST['oowner'] . "'";
$qry .= ", physical_location='" . $_POST['olocation'] . "'";
$qry .= ", remark='" . $_POST['oremark'] . "'";
$qry .= ", timezone='" . $_POST['otimezone'] . "'";
$qry .= " WHERE objectid=" . $_GET['oid'];
pg_exec($this->database, $qry);
}
else if (isset($_POST['action']) && $_POST['action'] == 'Modify Service')
{
$obj_srv_res = pg_exec($this->database, "SELECT * from object_service WHERE objectid='" . $_GET['oid']
. "' AND servicecode='" . $_POST['servcode'] . "'");
if (pg_numrows($obj_srv_res) == 0)
{
// Add a new service for this object
if (isset($_POST['servused']))
{
$qry = "INSERT INTO object_service (objectid, servicecode, expected_interval) ";
$qry .= "VALUES ('" . $_GET['oid'] . "', '" . $_POST['servcode'] . "', '";
$qry .= $_POST['expinterval'] . "')";
pg_exec($this->database, $qry);
}
}
else
{
// Modify or remove the service for this object
if (isset($_POST['servused']))
{
// Service is still used; update some values.
$qry = "UPDATE object_service SET expected_interval='" . $_POST['expinterval'];
$qry .= "' WHERE objectid='" . $_GET['oid'];
$qry .= "' AND servicecode='" . $_POST['servcode'] . "'";
pg_exec($this->database, $qry);
}
else
{
// Checkbox was turned off, remove the service
$qry = "DELETE FROM object_service WHERE objectid='" . $_GET['oid'];
$qry .= "' AND servicecode='" . $_POST['servcode'] . "'";
pg_exec($this->database, $qry);
}
}
}
else if (isset($_POST['action']) && $_POST['action'] == 'Modify User')
{
$obj_srv_res = pg_exec($this->database, "SELECT * from object_user WHERE objectid='" . $_GET['oid']
. "' AND username='" . $_POST['username'] . "'");
if (pg_numrows($obj_srv_res) == 0)
{
// Add a new user for this object
if (isset($_POST['userused']))
{
$qry = "INSERT INTO object_user (objectid, username, security_level) ";
$qry .= "VALUES ('" . $_GET['oid'] . "', '" . $_POST['username'] . "', '";
$qry .= $_POST['seclevel'] . "')";
pg_exec($this->database, $qry);
}
}
else
{
// Modify or remove the user for this object
if (isset($_POST['userused']))
{
// Service is still used; update some values.
$qry = "UPDATE object_user SET security_level='" . $_POST['seclevel'];
$qry .= "' WHERE objectid='" . $_GET['oid'];
$qry .= "' AND username='" . $_POST['username'] . "'";
pg_exec($this->database, $qry);
}
else
{
// Checkbox was turned off, remove the user
$qry = "DELETE FROM object_user WHERE objectid='" . $_GET['oid'];
$qry .= "' AND username='" . $_POST['username'] . "'";
pg_exec($this->database, $qry);
}
}
}
$res = pg_exec($this->database, "SELECT * FROM object
WHERE objectid='" . $_GET['oid'] . "'");
$obj = pg_fetch_object($res, 0);
echo "";
echo "Services on " . $obj->objectname . "
\n";
echo "";
echo "Users of " . $obj->objectname . "
\n";
echo "";
}
else
{
echo "Objects Administration
";
$res = pg_exec($this->database, "SELECT * FROM object ORDER BY objectname");
?>
";
?>
Create new object:
Showpage();
?>