From b7bd2894576ff4a79aeb1cf98cabfe4209460983 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Thu, 25 Jan 2024 12:06:27 +0100 Subject: [PATCH 01/26] Generate an event when there are too many XML data files queued for an agent. --- pandora_server/conf/pandora_server.conf.new | 3 ++ pandora_server/lib/PandoraFMS/Config.pm | 5 ++++ pandora_server/lib/PandoraFMS/DataServer.pm | 31 +++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index bddb11a293..15095c78be 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -816,3 +816,6 @@ madeserver_autofit 7d # Model sensitivity. A lower value triggers less anomalies (PANDORA FMS ENTERPRISE ONLY). madeserver_sensitivity 0.1 +# If greater than 0, generate an event when more than the specified number of XML data files are queued for an agent. +too_many_xml 10 + diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index eb23fcce89..2f48005c2f 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -589,6 +589,8 @@ sub pandora_load_config { $pa_config->{"madeserver"} = 0; # 774. + $pa_config->{"too_many_xml"} = 10; # 776. + # Check for UID0 if ($pa_config->{"quiet"} != 0){ if ($> == 0){ @@ -1412,6 +1414,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^madeserver\s+([0-1])/i){ $pa_config->{'madeserver'}= clean_blank($1); } + elsif ($parametro =~ m/^too_many_xml\s+([0-9]*)/i){ + $pa_config->{'too_many_xml'}= clean_blank($1); + } } # end of loop for parameter # # The DB host was overridden by pandora_ha. diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 80e8bb4bd3..d771d511c2 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -56,6 +56,7 @@ our @ISA = qw(PandoraFMS::ProducerConsumerServer); my @TaskQueue :shared; my %PendingTasks :shared; my %Agents :shared; +my %AgentCounts; my $Sem :shared; my $TaskSem :shared; my $AgentSem :shared; @@ -73,6 +74,7 @@ sub new ($$;$) { @TaskQueue = (); %PendingTasks = (); %Agents = (); + %AgentCounts = (); $Sem = Thread::Semaphore->new; $TaskSem = Thread::Semaphore->new (0); $AgentSem = Thread::Semaphore->new (1); @@ -142,6 +144,9 @@ sub data_producer ($) { opendir (DIR, $pa_config->{'incomingdir'}) || die "[FATAL] Cannot open Incoming data directory at " . $pa_config->{'incomingdir'} . ": $!"; + # Reset agent XML file counts + %AgentCounts = (); + # Do not read more than max_queue_files files my $file_count = 0; while (my $file = readdir (DIR)) { @@ -177,11 +182,21 @@ sub data_producer ($) { next if ($file !~ /^(.*)[\._]\d+\.data$/); my $agent_name = $1; + $AgentCounts{$agent_name} = defined($AgentCounts{$agent_name}) ? $AgentCounts{$agent_name} + 1 : 1; next if (agent_lock($pa_config, $dbh, $agent_name) == 0); push (@tasks, $file); } + # Generate an event if there are too many XML files for a given agent. + if ($pa_config->{'too_many_xml'} > 0) { + while (my ($agent_name, $xml_count) = each(%AgentCounts)) { + if ($xml_count > $pa_config->{'too_many_xml'}) { + pandora_timed_event(300, $pa_config, "Too many XML files for agent $agent_name ($xml_count)", 0, 0, 0, 0, 0, 'warning', 0, $dbh); + } + } + } + return @tasks; } @@ -200,6 +215,9 @@ sub data_producer_smart_queue ($) { opendir (DIR, $pa_config->{'incomingdir'}) || die "[FATAL] Cannot open Incoming data directory at " . $pa_config->{'incomingdir'} . ": $!"; + # Reset agent XML file counts + %AgentCounts = (); + # Do not read more than max_queue_files files my $smart_queue = {}; while (my $file = readdir (DIR)) { @@ -209,6 +227,9 @@ sub data_producer_smart_queue ($) { next if ($file !~ /^(.*)[\._]\d+\.data$/); my $agent_name = $1; + # Update per agent XML counts. + $AgentCounts{$agent_name} = defined($AgentCounts{$agent_name}) ? $AgentCounts{$agent_name} + 1 : 1; + # Queue a new file. if (!defined($smart_queue->{$agent_name})) { $smart_queue->{$agent_name} = $file; @@ -229,6 +250,16 @@ sub data_producer_smart_queue ($) { push (@tasks, $file); } + # Generate an event if there are too many XML files for a given agent. + if ($pa_config->{'too_many_xml'} > 0) { + while (my ($agent_name, $xml_count) = each(%AgentCounts)) { + print ">>> AGENT: $agent_name COUNT: $xml_count\n"; + if ($xml_count > $pa_config->{'too_many_xml'}) { + pandora_timed_event(300, $pa_config, "Too many XML files for agent $agent_name ($xml_count)", 0, 0, 0, 0, 0, 'warning', 0, $dbh); + } + } + } + return @tasks; } From f2a15061f0bcb2b8ecf2e1afb9b646c825c38930 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 7 Feb 2024 15:39:23 +0100 Subject: [PATCH 02/26] #12783 check if module is use by agent for safe mode before delete --- .../godmode/agentes/configurar_agente.php | 6 +++++ pandora_console/include/functions_modules.php | 25 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index c2e3a2f4f6..a2372a66f0 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -2318,6 +2318,12 @@ if ($delete_module) { exit; } + // Check if module is used by agent for Safe mode. + $is_safe_mode_module = modules_check_safe_mode($id_borrar_modulo); + if ($is_safe_mode_module === true) { + db_process_sql_update('tagente', ['safe_mode_module' => '0'], ['id_agente' => $id_agente]); + } + // Before delete the main module, check and delete the childrens from the original module. module_check_childrens_and_delete($id_borrar_modulo); diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 2d3b5676ec..91f6ffc5d1 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -5074,3 +5074,28 @@ function modules_made_compatible($id_tipo_modulo) return true; } } + + +/** + * Check if module is used by agent for Safe mode. + * + * @param integer $id_module Id for module to check + * + * @return boolean + */ +function modules_check_safe_mode($id_module) +{ + $id_agent = modules_give_agent_id_from_module_id($id_module); + if ($id_agent === 0) { + // No exist agent with this id. + return false; + } + + $agent = agents_get_agent($id_agent); + + if (isset($agent['safe_mode_module']) === true && (int) $agent['safe_mode_module'] === (int) $id_module) { + return true; + } else { + return false; + } +} From 2246fd8049e9e1781d8d273f8782f5a41697c4b9 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 7 Feb 2024 16:39:33 +0100 Subject: [PATCH 03/26] #12695 WIP warnings --- pandora_console/general/header.php | 4 + pandora_console/general/noaccess.php | 8 +- pandora_console/godmode/menu.php | 10 ++- .../wizards/ManageExtensions.class.php | 3 +- .../class/ExtensionsDiscovery.class.php | 3 +- .../include/class/WelcomeWindow.class.php | 12 ++- pandora_console/include/functions_graph.php | 12 +-- .../include/functions_register.php | 2 +- pandora_console/include/functions_reports.php | 2 +- pandora_console/include/functions_ui.php | 26 +++--- pandora_console/include/graphs/fgraph.php | 6 +- .../lib/TacticalView/GeneralTacticalView.php | 8 +- .../lib/TacticalView/elements/Agents.php | 1 + .../lib/TacticalView/elements/Events.php | 3 +- .../lib/TacticalView/elements/Groups.php | 3 + .../elements/MonitoringElements.php | 15 ++-- .../elements/ScheduledDowntime.php | 82 ++++++++++--------- pandora_console/index.php | 4 + pandora_console/operation/events/events.php | 13 ++- .../views/dashboard/tipsWindow.php | 6 +- 20 files changed, 135 insertions(+), 88 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 35b994fead..0110e745ae 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -161,6 +161,10 @@ echo sprintf('
', $menuTypeClass); 'code' => false, ]; + if (isset($_GET['sec']) === false) { + $_GET['sec'] = ''; + } + if (!isset($_GET['sec2'])) { $_GET['sec2'] = ''; } diff --git a/pandora_console/general/noaccess.php b/pandora_console/general/noaccess.php index b2fe4515a2..9299489864 100644 --- a/pandora_console/general/noaccess.php +++ b/pandora_console/general/noaccess.php @@ -152,9 +152,11 @@ echo __('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance.'); echo '

