diff --git a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/ConnectionCustomToast.java b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/ConnectionCustomToast.java index 8540370a2b..5026d96d98 100644 --- a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/ConnectionCustomToast.java +++ b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/ConnectionCustomToast.java @@ -2,7 +2,7 @@ Pandora FMS - http://pandorafms.com ================================================== -Copyright (c) 2005-2021 Artica Soluciones Tecnologicas +Copyright (c) 2005-2023 Pandora FMS Please see http://pandorafms.org for full contribution list This program is free software; you can redistribute it and/or diff --git a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Help.java b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Help.java index 32d73a7fa8..60708495c1 100644 --- a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Help.java +++ b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Help.java @@ -2,7 +2,7 @@ Pandora FMS - http://pandorafms.com ================================================== -Copyright (c) 2005-2021 Artica Soluciones Tecnologicas +Copyright (c) 2005-2023 Pandora FMS Please see http://pandorafms.org for full contribution list This program is free software; you can redistribute it and/or diff --git a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Options.java b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Options.java index 2cd8542fa0..782448ace6 100644 --- a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Options.java +++ b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Options.java @@ -2,7 +2,7 @@ Pandora FMS - http://pandorafms.com ================================================== -Copyright (c) 2005-2021 Artica Soluciones Tecnologicas +Copyright (c) 2005-2023 Pandora FMS Please see http://pandorafms.org for full contribution list This program is free software; you can redistribute it and/or diff --git a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/PandoraWebView.java b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/PandoraWebView.java index 4c566ff0f4..5b03bd03d3 100644 --- a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/PandoraWebView.java +++ b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/PandoraWebView.java @@ -2,7 +2,7 @@ Pandora FMS - http://pandorafms.com ================================================== -Copyright (c) 2005-2021 Artica Soluciones Tecnologicas +Copyright (c) 2005-2023 Pandora FMS Please see http://pandorafms.org for full contribution list This program is free software; you can redistribute it and/or diff --git a/extras/android-event-viewer/app/src/main/AndroidManifest.xml b/extras/android-event-viewer/app/src/main/AndroidManifest.xml index 56e27364eb..1678445c33 100644 --- a/extras/android-event-viewer/app/src/main/AndroidManifest.xml +++ b/extras/android-event-viewer/app/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ @@ -904,6 +920,44 @@ echo sprintf('
', $menuTypeClass); $("#agent_access").css("display",""); }); + $("#welcome-icon-header").click(function () { + if (!$('#welcome_modal_window').length){ + $(document.body).append('
'); + $(document.body).append( $('').attr('href', 'include/styles/new_installation_welcome_window.css') ); + } + // Clean DOM. + load_modal({ + target: $('#welcome_modal_window'), + url: '', + modal: { + title: "", + cancel: '', + ok: '' + }, + onshow: { + page: 'include/ajax/welcome_window', + method: 'loadWelcomeWindow', + }, + oncancel: { + page: 'include/ajax/welcome_window', + title: "", + method: 'cancelWelcome', + confirm: function (fn) { + confirmDialog({ + title: '', + message: '', + ok: '', + cancel: '', + onAccept: function() { + // Continue execution. + fn(); + } + }) + } + } + }); + }); + // Feedback. $("#feedback-header").click(function () { diff --git a/pandora_console/general/main_menu.php b/pandora_console/general/main_menu.php index 13e3f2c38c..60bffeb27f 100644 --- a/pandora_console/general/main_menu.php +++ b/pandora_console/general/main_menu.php @@ -349,7 +349,7 @@ echo '
'; const id = table_hover[0].id; const classes = $(`#${id}`).attr('class'); - if (id === 'icon_about') { + if (id === 'icon_about' || id === 'icon_about_operation') { return; } diff --git a/pandora_console/general/register.php b/pandora_console/general/register.php index 96f9232dab..759e319dbd 100644 --- a/pandora_console/general/register.php +++ b/pandora_console/general/register.php @@ -100,21 +100,23 @@ if ($initial && users_is_admin()) { ); } -$welcome = !$initial; -try { - $welcome_window = new WelcomeWindow($welcome); - if ($welcome_window !== null) { - $welcome_window->run(); +if (check_acl($config['id_user'], 0, 'AW')) { + $welcome = !$initial; + try { + $welcome_window = new WelcomeWindow($welcome); + if ($welcome_window !== null) { + $welcome_window->run(); + } + } catch (Exception $e) { + $welcome = false; } -} catch (Exception $e) { - $welcome = false; } try { if (isset($_SESSION['showed_tips_window']) === false) { $tips_window = new TipsWindow(); if ($tips_window !== null) { - $tips_window->run(); + $tips_window->run(); } } } catch (Exception $e) { diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 6efd958c5f..b161b7ff6d 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -965,7 +965,7 @@ foreach ($fields as $field) { true ); } else if ($field['is_link_enabled']) { - list($link_text, $link_url) = json_decode($custom_value, true); + list($link_text, $link_url) = json_decode(io_safe_output($custom_value), true); if (json_last_error() !== JSON_ERROR_NONE) { $link_text = ''; diff --git a/pandora_console/godmode/agentes/agent_template.php b/pandora_console/godmode/agentes/agent_template.php index 163fc16af8..9c080fcf3f 100644 --- a/pandora_console/godmode/agentes/agent_template.php +++ b/pandora_console/godmode/agentes/agent_template.php @@ -80,7 +80,7 @@ if (isset($_POST['template_id']) === true) { $values = [ 'id_agente' => $id_agente, 'id_tipo_modulo' => $row2['type'], - 'descripcion' => __('Created by template ').$name_template.' . '.$row2['description'], + 'descripcion' => $row2['description'], 'max' => $row2['max'], 'min' => $row2['min'], 'module_interval' => $row2['module_interval'], diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index c68d483eaf..b07fb5ca4f 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -460,6 +460,18 @@ if ($id_agente) { $templatetab['active'] = ($tab === 'template'); + // Policy tab. + $policyTab['text'] = html_print_menu_button( + [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=policy&id_agente='.$id_agente, + 'image' => 'images/policy@svg.svg', + 'title' => __('Manage policy'), + ], + true + ); + + $policyTab['active'] = ($tab === 'policy'); + // Inventory. $inventorytab['text'] = ''.html_print_image( 'images/hardware-software-component@svg.svg', @@ -638,6 +650,7 @@ if ($id_agente) { 'template' => $templatetab, 'inventory' => $inventorytab, 'pluginstab' => $pluginstab, + 'policy' => (enterprise_installed() === true) ? $policyTab : '', 'collection' => $collectiontab, 'group' => $grouptab, 'gis' => $gistab, @@ -654,11 +667,11 @@ if ($id_agente) { 'template' => $templatetab, 'inventory' => $inventorytab, 'pluginstab' => $pluginstab, + 'policy' => (enterprise_installed() === true) ? $policyTab : '', 'collection' => $collectiontab, 'group' => $grouptab, 'gis' => $gistab, 'agent_wizard' => $agent_wizard, - ]; } @@ -725,6 +738,11 @@ if ($id_agente) { $tab_name = __('Inventory'); break; + case 'policy': + $help_header = 'policy_tab'; + $tab_name = __('Policies'); + break; + case 'plugins': $help_header = 'plugins_tab'; $tab_name = __('Agent plugins'); @@ -2428,6 +2446,10 @@ switch ($tab) { include 'inventory_manager.php'; break; + case 'policy': + enterprise_include('operation/agentes/policy_manager.php'); + break; + default: if (enterprise_hook('switch_agent_tab', [$tab])) { // This will make sure that blank pages will have at least some diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 831de2b528..9021514178 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -929,7 +929,7 @@ if ($agents !== false) { [ 'href' => ui_get_full_url( sprintf( - 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&%s_agent=%s&group_id=%s&recursion=%s&search=%s&offset=%s&sort_field=%s&sort=%s&disabled=%s', + 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&%s_agent=%s&group_id=%s&recursion=%s&search=%s&offset=%s&sort_field=%s&sort=%s&disabled=%s&os=%s', $agentDisableEnableAction, $agent['id_agente'], $ag_group, @@ -938,7 +938,8 @@ if ($agents !== false) { '', $sortField, $sort, - $disabled + $disabled, + $os ) ), 'onClick' => ($agent['id_os'] === CLUSTER_OS_ID) ? sprintf('if (!confirm(\'%s\')) return false', $agentDisableEnableCaption) : 'return true;', @@ -1071,16 +1072,20 @@ if ((bool) check_acl($config['id_user'], 0, 'AW') === true) { function () { $(".actions", this).css ("visibility", "hidden"); }); - + $("#ag_group").click ( function () { $(this).css ("width", "auto"); $(this).css ("min-width", "100px"); }); - + $("#ag_group").blur (function () { $(this).css ("width", "100px"); }); - + + var show_deploy_agent = ""; + if (show_deploy_agent !== '0'){ + $('#button-modal_deploy_agent').click(); + } }); diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index b8b3789228..5c21fa71a0 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -47,8 +47,74 @@ if (isset($policy_page) === false) { $policy_page = false; } -$checked = (bool) get_parameter('checked'); +$checked = (bool) get_parameter('status_hierachy_mode'); +$status_hierachy_mode = (bool) get_parameter('status_hierachy_mode'); $sec2 = (string) get_parameter('sec2'); +// Table for filter bar. +$filterTable = new stdClass(); +$filterTable->class = 'filter-table-adv w100p'; +$filterTable->size[0] = '20%'; +$filterTable->size[1] = '20%'; +$filterTable->size[2] = '20%'; +$filterTable->size[3] = '20%'; +$filterTable->size[4] = '20%'; +$filterTable->data = []; +$filterTable->cellstyle[0][0] = 'width:0'; +$filterTable->data[0][0] = __('Search'); +$filterTable->data[1][0] .= html_print_input_text( + 'search_string', + $search_string, + '', + 30, + 255, + true, + false, + false, + '', + '' +); + +$filterTable->data[0][0] .= html_print_input_hidden('search', 1, true); + +if ((bool) $policy_page === false) { + $filterTable->data[0][1] = __('Show in hierachy mode'); + $filterTable->data[1][1] = html_print_checkbox_switch( + 'status_hierachy_mode', + ((string) $checked), + ((string) $checked), + true, + false, + 'onChange=change_mod_filter();' + ); +} + +$filterTable->data[1][2] = html_print_submit_button( + __('Filter'), + 'filter', + false, + [ + 'icon' => 'search', + 'class' => 'float-right', + 'mode' => 'secondary mini', + ], + true +); + +// Print filter table. +echo '
'; +ui_toggle( + html_print_table($filterTable, true).'
', + ''.__('Filter').'', + __('Filter'), + 'filter', + true, + false, + '', + 'white-box-content no_border', + 'filter-datatable-main box-flat white_table_graph fixed_filter_bar' +); +echo ''; + if (isset($id_agente) === false) { return; @@ -1215,14 +1281,17 @@ html_print_div( if (/checked/.test(window.location)) { var url = window.location.toString(); if (checked) { - window.location = url.replace("checked=false", "checked=true"); + //window.location = url.replace("checked=0", "checked=1"); + $("#checkbox-status_hierachy_mode").val('1'); } else { - window.location = url.replace("checked=true", "checked=false"); + //window.location = url.replace("checked=1", "checked=0"); + $("#checkbox-status_hierachy_mode").val('0'); } } else { - window.location = window.location + "&checked=true"; + //window.location = window.location + "&checked=1"; + $("#checkbox-status_hierachy_mode").val('1'); } } diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 927c58acc0..d63dff4035 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -32,6 +32,7 @@ require_once $config['homedir'].'/include/functions_categories.php'; require_once $config['homedir'].'/include/graphs/functions_d3.php'; use PandoraFMS\Agent; +use Psr\Log\NullLogger; include_javascript_d3(); @@ -950,6 +951,15 @@ $table_advanced->data['tags_module_parent'][0] .= html_print_div( if ((bool) $in_policies_page === false) { // Cannot select the current module to be itself parent. + if ($id_agent_module !== 0) { + $module_parent_filter['tagente_modulo.id_agente_modulo'] = '<>'.$id_agent_module; + $array_parent_module_id = []; + get_agent_module_childs($array_parent_module_id, $id_agent_module, $id_agente); + } else { + $module_parent_filter = []; + $array_parent_module_id = []; + } + $module_parent_filter = ($id_agent_module) ? ['tagente_modulo.id_agente_modulo' => '<>'.$id_agent_module] : []; $table_advanced->data['caption_tags_module_parent'][1] = __('Module parent'); // TODO. Review cause dont know not works. @@ -965,6 +975,13 @@ if ((bool) $in_policies_page === false) { false, $module_parent_filter ); + + if (empty($array_parent_module_id) === false) { + foreach ($array_parent_module_id as $key => $value) { + unset($modules_can_be_parent[$value]); + } + } + // If the user cannot have access to parent module, only print the name. if ((int) $parent_module_id !== 0 && in_array($parent_module_id, array_keys($modules_can_be_parent)) === true diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index 03e79c2f24..fc3439600e 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -90,14 +90,9 @@ push_table_simple($data, 'caption_target_ip'); $data = []; // Show agent_for defect. if ($page === 'enterprise/godmode/policies/policy_modules') { - if (empty($ip_target) === false && $ip_target !== 'auto') { + if ($ip_target !== 'auto' && $ip_target !== 'force_pri') { $custom_ip_target = $ip_target; $ip_target = 'custom'; - } else if (empty($ip_target) === true) { - $ip_target = 'force_pri'; - $custom_ip_target = ''; - } else { - $custom_ip_target = ''; } $target_ip_values = []; @@ -245,7 +240,7 @@ $snmp_versions['3'] = 'v. 3'; $snmpVersionsInput = html_print_select( $snmp_versions, 'snmp_version', - ($id_module_type >= 15 && $id_module_type <= 18) ? $snmp_version : 0, + ($id_module_type >= 15 && $id_module_type <= 18) ? $snmp_version : '2c', '', '', '', @@ -725,9 +720,13 @@ $(document).ready (function () { }); var custom_ip_target = ""; - if(custom_ip_target == ''){ + var ip_target = ""; + if(ip_target === 'custom'){ + $("#text-custom_ip_target").show(); + } else { $("#text-custom_ip_target").hide(); } + $('#ip_target').change(function() { if($(this).val() === 'custom') { $("#text-custom_ip_target").show(); diff --git a/pandora_console/godmode/agentes/module_manager_editor_web.php b/pandora_console/godmode/agentes/module_manager_editor_web.php index 281963108a..727e16d5bf 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_web.php +++ b/pandora_console/godmode/agentes/module_manager_editor_web.php @@ -113,7 +113,8 @@ if ($id_policy_module > 0) { $plugin_parameter_split = explode(' ', $plugin_parameter); $plugin_parameter_final_split = ''; -foreach ($plugin_parameter_split as $key => $value) { +$new_plugin_parameter_split = array_filter($plugin_parameter_split, 'strlen'); +foreach ($new_plugin_parameter_split as $key => $value) { if (strpos($value, 'http_auth_user') === false && strpos($value, 'http_auth_pass') === false) { $plugin_parameter_final_split .= $value.' '; } @@ -317,8 +318,7 @@ foreach ($texts as $code => $text) { return; } - $(plugin_parameter).val( - 'task_begin\ncookie 0\nresource 0\ntask_end'); + $(plugin_parameter).val('task_begin\ncookie 0\nresource 0\ntask_end'); $('#button-btn_loadbasic').attr('disabled', 'disabled'); diff --git a/pandora_console/godmode/agentes/module_manager_editor_wmi.php b/pandora_console/godmode/agentes/module_manager_editor_wmi.php index e65934e155..c01490b7ab 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_wmi.php +++ b/pandora_console/godmode/agentes/module_manager_editor_wmi.php @@ -43,14 +43,9 @@ if (empty($edit_module)) { $data = []; if ($page == 'enterprise/godmode/policies/policy_modules') { - if ($ip_target != 'auto' && $ip_target != '') { + if ($ip_target !== 'auto' && $ip_target !== 'force_pri') { $custom_ip_target = $ip_target; $ip_target = 'custom'; - } else if ($ip_target == '') { - $ip_target = 'force_pri'; - $custom_ip_target = ''; - } else { - $custom_ip_target = ''; } $target_ip_values = []; @@ -240,9 +235,13 @@ push_table_simple($data, 'key_field'); diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index d51180cb8e..3dd8a831f9 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -14,7 +14,7 @@ * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ========================================================== - * Copyright (c) 2005-2022 Artica Soluciones Tecnol贸gicas S.L + * Copyright (c) 2005-2023 Pandora FMS * This code is NOT free software. This code is NOT licenced under GPL2 licence * You cannot redistribute it without written permission of copyright holder. * ============================================================================ @@ -1311,10 +1311,10 @@ function show_display_update_action(id_module_action, alert_id, alert_id_agent_m }, open: function() { $(`#update_action-div-${alert_id}`).css('overflow', 'hidden'); - $(`#action_select_ajax-${alert_id}`).select2({ - tags: true, - dropdownParent: $(`#update_action-div-${alert_id}`) - }); + //$(`#action_select_ajax-${alert_id}`).select2({ + // tags: true, + // dropdownParent: $(`#update_action-div-${alert_id}`) + //}); }, width: 600, height: 350 diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index 828901f2bf..17669ab248 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -99,6 +99,19 @@ if ($update_alert) { } if ($create_alert) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $id_alert_template = (int) get_parameter('template'); $id_agent_module = (int) get_parameter('id_agent_module'); @@ -203,9 +216,28 @@ if ($create_alert) { } } } + + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($delete_alert) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $id_alert_agent_module = (int) get_parameter('id_alert'); $temp = db_get_row('talert_template_modules', 'id', $id_alert_agent_module); @@ -241,9 +273,27 @@ if ($delete_alert) { '', true ); + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($add_action) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $id_action = (int) get_parameter('action_select'); $id_alert_module = (int) get_parameter('id_alert_module'); $fires_min = (int) get_parameter('fires_min'); @@ -280,9 +330,28 @@ if ($add_action) { '', true ); + + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($update_action) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $alert_id = (int) get_parameter('alert_id'); $id_action = (int) get_parameter('action_select_ajax-'.$alert_id); $id_module_action = (int) get_parameter('id_module_action_ajax'); @@ -321,9 +390,28 @@ if ($update_action) { '', true ); + + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($delete_action) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $id_action = (int) get_parameter('id_action'); $id_alert = (int) get_parameter('id_alert'); @@ -348,6 +436,12 @@ if ($delete_action) { '', true ); + + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($enable_alert) { diff --git a/pandora_console/godmode/alerts/alert_templates.php b/pandora_console/godmode/alerts/alert_templates.php index 747882326d..003ec45d03 100644 --- a/pandora_console/godmode/alerts/alert_templates.php +++ b/pandora_console/godmode/alerts/alert_templates.php @@ -287,6 +287,7 @@ $url = ui_get_url_refresh( 'offset' => false, 'search_string' => $search_string, 'search_type' => $search_type, + 'alert_flag' => true, ], true, false diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index cd5a271971..1a3e991fde 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -318,61 +318,59 @@ if (count($actions) == 1 && isset($actions[0])) { } else { foreach ($actions as $kaction => $action) { $table->data[$kaction][0] = $action['name']; - if ((int) $kaction === 0) { - $table->data[$kaction][0] .= ui_print_help_tip( - __('The default actions will be executed every time that the alert is fired and no other action is executed'), - true - ); - } - - foreach ($action['escalation'] as $k => $v) { - if (count($table->head) >= count($action['escalation'])) { - if ($k === count($action['escalation'])) { - if ($k === 1) { - $table->head[$kaction] = __('Every time that the alert is fired'); - } else { - $table->head[$kaction] = '>#'.($kaction - 1); - } + if (count($action['escalation']) > 1) { + foreach ($action['escalation'] as $k => $v) { + $table->head[$k] = '#'.$k; + if ($v > 0) { + $table->data[$kaction][$k] .= html_print_image( + 'images/tick.png', + true, + ['class' => 'invert_filter'] + ); } else { - $table->head[$kaction] = '#'.($kaction); - if ($v > 0) { - $table->data[$kaction][($kaction + 1)] = html_print_image( - 'images/tick.png', - true, - ['class' => 'invert_filter'] - ); - } else { - $table->data[$kkaction][($kaction + 1)] = html_print_image( - 'images/blade.png', - true - ); - } + $table->data[$kaction][$k] = html_print_image( + 'images/blade.png', + true + ); } } - } - - $table->head[($kaction + 1)] = '#'.($kaction); - if (count($action['escalation']) === 0) { - $table->data[$kaction][($kaction + 2)] = html_print_image( - 'images/blade.png', - true - ); + } else { + $table->head[1] = __('Every time that the alert is fired'); + if (count($action['escalation']) > 0) { + if ($action['escalation'][0] > 0) { + $table->data[$kaction][1] .= html_print_image( + 'images/tick.png', + true, + ['class' => 'invert_filter'] + ); + } else { + $table->data[$kaction][1] = html_print_image( + 'images/blade.png', + true + ); + } + } else { + $table->data[$kaction][1] = html_print_image( + 'images/blade.png', + true + ); + } } $action_threshold = ($action['module_action_threshold'] > 0) ? $action['module_action_threshold'] : $action['action_threshold']; if ($action_threshold == 0) { - $table->data[$kaction][($k + 1)] = __('No'); + $table->data[$kaction][] = __('No'); } else { - $table->data[$kaction][($k + 1)] = human_time_description_raw( + $table->data[$kaction][] = human_time_description_raw( $action_threshold, true, 'tiny' ); } - - $table->head[($kaction + 1)] = __('Threshold'); } + + $table->head[] = __('Threshold'); } html_print_table($table); diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index 3324c92e9d..edaa003ce6 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -322,10 +322,18 @@ function update_template($step) if ($step == 1) { $name = (string) get_parameter('name'); + $name = trim(io_safe_output($name)); + if (strlen($name) === 0) { + ui_print_warning_message(__('You can\'t named a template with spaces')); + return false; + } + + $name = io_safe_input($name); $description = (string) get_parameter('description'); $wizard_level = (string) get_parameter('wizard_level'); $priority = (int) get_parameter('priority'); $id_group = get_parameter('id_group'); + $name_check = db_get_value('name', 'talert_templates', 'name', $name); // Only for Metaconsole. Save the previous name for synchronizing. if (is_metaconsole() === true) { $previous_name = db_get_value('name', 'talert_templates', 'id', $id); @@ -342,7 +350,12 @@ function update_template($step) 'previous_name' => $previous_name, ]; - $result = alerts_update_alert_template($id, $values); + if ($name_check === false) { + $result = alerts_update_alert_template($id, $values); + } else { + ui_print_warning_message(__('Another template with the same name already exists')); + $result = false; + } } else if ($step == 2) { $schedule = io_safe_output(get_parameter('schedule', [])); json_decode($schedule, true); @@ -487,6 +500,13 @@ $wizard_level = 'nowizard'; if ($create_template) { $name = (string) get_parameter('name'); + $name = trim(io_safe_output($name)); + if (strlen($name) === 0) { + ui_print_warning_message(__('You can\'t named a template with spaces')); + } + + $name = io_safe_input($name); + $description = (string) get_parameter('description'); $type = (string) get_parameter('type', 'critical'); $value = (string) get_parameter('value'); @@ -515,10 +535,11 @@ if ($create_template) { $values['field3_recovery'] = ' '; } - if (!$name_check) { + if ($name_check === false) { $result = alerts_create_alert_template($name, $type, $values); } else { - $result = ''; + ui_print_warning_message(__('Another template with the same name already exists')); + $result = false; } if ($result) { diff --git a/pandora_console/godmode/extensions.php b/pandora_console/godmode/extensions.php index baa3c2e6a5..5ec67b09a7 100644 --- a/pandora_console/godmode/extensions.php +++ b/pandora_console/godmode/extensions.php @@ -287,7 +287,7 @@ foreach ($extensions as $file => $extension) { [ 'href' => 'index.php?sec=godmode/extensions&sec2=godmode/extensions&enterprise='.(int) $extension['enterprise'].'&enabled='.$file, 'image' => 'images/lightbulb_off.png', - 'title' => __('Delete'), + 'title' => __('Enable'), ], true ); @@ -305,7 +305,7 @@ foreach ($extensions as $file => $extension) { [ 'href' => 'index.php?sec=godmode/extensions&sec2=godmode/extensions&enterprise='.(int) $extension['enterprise'].'&disabled='.$file, 'image' => 'images/lightbulb.png', - 'title' => __('Delete'), + 'title' => __('Disable'), ], true ); diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 3c3fbc0091..00bbdddb39 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -107,6 +107,8 @@ if (is_ajax() === true) { // Ids of agents to be include in the SQL clause as id_agent IN (). $filter_agents_json = (string) get_parameter('filter_agents_json', ''); $status_agents = (int) get_parameter('status_agents', AGENT_STATUS_ALL); + $os_agent = (int) get_parameter('os_agent', 0); + $os_agent_version = (string) get_parameter('os_agent_version', ''); // Juanma (22/05/2014) Fix: If setted remove void agents from result // (by default and for compatibility show void agents). $show_void_agents = (int) get_parameter('show_void_agents', 1); @@ -152,6 +154,14 @@ if (is_ajax() === true) { $filter['status'] = $status_agents; } + if ($os_agent !== 0) { + $filter['id_os'] = $os_agent; + } + + if ($os_agent_version !== '') { + $filter['os_version'] = $os_agent_version; + } + if ($id_os !== 0) { $filter['id_os'] = $id_os; } diff --git a/pandora_console/godmode/groups/tactical.php b/pandora_console/godmode/groups/tactical.php index 067bed45be..0b09cbc789 100644 --- a/pandora_console/godmode/groups/tactical.php +++ b/pandora_console/godmode/groups/tactical.php @@ -187,7 +187,7 @@ try { [ 'id' => 'list_agents_tactical', 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $columnNames, 'return' => true, diff --git a/pandora_console/godmode/massive/massive_copy_modules.php b/pandora_console/godmode/massive/massive_copy_modules.php index 5d069a8e9b..ade7a7f69b 100755 --- a/pandora_console/godmode/massive/massive_copy_modules.php +++ b/pandora_console/godmode/massive/massive_copy_modules.php @@ -86,31 +86,39 @@ if ($do_operation) { $groups = users_get_groups(); $table = new stdClass(); -$table->class = 'databox filters'; -$table->width = '100%'; -$table->data = []; -$table->style = []; -$table->style[0] = 'font-weight: bold;'; -$table->style[2] = 'font-weight: bold'; -$table->style[4] = 'font-weight: bold'; -$table->style[6] = 'font-weight: bold'; - -// Source selection $table->id = 'source_table'; -$table->data[0][0] = __('Group'); -$table->data[0][1] = html_print_select_groups( - false, - 'AW', - true, - 'source_id_group', - $source_id_group, - false, - '', - '', - true +$table->class = 'databox filters filter-table-adv'; +$table->width = '100%'; +$table->size[0] = '50%'; +$table->size[1] = '50%'; +$table->data = []; + +// Source selection. +$table->data[0][0] = html_print_label_input_block( + __('Group'), + html_print_select_groups( + false, + 'AW', + true, + 'source_id_group', + $source_id_group, + false, + '', + '', + true, + false, + false, + 'w100p', + false, + 'width:100%' + ) ); -$table->data[0][2] = __('Group recursion'); -$table->data[0][3] = html_print_checkbox('source_recursion', 1, $source_recursion, true, false); + +$table->data[0][1] = html_print_label_input_block( + __('Group recursion'), + html_print_checkbox('source_recursion', 1, $source_recursion, true, false) +); + $status_list = []; $status_list[AGENT_STATUS_NORMAL] = __('Normal'); $status_list[AGENT_STATUS_WARNING] = __('Warning'); @@ -118,37 +126,52 @@ $status_list[AGENT_STATUS_CRITICAL] = __('Critical'); $status_list[AGENT_STATUS_UNKNOWN] = __('Unknown'); $status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); $status_list[AGENT_STATUS_NOT_INIT] = __('Not init'); -$table->data[0][4] = __('Status'); -$table->data[0][5] = html_print_select( - $status_list, - 'status_agents_source', - 'selected', - '', - __('All'), - AGENT_STATUS_ALL, - true + +$table->data[1][0] = html_print_label_input_block( + __('Status'), + html_print_select( + $status_list, + 'status_agents_source', + 'selected', + '', + __('All'), + AGENT_STATUS_ALL, + true, + false, + true, + 'w100p' + ) ); -$table->data[0][6] = __('Agent'); -$table->data[0][6] .= ' '; -// $table->data[0][7] = html_print_select (agents_get_group_agents ($source_id_group, false, "none"), -// 'source_id_agent', $source_id_agent, false, __('Select'), 0, true); + $agents = ( $source_id_group ? agents_get_group_agents($source_id_group, false, 'none') : agents_get_group_agents(array_keys(users_get_groups($config['id_user'], 'AW', false))) ); -$table->data[0][7] = html_print_select($agents, 'source_id_agent', $source_id_agent, false, __('Select'), 0, true); - -echo '
'; +$table->data[1][1] = html_print_label_input_block( + __('Agent').' ', + html_print_select( + $agents, + 'source_id_agent', + $source_id_agent, + false, + __('Select'), + 0, + true + ) +); +echo ''; echo '
'; -echo ''; -echo ''.__('Source'); -echo ''; +echo ''.__('Source').''; html_print_table($table); echo '
'; -// Target selection + +unset($table); +// Target selection. +$table = new stdClass(); $table->id = 'target_table'; -$table->class = 'databox filters'; +$table->class = 'databox filters filter-table-adv'; +$table->width = '100%'; +$table->size[0] = '50%'; +$table->size[1] = '50%'; $table->data = []; $modules = []; @@ -169,66 +192,64 @@ foreach ($agent_alerts as $alert) { } $tags = tags_get_user_tags(); -$table->data['tags'][0] = __('Tags'); -$table->data['tags'][1] = html_print_select( - $tags, - 'tags[]', - $tags_name, - false, - __('Any'), - -1, - true, - true, - true +$table->colspan[0][0] = 2; +$table->data[0][0] = html_print_label_input_block( + __('Tags'), + html_print_select( + $tags, + 'tags[]', + $tags_name, + false, + __('Any'), + -1, + true, + true, + true, + '', + false, + 'overflow-x: hidden;white-space: nowrap;max-width: 1136px;' + ) ); -$table->data['operations'][0] = __('Operations'); -$table->data['operations'][1] = ''; -$table->data['operations'][1] .= html_print_checkbox('copy_modules', 1, true, true); -$table->data['operations'][1] .= html_print_label(__('Copy modules'), 'checkbox-copy_modules', true); -$table->data['operations'][1] .= '
'; - -$table->data['operations'][1] .= ''; -$table->data['operations'][1] .= html_print_checkbox('copy_alerts', 1, true, true); -$table->data['operations'][1] .= html_print_label(__('Copy alerts'), 'checkbox-copy_alerts', true); -$table->data['operations'][1] .= ''; - -$table->data['form_modules_filter'][0] = __('Filter Modules'); -$table->data['form_modules_filter'][1] = html_print_input_text('filter_modules', '', '', 20, 255, true); - -$table->data[1][0] = __('Modules'); -$table->data[1][1] = ''; -$table->data[1][1] .= html_print_select( - $modules, - 'target_modules[]', - 0, - false, - '', - '', - true, - true +$table->data[1][0] = html_print_label_input_block( + __('Operations'), + ''.html_print_checkbox('copy_modules', 1, true, true).html_print_label(__('Copy modules'), 'checkbox-copy_modules', true).''.html_print_checkbox('copy_alerts', 1, true, true).html_print_label(__('Copy alerts'), 'checkbox-copy_alerts', true).'' ); -$table->data[1][1] .= ''; -$table->data[1][1] .= ''; -$table->data[1][1] .= ''.__('No modules for this agent').''; -$table->data[1][1] .= ''; -$table->data[2][0] = __('Alerts'); -$table->data[2][1] = ''; -$table->data[2][1] .= html_print_select( - $alerts, - 'target_alerts[]', - 0, - false, - '', - '', - true, - true +$table->data[1][1] = html_print_label_input_block( + __('Filter Modules'), + html_print_input_text('filter_modules', '', '', 20, 255, true) +); + +$table->colspan[2][0] = 2; +$table->data[2][0] = html_print_label_input_block( + __('Modules'), + ''.html_print_select( + $modules, + 'target_modules[]', + 0, + false, + '', + '', + true, + true + ).''.__('No modules for this agent').'' +); + +$table->colspan[3][0] = 2; +$table->data[3][0] = html_print_label_input_block( + __('Alerts'), + ''.html_print_select( + $alerts, + 'target_alerts[]', + 0, + false, + '', + '', + true, + true + ).''.__('No alerts for this agent').'' ); -$table->data[2][1] .= ''; -$table->data[2][1] .= ''; -$table->data[2][1] .= ''.__('No alerts for this agent').''; -$table->data[2][1] .= ''; echo '