From d75355ffb831f6986d0e32a19d4b980bb930a8b6 Mon Sep 17 00:00:00 2001 From: Bart de Bruijn Date: Thu, 17 Sep 2015 13:19:26 +0200 Subject: [PATCH 1/3] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 035e8383e..0c80ef0a8 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -52,6 +52,6 @@ Contributors to LibreNMS: - Arjit Chaudhary (arjit.c@gmail.com) (arjitc) - Sergiusz Paprzycki (spaprzycki) - Juho Vanhanen (juhovan) - +- Bart de Bruijn (bartdebruijn) [1]: http://observium.org/ "Observium web site" From 62328dab91106d77ab31a7b67b412f5f4dfd846f Mon Sep 17 00:00:00 2001 From: Rosiak Date: Thu, 17 Sep 2015 16:19:48 +0200 Subject: [PATCH 2/3] Add Device Notes Field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a “Notes” field for devices to accommodate #1897 --- html/includes/forms/update-notes.inc.php | 32 ++++++++++++++ html/pages/device.inc.php | 6 +++ html/pages/device/notes.inc.php | 56 ++++++++++++++++++++++++ sql-schema/072.sql | 1 + 4 files changed, 95 insertions(+) create mode 100644 html/includes/forms/update-notes.inc.php create mode 100644 html/pages/device/notes.inc.php create mode 100644 sql-schema/072.sql diff --git a/html/includes/forms/update-notes.inc.php b/html/includes/forms/update-notes.inc.php new file mode 100644 index 000000000..4848add6b --- /dev/null +++ b/html/includes/forms/update-notes.inc.php @@ -0,0 +1,32 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +$status = 'error'; +$message = 'unknown error'; + +$device_id = mres($_POST['device_id']); +$notes = mres($_POST['notes']); + +if (isset($notes) && (dbUpdate(array('notes' => $notes), 'devices', 'device_id = ?', array($device_id)))) { + $status = 'ok'; + $message = 'Updated'; +} +else { + $status = 'error'; + $message = 'ERROR: Could not update'; +} +die(json_encode(array( + 'status' => $status, + 'message' => $message, + 'notes' => $notes, + 'device_id' => $device_id +))); diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index dfb90a30e..6bb1bf4fa 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -357,6 +357,12 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) { '; + echo '
  • + + Notes + +
  • '; + echo '
  • https
  • ssh
  • diff --git a/html/pages/device/notes.inc.php b/html/pages/device/notes.inc.php new file mode 100644 index 000000000..94f3372cc --- /dev/null +++ b/html/pages/device/notes.inc.php @@ -0,0 +1,56 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +$data = dbFetchRow("SELECT `notes` FROM `devices` WHERE device_id = ?", array( + $device['device_id'] +)); +?> + +
    +

    Device Notes

    +
    +
    +
    + +
    +
    +
    +
    + Submit + '; +?> +
    +
    +
    + diff --git a/sql-schema/072.sql b/sql-schema/072.sql new file mode 100644 index 000000000..6748b6eb4 --- /dev/null +++ b/sql-schema/072.sql @@ -0,0 +1 @@ +ALTER TABLE `devices` ADD COLUMN `notes` text; From ff7e1f5e845b7725c7a163764ff08ff4b9350383 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Thu, 17 Sep 2015 20:51:10 +0200 Subject: [PATCH 3/3] Use htmlentities --- html/pages/device/notes.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/pages/device/notes.inc.php b/html/pages/device/notes.inc.php index 94f3372cc..39e034ff1 100644 --- a/html/pages/device/notes.inc.php +++ b/html/pages/device/notes.inc.php @@ -21,7 +21,7 @@ $data = dbFetchRow("SELECT `notes` FROM `devices` WHERE device_id = ?", array(
    +echo htmlentities($data['notes']); ?>