From 4fe9bdb9a53c60605adcb39aaf7bd0afbd33f6c6 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Wed, 30 Dec 2020 18:39:56 +0100 Subject: [PATCH 01/44] Fixed session close on api --- pandora_console/include/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index 944c3a710c..eccad7ad70 100644 --- a/pandora_console/include/api.php +++ b/pandora_console/include/api.php @@ -311,7 +311,7 @@ if ($correctLogin) { } // Logout. -if (session_status() === PHP_SESSION_ACTIVE) { +if (session_status() !== PHP_SESSION_DISABLED) { $_SESSION = []; // Could give a warning if no session file is created. Ignore. @session_destroy(); From d9f360016b8ab211fc5dbb0b01abafe5231c94c5 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 26 Jan 2021 09:06:49 +0100 Subject: [PATCH 02/44] user_list optimization --- pandora_console/godmode/users/user_list.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index 5178cce690..a297811c8d 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -412,17 +412,21 @@ if (!defined('METACONSOLE')) { $table->valign[6] = 'top'; } -$group_um = users_get_groups_UM($config['id_user']); - $info1 = []; $user_is_admin = users_is_admin(); -// Is admin or has group permissions all. -if ($user_is_admin || isset($group_um[0])) { + +if ($user_is_admin) { $info1 = get_users($order); } else { - foreach ($group_um as $group => $value) { - $info1 = array_merge($info1, users_get_users_by_group($group, $value)); + $group_um = users_get_groups_UM($config['id_user']); + // 0 is the group 'all'. + if (isset($group_um[0])) { + $info1 = get_users($order); + } else { + foreach ($group_um as $group => $value) { + $info1 = array_merge($info1, users_get_users_by_group($group, $value)); + } } } From 9454ed2ff3114c38cf9e5f52376a6fb59ffff656 Mon Sep 17 00:00:00 2001 From: marcos Date: Mon, 1 Feb 2021 12:11:39 +0100 Subject: [PATCH 03/44] unsort template items --- pandora_console/include/functions_reporting.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 0d4b19efc0..face94f8e9 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -189,6 +189,14 @@ function reporting_make_reporting_data( $metaconsole_on = is_metaconsole(); $index_content = 0; + + usort( + $contents, + function ($a, $b) { + return ($a['order'] <=> $b['order']); + } + ); + foreach ($contents as $content) { $content['name'] = io_safe_input($content['name']); $content['description'] = io_safe_input($content['description']); From 6a9587bff875e5e0771b71726b7e124873341551 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 1 Feb 2021 13:54:57 +0100 Subject: [PATCH 04/44] #4536 autocomplete = off by default --- pandora_console/include/functions_html.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index df1efd0703..538f0a23de 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2095,7 +2095,7 @@ function html_print_input_text_extended( 'list', ]; - $output = ' $attr_value) { // Check valid attribute. if (in_array($attribute, $valid_attrs) === false) { @@ -2581,6 +2581,10 @@ function html_print_input_number(array $settings):string $settings['maxlength'] = 255; } + if (isset($settings['autocomplete']) === false) { + $settings['autocomplete'] = 'off'; + } + foreach ($settings as $attribute => $attr_value) { // Check valid attribute. if (in_array($attribute, $valid_attrs) === false) { @@ -4357,7 +4361,7 @@ function html_print_input($data, $wrapper='div', $input_only=false) ((isset($data['function']) === true) ? $data['function'] : ''), ((isset($data['class']) === true) ? $data['class'] : ''), ((isset($data['onChange']) === true) ? $data['onChange'] : ''), - ((isset($data['autocomplete']) === true) ? $data['autocomplete'] : ''), + ((isset($data['autocomplete']) === true) ? $data['autocomplete'] : 'off'), ((isset($data['autofocus']) === true) ? $data['autofocus'] : false), ((isset($data['onKeyDown']) === true) ? $data['onKeyDown'] : ''), ((isset($data['form']) === true) ? $data['form'] : ''), From 28445e3decc55f7a899dca18c99b8113673c7f98 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 2 Feb 2021 15:45:47 +0100 Subject: [PATCH 05/44] API get license, get license_remaining --- pandora_console/include/api.php | 1 + pandora_console/include/functions_api.php | 96 +++++++++++++++++++++++ 2 files changed, 97 insertions(+) diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index 944c3a710c..5182a87d25 100644 --- a/pandora_console/include/api.php +++ b/pandora_console/include/api.php @@ -36,6 +36,7 @@ define('DEBUG', 0); define('VERBOSE', 0); // TESTING THE UPDATE MANAGER. +enterprise_include_once('load_enterprise.php'); enterprise_include_once('include/functions_enterprise_api.php'); $ipOrigin = $_SERVER['REMOTE_ADDR']; diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index d30da4cc4c..843ae291cb 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -375,6 +375,102 @@ function api_get_test_event_replication_db() // -------------------------DEFINED OPERATIONS FUNCTIONS----------------- + + +/** + * Example: http://localhost/pandora_console/include/api.php?op=get&op2=license&user=admin&apipass=1234&pass=pandora&return_type=json + * Retrieve license information. + * + * @param null $trash1 Not used. + * @param null $trash1 Not used. + * @param null $trash1 Not used. + * @param string $returnType Return type (string, json...). + * + * @return void + */ +function api_get_license($trash1, $trash2, $trash3, $returnType='json') +{ + global $config; + check_login(); + + if (! check_acl($config['id_user'], 0, 'PM')) { + returnError('forbidden', $returnType); + return; + } + + enterprise_include_once('include/functions_license.php'); + $license = enterprise_hook('license_get_info'); + if ($license === ENTERPRISE_NOT_HOOK) { + // Not an enterprise environment? + if (license_free()) { + $license = 'PANDORA_FREE'; + } + + returnData( + $returnType, + [ + 'type' => 'array', + 'data' => ['license_mode' => $license], + ] + ); + return; + } + + returnData( + $returnType, + [ + 'type' => 'array', + 'data' => $license, + ] + ); + +} + + +/** + * Retrieve license status agents or modules left. + * + * @param null $trash1 Not used. + * @param null $trash1 Not used. + * @param null $trash1 Not used. + * @param string $returnType Return type (string, json...). + * + * @return void + */ +function api_get_license_remaining( + $trash1, + $trash2, + $trash3, + $returnType='json' +) { + enterprise_include_once('include/functions_license.php'); + $license = enterprise_hook('license_get_info'); + if ($license === ENTERPRISE_NOT_HOOK) { + if (license_free()) { + returnData( + $returnType, + [ + 'type' => 'integer', + 'data' => PHP_INT_MAX, + ] + ); + } else { + returnError('get-license', 'Failed to verify license.'); + } + + return; + } + + returnData( + $returnType, + [ + 'type' => 'integer', + 'data' => ($license['limit'] - $license['count_enabled']), + ] + ); +} + + function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db) { $returnAllGroup = true; From f47eefdeec202d67665d578185521718457f97bf Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 2 Feb 2021 15:55:01 +0100 Subject: [PATCH 06/44] Minor fix --- pandora_console/include/functions_api.php | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 843ae291cb..9d616da4b7 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -428,6 +428,7 @@ function api_get_license($trash1, $trash2, $trash3, $returnType='json') /** + * Example: http://localhost/pandora_console/include/api.php?op=get&op2=license_remaining&user=admin&apipass=1234&pass=pandora&return_type=json * Retrieve license status agents or modules left. * * @param null $trash1 Not used. From 7017c6136eb0dd9bd8fa72c3372a3b668c3f763d Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 10 Feb 2021 10:21:39 +0100 Subject: [PATCH 07/44] Avoid events while ceasing alerts --- pandora_server/lib/PandoraFMS/Core.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 24b89ce1f1..aa63bba6d8 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -679,7 +679,12 @@ sub pandora_process_alert ($$$$$$$$;$$) { $alert->{'critical_instructions'} = $critical_instructions; $alert->{'warning_instructions'} = $warning_instructions; $alert->{'unknown_instructions'} = $unknown_instructions; - + + # Generate event only if not quieted by module or agent. + return if ((ref($module) eq 'HASH' && $module->{'quiet'} != "0") + || (ref($agent) eq 'HASH' && $agent->{'quiet'} != "0") + || (ref($alert) eq 'HASH' && $alert->{'disable_event'} != "0")); + # Generate an event if ($table eq 'tevent_alert') { pandora_event ($pa_config, "Alert ceased (" . From b44d9980347c80bc178ef6a9960f304f74681515 Mon Sep 17 00:00:00 2001 From: marcos Date: Wed, 10 Feb 2021 16:27:29 +0100 Subject: [PATCH 08/44] add deafult header --- pandora_console/general/first_task/cluster_builder.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandora_console/general/first_task/cluster_builder.php b/pandora_console/general/first_task/cluster_builder.php index f2bee5e687..019dae1e94 100644 --- a/pandora_console/general/first_task/cluster_builder.php +++ b/pandora_console/general/first_task/cluster_builder.php @@ -24,6 +24,14 @@ if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'], return; } +\ui_print_page_header( + __('Monitoring').' » '.__('Clusters'), + 'images/chart.png', + false, + '', + false +); + ui_require_css_file('first_task'); ?> Date: Mon, 15 Feb 2021 12:55:35 +0100 Subject: [PATCH 09/44] Fixed module library download links --- .../include/javascript/module_library.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/javascript/module_library.js b/pandora_console/include/javascript/module_library.js index 4d5be47f8c..c4f2f89eea 100644 --- a/pandora_console/include/javascript/module_library.js +++ b/pandora_console/include/javascript/module_library.js @@ -409,7 +409,7 @@ function print_excerpt(id_div, response) { category_names(elem.categories) + "

" + updated + - elem.content.rendered + + format_download_link(elem.content.rendered) + '