From 826cd17c331fea7720e87c43f868abd5bc6016e2 Mon Sep 17 00:00:00 2001 From: pblasquez Date: Tue, 26 Apr 2016 15:13:01 -0700 Subject: [PATCH 1/2] Ajax headers for various --- html/includes/forms/callback-clear.inc.php | 1 + html/includes/forms/callback-statistics.inc.php | 1 + html/includes/forms/notifications.inc.php | 1 + html/includes/forms/parse-template-rules.inc.php | 1 + html/includes/forms/query-ripenccapi.inc.php | 1 + html/includes/forms/schedule-maintenance.inc.php | 1 + html/includes/forms/test-transport.inc.php | 1 + html/includes/forms/token-item-create.inc.php | 1 + html/includes/forms/token-item-disable.inc.php | 1 + html/includes/forms/token-item-remove.inc.php | 1 + html/includes/forms/update-notes.inc.php | 1 + html/includes/forms/widget-settings.inc.php | 1 + 12 files changed, 12 insertions(+) diff --git a/html/includes/forms/callback-clear.inc.php b/html/includes/forms/callback-clear.inc.php index 38d9906393..f0fb775766 100644 --- a/html/includes/forms/callback-clear.inc.php +++ b/html/includes/forms/callback-clear.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/callback-statistics.inc.php b/html/includes/forms/callback-statistics.inc.php index 36a2c4d9d1..1b25df57b1 100644 --- a/html/includes/forms/callback-statistics.inc.php +++ b/html/includes/forms/callback-statistics.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/notifications.inc.php b/html/includes/forms/notifications.inc.php index 187f2ee2c1..71c615085d 100644 --- a/html/includes/forms/notifications.inc.php +++ b/html/includes/forms/notifications.inc.php @@ -21,6 +21,7 @@ * @package LibreNMS * @subpackage Notifications */ +header('Content-type: application/json'); $status = 'error'; $message = 'unknown error'; diff --git a/html/includes/forms/parse-template-rules.inc.php b/html/includes/forms/parse-template-rules.inc.php index b5800b50f0..199daa5598 100644 --- a/html/includes/forms/parse-template-rules.inc.php +++ b/html/includes/forms/parse-template-rules.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/query-ripenccapi.inc.php b/html/includes/forms/query-ripenccapi.inc.php index 0e21b12fe9..e9af57177f 100644 --- a/html/includes/forms/query-ripenccapi.inc.php +++ b/html/includes/forms/query-ripenccapi.inc.php @@ -9,6 +9,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'); $status = 'error'; $message = 'unknown error'; diff --git a/html/includes/forms/schedule-maintenance.inc.php b/html/includes/forms/schedule-maintenance.inc.php index d601116ee1..661c9ba494 100644 --- a/html/includes/forms/schedule-maintenance.inc.php +++ b/html/includes/forms/schedule-maintenance.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/test-transport.inc.php b/html/includes/forms/test-transport.inc.php index 05b4dcfdd9..2486c71ca5 100644 --- a/html/includes/forms/test-transport.inc.php +++ b/html/includes/forms/test-transport.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/token-item-create.inc.php b/html/includes/forms/token-item-create.inc.php index 61810287af..7e573b2ac2 100644 --- a/html/includes/forms/token-item-create.inc.php +++ b/html/includes/forms/token-item-create.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/token-item-disable.inc.php b/html/includes/forms/token-item-disable.inc.php index 1f962c0209..f057961275 100644 --- a/html/includes/forms/token-item-disable.inc.php +++ b/html/includes/forms/token-item-disable.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/token-item-remove.inc.php b/html/includes/forms/token-item-remove.inc.php index 4d494672c0..4c241bedc9 100644 --- a/html/includes/forms/token-item-remove.inc.php +++ b/html/includes/forms/token-item-remove.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/update-notes.inc.php b/html/includes/forms/update-notes.inc.php index 3750e59d91..521a485bf4 100644 --- a/html/includes/forms/update-notes.inc.php +++ b/html/includes/forms/update-notes.inc.php @@ -9,6 +9,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'); $status = 'error'; $message = 'unknown error'; diff --git a/html/includes/forms/widget-settings.inc.php b/html/includes/forms/widget-settings.inc.php index fabe6c4aab..10ed3ad570 100644 --- a/html/includes/forms/widget-settings.inc.php +++ b/html/includes/forms/widget-settings.inc.php @@ -21,6 +21,7 @@ * @package LibreNMS * @subpackage Widgets */ +header('Content-type: application/json'); $status = 'error'; $message = 'unknown error'; From 4cc9203baa073d6b1d8699e5da78152822978163 Mon Sep 17 00:00:00 2001 From: pblasquez Date: Thu, 28 Apr 2016 14:42:06 -0700 Subject: [PATCH 2/2] Allow for separate headers upon conditional --- html/includes/forms/parse-template-rules.inc.php | 3 ++- html/includes/forms/schedule-maintenance.inc.php | 4 ++-- html/includes/forms/test-transport.inc.php | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/html/includes/forms/parse-template-rules.inc.php b/html/includes/forms/parse-template-rules.inc.php index 199daa5598..7211bc2b2c 100644 --- a/html/includes/forms/parse-template-rules.inc.php +++ b/html/includes/forms/parse-template-rules.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'); } @@ -25,5 +25,6 @@ if (is_numeric($template_id) && $template_id > 0) { } $output = array('rule_id' => $rules); + header('Content-type: application/json'); echo _json_encode($output); } diff --git a/html/includes/forms/schedule-maintenance.inc.php b/html/includes/forms/schedule-maintenance.inc.php index 661c9ba494..40a39e6137 100644 --- a/html/includes/forms/schedule-maintenance.inc.php +++ b/html/includes/forms/schedule-maintenance.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'); } @@ -129,5 +129,5 @@ else if ($sub_type == 'del-maintenance') { 'message' => $message, ); }//end if - +header('Content-type: application/json'); echo _json_encode($response); diff --git a/html/includes/forms/test-transport.inc.php b/html/includes/forms/test-transport.inc.php index 2486c71ca5..81da4e40bb 100644 --- a/html/includes/forms/test-transport.inc.php +++ b/html/includes/forms/test-transport.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'); } @@ -51,5 +51,5 @@ if (file_exists($config['install_dir']."/includes/alerts/transport.".$transport. } } } - +header('Content-type: application/json'); echo _json_encode(array('status' => $status));