From d4d2736954441139256ef325cb868b2a55e503a1 Mon Sep 17 00:00:00 2001 From: pblasquez Date: Tue, 26 Apr 2016 14:39:10 -0700 Subject: [PATCH 1/2] Ajax Headers for Alert Forms --- html/includes/forms/ack-alert.inc.php | 1 + html/includes/forms/alert-templates.inc.php | 1 + html/includes/forms/attach-alert-template.inc.php | 1 + html/includes/forms/delete-alert-rule.inc.php | 1 + html/includes/forms/delete-alert-template.inc.php | 1 + html/includes/forms/parse-alert-map.inc.php | 1 + html/includes/forms/parse-alert-rule.inc.php | 1 + html/includes/forms/parse-alert-template.inc.php | 1 + html/includes/forms/sensor-alert-reset.inc.php | 1 + html/includes/forms/sensor-alert-update.inc.php | 1 + html/includes/forms/update-alert-rule.inc.php | 1 + 11 files changed, 11 insertions(+) diff --git a/html/includes/forms/ack-alert.inc.php b/html/includes/forms/ack-alert.inc.php index 351825fb7..a89c4d694 100644 --- a/html/includes/forms/ack-alert.inc.php +++ b/html/includes/forms/ack-alert.inc.php @@ -11,6 +11,7 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ +header('Content-type: text/plain'); $alert_id = mres($_POST['alert_id']); $state = mres($_POST['state']); diff --git a/html/includes/forms/alert-templates.inc.php b/html/includes/forms/alert-templates.inc.php index 74fda1b8c..4b1ef9c12 100644 --- a/html/includes/forms/alert-templates.inc.php +++ b/html/includes/forms/alert-templates.inc.php @@ -21,6 +21,7 @@ * @package LibreNMS * @subpackage Alerts */ +header('Content-type: text/plain'); if(is_admin() === false) { die('ERROR: You need to be admin'); diff --git a/html/includes/forms/attach-alert-template.inc.php b/html/includes/forms/attach-alert-template.inc.php index 9303b4eaa..b38936255 100644 --- a/html/includes/forms/attach-alert-template.inc.php +++ b/html/includes/forms/attach-alert-template.inc.php @@ -11,6 +11,7 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ +header('Content-type: text/plain'); if (is_admin() === false) { die('ERROR: You need to be admin'); diff --git a/html/includes/forms/delete-alert-rule.inc.php b/html/includes/forms/delete-alert-rule.inc.php index 5c3e15744..78b758f59 100644 --- a/html/includes/forms/delete-alert-rule.inc.php +++ b/html/includes/forms/delete-alert-rule.inc.php @@ -11,6 +11,7 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ +header('Content-type: text/plain'); if (is_admin() === false) { die('ERROR: You need to be admin'); diff --git a/html/includes/forms/delete-alert-template.inc.php b/html/includes/forms/delete-alert-template.inc.php index c700a351a..1892785a3 100644 --- a/html/includes/forms/delete-alert-template.inc.php +++ b/html/includes/forms/delete-alert-template.inc.php @@ -11,6 +11,7 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ +header('Content-type: text/plain'); if (is_admin() === false) { die('ERROR: You need to be admin'); diff --git a/html/includes/forms/parse-alert-map.inc.php b/html/includes/forms/parse-alert-map.inc.php index 075de355b..8ded88953 100644 --- a/html/includes/forms/parse-alert-map.inc.php +++ b/html/includes/forms/parse-alert-map.inc.php @@ -11,6 +11,7 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ +header('Content-type: application/json'); if (is_admin() === false) { die('ERROR: You need to be admin'); diff --git a/html/includes/forms/parse-alert-rule.inc.php b/html/includes/forms/parse-alert-rule.inc.php index 286fb35c8..376776acd 100644 --- a/html/includes/forms/parse-alert-rule.inc.php +++ b/html/includes/forms/parse-alert-rule.inc.php @@ -11,6 +11,7 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ +header('Content-type: application/json'); if (is_admin() === false) { die('ERROR: You need to be admin'); diff --git a/html/includes/forms/parse-alert-template.inc.php b/html/includes/forms/parse-alert-template.inc.php index 2b8bb2e56..08eb2ba1b 100644 --- a/html/includes/forms/parse-alert-template.inc.php +++ b/html/includes/forms/parse-alert-template.inc.php @@ -11,6 +11,7 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ +header('Content-type: application/json'); if (is_admin() === false) { die('ERROR: You need to be admin'); diff --git a/html/includes/forms/sensor-alert-reset.inc.php b/html/includes/forms/sensor-alert-reset.inc.php index 2c027e647..46c1fc976 100644 --- a/html/includes/forms/sensor-alert-reset.inc.php +++ b/html/includes/forms/sensor-alert-reset.inc.php @@ -11,6 +11,7 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ +header('Content-type: text/plain'); // FUA diff --git a/html/includes/forms/sensor-alert-update.inc.php b/html/includes/forms/sensor-alert-update.inc.php index 16c5742a6..d03024480 100644 --- a/html/includes/forms/sensor-alert-update.inc.php +++ b/html/includes/forms/sensor-alert-update.inc.php @@ -11,6 +11,7 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ +header('Content-type: text/plain'); // FUA diff --git a/html/includes/forms/update-alert-rule.inc.php b/html/includes/forms/update-alert-rule.inc.php index 261e30062..1bd575081 100644 --- a/html/includes/forms/update-alert-rule.inc.php +++ b/html/includes/forms/update-alert-rule.inc.php @@ -11,6 +11,7 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ +header('Content-type: text/plain'); if (is_admin() === false) { die('ERROR: You need to be admin'); From 71a57b6214a5232557ab81ca6d08dc8636954053 Mon Sep 17 00:00:00 2001 From: pblasquez Date: Thu, 28 Apr 2016 14:30:03 -0700 Subject: [PATCH 2/2] Allow for separate headers upon conditional --- html/includes/forms/parse-alert-map.inc.php | 3 ++- html/includes/forms/parse-alert-rule.inc.php | 3 ++- html/includes/forms/parse-alert-template.inc.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/html/includes/forms/parse-alert-map.inc.php b/html/includes/forms/parse-alert-map.inc.php index 8ded88953..877ad16ca 100644 --- a/html/includes/forms/parse-alert-map.inc.php +++ b/html/includes/forms/parse-alert-map.inc.php @@ -11,9 +11,9 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ -header('Content-type: application/json'); if (is_admin() === false) { + header('Content-type: text/plain'); die('ERROR: You need to be admin'); } @@ -32,5 +32,6 @@ if (is_numeric($map_id) && $map_id > 0) { 'rule' => $map['name'], 'target' => $map['target'], ); + header('Content-type: application/json'); echo _json_encode($output); } diff --git a/html/includes/forms/parse-alert-rule.inc.php b/html/includes/forms/parse-alert-rule.inc.php index 376776acd..4372303bf 100644 --- a/html/includes/forms/parse-alert-rule.inc.php +++ b/html/includes/forms/parse-alert-rule.inc.php @@ -11,9 +11,9 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ -header('Content-type: application/json'); if (is_admin() === false) { + header('Content-type: text/plain'); die('ERROR: You need to be admin'); } @@ -30,5 +30,6 @@ if (is_numeric($alert_id) && $alert_id > 0) { 'name' => $rule['name'], 'rules' => $rule_split, ); + header('Content-type: application/json'); echo _json_encode($output); } diff --git a/html/includes/forms/parse-alert-template.inc.php b/html/includes/forms/parse-alert-template.inc.php index 08eb2ba1b..dd04ec575 100644 --- a/html/includes/forms/parse-alert-template.inc.php +++ b/html/includes/forms/parse-alert-template.inc.php @@ -11,9 +11,9 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ -header('Content-type: application/json'); if (is_admin() === false) { + header('Content-type: text/plain'); die('ERROR: You need to be admin'); } @@ -27,5 +27,6 @@ if (is_numeric($template_id) && $template_id > 0) { 'title' => $template['title'], 'title_rec' => $template['title_rec'], ); + header('Content-type: application/json'); echo _json_encode($output); }