From 229436b972aceb56f483f7e1d60fa35e27d5869b Mon Sep 17 00:00:00 2001 From: Daniel Barbero Date: Mon, 19 Sep 2022 14:40:31 +0200 Subject: [PATCH] fixed agent/module widget pandora_enterprise#9519 --- pandora_console/include/db/mysql.php | 10 +- pandora_console/include/functions_html.php | 67 ++++---- pandora_console/include/functions_modules.php | 10 +- .../lib/Dashboard/Widgets/agent_module.php | 147 +++++------------- .../operation/agentes/ver_agente.php | 11 +- 5 files changed, 90 insertions(+), 155 deletions(-) diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index 22690dee30..40eae95573 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -57,11 +57,17 @@ function mysql_connect_db( $port = $config['dbport']; } - if ($ssl === null && (bool) $config['dbssl'] === true) { + if ($ssl === null + && isset($config['dbssl']) === true + && (bool) $config['dbssl'] === true + ) { $ssl = $config['dbsslcafile']; } - if ($verify === null && (bool) $config['sslverifyservercert'] === true) { + if ($verify === null + && isset($config['sslverifyservercert']) === true + && (bool) $config['sslverifyservercert'] === true + ) { $verify = 'verified'; } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index c519645560..fb64fa2a13 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1664,44 +1664,31 @@ function html_print_select_multiple_modules_filtered(array $data):string ] ); - // Show common modules. - $selection = [ - 0 => __('Show common modules'), - 1 => __('Show all modules'), - ]; - - if (true) { - $output .= html_print_input( - [ - - 'label' => __('Only common modules'), - 'type' => 'switch', - 'value' => 'checked', - 'id' => 'filtered-module-show-common-modules-'.$uniqId, - 'return' => true, - 'onchange' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', - ] - ); - } else { - $output .= html_print_input( - [ - 'label' => __('Show common modules'), - 'type' => 'select', - 'fields' => $selection, - 'name' => 'filtered-module-show-common-modules-'.$uniqId, - 'return' => true, - 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', - ] - ); + $commonModules = 0; + if (empty($data['mShowCommonModules']) === false) { + $commonModules = 1; } + $output .= html_print_input( + [ + 'label' => __('Only common modules'), + 'type' => 'switch', + 'checked' => $commonModules, + 'value' => $commonModules, + 'name' => 'filtered-module-show-common-modules-'.$uniqId, + 'id' => 'filtered-module-show-common-modules-'.$uniqId, + 'return' => true, + 'onchange' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', + ] + ); + if (empty($data['mAgents']) === false && empty($data['mModuleGroup'] === false) ) { $all_modules = get_modules_agents( $data['mModuleGroup'], explode(',', $data['mAgents']), - $data['mShowCommonModules'], + !$commonModules, false, true ); @@ -1709,10 +1696,18 @@ function html_print_select_multiple_modules_filtered(array $data):string $all_modules = []; } + $mModules = $data['mModules']; if (is_array($data['mModules']) === false) { - $result = explode(((is_metaconsole() === true) ? SEPARATOR_META_MODULE : ','), $data['mModules']); - } else { - $result = $data['mModules']; + $mModules = explode( + ',', + $data['mModules'] + ); + } + + $result = []; + // Clean double safe input. + foreach ($mModules as $name) { + $result[] = io_safe_output($name); } $output .= html_print_input( @@ -4956,7 +4951,7 @@ function html_print_input($data, $wrapper='div', $input_only=false) $output = ''; if (($data['label'] ?? false) && $input_only === false) { - $output = '<'.$wrapper.' id="'.$wrapper.'-'.$data['name'].'" '; + $output = '<'.$wrapper.' id="'.$wrapper.'-'.($data['name'] ?? '').'" '; $output .= ' class="'.($data['input_class'] ?? '').'">'; $output .= '