From d2be07b49c23a46139b0e953381c2f0fbeb4733b Mon Sep 17 00:00:00 2001 From: pblasquez Date: Tue, 26 Apr 2016 14:47:03 -0700 Subject: [PATCH 1/2] Ajax headers for dashboard/config forms --- html/includes/forms/add-dashboard.inc.php | 1 + html/includes/forms/config-item-disable.inc.php | 1 + html/includes/forms/config-item-update.inc.php | 1 + html/includes/forms/config-item.inc.php | 1 + html/includes/forms/delete-dashboard.inc.php | 1 + html/includes/forms/edit-dashboard.inc.php | 1 + html/includes/forms/override-config.inc.php | 1 + html/includes/forms/update-config-item.inc.php | 1 + html/includes/forms/update-dashboard-config.inc.php | 1 + 9 files changed, 9 insertions(+) diff --git a/html/includes/forms/add-dashboard.inc.php b/html/includes/forms/add-dashboard.inc.php index e34993a6e..109afc698 100644 --- a/html/includes/forms/add-dashboard.inc.php +++ b/html/includes/forms/add-dashboard.inc.php @@ -21,6 +21,7 @@ * @package LibreNMS * @subpackage Dashboards */ +header('Content-type: application/json'); $status = 'error'; $message = 'unknown error'; diff --git a/html/includes/forms/config-item-disable.inc.php b/html/includes/forms/config-item-disable.inc.php index a3475049f..5d44e5f6c 100644 --- a/html/includes/forms/config-item-disable.inc.php +++ b/html/includes/forms/config-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'); // FUA diff --git a/html/includes/forms/config-item-update.inc.php b/html/includes/forms/config-item-update.inc.php index 6f7b40e4e..948daaf45 100644 --- a/html/includes/forms/config-item-update.inc.php +++ b/html/includes/forms/config-item-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/config-item.inc.php b/html/includes/forms/config-item.inc.php index 12fd3c436..f1b6b5d5c 100644 --- a/html/includes/forms/config-item.inc.php +++ b/html/includes/forms/config-item.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) { $response = array( diff --git a/html/includes/forms/delete-dashboard.inc.php b/html/includes/forms/delete-dashboard.inc.php index 2874dec6e..b70b0baf1 100644 --- a/html/includes/forms/delete-dashboard.inc.php +++ b/html/includes/forms/delete-dashboard.inc.php @@ -21,6 +21,7 @@ * @package LibreNMS * @subpackage Dashboards */ +header('Content-type: application/json'); $status = 'error'; $message = 'unknown error'; diff --git a/html/includes/forms/edit-dashboard.inc.php b/html/includes/forms/edit-dashboard.inc.php index fe9d9c527..95c06f853 100644 --- a/html/includes/forms/edit-dashboard.inc.php +++ b/html/includes/forms/edit-dashboard.inc.php @@ -21,6 +21,7 @@ * @package LibreNMS * @subpackage Dashboards */ +header('Content-type: application/json'); $status = 'error'; $message = 'unknown error'; diff --git a/html/includes/forms/override-config.inc.php b/html/includes/forms/override-config.inc.php index 6004710dc..d12de54c7 100644 --- a/html/includes/forms/override-config.inc.php +++ b/html/includes/forms/override-config.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) { $response = array( diff --git a/html/includes/forms/update-config-item.inc.php b/html/includes/forms/update-config-item.inc.php index dff681ceb..2885a2a71 100644 --- a/html/includes/forms/update-config-item.inc.php +++ b/html/includes/forms/update-config-item.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/update-dashboard-config.inc.php b/html/includes/forms/update-dashboard-config.inc.php index e9bdb23db..69dd2e673 100644 --- a/html/includes/forms/update-dashboard-config.inc.php +++ b/html/includes/forms/update-dashboard-config.inc.php @@ -1,4 +1,5 @@ Date: Thu, 28 Apr 2016 14:36:25 -0700 Subject: [PATCH 2/2] Allow for separate headers upon conditional --- html/includes/forms/update-config-item.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/html/includes/forms/update-config-item.inc.php b/html/includes/forms/update-config-item.inc.php index 2885a2a71..b943fbb5c 100644 --- a/html/includes/forms/update-config-item.inc.php +++ b/html/includes/forms/update-config-item.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'); } @@ -100,4 +100,5 @@ $response = array( 'status' => $status, 'message' => $message, ); +header('Content-type: application/json'); echo _json_encode($response);