From 104a166d728be699b673911dc493d1453b9efc15 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Fri, 18 Mar 2011 15:30:49 +0000 Subject: [PATCH] move device-edit into its proper file again, no longer set timeout and retries to 0 after saving device settings git-svn-id: http://www.observium.org/svn/observer/trunk@1923 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/includes/device-edit.inc.php | 34 ------------------------- html/pages/device/edit/device.inc.php | 36 ++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 37 deletions(-) delete mode 100644 html/includes/device-edit.inc.php diff --git a/html/includes/device-edit.inc.php b/html/includes/device-edit.inc.php deleted file mode 100644 index 997717fd7..000000000 --- a/html/includes/device-edit.inc.php +++ /dev/null @@ -1,34 +0,0 @@ - 0) -{ - $update_message = mysql_affected_rows() . " Device record updated."; - $updated = 1; -} elseif ($rows_updated = '-1') { - $update_message = "Device record unchanged. No update necessary."; - $updated = -1; -} else { - $update_message = "Device record update error."; - $updated = 0; -} - -?> \ No newline at end of file diff --git a/html/pages/device/edit/device.inc.php b/html/pages/device/edit/device.inc.php index 9b881922b..7a3089e56 100644 --- a/html/pages/device/edit/device.inc.php +++ b/html/pages/device/edit/device.inc.php @@ -4,7 +4,37 @@ if ($_POST['editing']) { if ($_SESSION['userlevel'] > "7") { - include("includes/device-edit.inc.php"); + $descr = mres($_POST['descr']); + $ignore = mres($_POST['ignore']); + $type = mres($_POST['type']); + $disabled = mres($_POST['disabled']); + $community = mres($_POST['community']); + $snmpver = mres($_POST['snmpver']); + $port = mres($_POST['port']); + $timeout = mres($_POST['timeout']); + $retries = mres($_POST['retries']); + + #FIXME needs more sanity checking! and better feedback + $sql = "UPDATE `devices` SET `purpose` = '" . $descr . "', `community` = '" . $community . "', `type` = '$type'"; + $sql .= ", `snmpver` = '" . $snmpver . "', `ignore` = '$ignore', `disabled` = '$disabled', `port` = '$port', "; + if ($timeout) { $sql .= "`timeout` = '$timeout', "; } else { $sql .= "`timeout` = NULL, "; } + if ($retries) { $sql .= "`retries` = '$retries'"; } else { $sql .= "`retries` = NULL"; } + $sql .= " WHERE `device_id` = '".$device['device_id']."'"; + $query = mysql_query($sql); + + $rows_updated = mysql_affected_rows(); + + if ($rows_updated > 0) + { + $update_message = mysql_affected_rows() . " Device record updated."; + $updated = 1; + } elseif ($rows_updated = '-1') { + $update_message = "Device record unchanged. No update necessary."; + $updated = -1; + } else { + $update_message = "Device record update error."; + $updated = 0; + } } } @@ -69,13 +99,13 @@ echo("
SNMP Timeout
-   +   seconds
SNMP Retries
- +