From 89253f41111853a7bf0c36e252ac68f691320750 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Fri, 13 Sep 2019 10:27:14 +0200 Subject: [PATCH 01/36] Added option for custom delimiter in export csv for datatables - #4623 --- pandora_console/include/functions_ui.php | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 008c05b8d7..4f529dbd43 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3205,6 +3205,7 @@ function ui_print_datatable(array $parameters) { extend: "csv", text : "'.__('Export current page to CSV').'", + fieldSeparator: "'.$config['csv_divider'].'", exportOptions : { modifier : { // DataTables core From c93c29fd591b15124833fceee6a05fd48987da9d Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Tue, 24 Sep 2019 16:37:53 +0200 Subject: [PATCH 02/36] Added recursion to api_get_all_agents --- pandora_console/include/functions_api.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 899add9ec0..ee349583b0 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -1860,7 +1860,7 @@ function api_set_delete_agent($id, $thrash1, $thrast2, $thrash3) * * @param $thrash1 Don't use. * @param $thrash2 Don't use. - * @param array $other it's array, $other as param are the filters available ;;;;; in this order + * @param array $other it's array, $other as param are the filters available ;;;;; in this order * and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_) * example for CSV: * @@ -1889,17 +1889,25 @@ function api_get_all_agents($thrash1, $thrash2, $other, $returnType) } if (isset($other['data'][0])) { - // Filter by SO + // Filter by SO. if ($other['data'][0] != '') { $where .= ' AND tconfig_os.id_os = '.$other['data'][0]; } } if (isset($other['data'][1])) { - // Filter by group + // Filter by group. if ($other['data'][1] != '') { - $where .= ' AND id_grupo = '.$other['data'][1]; + $ag_groups = $other['data'][1]; + // Recursion. + if ($other['data'][6] === '1') { + $ag_groups = groups_get_id_recursive($ag_groups, true); + } + + $ag_groups = implode(',', (array) $ag_groups); } + + $where .= ' AND (id_grupo IN ('.$ag_groups.') OR id_group IN ('.$ag_groups.'))'; } if (isset($other['data'][3])) { @@ -1933,8 +1941,8 @@ function api_get_all_agents($thrash1, $thrash2, $other, $returnType) $sql = "SELECT id_agente, alias, direccion, comentarios, tconfig_os.name, url_address, nombre FROM tconfig_os, tmetaconsole_agent - LEFT JOIN tagent_secondary_group - ON tmetaconsole_agent.id_agente = tagent_secondary_group.id_agent + LEFT JOIN tmetaconsole_agent_secondary_group + ON tmetaconsole_agent.id_agente = tmetaconsole_agent_secondary_group.id_agent WHERE tmetaconsole_agent.id_os = tconfig_os.id_os AND disabled = 0 $where AND $groups"; } else { @@ -1947,6 +1955,9 @@ function api_get_all_agents($thrash1, $thrash2, $other, $returnType) AND disabled = 0 $where AND $groups"; } + // Group by agent + $sql .= ' GROUP BY id_agente'; + $all_agents = db_get_all_rows_sql($sql); // Filter by status: unknown, warning, critical, without modules From 305d74878c5f01041c542c8ae7a81b17dbe05070 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Fri, 4 Oct 2019 11:51:30 +0200 Subject: [PATCH 03/36] Changed title of csv in events - #4625 --- pandora_console/include/functions_ui.php | 1 + pandora_console/operation/events/export_csv.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 06c4b579ea..90d5a7360c 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3206,6 +3206,7 @@ function ui_print_datatable(array $parameters) { extend: "csv", text : "'.__('Export current page to CSV').'", + title: "export_'.$parameters['id'].'_current_page_'.date('Y-m-d').'", exportOptions : { modifier : { // DataTables core diff --git a/pandora_console/operation/events/export_csv.php b/pandora_console/operation/events/export_csv.php index 0c16a16f9d..8f564bbb92 100644 --- a/pandora_console/operation/events/export_csv.php +++ b/pandora_console/operation/events/export_csv.php @@ -118,7 +118,7 @@ $now = date('Y-m-d'); // Download header. header('Content-type: text/txt'); -header('Content-Disposition: attachment; filename="pandora_export_event'.$now.'.csv"'); +header('Content-Disposition: attachment; filename="export_events_'.$now.'.csv"'); try { $fb64 = get_parameter('fb64', null); From bf19fbffd3743ea563844ea21fe790b1333feb48 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Thu, 10 Oct 2019 14:25:17 +0200 Subject: [PATCH 04/36] Added API and cli function get_agents_id_by_alias --- pandora_console/include/functions_api.php | 34 ++++++++++++++++++++++ pandora_server/util/pandora_manage.pl | 35 +++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 899add9ec0..5c8afeaac1 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -13450,6 +13450,40 @@ function api_get_agents_id_name_by_cluster_name($cluster_name, $trash1, $trash2, } +/** + * Get agents alias, id and server id (if Metaconsole) given agent alias + * matching part of it. + * + * @param string $alias + * @param $trash1 + * @param $trash2 + * @param string $returnType + * Example: + * api.php?op=get&op2=agents_id_name_by_alias&return_type=json&apipass=1234&user=admin&pass=pandora + */ +function api_get_agents_id_name_by_alias($alias, $trash1, $trash2, $returnType) +{ + global $config; + + if (is_metaconsole()) { + $all_agents = db_get_all_rows_sql("SELECT alias, id_agente, id_tagente,id_tmetaconsole_setup FROM tmetaconsole_agent WHERE upper(alias) LIKE upper('%$alias%')"); + } else { + $all_agents = db_get_all_rows_sql("SELECT alias, id_agente from tagente WHERE upper(alias) LIKE upper('%$alias%')"); + } + + if ($all_agents !== false) { + $data = [ + 'type' => 'json', + 'data' => $all_agents, + ]; + + returnData('json', $data, JSON_FORCE_OBJECT); + } else { + returnError('error_agents', 'No agents retrieved.'); + } +} + + function api_get_modules_id_name_by_cluster_id($cluster_id) { global $config; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 5faea24aa2..ac08b33116 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -4003,6 +4003,37 @@ sub cli_get_agent_modules() { } } +############################################################################## +# Show id, name and id_server of an agent given alias +# Related option: --get_agents_id_name_by_alias +############################################################################## + +sub cli_get_agents_id_name_by_alias() { + my $agent_alias = @ARGV[2]; + my @agents; + + if(is_metaconsole($conf) == 1) { + @agents = get_db_rows($dbh,"SELECT alias, id_agente, id_tagente,id_tmetaconsole_setup FROM tmetaconsole_agent WHERE UPPER(alias) LIKE UPPER(?)","%".$agent_alias."%"); + } else { + @agents = get_db_rows($dbh,"SELECT alias, id_agente, id_agente FROM tagente WHERE UPPER(alias) LIKE UPPER(?)", "%".$agent_alias."%"); + } + + if(scalar(@agents) == 0) { + print "[ERROR] No agents retrieved.\n\n"; + } + + if(is_metaconsole($conf) == 1) { + print "id_module, alias, id_server\n"; + } else { + print "id_module, alias\n"; + } + + foreach my $agent (@agents) { + print $agent->{'id_agente'}.",".safe_output($agent->{'alias'}).", ".$agent->{'id_tmetaconsole_setup'}."\n"; + } +} + + sub cli_create_synthetic() { my $name_module = @ARGV[2]; my $synthetic_type = @ARGV[3]; @@ -6285,6 +6316,10 @@ sub pandora_manage_main ($$$) { param_check($ltotal, 1); cli_get_agent_modules(); } + elsif ($param eq '--get_agents_id_name_by_alias') { + param_check($ltotal, 1); + cli_get_agents_id_name_by_alias(); + } elsif ($param eq '--get_policy_modules') { param_check($ltotal, 1); cli_get_policy_modules(); From 01148749a6e57186877e3578431612c62e348c89 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 14 Oct 2019 17:10:48 +0200 Subject: [PATCH 05/36] Added secondarygroups macro and updated spanish, english and japanses wiki --- pandora_console/include/help/en/help_alert_macros.php | 1 + pandora_console/include/help/es/help_alert_macros.php | 1 + pandora_console/include/help/ja/help_alert_macros.php | 2 ++ pandora_server/lib/PandoraFMS/Core.pm | 10 ++++++++++ 4 files changed, 14 insertions(+) diff --git a/pandora_console/include/help/en/help_alert_macros.php b/pandora_console/include/help/en/help_alert_macros.php index 9d730cfcc9..2a16e0b182 100644 --- a/pandora_console/include/help/en/help_alert_macros.php +++ b/pandora_console/include/help/en/help_alert_macros.php @@ -77,6 +77,7 @@ Besides the defined module macros, the following macros are available:
  • _policy_: Name of the policy that the module belongs to (if applies).
  • _prevdata_: Module previous data before the alert has been triggered.
  • _rca_: Root cause analysis chain (only for services).
  • +
  • _secondarygroups_: List of all secondary groups of the agent.
  • _server_ip_: Ip of server assigned to agent.
  • _server_name_: Name of server assigned to agent.
  • _target_ip_: IP address for the module’s target.
  • diff --git a/pandora_console/include/help/es/help_alert_macros.php b/pandora_console/include/help/es/help_alert_macros.php index 75e627f19a..e4fa442b2c 100644 --- a/pandora_console/include/help/es/help_alert_macros.php +++ b/pandora_console/include/help/es/help_alert_macros.php @@ -77,6 +77,7 @@ Además de las macros de módulo definidas, las siguientes macros están disponi
  • _policy_: Nombre de la política a la que pertenece el módulo (si aplica).
  • _prevdata_: Dato previo antes de disparase la alerta.
  • _rca_: Cadena de análasis de causa raíz (sólo para servicios).
  • +
  • _secondarygroups_: Lista de todos los grupos secundarios del agente.
  • _server_ip_: Ip del servidor al que el agente está asignado.
  • _server_name_: Nombre del servidor al que el agente está asignado.
  • _target_ip_: Dirección IP del objetivo del módulo.
  • diff --git a/pandora_console/include/help/ja/help_alert_macros.php b/pandora_console/include/help/ja/help_alert_macros.php index 36ff609741..65f598fc8b 100644 --- a/pandora_console/include/help/ja/help_alert_macros.php +++ b/pandora_console/include/help/ja/help_alert_macros.php @@ -77,11 +77,13 @@
  • _policy_ : モジュールが属するポリシー名 (存在する場合)
  • _prevdata_ : アラートを発報する前のモジュールデータ
  • _rca_: Root cause analysis chain (only for services).
  • +
  • _secondarygroups_: エージェントのすべてのセカンダリグループのリスト
  • _server_ip_ : エージェントが割り当てられているサーバ IP。
  • _server_name_ : エージェントが割り当てられているサーバ名。
  • _target_ip_ : モジュールの対象IPアドレス
  • _target_port_ : モジュールの対象ポート
  • _timestamp_ : アラートが発生した日時 (yy-mm-dd hh:mm:ss).
  • +エージェントのすべてのセカンダリグループのリスト
  • _timezone_: _timestamp_ で使用されるタイムゾーン名.
  • 例: Agent _agent_ has fired alert _alert_ with data _data_ diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index ef8a9c18bf..94c107f8e3 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1125,6 +1125,7 @@ sub pandora_execute_action ($$$$$$$$$;$) { _name_tag_ => undef, _all_address_ => undef, '_address_\d+_' => undef, + _secondarygroups_ => undef, ); if ((defined ($extra_macros)) && (ref($extra_macros) eq "HASH")) { @@ -4114,6 +4115,15 @@ sub on_demand_macro($$$$$$;$) { } return(defined($field_value)) ? $field_value : ''; + } elsif ($macro eq '_secondarygroups_') { + my $field_value = ''; + + my @groups = get_db_rows ($dbh, 'SELECT tg.nombre from tagent_secondary_group as tsg INNER JOIN tgrupo tg ON tsg.id_group = tg.id_grupo WHERE tsg.id_agent = ?', $module->{'id_agente'}); + foreach my $element (@groups) { + $field_value .= $element->{'nombre'} .","; + } + chop($field_value); + return(defined($field_value)) ? '('.$field_value.')' : ''; } } From e0ff5bf9cc9c1c4ca9671c7816e82b81e4d7c014 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 14 Oct 2019 17:13:13 +0200 Subject: [PATCH 06/36] Solved an issue with japanese wiki --- pandora_console/include/help/ja/help_alert_macros.php | 1 - 1 file changed, 1 deletion(-) diff --git a/pandora_console/include/help/ja/help_alert_macros.php b/pandora_console/include/help/ja/help_alert_macros.php index 65f598fc8b..86bf24ad59 100644 --- a/pandora_console/include/help/ja/help_alert_macros.php +++ b/pandora_console/include/help/ja/help_alert_macros.php @@ -83,7 +83,6 @@

  • _target_ip_ : モジュールの対象IPアドレス
  • _target_port_ : モジュールの対象ポート
  • _timestamp_ : アラートが発生した日時 (yy-mm-dd hh:mm:ss).
  • -エージェントのすべてのセカンダリグループのリスト
  • _timezone_: _timestamp_ で使用されるタイムゾーン名.
  • 例: Agent _agent_ has fired alert _alert_ with data _data_ From 85dff93f41f133d158e32ac8f954d7f997fe63f1 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Fri, 18 Oct 2019 12:22:20 +0200 Subject: [PATCH 07/36] Added strict option --- pandora_console/include/functions_api.php | 16 ++++++--- pandora_server/util/pandora_manage.pl | 41 ++++++++++++++++------- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 5c8afeaac1..a32c105cd2 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -13459,16 +13459,22 @@ function api_get_agents_id_name_by_cluster_name($cluster_name, $trash1, $trash2, * @param $trash2 * @param string $returnType * Example: - * api.php?op=get&op2=agents_id_name_by_alias&return_type=json&apipass=1234&user=admin&pass=pandora + * api.php?op=get&op2=agents_id_name_by_alias&return_type=json&apipass=1234&user=admin&pass=pandora&id=pandrora&id2=strict */ -function api_get_agents_id_name_by_alias($alias, $trash1, $trash2, $returnType) +function api_get_agents_id_name_by_alias($alias, $strict, $trash2, $returnType) { global $config; - if (is_metaconsole()) { - $all_agents = db_get_all_rows_sql("SELECT alias, id_agente, id_tagente,id_tmetaconsole_setup FROM tmetaconsole_agent WHERE upper(alias) LIKE upper('%$alias%')"); + if ($strict == 'strict') { + $where_clause = " alias = '$alias'"; } else { - $all_agents = db_get_all_rows_sql("SELECT alias, id_agente from tagente WHERE upper(alias) LIKE upper('%$alias%')"); + $where_clause = " upper(alias) LIKE upper('%$alias%')"; + } + + if (is_metaconsole()) { + $all_agents = db_get_all_rows_sql("SELECT alias, id_agente, id_tagente,id_tmetaconsole_setup, server_name FROM tmetaconsole_agent WHERE $where_clause"); + } else { + $all_agents = db_get_all_rows_sql("SELECT alias, id_agente from tagente WHERE $where_clause"); } if ($all_agents !== false) { diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index ac08b33116..ad75e40a00 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -121,6 +121,7 @@ sub help_screen{ help_screen_line('--get_agent_group', '', 'Get the group name of an agent'); help_screen_line('--get_agent_group_id', '', 'Get the group ID of an agent'); help_screen_line('--get_agent_modules', '', 'Get the modules of an agent'); + help_screen_line('--get_agents_id_name_by_alias', '', '[]', 'List id and alias of agents mathing given alias'); help_screen_line('--get_agents', '[ ]', "Get \n\t list of agents with optative filter parameters"); help_screen_line('--delete_conf_file', '', 'Delete a local conf of a given agent'); help_screen_line('--clean_conf_file', '', "Clean a local conf of a given agent deleting all modules, \n\t policies, file collections and comments"); @@ -4010,27 +4011,41 @@ sub cli_get_agent_modules() { sub cli_get_agents_id_name_by_alias() { my $agent_alias = @ARGV[2]; + my $strict = @ARGV[3]; my @agents; + my $where_value; - if(is_metaconsole($conf) == 1) { - @agents = get_db_rows($dbh,"SELECT alias, id_agente, id_tagente,id_tmetaconsole_setup FROM tmetaconsole_agent WHERE UPPER(alias) LIKE UPPER(?)","%".$agent_alias."%"); + use Data::Dumper; + print Dumper($agent_alias ,$strict); + if($strict eq 'strict') { + $where_value = $agent_alias; } else { - @agents = get_db_rows($dbh,"SELECT alias, id_agente, id_agente FROM tagente WHERE UPPER(alias) LIKE UPPER(?)", "%".$agent_alias."%"); + $where_value = "%".$agent_alias."%"; } + if(is_metaconsole($conf) == 1) { + @agents = get_db_rows($dbh,"SELECT alias, id_agente, id_tagente,id_tmetaconsole_setup FROM tmetaconsole_agent WHERE UPPER(alias) LIKE UPPER(?)", $where_value); + } else { + @agents = get_db_rows($dbh,"SELECT alias, id_agente, id_agente FROM tagente WHERE UPPER(alias) LIKE UPPER(?)", $where_value); + } if(scalar(@agents) == 0) { print "[ERROR] No agents retrieved.\n\n"; - } - - if(is_metaconsole($conf) == 1) { - print "id_module, alias, id_server\n"; } else { - print "id_module, alias\n"; - } + if(is_metaconsole($conf) == 1) { + print "id_module, alias, id_server\n"; - foreach my $agent (@agents) { - print $agent->{'id_agente'}.",".safe_output($agent->{'alias'}).", ".$agent->{'id_tmetaconsole_setup'}."\n"; - } + foreach my $agent (@agents) { + + print $agent->{'id_agente'}.",".safe_output($agent->{'alias'}).", ".$agent->{'id_tmetaconsole_setup'}."\n"; + } + } else { + print "id_module, alias\n"; + + foreach my $agent (@agents) { + print $agent->{'id_agente'}.",".safe_output($agent->{'alias'})."\n"; + } + } + } } @@ -6317,7 +6332,7 @@ sub pandora_manage_main ($$$) { cli_get_agent_modules(); } elsif ($param eq '--get_agents_id_name_by_alias') { - param_check($ltotal, 1); + param_check($ltotal, 2,1); cli_get_agents_id_name_by_alias(); } elsif ($param eq '--get_policy_modules') { From 4638915c70a48defc34d179f656473a375ab5269 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Fri, 18 Oct 2019 12:48:38 +0200 Subject: [PATCH 08/36] Fixed minor bugs --- pandora_console/include/functions_api.php | 2 +- pandora_server/util/pandora_manage.pl | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index a32c105cd2..902083728b 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -13472,7 +13472,7 @@ function api_get_agents_id_name_by_alias($alias, $strict, $trash2, $returnType) } if (is_metaconsole()) { - $all_agents = db_get_all_rows_sql("SELECT alias, id_agente, id_tagente,id_tmetaconsole_setup, server_name FROM tmetaconsole_agent WHERE $where_clause"); + $all_agents = db_get_all_rows_sql("SELECT alias, id_agente, id_tagente,id_tmetaconsole_setup as 'id_server', server_name FROM tmetaconsole_agent WHERE $where_clause"); } else { $all_agents = db_get_all_rows_sql("SELECT alias, id_agente from tagente WHERE $where_clause"); } diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index ad75e40a00..13c9857804 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -4015,8 +4015,6 @@ sub cli_get_agents_id_name_by_alias() { my @agents; my $where_value; - use Data::Dumper; - print Dumper($agent_alias ,$strict); if($strict eq 'strict') { $where_value = $agent_alias; } else { @@ -4024,22 +4022,22 @@ sub cli_get_agents_id_name_by_alias() { } if(is_metaconsole($conf) == 1) { - @agents = get_db_rows($dbh,"SELECT alias, id_agente, id_tagente,id_tmetaconsole_setup FROM tmetaconsole_agent WHERE UPPER(alias) LIKE UPPER(?)", $where_value); + @agents = get_db_rows($dbh,"SELECT alias, id_agente, id_tagente, id_tmetaconsole_setup as 'id_server', server_name FROM tmetaconsole_agent WHERE UPPER(alias) LIKE UPPER(?)", $where_value); } else { - @agents = get_db_rows($dbh,"SELECT alias, id_agente, id_agente FROM tagente WHERE UPPER(alias) LIKE UPPER(?)", $where_value); + @agents = get_db_rows($dbh,"SELECT alias, id_agente FROM tagente WHERE UPPER(alias) LIKE UPPER(?)", $where_value); } if(scalar(@agents) == 0) { print "[ERROR] No agents retrieved.\n\n"; } else { if(is_metaconsole($conf) == 1) { - print "id_module, alias, id_server\n"; + print "alias, id_agente, id_tagente, id_server, server_name\n"; foreach my $agent (@agents) { - print $agent->{'id_agente'}.",".safe_output($agent->{'alias'}).", ".$agent->{'id_tmetaconsole_setup'}."\n"; + print safe_output($agent->{'alias'}).", ".$agent->{'id_agente'}.", ".$agent->{'id_tagente'}.", ".$agent->{'id_server'}.", ".$agent->{'server_name'}."\n"; } } else { - print "id_module, alias\n"; + print "alias, id_agente\n"; foreach my $agent (@agents) { print $agent->{'id_agente'}.",".safe_output($agent->{'alias'})."\n"; From a06f56a4131b9c77b24da63df3f63876492dd267 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Wed, 23 Oct 2019 17:22:18 +0200 Subject: [PATCH 09/36] added function to convert cidr prefixes to mask --- pandora_console/include/functions.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 70eb7b8728..586d51be3c 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -4092,6 +4092,18 @@ function mask2cidr($mask) } +/** + * convert the cidr prefix to subnet mask + * + * @param int cidr prefix + * @return string subnet mask + */ +function cidr2mask($int) +{ + return long2ip(-1 << (32 - (int) $int)); +} + + function get_help_info($section_name) { global $config; From 38b3490e4e5ae40aa0d2a46e59fda24861653e40 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Thu, 24 Oct 2019 17:42:27 +0200 Subject: [PATCH 10/36] Changed color of constant to severity minor in events --- pandora_console/include/constants.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 8c5b1364f1..7c0e9ee552 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -147,7 +147,7 @@ define('COL_UNKNOWN', '#B2B2B2'); define('COL_DOWNTIME', '#976DB1'); define('COL_IGNORED', '#DDD'); define('COL_ALERTFIRED', '#F36201'); -define('COL_MINOR', '#B2B2B2'); +define('COL_MINOR', '#F099A2'); define('COL_MAJOR', '#C97A4A'); define('COL_INFORMATIONAL', '#E4E4E4'); define('COL_MAINTENANCE', '#4a83f3'); From 32da1d287bbbdbb59dbb2aeb7e1faa087e828369 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Mon, 28 Oct 2019 15:19:39 +0100 Subject: [PATCH 11/36] Fixed API function set_module_data --- pandora_console/include/functions_api.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 5aa1020214..2b124f5435 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -9080,7 +9080,9 @@ function api_set_delete_module($id, $id2, $other, $trash1) function api_set_module_data($id, $thrash2, $other, $trash1) { - if (defined('METACONSOLE')) { + global $config; + + if (is_metaconsole()) { return; } @@ -9129,8 +9131,9 @@ function api_set_module_data($id, $thrash2, $other, $trash1) ); if (false === @file_put_contents($config['remote_config'].'/'.io_safe_output($agent['nombre']).'.'.$time.'.data', $xml)) { - returnError('error_file', 'Can save agent data xml.'); + returnError('error_file', 'XML file could not be generated in path: '.$config['remote_config']); } else { + echo __('XML file was generated successfully in path: ').$config['remote_config']; returnData('string', ['type' => 'string', 'data' => $xml]); return; } From 64e80e6fee647c3e64c2f490303627828ac48618 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Tue, 29 Oct 2019 10:32:59 +0100 Subject: [PATCH 12/36] Fixed error message --- pandora_console/include/functions_api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 5ee6c1c7c6..21514cac7e 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -14261,7 +14261,7 @@ function api_get_agents_id_name_by_alias($alias, $strict, $trash2, $returnType) returnData('json', $data, JSON_FORCE_OBJECT); } else { - returnError('error_agents', 'No agents retrieved.'); + returnError('error_agents', 'Alias did not match any agent.'); } } From 8573add0b31e60f76186f0d8bcfbaa3666b37bfe Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 30 Oct 2019 13:01:59 +0100 Subject: [PATCH 13/36] Fixed agent name and error lenght --- pandora_console/operation/events/events.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index bc9c59eda5..7383a2c05c 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1539,7 +1539,7 @@ function process_datatables_callback(table, settings) { // Agent id. target = i; } - if(label == '') { + if(label == '') { // Agent id. target = i; break; @@ -1619,15 +1619,13 @@ function process_datatables_item(item) { // Show comments events. item.user_comment = item.comments - - if(item.comments.length > 80){ - item.user_comment += '  '; - item.user_comment += ' __('Show more')]); ?>'; - + if(typeof item.comments !== 'undefined' && item.comments.length > 80) { + item.user_comment += '  '; + item.user_comment += ' __('Show more')]); ?>'; } - + // Grouped events. if(item.max_id_evento) { item.id_evento = item.max_id_evento From 867ab6d0bf081df23b19533b360068650fdb4feb Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Thu, 31 Oct 2019 09:51:38 +0100 Subject: [PATCH 14/36] Fixed bug in report date --- pandora_console/include/functions_reporting.php | 4 ++++ pandora_console/include/functions_reporting_html.php | 9 +++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 1d0355cf97..ee1e7d6001 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -179,6 +179,10 @@ function reporting_make_reporting_data( $report['group_name'] = groups_get_name($report['id_group']); $report['contents'] = []; + if (empty($report['period']) && $pdf === false) { + $report['period'] = $period; + } + if (empty($contents)) { return reporting_check_structure_report($report); } diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index cf1fa60e70..3c773f9771 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -121,12 +121,9 @@ function html_do_report_info($report) '.__('Report date').': '; - if (isset($report['period'])) { - if (is_numeric($report['datetime']) && is_numeric($report['period'])) { - $html .= ''.date($config['date_format'], ($report['datetime'] - $report['period'])).''; - } - - $html .= ''; + if (is_numeric($report['datetime']) && is_numeric($report['period']) && ($report['period'] != 0)) { + $html .= ''.__('From').' '.date($config['date_format'], ($report['datetime'] - $report['period'])).''; + $html .= ''.__('to').' '.date($config['date_format'], $report['datetime']).''; } else { $html .= ''.__('Items period before').' '.date($config['date_format'], $report['datetime']).''; } From d0c2c0d1ebb5df46b3d1556c789c084b59667619 Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 4 Nov 2019 10:39:16 +0100 Subject: [PATCH 15/36] Fixed visual bug in general report item --- .../reporting_builder.item_editor.php | 5 +++- .../include/functions_reporting_html.php | 30 +++++++++++-------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index b59dbc2ee5..81bb605c01 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -3835,11 +3835,14 @@ $(document).ready (function () { }); $("#checkbox-checkbox_show_resume").change(function(){ - if($(this).is(":checked")){ + type = $("#type").val(); + if($(this).is(":checked") && type !== 'general'){ $("#row_select_fields2").show(); + $("#row_select_fields3").show(); } else{ $("#row_select_fields2").hide(); + $("#row_select_fields3").hide(); } }); diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index cf1fa60e70..a2345a9434 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -3625,10 +3625,10 @@ function reporting_html_general($table, $item, $pdf=0) } $table1->head[3] = __('Value'); - $table1->style[0] = 'text-align: left'; - $table1->style[1] = 'text-align: left'; - $table1->style[2] = 'text-align: left'; - $table1->style[3] = 'text-align: left'; + $table1->style[0] = 'text-align: center'; + $table1->style[1] = 'text-align: center'; + $table1->style[2] = 'text-align: center'; + $table1->style[3] = 'text-align: center'; // Begin - Order by agent. foreach ($item['data'] as $key => $row) { @@ -3759,12 +3759,16 @@ function reporting_html_general($table, $item, $pdf=0) $table_summary->head = []; $table_summary->head_colspan = []; $table_summary->align = []; + $table_summary->headstyle = []; + $table_summary->headstyle[0] = 'text-align: center;'; + $table_summary->headstyle[1] = 'text-align: center;'; + $table_summary->headstyle[2] = 'text-align: center;'; - $table_summary->align[0] = 'left'; - $table_summary->align[1] = 'right'; - $table_summary->align[2] = 'right'; - $table_summary->align[3] = 'left'; - $table_summary->align[4] = 'right'; + $table_summary->align[0] = 'center'; + $table_summary->align[1] = 'center'; + $table_summary->align[2] = 'center'; + $table_summary->align[3] = 'center'; + $table_summary->align[4] = 'center'; $table_summary->head_colspan[0] = 2; $table_summary->head[0] = __('Min Value'); @@ -3772,11 +3776,11 @@ function reporting_html_general($table, $item, $pdf=0) $table_summary->head_colspan[2] = 2; $table_summary->head[2] = __('Max Value'); - $table_summary->data[0][0] = $item['min']['agent'].' - '.$item['min']['module']; - $table_summary->data[0][1] = $item['min']['formated_value']; + $table_summary->data[0][0] = $item['min']['agent'].' - '.$item['min']['module'].str_repeat(' ', 20).$item['min']['formated_value']; + $table_summary->data[0][1] = ''; $table_summary->data[0][2] = format_for_graph($item['avg_value'], 2); - $table_summary->data[0][3] = $item['max']['agent'].' - '.$item['max']['module']; - $table_summary->data[0][4] = $item['max']['formated_value']; + $table_summary->data[0][3] = $item['max']['agent'].' - '.$item['max']['module'].str_repeat(' ', 20).$item['max']['formated_value']; + $table_summary->data[0][4] = ''; if ($pdf !== 0) { $return_pdf .= html_print_table($table_summary, true); From 9fc635a7a920cc8ae92fdc9d6c5c0af5d3407168 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Tue, 5 Nov 2019 11:03:28 +0100 Subject: [PATCH 16/36] user ack filter in event list not displaying users with all group --- pandora_console/operation/events/events.php | 2 +- pandora_console/operation/events/events_list.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index bc9c59eda5..12d4cbd087 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1018,7 +1018,7 @@ $adv_inputs[] = $in; $user_users = users_get_user_users( $config['id_user'], $access, - users_can_manage_group_all() + users_can_manage_group_all($access) ); $data = html_print_select( diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 298310a845..fc16470e37 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -767,7 +767,7 @@ $data[0] = __('User ack.').$jump; $user_users = users_get_user_users( $config['id_user'], $access, - users_can_manage_group_all() + users_can_manage_group_all($access) ); $data[0] .= html_print_select( From e583b71a99086fa56b18bc85ae069f0df6246a31 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 5 Nov 2019 11:51:26 +0100 Subject: [PATCH 17/36] missaligned tips --- pandora_console/extensions/quick_shell.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php index 8c87577abc..3b1e2db1ba 100644 --- a/pandora_console/extensions/quick_shell.php +++ b/pandora_console/extensions/quick_shell.php @@ -392,7 +392,8 @@ function quickShellSettings() 'inputs' => [ [ 'label' => __('Gotty path').ui_print_help_tip( - __('Leave blank if using an external Gotty service') + __('Leave blank if using an external Gotty service'), + true ), 'arguments' => [ 'type' => 'text', @@ -426,7 +427,8 @@ function quickShellSettings() ], [ 'label' => __('Gotty user').ui_print_help_tip( - __('Optional, set a user to access gotty service') + __('Optional, set a user to access gotty service'), + true ), 'arguments' => [ 'type' => 'text', @@ -436,7 +438,8 @@ function quickShellSettings() ], [ 'label' => __('Gotty password').ui_print_help_tip( - __('Optional, set a password to access gotty service') + __('Optional, set a password to access gotty service'), + true ), 'arguments' => [ 'type' => 'password', From dc565d2575225408601c7f54f6ffc4cc21d163e6 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 5 Nov 2019 12:01:58 +0100 Subject: [PATCH 18/36] pandora_websocket_engine installation in RPM/DEB packages --- pandora_console/DEBIAN/postinst | 6 ++++++ pandora_console/pandora_console.rhel7.spec | 6 ++++++ pandora_console/pandora_console.spec | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/pandora_console/DEBIAN/postinst b/pandora_console/DEBIAN/postinst index eb8e4872f3..731af15219 100755 --- a/pandora_console/DEBIAN/postinst +++ b/pandora_console/DEBIAN/postinst @@ -11,4 +11,10 @@ echo Restart the apache. /etc/init.d/apache2 restart fi +# Install pandora_websocket_engine service. +cp -pf %{prefix}/pandora_console/pandora_websocket_engine /etc/init.d/ + +echo "You can now start the Pandora FMS Websocket service by executing" +echo " /etc/init.d/pandora_websocket_engine start" + echo "Please, now, point your browser to http://your_IP_address/pandora_console/install.php and follow all the steps described on it." diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec index 91f5bebedf..553b604e9d 100644 --- a/pandora_console/pandora_console.rhel7.spec +++ b/pandora_console/pandora_console.rhel7.spec @@ -57,6 +57,12 @@ install -m 0644 pandora_console_logrotate_centos $RPM_BUILD_ROOT%{_sysconfdir}/l rm -rf $RPM_BUILD_ROOT %post +# Install pandora_websocket_engine service. +cp -pf %{prefix}/pandora_console/pandora_websocket_engine /etc/init.d/ + +echo "You can now start the Pandora FMS Websocket service by executing" +echo " /etc/init.d/pandora_websocket_engine start" + # Has an install already been done, if so we only want to update the files # push install.php aside so that the console works immediately using existing # configuration. diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 1aa902495e..335caf8001 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -58,6 +58,12 @@ fi rm -rf $RPM_BUILD_ROOT %post +# Install pandora_websocket_engine service. +cp -pf %{prefix}/pandora_console/pandora_websocket_engine /etc/init.d/ + +echo "You can now start the Pandora FMS Websocket service by executing" +echo " /etc/init.d/pandora_websocket_engine start" + # Has an install already been done, if so we only want to update the files # push install.php aside so that the console works immediately using existing # configuration. From 945383b8ece6593f8be7336ccbaf3ea5b9f0e67a Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Tue, 5 Nov 2019 12:43:08 +0100 Subject: [PATCH 19/36] Changed name of xml report --- pandora_console/operation/reporting/reporting_xml.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/operation/reporting/reporting_xml.php b/pandora_console/operation/reporting/reporting_xml.php index 4cd5a8508e..75bb3001db 100755 --- a/pandora_console/operation/reporting/reporting_xml.php +++ b/pandora_console/operation/reporting/reporting_xml.php @@ -91,10 +91,6 @@ check_login(); $id_report = (int) get_parameter('id'); $filename = (string) get_parameter('filename'); -if (empty($filename)) { - $filename = 'pandorafms_report_'.date('Y-m-d_His'); -} - $date_mode = get_parameter('date_mode', 'none'); $period = null; @@ -132,6 +128,10 @@ $report = reporting_make_reporting_data( 'static' ); +if (empty($filename)) { + $filename = $report['name'].'_report_'.date('Y-m-d_His'); +} + reporting_xml_get_report($report, $filename); exit; From b707ebd4a4007efc7a5ecccae05b8acce597e276 Mon Sep 17 00:00:00 2001 From: Luis Date: Tue, 5 Nov 2019 17:09:29 +0100 Subject: [PATCH 20/36] Added docs and support urls in console. Fixed bugs --- pandora_console/general/header.php | 6 +++--- pandora_console/general/login_help_dialog.php | 4 ++-- pandora_console/general/login_page.php | 8 ++++---- pandora_console/include/functions_ui.php | 20 +++++++++++++++++++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 99bb38cc21..e94309b415 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -331,19 +331,19 @@ if ($config['menu_type'] == 'classic') { // Support. if (defined('PANDORA_ENTERPRISE')) { - $header_support_link = 'https://support.artica.es/'; + $header_support_link = $config['custom_support_url']; } else { $header_support_link = 'https://pandorafms.com/forums/'; } $header_support = '

    '; // Documentation. $header_docu = ''; diff --git a/pandora_console/general/login_help_dialog.php b/pandora_console/general/login_help_dialog.php index 323b465d5a..b02c47cea9 100644 --- a/pandora_console/general/login_help_dialog.php +++ b/pandora_console/general/login_help_dialog.php @@ -87,7 +87,7 @@ echo '
    '; - echo ''.html_print_image( + echo ''.html_print_image( 'images/documentation.png', true, [ @@ -96,7 +96,7 @@ echo '
    '; - echo ''.__('Documentation').''; + echo ''.__('Documentation').''; echo ''; echo ''; echo ''; diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index 5aecfcc92c..ea40ef48aa 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -96,16 +96,16 @@ echo '
    '; echo '
      '; if ($docs_logo !== false) { - echo '
    • docs
    • '; + echo '
    • docs
    • '; } - echo '
    • '.__('Docs').'
    • '; + echo '
    • '.__('Docs').'
    • '; if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { if ($support_logo !== false) { - echo '
    • support
    • '; + echo '
    • support
    • '; } - echo '
    • '.__('Support').'
    • '; + echo '
    • '.__('Support').'
    • '; } else { echo '
    • support
    • '; echo '
    • '.__('Support').'
    • '; diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index a65cee76cd..266a4b6a99 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -5734,3 +5734,23 @@ function ui_print_comments($comments) return io_safe_output($comentario); } + + +/** + * Get complete external pandora url. + * + * @param string $url Url to be parsed. + * + * @return string Full url. + */ +function ui_get_full_external_url(string $url) +{ + $url_parsed = parse_url($url); + if ($url_parsed) { + if (!isset($url_parsed['scheme'])) { + $url = 'http://'.$url; + } + } + + return $url; +} From 4b9d6f1ae222c2dd218cb857dee65860447b7548 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Tue, 5 Nov 2019 17:18:38 +0100 Subject: [PATCH 21/36] fix bug in user list permission checks --- pandora_console/godmode/users/user_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index 6a02f4bb57..04ac8a22b6 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -418,7 +418,7 @@ if ($own_info['is_admin']) { else { foreach ($info1 as $key => $usr) { $u = get_user_info($key); - $g = users_get_groups($key, 'AR', $u['is_admin']); + $g = users_get_groups($key, false, $u['is_admin']); $result = array_intersect($g, $own_groups); // Show users without profile too. From a48673892088ea93257392f3dbb38a2799c6004f Mon Sep 17 00:00:00 2001 From: manuel Date: Wed, 6 Nov 2019 10:31:26 +0100 Subject: [PATCH 22/36] Fixed visual styles ticket 4809 --- .../godmode/agentes/modificar_agente.php | 81 ++++++++++++------- pandora_console/include/styles/pandora.css | 18 +++++ .../operation/agentes/estado_agente.php | 60 ++++++++++---- 3 files changed, 114 insertions(+), 45 deletions(-) diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index a383de35c4..3d2db9994a 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -14,7 +14,7 @@ // Load global vars check_login(); -// Take some parameters (GET) +// Take some parameters (GET). $offset = (int) get_parameter('offset'); $group_id = (int) get_parameter('group_id'); $ag_group = get_parameter('ag_group_refresh', -1); @@ -47,10 +47,10 @@ require_once 'include/functions_users.php'; $search = get_parameter('search', ''); -// Prepare the tab system to the future +// Prepare the tab system to the future. $tab = 'view'; -// Setup tab +// Setup tab. $viewtab['text'] = ''.html_print_image('images/operation.png', true, ['title' => __('View')]).''; $viewtab['operation'] = true; @@ -59,10 +59,10 @@ $viewtab['active'] = false; $onheader = ['view' => $viewtab]; -// Header +// Header. ui_print_page_header(__('Agents defined in %s', get_product_name()), 'images/agent_mc.png', false, '', true, $onheader); -// Perform actions +// Perform actions. $agent_to_delete = (int) get_parameter('borrar_agente'); $enable_agent = (int) get_parameter('enable_agent'); $disable_agent = (int) get_parameter('disable_agent'); @@ -99,7 +99,7 @@ if ($agent_to_delete) { ui_print_result_message($result, __('Success deleted agent.'), __('Could not be deleted.')); if (enterprise_installed()) { - // Check if the remote config file still exist + // Check if the remote config file still exist. if (isset($config['remote_config'])) { enterprise_include_once('include/functions_config_agents.php'); if (enterprise_hook('config_agents_has_remote_configuration', [$id_agente])) { @@ -114,7 +114,7 @@ if ($enable_agent) { $alias = agents_get_alias($enable_agent); if ($result) { - // Update the agent from the metaconsole cache + // Update the agent from the metaconsole cache. enterprise_include_once('include/functions_agents.php'); $values = ['disabled' => 0]; enterprise_hook('agent_update_from_cache', [$enable_agent, $values, $server_name]); @@ -136,7 +136,7 @@ if ($disable_agent) { $alias = agents_get_alias($disable_agent); if ($result) { - // Update the agent from the metaconsole cache + // Update the agent from the metaconsole cache. enterprise_include_once('include/functions_agents.php'); $values = ['disabled' => 1]; enterprise_hook('agent_update_from_cache', [$disable_agent, $values, $server_name]); @@ -223,6 +223,10 @@ switch ($config['dbtype']) { case 'oracle': $order_collation = ''; break; + + default: + // Default. + break; } $selected = true; @@ -252,6 +256,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Default. + break; } break; @@ -274,6 +282,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Default. + break; } break; @@ -296,6 +308,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Default. + break; } break; @@ -318,6 +334,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Default. + break; } break; @@ -378,7 +398,7 @@ if ($os != 0) { } $user_groups_to_sql = ''; -// Show only selected groups +// Show only selected groups. if ($ag_group > 0) { $ag_groups = []; $ag_groups = (array) $ag_group; @@ -388,7 +408,7 @@ if ($ag_group > 0) { $user_groups_to_sql = implode(',', $ag_groups); } else { - // Concatenate AW and AD permisions to get all the possible groups where the user can manage + // Concatenate AW and AD permisions to get all the possible groups where the user can manage. $user_groupsAW = users_get_groups($config['id_user'], 'AW'); $user_groupsAD = users_get_groups($config['id_user'], 'AD'); @@ -431,24 +451,25 @@ $sql = sprintf( $agents = db_get_all_rows_sql($sql); -// Delete rnum row generated by oracle_recode_query() function +// Delete rnum row generated by oracle_recode_query() function. if (($config['dbtype'] == 'oracle') && ($agents !== false)) { for ($i = 0; $i < count($agents); $i++) { unset($agents[$i]['rnum']); } } -// Prepare pagination +// Prepare pagination. ui_pagination($total_agents, "index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id=$ag_group&recursion=$recursion&search=$search&sort_field=$sortField&sort=$sort&disabled=$disabled&os=$os", $offset); if ($agents !== false) { // Urls to sort the table. - // Agent name size and description for Chinese and Japanese languages ​​are adjusted - $agent_font_size = '7'; - $description_font_size = '6.5'; - if ($config['language'] == 'ja' || $config['language'] == 'zh_CN' || $own_info['language'] == 'ja' || $own_info['language'] == 'zh_CN') { - $agent_font_size = '15'; - $description_font_size = '11'; + if ($config['language'] == 'ja' + || $config['language'] == 'zh_CN' + || $own_info['language'] == 'ja' + || $own_info['language'] == 'zh_CN' + ) { + // Adds a custom font size for Japanese and Chinese language. + $custom_font_size = 'custom_font_size'; } $url_up_agente = 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&group_id='.$ag_group.'&recursion='.$recursion.'&search='.$search.'&os='.$os.'&offset='.$offset.'&sort_field=name&sort=up&disabled=$disabled'; @@ -476,21 +497,21 @@ if ($agents !== false) { $rowPair = true; $iterator = 0; foreach ($agents as $agent) { - // Begin Update tagente.remote 0/1 with remote agent function return + // Begin Update tagente.remote 0/1 with remote agent function return. if (enterprise_hook('config_agents_has_remote_configuration', [$agent['id_agente']])) { db_process_sql_update('tagente', ['remote' => 1], 'id_agente = '.$agent['id_agente'].''); } else { db_process_sql_update('tagente', ['remote' => 0], 'id_agente = '.$agent['id_agente'].''); } - // End Update tagente.remote 0/1 with remote agent function return + // End Update tagente.remote 0/1 with remote agent function return. $all_groups = agents_get_all_groups_agent($agent['id_agente'], $agent['id_grupo']); $check_aw = check_acl_one_of_groups($config['id_user'], $all_groups, 'AW'); $check_ad = check_acl_one_of_groups($config['id_user'], $all_groups, 'AD'); $cluster = db_get_row_sql('select id from tcluster where id_agent = '.$agent['id_agente']); - // Do not show the agent if there is not enough permissions + // Do not show the agent if there is not enough permissions. if (!$check_aw && !$check_ad) { continue; } @@ -512,7 +533,7 @@ if ($agents !== false) { $rowPair = !$rowPair; $iterator++; - // Agent name + // Agent name. echo ""; if ($agent['disabled']) { echo ''; @@ -537,7 +558,7 @@ if ($agents !== false) { } else { echo '".''.$agent['alias'].''.''; + id_agente=".$agent['id_agente']."'>".''.$agent['alias'].''.''; } echo ''; @@ -617,12 +638,12 @@ if ($agents !== false) { echo ''; - // Operating System icon + // Operating System icon. echo ""; ui_print_os_icon($agent['id_os'], false); echo ''; - // Type agent (Networt, Software or Satellite) + // Type agent (Networt, Software or Satellite). echo ""; echo ui_print_type_agent_icon( $agent['id_os'], @@ -634,10 +655,12 @@ if ($agents !== false) { echo ''; - // Group icon and name + // Group icon and name. echo "".ui_print_group_icon($agent['id_grupo'], true).''; - // Description - echo "".ui_print_truncate_text($agent['comentarios'], 'description', true, true, true, '[…]', 'font-size: '.$description_font_size.'pt;').''; + + // Description. + echo "".ui_print_truncate_text($agent['comentarios'], 'description', true, true, true, '[…]').''; + // Action // When there is only one element in page it's necesary go back page. if ((count($agents) == 1) && ($offset >= $config['block_size'])) { @@ -695,7 +718,7 @@ if ($agents !== false) { } if (check_acl($config['id_user'], 0, 'AW')) { - // Create agent button + // Create agent button. echo '
      '; echo '
      '; html_print_input_hidden('new_agent', 1); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 459cc5c54d..b3a0ebca57 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -5889,6 +5889,12 @@ table.table_modal_alternate tr td:first-child { width: 100%; } +/* + * --------------------------------------------------------------------- + * - VISUAL STYLES FOR HISTOGRAM GRAPHS + * --------------------------------------------------------------------- + */ + .slicebar-box-hover-styles { position: absolute; background-color: #fff; @@ -5903,3 +5909,15 @@ table.table_modal_alternate tr td:first-child { .flot-text { width: 101%; } + +/* + * --------------------------------------------------------------------- + * - FONT SIZES IN AGENT VIEW. This changes the font size of the agent + * name and the description when the language is Japanese or Chinese + * --------------------------------------------------------------------- + */ + +.custom_font_size { + font-size: 14px; + font-weight: bold; +} diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index df2c36a1cd..ad25765007 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -155,7 +155,7 @@ if (is_ajax()) { ob_end_clean(); -// Take some parameters (GET) +// Take some parameters (GET). $group_id = (int) get_parameter('group_id', 0); $search = trim(get_parameter('search', '')); $search_custom = trim(get_parameter('search_custom', '')); @@ -172,10 +172,10 @@ $access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR'); $onheader = []; if (check_acl($config['id_user'], 0, 'AW')) { - // Prepare the tab system to the future + // Prepare the tab system to the future. $tab = 'setup'; - // Setup tab + // Setup tab. $setuptab['text'] = ''.html_print_image('images/setup.png', true, ['title' => __('Setup')]).''; $setuptab['godmode'] = true; @@ -193,7 +193,7 @@ if (!$strict_user) { } } -// User is deleting agent +// User is deleting agent. if (isset($result_delete)) { if ($result_delete) { ui_print_success_message(__('Sucessfully deleted agent')); @@ -283,7 +283,7 @@ $order = null; $order_collation = ''; switch ($config['dbtype']) { case 'mysql': - // $order_collation = " COLLATE utf8_general_ci"; + // $order_collation = " COLLATE utf8_general_ci";. $order_collation = ''; break; @@ -314,6 +314,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Default. + break; } break; @@ -336,6 +340,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Default. + break; } break; @@ -358,6 +366,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Default. + break; } break; @@ -380,6 +392,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Default. + break; } break; @@ -402,6 +418,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Default. + break; } break; @@ -424,6 +444,10 @@ switch ($sortField) { 'order' => 'ASC', ]; break; + + default: + // Default. + break; } break; @@ -446,6 +470,10 @@ switch ($sortField) { 'order' => 'ASC', ]; break; + + default: + // Default. + break; } break; @@ -505,7 +533,7 @@ if (!empty($search_custom)) { $search_sql_custom = ''; } -// Show only selected groups +// Show only selected groups. if ($group_id > 0) { $groups = [$group_id]; if ($recursion) { @@ -624,11 +652,13 @@ if (empty($agents)) { $agents = []; } -$agent_font_size = 'font-size: 7px'; -$description_font_size = 'font-size: 6.5px'; -if ($config['language'] == 'ja' || $config['language'] == 'zh_CN' || $own_info['language'] == 'ja' || $own_info['language'] == 'zh_CN') { - $agent_font_size = 'font-size: 15px'; - $description_font_size = 'font-size: 11px'; +if ($config['language'] == 'ja' + || $config['language'] == 'zh_CN' + || $own_info['language'] == 'ja' + || $own_info['language'] == 'zh_CN' +) { + // Adds a custom font size for Japanese and Chinese language. + $custom_font_size = 'custom_font_size'; } // Urls to sort the table. @@ -648,7 +678,7 @@ $url_up_last = 'index.php?sec=view&sec2=operation/agentes/estado_agente& $url_down_last = 'index.php?sec=view&sec2=operation/agentes/estado_agente&refr='.$refr.'&offset='.$offset.'&group_id='.$group_id.'&recursion='.$recursion.'&search='.$search.'&status='.$status.'&sort_field=last_contact&sort=down'; -// Prepare pagination +// Prepare pagination. ui_pagination( $total_agents, ui_get_url_refresh(['group_id' => $group_id, 'recursion' => $recursion, 'search' => $search, 'sort_field' => $sortField, 'sort' => $sort, 'status' => $status]) @@ -744,10 +774,8 @@ foreach ($agents as $agent) { $data = []; $data[0] = '
      '; - $data[0] .= ''; - $data[0] .= ' '.$agent['alias'].''; - $data[0] .= ''; + $data[0] .= ''.$agent['alias'].''; if ($agent['quiet']) { $data[0] .= ' '; @@ -779,7 +807,7 @@ foreach ($agents as $agent) { $data[0] .= '
      '; - $data[1] = ui_print_truncate_text($agent['description'], 'description', false, true, true, '[…]', $description_font_size); + $data[1] = ''.ui_print_truncate_text($agent['description'], 'description', false, true, true, '[…]').''; $data[10] = ''; From 1a34e488b67c9e7eda36c5a88e81414648cb9350 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Wed, 6 Nov 2019 10:34:08 +0100 Subject: [PATCH 23/36] Fixed bug in report date in pdf reports --- pandora_console/include/functions_reporting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index ef3d734286..a5e76eabf3 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -179,7 +179,7 @@ function reporting_make_reporting_data( $report['group_name'] = groups_get_name($report['id_group']); $report['contents'] = []; - if (empty($report['period']) && $pdf === false) { + if (empty($report['period'])) { $report['period'] = $period; } From e9b516c3990245faa5850299de8bf999e0535a54 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Wed, 6 Nov 2019 12:56:42 +0100 Subject: [PATCH 24/36] change access permission to users in user ack filter in event list --- pandora_console/operation/events/events.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 12d4cbd087..86b782f696 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1018,7 +1018,7 @@ $adv_inputs[] = $in; $user_users = users_get_user_users( $config['id_user'], $access, - users_can_manage_group_all($access) + true ); $data = html_print_select( From 90912e2636a7b3f9a2850cba23f8a99fe5ced12a Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Thu, 7 Nov 2019 09:52:06 +0100 Subject: [PATCH 25/36] Hide agent info when only GIS data is displayed and it is empty --- .../operation/agentes/estado_generalagente.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 24aa44e098..b7e0758596 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -825,7 +825,15 @@ $table_events = '
      $agent_contact = html_print_table($table_contact, true); -$agent_info = empty($table_data->data) ? '' : html_print_table($table_data, true); +if (empty($table_data->data)) { + $agent_info = ''; +} else { + if (count($table_data->data) === 1 && $config['activate_gis'] && $dataPositionAgent === false) { + $agent_info = ''; + } else { + $agent_info = html_print_table($table_data, true); + } +} $agent_incidents = !isset($table_incident) ? '' : html_print_table($table_incident, true); From d080f1d6a78a7cd905627e8ce98c42eeb9112b07 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 7 Nov 2019 10:42:46 +0100 Subject: [PATCH 26/36] Welcome pack --- pandora_console/images/arrow-icon.png | Bin 0 -> 369 bytes .../include/class/WelcomeWindow.class.php | 84 +++++++++++++----- .../new_installation_welcome_window.css | 43 ++++++++- pandora_console/include/styles/register.css | 5 +- 4 files changed, 107 insertions(+), 25 deletions(-) create mode 100644 pandora_console/images/arrow-icon.png diff --git a/pandora_console/images/arrow-icon.png b/pandora_console/images/arrow-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..73a0b08f9a7b64e50382261c37e2b60cbf897740 GIT binary patch literal 369 zcmV-%0gnEOP)F6XfHJ^HO~V>@>M8)K z03be4?|%8hfI0~17y}@+ABY8@LWw{}Ef^37K||&|l4BUibrcho0w@8CV?ba&(6I>v z;UIkJg(OE&GY!p$h7>M9RP<3hmr?8}MrxNMlsby)4x-diG;t6mj-r`^$aNG=9Yl_! z7@?Z_fmFc&)~RquF#;Xq0Ih=t8h{#YnMZsM+hF ziesqV>!8>%^r$*Watt*cv;a$2h-AmmB2ll0RzaZpF_7H;{U{hx03g5sVK0cF', modal: { title: "", - cancel: '', - ok: '' + cancel: '', + ok: '' }, onshow: { page: 'ajaxController; ?>', @@ -258,16 +258,25 @@ class WelcomeWindow extends Wizard $btn_create_alert_class = ''; $btn_create_discovery_class = 'pending'; + $li_configure_mail_class = 'green'; + $li_create_agent_class = 'green'; + $li_create_module_class = 'grey'; + $li_create_alert_class = 'grey'; + $li_create_discovery_class = 'green'; + switch ($this->step) { case W_CREATE_AGENT: $btn_configure_mail_class = ' completed'; $btn_create_agent_class = ' pending'; + $li_create_module_class = 'green'; break; case W_CREATE_MODULE: $btn_configure_mail_class = ' completed'; $btn_create_agent_class = ' completed'; $btn_create_module_class = ' pending'; + $li_create_module_class = 'green'; + $li_create_alert_class = 'green'; break; case W_CREATE_ALERT: @@ -275,6 +284,8 @@ class WelcomeWindow extends Wizard $btn_create_agent_class = ' completed'; $btn_create_module_class = ' completed'; $btn_create_alert_class = ' pending'; + $li_create_module_class = 'green'; + $li_create_alert_class = 'green'; break; case W_CREATE_TASK: @@ -283,6 +294,8 @@ class WelcomeWindow extends Wizard $btn_create_module_class = ' completed'; $btn_create_alert_class = ' completed'; $btn_create_discovery_class = ' pending'; + $li_create_module_class = 'green'; + $li_create_alert_class = 'green'; break; case WELCOME_FINISHED: @@ -292,6 +305,8 @@ class WelcomeWindow extends Wizard $btn_create_module_class = ' completed'; $btn_create_alert_class = ' completed'; $btn_create_discovery_class = ' completed'; + $li_create_module_class = 'green'; + $li_create_alert_class = 'green'; break; default: @@ -308,11 +323,32 @@ class WelcomeWindow extends Wizard 'class' => 'modal', ]; + $logo_url = ''; + if (enterprise_installed()) { + $logo_url = ENTERPRISE_DIR.'/'; + } + + $logo_url .= 'images/custom_logo/'.$config['custom_logo_white_bg']; + $inputs = [ + [ + 'class' => 'white_box', + 'block_content' => [ + [ + 'class' => 'centered_full', + 'arguments' => [ + 'type' => 'image', + 'src' => $logo_url, + 'value' => 1, + 'return' => true, + ], + ], + ], + ], [ 'wrapper' => 'div', 'block_id' => 'div_configure_mail', - 'class' => 'flex-row w100p', + 'class' => 'hole flex-row w100p '.$li_configure_mail_class, 'direct' => 1, 'block_content' => [ [ @@ -333,10 +369,20 @@ class WelcomeWindow extends Wizard ], ], ], - ],[ + ], + [ + 'label' => 'Learn to monitor', + 'class' => 'extra', + 'arguments' => [ + 'class' => 'class="lbl_learn"', + 'name' => 'lbl_learn', + 'id' => 'lbl_learn', + ], + ], + [ 'wrapper' => 'div', 'block_id' => 'div_create_agent', - 'class' => 'flex-row w100p', + 'class' => 'learn_content_indented flex-row w100p '.$li_create_agent_class, 'direct' => 1, 'block_content' => [ [ @@ -358,18 +404,10 @@ class WelcomeWindow extends Wizard ], ], ], - [ - 'label' => 'Learn to monitor', - 'arguments' => [ - 'class' => 'class="lbl_learn"', - 'name' => 'lbl_learn', - 'id' => 'lbl_learn', - ], - ], [ 'wrapper' => 'div', 'block_id' => 'div_monitor_actions', - 'class' => 'learn_content_indented flex-row w100p', + 'class' => 'learn_content_indented flex-row w100p '.$li_create_module_class, 'direct' => 1, 'block_content' => [ [ @@ -394,7 +432,7 @@ class WelcomeWindow extends Wizard [ 'wrapper' => 'div', 'block_id' => 'div_monitor_actions', - 'class' => 'learn_content_indented flex-row w100p', + 'class' => 'hole learn_content_indented flex-row w100p '.$li_create_alert_class, 'direct' => 1, 'block_content' => [ [ @@ -419,7 +457,7 @@ class WelcomeWindow extends Wizard [ 'wrapper' => 'div', 'block_id' => 'div_discover', - 'class' => 'flex-row w100p', + 'class' => 'hole flex-row w100p '.$li_create_discovery_class, 'direct' => 1, 'block_content' => [ [ @@ -444,7 +482,7 @@ class WelcomeWindow extends Wizard [ 'wrapper' => 'div', 'block_id' => 'div_not_working', - 'class' => 'flex-row w100p', + 'class' => 'hole flex-row w100p', 'direct' => 1, 'block_content' => [ [ @@ -505,6 +543,11 @@ class WelcomeWindow extends Wizard // Check current page. $sec2 = get_parameter('sec2', ''); + // Search also does not fulfill sec2. + if (empty($sec2) === true) { + $sec2 = get_parameter('keywords', ''); + } + if ($must_run === false || $config['welcome_state'] === WELCOME_FINISHED ) { @@ -545,12 +588,11 @@ class WelcomeWindow extends Wizard /* * Create agent. Control current flow. * - * On empty sec2: show current step. - * On agent creation page: do not show. - * After agent creation: enable module step. + * Welcome wizard is shown if you create your first agent. + * */ - if ($this->step === W_CREATE_AGENT) { + if (empty($config['welcome_id_agent']) === true) { // Create agent is pending. if ($sec2 === 'godmode/agentes/configurar_agente' && get_parameter('create_agent', false) !== false diff --git a/pandora_console/include/styles/new_installation_welcome_window.css b/pandora_console/include/styles/new_installation_welcome_window.css index 4aba16193d..369349495f 100644 --- a/pandora_console/include/styles/new_installation_welcome_window.css +++ b/pandora_console/include/styles/new_installation_welcome_window.css @@ -17,10 +17,11 @@ */ } -#welcome_form ul.wizard li { +#welcome_form ul.wizard > li { padding: 1em; - padding-bottom: 0; - padding-top: 1em; + padding-bottom: 0.6em; + padding-top: 0.6em; + padding-left: 0.7em; } #welcome_form label { @@ -55,8 +56,44 @@ .pending { background-image: url(../../images/darrowright.png); + background-image: url(../../images/arrow-icon.png); } .completed { background-image: url(../../images/input_tick.png); } + +.centered_full { + padding: 1em; + text-align: center; +} + +#welcome_form li.centered_full > label { + width: auto; +} + +#welcome_form ul.wizard li.white_box { + padding: 0; + margin-bottom: 2em; +} + +#welcome_form ul.wizard li.centered_full { + padding-top: 1em; + padding-bottom: 1em; +} + +#welcome_form li:not(.centered_full):not(.white_box) { + border-left: 4px solid #79a930; +} + +#welcome_form li:not(.centered_full):not(.white_box).grey { + border-left: 4px solid #d6d6d6; +} + +#welcome_form li.hole { + margin-bottom: 0.8em; +} + +#welcome_form li.extra { + padding-bottom: 2.5em; +} diff --git a/pandora_console/include/styles/register.css b/pandora_console/include/styles/register.css index ef0fdc6e1b..7fef0db90f 100644 --- a/pandora_console/include/styles/register.css +++ b/pandora_console/include/styles/register.css @@ -10,7 +10,8 @@ button.submit-cancel { cursor: pointer; text-align: center; height: 30px; - width: 90px; + width: auto; + min-width: 90px; } input[type="submit"].submit-cancel:hover, @@ -32,6 +33,8 @@ input[type="button"].submit-next { cursor: pointer; text-align: center; height: 30px; + width: auto; + min-width: 90px; } input[type="submit"].submit-next:hover, From f497312d29e5bf97127dcdda558c1d1933bda9a5 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 7 Nov 2019 10:54:05 +0100 Subject: [PATCH 27/36] minor fix. default values QS admin page --- pandora_console/extensions/quick_shell.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php index 3b1e2db1ba..3f9ca3c3c7 100644 --- a/pandora_console/extensions/quick_shell.php +++ b/pandora_console/extensions/quick_shell.php @@ -298,6 +298,19 @@ function quickShellSettings() ui_require_css_file('wizard'); ui_require_css_file('discovery'); + // Gotty settings. Internal communication (WS). + if (isset($config['gotty_host']) === false) { + config_update_value('gotty_host', '127.0.0.1'); + } + + if (isset($config['gotty_telnet_port']) === false) { + config_update_value('gotty_telnet_port', 8082); + } + + if (isset($config['gotty_ssh_port']) === false) { + config_update_value('gotty_ssh_port', 8081); + } + // Parser. // Gotty settings. Internal communication (WS). $gotty = get_parameter( From f95ecb0f281df8d3da585d4a1c2be63e7745416b Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 7 Nov 2019 13:00:38 +0100 Subject: [PATCH 28/36] Allow empty configuration for gotty path --- pandora_console/extensions/quick_shell.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php index 3f9ca3c3c7..a70e1b26b8 100644 --- a/pandora_console/extensions/quick_shell.php +++ b/pandora_console/extensions/quick_shell.php @@ -315,7 +315,7 @@ function quickShellSettings() // Gotty settings. Internal communication (WS). $gotty = get_parameter( 'gotty', - $config['gotty'] + null ); $gotty_host = get_parameter( 'gotty_host', From 664017aa3838025fbbd1d130c11f8c608eeecaac Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 7 Nov 2019 13:11:11 +0100 Subject: [PATCH 29/36] same, null is overwritten by ws.php --- pandora_console/extensions/quick_shell.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php index a70e1b26b8..9946c120ef 100644 --- a/pandora_console/extensions/quick_shell.php +++ b/pandora_console/extensions/quick_shell.php @@ -315,7 +315,7 @@ function quickShellSettings() // Gotty settings. Internal communication (WS). $gotty = get_parameter( 'gotty', - null + '' ); $gotty_host = get_parameter( 'gotty_host', From 5fe515a3ed4cb287c111b8b86b6a0d21c93aa346 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 7 Nov 2019 14:05:42 +0100 Subject: [PATCH 30/36] Fixed welcome flow --- .../include/class/WelcomeWindow.class.php | 220 ++++++++++++------ 1 file changed, 154 insertions(+), 66 deletions(-) diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 0c6cf4fbe6..86ed9d2b26 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -47,6 +47,19 @@ class WelcomeWindow extends Wizard 'cancelWelcome', ]; + /** + * Tasks. + * + * @var array + */ + private $tasks = [ + 'welcome_mail_configured', + 'welcome_id_agent', + 'welcome_module', + 'welcome_alert', + 'welcome_task', + ]; + /** * Url of controller. * @@ -197,6 +210,19 @@ class WelcomeWindow extends Wizard global $config; $this->step = $config['welcome_state']; + // Get step available. + if (empty($config['welcome_id_agent']) === true) { + $this->step = W_CREATE_AGENT; + } else if (empty($config['welcome_module']) === true) { + $this->step = W_CREATE_MODULE; + } else if (empty($config['welcome_alert']) === true) { + $this->step = W_CREATE_ALERT; + } else if (empty($config['welcome_task']) === true) { + $this->step = W_CREATE_TASK; + } else if (empty($config['welcome_mail_configured']) === true) { + $this->step = W_CONFIGURE_MAIL; + } + return $this->step; } @@ -212,7 +238,61 @@ class WelcomeWindow extends Wizard { $this->step = $step; config_update_value('welcome_state', $step); + } + + /** + * Completes current step. + * + * @return void + */ + public function completeStep() + { + switch ($this->step) { + case W_CONFIGURE_MAIL: + config_update_value('welcome_mail_configured', true); + break; + + case W_CREATE_AGENT: + config_update_value('welcome_id_agent', true); + break; + + case W_CREATE_MODULE: + config_update_value('welcome_module', true); + break; + + case W_CREATE_ALERT: + config_update_value('welcome_alert', true); + break; + + case W_CREATE_TASK: + config_update_value('welcome_task', true); + break; + + default: + // Ignore. + break; + } + + } + + + /** + * Check if all tasks had been completed. + * + * @return boolean All completed or not. + */ + public function checkAllTasks() + { + global $config; + + foreach ($this->tasks as $t) { + if (empty($config[$t]) === true) { + return false; + } + } + + return true; } @@ -264,56 +344,40 @@ class WelcomeWindow extends Wizard $li_create_alert_class = 'grey'; $li_create_discovery_class = 'green'; - switch ($this->step) { - case W_CREATE_AGENT: - $btn_configure_mail_class = ' completed'; - $btn_create_agent_class = ' pending'; - $li_create_module_class = 'green'; - break; + if (empty($config['welcome_mail_configured']) === false) { + $btn_configure_mail_class = ' completed'; + } - case W_CREATE_MODULE: - $btn_configure_mail_class = ' completed'; - $btn_create_agent_class = ' completed'; - $btn_create_module_class = ' pending'; - $li_create_module_class = 'green'; - $li_create_alert_class = 'green'; - break; + if (empty($config['welcome_id_agent']) === false) { + $btn_create_agent_class = ' completed'; + $btn_create_module_class = ' pending'; + $li_create_module_class = 'green'; + } - case W_CREATE_ALERT: - $btn_configure_mail_class = ' completed'; - $btn_create_agent_class = ' completed'; - $btn_create_module_class = ' completed'; - $btn_create_alert_class = ' pending'; - $li_create_module_class = 'green'; - $li_create_alert_class = 'green'; - break; + if (empty($config['welcome_module']) === false) { + $btn_create_module_class = ' completed'; + $btn_create_alert_class = ' pending'; + $li_create_module_class = 'green'; + } - case W_CREATE_TASK: - $btn_configure_mail_class = ' completed'; - $btn_create_agent_class = ' completed'; - $btn_create_module_class = ' completed'; - $btn_create_alert_class = ' completed'; - $btn_create_discovery_class = ' pending'; - $li_create_module_class = 'green'; - $li_create_alert_class = 'green'; - break; + if (empty($config['welcome_alert']) === false) { + $btn_create_alert_class = ' completed'; + $li_create_alert_class = 'green'; + } - case WELCOME_FINISHED: - // Nothing left to do. - $btn_configure_mail_class = ' completed'; - $btn_create_agent_class = ' completed'; - $btn_create_module_class = ' completed'; - $btn_create_alert_class = ' completed'; - $btn_create_discovery_class = ' completed'; - $li_create_module_class = 'green'; - $li_create_alert_class = 'green'; - break; + if (empty($config['welcome_task']) === false) { + $btn_create_discovery_class = ' completed'; + } - default: - case W_CONFIGURE_MAIL: - // Nothing done yet. - $btn_configure_mail_class = ' pending'; - break; + if ((int) $config['welcome_state'] === WELCOME_FINISHED) { + // Nothing left to do. + $btn_configure_mail_class = ' completed'; + $btn_create_agent_class = ' completed'; + $btn_create_module_class = ' completed'; + $btn_create_alert_class = ' completed'; + $btn_create_discovery_class = ' completed'; + $li_create_module_class = 'green'; + $li_create_alert_class = 'green'; } $form = [ @@ -537,6 +601,7 @@ class WelcomeWindow extends Wizard global $config; if (isset($config['welcome_state']) === false) { + $this->completeStep(); $this->setStep(W_CONFIGURE_MAIL); } @@ -549,7 +614,7 @@ class WelcomeWindow extends Wizard } if ($must_run === false - || $config['welcome_state'] === WELCOME_FINISHED + || ((int) $config['welcome_state']) === WELCOME_FINISHED ) { // Do not show if finished. return false; @@ -566,13 +631,14 @@ class WelcomeWindow extends Wizard * After mail configuration: enable agent step. */ - if ($this->step == W_CONFIGURE_MAIL) { + if ($this->step === W_CONFIGURE_MAIL) { if ($sec2 === 'godmode/setup/setup' && get_parameter('section', '') == 'general' && get_parameter('update_config', false) !== false ) { // Mail configuration have been processed. - $_SESSION['configured_mail'] = true; + $this->step = W_CONFIGURE_MAIL; + $this->completeStep(); $this->setStep(W_CREATE_AGENT); } else if ($sec2 === 'godmode/setup/setup' && get_parameter('section', '') === 'general' @@ -580,7 +646,7 @@ class WelcomeWindow extends Wizard // Mail configuration is being processed. return false; } else if (empty($sec2) === true) { - // If at main page, show welcome. + // Show main page. return true; } } @@ -598,10 +664,19 @@ class WelcomeWindow extends Wizard && get_parameter('create_agent', false) !== false ) { // Agent have been created. Store. + // Here complete step is not needed because is already done + // by setWelcomeAgent. $this->setWelcomeAgent( - db_get_value( - 'MAX(id_agente)', - 'tagente' + // Non yet processed. Get next available ID. + db_get_value_sql( + sprintf( + 'SELECT AUTO_INCREMENT + FROM information_schema.TABLES + WHERE TABLE_SCHEMA = "%s" + AND TABLE_NAME = "%s"', + $config['dbname'], + 'tagente' + ) ) ); $this->setStep(W_CREATE_MODULE); @@ -613,6 +688,8 @@ class WelcomeWindow extends Wizard // If at main page, show welcome. return true; } + } else if ($this->step === W_CREATE_AGENT) { + $this->step = W_CREATE_MODULE; } /* @@ -630,6 +707,7 @@ class WelcomeWindow extends Wizard && get_parameter('create_module', false) !== false ) { // Module have been created. + $this->completeStep(); $this->setStep(W_CREATE_ALERT); return true; } else if ($sec2 === 'godmode/agentes/configurar_agente' @@ -658,6 +736,7 @@ class WelcomeWindow extends Wizard && get_parameter('create_alert', false) !== false ) { // Alert have been created. + $this->completeStep(); $this->setStep(W_CREATE_TASK); return true; } else if ($sec2 === 'godmode/agentes/configurar_agente' @@ -679,24 +758,33 @@ class WelcomeWindow extends Wizard * After discovery task creation: finish. */ - if ($this->step === W_CREATE_TASK) { - // Create Discovery task is pending. - // Host&Devices finishses on page 2. - if ($sec2 === 'godmode/servers/discovery' - && get_parameter('page', 0) == 2 - ) { - // Discovery task have been created. - $this->setStep(WELCOME_FINISHED); + // Create Discovery task is pending. + // Host&Devices finishses on page 2. + if ($sec2 === 'godmode/servers/discovery' + && get_parameter('page', 0) == 2 + ) { + // Discovery task have been created. + $this->step = W_CREATE_TASK; + $this->completeStep(); + // Check if all other tasks had been completed. + if ($this->checkAllTasks() === true) { // Finished! do not show. + $this->setStep(WELCOME_FINISHED); return false; - } else if ($sec2 == 'godmode/servers/discovery') { - // Discovery task is being created. - return false; - } else if (empty($sec2) === true) { - // If at main page, show welcome. - return true; } + + return true; + } else if ($sec2 == 'godmode/servers/discovery') { + // Discovery task is being created. + return false; + } + + // Check if all other tasks had been completed. + if ($this->checkAllTasks() === true) { + // Finished! do not show. + $this->setStep(WELCOME_FINISHED); + return false; } if ($this->step === WELCOME_FINISHED) { From ab6e790b4e848916640d6c40b8f856522e8dd4bc Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 7 Nov 2019 14:20:29 +0100 Subject: [PATCH 31/36] minor-fix qs_admin interface --- pandora_console/extensions/quick_shell.php | 117 +++++++++++---------- 1 file changed, 63 insertions(+), 54 deletions(-) diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php index 9946c120ef..9d5d2b8851 100644 --- a/pandora_console/extensions/quick_shell.php +++ b/pandora_console/extensions/quick_shell.php @@ -312,69 +312,71 @@ function quickShellSettings() } // Parser. - // Gotty settings. Internal communication (WS). - $gotty = get_parameter( - 'gotty', - '' - ); - $gotty_host = get_parameter( - 'gotty_host', - $config['gotty_host'] - ); - $gotty_ssh_port = get_parameter( - 'gotty_ssh_port', - $config['gotty_ssh_port'] - ); - $gotty_telnet_port = get_parameter( - 'gotty_telnet_port', - $config['gotty_telnet_port'] - ); + if (get_parameter('qs_update', false) !== false) { + // Gotty settings. Internal communication (WS). + $gotty = get_parameter( + 'gotty', + '' + ); + $gotty_host = get_parameter( + 'gotty_host', + $config['gotty_host'] + ); + $gotty_ssh_port = get_parameter( + 'gotty_ssh_port', + $config['gotty_ssh_port'] + ); + $gotty_telnet_port = get_parameter( + 'gotty_telnet_port', + $config['gotty_telnet_port'] + ); - $gotty_user = get_parameter( - 'gotty_user', - $config['gotty_user'] - ); + $gotty_user = get_parameter( + 'gotty_user', + $config['gotty_user'] + ); - $gotty_pass = get_parameter( - 'gotty_pass', - io_output_password($config['gotty_pass']) - ); + $gotty_pass = get_parameter( + 'gotty_pass', + io_output_password($config['gotty_pass']) + ); - $gotty_pass = io_input_password($gotty_pass); + $gotty_pass = io_input_password($gotty_pass); - $changes = 0; - $critical = 0; - if ($config['gotty'] != $gotty) { - config_update_value('gotty', $gotty); - $changes++; - $critical++; - } + $changes = 0; + $critical = 0; + if ($config['gotty'] != $gotty) { + config_update_value('gotty', $gotty); + $changes++; + $critical++; + } - if ($config['gotty_host'] != $gotty_host) { - config_update_value('gotty_host', $gotty_host); - $changes++; - } + if ($config['gotty_host'] != $gotty_host) { + config_update_value('gotty_host', $gotty_host); + $changes++; + } - if ($config['gotty_telnet_port'] != $gotty_telnet_port) { - config_update_value('gotty_telnet_port', $gotty_telnet_port); - $changes++; - } + if ($config['gotty_telnet_port'] != $gotty_telnet_port) { + config_update_value('gotty_telnet_port', $gotty_telnet_port); + $changes++; + } - if ($config['gotty_ssh_port'] != $gotty_ssh_port) { - config_update_value('gotty_ssh_port', $gotty_ssh_port); - $changes++; - } + if ($config['gotty_ssh_port'] != $gotty_ssh_port) { + config_update_value('gotty_ssh_port', $gotty_ssh_port); + $changes++; + } - if ($config['gotty_user'] != $gotty_user) { - config_update_value('gotty_user', $gotty_user); - $changes++; - $critical++; - } + if ($config['gotty_user'] != $gotty_user) { + config_update_value('gotty_user', $gotty_user); + $changes++; + $critical++; + } - if ($config['gotty_pass'] != $gotty_pass) { - config_update_value('gotty_pass', $gotty_pass); - $changes++; - $critical++; + if ($config['gotty_pass'] != $gotty_pass) { + config_update_value('gotty_pass', $gotty_pass); + $changes++; + $critical++; + } } // Interface. @@ -460,6 +462,13 @@ function quickShellSettings() 'value' => io_output_password($config['gotty_pass']), ], ], + [ + 'arguments' => [ + 'type' => 'hidden', + 'name' => 'qs_update', + 'value' => 1, + ], + ], [ 'arguments' => [ 'type' => 'submit', From 763ec6772cf031d0c75960ba635e18337f2cd695 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 7 Nov 2019 17:26:32 +0100 Subject: [PATCH 32/36] Help feedback style improved --- .../include/class/HelpFeedBack.class.php | 84 +++++++--------- pandora_console/include/functions_html.php | 65 +++++++++---- pandora_console/include/functions_ui.php | 39 +++++++- .../include/styles/help_feedback.css | 96 ++++++------------- 4 files changed, 145 insertions(+), 139 deletions(-) diff --git a/pandora_console/include/class/HelpFeedBack.class.php b/pandora_console/include/class/HelpFeedBack.class.php index 074f3d8df2..44751624f5 100644 --- a/pandora_console/include/class/HelpFeedBack.class.php +++ b/pandora_console/include/class/HelpFeedBack.class.php @@ -91,6 +91,7 @@ class HelpFeedBack extends Wizard */ public function run() { + ui_require_css_File('discovery'); ui_require_css_file('help_feedback'); $help_url = get_parameter('url', null); @@ -123,8 +124,6 @@ class HelpFeedBack extends Wizard { global $config; - ui_require_css_file('helper'); - $form = [ 'action' => '#', 'id' => 'feedback_form', @@ -134,35 +133,38 @@ class HelpFeedBack extends Wizard $inputs = [ [ 'wrapper' => 'div', - 'block_id' => 'btn_section', - 'class' => 'btn_section', + 'block_id' => 'flex-row-baseline w100p', + 'class' => 'flex-row-baseline w100p', 'direct' => 1, 'block_content' => [ [ 'arguments' => [ 'label' => __('Sugesstion'), - 'type' => 'button', - 'attributes' => 'class="btn_sug"', - 'name' => 'option_1', - 'id' => 'option_1', - 'script' => 'change_option1()', + 'type' => 'radio_button', + 'attributes' => 'class="btn"', + 'name' => 'suggestion', + 'id' => 'suggestion', + 'script' => 'disableRadio(\'report\')', + 'return' => true, ], ], [ 'arguments' => [ 'label' => __('Something is not quite right'), - 'type' => 'button', - 'attributes' => 'class="btn_something"', - 'name' => 'option_2', - 'id' => 'option_2', - 'script' => 'change_option2()', + 'type' => 'radio_button', + 'attributes' => 'class="btn"', + 'name' => 'report', + 'id' => 'report', + 'script' => 'disableRadio(\'suggestion\')', + 'return' => true, ], ], ], ], [ - 'label' => __('What Happend?'), + 'label' => __('What happened?'), + 'class' => 'explain', 'arguments' => [ 'class' => 'textarea_feedback', 'id' => 'feedback_text', @@ -192,21 +194,22 @@ class HelpFeedBack extends Wizard ], ]; - $output = ui_toggle( - $this->printForm( - [ - 'form' => $form, - 'inputs' => $inputs, - ], - true - ), - __('Feedback'), - '', - '', - true, - false, - '', - 'no-border' + $output = ui_print_toggle( + [ + 'content' => $this->printForm( + [ + 'form' => $form, + 'inputs' => $inputs, + ], + true + ), + 'name' => __('Feedback'), + 'return' => true, + 'class' => 'no-border', + 'img_a' => 'images/arrow_down_white.png', + 'img_b' => 'images/arrow_up_white.png', + + ] ); $output .= $this->loadJS(); @@ -254,24 +257,10 @@ class HelpFeedBack extends Wizard ob_start(); ?>