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 "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Name
Identification code
Description
Owner
Physical location
Remarks
Timezone
"; echo ""; echo "
"; echo "

Services on " . $obj->objectname . "


\n"; echo ""; echo ""; $srv_res = pg_exec($this->database, "SELECT servicecode, servicename FROM service ORDER BY servicecode"); for ($srv_row = 0; $srv_row < pg_numrows($srv_res); $srv_row++) { $srv = pg_fetch_object($srv_res, $srv_row); $srv_obj_res = pg_exec($this->database, "SELECT * FROM object_service WHERE objectid='" . $obj->objectid . "' AND servicecode='" . $srv->servicecode . "'"); echo ""; echo ""; echo ""; if (pg_numrows($srv_obj_res) == 0) { echo ""; echo ""; echo ""; echo ""; } else { $obj_srv = pg_fetch_object($srv_obj_res, 0); echo ""; echo ""; echo ""; echo ""; } echo ""; } echo "
Service nameLast entryExpected interval
" . $srv->servicename . "  " . $srv->servicename . "" . $obj_srv->last_entry . "
"; echo "

Users of " . $obj->objectname . "


\n"; echo ""; echo ""; $usr_res = pg_exec($this->database, "SELECT username, security_level FROM usr ORDER BY username"); for ($usr_row = 0; $usr_row < pg_numrows($usr_res); $usr_row++) { $usr = pg_fetch_object($usr_res, $usr_row); $usr_obj_res = pg_exec($this->database, "SELECT * FROM object_user WHERE objectid='" . $obj->objectid . "' AND username='" . $usr->username . "'"); echo ""; echo ""; echo ""; if (pg_numrows($usr_obj_res) == 0) { echo ""; echo ""; echo ""; } else { $usr_obj = pg_fetch_object($usr_obj_res, 0); echo ""; echo ""; echo ""; } echo ""; } echo "
User nameSecurity level 
" . $usr->username . " " . $usr->username . "
"; } else { echo "
"; $res = pg_exec($this->database, "SELECT * FROM object ORDER BY objectname"); ?> GatherStatistics($u->objectid); $count_parameters += $this->nr_parameters; $removed_parameters += $this->removed_parameters; $count_logs = $count_logs + $this->nr_logs; $count_notifications += $this->nr_notifications; $closed_notifications += $this->closed_notifications; ?> "; echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; echo "
ObjectDescriptionLog entries ParametersNotificationsAbuses
server
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
 $count_logs$count_parameters ($removed_parameters removed)$count_notifications ($closed_notifications closed) 
\n"; ?>

Create new object:

Object's name (FQDN):
Showpage(); ?>