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['objectid']))
{
$oid = $_POST['objectid'];
// Cleanup notifications for this object
$r = pg_exec($this->database, "SELECT notificationid FROM notification WHERE objectid='$oid'");
for ($i = 0; $i < pg_numrows($r); $i++)
{
$notif = pg_fetch_object($r, $i);
$notid = $notif->notificationid;
pg_exec($this->database, "DELETE FROM log_notification WHERE notificationid='$notid'");
pg_exec($this->database, "DELETE FROM action_user WHERE notificationid='$notid'");
pg_exec($this->database, "DELETE FROM parameter_notification WHERE notificationid='$notid'");
}
pg_exec($this->database, "DELETE FROM notification WHERE objectid='$oid'");
// Cleanup parameters for this object
$r = pg_exec($this->database, "SELECT paramid FROM parameter WHERE objectid='$oid'");
for ($i = 0; $i < pg_numrows($r); $i++)
{
$param = pg_fetch_object($r, $i);
$parid = $param->paramid;
pg_exec($this->database, "DELETE FROM history WHERE paramid='$parid'");
pg_exec($this->database, "DELETE FROM property WHERE paramid='$parid'");
}
pg_exec($this->database, "DELETE FROM parameter WHERE objectid='$oid'");
// Cleanup log and abuses for this object
pg_exec($this->database, "DELETE FROM log_abuse WHERE objectid='$oid'");
pg_exec($this->database, "DELETE FROM object_abuse WHERE objectid='$oid'");
pg_exec($this->database, "DELETE FROM log WHERE objectid='$oid'");
// Cleanup services, statistics, users and finally, the object itself.
pg_exec($this->database, "DELETE FROM object_service WHERE objectid='$oid'");
pg_exec($this->database, "DELETE FROM object_statistics WHERE objectid='$oid'");
pg_exec($this->database, "DELETE FROM object_user WHERE objectid='$oid'");
pg_exec($this->database, "DELETE FROM object WHERE objectid='$oid'");
}
if (isset($_GET['oid']))
{
echo "
\n";
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 "
Service name | Last entry | Expected interval |
---|---|---|
User name | Security level | |
---|---|---|
Object | Description | Log entries | Parameters | Notifications | Abuses | |
---|---|---|---|---|---|---|
objectname ?> | object_description) ?> | nr_logs > 0 ) { echo " $this->nr_logs "; } else { echo "0"; } ?> | objectid'>" . $this->nr_parameters . " (" . $this->removed_parameters . " removed)" ?> | nr_notifications == $this->closed_notifications ) { echo $this->nr_notifications . " (" . $this->closed_notifications . " closed)"; } else { echo "" . $this->nr_notifications . " (" . $this->closed_notifications . " closed)"; } ?> | objectid'>" . "Abuse list" . " " ?> | TOTALS | ";
echo ""; echo " | $count_logs | "; echo "$count_parameters ($removed_parameters removed) | "; echo "$count_notifications ($closed_notifications closed) | "; echo ""; echo "\n"; echo " |