From 6a5538346a91ff936bfbfc2c17e83122d017080b Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 5 Jul 2016 16:53:40 +0200 Subject: [PATCH] Added audit log. Tciket #3714. --- pandora_console/godmode/setup/setup_general.php | 9 +++------ pandora_console/include/functions_config.php | 6 ++++++ pandora_console/include/functions_db.php | 10 +++++++++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index f8b054be3e..4e547143d5 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -280,13 +280,10 @@ $table->data[34][1] = html_print_input_text('limit_parameters_massive', $table->data[35][0] = __('Include agents manually disabled'); $table->data[35][1] = __('Yes').'   '.html_print_radio_button ('include_agents', 1, '', $config["include_agents"], true).'  '; $table->data[35][1] .= __('No').'   '.html_print_radio_button ('include_agents', 0, '', $config["include_agents"], true); - /*$row = array(); - $row[0] = __('Include agents'); - $row[1] = __('Yes') . '   ' . html_print_radio_button ('include_agents', 1, '', $config["include_agents"], true) . '  '; - $row[1] .= __('No') . '   ' . html_print_radio_button ('include_agents', 0, '', $config["include_agents"], true); - - $data['include_agents'] = $row;*/ +$table->data[36][0] = __('audit log directory') . + ui_print_help_tip (__("Directory where audit log is stored."), true); +$table->data[36][1] = html_print_input_text ('auditdir', io_safe_output($config["auditdir"]), '', 30, 100, true); echo '
'; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 7701809f36..853c736301 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -205,6 +205,8 @@ function config_update_config () { $error_update[] = __('Identification_reminder'); if (!config_update_value ('include_agents', (bool)get_parameter('include_agents'))) $error_update[] = __('Include_agents'); + if (!config_update_value ('auditdir', get_parameter('auditdir'))) + $error_update[] = __('Audit log directory'); break; case 'enterprise': if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { @@ -908,6 +910,10 @@ function config_process_config () { config_update_value ('include_agents', 0); } + if (!isset ($config["auditdir"])) { + config_update_value ('auditdir',"/var/www/html/pandora_console"); + } + if (!isset ($config["log_dir"])) { if ($is_windows) $default = 'C:\\PandoraFMS\\Pandora_Server\\data_in\\log'; diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index d8b469cdc9..7c686842b4 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -191,7 +191,15 @@ function db_pandora_audit($accion, $descripcion, $user_id = false, $ip = true, $ break; } $id_audit = db_process_sql_insert('tsesion', $values); - + + $valor = "".$values['fecha']." - ".io_safe_output($id)." - ".io_safe_output($accion)." - ".$ip. " - ".io_safe_output($descripcion)."\n"; + + if(empty($config["auditdir"])){ + file_put_contents($config["homedir"]."/audit.log", $valor, FILE_APPEND); + }else{ + file_put_contents($config["auditdir"]."/audit.log", $valor, FILE_APPEND); + } + enterprise_include_once('include/functions_audit.php'); enterprise_hook('audit_pandora_enterprise', array($id_audit, $info));