From 4fc3013cc3b15ef4981a1b5fdcc6688da65585b9 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 24 Jan 2024 09:15:32 +0100 Subject: [PATCH] #12522 fixed multiple audit when update setup --- pandora_console/include/functions_config.php | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 9f4c38aa68..0f552ac519 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -104,6 +104,7 @@ function config_update_value($token, $value, $noticed=false, $password=false) return true; } + $prev_value = $config[$token]; $config[$token] = $value; $value = io_safe_output($value); @@ -117,13 +118,24 @@ function config_update_value($token, $value, $noticed=false, $password=false) return true; } else { // Something in setup changes. - if ($noticed === true) { + $value_token = (empty($config[$token]) === true) ? 0 : $config[$token]; + $prev_value = (empty($prev_value) === true) ? 0 : $prev_value; + if (is_array($prev_value) === true) { + $prev_value = implode(';', $prev_value); + } + + if ($noticed === true && $prev_value !== $value_token) { db_pandora_audit( AUDIT_LOG_SETUP, 'Setup has changed', false, false, - sprintf('Token << %s >> updated.', $token) + sprintf( + 'Token << %s >> updated %s -> %s', + $token, + $prev_value, + $value_token + ) ); } @@ -2090,11 +2102,6 @@ function config_update_config() } else { $config['error_config_update_config'] = []; $config['error_config_update_config']['correct'] = true; - - db_pandora_audit( - AUDIT_LOG_SETUP, - 'Setup has changed' - ); } if (count($errors) > 0) {