From 60f9483e79bdbf13fb3857511716db36b24b23eb Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 19 Nov 2018 11:54:35 +0100 Subject: [PATCH 01/74] mandatory public_url if is set --- pandora_console/include/functions_ui.php | 45 ++++++++++++++---------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 7d02e1ac11..76ce70f59b 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -2407,29 +2407,38 @@ function ui_get_full_url ($url = '', $no_proxy = false, $add_name_php_file = fal $port = $_SERVER['SERVER_PORT']; } } - - if (!$no_proxy) { - //Check if the PandoraFMS runs across the proxy like as - //mod_proxy of Apache - //and check if public_url is setted - if (!empty($config['public_url']) - && (!empty($_SERVER['HTTP_X_FORWARDED_HOST']))) { - $fullurl = $config['public_url']; - $proxy = true; + + if (!empty($config['public_url'])) { + $fullurl = $config['public_url']; + // if user had specify a custom public_url, disable internal homeurl & homeurl_static + $config['homeurl'] = ''; + $config['homeurl_static'] = ''; + + } else { + + if (!$no_proxy) { + //Check if the PandoraFMS runs across the proxy like as + //mod_proxy of Apache + //and check if public_url is set + if (!empty($config['public_url']) + && (!empty($_SERVER['HTTP_X_FORWARDED_HOST']))) { + $fullurl = $config['public_url']; + $proxy = true; + } + else { + $fullurl = $protocol.'://' . $_SERVER['SERVER_NAME']; + } } else { $fullurl = $protocol.'://' . $_SERVER['SERVER_NAME']; } - } - else { - $fullurl = $protocol.'://' . $_SERVER['SERVER_NAME']; - } - - // using a different port than the standard - if (!$proxy) { + // using a different port than the standard - if ( $port != null ) { - $fullurl .= ":" . $port; + if (!$proxy) { + // using a different port than the standard + if ( $port != null ) { + $fullurl .= ":" . $port; + } } } From b90da54c8621eec98d991ccbf5499eddaeffe57c Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 19 Nov 2018 13:16:53 +0100 Subject: [PATCH 02/74] fixed public_url mandatory in MC environments --- pandora_console/include/functions_ui.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 76ce70f59b..40236629f2 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -2410,9 +2410,7 @@ function ui_get_full_url ($url = '', $no_proxy = false, $add_name_php_file = fal if (!empty($config['public_url'])) { $fullurl = $config['public_url']; - // if user had specify a custom public_url, disable internal homeurl & homeurl_static - $config['homeurl'] = ''; - $config['homeurl_static'] = ''; + $proxy = true; } else { From 08ea1b22837c95e4ee1aa53a3e4bb9db55c93b05 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 19 Nov 2018 14:15:34 +0100 Subject: [PATCH 03/74] minor fix ui_get_full_url --- pandora_console/include/functions_ui.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 40236629f2..cba6670e4c 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -2411,7 +2411,7 @@ function ui_get_full_url ($url = '', $no_proxy = false, $add_name_php_file = fal if (!empty($config['public_url'])) { $fullurl = $config['public_url']; $proxy = true; - + $fullurl .= '/'; } else { if (!$no_proxy) { From 932802acb49e326e0c73ba4bb0a53b465b7735d0 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 28 Mar 2019 15:16:09 +0100 Subject: [PATCH 04/74] Fixed netflow reports resolution Former-commit-id: f49404e7c1129344df026a81e4059e9276acf9eb --- pandora_console/include/functions_netflow.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 69aa0a1608..f1febb5c41 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -35,8 +35,8 @@ define('NETFLOW_RES_LOWD', 6); define('NETFLOW_RES_MEDD', 12); define('NETFLOW_RES_HID', 24); define('NETFLOW_RES_ULTRAD', 30); -define('NETFLOW_RES_HOURLY', 'hourly'); -define('NETFLOW_RES_DAILY', 'daily'); +define('NETFLOW_RES_HOURLY', -1); +define('NETFLOW_RES_DAILY', -2); define('NETFLOW_MAX_DATA_CIRCULAR_MESH', 10000); @@ -473,7 +473,7 @@ function netflow_get_data( // Put all points into an array. $intervals = [($start_date - $multiplier_time)]; - while ((end($intervals) < $end_date) === true) { + while (($next = (end($intervals) + $multiplier_time) < $end_date) === true) { $intervals[] = (end($intervals) + $multiplier_time); } From 74d64db497abc980379c2efbdee884c2cb56ef30 Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Mon, 8 Apr 2019 15:29:02 +0200 Subject: [PATCH 05/74] change name label from functions_visual_map_editor.php Former-commit-id: 9dd7f0c86268d9657b6054fca109aefb18020962 --- pandora_console/include/functions_visual_map_editor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index 151014cd01..3cb5c215ba 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -1245,7 +1245,7 @@ function visual_map_editor_print_toolbox() } echo '
'; - visual_map_print_button_editor('static_graph', __('Static Graph'), 'left', false, 'camera_min', true); + visual_map_print_button_editor('static_graph', __('Static Image'), 'left', false, 'camera_min', true); visual_map_print_button_editor('percentile_item', __('Percentile Item'), 'left', false, 'percentile_item_min', true); visual_map_print_button_editor('module_graph', __('Module Graph'), 'left', false, 'graph_min', true); visual_map_print_button_editor('donut_graph', __('Serialized pie graph'), 'left', false, 'donut_graph_min', true); From 550eb3cd3e8fd9699b0cb35eccb3ff0fd0768952 Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Mon, 8 Apr 2019 15:30:07 +0200 Subject: [PATCH 06/74] change name label from visual_console_builder.elements.php Former-commit-id: 71201d54200624452c4dd75231894d4cd4e29031 --- .../godmode/reporting/visual_console_builder.elements.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/reporting/visual_console_builder.elements.php b/pandora_console/godmode/reporting/visual_console_builder.elements.php index d2849ce5e0..720bb57a1c 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.elements.php +++ b/pandora_console/godmode/reporting/visual_console_builder.elements.php @@ -171,7 +171,7 @@ foreach ($layoutDatas as $layoutData) { $table->data[($i + 1)]['icon'] = html_print_image( 'images/camera.png', true, - ['title' => __('Static Graph')] + ['title' => __('Static Image')] ); break; From 4d98db86e711eb13baeb9767f1fa60c5a7dc7682 Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Mon, 8 Apr 2019 15:30:48 +0200 Subject: [PATCH 07/74] change name label from functions_visual_map.php Former-commit-id: c6bf206301662993be9f41f1d1259e1373060776 --- pandora_console/include/functions_visual_map.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 5344eb15ee..0d3180fcf3 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -4241,7 +4241,7 @@ function visual_map_create_internal_name_item($label=null, $type, $image, $agent case 'static_graph': case STATIC_GRAPH: - $text = __('Static graph').' - '.$image; + $text = __('Static Image').' - '.$image; break; case 'simple_value': From 7a1a6822489ba03907c11119869d330d0a778a87 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 12 Apr 2019 13:09:26 +0200 Subject: [PATCH 08/74] Added advice when a primary group will be selected when is currentl a secondary group Former-commit-id: ca23bc1f24b901c2300385ee6d3468dc5059d51d --- pandora_console/godmode/agentes/agent_manager.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index a7fc1f156a..9996d0946e 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -999,6 +999,19 @@ ui_require_jquery_file('bgiframe'); } $(document).ready (function() { + + var previous_primary_group_select; + $("#grupo").on('focus', function () { + previous_primary_group_select = this.value; + }).change(function() { + if ($("#secondary_groups_selected option[value="+$("#grupo").val()+"]").length) { + alert(""); + $("#grupo").val(previous_primary_group_select); + } else { + previous_primary_group_select = this.value; + } + }); + $("select#id_os").pandoraSelectOS (); var checked = $("#checkbox-cascade_protection").is(":checked"); From 43d8a25c39ef229fca313af22bbd600ec11c3cc8 Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Wed, 24 Apr 2019 16:49:04 +0200 Subject: [PATCH 09/74] Add remaning attemps Former-commit-id: 07960eaa4b3281ee13f14b0fc5249b94ac0626fa --- pandora_console/general/login_page.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index d8e28223c6..84df350d3c 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -376,6 +376,9 @@ if (isset($correct_reset_pass_process)) { } if (isset($login_failed)) { + $nick = get_parameter_post('nick'); + $fails = db_get_value('failed_attempt', 'tusuario', 'id_user', $nick); + $attemps = ($config['number_attempts'] - $fails); echo '
'; echo '
'; echo '
'; @@ -386,6 +389,9 @@ if (isset($login_failed)) { echo '

'.__('ERROR').'

'; echo '

'.$config['auth_error'].'

'; echo '
'; + echo '
'; + echo '

Remaining attempts: '.$attemps.'

'; + echo '
'; echo '
'; html_print_submit_button('Ok', 'hide-login-error', false); echo '
'; From d7ca0f11340d6b5c3f2cf5f9095ef837d0338f7a Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Wed, 24 Apr 2019 16:51:41 +0200 Subject: [PATCH 10/74] Add strong Former-commit-id: 68b08a3a6f7dbdd4365b88faf9bfb678e506a5ac --- pandora_console/general/login_page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index 84df350d3c..3e0acb3576 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -390,7 +390,7 @@ if (isset($login_failed)) { echo '

'.$config['auth_error'].'

'; echo '
'; echo '
'; - echo '

Remaining attempts: '.$attemps.'

'; + echo '

Remaining attempts: '.$attemps.'

'; echo '
'; echo '
'; html_print_submit_button('Ok', 'hide-login-error', false); From de4ea8434aebba5070205972bc9965d335a811e7 Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Wed, 24 Apr 2019 17:11:02 +0200 Subject: [PATCH 11/74] Se ajusta la ventana de usuario bloqueado Former-commit-id: dca9700142a5f4b539892f8727d8e5c83222312b --- pandora_console/general/login_page.php | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index 3e0acb3576..193a0d2d15 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -685,5 +685,6 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' $("#final_process_correct").dialog('close'); }); }); + /* ]]> */ From dcfb9c9b61da306d3f530e3d3f1a0635db328c1d Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Wed, 24 Apr 2019 17:45:01 +0200 Subject: [PATCH 12/74] se actualiza en mensaje en la meta Former-commit-id: b20edf93845577c1fdd551211907a25888c6543a --- pandora_console/general/login_page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index 193a0d2d15..42e6568890 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -391,7 +391,7 @@ if (isset($login_failed)) { echo '
'; echo '
'; echo '

Remaining attempts: '.$attemps.'

'; - echo '
'; + echo '
'; echo '
'; html_print_submit_button('Ok', 'hide-login-error', false); echo '
'; From 105695f1bd039abe2ef0f8aeb43037a531e784c1 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Fri, 17 May 2019 18:29:38 +0200 Subject: [PATCH 13/74] Added notification for serialize_precicion value --- .../include/class/ConsoleSupervisor.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 7259287d68..d9bea3ffbe 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -1233,6 +1233,7 @@ class ConsoleSupervisor $PHPdisable_functions = ini_get('disable_functions'); $PHPupload_max_filesize_min = config_return_in_bytes('800M'); $PHPmemory_limit_min = config_return_in_bytes('500M'); + $PHPSerialize_precision = ini_get('serialize_precision'); // PhantomJS status. $result_ejecution = exec($config['phantomjs_bin'].'/phantomjs --version'); @@ -1408,6 +1409,30 @@ class ConsoleSupervisor } else { $this->cleanNotifications('NOTIF.PHP.VERSION'); } + + if ($PHPSerialize_precision != -1) { + $url = 'https://www.php.net/manual/en/ini.core.php#ini.serialize-precision'; + if ($config['language'] == 'es') { + $url = 'https://www.php.net/manual/es/ini.core.php#ini.serialize-precision'; + } + + $this->notify( + [ + 'type' => 'NOTIF.PHP.SERIALIZE_PRECISION', + 'title' => sprintf( + __("Not recommended '%s' value in PHP configuration"), + 'serialze_precision' + ), 'message' => sprintf( + __('Recommended value is: %s'), + sprintf('-1') + ).'

'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'), + 'url' => $url, + ] + ); + } else { + $this->cleanNotifications('NOTIF.PHP.VERSION'); + } + } From 4b6c21bb309c82ae67daf826739437254d700db8 Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Tue, 4 Jun 2019 11:44:11 +0200 Subject: [PATCH 14/74] Add policies to general search and deleted help functions --- pandora_console/operation/search_main.php | 11 +- .../operation/search_policies.getdata.php | 199 ++++++++++++++++++ pandora_console/operation/search_policies.php | 65 ++++++ pandora_console/operation/search_results.php | 41 ++-- 4 files changed, 294 insertions(+), 22 deletions(-) create mode 100644 pandora_console/operation/search_policies.getdata.php create mode 100644 pandora_console/operation/search_policies.php diff --git a/pandora_console/operation/search_main.php b/pandora_console/operation/search_main.php index ffc9d93f74..d5ae3bff42 100644 --- a/pandora_console/operation/search_main.php +++ b/pandora_console/operation/search_main.php @@ -20,6 +20,7 @@ $searchGraphs = check_acl($config['id_user'], 0, 'RR'); $searchMaps = check_acl($config['id_user'], 0, 'RR'); $searchReports = check_acl($config['id_user'], 0, 'RR'); $searchUsers = check_acl($config['id_user'], 0, 'UM'); +$searchPolicies = check_acl($config['id_user'], 0, 'UM'); $searchHelps = true; echo '
'; @@ -44,8 +45,12 @@ $table->style[9] = 'font-weight: bold; text-align: center;'; $table->style[10] = 'font-weight: bold; text-align: center;'; $table->style[11] = 'font-weight: bold; text-align: center;'; $table->style[13] = 'font-weight: bold; text-align: center;'; +$table->style[14] = 'font-weight: bold; text-align: center;'; $table->style[15] = 'font-weight: bold; text-align: center;'; + + + $table->data[0][0] = html_print_image('images/agent.png', true, ['title' => __('Agents found')]); $table->data[0][1] = "".sprintf(__('%s Found'), $totalAgents).''; $table->data[0][2] = html_print_image('images/module.png', true, ['title' => __('Modules found')]); @@ -64,8 +69,10 @@ $table->data[0][10] = html_print_image('images/reporting.png', true, ['title' => $table->data[0][11] = "".sprintf(__('%s Found'), $totalReports).''; $table->data[0][12] = html_print_image('images/visual_console_green.png', true, ['title' => __('Maps found')]); $table->data[0][13] = "".sprintf(__('%s Found'), $totalMaps).''; -$table->data[0][14] = html_print_image('images/help.png', true, ['title' => __('Helps found')]); -$table->data[0][15] = "".sprintf(__('%s Found'), $totalHelps).''; +if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { + $table->data[0][14] = html_print_image('images/policies.png', true, ['title' => __('Policies')]); + $table->data[0][15] = "".sprintf(__('%s Found'), $totalPolicies).''; +} html_print_table($table); diff --git a/pandora_console/operation/search_policies.getdata.php b/pandora_console/operation/search_policies.getdata.php new file mode 100644 index 0000000000..c91e7e4279 --- /dev/null +++ b/pandora_console/operation/search_policies.getdata.php @@ -0,0 +1,199 @@ + 'id', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectpolicieIDDown = $selected; + $order = [ + 'field' => 'id', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'name': + switch ($sort) { + case 'up': + $selectNameUp = $selected; + $order = [ + 'field' => 'name', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectNameDown = $selected; + $order = [ + 'field' => 'name', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'description': + switch ($sort) { + case 'up': + $selectId_groupUp = $selected; + $order = [ + 'field' => 'description', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectDescriptionDown = $selected; + $order = [ + 'field' => 'description', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'last_contact': + switch ($sort) { + case 'up': + $selectId_groupUp = $selected; + $order = [ + 'field' => 'last_connect', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectId_groupDown = $selected; + $order = [ + 'field' => 'last_connect', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'id_group': + switch ($sort) { + case 'up': + $selectId_groupUp = $selected; + $order = [ + 'field' => 'last_connect', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectId_groupDown = $selected; + $order = [ + 'field' => 'last_connect', + 'order' => 'DESC', + ]; + break; + } + break; + + case 'status': + switch ($sort) { + case 'up': + $selectStatusUp = $selected; + $order = [ + 'field' => 'is_admin', + 'order' => 'ASC', + ]; + break; + + case 'down': + $selectStatusDown = $selected; + $order = [ + 'field' => 'is_admin', + 'order' => 'DESC', + ]; + break; + } + break; + + default: + $selectpolicieIDUp = $selected; + $selectpolicieIDDown = ''; + $selectNameUp = ''; + $selectNameDown = ''; + $selectDescriptionUp = ''; + $selectDescriptionDown = ''; + $selectId_groupUp = ''; + $selectId_groupDown = ''; + $selectStatusUp = ''; + $selectStatusDown = ''; + + $order = [ + 'field' => 'id', + 'order' => 'ASC', + ]; + break; +} + +if ($searchpolicies == 0) { + $sql = "SELECT id, name, description, id_group, status FROM tpolicies + WHERE name LIKE '%".$stringSearchSQL."%' OR + description LIKE '%".$stringSearchSQL."%' + ORDER BY ".$order['field'].' '.$order['order']; +} + + $sql .= ' LIMIT '.$config['block_size'].' OFFSET '.get_parameter('offset', 0); + + + $policies = db_process_sql($sql); + +if ($policies !== false) { + if ($only_count) { + unset($policies); + } + + $sql = "SELECT COUNT(id) AS count FROM tpolicies + WHERE name LIKE '%".$stringSearchSQL."%' OR + description LIKE '%".$stringSearchSQL."%'"; + + + // q$totalPolicies = db_get_value_sql($sql); + $totalPolicies = count($policies); +} else { + $totalPolicies = 0; +} diff --git a/pandora_console/operation/search_policies.php b/pandora_console/operation/search_policies.php new file mode 100644 index 0000000000..8f339b7c1b --- /dev/null +++ b/pandora_console/operation/search_policies.php @@ -0,0 +1,65 @@ +
".__('Zero results found')."
\n"; +} else { + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->width = '98%'; + $table->class = 'databox'; + + $table->align = []; + $table->align[4] = 'center'; + + $table->head = []; + $table->head[0] = __('ID').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectpolicieIDUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectpolicieIDDown]).''; + $table->head[1] = __('Name').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectNameUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectNameDown]).''; + $table->head[2] = __('Description').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectDescriptionUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectDescriptionDown]).''; + $table->head[3] = __('Id_group').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectId_groupUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectId_groupDown]).''; + $table->head[4] = __('Status').' '.''.html_print_image('images/sort_up.png', true, ['style' => $selectStatusUp]).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectstatusDown]).''; + + $table->data = []; + + foreach ($policies as $policie) { + $policieIDCell = "".$policies['id'].''; + + + array_push( + $table->data, + [ + $policie['id'], + $policie['name'], + $policie['description'], + $policie['id_group'], + $policie['status'], + + ] + ); + } + + $totalPolicies = count($policies); + echo '
'; + ui_pagination($totalPolicies); + html_print_table($table); + unset($table); + ui_pagination($totalPolicies); +} diff --git a/pandora_console/operation/search_results.php b/pandora_console/operation/search_results.php index d59e6908cb..cbd49ccc28 100644 --- a/pandora_console/operation/search_results.php +++ b/pandora_console/operation/search_results.php @@ -18,7 +18,7 @@ require_once $config['homedir'].'/include/functions_reporting.php'; enterprise_include('operation/reporting/custom_reporting.php'); $searchAgents = $searchAlerts = $searchModules = check_acl($config['id_user'], 0, 'AR'); -$searchUsers = check_acl($config['id_user'], 0, 'UM'); +$searchUsers = $searchPolicies = check_acl($config['id_user'], 0, 'UM'); $searchMaps = $searchReports = $searchGraphs = check_acl($config['id_user'], 0, 'IR'); $searchMain = true; $searchHelps = true; @@ -43,6 +43,7 @@ if ($config['search_category'] == 'all') { // INI SECURITY ACL if ((!$searchAgents && !$searchUsers && !$searchMaps) || (!$searchUsers && $searchTab == 'users') + || (!$searchPolicies && $searchTab == 'policies') || (!$searchAgents && ($searchTab == 'agents' || $searchTab == 'alerts')) || (!$searchGraphs && ($searchTab == 'graphs' || $searchTab == 'maps' || $searchTab == 'reports')) ) { @@ -161,29 +162,29 @@ if ($searchModules) { $modules_tab = ''; } -if ($searchHelps) { - $helps_tab = [ - 'text' => "".html_print_image( - 'images/help_w.png', +if ($searchPolicies) { + $policies_tab = [ + 'text' => "".html_print_image( + 'images/policies.png', true, - ['title' => __('Helps')] + ['title' => __('Policies')] ).'', - 'active' => $searchTab == 'helps', + 'active' => $searchTab == 'policies', ]; } else { - $helps_tab = ''; + $policies_tab = ''; } $onheader = [ - 'main' => $main_tab, - 'agents' => $agents_tab, - 'modules' => $modules_tab, - 'alerts' => $alerts_tab, - 'users' => $users_tab, - 'graphs' => $graphs_tab, - 'reports' => $reports_tab, - 'maps' => $maps_tab, - 'helps' => $helps_tab, + 'main' => $main_tab, + 'agents' => $agents_tab, + 'modules' => $modules_tab, + 'alerts' => $alerts_tab, + 'users' => $users_tab, + 'graphs' => $graphs_tab, + 'reports' => $reports_tab, + 'maps' => $maps_tab, + 'policies' => $policies_tab, ]; ui_print_page_header( @@ -251,8 +252,8 @@ switch ($searchTab) { include_once 'search_modules.php'; break; - case 'helps': - include_once 'search_helps.getdata.php'; - include_once 'search_helps.php'; + case 'policies': + include_once 'search_policies.getdata.php'; + include_once 'search_policies.php'; break; } From c5cb76b2714e559a9acc6a60267653e8c476da5e Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Tue, 4 Jun 2019 11:52:56 +0200 Subject: [PATCH 15/74] Add policies to general search --- pandora_console/operation/search_policies.getdata.php | 1 + pandora_console/operation/search_results.php | 1 + 2 files changed, 2 insertions(+) diff --git a/pandora_console/operation/search_policies.getdata.php b/pandora_console/operation/search_policies.getdata.php index c91e7e4279..fd97335421 100644 --- a/pandora_console/operation/search_policies.getdata.php +++ b/pandora_console/operation/search_policies.getdata.php @@ -177,6 +177,7 @@ if ($searchpolicies == 0) { ORDER BY ".$order['field'].' '.$order['order']; } + $sql .= ' LIMIT '.$config['block_size'].' OFFSET '.get_parameter('offset', 0); diff --git a/pandora_console/operation/search_results.php b/pandora_console/operation/search_results.php index cbd49ccc28..e4dbe38a0c 100644 --- a/pandora_console/operation/search_results.php +++ b/pandora_console/operation/search_results.php @@ -255,5 +255,6 @@ switch ($searchTab) { case 'policies': include_once 'search_policies.getdata.php'; include_once 'search_policies.php'; + break; } From 22efc4ba44c2d2fe4b1a820e436d40156ea92506 Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Tue, 4 Jun 2019 17:05:17 +0200 Subject: [PATCH 16/74] Resolved problem with counts on search main --- pandora_console/operation/search_graphs.getdata.php | 4 ++++ pandora_console/operation/search_main.php | 1 + pandora_console/operation/search_policies.getdata.php | 6 ++---- pandora_console/operation/search_policies.php | 2 +- pandora_console/operation/search_results.php | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pandora_console/operation/search_graphs.getdata.php b/pandora_console/operation/search_graphs.getdata.php index aefd6e2073..bd3159d72f 100644 --- a/pandora_console/operation/search_graphs.getdata.php +++ b/pandora_console/operation/search_graphs.getdata.php @@ -26,6 +26,7 @@ if ($searchGraphs) { $usergraphs_id = array_keys($usergraphs); if (empty($usergraphs_id)) { + $totalGraphs = 0; return; } @@ -37,6 +38,7 @@ if ($searchGraphs) { 'id_graph', 'name', 'description', + ]; $totalGraphs = (int) db_get_value_filter('COUNT(id_graph) AS count', 'tgraph', $filter); @@ -46,4 +48,6 @@ if ($searchGraphs) { $filter['offset'] = (int) get_parameter('offset'); $graphs = db_get_all_rows_filter('tgraph', $filter, $columns); } + + $totalGraphs = 0; } diff --git a/pandora_console/operation/search_main.php b/pandora_console/operation/search_main.php index d5ae3bff42..f4ba5e3f91 100644 --- a/pandora_console/operation/search_main.php +++ b/pandora_console/operation/search_main.php @@ -86,4 +86,5 @@ if ($searchAgents && $totalAgents > 0) { ).''; } + echo '
'; diff --git a/pandora_console/operation/search_policies.getdata.php b/pandora_console/operation/search_policies.getdata.php index fd97335421..0a28651e7a 100644 --- a/pandora_console/operation/search_policies.getdata.php +++ b/pandora_console/operation/search_policies.getdata.php @@ -13,8 +13,7 @@ // GNU General Public License for more details. global $config; - -require_once $config['homedir'].'/enterprise/include/functions_policies.php'; +enterprise_include_once('include/functions_policies.php'); $searchpolicies = check_acl($config['id'], 0, 'UM'); @@ -193,8 +192,7 @@ if ($policies !== false) { description LIKE '%".$stringSearchSQL."%'"; - // q$totalPolicies = db_get_value_sql($sql); - $totalPolicies = count($policies); + $totalPolicies = db_get_value_sql($sql); } else { $totalPolicies = 0; } diff --git a/pandora_console/operation/search_policies.php b/pandora_console/operation/search_policies.php index 8f339b7c1b..c048e12c7c 100644 --- a/pandora_console/operation/search_policies.php +++ b/pandora_console/operation/search_policies.php @@ -14,7 +14,7 @@ global $config; // require_once $config['homedir'].'/include/functions_status.php'; -require_once $config['homedir'].'/enterprise/include/functions_policies.php'; +enterprise_include_once('include/functions_policies.php'); require_once $config['homedir'].'/enterprise/include/functions_groups.php'; $searchpolicies = check_acl($config['id_user'], 0, 'UM'); diff --git a/pandora_console/operation/search_results.php b/pandora_console/operation/search_results.php index e4dbe38a0c..11b4aedec9 100644 --- a/pandora_console/operation/search_results.php +++ b/pandora_console/operation/search_results.php @@ -213,6 +213,7 @@ switch ($searchTab) { include_once 'search_maps.getdata.php'; include_once 'search_modules.getdata.php'; include_once 'search_helps.getdata.php'; + include_once 'search_policies.getdata.php'; include_once 'search_main.php'; break; From 9bc83b4ffd7c2275ab53a83ae237faef499f5d5b Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Tue, 4 Jun 2019 17:08:08 +0200 Subject: [PATCH 17/74] Add new else --- pandora_console/operation/search_graphs.getdata.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/operation/search_graphs.getdata.php b/pandora_console/operation/search_graphs.getdata.php index bd3159d72f..4dc6f3ba74 100644 --- a/pandora_console/operation/search_graphs.getdata.php +++ b/pandora_console/operation/search_graphs.getdata.php @@ -47,7 +47,7 @@ if ($searchGraphs) { $filter['limit'] = $config['block_size']; $filter['offset'] = (int) get_parameter('offset'); $graphs = db_get_all_rows_filter('tgraph', $filter, $columns); + } else { + $totalGraphs = 0; } - - $totalGraphs = 0; } From 1ee347684e5357766142b3c4b0ff34f7dcf61ad8 Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Wed, 5 Jun 2019 10:17:28 +0200 Subject: [PATCH 18/74] Added condition if enterprise installed --- pandora_console/operation/search_main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/operation/search_main.php b/pandora_console/operation/search_main.php index f4ba5e3f91..2da3377ff4 100644 --- a/pandora_console/operation/search_main.php +++ b/pandora_console/operation/search_main.php @@ -69,7 +69,7 @@ $table->data[0][10] = html_print_image('images/reporting.png', true, ['title' => $table->data[0][11] = "".sprintf(__('%s Found'), $totalReports).''; $table->data[0][12] = html_print_image('images/visual_console_green.png', true, ['title' => __('Maps found')]); $table->data[0][13] = "".sprintf(__('%s Found'), $totalMaps).''; -if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { +if (enterprise_installed()) { $table->data[0][14] = html_print_image('images/policies.png', true, ['title' => __('Policies')]); $table->data[0][15] = "".sprintf(__('%s Found'), $totalPolicies).''; } From 738958386a0e70e53823ca561e3457d0741dc8ed Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Tue, 11 Jun 2019 10:01:51 +0200 Subject: [PATCH 19/74] guardo cambios --- pandora_console/operation/search_main.php | 2 +- .../operation/search_policies.getdata.php | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pandora_console/operation/search_main.php b/pandora_console/operation/search_main.php index 2da3377ff4..b236539695 100644 --- a/pandora_console/operation/search_main.php +++ b/pandora_console/operation/search_main.php @@ -69,7 +69,7 @@ $table->data[0][10] = html_print_image('images/reporting.png', true, ['title' => $table->data[0][11] = "".sprintf(__('%s Found'), $totalReports).''; $table->data[0][12] = html_print_image('images/visual_console_green.png', true, ['title' => __('Maps found')]); $table->data[0][13] = "".sprintf(__('%s Found'), $totalMaps).''; -if (enterprise_installed()) { +if (enterprise_installed() || is_metaconsole()) { $table->data[0][14] = html_print_image('images/policies.png', true, ['title' => __('Policies')]); $table->data[0][15] = "".sprintf(__('%s Found'), $totalPolicies).''; } diff --git a/pandora_console/operation/search_policies.getdata.php b/pandora_console/operation/search_policies.getdata.php index 0a28651e7a..0288c24d1b 100644 --- a/pandora_console/operation/search_policies.getdata.php +++ b/pandora_console/operation/search_policies.getdata.php @@ -177,19 +177,33 @@ if ($searchpolicies == 0) { } - $sql .= ' LIMIT '.$config['block_size'].' OFFSET '.get_parameter('offset', 0); + $sql .= ' LIMIT '.$config['block_size'].' OFFSET '.get_parameter('offset', 0); $policies = db_process_sql($sql); + $sql = "SELECT id_grupo FROM tusuario_perfil + WHERE id_usuario LIKE '%".$config['id_user']."%'"; + + $groups_for_search = db_process_sql($sql); + + +foreach ($policies as $p) { + foreach ($groups_for_search as $group) { + if ($p['id_group'] == $group['id_grupo'] || $group['id_grupo'] == 0) { + $policies_final = $p; + } + } +} + +$policies = $policies_final; if ($policies !== false) { if ($only_count) { unset($policies); } $sql = "SELECT COUNT(id) AS count FROM tpolicies - WHERE name LIKE '%".$stringSearchSQL."%' OR - description LIKE '%".$stringSearchSQL."%'"; + WHERE id = '".$policies_final['id']."'"; $totalPolicies = db_get_value_sql($sql); From 23469796f89cdee6c959eeb75addc843e8f4f826 Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Tue, 11 Jun 2019 16:23:42 +0200 Subject: [PATCH 20/74] Limited result for user groups --- .../operation/search_policies.getdata.php | 38 ++++++------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/pandora_console/operation/search_policies.getdata.php b/pandora_console/operation/search_policies.getdata.php index 0288c24d1b..980a71cec8 100644 --- a/pandora_console/operation/search_policies.getdata.php +++ b/pandora_console/operation/search_policies.getdata.php @@ -170,43 +170,27 @@ switch ($sortField) { } if ($searchpolicies == 0) { - $sql = "SELECT id, name, description, id_group, status FROM tpolicies - WHERE name LIKE '%".$stringSearchSQL."%' OR - description LIKE '%".$stringSearchSQL."%' - ORDER BY ".$order['field'].' '.$order['order']; + $user_groups = users_get_groups($config['id_user'], 'AR', false); + $id_user_groups = array_keys($user_groups); + $id_user_groups_str = implode(',', $id_user_groups); + + $sql = "SELECT id, name, description, id_group, status + FROM tpolicies + WHERE name LIKE '$stringSearchSQL' + AND id_group IN ($id_user_groups_str)"; } - $sql .= ' LIMIT '.$config['block_size'].' OFFSET '.get_parameter('offset', 0); - + $sql .= ' LIMIT '.$config['block_size'].' OFFSET '.get_parameter('offset', 0); $policies = db_process_sql($sql); - $sql = "SELECT id_grupo FROM tusuario_perfil - WHERE id_usuario LIKE '%".$config['id_user']."%'"; - - $groups_for_search = db_process_sql($sql); - - -foreach ($policies as $p) { - foreach ($groups_for_search as $group) { - if ($p['id_group'] == $group['id_grupo'] || $group['id_grupo'] == 0) { - $policies_final = $p; - } - } -} - -$policies = $policies_final; if ($policies !== false) { + $totalPolicies = count($policies); + if ($only_count) { unset($policies); } - - $sql = "SELECT COUNT(id) AS count FROM tpolicies - WHERE id = '".$policies_final['id']."'"; - - - $totalPolicies = db_get_value_sql($sql); } else { $totalPolicies = 0; } From 4b224d1314d9b71dae9c58e94d3a7731193b471e Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Wed, 12 Jun 2019 10:13:37 +0200 Subject: [PATCH 21/74] ad coments and delete is_metaconsole() condition --- pandora_console/operation/search_main.php | 2 +- pandora_console/operation/search_policies.getdata.php | 4 ++++ pandora_console/operation/search_policies.php | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pandora_console/operation/search_main.php b/pandora_console/operation/search_main.php index b236539695..2da3377ff4 100644 --- a/pandora_console/operation/search_main.php +++ b/pandora_console/operation/search_main.php @@ -69,7 +69,7 @@ $table->data[0][10] = html_print_image('images/reporting.png', true, ['title' => $table->data[0][11] = "".sprintf(__('%s Found'), $totalReports).''; $table->data[0][12] = html_print_image('images/visual_console_green.png', true, ['title' => __('Maps found')]); $table->data[0][13] = "".sprintf(__('%s Found'), $totalMaps).''; -if (enterprise_installed() || is_metaconsole()) { +if (enterprise_installed()) { $table->data[0][14] = html_print_image('images/policies.png', true, ['title' => __('Policies')]); $table->data[0][15] = "".sprintf(__('%s Found'), $totalPolicies).''; } diff --git a/pandora_console/operation/search_policies.getdata.php b/pandora_console/operation/search_policies.getdata.php index 980a71cec8..aec8298170 100644 --- a/pandora_console/operation/search_policies.getdata.php +++ b/pandora_console/operation/search_policies.getdata.php @@ -170,6 +170,10 @@ switch ($sortField) { } if ($searchpolicies == 0) { + /* + We take the user groups to get policies that meet the requirements of the search + and which the user have permission on this groups + */ $user_groups = users_get_groups($config['id_user'], 'AR', false); $id_user_groups = array_keys($user_groups); $id_user_groups_str = implode(',', $id_user_groups); diff --git a/pandora_console/operation/search_policies.php b/pandora_console/operation/search_policies.php index c048e12c7c..a71d76a733 100644 --- a/pandora_console/operation/search_policies.php +++ b/pandora_console/operation/search_policies.php @@ -13,7 +13,6 @@ // GNU General Public License for more details. global $config; -// require_once $config['homedir'].'/include/functions_status.php'; enterprise_include_once('include/functions_policies.php'); require_once $config['homedir'].'/enterprise/include/functions_groups.php'; From 2b59f3e184ff98be02f880d53a8aaae22c8dc4e2 Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Thu, 13 Jun 2019 17:06:43 +0200 Subject: [PATCH 22/74] Changed Ignore Time texto to Scheduled shutdown fms --- pandora_console/include/functions_reporting_html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 10bef8631f..f0f3a1c168 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -753,7 +753,7 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0) $table1->size[10] = '2%'; $table1->data[0][10] = ''; $table1->size[11] = '15%'; - $table1->data[0][11] = ''.__('Ignore time').''; + $table1->data[0][11] = ''.__('Scheduled shutdown').''; if ($pdf === 0) { $table->colspan['legend']['cell'] = 2; @@ -3335,7 +3335,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0) $table2->size[10] = '2%'; $table2->data[0][10] = ''; $table2->size[11] = '15%'; - $table2->data[0][11] = ''.__('Ignore time').''; + $table2->data[0][11] = ''.__('Scheduled shutdown').''; } if ($pdf !== 0) { From f1700fa927e052d121194f571d8289dd21759f08 Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Thu, 13 Jun 2019 17:21:33 +0200 Subject: [PATCH 23/74] Changed Ignore time to Scheduled shutdown fms --- pandora_console/include/functions_reporting_html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 10bef8631f..f0f3a1c168 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -753,7 +753,7 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0) $table1->size[10] = '2%'; $table1->data[0][10] = ''; $table1->size[11] = '15%'; - $table1->data[0][11] = ''.__('Ignore time').''; + $table1->data[0][11] = ''.__('Scheduled shutdown').''; if ($pdf === 0) { $table->colspan['legend']['cell'] = 2; @@ -3335,7 +3335,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0) $table2->size[10] = '2%'; $table2->data[0][10] = ''; $table2->size[11] = '15%'; - $table2->data[0][11] = ''.__('Ignore time').''; + $table2->data[0][11] = ''.__('Scheduled shutdown').''; } if ($pdf !== 0) { From 2fe0d22d7dfd692660352aa7a4d9baae53d2617c Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Thu, 13 Jun 2019 17:27:49 +0200 Subject: [PATCH 24/74] x --- .../visual_console_builder.editor.js | 97 +++++++++++++++++-- 1 file changed, 88 insertions(+), 9 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index e5f1377be1..85cbd9be5e 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -1,3 +1,5 @@ +/* globals $ */ + // Pandora FMS - http://pandorafms.com // ================================================== // Copyright (c) 2005-2009 Artica Soluciones Tecnologicas @@ -31,6 +33,8 @@ var SIZE_GRID = 16; //Const the size (for width and height) of grid. var img_handler_start; var img_handler_end; +var default_cache_expiration = null; + function toggle_advance_options_palette(close) { if ($("#advance_options").css("display") == "none") { $("#advance_options").css("display", ""); @@ -679,12 +683,17 @@ function update_button_palette_callback() { return false; } } - if (values["module"] == 0) { + var radio_value = $("input[name='radio_choice']:checked").val(); + if (values["agent"] == "" && radio_value == "module_graph") { + dialog_message("#message_alert_no_agent"); + return false; + } + if (values["module"] == 0 && radio_value == "module_graph") { dialog_message("#message_alert_no_module"); return false; } - if (values["agent"] == "") { - dialog_message("#message_alert_no_agent"); + if (values["id_custom_graph"] == 0 && radio_value == "custom_graph") { + dialog_message("#message_alert_no_custom_graph"); return false; } if ($("input[name=width_module_graph]").val() == "") { @@ -1095,10 +1104,11 @@ function readFields() { var text = tinymce.get("text-label").getContent(); values["label"] = text; + values["percentile_label_color"] = $( + "input[name=percentile_label_color]" + ).val(); + if ($("input[name=percentile_label]").val().length > 0) { - values["percentile_label_color"] = $( - "input[name=percentile_label_color]" - ).val(); values["label"] = " Date: Fri, 14 Jun 2019 09:25:51 +0200 Subject: [PATCH 25/74] Changed Scheduled shutdown to Planned Downtime on fms --- pandora_console/include/functions_reporting_html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index f0f3a1c168..711c038cbc 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -753,7 +753,7 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0) $table1->size[10] = '2%'; $table1->data[0][10] = ''; $table1->size[11] = '15%'; - $table1->data[0][11] = ''.__('Scheduled shutdown').''; + $table1->data[0][11] = ''.__('Planned Downtime').''; if ($pdf === 0) { $table->colspan['legend']['cell'] = 2; @@ -3335,7 +3335,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0) $table2->size[10] = '2%'; $table2->data[0][10] = ''; $table2->size[11] = '15%'; - $table2->data[0][11] = ''.__('Scheduled shutdown').''; + $table2->data[0][11] = ''.__('Planned Downtime').''; } if ($pdf !== 0) { From 04d3f315b0b9a6c4489b242896fd5965ed541b04 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Tue, 25 Jun 2019 15:19:40 +0200 Subject: [PATCH 26/74] Added selector for all or common modules- #2140 --- .../godmode/agentes/agent_manager.php | 12 ++++++++- .../agent_wizard.snmp_interfaces_explorer.php | 27 ++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 7c6a3ab03b..f62354d910 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -77,6 +77,7 @@ if (is_ajax()) { } $get_modules_json_for_multiple_snmp = (bool) get_parameter('get_modules_json_for_multiple_snmp', 0); + $get_common_modules = (bool) get_parameter('get_common_modules', 1); if ($get_modules_json_for_multiple_snmp) { include_once 'include/graphs/functions_utils.php'; @@ -100,7 +101,16 @@ if (is_ajax()) { if ($out === false) { $out = $oid_snmp; } else { - $out = array_intersect($out, $oid_snmp); + $commons = array_intersect($out, $oid_snmp); + if ($get_common_modules) { + // Common modules is selected (default) + $out = $commons; + } else { + // All modules is selected + $array1 = array_diff($out, $oid_snmp); + $array2 = array_diff($oid_snmp, $out); + $out = array_merge($commons, $array1, $array2); + } } $oid_snmp = []; diff --git a/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php b/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php index b08dc62c4f..33279059ea 100644 --- a/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php +++ b/pandora_console/godmode/agentes/agent_wizard.snmp_interfaces_explorer.php @@ -583,7 +583,24 @@ if (!empty($interfaces_list)) { $table->data[0][2] = ''.__('Modules').''; $table->data[1][0] = html_print_select($interfaces_list, 'id_snmp[]', 0, false, '', '', true, true, true, '', false, 'width:500px; overflow: auto;'); - $table->data[1][1] = html_print_image('images/darrowright.png', true); + + $table->data[1][1] = __('When selecting interfaces'); + $table->data[1][1] .= '
'; + $table->data[1][1] .= html_print_select( + [ + 1 => __('Show common modules'), + 0 => __('Show all modules'), + ], + 'modules_selection_mode', + 1, + false, + '', + '', + true, + false, + false + ); + $table->data[1][2] = html_print_select([], 'module[]', 0, false, '', 0, true, true, true, '', false, 'width:200px;'); $table->data[1][2] .= html_print_input_hidden('agent', $id_agent, true); @@ -628,10 +645,17 @@ $(document).ready (function () { $("#no_snmp").hide (); $("#form_interfaces").hide (); }); + + // When select interfaces changes + $("#modules_selection_mode").change (function() { + $("#id_snmp").trigger('change'); + }); + }); function snmp_changed_by_multiple_snmp (event, id_snmp, selected) { var idSNMP = Array(); + var get_common_modules = $("#modules_selection_mode option:selected").val(); jQuery.each ($("#id_snmp option:selected"), function (i, val) { idSNMP.push($(val).val()); @@ -643,6 +667,7 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) { jQuery.post ('ajax.php', {"page" : "godmode/agentes/agent_manager", "get_modules_json_for_multiple_snmp": 1, + "get_common_modules" : get_common_modules, "id_snmp[]": idSNMP, "id_snmp_serialize": $("#hidden-id_snmp_serialize").val() }, From 1ffb435d5a5e8f1256e52f259ec2a766ae28db88 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Thu, 27 Jun 2019 09:48:37 +0200 Subject: [PATCH 27/74] Fixed wrong img paths --- pandora_console/include/styles/js/cluetip.css | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/styles/js/cluetip.css b/pandora_console/include/styles/js/cluetip.css index 233dbf3cbb..a1360b0afe 100644 --- a/pandora_console/include/styles/js/cluetip.css +++ b/pandora_console/include/styles/js/cluetip.css @@ -2,19 +2,23 @@ #cluetip-close img { border: 0; } + #cluetip-title { overflow: hidden; } + #cluetip-title #cluetip-close { float: right; position: relative; } + #cluetip-waitimage { width: 43px; height: 11px; position: absolute; background-image: url(../../../images/wait.gif); } + .cluetip-arrows { display: none; position: absolute; @@ -25,9 +29,11 @@ background-repeat: no-repeat; background-position: 0 0; } + #cluetip-extra { display: none; } + /*************************************** =cluetipClass: 'default' -------------------------------------- */ @@ -36,11 +42,13 @@ background-color: #fff; text-align: left; } + .cluetip-default #cluetip-outer { position: relative; margin: 0; background-color: #fff; } + .cluetip-default h3 { margin: 0 0 5px; padding: 8px 10px 4px; @@ -49,6 +57,7 @@ background-color: #b1b1b1; color: #fff; } + .cluetip-default h3#cluetip-title { display: none; height: 0px; @@ -56,41 +65,49 @@ padding: 0; color: #fff; } + .cluetip-default #cluetip-title a { color: #fff; font-size: 0.95em; } + .cluetip-default #cluetip-inner { padding: 10px; } + .cluetip-default div#cluetip-close { text-align: right; margin: 0 5px 5px; color: #900; } + .cluetip-default ul { text-align: left; } + /* default arrows */ .clue-right-default .cluetip-arrows { - background-image: url(../../images/darrowleft.png); + background-image: url(../../../images/darrowleft.png); } + .clue-left-default .cluetip-arrows { - background-image: url(../../images/darrowright.png); + background-image: url(../../../images/darrowright.png); left: 100%; margin-right: -11px; } + .clue-top-default .cluetip-arrows { - background-image: url(../../images/darrowdown.png); + background-image: url(../../../images/darrowdown.png); top: 100%; left: 50%; margin-left: -11px; height: 11px; width: 22px; } + .clue-bottom-default .cluetip-arrows { - background-image: url(../../images/darrowup.png); + background-image: url(../../../images/darrowup.png); top: -11px; left: 50%; margin-left: -11px; From a2877b46f336b4b674549b6223dfa302bbdab119 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Thu, 27 Jun 2019 14:58:57 +0200 Subject: [PATCH 28/74] Solved wrong variable rewriting --- .../godmode/reporting/reporting_builder.item_editor.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index a5e59e46ce..211385cac8 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -847,7 +847,10 @@ $class = 'databox filters'; } ?> '.html_print_image('images/tip.png', true, ['title' => $text]).''; ?> From 411e62fb0dd8451437b75beb6d9a6a197653ef45 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Thu, 27 Jun 2019 16:38:00 +0200 Subject: [PATCH 29/74] Changed link to Discovery task list and added ui_get_full_url function over other links --- .../godmode/servers/servers.build_table.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index aa2f0a0735..f0e2a4ad08 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -152,12 +152,12 @@ foreach ($servers as $server) { $data[8] = ''; if ($server['type'] == 'recon') { - $data[8] .= ''; + $data[8] .= ''; $data[8] .= html_print_image( 'images/firts_task/icono_grande_reconserver.png', true, [ - 'title' => __('Manage recon tasks'), + 'title' => __('Manage Discovery tasks'), 'style' => 'width:21px;height:21px;', ] ); @@ -165,7 +165,7 @@ foreach ($servers as $server) { } if ($server['type'] == 'data') { - $data[8] .= ''; + $data[8] .= ''; $data[8] .= html_print_image( 'images/target.png', true, @@ -173,7 +173,7 @@ foreach ($servers as $server) { ); $data[8] .= ''; } else if ($server['type'] == 'enterprise snmp') { - $data[8] .= ''; + $data[8] .= ''; $data[8] .= html_print_image( 'images/target.png', true, @@ -182,7 +182,7 @@ foreach ($servers as $server) { $data[8] .= ''; } - $data[8] .= ''; + $data[8] .= ''; $data[8] .= html_print_image( 'images/config.png', true, @@ -191,7 +191,7 @@ foreach ($servers as $server) { $data[8] .= ''; if (($names_servers[$safe_server_name] === true) && ($server['type'] == 'data' || $server['type'] == 'enterprise satellite')) { - $data[8] .= ''; + $data[8] .= ''; $data[8] .= html_print_image( 'images/remote_configuration.png', true, @@ -201,7 +201,7 @@ foreach ($servers as $server) { $names_servers[$safe_server_name] = false; } - $data[8] .= ''; + $data[8] .= ''; $data[8] .= html_print_image( 'images/cross.png', true, From 25e5f0914ac5eb33595b20b1e18c5ae1f1e70b41 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Thu, 27 Jun 2019 16:58:48 +0200 Subject: [PATCH 30/74] Added delete_files entry for recon view deletion --- pandora_console/extras/delete_files/delete_files.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 pandora_console/extras/delete_files/delete_files.txt diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt new file mode 100644 index 0000000000..c0d8f0a9db --- /dev/null +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -0,0 +1 @@ +operation/servers/recon_view.php \ No newline at end of file From 03edb75b7c1d9d16f2215b249c7581e5a1d95c79 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Thu, 27 Jun 2019 17:19:48 +0200 Subject: [PATCH 31/74] Modified agent alias name --- pandora_console/godmode/servers/plugin.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index a7fc94bcca..3eb385332c 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -70,7 +70,7 @@ if (is_ajax()) { $table->head[0] = __('Agent'); $table->head[1] = __('Module'); foreach ($modules as $mod) { - $agent_name = ''.modules_get_agentmodule_agent_name( + $agent_name = ''.modules_get_agentmodule_agent_alias( $mod['id_agente_modulo'] ).''; @@ -1215,4 +1215,3 @@ ui_require_javascript_file('pandora_modules'); - From 52025efbee2ddc95a1931a0c74c00368b8d330e7 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 1 Jul 2019 13:55:44 +0200 Subject: [PATCH 32/74] Modified control for module edition --- .../agentes/module_manager_editor_common.php | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index fbdd620f77..e09a14ae92 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -134,7 +134,9 @@ $largeClassDisabledBecauseInPolicy = ''; $page = get_parameter('page', ''); -if (strstr($page, 'policy_modules') === false && $id_agent_module) { +$in_policies_page = strstr($page, 'policy_modules'); + +if ($in_policies_page === false && $id_agent_module) { if ($config['enterprise_installed']) { if (policies_is_module_linked($id_agent_module) == 1) { $disabledBecauseInPolicy = 1; @@ -243,6 +245,12 @@ $table_simple->data[0][3] .= html_print_select_from_sql( $disabledBecauseInPolicy ); +if ((isset($id_agent_module) && $id_agent_module) || $id_policy_module != 0) { + $edit = false; +} else { + $edit = true; +} + $in_policy = strstr($page, 'policy_modules'); if (!$in_policy) { // Cannot select the current module to be itself parent @@ -273,17 +281,6 @@ if (!$in_policy) { $table_simple->data[2][0] = __('Type').' '.ui_print_help_icon($help_type, true, '', 'images/help_green.png', '', 'module_type_help'); $table_simple->data[2][0] .= html_print_input_hidden('id_module_type_hidden', $id_module_type, true); -if (isset($id_agent_module)) { - if ($id_agent_module) { - $edit = false; - } else { - $edit = true; - } -} else { - // Run into a policy - $edit = true; -} - if (!$edit) { $sql = sprintf( 'SELECT id_tipo, nombre From 4430f18ac5ca51ccd41269299665a0c9684a929a Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Tue, 2 Jul 2019 12:21:58 +0200 Subject: [PATCH 33/74] Resolved error query --- pandora_console/include/functions_events.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 5f83669b4b..927a82da40 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -4861,7 +4861,7 @@ function events_get_count_events_by_agent( COUNT(*) AS count FROM %s t3 WHERE utimestamp > %d AND utimestamp <= %d - AND id_grupo IN (%s) %s + AND id_grupo IN (%s) GROUP BY id_agente', $tagente, $tevento, From 84cdbefebd6adffbe285389df775c0c2f71c03b2 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 2 Jul 2019 16:22:23 +0200 Subject: [PATCH 34/74] cleanup and fix in location reload --- pandora_console/index.php | 365 ++++++++++++++++++++++++-------------- 1 file changed, 235 insertions(+), 130 deletions(-) diff --git a/pandora_console/index.php b/pandora_console/index.php index 3c95074171..e299d0869d 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1,17 +1,32 @@ $value) { if ($key == 1) { continue; @@ -162,12 +181,12 @@ if (!empty($config['https']) && empty($_SERVER['HTTPS'])) { $url = ui_get_full_url($query); // Prevent HTTP response splitting attacks - // http://en.wikipedia.org/wiki/HTTP_response_splitting + // http://en.wikipedia.org/wiki/HTTP_response_splitting. $url = str_replace("\n", '', $url); header('Location: '.$url); + // Always exit after sending location headers. exit; - // Always exit after sending location headers } // Pure mode (without menu, header and footer). @@ -188,20 +207,21 @@ echo ''."\n"; echo ''."\n"; -// This starts the page head. In the call back function, things from $page['head'] array will be processed into the head +// This starts the page head. In the callback function, +// $page['head'] array content will be processed into the head. ob_start('ui_process_page_head'); -// Enterprise main +// Enterprise main. enterprise_include('index.php'); echo ''; // This tag is included in the buffer passed to ui_process_page_head so -// technically it can be stripped +// technically it can be stripped. echo ''."\n"; require_once 'include/functions_themes.php'; @@ -212,13 +232,13 @@ $config['remote_addr'] = $_SERVER['REMOTE_ADDR']; $sec2 = get_parameter_get('sec2'); $sec2 = safe_url_extraclean($sec2); $page = $sec2; -// Reference variable for old time sake +// Reference variable for old time sake. $sec = get_parameter_get('sec'); $sec = safe_url_extraclean($sec); $process_login = false; -// Update user password +// Update user password. $change_pass = get_parameter_post('renew_password', 0); if ($change_pass == 1) { @@ -235,14 +255,14 @@ $searchPage = false; $search = get_parameter_get('head_search_keywords'); if (strlen($search) > 0) { $config['search_keywords'] = io_safe_input(trim(io_safe_output(get_parameter('keywords')))); - // If not search category providad, we'll use an agent search + // If not search category providad, we'll use an agent search. $config['search_category'] = get_parameter('search_category', 'all'); if (($config['search_keywords'] != 'Enter keywords to search') && (strlen($config['search_keywords']) > 0)) { $searchPage = true; } } -// Login process +// Login process. if (! isset($config['id_user'])) { // Clear error messages. unset($_COOKIE['errormsg']); @@ -250,50 +270,53 @@ if (! isset($config['id_user'])) { if (isset($_GET['login'])) { include_once 'include/functions_db.php'; - // Include it to use escape_string_sql function + // Include it to use escape_string_sql function. $config['auth_error'] = ''; - // Set this to the error message from the authorization mechanism + // Set this to the error message from the authorization mechanism. $nick = get_parameter_post('nick'); - // This is the variable with the login + // This is the variable with the login. $pass = get_parameter_post('pass'); - // This is the variable with the password + // This is the variable with the password. $nick = db_escape_string_sql($nick); $pass = db_escape_string_sql($pass); - // Since now, only the $pass variable are needed + // Since now, only the $pass variable are needed. unset($_GET['pass'], $_POST['pass'], $_REQUEST['pass']); - // If the auth_code exists, we assume the user has come through the double auth page + // If the auth_code exists, we assume the user has come from + // double authorization page. if (isset($_POST['auth_code'])) { $double_auth_success = false; - // The double authentication is activated and the user has surpassed the first step (the login). + // The double authentication is activated and the user has + // surpassed the first step (the login). // Now the authentication code provided will be checked. if (isset($_SESSION['prepared_login_da'])) { if (isset($_SESSION['prepared_login_da']['id_user']) && isset($_SESSION['prepared_login_da']['timestamp']) ) { - // The user has a maximum of 5 minutes to introduce the double auth code + // The user has a maximum of 5 minutes to introduce + // the double auth code. $dauth_period = SECONDS_2MINUTES; $now = time(); $dauth_time = $_SESSION['prepared_login_da']['timestamp']; if (($now - $dauth_period) < $dauth_time) { - // Nick + // Nick. $nick = $_SESSION['prepared_login_da']['id_user']; - // Code + // Code. $code = (string) get_parameter_post('auth_code'); if (!empty($code)) { $result = validate_double_auth_code($nick, $code); if ($result === true) { - // Double auth success + // Double auth success. $double_auth_success = true; } else { - // Screen + // Screen. $login_screen = 'double_auth'; - // Error message + // Error message. $config['auth_error'] = __('Invalid code'); if (!isset($_SESSION['prepared_login_da']['attempts'])) { @@ -303,9 +326,9 @@ if (! isset($config['id_user'])) { $_SESSION['prepared_login_da']['attempts']++; } } else { - // Screen + // Screen. $login_screen = 'double_auth'; - // Error message + // Error message. $config['auth_error'] = __("The code shouldn't be empty"); if (!isset($_SESSION['prepared_login_da']['attempts'])) { @@ -315,27 +338,27 @@ if (! isset($config['id_user'])) { $_SESSION['prepared_login_da']['attempts']++; } } else { - // Expired login + // Expired login. unset($_SESSION['prepared_login_da']); - // Error message + // Error message. $config['auth_error'] = __('Expired login'); } } else { - // If the code doesn't exist, remove the prepared login + // If the code doesn't exist, remove the prepared login. unset($_SESSION['prepared_login_da']); - // Error message + // Error message. $config['auth_error'] = __('Login error'); } - } - // If $_SESSION['prepared_login_da'] doesn't exist, the user have to do the login again - else { - // Error message + } else { + // If $_SESSION['prepared_login_da'] doesn't exist, the user + // must login again. + // Error message. $config['auth_error'] = __('Login error'); } - // Remove the authenticator code + // Remove the authenticator code. unset($_POST['auth_code'], $code); if (!$double_auth_success) { @@ -347,6 +370,8 @@ if (! isset($config['id_user'])) { $_SERVER['REMOTE_ADDR'] ); while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); @@ -355,7 +380,8 @@ if (! isset($config['id_user'])) { $login_button_saml = get_parameter('login_button_saml', false); if (isset($double_auth_success) && $double_auth_success) { - // This values are true cause there are checked before complete the 2nd auth step + // This values are true cause there are checked before complete + // the 2nd auth step. $nick_in_db = $_SESSION['prepared_login_da']['id_user']; $expired_pass = false; } else if (($config['auth'] == 'saml') && ($login_button_saml)) { @@ -370,10 +396,13 @@ if (! isset($config['id_user'])) { $as->logout(); } } else { - // process_user_login is a virtual function which should be defined in each auth file. - // It accepts username and password. The rest should be internal to the auth file. - // The auth file can set $config["auth_error"] to an informative error output or reference their internal error messages to it - // process_user_login should return false in case of errors or invalid login, the nickname if correct + // Function process_user_login is a virtual function which should be + // defined in each auth file. It accepts username and password. The + // rest should be internal to the auth file. The auth file can set + // $config["auth_error"] to an informative error output or reference + // their internal error messages to it process_user_login should + // return false in case of errors or invalid login, the nickname + // if correct. $nick_in_db = process_user_login($nick, $pass); $expired_pass = false; @@ -391,28 +420,34 @@ if (! isset($config['id_user'])) { include_once 'general/login_page.php'; db_pandora_audit('Password expired', 'Password expired: '.$nick, $nick); while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); } - // Checks if password has expired + // Checks if password has expired. $check_status = check_pass_status($nick, $pass); switch ($check_status) { case PASSSWORD_POLICIES_FIRST_CHANGE: - // first change + // First change. case PASSSWORD_POLICIES_EXPIRED: - // pass expired + // Pass expired. $expired_pass = true; login_change_password($nick, '', $check_status); break; + + default: + // Ignore. + break; } } } if (($nick_in_db !== false) && $expired_pass) { - // login ok and password has expired + // Login ok and password has expired. include_once 'general/login_page.php'; db_pandora_audit( 'Password expired', @@ -420,30 +455,38 @@ if (! isset($config['id_user'])) { $nick ); while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); } else if (($nick_in_db !== false) && (!$expired_pass)) { - // login ok and password has not expired - // Double auth check - if ((!isset($double_auth_success) || !$double_auth_success) && is_double_auth_enabled($nick_in_db)) { - // Store this values in the session to know if the user login was correct + // Login ok and password has not expired. + // Double auth check. + if ((!isset($double_auth_success) + || !$double_auth_success) + && is_double_auth_enabled($nick_in_db) + ) { + // Store this values in the session to know if the user login + // was correct. $_SESSION['prepared_login_da'] = [ 'id_user' => $nick_in_db, 'timestamp' => time(), 'attempts' => 0, ]; - // Load the page to introduce the double auth code + // Load the page to introduce the double auth code. $login_screen = 'double_auth'; include_once 'general/login_page.php'; while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); } - // login ok and password has not expired + // Login ok and password has not expired. $process_login = true; if (is_user_admin($nick)) { @@ -455,7 +498,7 @@ if (! isset($config['id_user'])) { if (!isset($_GET['sec2']) && !isset($_GET['sec'])) { // Avoid the show homepage when the user go to // a specific section of pandora - // for example when timeout the sesion + // for example when timeout the sesion. unset($_GET['sec2']); $_GET['sec'] = 'general/logon_ok'; $home_page = ''; @@ -486,6 +529,7 @@ if (! isset($config['id_user'])) { break; case 'Default': + default: $_GET['sec'] = 'general/logon_ok'; break; @@ -521,11 +565,14 @@ if (! isset($config['id_user'])) { $_SESSION['id_usuario'] = $nick_in_db; $config['id_user'] = $nick_in_db; - // Check if connection goes through F5 balancer. If it does, then don't call config_prepare_session() or user will be back to login all the time + // Check if connection goes through F5 balancer. If it does, then + // don't call config_prepare_session() or user will be back to login + // all the time. $prepare_session = true; foreach ($_COOKIE as $key => $value) { if (preg_match('/BIGipServer*/', $key)) { $prepare_session = false; + break; } } @@ -534,9 +581,13 @@ if (! isset($config['id_user'])) { } if (is_user_admin($config['id_user'])) { - // PHP configuration values - $PHPupload_max_filesize = config_return_in_bytes(ini_get('upload_max_filesize')); - $PHPmemory_limit = config_return_in_bytes(ini_get('memory_limit')); + // PHP configuration values. + $PHPupload_max_filesize = config_return_in_bytes( + ini_get('upload_max_filesize') + ); + $PHPmemory_limit = config_return_in_bytes( + ini_get('memory_limit') + ); $PHPmax_execution_time = ini_get('max_execution_time'); if ($PHPmax_execution_time !== '0') { @@ -571,43 +622,60 @@ if (! isset($config['id_user'])) { $l10n = null; if (file_exists('./include/languages/'.$user_language.'.mo')) { - $l10n = new gettext_reader(new CachedFileReader('./include/languages/'.$user_language.'.mo')); + $cacheFileReader = new CachedFileReader( + './include/languages/'.$user_language.'.mo' + ); + $l10n = new gettext_reader($cacheFileReader); $l10n->load_tables(); } } else { - // login wrong + // Login wrong. $blocked = false; - if ((!is_user_admin($nick) || $config['enable_pass_policy_admin']) && file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { + if ((!is_user_admin($nick) || $config['enable_pass_policy_admin']) + && file_exists(ENTERPRISE_DIR.'/load_enterprise.php') + ) { $blocked = login_check_blocked($nick); } if (!$blocked) { if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { + // Checks failed attempts. login_check_failed($nick); - // Checks failed attempts } $login_failed = true; include_once 'general/login_page.php'; - db_pandora_audit('Logon Failed', 'Invalid login: '.$nick, $nick); + db_pandora_audit( + 'Logon Failed', + 'Invalid login: '.$nick, + $nick + ); while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); } else { include_once 'general/login_page.php'; - db_pandora_audit('Logon Failed', 'Invalid login: '.$nick, $nick); + db_pandora_audit( + 'Logon Failed', + 'Invalid login: '.$nick, + $nick + ); while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); } } - // Form the url + // Form the url. $query_params_redirect = $_GET; - // Visual console do not want sec2 + // Visual console do not want sec2. if ($home_page == 'Visual console') { unset($query_params_redirect['sec2']); } @@ -621,15 +689,19 @@ if (! isset($config['id_user'])) { $redirect_url .= '&'.safe_url_extraclean($key).'='.safe_url_extraclean($value); } - header('Location: '.$config['homeurl'].'index.php'.$redirect_url); + header('Location: '.ui_get_full_url('index.php'.$redirect_url)); exit; // Always exit after sending location headers. } else if (isset($_GET['loginhash'])) { - // Hash login process + // Hash login process. $loginhash_data = get_parameter('loginhash_data', ''); $loginhash_user = str_rot13(get_parameter('loginhash_user', '')); - if ($config['loginhash_pwd'] != '' && $loginhash_data == md5($loginhash_user.io_output_password($config['loginhash_pwd']))) { + if ($config['loginhash_pwd'] != '' + && $loginhash_data == md5( + $loginhash_user.io_output_password($config['loginhash_pwd']) + ) + ) { db_logon($loginhash_user, $_SERVER['REMOTE_ADDR']); $_SESSION['id_usuario'] = $loginhash_user; $config['id_user'] = $loginhash_user; @@ -637,6 +709,8 @@ if (! isset($config['id_user'])) { include_once 'general/login_page.php'; db_pandora_audit('Logon Failed (loginhash', '', 'system'); while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); @@ -758,7 +832,7 @@ if (! isset($config['id_user'])) { $body .= '

'; $body .= __('Please click the link below to reset your password'); $body .= '

'; - $body .= ''.__('Reset your password').''; + $body .= ''.__('Reset your password').''; $body .= '

'; $body .= get_product_name(); $body .= '

'; @@ -781,6 +855,8 @@ if (! isset($config['id_user'])) { } while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); @@ -790,11 +866,20 @@ if (! isset($config['id_user'])) { $loginhash_data = get_parameter('loginhash_data', ''); $loginhash_user = str_rot13(get_parameter('loginhash_user', '')); $iduser = $_SESSION['id_usuario']; - // logoff_db ($iduser, $_SERVER["REMOTE_ADDR"]); check why is not available + + /* + * Check why is not available. + * logoff_db ($iduser, $_SERVER["REMOTE_ADDR"]); + */ + unset($_SESSION['id_usuario']); unset($iduser); - if ($config['loginhash_pwd'] != '' && $loginhash_data == md5($loginhash_user.io_output_password($config['loginhash_pwd']))) { + if ($config['loginhash_pwd'] != '' + && $loginhash_data == md5( + $loginhash_user.io_output_password($config['loginhash_pwd']) + ) + ) { db_logon($loginhash_user, $_SERVER['REMOTE_ADDR']); $_SESSION['id_usuario'] = $loginhash_user; $config['id_user'] = $loginhash_user; @@ -802,6 +887,8 @@ if (! isset($config['id_user'])) { include_once 'general/login_page.php'; db_pandora_audit('Logon Failed (loginhash', '', 'system'); while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); @@ -814,7 +901,7 @@ if (! isset($config['id_user'])) { '*' ); if ($user_in_db == false) { - // logout + // Logout. $_REQUEST = []; $_GET = []; $_POST = []; @@ -825,6 +912,8 @@ if (! isset($config['id_user'])) { unset($iduser); include_once 'general/login_page.php'; while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); @@ -832,7 +921,7 @@ if (! isset($config['id_user'])) { if (((bool) $user_in_db['is_admin'] === false) && ((bool) $user_in_db['not_login'] === true) ) { - // logout + // Logout. $_REQUEST = []; $_GET = []; $_POST = []; @@ -843,6 +932,8 @@ if (! isset($config['id_user'])) { unset($iduser); include_once 'general/login_page.php'; while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); @@ -850,12 +941,12 @@ if (! isset($config['id_user'])) { } } -// Enterprise support +// Enterprise support. if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { include_once ENTERPRISE_DIR.'/load_enterprise.php'; } -// Log off +// Log off. if (isset($_GET['bye'])) { include 'general/logoff.php'; $iduser = $_SESSION['id_usuario']; @@ -873,6 +964,8 @@ if (isset($_GET['bye'])) { } while (@ob_end_flush()) { + // Dumping... + continue; } exit(''); @@ -880,10 +973,11 @@ if (isset($_GET['bye'])) { clear_pandora_error_for_header(); -// ---------------------------------------------------------------------- -// EXTENSIONS -// ---------------------------------------------------------------------- /* + * ---------------------------------------------------------------------- + * EXTENSIONS + * ---------------------------------------------------------------------- + * * Load the basic configurations of extension and add extensions into menu. * Load here, because if not, some extensions not load well, I don't why. */ @@ -892,7 +986,7 @@ $config['logged'] = false; extensions_load_extensions($process_login); if ($process_login) { - // Call all extensions login function + // Call all extensions login function. extensions_call_login_function(); unset($_SESSION['new_update']); @@ -983,7 +1077,7 @@ if (get_parameter('login', 0) !== 0) { } } -// Header +// Header. if ($config['pure'] == 0) { echo '

'; - // main_pure + // Main pure. } echo '
'; @@ -1202,16 +1299,17 @@ require_once 'include/functions_clippy.php'; clippy_start($sec2); while (@ob_end_flush()) { - // Dump. + // Dumping... + continue; } db_print_database_debug(); echo ''; $run_time = format_numeric((microtime(true) - $config['start_time']), 3); -echo "\n\n"; +echo "\n\n"; -// Values from PHP to be recovered from JAVASCRIPT +// Values from PHP to be recovered from JAVASCRIPT. require 'include/php_to_js_values.php'; @@ -1219,12 +1317,13 @@ require 'include/php_to_js_values.php'; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 679e01e0f4..93bd2dee08 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -5323,6 +5323,10 @@ table.info_table.policy_sub_table { margin-bottom: 4px; } +.agent_options input[readonly] { + color: #848484; +} + /* * --------------------------------------------------------------------- * - CLASSES FOR THE NEW TOGGLES - From 31b19ab970f1df69484c4c799c43a639b3d34bd3 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Fri, 5 Jul 2019 09:31:23 +0200 Subject: [PATCH 39/74] Fix pagination blank page - #4306 --- pandora_console/include/functions_ui.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index ef8089ac3a..0bf4b8dd2d 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -2049,7 +2049,7 @@ function ui_pagination( $actual_page = floor($offset / $pagination); $ini_page = (floor($actual_page / $block_limit) * $block_limit); $end_page = ($ini_page + $block_limit - 1); - if ($end_page > $number_of_pages) { + if ($end_page >= $number_of_pages) { $end_page = ($number_of_pages - 1); } From 58cb113d400964ead195719e4f0f968b61ec2222 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Date: Mon, 8 Jul 2019 13:23:35 +0200 Subject: [PATCH 40/74] fixed error in pdf --- pandora_console/include/functions_graph.php | 2 +- pandora_console/include/graphs/flot/pandora.flot.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 72bc9b5c91..d04c2049a0 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2161,7 +2161,7 @@ function graphic_combined_module( $graph_values = $temp; if (!$params['vconsole']) { - $width = 1024; + $width = $width; $height = 500; } diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index f7af997508..f0976cb98f 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -2791,14 +2791,16 @@ function pandoraFlotArea( if (short_data) { formatted = number_format(v, force_integer, "", short_data); } else { - // It is an integer + // It is an integer. if (v - Math.floor(v) == 0) { formatted = number_format(v, force_integer, "", 2); } } - // Get only two decimals - formatted = round_with_decimals(formatted, 100); + // Get only two decimals. + if (typeof formatted != "string") { + formatted = Math.round(formatted * 100) / 100; + } return formatted; } From 6d6c8fe197426acb169b5981ecd5c19ad44bff64 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Mon, 8 Jul 2019 17:57:23 +0200 Subject: [PATCH 41/74] Added filter by agent - #4318 --- .../godmode/massive/massive_delete_modules.php | 8 ++++++++ pandora_console/godmode/massive/massive_edit_modules.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/pandora_console/godmode/massive/massive_delete_modules.php b/pandora_console/godmode/massive/massive_delete_modules.php index c52878c5da..7d8d64141a 100755 --- a/pandora_console/godmode/massive/massive_delete_modules.php +++ b/pandora_console/godmode/massive/massive_delete_modules.php @@ -501,6 +501,11 @@ $table->data['form_agents_4'][1] = html_print_select( true ); +$table->rowstyle['form_agents_filter'] = 'vertical-align: top;'; +$table->rowclass['form_agents_filter'] = 'select_agents_row select_agents_row_2'; +$table->data['form_agents_filter'][0] = __('Filter Agents'); +$table->data['form_agents_filter'][1] = html_print_input_text('filter_agents', '', '', 20, 255, true); + $table->rowstyle['form_agents_3'] = 'vertical-align: top;'; $table->rowclass['form_agents_3'] = 'select_agents_row select_agents_row_2'; $table->data['form_agents_3'][0] = __('Agents'); @@ -763,6 +768,9 @@ $(document).ready (function () { .html (value["alias"]); $("#id_agents").append (option); }); + //Filter agents. Call the function when the select is fully loaded. + var textNoData = ""; + filterByText($('#id_agents'), $("#text-filter_agents"), textNoData); }, "json" ); diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 1a18b410d5..f52707cb2a 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -473,6 +473,11 @@ $table->data['form_agents_4'][1] = html_print_select( true ); +$table->rowstyle['form_agents_filter'] = 'vertical-align: top;'; +$table->rowclass['form_agents_filter'] = 'select_agents_row select_agents_row_2'; +$table->data['form_agents_filter'][0] = __('Filter agents'); +$table->data['form_agents_filter'][1] = html_print_input_text('filter_agents', '', '', 20, 255, true); + $table->rowstyle['form_agents_3'] = 'vertical-align: top;'; $table->rowclass['form_agents_3'] = 'select_agents_row select_agents_row_2'; $table->data['form_agents_3'][0] = __('Agents'); @@ -1638,6 +1643,9 @@ $(document).ready (function () { .html(value["alias"]); $("#id_agents").append (option); }); + //Filter agents. Call the function when the select is fully loaded. + var textNoData = ""; + filterByText($('#id_agents'), $("#text-filter_agents"), textNoData); }, "json" ); From 6382cb2abefc0894443c74512352bc1ad7222335 Mon Sep 17 00:00:00 2001 From: "marcos.alconada" Date: Wed, 10 Jul 2019 14:18:23 +0200 Subject: [PATCH 42/74] fixed errors with graphs in meta --- pandora_console/include/functions_events.php | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index f9a1271c18..b13137c06c 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -25,13 +25,17 @@ * GNU General Public License for more details. * ============================================================================ */ +global $config; require_once $config['homedir'].'/include/functions_ui.php'; require_once $config['homedir'].'/include/functions_tags.php'; require_once $config['homedir'].'/include/functions.php'; +require_once $config['homedir'].'/include/functions_reporting.php'; +enterprise_include_once('include/functions_metaconsole.php'); enterprise_include_once('meta/include/functions_events_meta.php'); enterprise_include_once('meta/include/functions_agents_meta.php'); enterprise_include_once('meta/include/functions_modules_meta.php'); +enterprise_include_once('meta/include/functions_events_meta.php'); /** @@ -4848,10 +4852,6 @@ function events_get_count_events_by_agent( $tagente = 'tagente'; $tevento = 'tevento'; - if ($dbmeta) { - $tagente = 'tmetaconsole_agent'; - $tevento = 'tmetaconsole_event'; - } $sql = sprintf( 'SELECT id_agente, @@ -5028,9 +5028,6 @@ function events_get_count_events_validated_by_user( } $tevento = 'tevento'; - if ($dbmeta) { - $tevento = 'tmetaconsole_event'; - } $sql = sprintf( 'SELECT id_usuario, @@ -5206,9 +5203,6 @@ function events_get_count_events_by_criticity( } $tevento = 'tevento'; - if ($dbmeta) { - $tevento = 'tmetaconsole_event'; - } $sql = sprintf( 'SELECT criticity, @@ -5414,9 +5408,6 @@ function events_get_count_events_validated( } $tevento = 'tevento'; - if ($dbmeta) { - $tevento = 'tmetaconsole_event'; - } $sql = sprintf('SELECT estado, COUNT(*) AS count FROM %s WHERE %s %s GROUP BY estado', $tevento, $sql_filter, $sql_where); From 3b23810323b71a77b51d82dd6effa7d16fe6ddeb Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Wed, 10 Jul 2019 16:37:24 +0200 Subject: [PATCH 43/74] Added filter by agent in massive copy - #4318 --- .../godmode/massive/massive_copy_modules.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/massive/massive_copy_modules.php b/pandora_console/godmode/massive/massive_copy_modules.php index 5ca25ebc11..36ab0c310c 100755 --- a/pandora_console/godmode/massive/massive_copy_modules.php +++ b/pandora_console/godmode/massive/massive_copy_modules.php @@ -273,6 +273,9 @@ $table->data[1][1] = html_print_select( true ); +$table->data['form_agents_filter'][0] = __('Filter Agents'); +$table->data['form_agents_filter'][1] = html_print_input_text('filter_agents', '', '', 20, 255, true); + $table->data[2][0] = __('Agent'); $table->data[2][0] .= '