From fdc6d2f4c8ad459256d5d98a0a76aee0e8de8c5d Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Tue, 8 Jun 2021 16:09:37 +0200 Subject: [PATCH 01/40] implemented capacity to handle string data for event data --- pandora_console/extras/mr/48.sql | 6 ++++++ .../extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 3 +++ pandora_console/operation/events/events.php | 10 ++++++---- pandora_console/pandoradb.sql | 4 ++-- pandora_server/lib/PandoraFMS/Core.pm | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 pandora_console/extras/mr/48.sql diff --git a/pandora_console/extras/mr/48.sql b/pandora_console/extras/mr/48.sql new file mode 100644 index 0000000000..63a85e8d3c --- /dev/null +++ b/pandora_console/extras/mr/48.sql @@ -0,0 +1,6 @@ +START TRANSACTION; + +ALTER TABLE `tevento` MODIFY `data` TINYTEXT default NULL; +ALTER TABLE `tmetaconsole_event` MODIFY `data` TINYTEXT default NULL; + +COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 1335550ef7..aeca7e98cd 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1026,6 +1026,7 @@ ALTER TABLE `tmetaconsole_event` ADD INDEX `tme_timestamp_idx` (`timestamp`); ALTER TABLE `tmetaconsole_event` ADD INDEX `tme_module_status_idx` (`module_status`); ALTER TABLE `tmetaconsole_event` ADD INDEX `tme_criticity_idx` (`criticity`); ALTER TABLE `tmetaconsole_event` ADD INDEX `tme_agent_name_idx` (`agent_name`); +ALTER TABLE `tmetaconsole_event` MODIFY `data` TINYTEXT default NULL; -- --------------------------------------------------------------------- -- Table `tmetaconsole_event_history` @@ -2345,6 +2346,8 @@ ALTER TABLE `tevento` ADD COLUMN `data` double(50,5) default NULL; ALTER TABLE `tevento` ADD COLUMN `module_status` int(4) NOT NULL default '0'; +ALTER TABLE `tevento` MODIFY `data` TINYTEXT default NULL; + -- --------------------------------------------------------------------- -- Table `tevent_extended` -- --------------------------------------------------------------------- diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 9dab979e38..6ea8eed104 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -391,10 +391,12 @@ if (is_ajax()) { true ); - $tmp->data = format_numeric( - $tmp->data, - $config['graph_precision'] - ); + if (is_numeric($tmp->data) === true) { + $tmp->data = format_numeric( + $tmp->data, + $config['graph_precision'] + ); + } $tmp->instructions = events_get_instructions($item); diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index ec7d1a2072..4026b5e78b 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -681,7 +681,7 @@ CREATE TABLE IF NOT EXISTS `tevento` ( `owner_user` VARCHAR(100) NOT NULL DEFAULT '', `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0', `custom_data` TEXT NOT NULL, - `data` double(50,5) default NULL, + `data` tinytext default NULL, `module_status` int(4) NOT NULL default '0', PRIMARY KEY (`id_evento`), KEY `idx_agente` (`id_agente`), @@ -3275,7 +3275,7 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_event` ( `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0', `server_id` int(10) NOT NULL, `custom_data` TEXT NOT NULL DEFAULT '', - `data` double(50,5) default NULL, + `data` tinytext default NULL, `module_status` int(4) NOT NULL default '0', PRIMARY KEY (`id_evento`), KEY `idx_agente` (`id_agente`), diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index bbce7913e9..7144660ac5 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -3655,7 +3655,7 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) { # Create the event logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10); my $event_id = db_insert ($dbh, 'id_evento','INSERT INTO ' . $event_table . ' (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, user_comment, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $comment, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, $module_data, $module_status); + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $comment, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, safe_input($module_data), $module_status); # Do not write to the event file return $event_id if ($pa_config->{'event_file'} eq ''); From 240efc4dcf8fc37fc6a4b3856b104ee935ddafdd Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Tue, 8 Jun 2021 16:48:01 +0200 Subject: [PATCH 02/40] truncate string --- pandora_console/operation/events/events.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 6ea8eed104..69c39537d9 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -396,6 +396,8 @@ if (is_ajax()) { $tmp->data, $config['graph_precision'] ); + } else { + $tmp->data = ui_print_truncate_text($tmp->data, 10); } $tmp->instructions = events_get_instructions($item); From 716c82bd300b9ba3b75f7b7c8c3e11b03edf8f3b Mon Sep 17 00:00:00 2001 From: marcos Date: Wed, 16 Jun 2021 10:41:12 +0200 Subject: [PATCH 03/40] fixed error with pagination user filter --- pandora_console/godmode/users/user_list.php | 40 +++++++++++++-------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index fee1a325c4..aa9421c0e3 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -112,6 +112,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Nothing to do. + break; } break; @@ -132,6 +136,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Nothing to do. + break; } break; @@ -152,6 +160,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Nothing to do. + break; } break; @@ -171,7 +183,7 @@ switch ($sortField) { $buttons[$tab]['active'] = true; -// Header +// Header. if (defined('METACONSOLE')) { user_meta_print_header(); $sec = 'advanced'; @@ -234,9 +246,9 @@ if (defined('METACONSOLE')) { $disable_user = get_parameter('disable_user', false); if ((bool) get_parameter('user_del', false) === true) { - // delete user + // Delete user. $id_user = get_parameter('delete_user', 0); - // Only allow delete user if is not the actual user + // Only allow delete user if is not the actual user. if ($id_user != $config['id_user']) { $user_row = users_get_user_by_id($id_user); @@ -255,13 +267,13 @@ if ((bool) get_parameter('user_del', false) === true) { __('There was a problem deleting the user') ); - // Delete the user in all the consoles + // Delete the user in all the consoles. if (defined('METACONSOLE') && isset($_GET['delete_all'])) { $servers = metaconsole_get_servers(); foreach ($servers as $server) { // Connect to the remote console. if (metaconsole_connect($server) === NOERR) { - // Delete the user + // Delete the user. $result = delete_user($id_user); if ($result) { db_pandora_audit( @@ -274,7 +286,7 @@ if ((bool) get_parameter('user_del', false) === true) { metaconsole_restore_db(); } - // Log to the metaconsole too + // Log to the metaconsole too. if ($result) { db_pandora_audit( 'User management', @@ -293,7 +305,7 @@ if ((bool) get_parameter('user_del', false) === true) { ui_print_error_message(__('There was a problem deleting the user')); } } else if (isset($_GET['profile_del'])) { - // delete profile + // Delete profile. $id_profile = (int) get_parameter_post('delete_profile'); $result = profile_delete_profile($id_profile); ui_print_result_message( @@ -302,7 +314,7 @@ if ((bool) get_parameter('user_del', false) === true) { __('There was a problem deleting the profile') ); } else if ($disable_user !== false) { - // disable_user + // Disable_user. $id_user = get_parameter('id', 0); if ($id_user !== 0) { @@ -457,7 +469,7 @@ if ($user_is_admin) { } } -// Filter the users +// Filter the users. if ($search) { foreach ($info1 as $iterator => $user_info) { $found = false; @@ -498,7 +510,7 @@ if ($search) { $info = $info1; -// Prepare pagination +// Prepare pagination. ui_pagination(count($info)); $offset = (int) get_parameter('offset'); @@ -537,12 +549,12 @@ foreach ($info as $user_id => $user_info) { $cont++; - // Manual pagination due the complicated process of the ACL data - if ($cont <= $offset) { + // Manual pagination due the complicated process of the ACL data. + if ($cont <= $offset && $search !== true) { continue; } - if ($cont > ($limit + $offset)) { + if ($cont > ($limit + $offset) && $search !== true) { break; } @@ -764,7 +776,7 @@ foreach ($info as $user_id => $user_info) { } } else { $data[6] .= ''; - // Delete button not in this mode + // Delete button not in this mode. } } From 00d4f0c57d0349e165e6bcc31dad3bdfd0fefc9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gonz=C3=A1lez?= Date: Wed, 16 Jun 2021 15:29:28 +0200 Subject: [PATCH 04/40] Clean code and fix issue with lateral main menu --- pandora_console/general/header.php | 7 +- pandora_console/general/main_menu.php | 120 +++++++++++---------- pandora_console/include/config_process.php | 2 +- pandora_console/include/functions_menu.php | 6 +- pandora_console/include/styles/menu.css | 4 +- pandora_console/index.php | 32 +++--- 6 files changed, 90 insertions(+), 81 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 81d51dc749..dedae177cb 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -23,13 +23,8 @@ ui_require_css_file('order_interpreter'); // Global errors/warnings checking. config_check(); +echo sprintf('
', $menuTypeClass); - -if ($config['menu_type'] == 'classic') { - echo '
'; -} else { - echo '
'; -} ?>
$(document).ready(function(){ - var menuType_value = ""; + var menuType_value = ""; - if (menuType_value == 'classic') { + if (menuType_value === 'classic') { $('ul.submenu').css('left', '214px'); } else{ @@ -34,26 +50,22 @@ $(document).ready(function(){ '; -} else { - echo '