From 38c86a2b41f9fded013c4f32a5e6588c8fcddd7c Mon Sep 17 00:00:00 2001 From: gfjardim Date: Tue, 14 Jan 2020 11:29:10 -0300 Subject: [PATCH 1/2] Use php json_encode to properly encode notifications --- plugins/dynamix/include/DefaultPageLayout.php | 3 +-- plugins/dynamix/scripts/notify | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/dynamix/include/DefaultPageLayout.php b/plugins/dynamix/include/DefaultPageLayout.php index 7932532f5..60bda900b 100644 --- a/plugins/dynamix/include/DefaultPageLayout.php +++ b/plugins/dynamix/include/DefaultPageLayout.php @@ -299,8 +299,7 @@ function notifier() { var tub1 = 0, tub2 = 0, tub3 = 0; $.post('/webGui/include/Notify.php',{cmd:'get'},function(json) { var data = $.parseJSON(json); - $.each(data, function(i, object) { - var notify = $.parseJSON(object); + $.each(data, function(i, notify) { switch (notify.importance) { case 'alert' : tub1++; break; diff --git a/plugins/dynamix/scripts/notify b/plugins/dynamix/scripts/notify index 7729263de..85bcdbc7c 100755 --- a/plugins/dynamix/scripts/notify +++ b/plugins/dynamix/scripts/notify @@ -218,13 +218,12 @@ case 'get': if (!$field) continue; list($key,$val) = explode('=', $field); if ($time) {$val = date($notify['date'].' '.$notify['time'], $val); $time = false;} - $output[$i][] = '\"'.trim($key).'\":\"'.trim($val).'\"'; + $output[$i][trim($key)] = trim($val); } - $output[$i++][] = '\"file\":\"'.basename($file).'\"'; + $output[$i++]["file"] = basename($file); chmod($file,0000); } - for ($n=0; $n<$i; $n++) $json[] = '"{'.implode(',', $output[$n]).'}"'; - echo '['.implode(',', $json).']'; + echo json_encode($output, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); break; case 'archive': From 9d453015126f643f1fe5f4bb5512ed95305e0e0e Mon Sep 17 00:00:00 2001 From: gfjardim Date: Tue, 14 Jan 2020 11:51:55 -0300 Subject: [PATCH 2/2] Use php json_encode to properly encode notifications - 2 --- plugins/dynamix/include/DefaultPageLayout.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/dynamix/include/DefaultPageLayout.php b/plugins/dynamix/include/DefaultPageLayout.php index 60bda900b..b638f1c6e 100644 --- a/plugins/dynamix/include/DefaultPageLayout.php +++ b/plugins/dynamix/include/DefaultPageLayout.php @@ -335,8 +335,7 @@ function digits(number) { function openNotifier(filter) { $.post('/webGui/include/Notify.php',{cmd:'get'},function(json) { var data = $.parseJSON(json); - $.each(data, function(i, object) { - var notify = $.parseJSON(object); + $.each(data, function(i, notify) { if (notify.importance == filter) { $.jGrowl(notify.subject+'
'+notify.description, { group: notify.importance, @@ -353,8 +352,7 @@ function closeNotifier(filter) { clearTimeout(timers.notifier); $.post('/webGui/include/Notify.php',{cmd:'get'},function(json) { var data = $.parseJSON(json); - $.each(data, function(i, object) { - var notify = $.parseJSON(object); + $.each(data, function(i, notify) { if (notify.importance == filter) $.post('/webGui/include/Notify.php',{cmd:'archive',file:notify.file}); }); $('div.jGrowl').find('.'+filter).find('div.jGrowl-close').trigger('click');