'; echo __('Please know that all attempts to access this page are recorded in security logs of %s System Database', get_product_name()); - if ($config['logged'] == false) { - if (session_status() === PHP_SESSION_ACTIVE) { - session_destroy(); + if (isset($config['logged']) === true) { + if ($config['logged'] == false) { + if (session_status() === PHP_SESSION_ACTIVE) { + session_destroy(); + } } } ?> diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 3505e7cf2c..db8d1132c3 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -521,10 +521,12 @@ if ($access_console_node === true) { if ((bool) check_acl($config['id_user'], 0, 'AW') === true) { $show_ipam = false; $ipam = db_get_all_rows_sql('SELECT users_operator FROM tipam_network'); - foreach ($ipam as $row) { - if (str_contains($row['users_operator'], '-1') || str_contains($row['users_operator'], $config['id_user'])) { - $show_ipam = true; - break; + if ($ipam !== false) { + foreach ($ipam as $row) { + if (str_contains($row['users_operator'], '-1') || str_contains($row['users_operator'], $config['id_user'])) { + $show_ipam = true; + break; + } } } } diff --git a/pandora_console/godmode/wizards/ManageExtensions.class.php b/pandora_console/godmode/wizards/ManageExtensions.class.php index 34c9950bc6..deb2a4dbf5 100644 --- a/pandora_console/godmode/wizards/ManageExtensions.class.php +++ b/pandora_console/godmode/wizards/ManageExtensions.class.php @@ -214,7 +214,8 @@ class ManageExtensions extends HTML break; default: - continue; + // Nothing. + break; } } diff --git a/pandora_console/include/class/ExtensionsDiscovery.class.php b/pandora_console/include/class/ExtensionsDiscovery.class.php index b9b5d0ebf2..f132cc160f 100644 --- a/pandora_console/include/class/ExtensionsDiscovery.class.php +++ b/pandora_console/include/class/ExtensionsDiscovery.class.php @@ -2190,7 +2190,8 @@ class ExtensionsDiscovery extends Wizard break; default: - continue; + // Nothing. + break; } if ($value !== false) { diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 4a157540c5..ba9c89e350 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -376,10 +376,6 @@ class WelcomeWindow extends Wizard 'class' => 'modal', ]; - if (enterprise_installed() === true) { - $logo_url = ENTERPRISE_DIR.'/'.$logo_url; - } - if (check_acl($config['id_user'], 0, 'PM')) { $flag_um = false; $flag_cm = false; @@ -768,6 +764,10 @@ class WelcomeWindow extends Wizard ], true ); + if (isset($agents_num) === false) { + $agents_num = ''; + } + echo html_print_label_input_block( __('Number of agents to be created'), html_print_div( @@ -893,6 +893,10 @@ class WelcomeWindow extends Wizard __('Agent'), ui_print_agent_autocomplete_input($params) ); + if (isset($modules) === false) { + $modules = ''; + } + echo html_print_label_input_block( __('Module'), html_print_select( diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index f713f68ee0..ce8a10527c 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4701,11 +4701,13 @@ function graph_nodata_image($options) { global $config; - if ($options['base64'] === true) { - $dataImg = file_get_contents( - $config['homedir'].'/images/image_problem_area_150.png' - ); - return base64_encode($dataImg); + if (isset($options['base64']) === true) { + if ($options['base64'] === true) { + $dataImg = file_get_contents( + $config['homedir'].'/images/image_problem_area_150.png' + ); + return base64_encode($dataImg); + } } $style = ''; diff --git a/pandora_console/include/functions_register.php b/pandora_console/include/functions_register.php index db1bc8bf21..6b1d6ec0a7 100644 --- a/pandora_console/include/functions_register.php +++ b/pandora_console/include/functions_register.php @@ -144,7 +144,7 @@ function config_wiz_modal( 'UTC' => __('UTC'), ]; - if ($zone_selected == '') { + if (isset($zone_selected) === false) { if ($config['timezone'] != '') { $zone_array = explode('/', $config['timezone']); $zone_selected = $zone_array[0]; diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index bb9f57f5c3..c8e774acc7 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -1435,7 +1435,7 @@ function custom_fields_macros_report($macro, $key_macro) $macro['server_id'] ); if (metaconsole_connect($server) != NOERR) { - continue; + break; } } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 09803c43c6..bcf23c6d71 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -4004,19 +4004,21 @@ function ui_print_datatable(array $parameters) $parameters['order']['order'] = $order; $parameters['order']['direction'] = $direction; - foreach ($parameters['no_sortable_columns'] as $key => $find) { - $found = array_search( - $parameters['no_sortable_columns'][$key], - $columns_tmp - ); + if (isset($parameters['no_sortable_columns']) === true) { + foreach ($parameters['no_sortable_columns'] as $key => $find) { + $found = array_search( + $parameters['no_sortable_columns'][$key], + $columns_tmp + ); - if ($found !== false) { - unset($parameters['no_sortable_columns'][$key]); - array_push($parameters['no_sortable_columns'], $found); - } + if ($found !== false) { + unset($parameters['no_sortable_columns'][$key]); + array_push($parameters['no_sortable_columns'], $found); + } - if (is_int($parameters['no_sortable_columns'][$key]) === false) { - unset($parameters['no_sortable_columns'][$key]); + if (is_int($parameters['no_sortable_columns'][$key]) === false) { + unset($parameters['no_sortable_columns'][$key]); + } } } @@ -4234,7 +4236,7 @@ function ui_print_datatable(array $parameters) } $parameters['phpDate'] = date('Y-m-d'); - $parameters['dataElements'] = json_encode($parameters['data_element']); + $parameters['dataElements'] = (isset($parameters['data_element']) === true) ? json_encode($parameters['data_element']) : ''; // * START JAVASCRIPT. $file_path = $config['homedir'].'/include/javascript/datatablesFunction.js'; diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index d8db7d64d9..5861f67033 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -1355,12 +1355,12 @@ function get_build_setup_charts($type, $options, $data) $chart->labels()->exchangeArray($options['labels']); foreach ($data as $key => $dataset) { $dataSet = $chart->createDataSet(); - $dataSet->setLabel($dataset['label']); + $dataSet->setLabel((isset($dataset['label']) === true) ? $dataset['label'] : ''); $dataSet->setBackgroundColor($dataset['backgroundColor']); $dataSet->setBorderColor($dataset['borderColor']); $dataSet->setPointBackgroundColor($dataset['pointBackgroundColor']); - $dataSet->setPointBorderColor($dataset['pointBorderColor']); - $dataSet->setPointHoverBackgroundColor($dataset['pointHoverBackgroundColor']); + $dataSet->setPointBorderColor((isset($dataset['pointBorderColor']) === true) ? $dataset['pointBorderColor'] : ''); + $dataSet->setPointHoverBackgroundColor((isset($dataset['pointHoverBackgroundColor']) === true) ? $dataset['pointHoverBackgroundColor'] : ''); $dataSet->setPointHoverBorderColor($dataset['pointHoverBorderColor']); $dataSet->data()->exchangeArray($dataset['data']); $chart->addDataSet($dataSet); diff --git a/pandora_console/include/lib/TacticalView/GeneralTacticalView.php b/pandora_console/include/lib/TacticalView/GeneralTacticalView.php index 06e27e4fd6..02f60f8252 100644 --- a/pandora_console/include/lib/TacticalView/GeneralTacticalView.php +++ b/pandora_console/include/lib/TacticalView/GeneralTacticalView.php @@ -144,9 +144,11 @@ class GeneralTacticalView { $js = ''; $output .= '
'; @@ -58,7 +62,7 @@ if ($files !== false) { } } -if ($files64 !== false) { +if (isset($files64) === true) { foreach ($files64 as $key => $file) { $output .= ''; } From 9084a34514c4738b3791e559b8f33f30ba38ef12 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 8 Feb 2024 12:31:55 +0100 Subject: [PATCH 04/26] #12695 wip removing warnings --- pandora_console/extensions/quick_shell.php | 39 +++++++++++++++++++ .../godmode/agentes/agent_manager.php | 1 + pandora_console/godmode/setup/setup.php | 16 +++++--- pandora_console/godmode/setup/setup_ITSM.php | 4 ++ pandora_console/godmode/setup/setup_auth.php | 4 +- .../godmode/setup/setup_ehorus.php | 12 ++++++ .../godmode/setup/setup_general.php | 12 ++++++ .../godmode/setup/welcome_tips.php | 2 + .../godmode/snmpconsole/snmp_filters.php | 6 ++- .../godmode/users/configure_user.php | 13 ++++++- .../godmode/users/user_management.php | 24 ++++++------ .../include/class/TipsWindow.class.php | 4 +- .../include/functions_filemanager.php | 6 ++- pandora_console/include/lib/ITSM/ITSM.php | 3 ++ .../lib/TacticalView/elements/Database.php | 8 ++++ pandora_console/index.php | 4 ++ .../views/dashboard/tipsWindow.php | 10 ++++- 17 files changed, 140 insertions(+), 28 deletions(-) diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php index 9ea79ba364..2f45e19606 100644 --- a/pandora_console/extensions/quick_shell.php +++ b/pandora_console/extensions/quick_shell.php @@ -273,6 +273,14 @@ function buildConnectionURL($method) { global $config; + if (isset($config['gotty_ssh_use_ssl']) === false) { + $config['gotty_ssh_use_ssl'] = ''; + } + + if (isset($config['gotty_telnet_use_ssl']) === false) { + $config['gotty_telnet_use_ssl'] = ''; + } + $address = (empty($config['gotty_addr']) === true) ? $_SERVER['SERVER_ADDR'] : $config['gotty_addr']; $use_ssl = ($method === 'ssh') ? $config['gotty_ssh_use_ssl'] : $config['gotty_telnet_use_ssl']; $protocol = ((bool) $use_ssl === true) ? 'https://' : 'http://'; @@ -353,6 +361,18 @@ function quickShellSettings() config_update_value('gotty_telnet_enabled', $gotty_telnet_enabled); } + if (isset($config['gotty_addr']) === false) { + $config['gotty_addr'] = ''; + } + + if (isset($config['gotty_ssh_use_ssl']) === false) { + $config['gotty_ssh_use_ssl'] = ''; + } + + if (isset($config['gotty_telnet_use_ssl']) === false) { + $config['gotty_telnet_use_ssl'] = ''; + } + if ($config['gotty_addr'] != $gotty_addr) { config_update_value('gotty_addr', $gotty_addr); } @@ -389,6 +409,25 @@ function quickShellSettings() $general_table->data = []; $general_table->style = []; $general_table->style[0] = 'width: 50%;'; + if (isset($config['gotty_addr']) === false) { + $config['gotty_addr'] = ''; + } + + if (isset($config['gotty_ssh_enabled']) === false) { + $config['gotty_ssh_enabled'] = ''; + } + + if (isset($config['gotty_ssh_use_ssl']) === false) { + $config['gotty_ssh_use_ssl'] = ''; + } + + if (isset($disable_agentaccess) === false) { + $disable_agentaccess = ''; + } + + if (isset($config['gotty_telnet_use_ssl']) === false) { + $config['gotty_telnet_use_ssl'] = ''; + } $general_table->data[0][] = html_print_label_input_block( __('Address'), diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 283610e06a..fe44b479a9 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -246,6 +246,7 @@ if ($new_agent === true) { // QR Code table. +$CodeQRContent = ''; if ($new_agent === false) { $CodeQRContent .= html_print_div(['id' => 'qr_container_image'], true); $CodeQRContent .= html_print_anchor( diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index df6dcc1eb6..1db1d922e3 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -413,15 +413,19 @@ if (isset($config['error_config_update_config'])) { ui_print_success_message(__('Correct update the setup options')); } - if (is_array($config['error_config_update_config']['errors']) === true) { - foreach ($config['error_config_update_config']['errors'] as $msg) { - ui_print_error_message($msg); + if (isset($config['error_config_update_config']['errors']) === true) { + if (is_array($config['error_config_update_config']['errors']) === true) { + foreach ($config['error_config_update_config']['errors'] as $msg) { + ui_print_error_message($msg); + } } } - if (is_array($config['error_config_update_config']['warnings']) === true) { - foreach ($config['error_config_update_config']['warnings'] as $msg) { - ui_print_warning_message($msg); + if (isset($config['error_config_update_config']['warnings']) === true) { + if (is_array($config['error_config_update_config']['warnings']) === true) { + foreach ($config['error_config_update_config']['warnings'] as $msg) { + ui_print_warning_message($msg); + } } } diff --git a/pandora_console/godmode/setup/setup_ITSM.php b/pandora_console/godmode/setup/setup_ITSM.php index 313e6763c0..899a73a985 100644 --- a/pandora_console/godmode/setup/setup_ITSM.php +++ b/pandora_console/godmode/setup/setup_ITSM.php @@ -137,6 +137,10 @@ $row['hostname'] = html_print_label_input_block( ['div_class' => 'ITSM-remote-setup-ITSM_hostname'] ); +if (isset($config['ITSM_token']) === false) { + $config['ITSM_token'] = ''; +} + // ITSM token. $row['password'] = html_print_label_input_block( __('Token'), diff --git a/pandora_console/godmode/setup/setup_auth.php b/pandora_console/godmode/setup/setup_auth.php index f9f2afcd14..df4d75d6aa 100644 --- a/pandora_console/godmode/setup/setup_auth.php +++ b/pandora_console/godmode/setup/setup_auth.php @@ -390,7 +390,7 @@ if (is_ajax() === true) { set_unless_defined($config['double_auth_enabled'], false); $row = []; $row['name'] = __('Double authentication'); - $row['control'] .= html_print_checkbox_switch( + $row['control'] = html_print_checkbox_switch( 'double_auth_enabled', 1, $config['double_auth_enabled'], @@ -405,7 +405,7 @@ if (is_ajax() === true) { set_unless_defined($config['2FA_all_users'], false); $row = []; $row['name'] = __('Force 2FA for all users is enabled'); - $row['control'] .= html_print_checkbox_switch( + $row['control'] = html_print_checkbox_switch( '2FA_all_users', 1, $config['2FA_all_users'], diff --git a/pandora_console/godmode/setup/setup_ehorus.php b/pandora_console/godmode/setup/setup_ehorus.php index 6f4879a4ac..5f0d258082 100644 --- a/pandora_console/godmode/setup/setup_ehorus.php +++ b/pandora_console/godmode/setup/setup_ehorus.php @@ -78,6 +78,18 @@ $table_remote->class = 'databox filters filter-table-adv'; $table_remote->size['ehorus_hostname'] = '50%'; $table_remote->size['ehorus_port'] = '50%'; +if (isset($config['ehorus_user_level_conf']) === false) { + $config['ehorus_user_level_conf'] = ''; +} + +if (isset($config['ehorus_user']) === false) { + $config['ehorus_user'] = ''; +} + +if (isset($config['ehorus_pass']) === false) { + $config['ehorus_pass'] = ''; +} + // Enable eHorus user configuration. $row = []; $row['ehorus_user_level_conf'] = html_print_label_input_block( diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 3366fcc6f8..f9ea0ece51 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -488,6 +488,10 @@ $table->data[$i][] = html_print_label_input_block( ) ); +if (isset($config['force_public_url']) === false) { + $config['force_public_url'] = ''; +} + $table->data[$i++][] = html_print_label_input_block( __('Force use Public URL'), html_print_switch( @@ -498,6 +502,10 @@ $table->data[$i++][] = html_print_label_input_block( ) ); +if (isset($config['public_url_exclusions']) === false) { + $config['public_url_exclusions'] = ''; +} + $table->data[$i++][] = html_print_label_input_block( __('Public URL host exclusions'), html_print_textarea( @@ -919,6 +927,10 @@ echo ''.__('Mail configuration').''; $table_ncm_config->size[0] = '50%'; $table_ncm_config->data = []; + if (isset($config['tftp_server_ip']) === false) { + $config['tftp_server_ip'] = ''; + } + $table_ncm_config->data[0][] = html_print_label_input_block( __('FTP server IP').ui_print_help_tip(__('This value will be used by TFTP_SERVER_IP macro in NCM scripts.'), true), html_print_input_text( diff --git a/pandora_console/godmode/setup/welcome_tips.php b/pandora_console/godmode/setup/welcome_tips.php index 1a62aa857b..ae669029d3 100644 --- a/pandora_console/godmode/setup/welcome_tips.php +++ b/pandora_console/godmode/setup/welcome_tips.php @@ -74,6 +74,8 @@ if ($view === 'create' || $view === 'edit') { if (count($errors) === 0) { if (count($files) > 0) { $uploadImages = $tipsWindow->uploadImages($files); + } else { + $uploadImages = ''; } $response = $tipsWindow->createTip($id_lang, $id_profile, $title, $text, $url, $enable, $uploadImages); diff --git a/pandora_console/godmode/snmpconsole/snmp_filters.php b/pandora_console/godmode/snmpconsole/snmp_filters.php index d4fc275122..fb8987431d 100644 --- a/pandora_console/godmode/snmpconsole/snmp_filters.php +++ b/pandora_console/godmode/snmpconsole/snmp_filters.php @@ -377,11 +377,15 @@ if ($edit_filter > -2) { echo '
'; } + +if (isset($index) === false) { + $index = 0; +} ?> '; $output .= '
'; @@ -63,8 +67,10 @@ if ($files !== false) { } if (isset($files64) === true) { - foreach ($files64 as $key => $file) { - $output .= ''; + if ($files64 !== false) { + foreach ($files64 as $key => $file) { + $output .= ''; + } } } From 56e26ab3d52fa27ee1574649696871a59d18d0b0 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 8 Feb 2024 13:42:02 +0100 Subject: [PATCH 05/26] #12695 wip removing warnings --- .../include/lib/TacticalView/elements/Database.php | 4 ++-- pandora_console/include/lib/TacticalView/elements/Groups.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/lib/TacticalView/elements/Database.php b/pandora_console/include/lib/TacticalView/elements/Database.php index c329f062bf..033783cc25 100644 --- a/pandora_console/include/lib/TacticalView/elements/Database.php +++ b/pandora_console/include/lib/TacticalView/elements/Database.php @@ -198,7 +198,7 @@ class Database extends Element $total = 0; foreach ($reads as $key => $read) { if (isset($read['utimestamp']) === false) { - $read['utimestamp'] = ''; + $read['utimestamp'] = 0; } $dates[] = date('d-m-Y H:i:s', $read['utimestamp']); @@ -277,7 +277,7 @@ class Database extends Element $total = 0; foreach ($writes as $key => $write) { if (isset($write['utimestamp']) === false) { - $write['utimestamp'] = ''; + $write['utimestamp'] = 0; } $dates[] = date('d-m-Y H:i:s', $write['utimestamp']); diff --git a/pandora_console/include/lib/TacticalView/elements/Groups.php b/pandora_console/include/lib/TacticalView/elements/Groups.php index d1bfda4e77..860d10c130 100644 --- a/pandora_console/include/lib/TacticalView/elements/Groups.php +++ b/pandora_console/include/lib/TacticalView/elements/Groups.php @@ -101,8 +101,8 @@ class Groups extends Element public function getStatusHeatMapModules():string { global $config; - $width = get_parameter('width', 350); - $height = get_parameter('height', 275); + $width = (int) get_parameter('width', 350); + $height = (int) get_parameter('height', 275); $id_groups = array_keys(users_get_groups($config['id_user'], 'AR', false)); From 6e1fb2f0613a1cd2b1f4d223d0784bdf37560929 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 8 Feb 2024 17:17:17 +0100 Subject: [PATCH 06/26] #12695 wip removing warnings --- .../godmode/agentes/configure_field.php | 6 ++- pandora_console/godmode/setup/demo.php | 4 ++ .../include/ajax/demo_data.ajax.php | 40 ++++++++++++++++--- pandora_console/include/class/Tree.class.php | 16 ++++++++ .../include/class/TreeGroup.class.php | 4 ++ .../include/functions_groupview.php | 2 +- pandora_console/include/functions_modules.php | 8 ++++ pandora_console/include/functions_ui.php | 4 ++ .../operation/agentes/estado_agente.php | 4 ++ .../operation/agentes/group_view.php | 7 +++- pandora_console/operation/events/events.php | 24 ++++++----- 11 files changed, 98 insertions(+), 21 deletions(-) diff --git a/pandora_console/godmode/agentes/configure_field.php b/pandora_console/godmode/agentes/configure_field.php index 904b807bbd..44332487ce 100755 --- a/pandora_console/godmode/agentes/configure_field.php +++ b/pandora_console/godmode/agentes/configure_field.php @@ -55,7 +55,7 @@ if ($id_field) { $display_on_front = $field['display_on_front']; $is_password_type = $field['is_password_type']; $combo_values = $field['combo_values'] ? $field['combo_values'] : ''; - $is_combo_enable = $config['is_combo_enable']; + $is_combo_enable = (isset($config['is_combo_enable']) === true) ? $config['is_combo_enable'] : false; $is_link_enabled = $field['is_link_enabled']; $header_title = __('Update agent custom field'); } else { @@ -162,6 +162,10 @@ $table->data[2][0] = html_print_label_input_block( ) ); +if (isset($config['is_combo_enable']) === false) { + $config['is_combo_enable'] = false; +} + $table->data[2][1] = html_print_label_input_block( __('Enabled combo'), html_print_checkbox_switch_extended( diff --git a/pandora_console/godmode/setup/demo.php b/pandora_console/godmode/setup/demo.php index 62446d48a2..b64a6d7f6d 100644 --- a/pandora_console/godmode/setup/demo.php +++ b/pandora_console/godmode/setup/demo.php @@ -116,6 +116,10 @@ if ($display_loading === true || $running_create === true || $running_delete) { $table_load->size = []; $table_load->size[0] = '50%'; $table_load->size[1] = '50%'; + $list_mkup = ''; + if (isset($operation['id']) === false) { + $operation['id'] = 0; + } $table_load->data['row0'][] = progress_bar( 0, diff --git a/pandora_console/include/ajax/demo_data.ajax.php b/pandora_console/include/ajax/demo_data.ajax.php index 5d9e1ee6b8..6d6e7eccd4 100644 --- a/pandora_console/include/ajax/demo_data.ajax.php +++ b/pandora_console/include/ajax/demo_data.ajax.php @@ -186,9 +186,9 @@ if ($action === 'create_demo_data') { } $modules_data = $ini_agent_data['modules']; - $inventory = $ini_agent_data['inventory']; - $inventory_values = $ini_agent_data['inventory_values']; - $traps = $ini_agent_data['traps']; + $inventory = (isset($ini_agent_data['inventory']) === true) ? $ini_agent_data['inventory'] : ''; + $inventory_values = (isset($ini_agent_data['inventory_values']) === true) ? $ini_agent_data['inventory_values'] : ''; + $traps = (isset($ini_agent_data['traps']) === true) ? $ini_agent_data['traps'] : ''; $address_network = $agent_data['address_network']; @@ -435,11 +435,15 @@ if ($action === 'create_demo_data') { $module_description = ''; if (isset($modules_array['description']) === true && is_string($modules_array['description']) === true) { + if (isset($mac) === false) { + $mac = ''; + } + $module_description = str_replace('_mac_', $mac, $modules_array['description']); } $values = [ - 'unit' => $modules_array['unit'], + 'unit' => (isset($modules_array['unit']) === true) ? $modules_array['unit'] : '', 'descripcion' => $module_description, 'id_tipo_modulo' => $id_tipo, 'id_module_group' => ($modules_array['group'] ?? 0), @@ -597,8 +601,12 @@ if ($action === 'create_demo_data') { while (1) { // Insert in tmodule_inventory. $modules_array = []; - foreach ($inventory as $key => $value) { - $modules_array[$key] = ($value[$module_access_idx] ?? null); + if (isset($inventory) === true) { + if ($inventory !== '') { + foreach ($inventory as $key => $value) { + $modules_array[$key] = ($value[$module_access_idx] ?? null); + } + } } $module_access_idx++; @@ -3307,6 +3315,26 @@ if ($action === 'create_demo_data') { $module_values['module_interval'] = $interval; $module_values['id_modulo'] = 4; $module_values['id_plugin'] = $created_plugin_id; + if (isset($traps_target_ip) === false) { + $traps_target_ip = ''; + } + + if (isset($traps_community) === false) { + $traps_community = ''; + } + + if (isset($tentacle_target_ip) === false) { + $tentacle_target_ip = ''; + } + + if (isset($tentacle_port) === false) { + $tentacle_port = ''; + } + + if (isset($tentacle_extra_options) === false) { + $tentacle_extra_options = ''; + } + $module_values['macros'] = '{"1":{"macro":"_field1_","desc":"Agents files folder path","help":"","value":"/usr/share/pandora_server/util/plugin/demodata_agents","hide":""},"2":{"macro":"_field2_","desc":"Number of agents","help":"","value":"'.$total_agents_to_create.'","hide":""},"3":{"macro":"_field3_","desc":"Traps target IP","help":"","value":"'.$traps_target_ip.'","hide":""},"4":{"macro":"_field4_","desc":"Traps community","help":"","value":"'.$traps_community.'","hide":""},"5":{"macro":"_field5_","desc":"Tentacle target IP","help":"","value":"'.$tentacle_target_ip.'","hide":""},"6":{"macro":"_field6_","desc":"Tentacle port","help":"","value":"'.$tentacle_port.'","hide":""},"7":{"macro":"_field7_","desc":"Tentacle extra options","help":"","value":"'.$tentacle_extra_options.'","hide":""}}'; $id_plugin_module = modules_create_agent_module( diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index ed515dee87..e7481fb5f7 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -738,6 +738,22 @@ class Tree if ($module['showGraphs']) { $tresholds = true; + if (isset($module['min_warning']) === false) { + $module['min_warning'] = ''; + } + + if (isset($module['max_warning']) === false) { + $module['max_warning'] = ''; + } + + if (isset($module['min_critical']) === false) { + $module['min_critical'] = ''; + } + + if (isset($module['max_critical']) === false) { + $module['max_critical'] = ''; + } + if (empty((float) $module['min_warning']) === true && empty((float) $module['max_warning']) === true && empty($module['warning_inverse']) === true diff --git a/pandora_console/include/class/TreeGroup.class.php b/pandora_console/include/class/TreeGroup.class.php index 55536fe279..520748bb69 100644 --- a/pandora_console/include/class/TreeGroup.class.php +++ b/pandora_console/include/class/TreeGroup.class.php @@ -621,6 +621,10 @@ class TreeGroup extends Tree protected function getDisplayHierarchy() { + if (isset($this->filter['searchHirearchy']) === false) { + $this->filter['searchHirearchy'] = ''; + } + return $this->filter['searchHirearchy'] || (empty($this->filter['searchAgent']) && empty($this->filter['searchModule'])); } diff --git a/pandora_console/include/functions_groupview.php b/pandora_console/include/functions_groupview.php index b96701ab28..7ababa9b95 100644 --- a/pandora_console/include/functions_groupview.php +++ b/pandora_console/include/functions_groupview.php @@ -196,7 +196,7 @@ function groupview_get_groups_list($id_user=false, $access='AR', $is_not_paginat $list[$id_group]['_monitors_not_init_'] = (int) $modules_counters[$id_group]['total_module_not_init']; $list[$id_group]['_monitors_ok_'] = (int) $modules_counters[$id_group]['total_module_normal']; $list[$id_group]['_monitor_checks_'] = (int) $modules_counters[$id_group]['total_module']; - $list[$id_group]['_monitor_not_normal_'] = ($list[$group['id_grupo']]['_monitor_checks_'] - $list[$group['id_grupo']]['_monitors_ok_']); + $list[$id_group]['_monitor_not_normal_'] = ($modules_counters[$id_group]['total_module'] - $modules_counters[$id_group]['total_module_normal']); $list[$id_group]['_monitors_alerts_fired_'] = (int) $modules_counters[$id_group]['total_module_alerts']; } diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 2d3b5676ec..0ab26ed1c1 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -2700,6 +2700,14 @@ function modules_get_agentmodule_data_for_humans($module) if ($data_macro !== false) { $salida = $data_macro; } else { + if (isset($module['current_interval']) === false) { + $module['current_interval'] = 0; + } + + if (isset($module['module_name']) === false) { + $module['module_name'] = 0; + } + $salida = ui_print_module_string_value( $module['datos'], empty($module['id']) ? $module['id_agente_modulo'] : $module['id'], diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index bcf23c6d71..3c89cdda6a 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -6764,6 +6764,10 @@ function ui_print_module_string_value( $value = io_safe_input($value); } + if (isset($module) === false) { + $module['datos'] = ''; + } + $is_snapshot = is_snapshot_data($module['datos']); $is_large_image = is_text_to_black_string($module['datos']); if (($config['command_snapshot']) && ($is_snapshot || $is_large_image)) { diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index d3543b0a7c..8a392f1306 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -206,6 +206,10 @@ if ($load_filter_id > 0) { $loaded_filter = db_get_row_sql($sql); } +if (isset($loaded_filter) === false) { + $loaded_filter['id_filter'] = 0; +} + if ($loaded_filter['id_filter'] > 0) { $query_filter['id_filter'] = $load_filter_id; $filter = db_get_row_filter('tagent_filter', $query_filter, false); diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index c7bca5635a..d9b7b04368 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -80,8 +80,7 @@ if ($config['realtimestats'] == 0) { $updated_time .= __('Last update').' : '.ui_print_timestamp(db_get_sql('SELECT min(utimestamp) FROM tgroup_stat'), true); $updated_time .= ''; } else { - // $updated_info = __("Updated at realtime"); - $updated_info = ''; + $updated_time = ''; } // Header. @@ -211,6 +210,10 @@ if ($count == 1) { } } +if (isset($offset) === false) { + $offset = 0; +} + if (empty($result_groups) === false) { $pagination = ui_pagination( $count, diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index f42d889c5f..192a89b539 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -962,17 +962,19 @@ if (is_ajax() === true) { $tmp->id_grupo = $tmp->group_name; } - if (strlen($tmp->id_grupo) >= 10) { - $tmp->id_grupo = ui_print_truncate_text( - $tmp->id_grupo, - 10, - false, - true, - false, - '…', - true, - true, - ); + if (isset($tmp->id_grupo) === true) { + if (strlen($tmp->id_grupo) >= 10) { + $tmp->id_grupo = ui_print_truncate_text( + $tmp->id_grupo, + 10, + false, + true, + false, + '…', + true, + true, + ); + } } // Module name. From d590961e69506067033b50ff62de75aee170eba5 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 9 Feb 2024 13:51:56 +0100 Subject: [PATCH 07/26] #12695 wip removing warnings --- pandora_console/extensions/agents_modules.php | 4 ++++ pandora_console/extensions/module_groups.php | 8 ++++++-- pandora_console/include/ajax/alert_list.ajax.php | 8 ++++++++ pandora_console/include/functions_agents.php | 2 +- pandora_console/include/functions_graph.php | 12 ++++++++++++ pandora_console/include/functions_ui.php | 12 +++++++----- pandora_console/include/graphs/functions_flot.php | 8 ++++++++ pandora_console/include/graphs/functions_utils.php | 6 +++++- .../operation/agentes/alerts_status.functions.php | 2 +- pandora_console/operation/agentes/alerts_status.php | 5 +++++ .../operation/agentes/interface_view.functions.php | 1 + pandora_console/operation/agentes/interface_view.php | 4 ++++ pandora_console/operation/agentes/status_monitor.php | 8 ++++++++ 13 files changed, 70 insertions(+), 10 deletions(-) diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index 90c9527e55..0b43ce0bba 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -496,6 +496,10 @@ function mainAgentsModules() $agents = []; } + if (isset($agents_id) === false) { + $agents_id = ''; + } + $filter_agents = html_print_label_input_block( __('Agents'), html_print_select( diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 957d3a17a1..15c9e614ee 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -91,7 +91,7 @@ function mainModuleGroups() $module_group_search = get_parameter('module_group_search', ''); // Check the user's group permissions. - $user_groups = users_get_groups($config['user'], 'AR'); + $user_groups = users_get_groups($config['id_user'], 'AR'); $info = array_filter( $info, function ($v) use ($user_groups) { @@ -112,7 +112,7 @@ function mainModuleGroups() ); if (empty($info) === false) { - $groups_view = ($is_not_paginated) ? $info : array_slice( + $groups_view = (isset($is_not_paginated) === true) ? $info : array_slice( $info, $offset, $config['block_size'] @@ -374,6 +374,10 @@ function mainModuleGroups() '…' ); $j = 1; + if (isset($background_color) === false) { + $background_color = 'none'; + } + if (isset($array_data[$key])) { foreach ($value['gm'] as $k => $v) { if (isset($array_data[$key][$k])) { diff --git a/pandora_console/include/ajax/alert_list.ajax.php b/pandora_console/include/ajax/alert_list.ajax.php index 6ed1d582cb..23b8197297 100644 --- a/pandora_console/include/ajax/alert_list.ajax.php +++ b/pandora_console/include/ajax/alert_list.ajax.php @@ -431,6 +431,10 @@ if ($get_agent_alerts_datatable === true) { if (empty($filter_alert['free_search']) === false) { $free_search_alert = $filter_alert['free_search']; } else { + if (isset($filter_alert['free_search_alert']) === false) { + $filter_alert['free_search_alert'] = ''; + } + $free_search_alert = $filter_alert['free_search_alert']; } @@ -635,6 +639,10 @@ if ($get_agent_alerts_datatable === true) { } $alerts = []; + if (isset($agent_view_page) === false) { + $agent_view_page = false; + } + if ($agent_view_page === true) { $options_simple = ['order' => $order]; } else { diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 293f140ad6..a9e1b77c1f 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1279,7 +1279,7 @@ function agents_get_group_agents( } if (is_array($search) === true) { - if (!$search['all_agents']) { + if (isset($search['all_agents']) === false) { $filter['disabled'] = 0; if (isset($search['disabled']) === true) { $filter['disabled'] = (int) $search['disabled']; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index ce8a10527c..d81e2bc1d6 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -737,6 +737,10 @@ function grafico_modulo_sparse($params) $params['backgroundColor'] = 'white'; } + if (isset($params['vconsole']) === false) { + $params['vconsole'] = false; + } + if (isset($params['only_image']) === true && $params['vconsole'] !== true) { $params['backgroundColor'] = 'transparent'; } @@ -903,6 +907,10 @@ function grafico_modulo_sparse($params) // Format of the graph. if (empty($params['unit']) === true) { + if (isset($module_data['unit']) === false) { + $module_data['unit'] = ''; + } + $params['unit'] = $module_data['unit']; if (modules_is_unit_macro($params['unit'])) { $params['unit'] = ''; @@ -1008,6 +1016,10 @@ function grafico_modulo_sparse($params) $data_module_graph = []; } + if (isset($series_suffix) === false) { + $series_suffix = ''; + } + $data_module_graph['series_suffix'] = $series_suffix; // Check available data. diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 3c89cdda6a..d145393c19 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -4082,11 +4082,13 @@ function ui_print_datatable(array $parameters) $filter .= '
    '; - foreach ($parameters['form']['inputs'] as $input) { - if ($input['type'] === 'date_range') { - $filter .= '
  • '.html_print_select_date_range('date', true).'
  • '; - } else { - $filter .= html_print_input(($input + ['return' => true]), 'li'); + if (isset($parameters['form']['inputs']) === true) { + foreach ($parameters['form']['inputs'] as $input) { + if ($input['type'] === 'date_range') { + $filter .= '
  • '.html_print_select_date_range('date', true).'
  • '; + } else { + $filter .= html_print_input(($input + ['return' => true]), 'li'); + } } } diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index c51e3283df..40530a49be 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -205,6 +205,14 @@ function flot_area_graph( $red_inverse = false; } } else if (isset($params['combined']) === false || !$params['combined']) { + if (isset($data_module_graph['w_min']) === false) { + $data_module_graph['w_min'] = ''; + } + + if (isset($data_module_graph['c_min']) === false) { + $data_module_graph['c_min'] = ''; + } + $yellow_threshold = $data_module_graph['w_min']; $red_threshold = $data_module_graph['c_min']; // Get other required module datas to draw warning and critical. diff --git a/pandora_console/include/graphs/functions_utils.php b/pandora_console/include/graphs/functions_utils.php index a96cf8f4c2..e217e25034 100644 --- a/pandora_console/include/graphs/functions_utils.php +++ b/pandora_console/include/graphs/functions_utils.php @@ -43,7 +43,11 @@ function unserialize_in_temp($serial_id=null, $delete=true, $ttl=1) } } - $content = file_get_contents($file_path); + if (file_exists($file_path) === false) { + return false; + } else { + $content = file_get_contents($file_path); + } if ($content === false) { return false; diff --git a/pandora_console/operation/agentes/alerts_status.functions.php b/pandora_console/operation/agentes/alerts_status.functions.php index 8b95c50b30..f33ec03163 100755 --- a/pandora_console/operation/agentes/alerts_status.functions.php +++ b/pandora_console/operation/agentes/alerts_status.functions.php @@ -211,7 +211,7 @@ function printFormFilterAlert( ) ); - $data .= html_print_table($table, true); + $data = html_print_table($table, true); if ($return) { return $data; diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index 68988900bc..9a564eb15f 100755 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -358,6 +358,9 @@ if (is_metaconsole() === true) { } ob_start(); +if (isset($agent_view_page) === false) { + $agent_view_page = false; +} if ($agent_view_page === true) { ui_print_datatable( @@ -550,6 +553,8 @@ if (isset($id_agente)) { } echo '
    '.__('Your system has a much higher rate of modules per agent than recommended (200 modules per agent). This implies performance problems in the system, please consider reducing the number of modules in this agent.').'
    '; +} else { + $system_higher = false; } ?> diff --git a/pandora_console/operation/agentes/interface_view.functions.php b/pandora_console/operation/agentes/interface_view.functions.php index 00211d23f0..dd7bb5eddc 100644 --- a/pandora_console/operation/agentes/interface_view.functions.php +++ b/pandora_console/operation/agentes/interface_view.functions.php @@ -464,6 +464,7 @@ function print_table( $url_if_bandwidth_usage_out .= $selected_agents_query_str.'&'.$selected_interfaces_query_str; $last_data .= $selected_agents_query_str.'&'.$selected_interfaces_query_str; + $recursion = get_parameter_switch('recursion', ''); $url_if_agent_name .= '&recursion='.$recursion; $url_if_name .= '&recursion='.$recursion; $url_if_speed .= '&recursion='.$recursion; diff --git a/pandora_console/operation/agentes/interface_view.php b/pandora_console/operation/agentes/interface_view.php index a4e936ba18..3799e4816e 100644 --- a/pandora_console/operation/agentes/interface_view.php +++ b/pandora_console/operation/agentes/interface_view.php @@ -58,6 +58,10 @@ $autosearch = false; $sec = (string) get_parameter('sec', 'view'); $agent_id = (int) get_parameter('id_agente', 0); +if (isset($subpage) === false) { + $subpage = ''; +} + if ($sec === 'view') { ui_print_standard_header( __('Interface view').$subpage, diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index ab655d518b..8d54063ee3 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -228,6 +228,10 @@ if ($load_filter_id > 0) { $loaded_filter = db_get_row_sql($sql); } +if (isset($loaded_filter['id_filter']) === false) { + $loaded_filter['id_filter'] = 0; +} + if ($loaded_filter['id_filter'] > 0) { $query_filter['id_filter'] = $load_filter_id; $filter = db_get_row_filter('tmonitor_filter', $query_filter, false); @@ -2370,6 +2374,10 @@ if (empty($result) === false) { ui_print_info_message(['no_close' => true, 'message' => __('Please apply a filter to display the data')]); } +if (isset($tablePagination) === false) { + $tablePagination = ''; +} + if (is_metaconsole() !== true) { html_print_action_buttons( '', From a860338f31ebcb3dcfdfa413cbd3c7f8aa778c58 Mon Sep 17 00:00:00 2001 From: alejandro Date: Mon, 12 Feb 2024 15:39:01 +0100 Subject: [PATCH 08/26] upload web_check_lwp.pl --- pandora_plugins/web_check/web_check_lwp.pl | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 pandora_plugins/web_check/web_check_lwp.pl diff --git a/pandora_plugins/web_check/web_check_lwp.pl b/pandora_plugins/web_check/web_check_lwp.pl new file mode 100644 index 0000000000..73b1c0a028 --- /dev/null +++ b/pandora_plugins/web_check/web_check_lwp.pl @@ -0,0 +1,24 @@ +use strict; +use warnings; + +use LWP::UserAgent (); +use Data::Dumper; + +die "Usage: $0 \n" unless @ARGV == 3; + +my ($URL, $username, $password) = @ARGV; + +my $ua = LWP::UserAgent->new(timeout => 10); +$ua->protocols_allowed( ['http', 'https'] ); +$ua->ssl_opts("verify_hostname" => 0); + +$ua->credentials($URL, "", $username, $password); + +my $response = $ua->get($URL); + +if ($response->is_success) { + print $response->decoded_content; +} +else { + die print(Dumper($response)); +} From 0dcced8b53f5523f6bbe5b284031e0b5106a36b4 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 12 Feb 2024 17:59:27 +0100 Subject: [PATCH 09/26] #12695 wip removing warnings --- .../extensions/users_connected.php | 2 +- pandora_console/godmode/reporting/graphs.php | 9 ++++- .../reporting/visual_console_builder.data.php | 8 ++++ .../reporting/visual_console_builder.php | 6 ++- .../godmode/wizards/Applications.class.php | 3 +- .../godmode/wizards/Custom.class.php | 3 +- .../wizards/DiscoveryTaskList.class.php | 6 ++- .../include/ajax/custom_fields.php | 4 ++ .../include/class/Diagnostics.class.php | 4 ++ .../class/ExtensionsDiscovery.class.php | 8 ++-- pandora_console/include/class/HTML.class.php | 4 ++ .../include/class/SnmpConsole.class.php | 4 ++ .../include/functions_custom_fields.php | 13 +++++++ pandora_console/include/functions_html.php | 3 +- .../include/functions_inventory.php | 30 ++++++++------- .../include/functions_snmp_browser.php | 2 +- .../operation/agentes/pandora_networkmap.php | 4 +- .../custom_fields/custom_fields_view.php | 2 +- pandora_console/operation/events/events.php | 23 ++++++++--- .../operation/events/sound_events.php | 6 ++- .../operation/inventory/inventory.php | 38 ++++++++++++------- .../operation/messages/message_list.php | 6 ++- .../operation/reporting/graph_analytics.php | 4 ++ .../operation/snmpconsole/snmp_browser.php | 4 ++ pandora_console/views/dashboard/list.php | 8 ++++ 25 files changed, 155 insertions(+), 49 deletions(-) diff --git a/pandora_console/extensions/users_connected.php b/pandora_console/extensions/users_connected.php index 4b76957344..712dcd014d 100644 --- a/pandora_console/extensions/users_connected.php +++ b/pandora_console/extensions/users_connected.php @@ -229,7 +229,7 @@ function users_extension_main_god($god=true) $data = []; $data[0] = ''.$row['id_user'].''; - $data[1] = $last_login_data['ip_origin']; + $data[1] = $last_login_data['ip_origen']; $data[2] = date($config['date_format'], $last_login_data['utimestamp']); $data[3] = date($config['date_format'], $row['last_connect']); array_push($table->data, $data); diff --git a/pandora_console/godmode/reporting/graphs.php b/pandora_console/godmode/reporting/graphs.php index 1a5fbb4283..e072b0f28a 100644 --- a/pandora_console/godmode/reporting/graphs.php +++ b/pandora_console/godmode/reporting/graphs.php @@ -221,6 +221,9 @@ $search = trim(get_parameter('search', '')); $graphs = custom_graphs_get_user($config['id_user'], false, true, $access); $offset = (int) get_parameter('offset'); $table_aux = new stdClass(); +if (isset($strict_user) === false) { + $strict_user = false; +} $table_aux->width = '100%'; if (is_metaconsole() === true) { @@ -273,7 +276,11 @@ if (is_metaconsole() === true) { html_print_input_text('search', $search, '', 30, '', true) ); - $searchForm .= '
    '; + if (isset($pure) === false) { + $pure = ''; + } + + $searchForm = ''; $searchForm .= html_print_table($table_aux, true); $searchForm .= html_print_div( diff --git a/pandora_console/godmode/reporting/visual_console_builder.data.php b/pandora_console/godmode/reporting/visual_console_builder.data.php index f5cc8d059c..a1e49d7206 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.data.php +++ b/pandora_console/godmode/reporting/visual_console_builder.data.php @@ -130,6 +130,14 @@ if ($action === 'new') { $backgroundPreviewImages[] = html_print_image('', true, ['id' => 'imagen', 'class' => 'invisible']); +if (isset($formAction) === false) { + $formAction = 'POST'; +} + +if (isset($formHidden) === false) { + $formHidden = ''; +} + // Form. echo ''; echo $formHidden; diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php index c49acaf80d..cdba62419a 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.php +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -285,7 +285,11 @@ switch ($activeTab) { } // If the background is changed the size is reseted - $background_now = $visualConsole['background']; + if (isset($visualConsole['background']) === true) { + $background_now = $visualConsole['background']; + } else { + $background_now = ''; + } $values['width'] = $width; $values['height'] = $height; diff --git a/pandora_console/godmode/wizards/Applications.class.php b/pandora_console/godmode/wizards/Applications.class.php index 680630f86b..7bdbe13ee9 100644 --- a/pandora_console/godmode/wizards/Applications.class.php +++ b/pandora_console/godmode/wizards/Applications.class.php @@ -66,7 +66,8 @@ class Applications extends Wizard int $page=0, string $msg='Default message. Not set.', string $icon='images/wizard/applications.png', - string $label='Applications' + string $label='Applications', + string $class_style='', ) { $this->setBreadcrum([]); diff --git a/pandora_console/godmode/wizards/Custom.class.php b/pandora_console/godmode/wizards/Custom.class.php index f721e76aa7..a164c8f666 100644 --- a/pandora_console/godmode/wizards/Custom.class.php +++ b/pandora_console/godmode/wizards/Custom.class.php @@ -66,7 +66,8 @@ class Custom extends Wizard int $page=0, string $msg='Default message. Not set.', string $icon='/images/wizard/Custom_apps@svg.svg', - string $label='Custom' + string $label='Custom', + string $class_style='', ) { $this->setBreadcrum([]); diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index 4cebdfec9f..799917c590 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -629,7 +629,7 @@ class DiscoveryTaskList extends HTML // Updated at. $table->headstyle[8] .= 'min-width: 50px; width: 150px;'; // Operations. - $table->headstyle[9] .= 'min-width: 150px; width: 250px;'; + $table->headstyle[9] = 'min-width: 150px; width: 250px;'; if (check_acl($config['id_user'], 0, 'AW')) { $table->head[0] = __('Force'); @@ -1135,6 +1135,10 @@ class DiscoveryTaskList extends HTML array_push($table->data, $data); } + if (isset($server_name) === false) { + $server_name = ''; + } + if (empty($table->data)) { $content = '
    '.__('Server').' '.$server_name.' '.__('has no discovery tasks assigned').'
    '; $return = false; diff --git a/pandora_console/include/ajax/custom_fields.php b/pandora_console/include/ajax/custom_fields.php index f247c2e51e..fa01ef7f59 100644 --- a/pandora_console/include/ajax/custom_fields.php +++ b/pandora_console/include/ajax/custom_fields.php @@ -58,6 +58,10 @@ if (check_login()) { if ($check_csv_button) { if (check_acl($config['id_user'], 0, 'PM')) { + if (isset($permission) === false) { + $permission = ''; + } + echo json_encode($permission); return; } else { diff --git a/pandora_console/include/class/Diagnostics.class.php b/pandora_console/include/class/Diagnostics.class.php index 714a6a707f..4cbf4094ba 100644 --- a/pandora_console/include/class/Diagnostics.class.php +++ b/pandora_console/include/class/Diagnostics.class.php @@ -1059,6 +1059,10 @@ class Diagnostics extends Wizard $tFragmentationStatus = 1; } + if (isset($config['thousand_separator']) === false) { + $config['thousand_separator'] = ''; + } + $result = [ 'error' => false, 'data' => [ diff --git a/pandora_console/include/class/ExtensionsDiscovery.class.php b/pandora_console/include/class/ExtensionsDiscovery.class.php index f132cc160f..c48a644cb3 100644 --- a/pandora_console/include/class/ExtensionsDiscovery.class.php +++ b/pandora_console/include/class/ExtensionsDiscovery.class.php @@ -186,9 +186,11 @@ class ExtensionsDiscovery extends Wizard private function loadConfig() { $row = db_get_row('tdiscovery_apps', 'short_name', $this->mode); - $this->id = $row['id_app']; - $this->name = $row['name']; - $this->description = $row['description']; + if ($row !== false) { + $this->id = $row['id_app']; + $this->name = $row['name']; + $this->description = $row['description']; + } } diff --git a/pandora_console/include/class/HTML.class.php b/pandora_console/include/class/HTML.class.php index b019b2c59e..f2bae706ce 100644 --- a/pandora_console/include/class/HTML.class.php +++ b/pandora_console/include/class/HTML.class.php @@ -208,6 +208,10 @@ class HTML $i = 0; foreach ($urls as $url) { + if (isset($url['selected']) === false) { + $url['selected'] = 0; + } + if ($url['selected'] == 1) { $class = 'selected'; } else { diff --git a/pandora_console/include/class/SnmpConsole.class.php b/pandora_console/include/class/SnmpConsole.class.php index 6945d9b1fb..160e020e07 100644 --- a/pandora_console/include/class/SnmpConsole.class.php +++ b/pandora_console/include/class/SnmpConsole.class.php @@ -199,6 +199,10 @@ class SnmpConsole extends HTML ).''; $list['active'] = true; + if (isset($screen) === false) { + $screen = ''; + } + // Header. ui_print_standard_header( __('SNMP Console'), diff --git a/pandora_console/include/functions_custom_fields.php b/pandora_console/include/functions_custom_fields.php index 9ce92a0c78..aae86ab40e 100644 --- a/pandora_console/include/functions_custom_fields.php +++ b/pandora_console/include/functions_custom_fields.php @@ -289,6 +289,10 @@ function agent_counters_custom_fields($filters) } } + if (isset($groups_and) === false) { + $groups_and = ''; + } + // Filter by status module. $empty_agents_count = "UNION ALL SELECT ta.id_agente, @@ -616,6 +620,10 @@ function agent_counters_custom_fields($filters) $result_meta = []; $data = []; + if (isset($and_module_search) === false) { + $and_module_search = ''; + } + $query = sprintf( "SELECT tcd.description AS name_data, SUM(IF($agent_state_total, 1, 0)) AS a_agents, @@ -677,6 +685,11 @@ function agent_counters_custom_fields($filters) $result_meta[] = db_get_all_rows_sql($query); + if (isset($server_data) === false) { + $server_data = []; + $server_data['id'] = ''; + } + $query_data = sprintf( "SELECT tcd.description, diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 3a4ca01ebb..402f0c71a2 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -7415,8 +7415,9 @@ function html_print_select_date_range( $output .= '
'; $output .= '
'; $table = new stdClass(); + $table->data = []; $table->class = 'table-adv-filter'; - $table->data[0][0] .= '
'.__('From').':
'; + $table->data[0][0] = '
'.__('From').':
'; $table->data[0][0] .= html_print_input_text('date_init', $date_init, '', 12, 10, true).' '; $table->data[0][0] .= html_print_input_text('time_init', $time_init, '', 10, 7, true).' '; $table->data[0][0] .= '
'; diff --git a/pandora_console/include/functions_inventory.php b/pandora_console/include/functions_inventory.php index afa61c3811..38d5b49b81 100644 --- a/pandora_console/include/functions_inventory.php +++ b/pandora_console/include/functions_inventory.php @@ -788,22 +788,24 @@ function inventory_get_datatable( $rows = db_get_all_rows_sql($sql); if ($order_by_agent === false) { $modules = []; - foreach ($rows as $row) { - if ($row['utimestamp'] !== $row['last_update']) { - $row['timestamp'] = $row['last_update_timestamp']; - } - - $data_rows = explode(PHP_EOL, $row['data_inventory']); - foreach ($data_rows as $data_key => $data_value) { - if (empty($inventory_search_string) !== true) { - $search_check = strpos(str_replace(' ', ' ', $data_value), $inventory_search_string); - } else { - $search_check = true; + if ($rows !== false) { + foreach ($rows as $row) { + if ($row['utimestamp'] !== $row['last_update']) { + $row['timestamp'] = $row['last_update_timestamp']; } - if (empty($data_value) === false && $search_check !== false) { - $row['data'] = $data_value; - $modules[$row['name']][$row['name_agent'].'-'.$data_key.'-'.$data_value] = $row; + $data_rows = explode(PHP_EOL, $row['data_inventory']); + foreach ($data_rows as $data_key => $data_value) { + if (empty($inventory_search_string) !== true) { + $search_check = strpos(str_replace(' ', ' ', $data_value), $inventory_search_string); + } else { + $search_check = true; + } + + if (empty($data_value) === false && $search_check !== false) { + $row['data'] = $data_value; + $modules[$row['name']][$row['name_agent'].'-'.$data_key.'-'.$data_value] = $row; + } } } } diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index 99a0b07612..6d553b1ca3 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -741,7 +741,7 @@ function snmp_browser_print_container( ) ); - $table->data[0][1] .= html_print_label_input_block( + $table->data[0][1] = html_print_label_input_block( __('Port'), html_print_input( [ diff --git a/pandora_console/operation/agentes/pandora_networkmap.php b/pandora_console/operation/agentes/pandora_networkmap.php index 52c376b4f7..94e2cb51e6 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.php +++ b/pandora_console/operation/agentes/pandora_networkmap.php @@ -711,7 +711,9 @@ switch ($tab) { ] ); - echo $result_txt; + if (isset($result_txt) === true) { + echo $result_txt; + } $table = new stdClass(); $table->width = '100%'; diff --git a/pandora_console/operation/custom_fields/custom_fields_view.php b/pandora_console/operation/custom_fields/custom_fields_view.php index 83d35533c7..f05ee93c93 100644 --- a/pandora_console/operation/custom_fields/custom_fields_view.php +++ b/pandora_console/operation/custom_fields/custom_fields_view.php @@ -779,7 +779,7 @@ $(document).ready (function () { }); var filters = ''; - var indexed_descriptions = ''; + var indexed_descriptions = ''; var processing = ''; table_datatables(filters, indexed_descriptions, processing); diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 192a89b539..d1e995f25d 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1995,7 +1995,7 @@ $data = html_print_checkbox_switch( true ); -$in_sec_group .= $data; +$in_sec_group = $data; $in_sec_group .= '
'; $inputs[] = $in; // User private filter. +if (isset($private_filter_event) === false) { + $private_filter_event = ''; +} + $inputs[] = html_print_input_hidden('private_filter_event', $private_filter_event, true); // Trick view in table. $inputs[] = '
'; @@ -2774,12 +2778,13 @@ try { $form_id = 'events_form'; $show_hide_filters = ''; - if ((int) $_GET['pure'] === 1) { - $show_hide_filters = 'invisible'; + if (isset($_GET['pure']) === true) { + if ((int) $_GET['pure'] === 1) { + $show_hide_filters = 'invisible'; + } } - - // Print graphs + // Print graphs. $graph_background = ''; if ($config['style'] === 'pandora') { $graph_background = ' background-color: #fff;'; @@ -3038,6 +3043,14 @@ echo ''; echo ''; $autorefresh_draw = false; +if (isset($_GET['refr']) === false) { + $_GET['refr'] = 0; +} + +if (isset($config['refr']) === false) { + $config['refr'] = $_GET['refr']; +} + if ($_GET['refr'] || (bool) ($do_refresh ?? false) === true) { $autorefresh_draw = true; } diff --git a/pandora_console/operation/events/sound_events.php b/pandora_console/operation/events/sound_events.php index 4ff12e02f4..2107ca2de2 100644 --- a/pandora_console/operation/events/sound_events.php +++ b/pandora_console/operation/events/sound_events.php @@ -207,8 +207,10 @@ $output = '
'; ]; $eventsounds = db_get_all_rows_sql('SELECT * FROM tevent_sound WHERE active = 1'); - foreach ($eventsounds as $key => $row) { - $sounds[$row['sound']] = $row['name']; + if ($eventsounds !== false) { + foreach ($eventsounds as $key => $row) { + $sounds[$row['sound']] = $row['name']; + } } $inputs[] = [ diff --git a/pandora_console/operation/inventory/inventory.php b/pandora_console/operation/inventory/inventory.php index a841c53266..5f812f67e9 100755 --- a/pandora_console/operation/inventory/inventory.php +++ b/pandora_console/operation/inventory/inventory.php @@ -181,6 +181,10 @@ if (is_ajax() === true) { $id_agent = (int) get_parameter('id_agent', 0); $id_group = (int) get_parameter('id_group', 0); + if (isset($filter['value']) === false) { + $filter['value'] = ''; + } + $params = [ 'search' => $filter['value'], 'start' => $start, @@ -275,23 +279,25 @@ if (is_ajax() === true) { $custom_fields_names = ''; $custom_fields_values = ''; - foreach ($field_result as $field) { - $field_name = str_replace(' ', ' ', io_safe_output($field['name'])); - $custom_fields_names .= ''.$field_name.''; + if ($field_result !== false) { + foreach ($field_result as $field) { + $field_name = str_replace(' ', ' ', io_safe_output($field['name'])); + $custom_fields_names .= ''.$field_name.''; - $description = $field['description']; - $password_length = strlen(io_safe_output($field['description'])); - $asterisks = ''; + $description = $field['description']; + $password_length = strlen(io_safe_output($field['description'])); + $asterisks = ''; - if ((int) $field['is_password_type'] === 1) { - for ($i = 0; $i < $password_length; $i++) { - $asterisks .= '●'; + if ((int) $field['is_password_type'] === 1) { + for ($i = 0; $i < $password_length; $i++) { + $asterisks .= '●'; + } + + $description = $asterisks; } - $description = $asterisks; + $custom_fields_values .= ''.$description.''; } - - $custom_fields_values .= ''.$description.''; } $tmp->description = $agent['comentarios']; @@ -546,6 +552,10 @@ $table->size[2] = '33%'; $table->class = 'filter-table-adv'; $table->data = []; +if (isset($filteringFunction) === false) { + $filteringFunction = ''; +} + if ($is_metaconsole === true) { // Node select. $nodes = []; @@ -739,7 +749,7 @@ $table->data[1][1] = html_print_label_input_block( // Date filter. In Metaconsole has not reason for show. if (is_metaconsole() === false) { - $table->data[1][2] .= html_print_label_input_block( + $table->data[1][2] = html_print_label_input_block( __('Date').':
', html_print_select_date_range( 'utimestamp', @@ -1388,7 +1398,7 @@ ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript // Change chevron for node icon. let toggle = document.querySelectorAll('.toggle-inventory-nodo'); - let src = ''; + let src = ''; toggle.forEach(img => { img.parentElement.parentElement.style = 'cursor: pointer; border: 0'; diff --git a/pandora_console/operation/messages/message_list.php b/pandora_console/operation/messages/message_list.php index 26ffbc5bfe..705b17f771 100644 --- a/pandora_console/operation/messages/message_list.php +++ b/pandora_console/operation/messages/message_list.php @@ -245,6 +245,10 @@ if (empty($messages) === true) { $data[1] = $dest_user; } else { + if (isset($message['sender']) === false) { + $message['sender'] = 0; + } + $orig_user = get_user_fullname($message['sender']); if (!$orig_user) { $orig_user = $message['sender']; @@ -265,7 +269,7 @@ if (empty($messages) === true) { $contentSubject = ''.$contentSubject.''; } - $data[2] .= html_print_anchor( + $data[2] = html_print_anchor( [ 'href' => $pathSubject, 'content' => $contentSubject, diff --git a/pandora_console/operation/reporting/graph_analytics.php b/pandora_console/operation/reporting/graph_analytics.php index ff6272bdd6..9a85b81043 100644 --- a/pandora_console/operation/reporting/graph_analytics.php +++ b/pandora_console/operation/reporting/graph_analytics.php @@ -670,6 +670,10 @@ $data[0] .= html_print_select( 'width:'.$filter_id_width.';' ); +if (isset($config['user']) === false) { + $config['user'] = false; +} + $user_groups = users_get_groups($config['user'], 'RW'); $data[1] = __('Group'); $data[1] .= html_print_select( diff --git a/pandora_console/operation/snmpconsole/snmp_browser.php b/pandora_console/operation/snmpconsole/snmp_browser.php index 0fa30148ed..8b3e8acc38 100644 --- a/pandora_console/operation/snmpconsole/snmp_browser.php +++ b/pandora_console/operation/snmpconsole/snmp_browser.php @@ -76,6 +76,10 @@ if ($config['pure']) { $type = get_parameter('moduletype', false); $page = get_parameter('page', false); +if (isset($moduletype) === false) { + $moduletype = 0; +} + if (empty($page) && $type !== 'networkserver' && $moduletype !== 2) { // Header. ui_print_standard_header( diff --git a/pandora_console/views/dashboard/list.php b/pandora_console/views/dashboard/list.php index aaf675e64a..6282280867 100644 --- a/pandora_console/views/dashboard/list.php +++ b/pandora_console/views/dashboard/list.php @@ -170,6 +170,10 @@ if ($writeDashboards === 1) { true ); + if (isset($output) === false) { + $output = '
'; + } + $output .= '
'; echo $output; @@ -178,6 +182,10 @@ if ($writeDashboards === 1) { echo ''; } +if (isset($tablePagination) === false) { + $tablePagination = ''; +} + html_print_action_buttons( $input_button, [ From 66f8e31824f7be90cd3ebe6570a361e9d89091f1 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 13 Feb 2024 16:55:46 +0100 Subject: [PATCH 10/26] #12783 enabled correct modules when safe mode module is active in agent --- .../godmode/agentes/configurar_agente.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index a2372a66f0..7e9f566e17 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -2320,8 +2320,19 @@ if ($delete_module) { // Check if module is used by agent for Safe mode. $is_safe_mode_module = modules_check_safe_mode($id_borrar_modulo); - if ($is_safe_mode_module === true) { + if ($is_safe_mode_module === true && isset($id_agente) === true) { db_process_sql_update('tagente', ['safe_mode_module' => '0'], ['id_agente' => $id_agente]); + db_process_sql_update( + 'tagente_modulo', + [ + 'disabled' => 0, + 'disabled_by_safe_mode' => 0, + ], + [ + 'id_agente' => $id_agente, + 'disabled_by_safe_mode' => 1, + ] + ); } // Before delete the main module, check and delete the childrens from the original module. From da2bef45f25bfffdb7b59570fddb8a9986db40a2 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 13 Feb 2024 17:06:48 +0100 Subject: [PATCH 11/26] #12695 wip removing warnings --- .../godmode/wizards/HostDevices.class.php | 32 ++- .../godmode/wizards/Wizard.main.php | 18 ++ .../include/class/CustomNetScan.class.php | 16 +- pandora_console/include/class/HTML.class.php | 182 +++++++++++++++--- pandora_console/include/functions_cron.php | 8 +- pandora_console/include/functions_html.php | 6 +- 6 files changed, 221 insertions(+), 41 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 08a47b12f8..6c9820bb11 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -784,8 +784,36 @@ class HostDevices extends Wizard // Interval and schedules. $interv_manual = 0; - if ((int) $this->task['interval_sweep'] == 0) { - $interv_manual = 1; + if (isset($this->task['interval_sweep']) === true) { + if ((int) $this->task['interval_sweep'] == 0) { + $interv_manual = 1; + } + } else { + $this->task['interval_sweep'] = ''; + } + + if (isset($this->task['name']) === false) { + $this->task['name'] = ''; + } + + if (isset($this->task['id_recon_server']) === false) { + $this->task['id_recon_server'] = ''; + } + + if (isset($this->task['subnet_csv']) === false) { + $this->task['subnet_csv'] = ''; + } + + if (isset($this->task['subnet']) === false) { + $this->task['subnet'] = ''; + } + + if (isset($this->task['id_group']) === false) { + $this->task['id_group'] = 0; + } + + if (isset($this->task['description']) === false) { + $this->task['description'] = ''; } $form['rows'][0]['new_form_block'] = true; diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 9eb223e744..f54ded4662 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -104,6 +104,20 @@ class Wizard */ public $rootUrl; + /** + * Task. + * + * @var mixed + */ + public $task; + + /** + * Max pages net scan. + * + * @var mixed + */ + public $maxPagesNetScan; + /** * Setter for breadcrum @@ -221,6 +235,10 @@ class Wizard $i = 0; foreach ($urls as $url) { + if (isset($url['selected']) === false) { + $url['selected'] = 0; + } + if ($url['selected'] == 1) { $class = 'selected'; } else { diff --git a/pandora_console/include/class/CustomNetScan.class.php b/pandora_console/include/class/CustomNetScan.class.php index ec4351e831..24d261bc9c 100644 --- a/pandora_console/include/class/CustomNetScan.class.php +++ b/pandora_console/include/class/CustomNetScan.class.php @@ -452,7 +452,7 @@ class CustomNetScan extends Wizard 'label' => __('Task name'), 'arguments' => [ 'name' => 'taskname', - 'value' => $this->task['name'], + 'value' => (isset($this->task['name']) === true) ? $this->task['name'] : '', 'type' => 'text', 'size' => 50, ], @@ -474,7 +474,7 @@ class CustomNetScan extends Wizard 'label' => __('Comment'), 'arguments' => [ 'name' => 'comment', - 'value' => $this->task['description'], + 'value' => (isset($this->task['description']) === true) ? $this->task['description'] : '', 'type' => 'text', 'size' => 50, ], @@ -496,7 +496,7 @@ class CustomNetScan extends Wizard SERVER_TYPE_DISCOVERY ), 'name' => 'id_recon_server', - 'selected' => $this->task['id_recon_server'], + 'selected' => (isset($this->task['id_recon_server']) === true) ? $this->task['id_recon_server'] : '', 'return' => true, ], ]; @@ -509,7 +509,7 @@ class CustomNetScan extends Wizard 'returnAllGroup' => false, 'privilege' => $this->access, 'type' => 'select_groups', - 'selected' => $this->task['id_group'], + 'selected' => (isset($this->task['id_group']) === true) ? $this->task['id_group'] : '', 'return' => true, 'size' => '400px', ], @@ -517,8 +517,10 @@ class CustomNetScan extends Wizard // Interval and schedules. $interv_manual = 0; - if ((int) $this->task['interval_sweep'] == 0) { - $interv_manual = 1; + if (isset($this->task['interval_sweep']) === true) { + if ((int) $this->task['interval_sweep'] == 0) { + $interv_manual = 1; + } } // Schedule. @@ -541,7 +543,7 @@ class CustomNetScan extends Wizard ], 'extra' => ''.html_print_extended_select_for_time( 'interval', - $this->task['interval_sweep'], + (isset($this->task['interval_sweep']) === true) ? $this->task['interval_sweep'] : '', 'check_period_warning(this, \''.__('Warning').'\', \''.__('Displaying items with extended historical data can have an impact on system performance. We do not recommend that you use intervals longer than 30 days, especially if you combine several of them in a report, dashboard or visual console.').'\')', '', '0', diff --git a/pandora_console/include/class/HTML.class.php b/pandora_console/include/class/HTML.class.php index f2bae706ce..b8d41b0dce 100644 --- a/pandora_console/include/class/HTML.class.php +++ b/pandora_console/include/class/HTML.class.php @@ -622,6 +622,10 @@ class HTML public static function printBlockAsGrid(array $input, bool $return=false) { $output = ''; + if (isset($input['hidden']) === false) { + $input['hidden'] = 0; + } + if ($input['hidden'] == 1) { $class = ' hidden'; } else { @@ -632,6 +636,14 @@ class HTML $class = $input['class'].$class; } + if (isset($input['block_content']) === false) { + $input['block_content'] = ''; + } + + if (isset($input['block_class']) === false) { + $input['block_class'] = ''; + } + if (is_array($input['block_content']) === true) { if (empty($input['label']) === false) { $output .= '
'; @@ -648,6 +660,18 @@ class HTML $output .= ''; } else { + if (isset($input['arguments']['inline']) === false) { + $input['arguments']['inline'] = ''; + } + + if (isset($input['extra']) === false) { + $input['extra'] = ''; + } + + if (isset($input['arguments']) === false) { + $input['arguments'] = ''; + } + if ($input['arguments']['type'] != 'hidden' && $input['arguments']['type'] != 'hidden_extended' ) { @@ -733,6 +757,10 @@ class HTML public static function printBlockAsList(array $input, bool $return=false) { $output = ''; + if (isset($input['hidden']) === false) { + $input['hidden'] = 0; + } + if ($input['hidden'] == 1) { $class = ' hidden'; } else { @@ -743,6 +771,10 @@ class HTML $class = $input['class'].$class; } + if (isset($input['block_content']) === false) { + $input['block_content'] = ''; + } + if (is_array($input['block_content']) === true) { // Print independent block of inputs. $output .= '
  • '; @@ -753,6 +785,14 @@ class HTML $output .= '
  • '; } else { + if (isset($input['id']) === false) { + $input['id'] = ''; + } + + if (isset($input['extra']) === false) { + $input['extra'] = ''; + } + if ($input['arguments']['type'] != 'hidden' && $input['arguments']['type'] != 'hidden_extended' ) { @@ -953,6 +993,42 @@ class HTML { $form = $data['form']; + if (isset($data['rows']) === false) { + $data['rows'] = ''; + } + + if (isset($data['rawInputs']) === false) { + $data['rawInputs'] = ''; + } + + if (isset($data['js']) === false) { + $data['js'] = ''; + } + + if (isset($data['js_block']) === false) { + $data['js_block'] = ''; + } + + if (isset($data['cb_function']) === false) { + $data['cb_function'] = null; + } + + if (isset($data['cb_args']) === false) { + $data['cb_args'] = []; + } + + if (isset($form['class']) === false) { + $form['class'] = ''; + } + + if (isset($form['onsubmit']) === false) { + $form['onsubmit'] = ''; + } + + if (isset($form['extra']) === false) { + $form['extra'] = ''; + } + $rows = $data['rows']; $rawInputs = $data['rawInputs']; $js = $data['js']; @@ -991,7 +1067,15 @@ class HTML if (is_array($rows)) { foreach ($rows as $row) { - if ($row['new_form_block'] == true) { + if (isset($row['class']) === false) { + $row['class'] = ''; + } + + if (isset($row['style']) === false) { + $row['style'] = ''; + } + + if (isset($row['new_form_block']) === true) { if ($first_block_printed === true) { // If first form block has been placed, then close it before starting a new one. $output .= '
    '; @@ -1019,30 +1103,38 @@ class HTML // Toggle option. foreach ($column['inputs'] as $input) { if (is_array($input)) { - if ($input['arguments']['type'] != 'submit') { - if ($input['toggle'] === true) { - $output .= ui_print_toggle( - [ - 'name' => (isset($input['toggle_name']) ? $input['toggle_name'] : 'toggle_'.uniqid()), - 'title' => $input['toggle_title'], - 'id' => $input['toggle_id'], - 'hidden_default' => $input['toggle_hidden_default'], - 'content' => self::printBlockAsGrid( - $input, - true - ), - 'return' => true, - 'name' => (isset($input['toggle_name']) ? $input['toggle_name'] : 'toggle_'.uniqid()), - 'toggle_class' => $input['toggle_toggle_class'], - 'main_class' => $input['toggle_main_class'], - 'container_class' => $input['toggle_container_class'], - 'img_a' => $input['toggle_img_a'], - 'img_b' => $input['toggle_img_b'], - 'clean' => (isset($input['toggle_clean']) ? $input['toggle_clean'] : true), - ] - ); + if (isset($input['arguments']) === true) { + if ($input['arguments']['type'] != 'submit') { + if (isset($input['toggle']) === true) { + if ($input['toggle'] === true) { + $output .= ui_print_toggle( + [ + 'name' => (isset($input['toggle_name']) ? $input['toggle_name'] : 'toggle_'.uniqid()), + 'title' => $input['toggle_title'], + 'id' => $input['toggle_id'], + 'hidden_default' => $input['toggle_hidden_default'], + 'content' => self::printBlockAsGrid( + $input, + true + ), + 'return' => true, + 'name' => (isset($input['toggle_name']) ? $input['toggle_name'] : 'toggle_'.uniqid()), + 'toggle_class' => $input['toggle_toggle_class'], + 'main_class' => $input['toggle_main_class'], + 'container_class' => $input['toggle_container_class'], + 'img_a' => $input['toggle_img_a'], + 'img_b' => $input['toggle_img_b'], + 'clean' => (isset($input['toggle_clean']) ? $input['toggle_clean'] : true), + ] + ); + } else { + $output .= self::printBlockAsGrid($input, true); + } + } else { + $output .= self::printBlockAsGrid($input, true); + } } else { - $output .= self::printBlockAsGrid($input, true); + $output_submit .= self::printBlockAsGrid($input, true); } } else { $output_submit .= self::printBlockAsGrid($input, true); @@ -1093,6 +1185,34 @@ class HTML */ public static function printFormAsList(array $data, bool $return=false) { + if (isset($data['rows']) === false) { + $data['rows'] = ''; + } + + if (isset($data['rawInputs']) === false) { + $data['rawInputs'] = ''; + } + + if (isset($data['js']) === false) { + $data['js'] = ''; + } + + if (isset($data['js_block']) === false) { + $data['js_block'] = ''; + } + + if (isset($data['cb_function']) === false) { + $data['cb_function'] = null; + } + + if (isset($data['cb_args']) === false) { + $data['cb_args'] = []; + } + + if (isset($form['class']) === false) { + $form['class'] = ''; + } + $form = $data['form']; $inputs = $data['inputs']; $rawInputs = $data['rawInputs']; @@ -1101,6 +1221,18 @@ class HTML $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; + if (isset($form['onsubmit']) === false) { + $form['onsubmit'] = ''; + } + + if (isset($form['extra']) === false) { + $form['extra'] = ''; + } + + if (isset($form['enctype']) === false) { + $form['enctype'] = ''; + } + $output_head = ''; @@ -1121,7 +1253,7 @@ class HTML $output = '
    '; $output .= '
      '; - + $output_submit = ''; foreach ($inputs as $input) { if ($input['arguments']['type'] != 'submit') { $output .= self::printBlockAsList($input, true); diff --git a/pandora_console/include/functions_cron.php b/pandora_console/include/functions_cron.php index 711ed7f6ba..f3755fd383 100644 --- a/pandora_console/include/functions_cron.php +++ b/pandora_console/include/functions_cron.php @@ -593,7 +593,7 @@ function cron_list_table() // Check ACL in reports_get_report return false. if ($report === false) { - continue; + break; } $email = ui_print_truncate_text($args[1], 120); @@ -656,7 +656,7 @@ function cron_list_table() // Check ACL in reports_get_report return false. if ($template === false) { - continue; + break; } if (empty($args[1]) === false && (string) $args[1] !== '0') { @@ -777,7 +777,7 @@ function cron_list_table() // Check ACL in reports_get_report return false. if ($report === false) { - continue; + break; } $path = $args[1]; @@ -817,7 +817,7 @@ function cron_list_table() // Check ACL in reports_get_report return false. if ($report === false) { - continue; + break; } $path = $args[1]; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 402f0c71a2..8fb8e3dcd0 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -5858,9 +5858,9 @@ function html_print_input($data, $wrapper='div', $input_only=false) case 'textarea': $output .= html_print_textarea( - $data['name'], - $data['rows'], - $data['columns'], + (isset($data['name']) === true) ? $data['name'] : '', + (isset($data['rows']) === true) ? $data['rows'] : '', + (isset($data['columns']) === true) ? $data['columns'] : '', ((isset($data['value']) === true) ? $data['value'] : ''), ((isset($data['attributes']) === true) ? $data['attributes'] : ''), ((isset($data['return']) === true) ? $data['return'] : false), From b00bb507b6fd833ddb00932d6b5ffa1620ff4778 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Wed, 14 Feb 2024 14:02:31 +0100 Subject: [PATCH 12/26] fix entities --- pandora_console/include/lib/Dashboard/Widgets/maps_status.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/maps_status.php b/pandora_console/include/lib/Dashboard/Widgets/maps_status.php index 2e59af771c..d3f5bfd625 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/maps_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/maps_status.php @@ -253,7 +253,7 @@ class MapsStatusWidget extends Widget $fields = array_reduce( $dataVc, function ($carry, $item) { - $carry[$item['id']] = $item['name']; + $carry[$item['id']] = io_safe_output($item['name']); return $carry; }, [] From 5dbf868460e2b6db542880d254a45911c009afb0 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Wed, 14 Feb 2024 17:37:10 +0100 Subject: [PATCH 13/26] fix entities --- pandora_console/include/lib/Dashboard/Widgets/maps_status.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/maps_status.php b/pandora_console/include/lib/Dashboard/Widgets/maps_status.php index d3f5bfd625..12d0ef9461 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/maps_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/maps_status.php @@ -350,7 +350,7 @@ class MapsStatusWidget extends Widget // This will give us the group name. $data[0] = ''; - $data[0] .= $user_layouts[$id_layout]['name']; + $data[0] .= io_safe_output($user_layouts[$id_layout]['name']); $data[0] .= ''; // Status 0 is OK. From 42975c79670e52c8c98bc0dfc49d6d6809ae06d5 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 14 Feb 2024 17:43:20 +0100 Subject: [PATCH 14/26] #12695 wip removing warnings --- .../godmode/alerts/alert_commands.php | 2 +- .../godmode/alerts/alert_list.list.php | 4 +- pandora_console/godmode/category/category.php | 1 + pandora_console/godmode/extensions.php | 10 ++-- pandora_console/godmode/groups/group_list.php | 6 +-- .../modules/manage_network_components.php | 8 +++- .../godmode/servers/modificar_server.php | 4 +- pandora_console/godmode/servers/plugin.php | 4 ++ .../godmode/servers/plugin_registration.php | 38 ++++++++------- .../godmode/servers/servers.build_table.php | 4 +- .../godmode/setup/file_manager.php | 11 ++++- pandora_console/godmode/setup/license.php | 8 ++-- pandora_console/godmode/setup/news.php | 4 ++ pandora_console/godmode/setup/os.list.php | 5 +- .../godmode/snmpconsole/snmp_alert.php | 44 ++++++++--------- .../update_manager/update_manager.setup.php | 2 +- .../godmode/wizards/Cloud.class.php | 8 ++-- .../include/ajax/consoles.ajax.php | 2 +- .../include/class/Diagnostics.class.php | 8 +++- .../include/class/EventSound.class.php | 48 ++++++++++--------- .../class/ExtensionsDiscovery.class.php | 5 +- pandora_console/include/class/HTML.class.php | 4 ++ .../include/class/ModuleTemplates.class.php | 9 +++- .../include/functions_filemanager.php | 6 ++- pandora_console/include/functions_html.php | 4 +- pandora_console/include/functions_menu.php | 4 +- .../operation/agentes/exportdata.php | 10 +++- 27 files changed, 157 insertions(+), 106 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index a5b4de7c80..b242e41e29 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -109,7 +109,7 @@ if (is_ajax()) { for ($i = 1; $i <= $config['max_macro_fields']; $i++) { $field_description = $fields_descriptions[($i - 1)]; $field_value = $fields_values[($i - 1)]; - $field_hidden = $fields_hidden_checked[($i - 1)]; + $field_hidden = (isset($fields_hidden_checked[($i - 1)]) === true) ? $fields_hidden_checked[($i - 1)] : ''; if (!empty($field_description)) { diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 5d71895ecd..fe0790f71b 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -253,7 +253,7 @@ if (is_metaconsole() === true) { echo '
      '; } -if (!$id_cluster) { +if (isset($id_cluster) === false) { ui_toggle( $form_filter, ''.__('Alert control filter').'', @@ -1115,7 +1115,7 @@ if (isset($dont_display_alert_create_bttn)) { } } -if ($display_create && (check_acl($config['id_user'], 0, 'LW') || check_acl($config['id_user'], $template_group, 'LM')) && !$id_cluster) { +if ($display_create && (check_acl($config['id_user'], 0, 'LW') || check_acl($config['id_user'], $template_group, 'LM')) && isset($id_cluster) === false) { echo ''; $actionButtons = html_print_submit_button( __('Create'), diff --git a/pandora_console/godmode/category/category.php b/pandora_console/godmode/category/category.php index 46095b6efb..02a221fee8 100755 --- a/pandora_console/godmode/category/category.php +++ b/pandora_console/godmode/category/category.php @@ -242,6 +242,7 @@ if (empty($result) === false) { html_print_table($table); $tablePagination = ui_pagination($total_categories, $url, $offset, 0, true, 'offset', false); } else { + $tablePagination = ''; // No categories available or selected. ui_print_info_message(['no_close' => true, 'message' => __('No categories found') ]); } diff --git a/pandora_console/godmode/extensions.php b/pandora_console/godmode/extensions.php index 3ff09273c6..3db36f71a9 100644 --- a/pandora_console/godmode/extensions.php +++ b/pandora_console/godmode/extensions.php @@ -195,13 +195,13 @@ foreach ($extensions as $file => $extension) { $data[] = ''.$file.''; // Get version of this extensions - if ($config['extensions'][$file]['operation_menu']) { + if (isset($config['extensions'][$file]['operation_menu']) === true) { $data[] = $config['extensions'][$file]['operation_menu']['version']; - } else if ($config['extensions'][$file]['godmode_menu']) { + } else if (isset($config['extensions'][$file]['godmode_menu']) === true) { $data[] = $config['extensions'][$file]['godmode_menu']['version']; - } else if ($config['extensions'][$file]['extension_ope_tab']) { + } else if (isset($config['extensions'][$file]['extension_ope_tab']) === true) { $data[] = $config['extensions'][$file]['extension_ope_tab']['version']; - } else if ($config['extensions'][$file]['extension_god_tab']) { + } else if (isset($config['extensions'][$file]['extension_god_tab']) === true) { $data[] = $config['extensions'][$file]['extension_god_tab']['version']; } else { $data[] = __('N/A'); @@ -216,7 +216,7 @@ foreach ($extensions as $file => $extension) { $data[] = $config['extensions'][$file]['godmode_menu']['version']; } else if (isset($config['extensions'][$file]['extension_ope_tab'])) { $data[] = $config['extensions'][$file]['extension_ope_tab']['version']; - } else if ($config['extensions'][$file]['extension_god_tab']) { + } else if (isset($config['extensions'][$file]['extension_god_tab']) === true) { $data[] = $config['extensions'][$file]['extension_god_tab']['version']; } else { $data[] = __('N/A'); diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 66717bc35b..f17f115b9d 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -1183,9 +1183,9 @@ $tab = 'group_edition';