From fd6aef1b37e41d2b3e7c1ce80b18b933ad1c0579 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Wed, 9 Dec 2020 18:15:01 +0100 Subject: [PATCH 01/49] Added control for id_agent_module --- pandora_console/operation/events/events.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index f24aa98699..5efe5a538d 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -140,8 +140,11 @@ $text_module = get_parameter( $filter['module_search'] ); $id_agent_module = get_parameter( - 'filter[id_agent_module]', - $filter['id_agent_module'] + 'id_agent_module', + get_parameter( + 'filter[id_agent_module]', + $filter['id_agent_module'] + ) ); $pagination = get_parameter( 'filter[pagination]', From d0b119c05f712da25d50ca9b4b0aa4ebdd1c1e22 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Thu, 10 Dec 2020 10:49:13 +0100 Subject: [PATCH 02/49] Module library user pass let empty user/pass --- pandora_console/include/functions_config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 4d3665db4d..fe148bfc1e 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1619,12 +1619,12 @@ function config_update_config() case 'module_library': $module_library_user = get_parameter('module_library_user'); - if ($module_library_user == '' || !config_update_value('module_library_user', $module_library_user)) { + if (!config_update_value('module_library_user', $module_library_user)) { $error_update[] = __('User'); } $module_library_password = get_parameter('module_library_password'); - if ($module_library_password == '' || !config_update_value('module_library_password', $module_library_password)) { + if (!config_update_value('module_library_password', $module_library_password)) { $error_update[] = __('Password'); } break; From 90d8ac5129197d672ded0a0dfcc48e809090232a Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 4 Jan 2021 15:12:55 +0100 Subject: [PATCH 03/49] Fixed ip target while creating policy modules --- pandora_console/include/functions_snmp_browser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index 0d3c5ca32d..5a3546354e 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -1316,7 +1316,7 @@ function snmp_browser_create_modules_snmp(string $module_target, array $snmp_val 'min_ff_event_critical' => 0, 'ff_type' => 0, 'each_ff' => 0, - 'ip_target' => $target_ip, + 'ip_target' => '', 'configuration_data' => '', 'history_data' => 1, ]; From 2781b4ab34d0b8c30cfba28d6d4cb24be78bf34f Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 5 Jan 2021 11:42:34 +0100 Subject: [PATCH 04/49] Fixed task list groups --- .../godmode/wizards/DiscoveryTaskList.class.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index a0a5fe549f..df81a7e8ff 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -379,7 +379,22 @@ class DiscoveryTaskList extends HTML include_once $config['homedir'].'/include/functions_servers.php'; include_once $config['homedir'].'/include/functions_network_profiles.php'; - $recon_tasks = db_get_all_rows_sql('SELECT * FROM trecon_task'); + if (users_is_admin()) { + $recon_tasks = db_get_all_rows_sql('SELECT * FROM trecon_task'); + } else { + $user_groups = implode( + ',', + array_keys(users_get_groups()) + ); + $recon_tasks = db_get_all_rows_sql( + sprintf( + 'SELECT * FROM trecon_task + WHERE id_group IN (%s)', + $user_groups + ) + ); + } + // Show network tasks for Recon Server. if ($recon_tasks === false) { $recon_tasks = []; From f89397996fd77cd7753f9b7c5479c729ebfa854e Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 8 Jan 2021 11:59:45 +0100 Subject: [PATCH 05/49] avoid double networkmap creation --- pandora_console/operation/agentes/pandora_networkmap.editor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/operation/agentes/pandora_networkmap.editor.php b/pandora_console/operation/agentes/pandora_networkmap.editor.php index 147d417b76..5b5a9e8f7f 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.editor.php +++ b/pandora_console/operation/agentes/pandora_networkmap.editor.php @@ -424,7 +424,7 @@ if ($not_found) { __('Save networkmap'), 'crt', false, - 'class="sub next"' + 'class="sub next" onclick="if (typeof(sent) == \'undefined\') {sent = 1; return true;} else {return false;}"' ); } From 73c182f65da06e56066d0a161446f87385cf382a Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 11 Jan 2021 18:32:44 +0100 Subject: [PATCH 06/49] Avoid performance tests if there are not enough modules in system --- pandora_console/include/class/ConsoleSupervisor.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index cc52f2062f..b495816fe1 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -45,6 +45,11 @@ enterprise_include_once('include/functions_cron.php'); class ConsoleSupervisor { + /** + * Minimum modules to check performance. + */ + public const MIN_PERFORMANCE_MODULES = 100; + /** * Show if console supervisor is enabled or not. * @@ -1141,6 +1146,12 @@ class ConsoleSupervisor $max_grown = ($total_modules[$queue['server_type']] * 0.40); } + if ($total_modules[$queue['server_type']] < self::MIN_PERFORMANCE_MODULES) { + $this->cleanNotifications('NOTIF.SERVER.QUEUE.'.$key); + // Skip. + continue; + } + // Compare queue increments in a not over 900 seconds. if (empty($previous[$key]['modules']) || ($time - $previous[$key]['utime']) > 900 From b2d13697173b54184307d6da1f97e99a730b6d86 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 12 Jan 2021 13:50:44 +0100 Subject: [PATCH 07/49] Added with option for api_get_module_graph --- pandora_console/include/functions_api.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 980bfc0d25..ef49a94ad9 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -13773,11 +13773,15 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) // Graph height when send email by alert $height = (!empty($other) && isset($other['data'][3]) && $other['data'][3]) ? $other['data'][3] : 225; + + // Graph width (optional). + $width = (!empty($other) && isset($other['data'][4]) && $other['data'][4]) ? $other['data'][4] : 225; } else { $graph_seconds = $other['data']; $graph_threshold = 0; $other['data'][1] = 0; $height = 225; + $width = '90%'; } if (is_nan($graph_seconds) || $graph_seconds <= 0) { From 93a4d92a72de0bcece91615f23f3edad8c8551d7 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 18 Jan 2021 14:56:36 +0100 Subject: [PATCH 08/49] Modified line for solve linter error --- pandora_console/include/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 6166eeea60..e2b466008d 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1798,7 +1798,7 @@ function is_ajax() */ function is_error($code) { - if ($code !== true and ($code <= ERR_GENERIC || $code === false)) { + if ($code !== true && ($code <= ERR_GENERIC || $code === false)) { return true; } else { return false; From 260b2dbdf70bfd200b426d01b7f215a64c8a27f9 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 18 Jan 2021 14:57:20 +0100 Subject: [PATCH 09/49] Community API functions file --- pandora_console/include/functions_api.php | 713 +++++++++++----------- 1 file changed, 354 insertions(+), 359 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 1afd3f8431..ec4770757b 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -94,7 +94,7 @@ function returnError($typeError, $returnType='string') $returnType, [ 'type' => 'string', - 'data' => __('No set or get or help operation.'), + 'data' => __('Not `set`, `get` or `help` operation selected.'), ] ); break; @@ -114,7 +114,7 @@ function returnError($typeError, $returnType='string') $returnType, [ 'type' => 'string', - 'data' => __('Id does not exist in database.'), + 'data' => __('The Id does not exist in database.'), ] ); break; @@ -134,7 +134,7 @@ function returnError($typeError, $returnType='string') $returnType, [ 'type' => 'string', - 'data' => __('The user has not enough permission to make this action.'), + 'data' => __('The user has not enough permissions for perform this action.'), ] ); break; @@ -154,7 +154,7 @@ function returnError($typeError, $returnType='string') $returnType, [ 'type' => 'string', - 'data' => __('This console is not manager of this environment, please manage this feature from centralized manager console (Metaconsole).'), + 'data' => __('This console is not the environment administrator. Please, manage this feature from centralized manager console (Metaconsole).'), ] ); break; @@ -1363,7 +1363,7 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3) if ($idParent != 0) { $parentCheck = agents_check_access_agent($idParent); if ($parentCheck === null) { - returnError('parent_agent_not_exist', __('The agent parent don`t exist.')); + returnError('parent_agent_not_exist', __('The parent agent does not exist.')); return; } @@ -1507,7 +1507,7 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) global $config; if (!check_acl($config['id_user'], 0, 'AW')) { - returnError('forbidden', 'you havent got permissions to do this'); + returnError('forbidden', 'string'); return; } @@ -1516,8 +1516,7 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) } if ((int) $other['data'][3] == 0) { - $agent_creation_error = __('The agent could not be created, for security reasons use a group another than 0'); - returnError('generic error', $agent_creation_error); + returnError('generic error', __('For security reasons, the agent was not created. Use a group other than 0.')); return; } @@ -1658,9 +1657,9 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) $id_agente = 0; if ($exists_alias) { - $agent_creation_error = __('Could not be created, because name already exists'); + $agent_creation_error = __('Could not be created because name already exists'); } else if ($exists_ip) { - $agent_creation_error = __('Could not be created, because IP already exists'); + $agent_creation_error = __('Could not be created because IP already exists'); } else { $agent_creation_error = __('Could not be created for unknown reason'); } @@ -1705,7 +1704,7 @@ function api_set_create_os($thrash1, $thrash2, $other, $thrash3) if ($resultOrId) { echo __('Success creating OS'); } else { - echo __('Error creating OS'); + echo __('Could not create OS'); } } @@ -1736,7 +1735,7 @@ function api_set_update_os($id_os, $thrash2, $other, $thrash3) if (db_process_sql_update('tconfig_os', $values, ['id_os' => $id_os])) { echo __('Success updating OS'); } else { - echo __('Error updating OS'); + echo __('Could not update OS'); } } @@ -1763,7 +1762,7 @@ function api_set_create_custom_field($t1, $t2, $other, $returnType) } if ($other['type'] == 'string') { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else if ($other['type'] == 'array') { $name = ''; @@ -1923,9 +1922,9 @@ function api_set_delete_agent($id, $thrash1, $other, $thrash3) } if (!$result) { - returnError('error_delete', 'Error in delete operation.'); + returnError('error_delete', __('The agent could not be deleted')); } else { - returnData('string', ['type' => 'string', 'data' => __('Correct Delete')]); + returnData('string', ['type' => 'string', 'data' => __('The agent was successfully deleted')]); } } @@ -3263,6 +3262,7 @@ function api_set_create_network_module($id, $thrash1, $other, $thrash3) if ($agent_by_alias) { $agents_affected = 0; + $idModule = false; foreach ($idsAgents as $id) { if (!util_api_check_agent_and_print_error($id['id_agente'], 'string', 'AW')) { @@ -3318,7 +3318,7 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3) if ($id_module == '') { returnError( 'error_update_network_module', - __('Error updating network module. Module name cannot be left blank.') + __('Could not update network module. Module name cannot be left blank.') ); return; } @@ -3337,7 +3337,7 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3) if (!$check_id_module) { returnError( 'error_update_network_module', - __('Error updating network module. Id_module doesn\'t exist.') + __('Could not update network module. Id_module does not exist.') ); return; } @@ -3363,7 +3363,7 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3) if ($id_module_exists) { returnError( 'error_update_network_module', - __('Error updating network module. Id_module exists in the new agent.') + __('Could not update network module. Id_module exists in the new agent.') ); return; } @@ -3419,7 +3419,7 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3) $result_update = modules_update_agent_module($id_module, $values); if ($result_update < 0) { - returnError('error_update_network_module', 'Error updating network module.'); + returnError('error_update_network_module', __('Could not update network module.')); } else { returnData('string', ['type' => 'string', 'data' => __('Network module updated.')]); } @@ -3552,7 +3552,7 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3) if (is_error($idModule)) { // TODO: Improve the error returning more info. - returnError('error_create_plugin_module', __('Error in creation plugin module.')); + returnError('error_create_plugin_module', __('Could not create Plugin module.')); } else { returnData('string', ['type' => 'string', 'data' => $idModule]); } @@ -3584,7 +3584,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3) } if ($id_module == '') { - returnError('error_update_plugin_module', __('Error updating plugin module. Id_module cannot be left blank.')); + returnError('error_update_plugin_module', __('Could not update plugin module. Id_module cannot be left blank.')); return; } @@ -3609,7 +3609,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3) $id_module_exists = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['nombre' => $module_name, 'id_agente' => $other['data'][0]]); if ($id_module_exists) { - returnError('error_update_plugin_module', __('Error updating plugin module. Id_module exists in the new agent.')); + returnError('error_update_plugin_module', __('Could not update plugin module. Id_module exists in the new agent.')); return; } } @@ -3617,7 +3617,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3) // Check if agent exists $check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]); if (!$check_id_agent) { - returnError('error_update_data_module', __('Error updating plugin module. Id_agent doesn\'t exist.')); + returnError('error_update_data_module', __('Could not update plugin module. Id_agent does not exist.')); return; } } @@ -3679,7 +3679,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3) $result_update = modules_update_agent_module($id_module, $values); if ($result_update < 0) { - returnError('error_update_plugin_module', 'Error updating plugin module.'); + returnError('error_update_plugin_module', __('Could not update plugin module.')); } else { returnData('string', ['type' => 'string', 'data' => __('Plugin module updated.')]); } @@ -3711,7 +3711,7 @@ function api_set_create_data_module($id, $thrash1, $other, $thrash3) } if ($other['data'][0] == '') { - returnError('error_create_data_module', __('Error in creation data module. Module_name cannot be left blank.')); + returnError('error_create_data_module', __('Could not create data module. Module_name cannot be left blank.')); return; } @@ -3803,7 +3803,7 @@ function api_set_create_data_module($id, $thrash1, $other, $thrash3) if (is_error($idModule)) { // TODO: Improve the error returning more info. - returnError('error_create_data_module', __('Error in creation data module.')); + returnError('error_create_data_module', __('Could not create data module.')); } else { returnData('string', ['type' => 'string', 'data' => $idModule]); } @@ -3835,7 +3835,7 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) io_safe_input_array($other); if ($other['data'][0] == '') { - returnError('error_create_data_module', __('Error in creation synthetic module. Module_name cannot be left blank.')); + returnError('error_create_data_module', __('Could not create synthetic module. Module_name cannot be left blank.')); return; } @@ -3858,13 +3858,13 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) if ($agent_by_alias) { foreach ($ids_agents as $id) { if (!$id['id_agente']) { - returnError('error_create_data_module', __('Error in creation synthetic module. Agent name doesn\'t exist.')); + returnError('error_create_data_module', __('Could not create synthetic module. Agent name does not exist.')); return; } } } else { if (!$idAgent) { - returnError('error_create_data_module', __('Error in creation synthetic module. Agent name doesn\'t exist.')); + returnError('error_create_data_module', __('Could not create synthetic module. Agent name does not exist.')); return; } } @@ -3894,7 +3894,7 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) if (is_error($idModule)) { // TODO: Improve the error returning more info. - returnError('error_create_data_module', __('Error in creation data module.')); + returnError('error_create_data_module', __('Could not create data module.')); } else { $synthetic_type = $other['data'][1]; unset($other['data'][0]); @@ -4037,7 +4037,7 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) returnError('error_synthetic_modules', 'Error Synthetic modules.'); } else { db_process_sql('UPDATE tagente SET total_count=total_count+1, notinit_count=notinit_count+1 WHERE id_agente='.(int) $idAgent); - returnData('string', ['type' => 'string', 'data' => __('Synthetic module created ID: '.$idModule)]); + returnData('string', ['type' => 'string', 'data' => __('Synthetic module created ID: %s', $idModule)]); } } } @@ -4047,7 +4047,7 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) if (is_error($idModule)) { // TODO: Improve the error returning more info - returnError('error_create_data_module', __('Error in creation data module.')); + returnError('error_create_data_module', __('Could not create data module.')); } else { $synthetic_type = $other['data'][1]; unset($other['data'][0]); @@ -4223,7 +4223,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3) } if ($id_module == '') { - returnError('error_update_data_module', __('Error updating data module. Id_module cannot be left blank.')); + returnError('error_update_data_module', __('Could not update data module. Id_module cannot be left blank.')); return; } @@ -4248,7 +4248,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3) $id_module_exists = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['nombre' => $module_name, 'id_agente' => $other['data'][0]]); if ($id_module_exists) { - returnError('error_update_data_module', __('Error updating data module. Id_module exists in the new agent.')); + returnError('error_update_data_module', __('Could not update data module. Id_module exists in the new agent.')); return; } } @@ -4256,7 +4256,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3) // Check if agent exists $check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]); if (!$check_id_agent) { - returnError('error_update_data_module', __('Error updating data module. Id_agent doesn\'t exist.')); + returnError('error_update_data_module', __('Could not update data module. Id_agent does not exist.')); return; } } @@ -4305,7 +4305,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3) $result_update = modules_update_agent_module($id_module, $values); if ($result_update < 0) { - returnError('error_update_data_module', 'Error updating data module.'); + returnError('error_update_data_module', 'Could not update data module.'); } else { returnData('string', ['type' => 'string', 'data' => __('Data module updated.')]); } @@ -4343,12 +4343,12 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3) } if ($other['data'][0] == '') { - returnError('error_create_snmp_module', __('Error in creation SNMP module. Module_name cannot be left blank.')); + returnError('error_create_snmp_module', __('Could not create SNMP module. Module_name cannot be left blank.')); return; } if ($other['data'][2] < 15 or $other['data'][2] > 18) { - returnError('error_create_snmp_module', __('Error in creation SNMP module. Invalid id_module_type for a SNMP module.')); + returnError('error_create_snmp_module', __('Could not create SNMP module. Invalid id_module_type for a SNMP module.')); return; } @@ -4379,17 +4379,17 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3) // SNMP version 3. if ($other['data'][14] == '3') { if ($other['data'][23] != 'AES' and $other['data'][23] != 'DES') { - returnError('error_create_snmp_module', __('Error in creation SNMP module. snmp3_priv_method doesn\'t exist. Set it to \'AES\' or \'DES\'. ')); + returnError('error_create_snmp_module', __('Could not create SNMP module. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. ')); return; } if ($other['data'][25] != 'authNoPriv' and $other['data'][25] != 'authPriv' and $other['data'][25] != 'noAuthNoPriv') { - returnError('error_create_snmp_module', __('Error in creation SNMP module. snmp3_sec_level doesn\'t exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ')); + returnError('error_create_snmp_module', __('Could not create SNMP module. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ')); return; } if ($other['data'][26] != 'MD5' and $other['data'][26] != 'SHA') { - returnError('error_create_snmp_module', __('Error in creation SNMP module. snmp3_auth_method doesn\'t exist. Set it to \'MD5\' or \'SHA\'. ')); + returnError('error_create_snmp_module', __('Could not create SNMP module. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. ')); return; } @@ -4493,7 +4493,7 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3) if (is_error($idModule)) { // TODO: Improve the error returning more info - returnError('error_create_snmp_module', __('Error in creation SNMP module.')); + returnError('error_create_snmp_module', __('Could not create SNMP module.')); } else { returnData('string', ['type' => 'string', 'data' => $idModule]); } @@ -4527,7 +4527,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) } if ($id_module == '') { - returnError('error_update_snmp_module', __('Error updating SNMP module. Id_module cannot be left blank.')); + returnError('error_update_snmp_module', __('Could not update SNMP module. Id_module cannot be left blank.')); return; } @@ -4552,7 +4552,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) $id_module_exists = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['nombre' => $module_name, 'id_agente' => $other['data'][0]]); if ($id_module_exists) { - returnError('error_update_snmp_module', __('Error updating SNMP module. Id_module exists in the new agent.')); + returnError('error_update_snmp_module', __('Could not update SNMP module. Id_module exists in the new agent.')); return; } } @@ -4560,7 +4560,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) // Check if agent exists $check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]); if (!$check_id_agent) { - returnError('error_update_data_module', __('Error updating snmp module. Id_agent doesn\'t exist.')); + returnError('error_update_data_module', __('Could not update snmp module. Id_agent does not exist.')); return; } } @@ -4570,7 +4570,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) if ($other['data'][22] != 'AES' and $other['data'][22] != 'DES') { returnError( 'error_create_snmp_module', - __('Error in creation SNMP module. snmp3_priv_method doesn\'t exist. Set it to \'AES\' or \'DES\'. ') + __('Error in creation SNMP module. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. ') ); return; } @@ -4581,7 +4581,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) ) { returnError( 'error_create_snmp_module', - __('Error in creation SNMP module. snmp3_sec_level doesn\'t exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ') + __('Error in creation SNMP module. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ') ); return; } @@ -4589,7 +4589,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) if ($other['data'][25] != 'MD5' and $other['data'][25] != 'SHA') { returnError( 'error_create_snmp_module', - __('Error in creation SNMP module. snmp3_auth_method doesn\'t exist. Set it to \'MD5\' or \'SHA\'. ') + __('Error in creation SNMP module. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. ') ); return; } @@ -4679,7 +4679,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) $result_update = modules_update_agent_module($id_module, $values); if ($result_update < 0) { - returnError('error_update_snmp_module', 'Error updating SNMP module.'); + returnError('error_update_snmp_module', 'Could not update SNMP module.'); } else { returnData('string', ['type' => 'string', 'data' => __('SNMP module updated.')]); } @@ -4717,17 +4717,17 @@ function api_set_new_network_component($id, $thrash1, $other, $thrash2) } if ($id == '') { - returnError('error_set_new_network_component', __('Error creating network component. Network component name cannot be left blank.')); + returnError('error_set_new_network_component', __('Could not create network component. Network component name cannot be left blank.')); return; } if ($other['data'][0] < 6 or $other['data'][0] > 18) { - returnError('error_set_new_network_component', __('Error creating network component. Incorrect value for Network component type field.')); + returnError('error_set_new_network_component', __('Could not create network component. Incorrect value for Network component type field.')); return; } if ($other['data'][17] == '') { - returnError('error_set_new_network_component', __('Error creating network component. Network component group cannot be left blank.')); + returnError('error_set_new_network_component', __('Could not create network component. Network component group cannot be left blank.')); return; } @@ -4765,14 +4765,14 @@ function api_set_new_network_component($id, $thrash1, $other, $thrash2) $name_check = db_get_value('name', 'tnetwork_component', 'name', $id); if ($name_check !== false) { - returnError('error_set_new_network_component', __('Error creating network component. This network component already exists.')); + returnError('error_set_new_network_component', __('Could not create network component. This network component already exist.')); return; } $id = network_components_create_network_component($id, $other['data'][0], $other['data'][17], $values); if (!$id) { - returnError('error_set_new_network_component', 'Error creating network component.'); + returnError('error_set_new_network_component', 'Could not create network component.'); } else { returnData('string', ['type' => 'string', 'data' => $id]); } @@ -4813,18 +4813,18 @@ function api_set_new_plugin_component($id, $thrash1, $other, $thrash2) if ($id == '') { returnError( 'error_set_new_plugin_component', - __('Error creating plugin component. Plugin component name cannot be left blank.') + __('Could not create plugin component. Plugin component name cannot be left blank.') ); return; } if ($other['data'][7] == '') { - returnError('error_set_new_plugin_component', __('Error creating plugin component. Incorrect value for Id plugin.')); + returnError('error_set_new_plugin_component', __('Could not create plugin component. Incorrect value for Id plugin.')); return; } if ($other['data'][21] == '') { - returnError('error_set_new_plugin_component', __('Error creating plugin component. Plugin component group cannot be left blank.')); + returnError('error_set_new_plugin_component', __('Could not create plugin component. Plugin component group cannot be left blank.')); return; } @@ -4866,14 +4866,14 @@ function api_set_new_plugin_component($id, $thrash1, $other, $thrash2) $name_check = db_get_value('name', 'tnetwork_component', 'name', $id); if ($name_check !== false) { - returnError('error_set_new_plugin_component', __('Error creating plugin component. This plugin component already exists.')); + returnError('error_set_new_plugin_component', __('Could not create plugin component. This plugin component already exist.')); return; } $id = network_components_create_network_component($id, $other['data'][0], $other['data'][21], $values); if (!$id) { - returnError('error_set_new_plugin_component', 'Error creating plugin component.'); + returnError('error_set_new_plugin_component', 'Could not create plugin component.'); } else { returnData('string', ['type' => 'string', 'data' => $id]); } @@ -4908,7 +4908,7 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) } if ($id == '') { - returnError('error_set_new_snmp_component', __('Error creating SNMP component. SNMP component name cannot be left blank.')); + returnError('error_set_new_snmp_component', __('Could not create SNMP component. SNMP component name cannot be left blank.')); return; } @@ -4918,12 +4918,12 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) } if ($other['data'][0] < 15 or $other['data'][0] > 17) { - returnError('error_set_new_snmp_component', __('Error creating SNMP component. Incorrect value for Snmp component type field.')); + returnError('error_set_new_snmp_component', __('Could not create SNMP component. Incorrect value for Snmp component type field.')); return; } if ($other['data'][25] == '') { - returnError('error_set_new_snmp_component', __('Error creating SNMP component. Snmp component group cannot be left blank.')); + returnError('error_set_new_snmp_component', __('Could not create SNMP component. Snmp component group cannot be left blank.')); return; } @@ -4934,7 +4934,7 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) // SNMP version 3 if ($other['data'][16] == '3') { if ($other['data'][22] != 'AES' and $other['data'][22] != 'DES') { - returnError('error_set_new_snmp_component', __('Error creating SNMP component. snmp3_priv_method doesn\'t exist. Set it to \'AES\' or \'DES\'. ')); + returnError('error_set_new_snmp_component', __('Could not create SNMP component. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. ')); return; } @@ -4944,7 +4944,7 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) ) { returnError( 'error_set_new_snmp_component', - __('Error creating SNMP component. snmp3_sec_level doesn\'t exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ') + __('Could not create SNMP component. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ') ); return; } @@ -4952,7 +4952,7 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) if ($other['data'][24] != 'MD5' and $other['data'][24] != 'SHA') { returnError( 'error_set_new_snmp_component', - __('Error creating SNMP component. snmp3_auth_method doesn\'t exist. Set it to \'MD5\' or \'SHA\'. ') + __('Could not create SNMP component. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. ') ); return; } @@ -5035,14 +5035,14 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) $name_check = db_get_value('name', 'tnetwork_component', 'name', $id); if ($name_check !== false) { - returnError('error_set_new_snmp_component', __('Error creating SNMP component. This SNMP component already exists.')); + returnError('error_set_new_snmp_component', __('Could not create SNMP component. This SNMP component already exist.')); return; } $id = network_components_create_network_component($id, $other['data'][0], $other['data'][26], $values); if (!$id) { - returnError('error_set_new_snmp_component', 'Error creating SNMP component.'); + returnError('error_set_new_snmp_component', 'Could not create SNMP component.'); } else { returnData('string', ['type' => 'string', 'data' => $id]); } @@ -5077,7 +5077,7 @@ function api_set_new_local_component($id, $thrash1, $other, $thrash2) if ($id == '') { returnError( 'error_set_new_local_component', - __('Error creating local component. Local component name cannot be left blank.') + __('Could not create local component. Local component name cannot be left blank.') ); return; } @@ -5090,7 +5090,7 @@ function api_set_new_local_component($id, $thrash1, $other, $thrash2) if ($other['data'][1] == '') { returnError( 'error_set_new_local_component', - __('Error creating local component. Local component group cannot be left blank.') + __('Could not create local component. Local component group cannot be left blank.') ); return; } @@ -5123,7 +5123,7 @@ function api_set_new_local_component($id, $thrash1, $other, $thrash2) if ($name_check === ENTERPRISE_NOT_HOOK) { returnError( 'error_set_new_local_component', - __('Error creating local component.') + __('Could not create local component.') ); return; } @@ -5131,7 +5131,7 @@ function api_set_new_local_component($id, $thrash1, $other, $thrash2) if ($name_check !== false) { returnError( 'error_set_new_local_component', - __('Error creating local component. This local component already exists.') + __('Could not create local component. This local component already exist.') ); return; } @@ -5147,7 +5147,7 @@ function api_set_new_local_component($id, $thrash1, $other, $thrash2) ); if (!$id) { - returnError('error_set_new_local_component', 'Error creating local component.'); + returnError('error_set_new_local_component', 'Could not create local component.'); } else { returnData('string', ['type' => 'string', 'data' => $id]); } @@ -5176,7 +5176,7 @@ function api_get_module_value_all_agents($id, $thrash1, $other, $thrash2) if ($id == '') { returnError( 'error_get_module_value_all_agents', - __('Error getting module value from all agents. Module name cannot be left blank.') + __('Failed to get module value from all agents. Module name cannot be left blank.') ); return; } @@ -5186,7 +5186,7 @@ function api_get_module_value_all_agents($id, $thrash1, $other, $thrash2) if ($id_module === false) { returnError( 'error_get_module_value_all_agents', - __('Error getting module value from all agents. Module name doesn\'t exist.') + __('Failed to get module value from all agents. Module name does not exist.') ); return; } @@ -5209,7 +5209,7 @@ function api_get_module_value_all_agents($id, $thrash1, $other, $thrash2) $module_values = db_get_all_rows_sql($sql); if (!$module_values) { - returnError('error_get_module_value_all_agents', 'Error getting module values from all agents.'); + returnError('error_get_module_value_all_agents', 'Could not get module values from all agents.'); } else { $data = [ 'type' => 'array', @@ -5249,7 +5249,7 @@ function api_set_create_alert_template($name, $thrash1, $other, $thrash3) if ($name == '') { returnError( 'error_create_alert_template', - __('Error creating alert template. Template name cannot be left blank.') + __('Could not create alert template. Template name cannot be left blank.') ); return; } @@ -5321,7 +5321,7 @@ function api_set_create_alert_template($name, $thrash1, $other, $thrash3) if (is_error($id_template)) { // TODO: Improve the error returning more info - returnError('error_create_alert_template', __('Error creating alert template.')); + returnError('error_create_alert_template', __('Could not create alert template.')); } else { returnData('string', ['type' => 'string', 'data' => $id_template]); } @@ -5361,7 +5361,7 @@ function api_set_update_alert_template($id_template, $thrash1, $other, $thrash3) if ($id_template == '') { returnError( 'error_update_alert_template', - __('Error updating alert template. Id_template cannot be left blank.') + __('Could not update alert template. Id_template cannot be left blank.') ); return; } @@ -5371,7 +5371,7 @@ function api_set_update_alert_template($id_template, $thrash1, $other, $thrash3) if (!$result_template) { returnError( 'error_update_alert_template', - __('Error updating alert template. Id_template doesn\'t exist.') + __('Could not update alert template. Id_template does not exist.') ); return; } @@ -5422,14 +5422,14 @@ function api_set_update_alert_template($id_template, $thrash1, $other, $thrash3) // TODO: Improve the error returning more info returnError( 'error_create_alert_template', - __('Error updating alert template.') + __('Could not update alert template.') ); } else { returnData( 'string', [ 'type' => 'string', - 'data' => __('Correct updating of alert template'), + 'data' => __('Successful update of the alert template'), ] ); } @@ -5458,7 +5458,7 @@ function api_set_delete_alert_template($id_template, $thrash1, $other, $thrash3) if ($id_template == '') { returnError( 'error_delete_alert_template', - __('Error deleting alert template. Id_template cannot be left blank.') + __('Could not delete alert template. Id_template cannot be left blank.') ); return; } @@ -5469,14 +5469,14 @@ function api_set_delete_alert_template($id_template, $thrash1, $other, $thrash3) // TODO: Improve the error returning more info returnError( 'error_create_alert_template', - __('Error deleting alert template.') + __('Could not delete alert template.') ); } else { returnData( 'string', [ 'type' => 'string', - 'data' => __('Correct deleting of alert template.'), + 'data' => __('Successful delete of alert template.'), ] ); } @@ -5527,7 +5527,7 @@ function api_get_all_alert_templates($thrash1, $thrash2, $other, $thrash3) if (!$template) { returnError( 'error_get_all_alert_templates', - __('Error getting all alert templates.') + __('Could not get all alert templates.') ); } else { returnData('csv', $data, $separator); @@ -5572,7 +5572,7 @@ function api_get_all_alert_commands($thrash1, $thrash2, $other, $thrash3) if (!$commands) { returnError( 'error_get_all_alert_commands', - __('Error getting all alert commands.') + __('Could not get all alert commands.') ); } else { returnData('csv', $data, $separator); @@ -5607,7 +5607,7 @@ function api_get_alert_template($id_template, $thrash1, $other, $thrash3) if (!$result_template) { returnError( 'error_get_alert_template', - __('Error getting alert template. Id_template doesn\'t exist.') + __('Could not get alert template. Id_template does not exist.') ); return; } @@ -5635,7 +5635,7 @@ function api_get_alert_template($id_template, $thrash1, $other, $thrash3) if (!$template) { returnError( 'error_get_alert_template', - __('Error getting alert template.') + __('Could not get alert template.') ); } else { returnData('csv', $data, ';'); @@ -5699,7 +5699,7 @@ function api_get_alert_actions($thrash1, $thrash2, $other, $returnType) if (!$actions) { returnError( 'error_get_alert_actions', - __('Error getting alert actions.') + __('Could not get alert actions.') ); } else { returnData($returnType, $data, $separator); @@ -5749,7 +5749,7 @@ function api_get_module_groups($thrash1, $thrash2, $other, $thrash3) } if (!$module_groups) { - returnError('error_get_module_groups', __('Error getting module groups.')); + returnError('error_get_module_groups', __('Could not get module groups.')); } else { returnData('csv', $data, $separator); } @@ -5813,7 +5813,7 @@ function api_get_plugins($thrash1, $thrash2, $other, $thrash3) } if (!$plugins) { - returnError('error_get_plugins', __('Error getting plugins.')); + returnError('error_get_plugins', __('Could not get plugins.')); } else { returnData('csv', $data, $separator); } @@ -5861,13 +5861,13 @@ function api_set_create_network_module_from_component($agent_name, $component_na if ($agent_by_alias) { foreach ($ids_agents as $id) { if (!$id['id_agente']) { - returnError('error_network_module_from_component', __('Error creating module from network component. Agent doesn\'t exist.')); + returnError('error_network_module_from_component', __('Could not create module from network component. Agent does not exist.')); return; } } } else { if (!$agent_id) { - returnError('error_network_module_from_component', __('Error creating module from network component. Agent doesn\'t exist.')); + returnError('error_network_module_from_component', __('Could not create module from network component. Agent does not exist.')); return; } } @@ -5875,7 +5875,7 @@ function api_set_create_network_module_from_component($agent_name, $component_na $component = db_get_row('tnetwork_component', 'name', $component_name); if (!$component) { - returnError('error_network_module_from_component', __('Error creating module from network component. Network component doesn\'t exist.')); + returnError('error_network_module_from_component', __('Could not create module from network component. Network component does not exist.')); return; } @@ -5907,7 +5907,7 @@ function api_set_create_network_module_from_component($agent_name, $component_na $module_id = modules_create_agent_module($agent_id, $component_name, $component, true); if (!$module_id) { - returnError('error_network_module_from_component', __('Error creating module from network component. Error creating module.')); + returnError('error_network_module_from_component', __('Could not create module from network component.')); return; } @@ -5938,7 +5938,7 @@ function api_set_create_module_template($id, $thrash1, $other, $thrash3) if ($id == '') { returnError( 'error_module_to_template', - __('Error assigning module to template. Id_template cannot be left blank.') + __('Could not assign module to template. Id_template cannot be left blank.') ); return; } @@ -5946,7 +5946,7 @@ function api_set_create_module_template($id, $thrash1, $other, $thrash3) if ($other['data'][0] == '') { returnError( 'error_module_to_template', - __('Error assigning module to template. Id_module cannot be left blank.') + __('Could not assign module to template. Id_module cannot be left blank.') ); return; } @@ -5954,7 +5954,7 @@ function api_set_create_module_template($id, $thrash1, $other, $thrash3) if ($other['data'][1] == '') { returnError( 'error_module_to_template', - __('Error assigning module to template. Id_agent cannot be left blank.') + __('Could not assign module to template. Id_agent cannot be left blank.') ); return; } @@ -5971,7 +5971,7 @@ function api_set_create_module_template($id, $thrash1, $other, $thrash3) if (!$result_template) { returnError( 'error_module_to_template', - __('Error assigning module to template. Id_template doensn\'t exists.') + __('Could not assign module to template. Id_template does not exist.') ); return; } @@ -5979,14 +5979,14 @@ function api_set_create_module_template($id, $thrash1, $other, $thrash3) $result_agent = agents_get_name($id_agent); if (!$result_agent) { - returnError('error_module_to_template', __('Error assigning module to template. Id_agent doesn\'t exist.')); + returnError('error_module_to_template', __('Could not assign module to template. Id_agent does not exist.')); return; } $result_module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', (int) $id_module); if (!$result_module) { - returnError('error_module_to_template', __('Error assigning module to template. Id_module doesn\'t exist.')); + returnError('error_module_to_template', __('Could not assign module to template. Id_module does not exist.')); return; } @@ -5994,7 +5994,7 @@ function api_set_create_module_template($id, $thrash1, $other, $thrash3) if (is_error($id_template_module)) { // TODO: Improve the error returning more info - returnError('error_module_to_template', __('Error assigning module to template.')); + returnError('error_module_to_template', __('Could not assign module to template.')); } else { returnData('string', ['type' => 'string', 'data' => $id_template_module]); } @@ -6028,14 +6028,14 @@ function api_set_delete_module_template($id, $thrash1, $other, $thrash3) } if ($id == '') { - returnError('error_delete_module_template', __('Error deleting module template. Id_module_template cannot be left blank.')); + returnError('error_delete_module_template', __('Could not delete module template. Id_module_template cannot be left blank.')); return; } $result_module_template = alerts_get_alert_agent_module($id); if (!$result_module_template) { - returnError('error_delete_module_template', __('Error deleting module template. Id_module_template doesn\'t exist.')); + returnError('error_delete_module_template', __('Could not delete module template. Id_module_template does not exist.')); return; } @@ -6043,7 +6043,7 @@ function api_set_delete_module_template($id, $thrash1, $other, $thrash3) if ($result == 0) { // TODO: Improve the error returning more info - returnError('error_delete_module_template', __('Error deleting module template.')); + returnError('error_delete_module_template', __('Could not delete module template.')); } else { returnData('string', ['type' => 'string', 'data' => __('Correct deleting of module template.')]); } @@ -6104,7 +6104,7 @@ function api_set_delete_module_template_by_names($id, $id2, $other, $trash1) $row = db_get_row_filter('talert_templates', ['name' => $id2]); if ($row === false) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } @@ -6138,7 +6138,7 @@ function api_set_delete_module_template_by_names($id, $id2, $other, $trash1) $idAgentModule = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['id_agente' => $idAgent, 'nombre' => $other['data'][0]]); if ($idAgentModule === false) { - returnError('error_parameter', 'Error in the parameters1.'); + returnError('error_parameter', 'Parameter error.'); return; } @@ -6151,9 +6151,9 @@ function api_set_delete_module_template_by_names($id, $id2, $other, $trash1) if ($result == 0) { // TODO: Improve the error returning more info - returnError('error_delete_module_template_by_name', __('Error deleting module template.')); + returnError('error_delete_module_template_by_name', __('Could not delete module template.')); } else { - returnData('string', ['type' => 'string', 'data' => __('Correct deleting of module template.')]); + returnData('string', ['type' => 'string', 'data' => __('Successful delete of module template.')]); } } } @@ -6226,9 +6226,9 @@ function api_set_validate_all_alerts($id, $thrash1, $other, $thrash3) if ($total_alerts > $count_results) { $errors = ($total_alerts - $count_results); - returnError('error_validate_all_alerts', __('Error validate all alerts. Failed '.$errors.'.')); + returnError('error_validate_all_alerts', __('Failed to validate all alerts. Failed '.$errors.'.')); } else { - returnData('string', ['type' => 'string', 'data' => __('Correct validating of all alerts (total %d).', $count_results)]); + returnData('string', ['type' => 'string', 'data' => __('Correct validation of all alerts (total %d).', $count_results)]); } } @@ -6263,7 +6263,7 @@ function api_set_validate_all_policy_alerts($id, $thrash1, $other, $thrash3) $policies = enterprise_hook('policies_get_policies', [false, false, false]); if ($duplicated === ENTERPRISE_NOT_HOOK) { - returnError('error_validate_all_policy_alerts', __('Error validating all alert policies.')); + returnError('error_validate_all_policy_alerts', __('Failed to validate all alert policies.')); return; } @@ -6320,9 +6320,9 @@ function api_set_validate_all_policy_alerts($id, $thrash1, $other, $thrash3) // Check results if ($total_alerts > $count_results) { $errors = ($total_alerts - $count_results); - returnError('error_validate_all_alerts', __('Error validate all policy alerts. Failed '.$errors.'.')); + returnError('error_validate_all_alerts', __('Failed to validate all policy alerts. Failed '.$errors.'.')); } else { - returnData('string', ['type' => 'string', 'data' => __('Correct validating of all policy alerts.')]); + returnData('string', ['type' => 'string', 'data' => __('Correct validation of all policy alerts.')]); } } @@ -6354,7 +6354,7 @@ function api_set_stop_downtime($id, $thrash1, $other, $thrash3) } if ($id == '') { - returnError('error_stop_downtime', __('Error stopping downtime. Id_downtime cannot be left blank.')); + returnError('error_stop_downtime', __('Failed to stop downtime. Id_downtime cannot be left blank.')); return; } @@ -6367,7 +6367,7 @@ function api_set_stop_downtime($id, $thrash1, $other, $thrash3) if ($result_update == 0) { returnError('error_stop_downtime', __('No action has been taken.')); } else if ($result_update < 0) { - returnError('error_stop_downtime', __('Error stopping downtime.')); + returnError('error_stop_downtime', __('Could not stop downtime.')); } else { returnData('string', ['type' => 'string', 'data' => __('Downtime stopped.')]); } @@ -6414,7 +6414,7 @@ function api_set_add_tag_module($id, $id2, $thrash1, $thrash2) } if (empty($exists)) { - returnError('error_set_tag_module', 'Error set tag module.'); + returnError('error_set_tag_module', 'Failed to set tag module.'); } else { returnData( 'string', @@ -6496,7 +6496,7 @@ function api_set_tag($id, $thrash1, $other, $thrash3) $id_tag = tags_create_tag($values); if (empty($id_tag)) { - returnError('error_set_tag', __('Error set tag.')); + returnError('error_set_tag', __('Failed to set tag.')); } else { returnData( 'string', @@ -6558,7 +6558,7 @@ function api_get_all_planned_downtimes($thrash1, $thrash2, $other, $returnType=' $returned = all_planned_downtimes($values); if ($returned === false) { - returnError('error_get_all_planned_downtimes', __('No planned downtime retrieved')); + returnError('error_get_all_planned_downtimes', __('Planned downtime was not retrieved')); return; } @@ -6893,7 +6893,7 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3) } if ($id == '') { - returnError('error_add_data_module_policy', __('Error adding data module to policy. Id_policy cannot be left blank.')); + returnError('error_add_data_module_policy', __('Could not add data module to policy. Id_policy cannot be left blank.')); return; } @@ -6903,7 +6903,7 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3) } if ($other['data'][0] == '') { - returnError('error_add_data_module_policy', __('Error adding data module to policy. Module_name cannot be left blank.')); + returnError('error_add_data_module_policy', __('Could not add data module to policy. Module_name cannot be left blank.')); return; } @@ -6911,7 +6911,7 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3) $name_module_policy = enterprise_hook('policies_get_modules', [$id, ['name' => $other['data'][0]], 'name']); if ($name_module_policy === ENTERPRISE_NOT_HOOK) { - returnError('error_add_data_module_policy', __('Error adding data module to policy.')); + returnError('error_add_data_module_policy', __('Could not add data module to policy.')); return; } @@ -6949,7 +6949,7 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3) if ($name_module_policy[0]['name'] == $other['data'][0]) { returnError( 'error_add_data_module_policy', - __('Error adding data module to policy. The module is already in the policy.') + __('Could not add data module to policy. The module is already in the policy.') ); return; } @@ -6970,7 +6970,7 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3) // returnData('string', array('type' => 'string', 'data' => __('Data module added to policy. Is necessary to apply the policy in order to changes take effect.'))); returnData('string', ['type' => 'string', 'data' => $success]); } else { - returnError('error_add_data_module_policy', 'Error adding data module to policy.'); + returnError('error_add_data_module_policy', 'Could not add data module to policy.'); } } @@ -7001,7 +7001,7 @@ function api_set_update_data_module_policy($id, $thrash1, $other, $thrash3) } if ($id == '') { - returnError('error_update_data_module_policy', __('Error updating data module in policy. Id_policy cannot be left blank.')); + returnError('error_update_data_module_policy', __('Could not update data module in policy. Id_policy cannot be left blank.')); return; } @@ -7010,7 +7010,7 @@ function api_set_update_data_module_policy($id, $thrash1, $other, $thrash3) } if ($other['data'][0] == '') { - returnError('error_update_data_module_policy', __('Error updating data module in policy. Id_policy_module cannot be left blank.')); + returnError('error_update_data_module_policy', __('Could not update data module in policy. Id_policy_module cannot be left blank.')); return; } @@ -7018,14 +7018,14 @@ function api_set_update_data_module_policy($id, $thrash1, $other, $thrash3) $module_policy = enterprise_hook('policies_get_modules', [$id, ['id' => $other['data'][0]], 'id_module']); if ($module_policy === false) { - returnError('error_update_data_module_policy', __('Error updating data module in policy. Module doesn\'t exist.')); + returnError('error_update_data_module_policy', __('Could not update data module in policy. Module does not exist.')); return; } if ($module_policy[0]['id_module'] != 1) { returnError( 'error_update_data_module_policy', - __('Error updating data module in policy. Module type is not network type.') + __('Could not update data module in policy. Module type is not network type.') ); return; } @@ -7069,7 +7069,7 @@ function api_set_update_data_module_policy($id, $thrash1, $other, $thrash3) ); if ($result_update < 0) { - returnError('error_update_data_module_policy', 'Error updating policy module.'); + returnError('error_update_data_module_policy', 'Could not update policy module.'); } else { returnData( 'string', @@ -7110,7 +7110,7 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) if ($id == '') { returnError( 'error_network_data_module_policy', - __('Error adding network module to policy. Id_policy cannot be left blank.') + __('Could not add network module to policy. Id_policy cannot be left blank.') ); return; } @@ -7123,7 +7123,7 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) if ($other['data'][0] == '') { returnError( 'error_network_data_module_policy', - __('Error adding network module to policy. Module_name cannot be left blank.') + __('Could not add network module to policy. Module_name cannot be left blank.') ); return; } @@ -7131,7 +7131,7 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) if ($other['data'][1] < 6 or $other['data'][1] > 18) { returnError( 'error_network_data_module_policy', - __('Error adding network module to policy. Id_module_type is not correct for network modules.') + __('Could not add network module to policy. Id_module_type is not correct for network modules.') ); return; } @@ -7149,7 +7149,7 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) if ($name_module_policy === ENTERPRISE_NOT_HOOK) { returnError( 'error_network_data_module_policy', - __('Error adding network module to policy.') + __('Could not add network module to policy.') ); return; } @@ -7189,7 +7189,7 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) if ($name_module_policy !== false) { if ($name_module_policy[0]['name'] == $other['data'][0]) { - returnError('error_network_data_module_policy', __('Error adding network module to policy. The module is already in the policy.')); + returnError('error_network_data_module_policy', __('Could not add network module to policy. The module is already in the policy.')); return; } } @@ -7199,7 +7199,7 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) if ($success) { returnData('string', ['type' => 'string', 'data' => $success]); } else { - returnError('error_add_network_module_policy', 'Error adding network module to policy.'); + returnError('error_add_network_module_policy', 'Could not add network module to policy.'); } } @@ -7231,7 +7231,7 @@ function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3) if ($id == '') { returnError( 'error_update_network_module_policy', - __('Error updating network module in policy. Id_policy cannot be left blank.') + __('Could not update network module in policy. Id_policy cannot be left blank.') ); return; } @@ -7239,18 +7239,18 @@ function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3) if ($other['data'][0] == '') { returnError( 'error_update_network_module_policy', - __('Error updating network module in policy. Id_policy_module cannot be left blank.') + __('Could not update network module in policy. Id_policy_module cannot be left blank.') ); return; } - // Check if the module exists. + // Check if the module exist. $module_policy = enterprise_hook('policies_get_modules', [$id, ['id' => $other['data'][0]], 'id_module']); if ($module_policy === false) { returnError( 'error_update_network_module_policy', - __('Error updating network module in policy. Module doesn\'t exist.') + __('Could not update network module in policy. Module does not exist.') ); return; } @@ -7258,7 +7258,7 @@ function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3) if ($module_policy[0]['id_module'] != 2) { returnError( 'error_update_network_module_policy', - __('Error updating network module in policy. Module type is not network type.') + __('Could not update network module in policy. Module type is not network type.') ); return; } @@ -7300,7 +7300,7 @@ function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3) $result_update = enterprise_hook('policies_update_module', [$other['data'][0], $values, false]); if ($result_update < 0) { - returnError('error_update_network_module_policy', 'Error updating policy module.'); + returnError('error_update_network_module_policy', 'Could not update policy module.'); } else { returnData('string', ['type' => 'string', 'data' => __('Network policy module updated.')]); } @@ -7332,7 +7332,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) } if ($id == '') { - returnError('error_add_plugin_module_policy', __('Error adding plugin module to policy. Id_policy cannot be left blank.')); + returnError('error_add_plugin_module_policy', __('Could not add plugin module to policy. Id_policy cannot be left blank.')); return; } @@ -7342,12 +7342,12 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) } if ($other['data'][0] == '') { - returnError('error_add_plugin_module_policy', __('Error adding plugin module to policy. Module_name cannot be left blank.')); + returnError('error_add_plugin_module_policy', __('Could not add plugin module to policy. Module_name cannot be left blank.')); return; } if ($other['data'][22] == '') { - returnError('error_add_plugin_module_policy', __('Error adding plugin module to policy. Id_plugin cannot be left blank.')); + returnError('error_add_plugin_module_policy', __('Could not add plugin module to policy. Id_plugin cannot be left blank.')); return; } @@ -7355,7 +7355,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) $name_module_policy = enterprise_hook('policies_get_modules', [$id, ['name' => $other['data'][0]], 'name']); if ($name_module_policy === ENTERPRISE_NOT_HOOK) { - returnError('error_add_plugin_module_policy', __('Error adding plugin module to policy.')); + returnError('error_add_plugin_module_policy', __('Could not add plugin module to policy.')); return; } @@ -7399,7 +7399,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) if ($name_module_policy !== false) { if ($name_module_policy[0]['name'] == $other['data'][0]) { - returnError('error_add_plugin_module_policy', __('Error adding plugin module to policy. The module is already in the policy.')); + returnError('error_add_plugin_module_policy', __('Could not add plugin module to policy. The module is already in the policy.')); return; } } @@ -7409,7 +7409,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) if ($success) { returnData('string', ['type' => 'string', 'data' => $success]); } else { - returnError('error_add_plugin_module_policy', 'Error adding plugin module to policy.'); + returnError('error_add_plugin_module_policy', 'Could not add plugin module to policy.'); } } @@ -7442,7 +7442,7 @@ function api_set_update_plugin_module_policy($id, $thrash1, $other, $thrash3) if ($id == '') { returnError( 'error_update_plugin_module_policy', - __('Error updating plugin module in policy. Id_policy cannot be left blank.') + __('Could not update plugin module in policy. Id_policy cannot be left blank.') ); return; } @@ -7450,18 +7450,18 @@ function api_set_update_plugin_module_policy($id, $thrash1, $other, $thrash3) if ($other['data'][0] == '') { returnError( 'error_update_plugin_module_policy', - __('Error updating plugin module in policy. Id_policy_module cannot be left blank.') + __('Could not update plugin module in policy. Id_policy_module cannot be left blank.') ); return; } - // Check if the module exists. + // Check if the module exist. $module_policy = enterprise_hook('policies_get_modules', [$id, ['id' => $other['data'][0]], 'id_module']); if ($module_policy === false) { returnError( 'error_updating_plugin_module_policy', - __('Error updating plugin module in policy. Module doesn\'t exist.') + __('Could not update plugin module in policy. Module does not exist.') ); return; } @@ -7469,7 +7469,7 @@ function api_set_update_plugin_module_policy($id, $thrash1, $other, $thrash3) if ($module_policy[0]['id_module'] != 4) { returnError( 'error_updating_plugin_module_policy', - __('Error updating plugin module in policy. Module type is not network type.') + __('Could not update plugin module in policy. Module type is not network type.') ); return; } @@ -7527,7 +7527,7 @@ function api_set_update_plugin_module_policy($id, $thrash1, $other, $thrash3) ); if ($result_update < 0) { - returnError('error_update_plugin_module_policy', 'Error updating policy module.'); + returnError('error_update_plugin_module_policy', 'Could not update policy module.'); } else { returnData('string', ['type' => 'string', 'data' => __('Plugin policy module updated.')]); } @@ -7615,7 +7615,7 @@ function api_get_module_from_conf($id_agent, $module_name, $thrash2, $thrash3) if ($result !== ENTERPRISE_NOT_HOOK && !empty($result)) { returnData('string', ['type' => 'string', 'data' => $result]); } else { - returnError('error_adding_module_conf', __('Remote config of module %s not available', $module_name)); + returnError('error_adding_module_conf', __('Remote config of module %s is not available', $module_name)); } } @@ -7732,7 +7732,7 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) } if ($id == '') { - returnError('error_add_snmp_module_policy', __('Error adding SNMP module to policy. Id_policy cannot be left blank.')); + returnError('error_add_snmp_module_policy', __('Could not add SNMP module to policy. Id_policy cannot be left blank.')); return; } @@ -7742,7 +7742,7 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) } if ($other['data'][0] == '') { - returnError('error_add_snmp_module_policy', __('Error adding SNMP module to policy. Module_name cannot be left blank.')); + returnError('error_add_snmp_module_policy', __('Could not add SNMP module to policy. Module_name cannot be left blank.')); return; } @@ -7750,12 +7750,12 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) $name_module_policy = enterprise_hook('policies_get_modules', [$id, ['name' => $other['data'][0]], 'name']); if ($name_module_policy === ENTERPRISE_NOT_HOOK) { - returnError('error_add_snmp_module_policy', __('Error adding SNMP module to policy.')); + returnError('error_add_snmp_module_policy', __('Could not add SNMP module to policy.')); return; } if ($other['data'][2] < 15 or $other['data'][2] > 18) { - returnError('error_add_snmp_module_policy', __('Error adding SNMP module to policy. Id_module_type is not correct for SNMP modules.')); + returnError('error_add_snmp_module_policy', __('Could not add SNMP module to policy. Id_module_type is not correct for SNMP modules.')); return; } @@ -7766,17 +7766,17 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) // SNMP version 3 if ($other['data'][13] == '3') { if ($other['data'][22] != 'AES' and $other['data'][22] != 'DES') { - returnError('error_add_snmp_module_policy', __('Error in creation SNMP module. snmp3_priv_method doesn\'t exist. Set it to \'AES\' or \'DES\'. ')); + returnError('error_add_snmp_module_policy', __('Error in creation SNMP module. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. ')); return; } if ($other['data'][24] != 'authNoPriv' and $other['data'][24] != 'authPriv' and $other['data'][24] != 'noAuthNoPriv') { - returnError('error_add_snmp_module_policy', __('Error in creation SNMP module. snmp3_sec_level doesn\'t exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ')); + returnError('error_add_snmp_module_policy', __('Error in creation SNMP module. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ')); return; } if ($other['data'][25] != 'MD5' and $other['data'][25] != 'SHA') { - returnError('error_add_snmp_module_policy', __('Error in creation SNMP module. snmp3_auth_method doesn\'t exist. Set it to \'MD5\' or \'SHA\'. ')); + returnError('error_add_snmp_module_policy', __('Error in creation SNMP module. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. ')); return; } @@ -7849,7 +7849,7 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) if ($name_module_policy !== false) { if ($name_module_policy[0]['name'] == $other['data'][0]) { - returnError('error_add_snmp_module_policy', __('Error adding SNMP module to policy. The module is already in the policy.')); + returnError('error_add_snmp_module_policy', __('Could not add SNMP module to policy. The module is already in the policy.')); return; } } @@ -7859,7 +7859,7 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) if ($success) { returnData('string', ['type' => 'string', 'data' => $success]); } else { - returnError('error_add_snmp_module_policy', 'Error adding SNMP module to policy.'); + returnError('error_add_snmp_module_policy', 'Could not add SNMP module to policy.'); } } @@ -7891,12 +7891,12 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) } if ($id == '') { - returnError('error_update_snmp_module_policy', __('Error updating SNMP module in policy. Id_policy cannot be left blank.')); + returnError('error_update_snmp_module_policy', __('Could not update SNMP module in policy. Id_policy cannot be left blank.')); return; } if ($other['data'][0] == '') { - returnError('error_update_snmp_module_policy', __('Error updating SNMP module in policy. Id_policy_module cannot be left blank.')); + returnError('error_update_snmp_module_policy', __('Could not update SNMP module in policy. Id_policy_module cannot be left blank.')); return; } @@ -7904,12 +7904,12 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) $module_policy = enterprise_hook('policies_get_modules', [$id, ['id' => $other['data'][0]], 'id_module']); if ($module_policy === false) { - returnError('error_update_snmp_module_policy', __('Error updating SNMP module in policy. Module doesn\'t exist.')); + returnError('error_update_snmp_module_policy', __('Could not update SNMP module in policy. Module does not exist.')); return; } if ($module_policy[0]['id_module'] != 2) { - returnError('error_update_snmp_module_policy', __('Error updating SNMP module in policy. Module type is not SNMP type.')); + returnError('error_update_snmp_module_policy', __('Could not update SNMP module in policy. Module type is not SNMP type.')); return; } @@ -7918,7 +7918,7 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) if ($other['data'][21] != 'AES' and $other['data'][21] != 'DES') { returnError( 'error_update_snmp_module_policy', - __('Error updating SNMP module. snmp3_priv_method doesn\'t exist. Set it to \'AES\' or \'DES\'. ') + __('Could not update SNMP module. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. ') ); return; @@ -7930,7 +7930,7 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) ) { returnError( 'error_update_snmp_module_policy', - __('Error updating SNMP module. snmp3_sec_level doesn\'t exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ') + __('Could not update SNMP module. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ') ); return; @@ -7939,7 +7939,7 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) if ($other['data'][24] != 'MD5' and $other['data'][24] != 'SHA') { returnError( 'error_update_snmp_module_policy', - __('Error updating SNMP module. snmp3_auth_method doesn\'t exist. Set it to \'MD5\' or \'SHA\'. ') + __('Could not update SNMP module. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. ') ); return; @@ -8019,7 +8019,7 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) ); if ($result_update < 0) { - returnError('error_update_snmp_module_policy', 'Error updating policy module.'); + returnError('error_update_snmp_module_policy', 'Could not update policy module.'); } else { returnData( 'string', @@ -8046,18 +8046,18 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) function api_set_remove_agent_from_policy_by_id($id, $thrash1, $other, $thrash2) { if ($id == '' || !$id) { - returnError('error_parameter', __('Error deleting agent from policy. Policy cannot be left blank.')); + returnError('error_parameter', __('Could not delete agent from policy. Policy cannot be left blank.')); return; } if ($other['data'][0] == '' || !$other['data'][0]) { - returnError('error_parameter', __('Error deleting agent from policy. Agent cannot be left blank.')); + returnError('error_parameter', __('Could not delete agent from policy. Agent cannot be left blank.')); return; } // Require node id if is metaconsole if (is_metaconsole() && $other['data'][1] == '') { - returnError('error_add_agent_policy', __('Error deleting agent from policy. Node ID cannot be left blank.')); + returnError('error_add_agent_policy', __('Could not delete agent from policy. Node ID cannot be left blank.')); return; } @@ -8079,12 +8079,12 @@ function api_set_remove_agent_from_policy_by_id($id, $thrash1, $other, $thrash2) function api_set_remove_agent_from_policy_by_name($id, $thrash1, $other, $thrash2) { if ($id == '' || !$id) { - returnError('error_parameter', __('Error deleting agent from policy. Policy cannot be left blank.')); + returnError('error_parameter', __('Could not delete agent from policy. Policy cannot be left blank.')); return; } if ($other['data'][0] == '' || !$other['data'][0]) { - returnError('error_add_agent_policy', __('Error adding agent to policy. Agent name cannot be left blank.')); + returnError('error_add_agent_policy', __('Could not add agent to policy. Agent name cannot be left blank.')); return; } @@ -8129,7 +8129,7 @@ function api_set_create_group($id, $thrash1, $other, $thrash3) if ($id == '') { returnError( 'error_create_group', - __('Error in group creation. Group_name cannot be left blank.') + __('Could not create a group. Group_name cannot be left blank.') ); return; } @@ -8137,7 +8137,7 @@ function api_set_create_group($id, $thrash1, $other, $thrash3) if ($other['data'][0] == '') { returnError( 'error_create_group', - __('Error in group creation. Icon_name cannot be left blank.') + __('Could not create a group. Icon_name cannot be left blank.') ); return; } @@ -8150,7 +8150,7 @@ function api_set_create_group($id, $thrash1, $other, $thrash3) if ($group == false) { returnError( 'error_create_group', - __('Error in group creation. Id_parent_group doesn\'t exist.') + __('Could not create a group. Id_parent_group does not exist.') ); return; } @@ -8179,7 +8179,7 @@ function api_set_create_group($id, $thrash1, $other, $thrash3) if (is_error($id_group)) { // TODO: Improve the error returning more info - returnError('error_create_group', __('Error in group creation.')); + returnError('error_create_group', __('Could not create a group.')); } else { if (defined('METACONSOLE')) { $servers = db_get_all_rows_sql( @@ -8236,7 +8236,7 @@ function api_set_update_group($id_group, $thrash2, $other, $thrash3) } if (db_get_value('id_grupo', 'tgrupo', 'id_grupo', $id_group) === false) { - returnError('error_set_update_group', __('There is not any group with the id provided')); + returnError('error_set_update_group', __('There is no group with the ID provided')); return; } @@ -8304,7 +8304,7 @@ function api_set_delete_group($id_group, $thrash2, $other, $thrash3) $group = db_get_row_filter('tgrupo', ['id_grupo' => $id_group]); if (!$group) { - returnError('error_delete', 'Error in delete operation. Id does not exist.'); + returnError('error_delete', 'Could not delete group. ID does not exist.'); return; } @@ -8317,7 +8317,7 @@ function api_set_delete_group($id_group, $thrash2, $other, $thrash3) if ($usedGroup['return']) { returnError( 'error_delete', - 'Error in delete operation. The group is not empty (used in '.implode(', ', $usedGroup['tables']).').' + 'The delete action could not be performed. The group is not empty (used in '.implode(', ', $usedGroup['tables']).').' ); return; } @@ -8328,9 +8328,9 @@ function api_set_delete_group($id_group, $thrash2, $other, $thrash3) $result = db_process_sql_delete('tgrupo', ['id_grupo' => $id_group]); if (!$result) { - returnError('error_delete', 'Error in delete operation.'); + returnError('error_delete', 'The delete action could not be performed.'); } else { - returnData('string', ['type' => 'string', 'data' => __('Correct Delete')]); + returnData('string', ['type' => 'string', 'data' => __('Successful deletion')]); } } @@ -8366,18 +8366,18 @@ function api_set_create_netflow_filter($thrash1, $thrash2, $other, $thrash3) } if ($other['data'][0] == '') { - returnError('error_create_netflow_filter', __('Error in netflow filter creation. Filter name cannot be left blank.')); + returnError('error_create_netflow_filter', __('Could not create netflow filter. Filter name cannot be left blank.')); return; } if ($other['data'][1] == '') { - returnError('error_create_netflow_filter', __('Error in netflow filter creation. Group id cannot be left blank.')); + returnError('error_create_netflow_filter', __('Could not create netflow filter. Group id cannot be left blank.')); return; } else { $group = groups_get_group_by_id($other['data'][1]); if ($group == false) { - returnError('error_create_group', __('Error in netflow filter creation. Id_group doesn\'t exist.')); + returnError('error_create_group', __('Could not create netflow filter. Id_group does not exist.')); return; } @@ -8388,17 +8388,17 @@ function api_set_create_netflow_filter($thrash1, $thrash2, $other, $thrash3) } if ($other['data'][2] == '') { - returnError('error_create_netflow_filter', __('Error in netflow filter creation. Filter cannot be left blank.')); + returnError('error_create_netflow_filter', __('Could not create netflow filter. Filter cannot be left blank.')); return; } if ($other['data'][3] == '') { - returnError('error_create_netflow_filter', __('Error in netflow filter creation. Aggregate_by cannot be left blank.')); + returnError('error_create_netflow_filter', __('Could not create netflow filter. Aggregate_by cannot be left blank.')); return; } if ($other['data'][4] == '') { - returnError('error_create_netflow_filter', __('Error in netflow filter creation. Output_format cannot be left blank.')); + returnError('error_create_netflow_filter', __('Could not create netflow filter. Output_format cannot be left blank.')); return; } @@ -8416,7 +8416,7 @@ function api_set_create_netflow_filter($thrash1, $thrash2, $other, $thrash3) $id = db_process_sql_insert('tnetflow_filter', $values); if ($id === false) { - returnError('error_create_netflow_filter', __('Error in netflow filter creation.')); + returnError('error_create_netflow_filter', __('Could not create netflow filter.')); } else { returnData('string', ['type' => 'string', 'data' => $id]); } @@ -8515,7 +8515,7 @@ function api_get_module_data($id, $thrash1, $other, $returnType) ); if ($data === false) { - returnError('error_query_module_data', 'Error in the query of module data.'); + returnError('error_query_module_data', 'Module data query error.'); } else if ($data['data'] == '') { returnError('error_query_module_data', 'No data to show.'); } else { @@ -8636,9 +8636,9 @@ function api_set_new_user($id, $thrash2, $other, $thrash3) $values['session_time'] = $other['data'][12]; if (!create_user($id, $password, $values)) { - returnError('error_create_user', 'Error create user'); + returnError('error_create_user', 'The user could not created'); } else { - returnData('string', ['type' => 'string', 'data' => __('Create user.')]); + returnData('string', ['type' => 'string', 'data' => __('User created.')]); } } @@ -8692,7 +8692,7 @@ function api_set_update_user($id, $thrash2, $other, $thrash3) if ($id == '') { returnError( 'error_update_user', - __('Error updating user. Id_user cannot be left blank.') + __('Could not update user. Id_user cannot be left blank.') ); return; } @@ -8702,7 +8702,7 @@ function api_set_update_user($id, $thrash2, $other, $thrash3) if (!$result_user) { returnError( 'error_update_user', - __('Error updating user. Id_user doesn\'t exist.') + __('Could not update user. Id_user does not exist.') ); return; } @@ -8719,15 +8719,15 @@ function api_set_update_user($id, $thrash2, $other, $thrash3) // If password field has data if ($other['data'][4] != '') { if (!update_user_password($id, $other['data'][4])) { - returnError('error_update_user', __('Error updating user. Password info incorrect.')); + returnError('error_update_user', __('Could not update user. Password info incorrect.')); return; } } if (!update_user($id, $values)) { - returnError('error_create_user', 'Error updating user'); + returnError('error_create_user', 'Could not update user'); } else { - returnData('string', ['type' => 'string', 'data' => __('Updated user.')]); + returnData('string', ['type' => 'string', 'data' => __('User updated.')]); } } @@ -8769,7 +8769,7 @@ function api_set_enable_disable_user($id, $thrash2, $other, $thrash3) if ($id == '') { returnError( 'error_enable_disable_user', - __('Error enable/disable user. Id_user cannot be left blank.') + __('Failed switching enable/disable user. Id_user cannot be left blank.') ); return; } @@ -8777,7 +8777,7 @@ function api_set_enable_disable_user($id, $thrash2, $other, $thrash3) if ($other['data'][0] != '0' and $other['data'][0] != '1') { returnError( 'error_enable_disable_user', - __('Error enable/disable user. Enable/disable value cannot be left blank.') + __('Failed switching enable/disable user. Enable/disable value cannot be left blank.') ); return; } @@ -8785,7 +8785,7 @@ function api_set_enable_disable_user($id, $thrash2, $other, $thrash3) if (users_get_user_by_id($id) == false) { returnError( 'error_enable_disable_user', - __('Error enable/disable user. The user doesn\'t exist.') + __('Failed switching enable/disable user. The user does not exist.') ); return; } @@ -8796,7 +8796,7 @@ function api_set_enable_disable_user($id, $thrash2, $other, $thrash3) // TODO: Improve the error returning more info returnError( 'error_enable_disable_user', - __('Error in user enabling/disabling.') + __('Could not enable/disable user.') ); } else { if ($other['data'][0] == '0') { @@ -8878,11 +8878,6 @@ function otherParameter2Filter($other, $return_as_array=false, $use_agent_name=f } } - // Esto es extraño, hablar con Tati - /* - $filter['1'] = $filter['sql']; - unset($filter['sql']); */ - if (isset($other['data'][4]) && $other['data'][4] != '') { $idTemplate = db_get_value_filter('id', 'talert_templates', ['name' => $other['data'][4]]); if ($idTemplate !== false) { @@ -9036,7 +9031,7 @@ function api_set_new_alert_template($id, $id2, $other, $trash1) } if ($other['type'] == 'string') { - returnError('error_parameter', 'Error in the parameters0.'); + returnError('error_parameter', 'Parameter error.'); return; } else if ($other['type'] == 'array') { $agent_by_alias = false; @@ -9066,7 +9061,7 @@ function api_set_new_alert_template($id, $id2, $other, $trash1) $row = db_get_row_filter('talert_templates', ['name' => $id2]); if ($row === false) { - returnError('error_parameter', 'Error in the parameters1.'); + returnError('error_parameter', 'Parameter error.'); return; } @@ -9100,7 +9095,7 @@ function api_set_new_alert_template($id, $id2, $other, $trash1) $idAgentModule = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['id_agente' => $idAgent, 'nombre' => $other['data'][0]]); if ($idAgentModule === false) { - returnError('error_parameter', 'Error in the parameter2s.'); + returnError('error_parameter', 'Parameter error.'); return; } @@ -9189,7 +9184,7 @@ function api_set_delete_module($id, $id2, $other, $trash1) $idAgentModule = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['id_agente' => $idAgent, 'nombre' => $id2]); if ($idAgentModule === false) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } @@ -9235,7 +9230,7 @@ function api_set_module_data($id, $thrash2, $other, $trash1) $agentModule = db_get_row_filter('tagente_modulo', ['id_agente_modulo' => $idAgentModule]); if ($agentModule === false) { - returnError('error_parameter', 'Not found module agent.'); + returnError('error_parameter', 'Module agent not found.'); } else { $agent = db_get_row_filter('tagente', ['id_agente' => $agentModule['id_agente']]); @@ -9273,7 +9268,7 @@ function api_set_module_data($id, $thrash2, $other, $trash1) } } } else { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } } @@ -9286,7 +9281,7 @@ function api_set_new_module($id, $id2, $other, $trash1) } if ($other['type'] == 'string') { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else if ($other['type'] == 'array') { $values = []; @@ -9319,12 +9314,12 @@ function api_set_new_module($id, $id2, $other, $trash1) $values['id_tipo_modulo'] = db_get_value_filter('id_tipo', 'ttipo_modulo', ['nombre' => $other['data'][0]]); if ($values['id_tipo_modulo'] === false) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } if ($other['data'][1] == '') { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } @@ -9332,7 +9327,7 @@ function api_set_new_module($id, $id2, $other, $trash1) if (strstr($other['data'][0], 'icmp') === false) { if (($other['data'][2] == '') || ($other['data'][2] <= 0 || $other['data'][2] > 65535)) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } @@ -9451,7 +9446,7 @@ function api_set_alert_actions($id, $id2, $other, $trash1) } if ($other['type'] == 'string') { - returnError('error_parameter', 'Error in the parameters0.'); + returnError('error_parameter', 'Parameter error.'); return; } else if ($other['type'] == 'array') { $agent_by_alias = false; @@ -9480,7 +9475,7 @@ function api_set_alert_actions($id, $id2, $other, $trash1) $row = db_get_row_filter('talert_templates', ['name' => $id2]); if ($row === false) { - returnError('error_parameter', 'Error in the parameters1.'); + returnError('error_parameter', 'Parameter error.'); return; } @@ -9497,18 +9492,18 @@ function api_set_alert_actions($id, $id2, $other, $trash1) $idAlertTemplateModule = db_get_value_filter('id', 'talert_template_modules', ['id_alert_template' => $idTemplate, 'id_agent_module' => $idAgentModule]); if ($idAlertTemplateModule === false) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } if ($other['data'][1] != '') { $idAction = db_get_value_filter('id', 'talert_actions', ['name' => $other['data'][1]]); if ($idAction === false) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } } else { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } @@ -9535,24 +9530,24 @@ function api_set_alert_actions($id, $id2, $other, $trash1) } else { $idAgentModule = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['id_agente' => $idAgent, 'nombre' => $other['data'][0]]); if ($idAgentModule === false) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } $idAlertTemplateModule = db_get_value_filter('id', 'talert_template_modules', ['id_alert_template' => $idTemplate, 'id_agent_module' => $idAgentModule]); if ($idAlertTemplateModule === false) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } if ($other['data'][1] != '') { $idAction = db_get_value_filter('id', 'talert_actions', ['name' => $other['data'][1]]); if ($idAction === false) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } } else { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } @@ -9604,21 +9599,21 @@ function api_set_new_module_group($id, $thrash2, $other, $trash1) } if ($id == '' || !$id) { - returnError('error_parameter', __('Module group must have a name')); + returnError('error_parameter', __('Module group must have a name.')); return; } $name = db_get_value('name', 'tmodule_group', 'name', $id); if ($name) { - returnError('error_parameter', __('Each module group must have a different name')); + returnError('error_parameter', __('Each Module Group must have a different name.')); return; } $return = db_process_sql_insert('tmodule_group', ['name' => $id]); if ($return === false) { - returnError('error_new_moodule_group', 'There was a problem creating group'); + returnError('error_new_moodule_group', 'There was a problem creating group.'); } else { returnData('string', ['type' => 'string', 'data' => $return]); } @@ -9663,14 +9658,14 @@ function api_set_module_group_synch($thrash1, $thrash2, $other, $thrash4) // User feedback if ($module_group_create_err > 0 or $module_group_update_err > 0) { - returnError('module_group_synch_err', __('Error creating/updating %s/%s module groups
', $module_group_create_err, $module_group_update_err)); + returnError('module_group_synch_err', __('Could not create/update %s/%s module groups
', $module_group_create_err, $module_group_update_err)); } if ($module_group_create_ok > 0 or $module_group_update_ok > 0) { returnData('string', ['type' => 'string', 'data' => $string_ok]); } } else { - returnError('not_defined_in_metaconsole', __('This function is only for metaconsole')); + returnError('not_defined_in_metaconsole', __('This function is for metaconsole only')); } } @@ -9727,17 +9722,17 @@ function api_set_alert_commands($id, $thrash2, $other, $trash1) } if ($name) { - returnError('error_parameter', __('Name already exist')); + returnError('error_parameter', __('Name already exist.')); return; } if (!$group && $id_group != 0) { - returnError('error_parameter', __('Group does not exist')); + returnError('error_parameter', __('Group does not exist.')); return; } if ($other['type'] == 'string') { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else if ($other['type'] == 'array') { $fields_descriptions = []; @@ -9792,21 +9787,21 @@ function api_set_new_event($trash1, $trash2, $other, $trash3) if ($other['type'] == 'string') { if ($other['data'] != '') { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } } else if ($other['type'] == 'array') { $values = []; if (($other['data'][0] == null) && ($other['data'][0] == '')) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else { $values['evento'] = $other['data'][0]; } if (($other['data'][1] == null) && ($other['data'][1] == '')) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else { $valuesAvaliable = [ @@ -9831,27 +9826,27 @@ function api_set_new_event($trash1, $trash2, $other, $trash3) if (in_array($other['data'][1], $valuesAvaliable)) { $values['event_type'] = $other['data'][1]; } else { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } } if (($other['data'][2] == null) && ($other['data'][2] == '')) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else { $values['estado'] = $other['data'][2]; } if (($other['data'][3] == null) && ($other['data'][3] == '')) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else { $values['id_agente'] = agents_get_agent_id($other['data'][3]); } if (($other['data'][4] == null) && ($other['data'][4] == '')) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else { $idAgentModule = db_get_value_filter( @@ -9865,14 +9860,14 @@ function api_set_new_event($trash1, $trash2, $other, $trash3) } if ($idAgentModule === false) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else { $values['id_agentmodule'] = $idAgentModule; } if (($other['data'][5] == null) && ($other['data'][5] == '')) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else { if ($other['data'][5] != 'all') { @@ -9882,7 +9877,7 @@ function api_set_new_event($trash1, $trash2, $other, $trash3) } if ($idGroup === false) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else { $values['id_grupo'] = $idGroup; @@ -9890,13 +9885,13 @@ function api_set_new_event($trash1, $trash2, $other, $trash3) } if (($other['data'][6] == null) && ($other['data'][6] == '')) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else { if (($other['data'][6] >= 0) && ($other['data'][6] <= 4)) { $values['criticity'] = $other['data'][6]; } else { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } } @@ -9914,7 +9909,7 @@ function api_set_new_event($trash1, $trash2, $other, $trash3) ); if ($idAlert === false) { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else { $values['id_alert_am'] = $idAlert; @@ -9955,7 +9950,7 @@ function api_set_event_validate_filter_pro($trash1, $trash2, $other, $trash3) if ($other['type'] == 'string') { if ($other['data'] != '') { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } } else if ($other['type'] == 'array') { @@ -10052,7 +10047,7 @@ function api_set_event_validate_filter($trash1, $trash2, $other, $trash3) if ($other['type'] == 'string') { if ($other['data'] != '') { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } } else if ($other['type'] == 'array') { @@ -10132,7 +10127,7 @@ function api_set_validate_events($id_event, $trash1, $other, $return_type, $user ] ); } else { - returnError('Error in validation operation.'); + returnError('The event could not be validated.'); } } @@ -10163,7 +10158,7 @@ function api_get_gis_agent($id_agent, $trash1, $tresh2, $return_type, $user_in_d ] ); } else { - returnError('get_gis_agent', __('There is not gis data for the agent')); + returnError('get_gis_agent', __('There is not GIS data for the agent.')); } } @@ -10204,7 +10199,7 @@ function api_set_gis_agent_only_position($id_agent, $trash1, $other, $return_typ if (!$config['activate_gis']) { $correct = false; - returnError('error_gis_agent_only_position', __('Gis not activated')); + returnError('error_gis_agent_only_position', __('GIS not activated.')); return; } else { if ($correct) { @@ -10223,7 +10218,7 @@ function api_set_gis_agent_only_position($id_agent, $trash1, $other, $return_typ __('Insert by %s Console', get_product_name()) ); } else { - returnError('error_gis_agent_only_position', __('Missing parameters')); + returnError('error_gis_agent_only_position', __('Missing parameters.')); return; } } @@ -10322,7 +10317,7 @@ function api_set_gis_agent($id_agent, $trash1, $other, $return_type, $user_in_db if (!$config['activate_gis']) { $correct = false; - returnError('error_gis_agent_only_position', __('Gis not activated')); + returnError('error_gis_agent_only_position', __('GIS not activated.')); return; } else { if ($correct) { @@ -10341,7 +10336,7 @@ function api_set_gis_agent($id_agent, $trash1, $other, $return_type, $user_in_db $description_first_insert ); } else { - returnError('error_set_ig_agent', __('Missing parameters')); + returnError('error_set_ig_agent', __('Missing parameters.')); return; } } @@ -10735,7 +10730,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db if ($other['type'] == 'string') { if ($other['data'] != '') { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else { // Default values @@ -10880,11 +10875,11 @@ function api_set_event($id_event, $unused1, $params, $unused2, $unused3) if (empty($result) === true || $result === false) { returnError( 'failed_event_update', - __('Failed event update') + __('Could not update the event') ); return false; } else { - returnData('string', ['data' => 'Event updated']); + returnData('string', ['data' => 'Event updated.']); } return; @@ -10928,7 +10923,7 @@ function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db=null) if ($other['type'] == 'string') { if ($other['data'] != '') { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else { // Default values @@ -10987,9 +10982,9 @@ function api_set_delete_user($id, $thrash1, $thrash2, $thrash3) } if (!delete_user($id)) { - returnError('error_delete_user', 'Error delete user'); + returnError('error_delete_user', 'Could not delete user'); } else { - returnData('string', ['type' => 'string', 'data' => __('Delete user.')]); + returnData('string', ['type' => 'string', 'data' => __('User deleted.')]); } } @@ -11025,12 +11020,12 @@ function api_set_add_user_profile($id, $thrash1, $other, $thrash2) $profile = $other['data'][1]; if (db_get_value('id_grupo', 'tgrupo', 'id_grupo', $group) === false) { - returnError('error_set_add_user_profile', __('There is not any group with the id provided')); + returnError('error_set_add_user_profile', __('There is not any group with the ID provided.')); return; } if (db_get_value('id_perfil', 'tperfil', 'id_perfil', $profile) === false) { - returnError('error_set_add_user_profile', __('There is not any profile with the id provided')); + returnError('error_set_add_user_profile', __('There is not any profile with the ID provided.')); return; } @@ -11040,9 +11035,9 @@ function api_set_add_user_profile($id, $thrash1, $other, $thrash2) } if (!profile_create_user_profile($id, $profile, $group, 'API')) { - returnError('error_add_user_profile', 'Error add user profile.'); + returnError('error_add_user_profile', 'Could not add user profile.'); } else { - returnData('string', ['type' => 'string', 'data' => __('Add user profile.')]); + returnData('string', ['type' => 'string', 'data' => __('User profile added.')]); } } @@ -11078,12 +11073,12 @@ function api_set_delete_user_profile($id, $thrash1, $other, $thrash2) $profile = $other['data'][1]; if (db_get_value('id_grupo', 'tgrupo', 'id_grupo', $group) === false) { - returnError('error_set_add_user_profile', __('There is not any group with the id provided')); + returnError('error_set_add_user_profile', __('There is not any group with the ID provided.')); return; } if (db_get_value('id_perfil', 'tperfil', 'id_perfil', $profile) === false) { - returnError('error_set_add_user_profile', __('There is not any profile with the id provided')); + returnError('error_set_add_user_profile', __('There is not any profile with the ID provided.')); return; } @@ -11099,9 +11094,9 @@ function api_set_delete_user_profile($id, $thrash1, $other, $thrash2) ]; $result = db_process_sql_delete('tusuario_perfil', $where); if ($return === false) { - returnError('error_delete_user_profile', 'Error delete user profile.'); + returnError('error_delete_user_profile', 'Could not delete user profile.'); } else { - returnData('string', ['type' => 'string', 'data' => __('Delete user profile.')]); + returnData('string', ['type' => 'string', 'data' => __('User profile deleted.')]); } } @@ -11158,7 +11153,7 @@ function api_get_user_profiles_info($thrash1, $thrash2, $thrash3, $returnType) ); if ($profiles === false) { - returnError('error_list_profiles', __('Error retrieving profiles')); + returnError('error_list_profiles', __('Profiles could not be retrieved.')); } else { returnData($returnType, ['type' => 'array', 'data' => $profiles]); } @@ -11214,7 +11209,7 @@ function api_set_create_user_profile_info($thrash1, $thrash2, $other, $returnTyp $return = db_process_sql_insert('tperfil', $values); if ($return === false) { - returnError('error_create_user_profile_info', __('Error creating user profile')); + returnError('error_create_user_profile_info', __('Could not create user profile.')); } else { returnData($returnType, ['type' => 'array', 'data' => 1]); } @@ -11276,7 +11271,7 @@ function api_set_update_user_profile_info($id_profile, $thrash1, $other, $return $return = db_process_sql_update('tperfil', $values, ['id_perfil' => $id_profile]); if ($return === false) { - returnError('error_update_user_profile_info', __('Error updating user profile')); + returnError('error_update_user_profile_info', __('Could not update user profile')); } else { returnData($returnType, ['type' => 'array', 'data' => 1]); } @@ -11311,7 +11306,7 @@ function api_set_delete_user_profile_info($id_profile, $thrash1, $thrash2, $retu $return = profile_delete_profile_and_clean_users($id_profile); if ($return === false) { - returnError('error_delete_user_profile_info', __('Error deleting user profile')); + returnError('error_delete_user_profile_info', __('Could not delete user profile')); } else { returnData($returnType, ['type' => 'array', 'data' => 1]); } @@ -11369,7 +11364,7 @@ function api_set_new_incident($thrash1, $thrash2, $other, $thrash3) $idIncident = db_process_sql_insert('tincidencia', $values); if ($return === false) { - returnError('error_new_incident', 'Error create new incident.'); + returnError('error_new_incident', 'A new incident could not be created.'); } else { returnData('string', ['type' => 'string', 'data' => $idIncident]); } @@ -11406,7 +11401,7 @@ function api_set_new_note_incident($id, $id2, $other, $thrash2) $idNote = db_process_sql_insert('tnota', $values); if ($idNote === false) { - returnError('error_new_incident', 'Error create new incident.'); + returnError('error_new_incident', 'A new incident could not be created+.'); } else { returnData('string', ['type' => 'string', 'data' => $idNote]); } @@ -11472,9 +11467,9 @@ function api_set_disable_module($agent_name, $module_name, $other, $thrash4) $result = modules_change_disabled($id_agent_module, 1); if ($result === NOERR) { - returnData('string', ['type' => 'string', 'data' => __('Correct module disable')]); + returnData('string', ['type' => 'string', 'data' => __('Module disabled successfully.')]); } else { - returnData('string', ['type' => 'string', 'data' => __('Error disabling module')]); + returnData('string', ['type' => 'string', 'data' => __('The module could not be disabled.')]); } } } @@ -11538,9 +11533,9 @@ function api_set_enable_module($agent_name, $module_name, $other, $thrash4) $result = modules_change_disabled($id_agent_module, 0); if ($result === NOERR) { - returnData('string', ['type' => 'string', 'data' => __('Correct module enable')]); + returnData('string', ['type' => 'string', 'data' => __('Module enabled successfully.')]); } else { - returnData('string', ['type' => 'string', 'data' => __('Error enabling module')]); + returnData('string', ['type' => 'string', 'data' => __('The module could not be enabled.')]); } } } @@ -11586,9 +11581,9 @@ function api_set_disable_alert($agent_name, $module_name, $template_name, $thras ); if ($result) { - returnData('string', ['type' => 'string', 'data' => 'Correct alert disable']); + returnData('string', ['type' => 'string', 'data' => 'Alert disabled successfully.']); } else { - returnData('string', ['type' => 'string', 'data' => __('Error alert disable')]); + returnData('string', ['type' => 'string', 'data' => __('The alert could not be disabled.')]); } } @@ -11635,13 +11630,13 @@ function api_set_disable_alert_alias($agent_alias, $module_name, $template_name, ); if ($result) { - returnData('string', ['type' => 'string', 'data' => 'Correct alert disable']); + returnData('string', ['type' => 'string', 'data' => 'Alert disabled successfully.']); return; } } if (!$result) { - returnData('string', ['type' => 'string', 'data' => __('Error alert disable')]); + returnData('string', ['type' => 'string', 'data' => __('The alert could not be disabled.')]); } } @@ -11686,9 +11681,9 @@ function api_set_enable_alert($agent_name, $module_name, $template_name, $thrash ); if ($result) { - returnData('string', ['type' => 'string', 'data' => 'Correct alert enable']); + returnData('string', ['type' => 'string', 'data' => 'Alert enabled successfully.']); } else { - returnData('string', ['type' => 'string', 'data' => __('Error alert enable')]); + returnData('string', ['type' => 'string', 'data' => __('The alert could not be enabled.')]); } } @@ -11735,13 +11730,13 @@ function api_set_enable_alert_alias($agent_alias, $module_name, $template_name, ); if ($result) { - returnData('string', ['type' => 'string', 'data' => 'Correct alert enable']); + returnData('string', ['type' => 'string', 'data' => 'Alert enabled successfully.']); return; } } if (!$result) { - returnData('string', ['type' => 'string', 'data' => __('Error alert enable')]); + returnData('string', ['type' => 'string', 'data' => __('The alert could not be enabled.')]); } } @@ -11822,7 +11817,7 @@ function api_set_disable_module_alerts($agent_name, $module_name, $other, $thras WHERE id_agent_module = $id_agent_module" ); - returnData('string', ['type' => 'string', 'data' => 'Correct alerts disable']); + returnData('string', ['type' => 'string', 'data' => 'Alerts disabled successfully.']); } } @@ -11903,7 +11898,7 @@ function api_set_enable_module_alerts($agent_name, $module_name, $other, $thrash WHERE id_agent_module = $id_agent_module" ); - returnData('string', ['type' => 'string', 'data' => 'Correct alerts enable']); + returnData('string', ['type' => 'string', 'data' => 'Alerts enabled successfully.']); } } @@ -11923,7 +11918,7 @@ function api_get_tags($thrash1, $thrash2, $other, $returnType, $user_in_db) if ($other['type'] == 'string') { if ($other['data'] != '') { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else { // Default values @@ -12323,7 +12318,7 @@ function api_set_create_tag($id, $trash1, $other, $returnType) ] ); } else { - returnError('error_set_tag_user_profile', 'Error create tag user profile.'); + returnError('error_set_tag_user_profile', 'Could not create tag for user profile.'); } } @@ -12339,7 +12334,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) } if ($other['type'] == 'string') { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else if ($other['type'] == 'array') { $values = []; @@ -12371,7 +12366,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) if (!empty($other['data'][17]) && is_metaconsole()) { $id_server = db_get_row_filter('tmetaconsole_setup', ['id' => $other['data'][17]]); if ($id_server === false) { - returnError('error_create_event', __('Server id does not exist in database.')); + returnError('error_create_event', __('Server ID does not exist in database.')); return; } @@ -12627,7 +12622,7 @@ function api_set_add_event_comment($id, $thrash2, $other, $thrash3) } if ($other['type'] == 'string') { - returnError('error_parameter', 'Error in the parameters.'); + returnError('error_parameter', 'Parameter error.'); return; } else if ($other['type'] == 'array') { $comment = $other['data'][0]; @@ -12643,7 +12638,7 @@ function api_set_add_event_comment($id, $thrash2, $other, $thrash3) if (is_error($status)) { returnError( 'error_add_event_comment', - __('Error adding event comment.') + __('Could not add event comment.') ); return; } @@ -12787,11 +12782,11 @@ function api_set_validate_event_by_id($id, $trash1=null, $trash2=null, $returnTy $status = db_get_value('estado', $table_events, 'id_evento', $id); if ($status == 1) { // event already validated - $data['data'] = 'Event already validated'; + $data['data'] = 'Event already validated.'; } else { $ack_utimestamp = time(); - events_comment($id, '', 'Change status to validated'); + events_comment($id, '', 'Changed the status to validated.'); $values = [ 'ack_utimestamp' => $ack_utimestamp, @@ -12801,13 +12796,13 @@ function api_set_validate_event_by_id($id, $trash1=null, $trash2=null, $returnTy $result = db_process_sql_update($table_events, $values, ['id_evento' => $id]); if ($result === false) { - $data['data'] = 'Error validating event'; + $data['data'] = 'The event could not be validated.'; } else { - $data['data'] = 'Event validate'; + $data['data'] = 'Validated event.'; } } } else { - $data['data'] = 'Event not exists'; + $data['data'] = 'Event does not exist.'; } returnData($returnType, $data); @@ -12926,7 +12921,7 @@ function api_set_enable_disable_agent($id, $thrash2, $other, $thrash3) if ($id == '') { returnError( 'error_enable_disable_agent', - __('Error enable/disable agent. Id_agent cannot be left blank.') + __('Failed switching enable/disable agent. Id_agent cannot be left blank.') ); return; } @@ -12938,7 +12933,7 @@ function api_set_enable_disable_agent($id, $thrash2, $other, $thrash3) if ($other['data'][0] != '0' and $other['data'][0] != '1') { returnError( 'error_enable_disable_agent', - __('Error enable/disable agent. Enable/disable value cannot be left blank.') + __('Failed switching enable/disable agent. Enable/disable value cannot be left blank.') ); return; } @@ -12946,7 +12941,7 @@ function api_set_enable_disable_agent($id, $thrash2, $other, $thrash3) if (agents_get_name($id) == false) { returnError( 'error_enable_disable_agent', - __('Error enable/disable agent. The agent doesn\'t exist.') + __('Failed switching enable/disable agent. The agent does not exist.') ); return; } @@ -12970,7 +12965,7 @@ function api_set_enable_disable_agent($id, $thrash2, $other, $thrash3) if (is_error($result)) { // TODO: Improve the error returning more info - returnError('error_enable_disable_agent', __('Error in agent enabling/disabling.')); + returnError('error_enable_disable_agent', __('Failed switching enable/disable agent.')); } else { if ($disabled == 0) { returnData( @@ -13100,7 +13095,7 @@ function api_get_special_days($thrash1, $thrash2, $other, $thrash3) } if (!$special_days) { - returnError('error_get_special_days', __('Error getting special_days.')); + returnError('error_get_special_days', __('Could not get special_days.')); } else { returnData('csv', $data, $separator); } @@ -13140,23 +13135,23 @@ function api_set_create_special_day($thrash1, $thrash2, $other, $thrash3) $check_id_special_day = db_get_value('id', 'talert_special_days', 'date', $special_day); if ($check_id_special_day) { - returnError('error_create_special_day', __('Error creating special day. Specified day already exists.')); + returnError('error_create_special_day', __('Could not create special day. Specified day already exist.')); return; } if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $special_day)) { - returnError('error_create_special_day', __('Error creating special day. Invalid date format.')); + returnError('error_create_special_day', __('Could not create special day. Invalid date format.')); return; } if (!isset($idGroup) || $idGroup == '') { - returnError('error_create_special_day', __('Error creating special day. Group id cannot be left blank.')); + returnError('error_create_special_day', __('Could not create special day. Group id cannot be left blank.')); return; } else { $group = groups_get_group_by_id($idGroup); if ($group == false) { - returnError('error_create_special_day', __('Error creating special day. Id_group doesn\'t exist.')); + returnError('error_create_special_day', __('Could not create special day. Id_group does not exist.')); return; } @@ -13174,7 +13169,7 @@ function api_set_create_special_day($thrash1, $thrash2, $other, $thrash3) $idSpecialDay = alerts_create_alert_special_day($special_day, $same_day, $values); if (is_error($idSpecialDay)) { - returnError('error_create_special_day', __('Error in creation special day.')); + returnError('error_create_special_day', __('Could not create special day.')); } else { returnData('string', ['type' => 'string', 'data' => $idSpecialDay]); } @@ -13227,7 +13222,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) $server_name = $other['data'][16]; if (empty($name)) { - returnError('error_create_service', __('Error in creation service. No name')); + returnError('error_create_service', __('Could not create service. No name provided.')); return; } @@ -13250,7 +13245,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) } if (empty($id_agent)) { - returnError('error_create_service', __('Error in creation service. No agent id')); + returnError('error_create_service', __('Could not create service. No agent ID provided.')); return; } else { if (!util_api_check_agent_and_print_error($id_agent, 'string', 'AR')) { @@ -13330,7 +13325,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) if ($result) { returnData('string', ['type' => 'string', 'data' => $result]); } else { - returnError('error_create_service', __('Error in creation service')); + returnError('error_create_service', __('Could not create service.')); } } @@ -13362,7 +13357,7 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) $id_service = $thrash1; if (empty($id_service)) { - returnError('error_update_service', __('Error in update service. No service id')); + returnError('error_update_service', __('Could not update service. No service ID provided.')); return; } @@ -13505,7 +13500,7 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) if ($result) { returnData('string', ['type' => 'string', 'data' => $result]); } else { - returnError('error_update_service', __('Error in update service')); + returnError('error_update_service', __('Could not update service.')); } } @@ -13538,7 +13533,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) $id = $thrash1; if (empty($id)) { - returnError('error_add_service_element', __('Error adding elements to service. No service id')); + returnError('error_add_service_element', __('Could not add elements to service. No service ID provided.')); return; } @@ -13615,7 +13610,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) if ($results) { returnData('string', ['type' => 'string', 'data' => 1]); } else { - returnError('error_add_service_element', __('Error adding elements to service')); + returnError('error_add_service_element', __('Could not add elements to service')); } } @@ -13652,19 +13647,19 @@ function api_set_update_special_day($id_special_day, $thrash2, $other, $thrash3) $idGroup = $other['data'][3]; if ($id_special_day == '') { - returnError('error_update_special_day', __('Error updating special day. Id cannot be left blank.')); + returnError('error_update_special_day', __('Could not update special day. ID cannot be left blank.')); return; } $check_id_special_day = db_get_value('id', 'talert_special_days', 'id', $id_special_day); if (!$check_id_special_day) { - returnError('error_update_special_day', __('Error updating special day. Id doesn\'t exist.')); + returnError('error_update_special_day', __('Could not update special day. ID does not exist.')); return; } if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $special_day)) { - returnError('error_update_special_day', __('Error updating special day. Invalid date format.')); + returnError('error_update_special_day', __('Could not update special day. Invalid date format.')); return; } @@ -13714,21 +13709,21 @@ function api_set_delete_special_day($id_special_day, $thrash2, $thrash3, $thrash } if ($id_special_day == '') { - returnError('error_update_special_day', __('Error deleting special day. Id cannot be left blank.')); + returnError('error_update_special_day', __('Could not delete special day. ID cannot be left blank.')); return; } $check_id_special_day = db_get_value('id', 'talert_special_days', 'id', $id_special_day); if (!$check_id_special_day) { - returnError('error_delete_special_day', __('Error deleting special day. Id doesn\'t exist.')); + returnError('error_delete_special_day', __('Could not delete special day. ID does not exist.')); return; } $return = alerts_delete_alert_special_day($id_special_day); if (is_error($return)) { - returnError('error_delete_special_day', __('Error in deletion special day.')); + returnError('error_delete_special_day', __('Could not delete special day.')); } else { returnData('string', ['type' => 'string', 'data' => $return]); } @@ -13843,12 +13838,12 @@ function api_set_metaconsole_synch($keys) enterprise_include_once('include/functions_metaconsole.php'); $array_metaconsole_update = metaconsole_update_all_nodes_license(); if ($array_metaconsole_update[0] === 0) { - ui_print_success_message(__('Metaconsole and all nodes license updated')); + ui_print_success_message(__('Metaconsole and the licenses of all nodes were updated.')); } else { - ui_print_error_message(__('Metaconsole license updated but %d of %d node synchronization failed', $array_metaconsole_update[0], $array_metaconsole_update[1])); + ui_print_error_message(__('Metaconsole license updated but %d of %d node failed to sync.', $array_metaconsole_update[0], $array_metaconsole_update[1])); } } else { - echo __('This function is only for metaconsole'); + echo __('This function is for metaconsole only.'); } } @@ -13874,7 +13869,7 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) $name_exist = db_process_sql('select count(name) as already_exist from tcluster as already_exist where name = "'.$name.'"'); if ($name_exist[0]['already_exist'] > 0) { - returnError('error_set_new_cluster', __('A cluster with this name already exists.')); + returnError('error_set_new_cluster', __('A cluster with this name already exist.')); return false; } @@ -13956,7 +13951,7 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) ] ); } else { - returnError('error_set_new_cluster', __('Failed to create cluster.')); + returnError('error_set_new_cluster', __('A cluster could not be created.')); } } else { returnError('error_set_new_cluster', __('Agent name cannot be empty.')); @@ -13994,7 +13989,7 @@ function api_set_add_cluster_agent($thrash1, $thrash2, $other, $thrash3) if ($tcluster_agent !== false) { returnData('string', ['type' => 'string', 'data' => 1]); } else { - returnError('error_add_cluster_element', __('Error adding elements to cluster')); + returnError('error_add_cluster_element', __('Could not add elements to cluster')); } } @@ -14118,7 +14113,7 @@ function api_set_add_cluster_item($thrash1, $thrash2, $other, $thrash3) if ($tcluster_balanced_module !== false) { db_pandora_audit('Report management', 'Module #'.$element['name'].' assigned to cluster #'.$element['id_cluster']); } else { - db_pandora_audit('Report management', 'Fail try to assign module to cluster'); + db_pandora_audit('Report management', 'The module could not be assigned to the cluster'); } } } @@ -14129,7 +14124,7 @@ function api_set_add_cluster_item($thrash1, $thrash2, $other, $thrash3) if ($id_module !== false) { returnData('string', ['type' => 'string', 'data' => 1]); } else { - returnError('error_add_cluster_element', __('Error adding elements to cluster')); + returnError('error_add_cluster_element', __('Could not add elements to cluster')); } } @@ -14166,9 +14161,9 @@ function api_set_delete_cluster($id, $thrash1, $thrast2, $thrash3) $tcluster_agent_delete = $temp_id_cluster[0]['id_agent'] !== null ? agents_delete_agent($temp_id_cluster[0]['id_agent']) : 0; if (($tcluster_modules_delete + $tcluster_items_delete + $tcluster_agents_delete + $tcluster_delete + $tcluster_agent_delete) == 0) { - returnError('error_delete', 'Error in delete operation.'); + returnError('error_delete', 'Cluster could not be deleted.'); } else { - returnData('string', ['type' => 'string', 'data' => __('Successfully deleted')]); + returnData('string', ['type' => 'string', 'data' => __('Successfully deleted.')]); } } @@ -14198,7 +14193,7 @@ function api_set_delete_cluster_agents($thrash1, $thrast2, $other, $thrash3) || (!check_acl($config['id_user'], $cluster['group'], 'AW')) || (!agents_check_access_agent($ta['id_agent'], 'AW')) ) { - returnError('error_set_delete_cluster_agent', __('The user cannot access to the cluster')); + returnError('error_set_delete_cluster_agent', __('The user cannot access the cluster.')); return; } } @@ -14228,7 +14223,7 @@ function api_set_delete_cluster_item($id, $thrash1, $thrast2, $thrast3) $cluster = $clusters[0]; if (!check_acl($config['id_user'], $cluster['group'], 'AD')) { - returnError('error_set_delete_cluster_item', __('The user cannot access to the cluster')); + returnError('error_set_delete_cluster_item', __('The user cannot access the cluster')); return; } @@ -14239,7 +14234,7 @@ function api_set_delete_cluster_item($id, $thrash1, $thrast2, $thrast3) if (!$delete_item) { returnError('error_delete', 'Error in delete operation.'); } else { - returnData('string', ['type' => 'string', 'data' => __('Correct Delete')]); + returnData('string', ['type' => 'string', 'data' => __('Successfully deleted.')]); } } @@ -14379,9 +14374,9 @@ function api_set_apply_module_template($id_template, $id_agent, $thrash3, $thras if ($error_count > 0) { if (empty($modules_already_added)) { - returnError('set_apply_module_template', __('Error adding modules').sprintf(' (%s)', $error_count)); + returnError('set_apply_module_template', __('Could not add modules').sprintf(' (%s)', $error_count)); } else { - returnError('set_apply_module_template', __('Error adding modules. The following errors already exists: ').implode(', ', $modules_already_added)); + returnError('set_apply_module_template', __('Could not add modules. The following errors already exists: ').implode(', ', $modules_already_added)); } } @@ -14591,7 +14586,7 @@ function api_get_modules_id_name_by_cluster_id($cluster_id) $clusters = Cluster::search(['id' => $cluster_id]); if ($clusters === false) { - returnError('error_clusters', 'Id does not exist in database.'); + returnError('error_clusters', 'ID does not exist in database.'); } $cluster = $clusters[0]; @@ -14626,7 +14621,7 @@ function api_get_modules_id_name_by_cluster_id($cluster_id) returnData('json', $data); } else { - returnError('error_agent_modules', 'No modules retrieved.'); + returnError('error_agent_modules', 'No modules were retrieved.'); } } @@ -14673,7 +14668,7 @@ function api_get_modules_id_name_by_cluster_name($cluster_name) returnData('json', $data); } else { - returnError('error_agent_modules', 'No modules retrieved.'); + returnError('error_agent_modules', 'No modules were retrieved.'); } } @@ -14914,7 +14909,7 @@ function api_get_cluster_items($cluster_id) returnData('json', $data); } else { - returnError('error_cluster_items', 'No items retrieved.'); + returnError('error_cluster_items', 'No items were retrieved.'); } } @@ -14939,7 +14934,7 @@ function api_set_create_event_filter($name, $thrash1, $other, $thrash3) if ($name == '') { returnError( 'error_create_event_filter', - __('Error creating event filter. Event filter name cannot be left blank.') + __('Could not create event filter. Event filter name cannot be left blank.') ); return; } @@ -15079,7 +15074,7 @@ function api_set_create_event_filter($name, $thrash1, $other, $thrash3) $id_filter = db_process_sql_insert('tevent_filter', $values); if ($id_filter === false) { - returnError('error_create_event_filter', __('Error creating event filter.')); + returnError('error_create_event_filter', __('Could not create event filter.')); } else { returnData( 'string', @@ -15122,7 +15117,7 @@ function api_set_update_event_filter($id_event_filter, $thrash1, $other, $thrash if ($id_event_filter == '') { returnError( 'error_update_event_filter', - __('Error updating event filter. Event filter ID cannot be left blank.') + __('Could not update event filter. Event filter ID cannot be left blank.') ); return; } @@ -15133,7 +15128,7 @@ function api_set_update_event_filter($id_event_filter, $thrash1, $other, $thrash if (!$result_event_filter) { returnError( 'error_update_event_filter', - __('Error updating event filter. Event filter ID doesn\'t exist.') + __('Could not update event filter. Event filter ID does not exist.') ); return; } @@ -15314,7 +15309,7 @@ function api_set_update_event_filter($id_event_filter, $thrash1, $other, $thrash ); if ($result === false) { - returnError('error_update_event_filter', __('Error updating event filter.')); + returnError('error_update_event_filter', __('Could not update event filter.')); } else { returnData( 'string', @@ -15346,7 +15341,7 @@ function api_set_delete_event_filter($id_event_filter, $thrash1, $other, $thrash if ($id_event_filter == '') { returnError( 'error_delete_event_filter', - __('Error deleting event_filter. Event filter ID cannot be left blank.') + __('Could not delete event_filter. Event filter ID cannot be left blank.') ); return; } @@ -15356,7 +15351,7 @@ function api_set_delete_event_filter($id_event_filter, $thrash1, $other, $thrash if ($result == 0) { returnError( 'error_delete_event_filter', - __('Error deleting event filter.') + __('Could not delete event filter.') ); } else { returnData( @@ -15411,7 +15406,7 @@ function api_get_all_event_filters($thrash1, $thrash2, $other, $thrash3) if (!$event_filters) { returnError( 'error_get_all_event_filters', - __('Error getting all event filters.') + __('Could not get all event filters.') ); } else { returnData('csv', $data, $separator); @@ -15641,7 +15636,7 @@ function api_set_validate_traps($id, $thrash2, $other, $thrash3) if (is_error($result)) { // TODO: Improve the error returning more info - returnError('error_update_trap', __('Error in trap update.')); + returnError('error_update_trap', __('Could not update trap.')); } else { returnData( 'string', @@ -15668,7 +15663,7 @@ function api_set_delete_traps($id, $thrash2, $other, $thrash3) if (is_error($result)) { // TODO: Improve the error returning more info - returnError('error_delete_trap', __('Error in trap delete.')); + returnError('error_delete_trap', __('Could not deleted trap.')); } else { returnData( 'string', @@ -15702,7 +15697,7 @@ function api_get_group_id_by_name($thrash1, $thrash2, $other, $thrash3) returnData('csv', $data, ';'); } else { - returnError('error_group_name', 'No groups retrieved.'); + returnError('error_group_name', 'No groups were retrieved.'); } } @@ -15728,7 +15723,7 @@ function api_get_timezone($thrash1, $thrash2, $other, $thrash3) returnData('string', ['type' => 'string', 'data' => $data['data'][0]['value']]); } else { - returnError('error_timezone', 'No timezone retrieved.'); + returnError('error_timezone', 'No timezone were retrieved.'); } } @@ -15754,7 +15749,7 @@ function api_get_language($thrash1, $thrash2, $other, $thrash3) returnData('string', ['type' => 'string', 'data' => $data['data'][0]['value']]); } else { - returnError('error_language', 'No language retrieved.'); + returnError('error_language', 'No language were retrieved.'); } } @@ -15780,7 +15775,7 @@ function api_get_session_timeout($thrash1, $thrash2, $other, $thrash3) returnData('string', ['type' => 'string', 'data' => $data['data'][0]['value']]); } else { - returnError('error_session_timeout', 'No session timeout retrieved.'); + returnError('error_session_timeout', 'No session timeout were retrieved.'); } } @@ -15805,7 +15800,7 @@ function api_get_users($thrash1, $thrash2, $other, $returnType) if (count($data) > 0 and $data !== false) { returnData($returnType, $data, $separator); } else { - returnError('error_users', 'No users retrieved.'); + returnError('error_users', 'No users were retrieved.'); } } From 2bf6db3224db20de3f4c19e68d84249629334efb Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 19 Jan 2021 16:09:06 +0100 Subject: [PATCH 10/49] Added last modifies --- pandora_console/include/functions_api.php | 898 ++++++++++------------ 1 file changed, 424 insertions(+), 474 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index ec4770757b..7c59d15acf 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -161,10 +161,10 @@ function returnError($typeError, $returnType='string') default: returnData( - 'string', + $returnType, [ 'type' => 'string', - 'data' => __($returnType), + 'data' => __($typeError), ] ); break; @@ -1089,7 +1089,7 @@ function api_get_module_properties_by_name($agent_name, $module_name, $other, $r $agent_id = agents_get_agent_id($agent_name); if ($agent_id == 0) { - returnError('error_get_module_properties_by_name', __('Does not exist agent with this name.')); + returnError('Does not exist agent with this name.'); return; } @@ -1099,7 +1099,7 @@ function api_get_module_properties_by_name($agent_name, $module_name, $other, $r $tagente_modulo = modules_get_agentmodule_id($module_name, $agent_id); if ($tagente_modulo === false) { - returnError('error_get_module_properties_by_name', __('Does not exist module with this name.')); + returnError('Does not exist module with this name.'); return; } @@ -1164,7 +1164,7 @@ function api_get_module_properties_by_alias($alias, $module_name, $other, $retur $data = db_get_row_sql($sql); if ($data === false) { - returnError('error_get_module_properties_by_name', __('Does not exist the pair alias/module required.')); + returnError('Does not exist the pair alias/module required.'); } if (!util_api_check_agent_and_print_error($data['id_agente'], $returnType)) { @@ -1347,7 +1347,7 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3) WHERE id_agente = '.$idParent.' AND id_agente_modulo = '.$cascadeProtectionModule ) === false) ) { - returnError('parent_agent_not_exist', 'Is not a parent module to do cascade protection.'); + returnError('Cascade protection is not applied because it is not a parent module'); } } else { $cascadeProtectionModule = 0; @@ -1363,12 +1363,12 @@ function api_set_update_agent($id_agent, $thrash2, $other, $thrash3) if ($idParent != 0) { $parentCheck = agents_check_access_agent($idParent); if ($parentCheck === null) { - returnError('parent_agent_not_exist', __('The parent agent does not exist.')); + returnError('The parent agent does not exist.'); return; } if ($parentCheck === false) { - returnError('parent_agent_forbidden', __('The user cannot access to parent agent.')); + returnError('The user cannot access to parent agent.'); return; } } @@ -1516,7 +1516,7 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) } if ((int) $other['data'][3] == 0) { - returnError('generic error', __('For security reasons, the agent was not created. Use a group other than 0.')); + returnError('For security reasons, the agent was not created. Use a group other than 0.'); return; } @@ -1544,7 +1544,7 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) WHERE id_agente = '.$id_parent.' AND id_agente_modulo = '.$cascade_protection_module ) === false) ) { - returnError('parent_agent_not_exist', 'Is not a parent module to do cascade protection.'); + returnError('Cascade protection is not applied because it is not a parent module.'); return; } } else { @@ -1555,15 +1555,15 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) // Check if agent exists (BUG WC-50518-2). if ($alias == '' && $alias_as_name === 0) { - returnError('alias_not_specified', 'No agent alias specified'); - } else if (agents_get_agent_id($name)) { - returnError('agent_name_exist', 'The name of agent yet exist in DB.'); + returnError('No agent alias specified'); + } else if (agents_get_agent_id($server_name)) { + returnError('The agent name already exists in DB.'); } else if (db_get_value_sql('SELECT id_grupo FROM tgrupo WHERE id_grupo = '.$grupo) === false) { - returnError('id_grupo_not_exist', 'The group don`t exist.'); + returnError('The group does not exist.'); } else if (db_get_value_sql('SELECT id_os FROM tconfig_os WHERE id_os = '.$id_os) === false) { - returnError('id_os_not_exist', 'The OS don`t exist.'); + returnError('The OS does not exist.'); } else if ($server_name === false) { - returnError('server_not_exist', 'The '.get_product_name().' Server don`t exist.'); + returnError('The '.get_product_name().' Server does not exist.'); } else { if ($alias_as_name === 1) { $exists_alias = db_get_row_sql('SELECT nombre FROM tagente WHERE nombre = "'.$alias.'"'); @@ -1657,14 +1657,14 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) $id_agente = 0; if ($exists_alias) { - $agent_creation_error = __('Could not be created because name already exists'); + $agent_creation_error = 'Could not be created because name already exists'; } else if ($exists_ip) { - $agent_creation_error = __('Could not be created because IP already exists'); + $agent_creation_error = 'Could not be created because IP already exists'; } else { - $agent_creation_error = __('Could not be created for unknown reason'); + $agent_creation_error = 'Could not be created for unknown reason'; } - returnError('generic error', $agent_creation_error); + returnError($agent_creation_error); return; } @@ -1762,7 +1762,7 @@ function api_set_create_custom_field($t1, $t2, $other, $returnType) } if ($other['type'] == 'string') { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else if ($other['type'] == 'array') { $name = ''; @@ -1770,7 +1770,7 @@ function api_set_create_custom_field($t1, $t2, $other, $returnType) if ($other['data'][0] != '') { $name = $other['data'][0]; } else { - returnError('error_parameter', 'Custom field name required'); + returnError('Custom field name required'); return; } @@ -1779,7 +1779,7 @@ function api_set_create_custom_field($t1, $t2, $other, $returnType) if ($other['data'][1] != '') { $display_front = $other['data'][1]; } else { - returnError('error_parameter', 'Custom field display flag required'); + returnError('Custom field display flag required'); return; } @@ -1788,7 +1788,7 @@ function api_set_create_custom_field($t1, $t2, $other, $returnType) if ($other['data'][2] != '') { $is_password_type = $other['data'][2]; } else { - returnError('error_parameter', 'Custom field is password type required'); + returnError('Custom field is password type required'); return; } @@ -1922,7 +1922,7 @@ function api_set_delete_agent($id, $thrash1, $other, $thrash3) } if (!$result) { - returnError('error_delete', __('The agent could not be deleted')); + returnError('The agent could not be deleted'); } else { returnData('string', ['type' => 'string', 'data' => __('The agent was successfully deleted')]); } @@ -1950,6 +1950,8 @@ function api_get_all_agents($thrash1, $thrash2, $other, $returnType) { global $config; + $where = ''; + // Error if user cannot read agents. if (!check_acl($config['id_user'], 0, 'AR')) { returnError('forbidden', $returnType); @@ -2123,7 +2125,7 @@ function api_get_all_agents($thrash1, $thrash2, $other, $returnType) ]; returnData($returnType, $data, $separator); } else { - returnError('error_all_agents', 'No agents retrieved.'); + returnError('No agents retrieved.'); } } @@ -2169,7 +2171,7 @@ function api_get_agent_modules($thrash1, $thrash2, $other, $thrash3) returnData('csv', $data, ';'); } else { - returnError('error_agent_modules', 'No modules retrieved.'); + returnError('No modules retrieved.'); } } @@ -2518,7 +2520,7 @@ function api_get_module_id($id, $thrash1, $name, $thrash3) ]; returnData('csv', $data, ';'); } else { - returnError('error_module_id', 'does not exist module or agent'); + returnError('Does not exist module or agent'); } } @@ -2706,7 +2708,7 @@ function api_get_group_agent_by_name($thrash1, $thrash2, $other, $thrash3) returnData('csv', $data, ';'); } else { - returnError('error_group_agent', 'No groups retrieved.'); + returnError('No groups retrieved.'); } } @@ -2804,7 +2806,7 @@ function api_get_group_agent_by_alias($thrash1, $thrash2, $other, $thrash3) returnData('csv', $data, ';'); } else { - returnError('error_group_agent', 'No groups retrieved.'); + returnError('No groups retrieved.'); } } @@ -2860,7 +2862,7 @@ function api_get_locate_agent($id, $thrash1, $thrash2, $thrash3) returnData('csv', $data, ';'); } else { - returnError('error_locate_agents', 'No agents located.'); + returnError('No agents located.'); } } @@ -2946,7 +2948,7 @@ function api_get_id_group_agent_by_name($thrash1, $thrash2, $other, $thrash3) returnData('csv', $data); } else { - returnError('error_group_agent', 'No groups retrieved.'); + returnError('No groups retrieved.'); } } @@ -3043,7 +3045,7 @@ function api_get_id_group_agent_by_alias($thrash1, $thrash2, $other, $thrash3) ]; returnData('csv', $data); } else { - returnError('error_group_agent', 'No groups retrieved.'); + returnError('No groups retrieved.'); } } @@ -3105,7 +3107,7 @@ function api_get_policies($thrash1, $thrash2, $other, $thrash3) returnData('csv', $data, ';'); } else { - returnError('error_get_policies', 'No policies retrieved.'); + returnError('No policies retrieved.'); } } @@ -3132,7 +3134,7 @@ function api_get_policy_modules($thrash1, $thrash2, $other, $thrash3) $where = ''; if ($other['data'][0] == '') { - returnError('error_policy_modules', 'Error retrieving policy modules. Id_policy cannot be left blank.'); + returnError('Could not retrieve policy modules. Id_policy cannot be left blank.'); return; } @@ -3145,7 +3147,7 @@ function api_get_policy_modules($thrash1, $thrash2, $other, $thrash3) ); if ($policies === ENTERPRISE_NOT_HOOK) { - returnError('error_policy_modules', 'Error retrieving policy modules.'); + returnError('Could not retrieve '); return; } @@ -3157,7 +3159,7 @@ function api_get_policy_modules($thrash1, $thrash2, $other, $thrash3) returnData('csv', $data, ';'); } else { - returnError('error_policy_modules', 'No policy modules retrieved.'); + returnError('No policy modules retrieved.'); } } @@ -3204,8 +3206,7 @@ function api_set_create_network_module($id, $thrash1, $other, $thrash3) if ($other['data'][2] < 6 or $other['data'][2] > 18) { returnError( - 'error_create_network_module', - __('Error in creation network module. Id_module_type is not correct for network modules.') + 'Could not be created the network module. Id_module_type is not correct for network modules.' ); return; } @@ -3285,7 +3286,7 @@ function api_set_create_network_module($id, $thrash1, $other, $thrash3) if (is_error($idModule)) { // TODO: Improve the error returning more info. - returnError('error_create_network_module', __('Error in creation network module.')); + returnError('Could not be created the network module.'); } else { returnData('string', ['type' => 'string', 'data' => $idModule]); } @@ -3317,8 +3318,7 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3) if ($id_module == '') { returnError( - 'error_update_network_module', - __('Could not update network module. Module name cannot be left blank.') + 'The network module could not be updated. Module name cannot be left blank.' ); return; } @@ -3336,8 +3336,7 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3) if (!$check_id_module) { returnError( - 'error_update_network_module', - __('Could not update network module. Id_module does not exist.') + 'The network module could not be updated. Id_module does not exist.' ); return; } @@ -3362,8 +3361,7 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3) if ($id_module_exists) { returnError( - 'error_update_network_module', - __('Could not update network module. Id_module exists in the new agent.') + 'The network module could not be updated. Id_module exists in the new agent.' ); return; } @@ -3419,7 +3417,7 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3) $result_update = modules_update_agent_module($id_module, $values); if ($result_update < 0) { - returnError('error_update_network_module', __('Could not update network module.')); + returnError('The network module could not be updated.'); } else { returnData('string', ['type' => 'string', 'data' => __('Network module updated.')]); } @@ -3451,7 +3449,7 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3) } if ($other['data'][22] == '') { - returnError('error_create_plugin_module', __('Error in creation plugin module. Id_plugin cannot be left blank.')); + returnError('The plugin module could not be created. Id_plugin cannot be left blank.'); return; } @@ -3552,7 +3550,7 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3) if (is_error($idModule)) { // TODO: Improve the error returning more info. - returnError('error_create_plugin_module', __('Could not create Plugin module.')); + returnError('The plugin module could not be created.'); } else { returnData('string', ['type' => 'string', 'data' => $idModule]); } @@ -3584,7 +3582,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3) } if ($id_module == '') { - returnError('error_update_plugin_module', __('Could not update plugin module. Id_module cannot be left blank.')); + returnError('The plugin module could not be updated. Id_module cannot be left blank.'); return; } @@ -3609,7 +3607,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3) $id_module_exists = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['nombre' => $module_name, 'id_agente' => $other['data'][0]]); if ($id_module_exists) { - returnError('error_update_plugin_module', __('Could not update plugin module. Id_module exists in the new agent.')); + returnError('The plugin module could not be updated. Id_module exists in the new agent.'); return; } } @@ -3617,7 +3615,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3) // Check if agent exists $check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]); if (!$check_id_agent) { - returnError('error_update_data_module', __('Could not update plugin module. Id_agent does not exist.')); + returnError('The plugin module could not be updated. Id_agent does not exist.'); return; } } @@ -3679,7 +3677,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3) $result_update = modules_update_agent_module($id_module, $values); if ($result_update < 0) { - returnError('error_update_plugin_module', __('Could not update plugin module.')); + returnError('The plugin module could not be updated'); } else { returnData('string', ['type' => 'string', 'data' => __('Plugin module updated.')]); } @@ -3711,7 +3709,7 @@ function api_set_create_data_module($id, $thrash1, $other, $thrash3) } if ($other['data'][0] == '') { - returnError('error_create_data_module', __('Could not create data module. Module_name cannot be left blank.')); + returnError('The data module could not be created. Module_name cannot be left blank.'); return; } @@ -3803,7 +3801,7 @@ function api_set_create_data_module($id, $thrash1, $other, $thrash3) if (is_error($idModule)) { // TODO: Improve the error returning more info. - returnError('error_create_data_module', __('Could not create data module.')); + returnError('The data module could not be created.'); } else { returnData('string', ['type' => 'string', 'data' => $idModule]); } @@ -3835,7 +3833,7 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) io_safe_input_array($other); if ($other['data'][0] == '') { - returnError('error_create_data_module', __('Could not create synthetic module. Module_name cannot be left blank.')); + returnError('The synthetic module could not be created. Module_name cannot be left blank.'); return; } @@ -3858,13 +3856,13 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) if ($agent_by_alias) { foreach ($ids_agents as $id) { if (!$id['id_agente']) { - returnError('error_create_data_module', __('Could not create synthetic module. Agent name does not exist.')); + returnError('The synthetic module could not be created. Agent name does not exist.'); return; } } } else { if (!$idAgent) { - returnError('error_create_data_module', __('Could not create synthetic module. Agent name does not exist.')); + returnError('The synthetic module could not be created. Agent name does not exist.'); return; } } @@ -3894,7 +3892,7 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) if (is_error($idModule)) { // TODO: Improve the error returning more info. - returnError('error_create_data_module', __('Could not create data module.')); + returnError('The synthetic module could not be created.'); } else { $synthetic_type = $other['data'][1]; unset($other['data'][0]); @@ -3909,7 +3907,7 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) if (preg_match('/[x\/+*-]/', $split_data[0]) && strlen($split_data[0]) == 1) { if (preg_match('/[\/|+|*|-]/', $split_data[0]) && $synthetic_type === 'average') { - returnError('', "[ERROR] With this type: $synthetic_type only be allow use this operator: 'x' \n\n"); + returnError(sprintf("[ERROR] With this type: %s only be allow use this operator: 'x' \n\n", $synthetic_type)); } $operator = strtolower($split_data[0]); @@ -3933,12 +3931,12 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) array_push($filterdata, $text_data); } else { if (strlen($split_data[1]) > 1 && $synthetic_type != 'average') { - returnError('', "[ERROR] You can only use +, -, *, / or x, and you use this: @split_data[1] \n\n"); + returnError(sprintf("[ERROR] You can only use +, -, *, / or x, and you use this: %s \n\n", $split_data[1])); return; } if (preg_match('/[\/|+|*|-]/', $split_data[1]) && $synthetic_type === 'average') { - returnError('', "[ERROR] With this type: $synthetic_type only be allow use this operator: 'x' \n\n"); + returnError(sprintf("[ERROR] With this type: %s only be allow use this operator: 'x' \n\n", $synthetic_type)); return; } @@ -3967,7 +3965,7 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) ); if ($synthetic === ENTERPRISE_NOT_HOOK) { - returnError('error_synthetic_modules', 'Error Synthetic modules.'); + returnError('The synthetic module could not be created.'); db_process_sql_delete( 'tagente_modulo', ['id_agente_modulo' => $idModule] @@ -4034,7 +4032,7 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) 'tagente_modulo', ['id_agente_modulo' => $idModule] ); - returnError('error_synthetic_modules', 'Error Synthetic modules.'); + returnError('The synthetic module could not be created.'); } else { db_process_sql('UPDATE tagente SET total_count=total_count+1, notinit_count=notinit_count+1 WHERE id_agente='.(int) $idAgent); returnData('string', ['type' => 'string', 'data' => __('Synthetic module created ID: %s', $idModule)]); @@ -4047,7 +4045,7 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) if (is_error($idModule)) { // TODO: Improve the error returning more info - returnError('error_create_data_module', __('Could not create data module.')); + returnError('The synthetic module could not be created.'); } else { $synthetic_type = $other['data'][1]; unset($other['data'][0]); @@ -4062,7 +4060,7 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) if (preg_match('/[x\/+*-]/', $split_data[0]) && strlen($split_data[0]) == 1) { if (preg_match('/[\/|+|*|-]/', $split_data[0]) && $synthetic_type === 'average') { - returnError('', "[ERROR] With this type: $synthetic_type only be allow use this operator: 'x' \n\n"); + returnError(sprintf("[ERROR] With this type: %s only be allow use this operator: 'x' \n\n", $synthetic_type)); } $operator = strtolower($split_data[0]); @@ -4086,12 +4084,12 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) array_push($filterdata, $text_data); } else { if (strlen($split_data[1]) > 1 && $synthetic_type != 'average') { - returnError('', "[ERROR] You can only use +, -, *, / or x, and you use this: @split_data[1] \n\n"); + returnError(sprintf("[ERROR] You can only use +, -, *, / or x, and you use this: %s \n\n", $split_data[1])); return; } if (preg_match('/[\/|+|*|-]/', $split_data[1]) && $synthetic_type === 'average') { - returnError('', "[ERROR] With this type: $synthetic_type only be allow use this operator: 'x' \n\n"); + returnError(sprintf("[ERROR] With this type: %s only be allow use this operator: 'x' \n\n", $synthetic_type)); return; } @@ -4120,7 +4118,7 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) ); if ($synthetic === ENTERPRISE_NOT_HOOK) { - returnError('error_synthetic_modules', 'Error Synthetic modules.'); + returnError('The synthetic module could not be created.'); db_process_sql_delete( 'tagente_modulo', ['id_agente_modulo' => $idModule] @@ -4187,7 +4185,7 @@ function api_set_create_synthetic_module($id, $agent_by_alias, $other, $thrash3) 'tagente_modulo', ['id_agente_modulo' => $idModule] ); - returnError('error_synthetic_modules', 'Error Synthetic modules.'); + returnError('The synthetic module could not be created.'); } else { db_process_sql('UPDATE tagente SET total_count=total_count+1, notinit_count=notinit_count+1 WHERE id_agente='.(int) $idAgent); returnData('string', ['type' => 'string', 'data' => __('Synthetic module created ID: '.$idModule)]); @@ -4223,7 +4221,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3) } if ($id_module == '') { - returnError('error_update_data_module', __('Could not update data module. Id_module cannot be left blank.')); + returnError('The data module could not be updated. Id_module cannot be left blank.'); return; } @@ -4248,7 +4246,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3) $id_module_exists = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['nombre' => $module_name, 'id_agente' => $other['data'][0]]); if ($id_module_exists) { - returnError('error_update_data_module', __('Could not update data module. Id_module exists in the new agent.')); + returnError('The data module could not be updated. Id_module exists in the new agent.'); return; } } @@ -4256,7 +4254,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3) // Check if agent exists $check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]); if (!$check_id_agent) { - returnError('error_update_data_module', __('Could not update data module. Id_agent does not exist.')); + returnError('The data module could not be updated. Id_agent does not exist.'); return; } } @@ -4305,7 +4303,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3) $result_update = modules_update_agent_module($id_module, $values); if ($result_update < 0) { - returnError('error_update_data_module', 'Could not update data module.'); + returnError('The data module could not be updated.'); } else { returnData('string', ['type' => 'string', 'data' => __('Data module updated.')]); } @@ -4343,12 +4341,12 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3) } if ($other['data'][0] == '') { - returnError('error_create_snmp_module', __('Could not create SNMP module. Module_name cannot be left blank.')); + returnError('The SNMP module could not be created. Module_name cannot be left blank.'); return; } if ($other['data'][2] < 15 or $other['data'][2] > 18) { - returnError('error_create_snmp_module', __('Could not create SNMP module. Invalid id_module_type for a SNMP module.')); + returnError('The SNMP module could not be created. Invalid id_module_type for a SNMP module.'); return; } @@ -4379,17 +4377,17 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3) // SNMP version 3. if ($other['data'][14] == '3') { if ($other['data'][23] != 'AES' and $other['data'][23] != 'DES') { - returnError('error_create_snmp_module', __('Could not create SNMP module. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. ')); + returnError('The SNMP module could not be created.. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. '); return; } if ($other['data'][25] != 'authNoPriv' and $other['data'][25] != 'authPriv' and $other['data'][25] != 'noAuthNoPriv') { - returnError('error_create_snmp_module', __('Could not create SNMP module. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ')); + returnError('The SNMP module could not be created. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. '); return; } if ($other['data'][26] != 'MD5' and $other['data'][26] != 'SHA') { - returnError('error_create_snmp_module', __('Could not create SNMP module. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. ')); + returnError('The SNMP module could not be created. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. '); return; } @@ -4493,7 +4491,7 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3) if (is_error($idModule)) { // TODO: Improve the error returning more info - returnError('error_create_snmp_module', __('Could not create SNMP module.')); + returnError('The SNMP module could not be created.'); } else { returnData('string', ['type' => 'string', 'data' => $idModule]); } @@ -4527,7 +4525,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) } if ($id_module == '') { - returnError('error_update_snmp_module', __('Could not update SNMP module. Id_module cannot be left blank.')); + returnError('The SNMP module could not be updated. Id_module cannot be left blank.'); return; } @@ -4552,7 +4550,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) $id_module_exists = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['nombre' => $module_name, 'id_agente' => $other['data'][0]]); if ($id_module_exists) { - returnError('error_update_snmp_module', __('Could not update SNMP module. Id_module exists in the new agent.')); + returnError('The SNMP module could not be updated. Id_module exists in the new agent.'); return; } } @@ -4560,7 +4558,9 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) // Check if agent exists $check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]); if (!$check_id_agent) { - returnError('error_update_data_module', __('Could not update snmp module. Id_agent does not exist.')); + returnError( + 'The SNMP module could not be updated. Id_agent does not exist.' + ); return; } } @@ -4569,8 +4569,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) if ($other['data'][13] == '3') { if ($other['data'][22] != 'AES' and $other['data'][22] != 'DES') { returnError( - 'error_create_snmp_module', - __('Error in creation SNMP module. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. ') + 'The SNMP module could not be updated. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. ' ); return; } @@ -4580,16 +4579,14 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) and $other['data'][24] != 'noAuthNoPriv' ) { returnError( - 'error_create_snmp_module', - __('Error in creation SNMP module. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ') + 'The SNMP module could not be updated. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ' ); return; } if ($other['data'][25] != 'MD5' and $other['data'][25] != 'SHA') { returnError( - 'error_create_snmp_module', - __('Error in creation SNMP module. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. ') + 'The SNMP module could not be updated. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. ' ); return; } @@ -4679,7 +4676,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) $result_update = modules_update_agent_module($id_module, $values); if ($result_update < 0) { - returnError('error_update_snmp_module', 'Could not update SNMP module.'); + returnError('The SNMP module could not be updated.'); } else { returnData('string', ['type' => 'string', 'data' => __('SNMP module updated.')]); } @@ -4717,17 +4714,17 @@ function api_set_new_network_component($id, $thrash1, $other, $thrash2) } if ($id == '') { - returnError('error_set_new_network_component', __('Could not create network component. Network component name cannot be left blank.')); + returnError('The network component could not be created. Network component name cannot be left blank.'); return; } if ($other['data'][0] < 6 or $other['data'][0] > 18) { - returnError('error_set_new_network_component', __('Could not create network component. Incorrect value for Network component type field.')); + returnError('The network component could not be created. Incorrect value for Network component type field.'); return; } if ($other['data'][17] == '') { - returnError('error_set_new_network_component', __('Could not create network component. Network component group cannot be left blank.')); + returnError('The network component could not be created. Network component group cannot be left blank.'); return; } @@ -4765,14 +4762,14 @@ function api_set_new_network_component($id, $thrash1, $other, $thrash2) $name_check = db_get_value('name', 'tnetwork_component', 'name', $id); if ($name_check !== false) { - returnError('error_set_new_network_component', __('Could not create network component. This network component already exist.')); + returnError('The network component could not be created. This network component already exist.'); return; } $id = network_components_create_network_component($id, $other['data'][0], $other['data'][17], $values); if (!$id) { - returnError('error_set_new_network_component', 'Could not create network component.'); + returnError('The network component could not be created.'); } else { returnData('string', ['type' => 'string', 'data' => $id]); } @@ -4812,19 +4809,22 @@ function api_set_new_plugin_component($id, $thrash1, $other, $thrash2) if ($id == '') { returnError( - 'error_set_new_plugin_component', - __('Could not create plugin component. Plugin component name cannot be left blank.') + 'The plugin component could not be created. Plugin component name cannot be left blank.' ); return; } if ($other['data'][7] == '') { - returnError('error_set_new_plugin_component', __('Could not create plugin component. Incorrect value for Id plugin.')); + returnError( + 'The plugin component could not be created. Incorrect value for Id plugin.' + ); return; } if ($other['data'][21] == '') { - returnError('error_set_new_plugin_component', __('Could not create plugin component. Plugin component group cannot be left blank.')); + returnError( + 'The plugin component could not be created. Plugin component group cannot be left blank.' + ); return; } @@ -4866,14 +4866,14 @@ function api_set_new_plugin_component($id, $thrash1, $other, $thrash2) $name_check = db_get_value('name', 'tnetwork_component', 'name', $id); if ($name_check !== false) { - returnError('error_set_new_plugin_component', __('Could not create plugin component. This plugin component already exist.')); + returnError('The plugin component could not be created. This plugin component already exist.'); return; } $id = network_components_create_network_component($id, $other['data'][0], $other['data'][21], $values); if (!$id) { - returnError('error_set_new_plugin_component', 'Could not create plugin component.'); + returnError('The plugin component could not be created.'); } else { returnData('string', ['type' => 'string', 'data' => $id]); } @@ -4908,7 +4908,7 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) } if ($id == '') { - returnError('error_set_new_snmp_component', __('Could not create SNMP component. SNMP component name cannot be left blank.')); + returnError('The SNMP component could not be created. SNMP component name cannot be left blank.'); return; } @@ -4918,12 +4918,12 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) } if ($other['data'][0] < 15 or $other['data'][0] > 17) { - returnError('error_set_new_snmp_component', __('Could not create SNMP component. Incorrect value for Snmp component type field.')); + returnError('The SNMP component could not be created. Incorrect value for Snmp component type field.'); return; } if ($other['data'][25] == '') { - returnError('error_set_new_snmp_component', __('Could not create SNMP component. Snmp component group cannot be left blank.')); + returnError('The SNMP component could not be created. Snmp component group cannot be left blank.'); return; } @@ -4934,7 +4934,9 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) // SNMP version 3 if ($other['data'][16] == '3') { if ($other['data'][22] != 'AES' and $other['data'][22] != 'DES') { - returnError('error_set_new_snmp_component', __('Could not create SNMP component. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. ')); + returnError( + 'The SNMP component could not be created. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. ' + ); return; } @@ -4943,16 +4945,14 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) and $other['data'][25] != 'noAuthNoPriv' ) { returnError( - 'error_set_new_snmp_component', - __('Could not create SNMP component. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ') + 'The SNMP component could not be created. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ' ); return; } if ($other['data'][24] != 'MD5' and $other['data'][24] != 'SHA') { returnError( - 'error_set_new_snmp_component', - __('Could not create SNMP component. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. ') + 'The SNMP component could not be created. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. ' ); return; } @@ -5035,14 +5035,14 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) $name_check = db_get_value('name', 'tnetwork_component', 'name', $id); if ($name_check !== false) { - returnError('error_set_new_snmp_component', __('Could not create SNMP component. This SNMP component already exist.')); + returnError('The SNMP component could not be created. This SNMP component already exist.'); return; } $id = network_components_create_network_component($id, $other['data'][0], $other['data'][26], $values); if (!$id) { - returnError('error_set_new_snmp_component', 'Could not create SNMP component.'); + returnError('The SNMP component could not be created.'); } else { returnData('string', ['type' => 'string', 'data' => $id]); } @@ -5076,8 +5076,7 @@ function api_set_new_local_component($id, $thrash1, $other, $thrash2) if ($id == '') { returnError( - 'error_set_new_local_component', - __('Could not create local component. Local component name cannot be left blank.') + 'The local component could not be created. Local component name cannot be left blank.' ); return; } @@ -5089,8 +5088,7 @@ function api_set_new_local_component($id, $thrash1, $other, $thrash2) if ($other['data'][1] == '') { returnError( - 'error_set_new_local_component', - __('Could not create local component. Local component group cannot be left blank.') + 'The local component could not be created. Local component group cannot be left blank.' ); return; } @@ -5122,16 +5120,14 @@ function api_set_new_local_component($id, $thrash1, $other, $thrash2) if ($name_check === ENTERPRISE_NOT_HOOK) { returnError( - 'error_set_new_local_component', - __('Could not create local component.') + 'The local component could not be created.' ); return; } if ($name_check !== false) { returnError( - 'error_set_new_local_component', - __('Could not create local component. This local component already exist.') + 'The local component could not be created. This local component already exist.' ); return; } @@ -5147,7 +5143,7 @@ function api_set_new_local_component($id, $thrash1, $other, $thrash2) ); if (!$id) { - returnError('error_set_new_local_component', 'Could not create local component.'); + returnError('The local component could not be created.'); } else { returnData('string', ['type' => 'string', 'data' => $id]); } @@ -5175,8 +5171,7 @@ function api_get_module_value_all_agents($id, $thrash1, $other, $thrash2) if ($id == '') { returnError( - 'error_get_module_value_all_agents', - __('Failed to get module value from all agents. Module name cannot be left blank.') + 'Could not get the module value from all agents. Module name cannot be left blank.' ); return; } @@ -5185,8 +5180,7 @@ function api_get_module_value_all_agents($id, $thrash1, $other, $thrash2) if ($id_module === false) { returnError( - 'error_get_module_value_all_agents', - __('Failed to get module value from all agents. Module name does not exist.') + 'Could not get the module value from all agents. Module name does not exist.' ); return; } @@ -5209,7 +5203,7 @@ function api_get_module_value_all_agents($id, $thrash1, $other, $thrash2) $module_values = db_get_all_rows_sql($sql); if (!$module_values) { - returnError('error_get_module_value_all_agents', 'Could not get module values from all agents.'); + returnError('Could not get module values from all agents.'); } else { $data = [ 'type' => 'array', @@ -5248,8 +5242,7 @@ function api_set_create_alert_template($name, $thrash1, $other, $thrash3) if ($name == '') { returnError( - 'error_create_alert_template', - __('Could not create alert template. Template name cannot be left blank.') + 'The alert template could not be created. Template name cannot be left blank.' ); return; } @@ -5321,7 +5314,7 @@ function api_set_create_alert_template($name, $thrash1, $other, $thrash3) if (is_error($id_template)) { // TODO: Improve the error returning more info - returnError('error_create_alert_template', __('Could not create alert template.')); + returnError('The alert template could not be created.'); } else { returnData('string', ['type' => 'string', 'data' => $id_template]); } @@ -5360,8 +5353,7 @@ function api_set_update_alert_template($id_template, $thrash1, $other, $thrash3) if ($id_template == '') { returnError( - 'error_update_alert_template', - __('Could not update alert template. Id_template cannot be left blank.') + 'The alert template could not be updated. Id_template cannot be left blank.' ); return; } @@ -5370,8 +5362,7 @@ function api_set_update_alert_template($id_template, $thrash1, $other, $thrash3) if (!$result_template) { returnError( - 'error_update_alert_template', - __('Could not update alert template. Id_template does not exist.') + 'The alert template could not be updated. Id_template does not exist.' ); return; } @@ -5421,8 +5412,7 @@ function api_set_update_alert_template($id_template, $thrash1, $other, $thrash3) if (is_error($id_template)) { // TODO: Improve the error returning more info returnError( - 'error_create_alert_template', - __('Could not update alert template.') + 'The alert template could not be updated.' ); } else { returnData( @@ -5457,8 +5447,7 @@ function api_set_delete_alert_template($id_template, $thrash1, $other, $thrash3) if ($id_template == '') { returnError( - 'error_delete_alert_template', - __('Could not delete alert template. Id_template cannot be left blank.') + 'The alert template could not be deleted. Id_template cannot be left blank.' ); return; } @@ -5468,8 +5457,7 @@ function api_set_delete_alert_template($id_template, $thrash1, $other, $thrash3) if ($result == 0) { // TODO: Improve the error returning more info returnError( - 'error_create_alert_template', - __('Could not delete alert template.') + 'The alert template could not be deleted.' ); } else { returnData( @@ -5526,8 +5514,7 @@ function api_get_all_alert_templates($thrash1, $thrash2, $other, $thrash3) if (!$template) { returnError( - 'error_get_all_alert_templates', - __('Could not get all alert templates.') + 'Could not get all alert templates' ); } else { returnData('csv', $data, $separator); @@ -5571,8 +5558,7 @@ function api_get_all_alert_commands($thrash1, $thrash2, $other, $thrash3) if (!$commands) { returnError( - 'error_get_all_alert_commands', - __('Could not get all alert commands.') + 'Could not get all alert commands.' ); } else { returnData('csv', $data, $separator); @@ -5606,8 +5592,7 @@ function api_get_alert_template($id_template, $thrash1, $other, $thrash3) if (!$result_template) { returnError( - 'error_get_alert_template', - __('Could not get alert template. Id_template does not exist.') + 'Could not get alert template. Id_template does not exist.' ); return; } @@ -5634,8 +5619,7 @@ function api_get_alert_template($id_template, $thrash1, $other, $thrash3) if (!$template) { returnError( - 'error_get_alert_template', - __('Could not get alert template.') + 'Could not get alert template' ); } else { returnData('csv', $data, ';'); @@ -5698,8 +5682,7 @@ function api_get_alert_actions($thrash1, $thrash2, $other, $returnType) if (!$actions) { returnError( - 'error_get_alert_actions', - __('Could not get alert actions.') + 'Could not get alert actions.' ); } else { returnData($returnType, $data, $separator); @@ -5749,7 +5732,7 @@ function api_get_module_groups($thrash1, $thrash2, $other, $thrash3) } if (!$module_groups) { - returnError('error_get_module_groups', __('Could not get module groups.')); + returnError('Could not get module groups.'); } else { returnData('csv', $data, $separator); } @@ -5813,7 +5796,7 @@ function api_get_plugins($thrash1, $thrash2, $other, $thrash3) } if (!$plugins) { - returnError('error_get_plugins', __('Could not get plugins.')); + returnError('Could not get plugins.'); } else { returnData('csv', $data, $separator); } @@ -5861,13 +5844,13 @@ function api_set_create_network_module_from_component($agent_name, $component_na if ($agent_by_alias) { foreach ($ids_agents as $id) { if (!$id['id_agente']) { - returnError('error_network_module_from_component', __('Could not create module from network component. Agent does not exist.')); + returnError('The network component could not be created. Agent does not exist.'); return; } } } else { if (!$agent_id) { - returnError('error_network_module_from_component', __('Could not create module from network component. Agent does not exist.')); + returnError('The network component could not be created. Agent does not exist.'); return; } } @@ -5875,7 +5858,7 @@ function api_set_create_network_module_from_component($agent_name, $component_na $component = db_get_row('tnetwork_component', 'name', $component_name); if (!$component) { - returnError('error_network_module_from_component', __('Could not create module from network component. Network component does not exist.')); + returnError('The network component could not be created. Network component does not exist.'); return; } @@ -5907,7 +5890,7 @@ function api_set_create_network_module_from_component($agent_name, $component_na $module_id = modules_create_agent_module($agent_id, $component_name, $component, true); if (!$module_id) { - returnError('error_network_module_from_component', __('Could not create module from network component.')); + returnError('The network component could not be created.'); return; } @@ -5937,24 +5920,21 @@ function api_set_create_module_template($id, $thrash1, $other, $thrash3) if ($id == '') { returnError( - 'error_module_to_template', - __('Could not assign module to template. Id_template cannot be left blank.') + 'The module template could not be assigned. Id_template cannot be left blank.' ); return; } if ($other['data'][0] == '') { returnError( - 'error_module_to_template', - __('Could not assign module to template. Id_module cannot be left blank.') + 'The module template could not be assigned. Id_module cannot be left blank.' ); return; } if ($other['data'][1] == '') { returnError( - 'error_module_to_template', - __('Could not assign module to template. Id_agent cannot be left blank.') + 'The module template could not be assigned. Id_agent cannot be left blank.' ); return; } @@ -5970,8 +5950,7 @@ function api_set_create_module_template($id, $thrash1, $other, $thrash3) if (!$result_template) { returnError( - 'error_module_to_template', - __('Could not assign module to template. Id_template does not exist.') + 'The module template could not be assigned. Id_template does not exist.' ); return; } @@ -5979,14 +5958,18 @@ function api_set_create_module_template($id, $thrash1, $other, $thrash3) $result_agent = agents_get_name($id_agent); if (!$result_agent) { - returnError('error_module_to_template', __('Could not assign module to template. Id_agent does not exist.')); + returnError( + 'The module template could not be assigned. Id_agent does not exist.' + ); return; } $result_module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', (int) $id_module); if (!$result_module) { - returnError('error_module_to_template', __('Could not assign module to template. Id_module does not exist.')); + returnError( + 'The module template could not be assigned. Id_module does not exist.' + ); return; } @@ -5994,7 +5977,9 @@ function api_set_create_module_template($id, $thrash1, $other, $thrash3) if (is_error($id_template_module)) { // TODO: Improve the error returning more info - returnError('error_module_to_template', __('Could not assign module to template.')); + returnError( + 'The module template could not be assigned.' + ); } else { returnData('string', ['type' => 'string', 'data' => $id_template_module]); } @@ -6028,14 +6013,14 @@ function api_set_delete_module_template($id, $thrash1, $other, $thrash3) } if ($id == '') { - returnError('error_delete_module_template', __('Could not delete module template. Id_module_template cannot be left blank.')); + returnError('The module template could not deleted. Id_module_template cannot be left blank.'); return; } $result_module_template = alerts_get_alert_agent_module($id); if (!$result_module_template) { - returnError('error_delete_module_template', __('Could not delete module template. Id_module_template does not exist.')); + returnError('The module template could not deleted. Id_module_template does not exist.'); return; } @@ -6043,7 +6028,7 @@ function api_set_delete_module_template($id, $thrash1, $other, $thrash3) if ($result == 0) { // TODO: Improve the error returning more info - returnError('error_delete_module_template', __('Could not delete module template.')); + returnError('The module template could not deleted.'); } else { returnData('string', ['type' => 'string', 'data' => __('Correct deleting of module template.')]); } @@ -6104,7 +6089,7 @@ function api_set_delete_module_template_by_names($id, $id2, $other, $trash1) $row = db_get_row_filter('talert_templates', ['name' => $id2]); if ($row === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } @@ -6133,12 +6118,12 @@ function api_set_delete_module_template_by_names($id, $id2, $other, $trash1) } } - returnError('error_delete_module_template_by_name', __('Module template has been deleted in %d agents.', $delete_count)); + returnError(sprintf('Module template has been deleted in %d agents.', $delete_count)); } else { $idAgentModule = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['id_agente' => $idAgent, 'nombre' => $other['data'][0]]); if ($idAgentModule === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } @@ -6151,7 +6136,7 @@ function api_set_delete_module_template_by_names($id, $id2, $other, $trash1) if ($result == 0) { // TODO: Improve the error returning more info - returnError('error_delete_module_template_by_name', __('Could not delete module template.')); + returnError('The module template could not deleted'); } else { returnData('string', ['type' => 'string', 'data' => __('Successful delete of module template.')]); } @@ -6226,7 +6211,7 @@ function api_set_validate_all_alerts($id, $thrash1, $other, $thrash3) if ($total_alerts > $count_results) { $errors = ($total_alerts - $count_results); - returnError('error_validate_all_alerts', __('Failed to validate all alerts. Failed '.$errors.'.')); + returnError(sprintf('Could not validate all alerts. Failed %d', $errors)); } else { returnData('string', ['type' => 'string', 'data' => __('Correct validation of all alerts (total %d).', $count_results)]); } @@ -6263,7 +6248,7 @@ function api_set_validate_all_policy_alerts($id, $thrash1, $other, $thrash3) $policies = enterprise_hook('policies_get_policies', [false, false, false]); if ($duplicated === ENTERPRISE_NOT_HOOK) { - returnError('error_validate_all_policy_alerts', __('Failed to validate all alert policies.')); + returnError('Could not validate all of alert policies.'); return; } @@ -6320,7 +6305,7 @@ function api_set_validate_all_policy_alerts($id, $thrash1, $other, $thrash3) // Check results if ($total_alerts > $count_results) { $errors = ($total_alerts - $count_results); - returnError('error_validate_all_alerts', __('Failed to validate all policy alerts. Failed '.$errors.'.')); + returnError(sprintf('Could not validate all policy alerts. Failed %s', $errors)); } else { returnData('string', ['type' => 'string', 'data' => __('Correct validation of all policy alerts.')]); } @@ -6354,7 +6339,7 @@ function api_set_stop_downtime($id, $thrash1, $other, $thrash3) } if ($id == '') { - returnError('error_stop_downtime', __('Failed to stop downtime. Id_downtime cannot be left blank.')); + returnError('Could not stop scheduled downtime. Id_downtime cannot be left blank.'); return; } @@ -6365,9 +6350,9 @@ function api_set_stop_downtime($id, $thrash1, $other, $thrash3) $result_update = db_process_sql_update('tplanned_downtime', $values, ['id' => $id]); if ($result_update == 0) { - returnError('error_stop_downtime', __('No action has been taken.')); + returnError('No action has been taken.'); } else if ($result_update < 0) { - returnError('error_stop_downtime', __('Could not stop downtime.')); + returnError('Could not stop downtime.'); } else { returnData('string', ['type' => 'string', 'data' => __('Downtime stopped.')]); } @@ -6414,7 +6399,7 @@ function api_set_add_tag_module($id, $id2, $thrash1, $thrash2) } if (empty($exists)) { - returnError('error_set_tag_module', 'Failed to set tag module.'); + returnError('The tag module could not be setted.'); } else { returnData( 'string', @@ -6496,7 +6481,7 @@ function api_set_tag($id, $thrash1, $other, $thrash3) $id_tag = tags_create_tag($values); if (empty($id_tag)) { - returnError('error_set_tag', __('Failed to set tag.')); + returnError('The tag could not be setted.'); } else { returnData( 'string', @@ -6558,7 +6543,7 @@ function api_get_all_planned_downtimes($thrash1, $thrash2, $other, $returnType=' $returned = all_planned_downtimes($values); if ($returned === false) { - returnError('error_get_all_planned_downtimes', __('Planned downtime was not retrieved')); + returnError('Planned downtime was not retrieved'); return; } @@ -6780,7 +6765,7 @@ function api_set_planned_downtimes_created($id, $thrash1, $other, $thrash3) $returned = planned_downtimes_created($values); if (!$returned['return']) { - returnError('error_set_planned_downtime', $returned['message']); + returnError($returned['message']); } else { returnData( 'string', @@ -6842,7 +6827,7 @@ function api_set_planned_downtimes_additem($id, $thrash1, $other, $thrash3) } if (empty($agents)) { - returnError('error_set_planned_downtime_additem', 'No agents to create planned downtime items'); + returnError('No agents to create planned downtime items'); } else { if (!empty($returned['bad_modules'])) { $bad_modules = __("and this modules are doesn't exists or not applicable a this agents: ").implode(', ', $returned['bad_modules']); @@ -6893,7 +6878,7 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3) } if ($id == '') { - returnError('error_add_data_module_policy', __('Could not add data module to policy. Id_policy cannot be left blank.')); + returnError('The data module could not be added to policy. Id_policy cannot be left blank.'); return; } @@ -6903,7 +6888,7 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3) } if ($other['data'][0] == '') { - returnError('error_add_data_module_policy', __('Could not add data module to policy. Module_name cannot be left blank.')); + returnError('The data module could not be added to policy. Module_name cannot be left blank.'); return; } @@ -6911,7 +6896,7 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3) $name_module_policy = enterprise_hook('policies_get_modules', [$id, ['name' => $other['data'][0]], 'name']); if ($name_module_policy === ENTERPRISE_NOT_HOOK) { - returnError('error_add_data_module_policy', __('Could not add data module to policy.')); + returnError('The data module could not be added to policy.'); return; } @@ -6948,8 +6933,7 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3) if ($name_module_policy !== false) { if ($name_module_policy[0]['name'] == $other['data'][0]) { returnError( - 'error_add_data_module_policy', - __('Could not add data module to policy. The module is already in the policy.') + 'The data module could not be added to policy. The module is already in the policy.' ); return; } @@ -6970,7 +6954,7 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3) // returnData('string', array('type' => 'string', 'data' => __('Data module added to policy. Is necessary to apply the policy in order to changes take effect.'))); returnData('string', ['type' => 'string', 'data' => $success]); } else { - returnError('error_add_data_module_policy', 'Could not add data module to policy.'); + returnError('The data module could not be added to policy.'); } } @@ -7001,7 +6985,9 @@ function api_set_update_data_module_policy($id, $thrash1, $other, $thrash3) } if ($id == '') { - returnError('error_update_data_module_policy', __('Could not update data module in policy. Id_policy cannot be left blank.')); + returnError( + 'The data module could not be updated in policy. Id_policy cannot be left blank.' + ); return; } @@ -7010,7 +6996,9 @@ function api_set_update_data_module_policy($id, $thrash1, $other, $thrash3) } if ($other['data'][0] == '') { - returnError('error_update_data_module_policy', __('Could not update data module in policy. Id_policy_module cannot be left blank.')); + returnError( + 'The data module could not be updated in policy. Id_policy_module cannot be left blank.' + ); return; } @@ -7018,14 +7006,15 @@ function api_set_update_data_module_policy($id, $thrash1, $other, $thrash3) $module_policy = enterprise_hook('policies_get_modules', [$id, ['id' => $other['data'][0]], 'id_module']); if ($module_policy === false) { - returnError('error_update_data_module_policy', __('Could not update data module in policy. Module does not exist.')); + returnError( + 'The data module could not be updated in policy. Module does not exist.' + ); return; } if ($module_policy[0]['id_module'] != 1) { returnError( - 'error_update_data_module_policy', - __('Could not update data module in policy. Module type is not network type.') + 'The data module could not be updated in policy. Module type is not network type.' ); return; } @@ -7069,7 +7058,7 @@ function api_set_update_data_module_policy($id, $thrash1, $other, $thrash3) ); if ($result_update < 0) { - returnError('error_update_data_module_policy', 'Could not update policy module.'); + returnError('The data module could not be updated in policy.'); } else { returnData( 'string', @@ -7109,8 +7098,7 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) if ($id == '') { returnError( - 'error_network_data_module_policy', - __('Could not add network module to policy. Id_policy cannot be left blank.') + 'The network module could not be added to policy. Id_policy cannot be left blank.' ); return; } @@ -7122,16 +7110,14 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) if ($other['data'][0] == '') { returnError( - 'error_network_data_module_policy', - __('Could not add network module to policy. Module_name cannot be left blank.') + 'The network module could not be added to policy. Module_name cannot be left blank.' ); return; } if ($other['data'][1] < 6 or $other['data'][1] > 18) { returnError( - 'error_network_data_module_policy', - __('Could not add network module to policy. Id_module_type is not correct for network modules.') + 'The network module could not be added to policy. Id_module_type is not correct for network modules.' ); return; } @@ -7147,10 +7133,7 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) ); if ($name_module_policy === ENTERPRISE_NOT_HOOK) { - returnError( - 'error_network_data_module_policy', - __('Could not add network module to policy.') - ); + returnError('The network module could not be added to policy.'); return; } @@ -7189,7 +7172,7 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) if ($name_module_policy !== false) { if ($name_module_policy[0]['name'] == $other['data'][0]) { - returnError('error_network_data_module_policy', __('Could not add network module to policy. The module is already in the policy.')); + returnError('The network module could not be added to policy. The module is already in the policy.'); return; } } @@ -7199,7 +7182,7 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) if ($success) { returnData('string', ['type' => 'string', 'data' => $success]); } else { - returnError('error_add_network_module_policy', 'Could not add network module to policy.'); + returnError('The network module could not be added to policy.'); } } @@ -7230,16 +7213,14 @@ function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3) if ($id == '') { returnError( - 'error_update_network_module_policy', - __('Could not update network module in policy. Id_policy cannot be left blank.') + 'The network module could not be updated in policy. Id_policy cannot be left blank.' ); return; } if ($other['data'][0] == '') { returnError( - 'error_update_network_module_policy', - __('Could not update network module in policy. Id_policy_module cannot be left blank.') + 'The network module could not be updated in policy. Id_policy_module cannot be left blank.' ); return; } @@ -7249,16 +7230,14 @@ function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3) if ($module_policy === false) { returnError( - 'error_update_network_module_policy', - __('Could not update network module in policy. Module does not exist.') + 'The network module could not be updated in policy. Module does not exist.' ); return; } if ($module_policy[0]['id_module'] != 2) { returnError( - 'error_update_network_module_policy', - __('Could not update network module in policy. Module type is not network type.') + 'The network module could not be updated in policy. Module type is not network type.' ); return; } @@ -7300,7 +7279,7 @@ function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3) $result_update = enterprise_hook('policies_update_module', [$other['data'][0], $values, false]); if ($result_update < 0) { - returnError('error_update_network_module_policy', 'Could not update policy module.'); + returnError('The network module could not be updated in policy.'); } else { returnData('string', ['type' => 'string', 'data' => __('Network policy module updated.')]); } @@ -7332,7 +7311,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) } if ($id == '') { - returnError('error_add_plugin_module_policy', __('Could not add plugin module to policy. Id_policy cannot be left blank.')); + returnError('The plugin module could not be added. Id_policy cannot be left blank.'); return; } @@ -7342,12 +7321,12 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) } if ($other['data'][0] == '') { - returnError('error_add_plugin_module_policy', __('Could not add plugin module to policy. Module_name cannot be left blank.')); + returnError('The plugin module could not be added. Module_name cannot be left blank.'); return; } if ($other['data'][22] == '') { - returnError('error_add_plugin_module_policy', __('Could not add plugin module to policy. Id_plugin cannot be left blank.')); + returnError('The plugin module could not be added. Id_plugin cannot be left blank.'); return; } @@ -7355,7 +7334,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) $name_module_policy = enterprise_hook('policies_get_modules', [$id, ['name' => $other['data'][0]], 'name']); if ($name_module_policy === ENTERPRISE_NOT_HOOK) { - returnError('error_add_plugin_module_policy', __('Could not add plugin module to policy.')); + returnError('The plugin module could not be added.'); return; } @@ -7399,7 +7378,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) if ($name_module_policy !== false) { if ($name_module_policy[0]['name'] == $other['data'][0]) { - returnError('error_add_plugin_module_policy', __('Could not add plugin module to policy. The module is already in the policy.')); + returnError('The plugin module could not be added. The module is already in the policy.'); return; } } @@ -7409,7 +7388,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) if ($success) { returnData('string', ['type' => 'string', 'data' => $success]); } else { - returnError('error_add_plugin_module_policy', 'Could not add plugin module to policy.'); + returnError('The plugin module could not be added.'); } } @@ -7441,16 +7420,14 @@ function api_set_update_plugin_module_policy($id, $thrash1, $other, $thrash3) if ($id == '') { returnError( - 'error_update_plugin_module_policy', - __('Could not update plugin module in policy. Id_policy cannot be left blank.') + 'The plugin module could not be updated in policy. Id_policy cannot be left blank.' ); return; } if ($other['data'][0] == '') { returnError( - 'error_update_plugin_module_policy', - __('Could not update plugin module in policy. Id_policy_module cannot be left blank.') + 'The plugin module could not be updated in policy. Id_policy_module cannot be left blank.' ); return; } @@ -7460,16 +7437,14 @@ function api_set_update_plugin_module_policy($id, $thrash1, $other, $thrash3) if ($module_policy === false) { returnError( - 'error_updating_plugin_module_policy', - __('Could not update plugin module in policy. Module does not exist.') + 'The plugin module could not be updated in policy. Module does not exist.' ); return; } if ($module_policy[0]['id_module'] != 4) { returnError( - 'error_updating_plugin_module_policy', - __('Could not update plugin module in policy. Module type is not network type.') + 'The plugin module could not be updated in policy. Module type is not network type.' ); return; } @@ -7527,7 +7502,7 @@ function api_set_update_plugin_module_policy($id, $thrash1, $other, $thrash3) ); if ($result_update < 0) { - returnError('error_update_plugin_module_policy', 'Could not update policy module.'); + returnError('The plugin module could not be updated in policy.'); } else { returnData('string', ['type' => 'string', 'data' => __('Plugin policy module updated.')]); } @@ -7565,7 +7540,7 @@ function api_set_add_module_in_conf($id_agent, $module_name, $configuration_data // If exists a module with same name, abort. if (!empty($old_configuration_data)) { - returnError('error_adding_module_conf', '-2'); + returnError('-2'); exit; } @@ -7574,7 +7549,7 @@ function api_set_add_module_in_conf($id_agent, $module_name, $configuration_data if ($result && $result !== ENTERPRISE_NOT_HOOK) { returnData('string', ['type' => 'string', 'data' => '0']); } else { - returnError('error_adding_module_conf', '-1'); + returnError('-1'); } } @@ -7615,7 +7590,7 @@ function api_get_module_from_conf($id_agent, $module_name, $thrash2, $thrash3) if ($result !== ENTERPRISE_NOT_HOOK && !empty($result)) { returnData('string', ['type' => 'string', 'data' => $result]); } else { - returnError('error_adding_module_conf', __('Remote config of module %s is not available', $module_name)); + returnError(sprintf('Remote config of module %s is not available', $module_name)); } } @@ -7651,7 +7626,7 @@ function api_set_delete_module_in_conf($id_agent, $module_name, $thrash2, $thras if ($result && $result !== ENTERPRISE_NOT_HOOK) { returnData('string', ['type' => 'string', 'data' => '0']); } else { - returnError('error_deleting_module_conf', '-1'); + returnError('-1'); } } @@ -7687,7 +7662,7 @@ function api_set_update_module_in_conf($id_agent, $module_name, $configuration_d // If not exists if (empty($old_configuration_data)) { - returnError('error_editing_module_conf', '-2'); + returnError('-2'); exit; } @@ -7702,7 +7677,7 @@ function api_set_update_module_in_conf($id_agent, $module_name, $configuration_d if ($result && $result !== ENTERPRISE_NOT_HOOK) { returnData('string', ['type' => 'string', 'data' => '0']); } else { - returnError('error_editing_module_conf', '-1'); + returnError('-1'); } } @@ -7732,7 +7707,7 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) } if ($id == '') { - returnError('error_add_snmp_module_policy', __('Could not add SNMP module to policy. Id_policy cannot be left blank.')); + returnError('The SNMP module could not be added to policy. Id_policy cannot be left blank.'); return; } @@ -7742,7 +7717,7 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) } if ($other['data'][0] == '') { - returnError('error_add_snmp_module_policy', __('Could not add SNMP module to policy. Module_name cannot be left blank.')); + returnError('The SNMP module could not be added to policy. Module_name cannot be left blank.'); return; } @@ -7750,12 +7725,12 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) $name_module_policy = enterprise_hook('policies_get_modules', [$id, ['name' => $other['data'][0]], 'name']); if ($name_module_policy === ENTERPRISE_NOT_HOOK) { - returnError('error_add_snmp_module_policy', __('Could not add SNMP module to policy.')); + returnError('The SNMP module could not be added to policy.'); return; } if ($other['data'][2] < 15 or $other['data'][2] > 18) { - returnError('error_add_snmp_module_policy', __('Could not add SNMP module to policy. Id_module_type is not correct for SNMP modules.')); + returnError('The SNMP module could not be added to policy. Id_module_type is not correct for SNMP modules.'); return; } @@ -7766,17 +7741,17 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) // SNMP version 3 if ($other['data'][13] == '3') { if ($other['data'][22] != 'AES' and $other['data'][22] != 'DES') { - returnError('error_add_snmp_module_policy', __('Error in creation SNMP module. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. ')); + returnError('The SNMP module could not be added to policy. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. '); return; } if ($other['data'][24] != 'authNoPriv' and $other['data'][24] != 'authPriv' and $other['data'][24] != 'noAuthNoPriv') { - returnError('error_add_snmp_module_policy', __('Error in creation SNMP module. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ')); + returnError('The SNMP module could not be added to policy. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. '); return; } if ($other['data'][25] != 'MD5' and $other['data'][25] != 'SHA') { - returnError('error_add_snmp_module_policy', __('Error in creation SNMP module. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. ')); + returnError('The SNMP module could not be added to policy. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. '); return; } @@ -7849,7 +7824,7 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) if ($name_module_policy !== false) { if ($name_module_policy[0]['name'] == $other['data'][0]) { - returnError('error_add_snmp_module_policy', __('Could not add SNMP module to policy. The module is already in the policy.')); + returnError('The SNMP module could not be added to policy. The module is already in the policy.'); return; } } @@ -7859,7 +7834,7 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) if ($success) { returnData('string', ['type' => 'string', 'data' => $success]); } else { - returnError('error_add_snmp_module_policy', 'Could not add SNMP module to policy.'); + returnError('The SNMP module could not be added to policy'); } } @@ -7891,12 +7866,12 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) } if ($id == '') { - returnError('error_update_snmp_module_policy', __('Could not update SNMP module in policy. Id_policy cannot be left blank.')); + returnError('The SNMP module could not be updated in policy. Id_policy cannot be left blank.'); return; } if ($other['data'][0] == '') { - returnError('error_update_snmp_module_policy', __('Could not update SNMP module in policy. Id_policy_module cannot be left blank.')); + returnError('The SNMP module could not be updated in policy. Id_policy_module cannot be left blank.'); return; } @@ -7904,12 +7879,12 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) $module_policy = enterprise_hook('policies_get_modules', [$id, ['id' => $other['data'][0]], 'id_module']); if ($module_policy === false) { - returnError('error_update_snmp_module_policy', __('Could not update SNMP module in policy. Module does not exist.')); + returnError('The SNMP module could not be updated in policy. Module does not exist.'); return; } if ($module_policy[0]['id_module'] != 2) { - returnError('error_update_snmp_module_policy', __('Could not update SNMP module in policy. Module type is not SNMP type.')); + returnError('The SNMP module could not be updated in policy. Module type is not SNMP type.'); return; } @@ -7917,20 +7892,18 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) if ($other['data'][12] == '3') { if ($other['data'][21] != 'AES' and $other['data'][21] != 'DES') { returnError( - 'error_update_snmp_module_policy', - __('Could not update SNMP module. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. ') + 'The SNMP module could not be updated in policy. snmp3_priv_method does not exist. Set it to \'AES\' or \'DES\'. ' ); return; } if ($other['data'][23] != 'authNoPriv' - and $other['data'][23] != 'authPriv' - and $other['data'][23] != 'noAuthNoPriv' + && $other['data'][23] != 'authPriv' + && $other['data'][23] != 'noAuthNoPriv' ) { returnError( - 'error_update_snmp_module_policy', - __('Could not update SNMP module. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ') + 'The SNMP module could not be updated in policy. snmp3_sec_level does not exist. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ' ); return; @@ -7938,8 +7911,7 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) if ($other['data'][24] != 'MD5' and $other['data'][24] != 'SHA') { returnError( - 'error_update_snmp_module_policy', - __('Could not update SNMP module. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. ') + 'The SNMP module could not be updated in policy. snmp3_auth_method does not exist. Set it to \'MD5\' or \'SHA\'. ' ); return; @@ -8019,7 +7991,7 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) ); if ($result_update < 0) { - returnError('error_update_snmp_module_policy', 'Could not update policy module.'); + returnError('The SNMP module could not be updated in policy'); } else { returnData( 'string', @@ -8046,18 +8018,18 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) function api_set_remove_agent_from_policy_by_id($id, $thrash1, $other, $thrash2) { if ($id == '' || !$id) { - returnError('error_parameter', __('Could not delete agent from policy. Policy cannot be left blank.')); + returnError('The agent could not be deleted from policy. ID Policy cannot be left blank.'); return; } if ($other['data'][0] == '' || !$other['data'][0]) { - returnError('error_parameter', __('Could not delete agent from policy. Agent cannot be left blank.')); + returnError('The agent could not be deleted from policy. Agent cannot be left blank.'); return; } // Require node id if is metaconsole if (is_metaconsole() && $other['data'][1] == '') { - returnError('error_add_agent_policy', __('Could not delete agent from policy. Node ID cannot be left blank.')); + returnError('The agent could not be deleted from policy. Node ID cannot be left blank.'); return; } @@ -8079,12 +8051,12 @@ function api_set_remove_agent_from_policy_by_id($id, $thrash1, $other, $thrash2) function api_set_remove_agent_from_policy_by_name($id, $thrash1, $other, $thrash2) { if ($id == '' || !$id) { - returnError('error_parameter', __('Could not delete agent from policy. Policy cannot be left blank.')); + returnError('The agent could not be deleted from policy. Policy cannot be left blank.'); return; } if ($other['data'][0] == '' || !$other['data'][0]) { - returnError('error_add_agent_policy', __('Could not add agent to policy. Agent name cannot be left blank.')); + returnError('The agent could not be deleted from policy. Agent name cannot be left blank.'); return; } @@ -8128,16 +8100,14 @@ function api_set_create_group($id, $thrash1, $other, $thrash3) if ($id == '') { returnError( - 'error_create_group', - __('Could not create a group. Group_name cannot be left blank.') + 'The group could not be created. Group_name cannot be left blank.' ); return; } if ($other['data'][0] == '') { returnError( - 'error_create_group', - __('Could not create a group. Icon_name cannot be left blank.') + 'The group could not be created. Icon_name cannot be left blank.' ); return; } @@ -8149,8 +8119,7 @@ function api_set_create_group($id, $thrash1, $other, $thrash3) if ($group == false) { returnError( - 'error_create_group', - __('Could not create a group. Id_parent_group does not exist.') + 'The group could not be created. Id_parent_group does not exist.' ); return; } @@ -8179,7 +8148,7 @@ function api_set_create_group($id, $thrash1, $other, $thrash3) if (is_error($id_group)) { // TODO: Improve the error returning more info - returnError('error_create_group', __('Could not create a group.')); + returnError('The group could not be created'); } else { if (defined('METACONSOLE')) { $servers = db_get_all_rows_sql( @@ -8236,7 +8205,7 @@ function api_set_update_group($id_group, $thrash2, $other, $thrash3) } if (db_get_value('id_grupo', 'tgrupo', 'id_grupo', $id_group) === false) { - returnError('error_set_update_group', __('There is no group with the ID provided')); + returnError('There is no group with the ID provided'); return; } @@ -8304,7 +8273,7 @@ function api_set_delete_group($id_group, $thrash2, $other, $thrash3) $group = db_get_row_filter('tgrupo', ['id_grupo' => $id_group]); if (!$group) { - returnError('error_delete', 'Could not delete group. ID does not exist.'); + returnError('The group could not be deleted. ID does not exist.'); return; } @@ -8316,7 +8285,6 @@ function api_set_delete_group($id_group, $thrash2, $other, $thrash3) $usedGroup = groups_check_used($id_group); if ($usedGroup['return']) { returnError( - 'error_delete', 'The delete action could not be performed. The group is not empty (used in '.implode(', ', $usedGroup['tables']).').' ); return; @@ -8328,7 +8296,7 @@ function api_set_delete_group($id_group, $thrash2, $other, $thrash3) $result = db_process_sql_delete('tgrupo', ['id_grupo' => $id_group]); if (!$result) { - returnError('error_delete', 'The delete action could not be performed.'); + returnError('The delete action could not be performed.'); } else { returnData('string', ['type' => 'string', 'data' => __('Successful deletion')]); } @@ -8366,18 +8334,18 @@ function api_set_create_netflow_filter($thrash1, $thrash2, $other, $thrash3) } if ($other['data'][0] == '') { - returnError('error_create_netflow_filter', __('Could not create netflow filter. Filter name cannot be left blank.')); + returnError('The netflow filter could not be created. Filter name cannot be left blank.'); return; } if ($other['data'][1] == '') { - returnError('error_create_netflow_filter', __('Could not create netflow filter. Group id cannot be left blank.')); + returnError('The netflow filter could not be created. Group id cannot be left blank.'); return; } else { $group = groups_get_group_by_id($other['data'][1]); if ($group == false) { - returnError('error_create_group', __('Could not create netflow filter. Id_group does not exist.')); + returnError('The netflow filter could not be created. Id_group does not exist.'); return; } @@ -8388,17 +8356,17 @@ function api_set_create_netflow_filter($thrash1, $thrash2, $other, $thrash3) } if ($other['data'][2] == '') { - returnError('error_create_netflow_filter', __('Could not create netflow filter. Filter cannot be left blank.')); + returnError('The netflow filter could not be created. Filter cannot be left blank.'); return; } if ($other['data'][3] == '') { - returnError('error_create_netflow_filter', __('Could not create netflow filter. Aggregate_by cannot be left blank.')); + returnError('The netflow filter could not be created. Aggregate_by cannot be left blank.'); return; } if ($other['data'][4] == '') { - returnError('error_create_netflow_filter', __('Could not create netflow filter. Output_format cannot be left blank.')); + returnError('The netflow filter could not be created. Output_format cannot be left blank.'); return; } @@ -8416,7 +8384,7 @@ function api_set_create_netflow_filter($thrash1, $thrash2, $other, $thrash3) $id = db_process_sql_insert('tnetflow_filter', $values); if ($id === false) { - returnError('error_create_netflow_filter', __('Could not create netflow filter.')); + returnError('The netflow filter could not be created'); } else { returnData('string', ['type' => 'string', 'data' => $id]); } @@ -8475,7 +8443,7 @@ function api_get_module_data($id, $thrash1, $other, $returnType) $date_end = new DateTime($date_end); $date_end = $date_end->format('U'); } catch (Exception $e) { - returnError('error_query_module_data', 'Error in date format. '); + returnError('Wrong date format.'); return; } } else { @@ -8515,9 +8483,9 @@ function api_get_module_data($id, $thrash1, $other, $returnType) ); if ($data === false) { - returnError('error_query_module_data', 'Module data query error.'); + returnError('Module data query error.', $returnType); } else if ($data['data'] == '') { - returnError('error_query_module_data', 'No data to show.'); + returnError('no_data_to_show', $returnType); } else { // returnData('csv_head', $data, $separator); returnData('csv', $data, $separator); @@ -8636,7 +8604,7 @@ function api_set_new_user($id, $thrash2, $other, $thrash3) $values['session_time'] = $other['data'][12]; if (!create_user($id, $password, $values)) { - returnError('error_create_user', 'The user could not created'); + returnError('The user could not created'); } else { returnData('string', ['type' => 'string', 'data' => __('User created.')]); } @@ -8691,8 +8659,7 @@ function api_set_update_user($id, $thrash2, $other, $thrash3) if ($id == '') { returnError( - 'error_update_user', - __('Could not update user. Id_user cannot be left blank.') + 'The user could not be updated. Id_user cannot be left blank.' ); return; } @@ -8701,8 +8668,7 @@ function api_set_update_user($id, $thrash2, $other, $thrash3) if (!$result_user) { returnError( - 'error_update_user', - __('Could not update user. Id_user does not exist.') + 'The user could not be updated. Id_user does not exist.' ); return; } @@ -8719,13 +8685,13 @@ function api_set_update_user($id, $thrash2, $other, $thrash3) // If password field has data if ($other['data'][4] != '') { if (!update_user_password($id, $other['data'][4])) { - returnError('error_update_user', __('Could not update user. Password info incorrect.')); + returnError('The user could not be updated. Password info incorrect.'); return; } } if (!update_user($id, $values)) { - returnError('error_create_user', 'Could not update user'); + returnError('The user could not be updated'); } else { returnData('string', ['type' => 'string', 'data' => __('User updated.')]); } @@ -8768,24 +8734,21 @@ function api_set_enable_disable_user($id, $thrash2, $other, $thrash3) if ($id == '') { returnError( - 'error_enable_disable_user', - __('Failed switching enable/disable user. Id_user cannot be left blank.') + 'Failed switching enable/disable user. Id_user cannot be left blank.' ); return; } if ($other['data'][0] != '0' and $other['data'][0] != '1') { returnError( - 'error_enable_disable_user', - __('Failed switching enable/disable user. Enable/disable value cannot be left blank.') + 'Failed switching enable/disable user. Enable/disable value cannot be left blank.' ); return; } if (users_get_user_by_id($id) == false) { returnError( - 'error_enable_disable_user', - __('Failed switching enable/disable user. The user does not exist.') + 'Failed switching enable/disable user. The user does not exist.' ); return; } @@ -8795,8 +8758,7 @@ function api_set_enable_disable_user($id, $thrash2, $other, $thrash3) if (is_error($result)) { // TODO: Improve the error returning more info returnError( - 'error_enable_disable_user', - __('Could not enable/disable user.') + 'The user could not be enabled/disabled.' ); } else { if ($other['data'][0] == '0') { @@ -9031,7 +8993,7 @@ function api_set_new_alert_template($id, $id2, $other, $trash1) } if ($other['type'] == 'string') { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else if ($other['type'] == 'array') { $agent_by_alias = false; @@ -9061,7 +9023,7 @@ function api_set_new_alert_template($id, $id2, $other, $trash1) $row = db_get_row_filter('talert_templates', ['name' => $id2]); if ($row === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } @@ -9095,7 +9057,7 @@ function api_set_new_alert_template($id, $id2, $other, $trash1) $idAgentModule = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['id_agente' => $idAgent, 'nombre' => $other['data'][0]]); if ($idAgentModule === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } @@ -9184,7 +9146,7 @@ function api_set_delete_module($id, $id2, $other, $trash1) $idAgentModule = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['id_agente' => $idAgent, 'nombre' => $id2]); if ($idAgentModule === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } @@ -9230,7 +9192,7 @@ function api_set_module_data($id, $thrash2, $other, $trash1) $agentModule = db_get_row_filter('tagente_modulo', ['id_agente_modulo' => $idAgentModule]); if ($agentModule === false) { - returnError('error_parameter', 'Module agent not found.'); + returnError('Module agent not found.'); } else { $agent = db_get_row_filter('tagente', ['id_agente' => $agentModule['id_agente']]); @@ -9260,7 +9222,7 @@ 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', 'XML file could not be generated in path: '.$config['remote_config']); + returnError(sprintf('XML file could not be generated in path: %s', $config['remote_config'])); } else { echo __('XML file was generated successfully in path: ').$config['remote_config']; returnData('string', ['type' => 'string', 'data' => $xml]); @@ -9268,7 +9230,7 @@ function api_set_module_data($id, $thrash2, $other, $trash1) } } } else { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } } @@ -9281,7 +9243,7 @@ function api_set_new_module($id, $id2, $other, $trash1) } if ($other['type'] == 'string') { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else if ($other['type'] == 'array') { $values = []; @@ -9314,12 +9276,12 @@ function api_set_new_module($id, $id2, $other, $trash1) $values['id_tipo_modulo'] = db_get_value_filter('id_tipo', 'ttipo_modulo', ['nombre' => $other['data'][0]]); if ($values['id_tipo_modulo'] === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } if ($other['data'][1] == '') { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } @@ -9327,7 +9289,7 @@ function api_set_new_module($id, $id2, $other, $trash1) if (strstr($other['data'][0], 'icmp') === false) { if (($other['data'][2] == '') || ($other['data'][2] <= 0 || $other['data'][2] > 65535)) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } @@ -9446,7 +9408,7 @@ function api_set_alert_actions($id, $id2, $other, $trash1) } if ($other['type'] == 'string') { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else if ($other['type'] == 'array') { $agent_by_alias = false; @@ -9475,7 +9437,7 @@ function api_set_alert_actions($id, $id2, $other, $trash1) $row = db_get_row_filter('talert_templates', ['name' => $id2]); if ($row === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } @@ -9492,18 +9454,18 @@ function api_set_alert_actions($id, $id2, $other, $trash1) $idAlertTemplateModule = db_get_value_filter('id', 'talert_template_modules', ['id_alert_template' => $idTemplate, 'id_agent_module' => $idAgentModule]); if ($idAlertTemplateModule === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } if ($other['data'][1] != '') { $idAction = db_get_value_filter('id', 'talert_actions', ['name' => $other['data'][1]]); if ($idAction === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } } else { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } @@ -9530,24 +9492,24 @@ function api_set_alert_actions($id, $id2, $other, $trash1) } else { $idAgentModule = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['id_agente' => $idAgent, 'nombre' => $other['data'][0]]); if ($idAgentModule === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } $idAlertTemplateModule = db_get_value_filter('id', 'talert_template_modules', ['id_alert_template' => $idTemplate, 'id_agent_module' => $idAgentModule]); if ($idAlertTemplateModule === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } if ($other['data'][1] != '') { $idAction = db_get_value_filter('id', 'talert_actions', ['name' => $other['data'][1]]); if ($idAction === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } } else { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } @@ -9599,21 +9561,21 @@ function api_set_new_module_group($id, $thrash2, $other, $trash1) } if ($id == '' || !$id) { - returnError('error_parameter', __('Module group must have a name.')); + returnError('Module group must have a name.'); return; } $name = db_get_value('name', 'tmodule_group', 'name', $id); if ($name) { - returnError('error_parameter', __('Each Module Group must have a different name.')); + returnError('Each Module Group must have a different name.'); return; } $return = db_process_sql_insert('tmodule_group', ['name' => $id]); if ($return === false) { - returnError('error_new_moodule_group', 'There was a problem creating group.'); + returnError('There was a problem creating group.'); } else { returnData('string', ['type' => 'string', 'data' => $return]); } @@ -9658,14 +9620,14 @@ function api_set_module_group_synch($thrash1, $thrash2, $other, $thrash4) // User feedback if ($module_group_create_err > 0 or $module_group_update_err > 0) { - returnError('module_group_synch_err', __('Could not create/update %s/%s module groups
', $module_group_create_err, $module_group_update_err)); + returnError(sprintf('The module groups %s/%s could not be created/updated
', $module_group_create_err, $module_group_update_err)); } if ($module_group_create_ok > 0 or $module_group_update_ok > 0) { returnData('string', ['type' => 'string', 'data' => $string_ok]); } } else { - returnError('not_defined_in_metaconsole', __('This function is for metaconsole only')); + returnError('This function is for metaconsole only'); } } @@ -9712,27 +9674,27 @@ function api_set_alert_commands($id, $thrash2, $other, $trash1) $group = db_get_value('id_grupo', 'tgrupo', 'id_grupo', $id_group); if ($id == '' || !$id) { - returnError('error_parameter', __('Name cannot be empty.')); + returnError('Name cannot be empty.'); return; } if ($command == '' || !$command) { - returnError('error_parameter', __('Command cannot be empty.')); + returnError('Command cannot be empty.'); return; } if ($name) { - returnError('error_parameter', __('Name already exist.')); + returnError('Name already exist.'); return; } if (!$group && $id_group != 0) { - returnError('error_parameter', __('Group does not exist.')); + returnError('Group does not exist.'); return; } if ($other['type'] == 'string') { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else if ($other['type'] == 'array') { $fields_descriptions = []; @@ -9787,21 +9749,21 @@ function api_set_new_event($trash1, $trash2, $other, $trash3) if ($other['type'] == 'string') { if ($other['data'] != '') { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } } else if ($other['type'] == 'array') { $values = []; if (($other['data'][0] == null) && ($other['data'][0] == '')) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else { $values['evento'] = $other['data'][0]; } if (($other['data'][1] == null) && ($other['data'][1] == '')) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else { $valuesAvaliable = [ @@ -9826,27 +9788,27 @@ function api_set_new_event($trash1, $trash2, $other, $trash3) if (in_array($other['data'][1], $valuesAvaliable)) { $values['event_type'] = $other['data'][1]; } else { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } } if (($other['data'][2] == null) && ($other['data'][2] == '')) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else { $values['estado'] = $other['data'][2]; } if (($other['data'][3] == null) && ($other['data'][3] == '')) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else { $values['id_agente'] = agents_get_agent_id($other['data'][3]); } if (($other['data'][4] == null) && ($other['data'][4] == '')) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else { $idAgentModule = db_get_value_filter( @@ -9860,14 +9822,14 @@ function api_set_new_event($trash1, $trash2, $other, $trash3) } if ($idAgentModule === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else { $values['id_agentmodule'] = $idAgentModule; } if (($other['data'][5] == null) && ($other['data'][5] == '')) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else { if ($other['data'][5] != 'all') { @@ -9877,7 +9839,7 @@ function api_set_new_event($trash1, $trash2, $other, $trash3) } if ($idGroup === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else { $values['id_grupo'] = $idGroup; @@ -9885,13 +9847,13 @@ function api_set_new_event($trash1, $trash2, $other, $trash3) } if (($other['data'][6] == null) && ($other['data'][6] == '')) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else { if (($other['data'][6] >= 0) && ($other['data'][6] <= 4)) { $values['criticity'] = $other['data'][6]; } else { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } } @@ -9909,7 +9871,7 @@ function api_set_new_event($trash1, $trash2, $other, $trash3) ); if ($idAlert === false) { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else { $values['id_alert_am'] = $idAlert; @@ -9950,7 +9912,7 @@ function api_set_event_validate_filter_pro($trash1, $trash2, $other, $trash3) if ($other['type'] == 'string') { if ($other['data'] != '') { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } } else if ($other['type'] == 'array') { @@ -10047,7 +10009,7 @@ function api_set_event_validate_filter($trash1, $trash2, $other, $trash3) if ($other['type'] == 'string') { if ($other['data'] != '') { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } } else if ($other['type'] == 'array') { @@ -10158,7 +10120,7 @@ function api_get_gis_agent($id_agent, $trash1, $tresh2, $return_type, $user_in_d ] ); } else { - returnError('get_gis_agent', __('There is not GIS data for the agent.')); + returnError('There is not GIS data for the agent.'); } } @@ -10199,7 +10161,7 @@ function api_set_gis_agent_only_position($id_agent, $trash1, $other, $return_typ if (!$config['activate_gis']) { $correct = false; - returnError('error_gis_agent_only_position', __('GIS not activated.')); + returnError('GIS not activated.'); return; } else { if ($correct) { @@ -10218,7 +10180,7 @@ function api_set_gis_agent_only_position($id_agent, $trash1, $other, $return_typ __('Insert by %s Console', get_product_name()) ); } else { - returnError('error_gis_agent_only_position', __('Missing parameters.')); + returnError('Missing parameters.'); return; } } @@ -10317,7 +10279,7 @@ function api_set_gis_agent($id_agent, $trash1, $other, $return_type, $user_in_db if (!$config['activate_gis']) { $correct = false; - returnError('error_gis_agent_only_position', __('GIS not activated.')); + returnError('GIS not activated.'); return; } else { if ($correct) { @@ -10336,7 +10298,7 @@ function api_set_gis_agent($id_agent, $trash1, $other, $return_type, $user_in_db $description_first_insert ); } else { - returnError('error_set_ig_agent', __('Missing parameters.')); + returnError('Missing parameters.'); return; } } @@ -10730,7 +10692,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db if ($other['type'] == 'string') { if ($other['data'] != '') { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else { // Default values @@ -10874,8 +10836,7 @@ function api_set_event($id_event, $unused1, $params, $unused2, $unused3) // If update results failed if (empty($result) === true || $result === false) { returnError( - 'failed_event_update', - __('Could not update the event') + 'The event could not be updated' ); return false; } else { @@ -10923,7 +10884,7 @@ function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db=null) if ($other['type'] == 'string') { if ($other['data'] != '') { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else { // Default values @@ -10982,7 +10943,7 @@ function api_set_delete_user($id, $thrash1, $thrash2, $thrash3) } if (!delete_user($id)) { - returnError('error_delete_user', 'Could not delete user'); + returnError('The user could not be deleted'); } else { returnData('string', ['type' => 'string', 'data' => __('User deleted.')]); } @@ -11020,12 +10981,12 @@ function api_set_add_user_profile($id, $thrash1, $other, $thrash2) $profile = $other['data'][1]; if (db_get_value('id_grupo', 'tgrupo', 'id_grupo', $group) === false) { - returnError('error_set_add_user_profile', __('There is not any group with the ID provided.')); + returnError('There is not any group with the ID provided.'); return; } if (db_get_value('id_perfil', 'tperfil', 'id_perfil', $profile) === false) { - returnError('error_set_add_user_profile', __('There is not any profile with the ID provided.')); + returnError('There is not any profile with the ID provided.'); return; } @@ -11035,7 +10996,7 @@ function api_set_add_user_profile($id, $thrash1, $other, $thrash2) } if (!profile_create_user_profile($id, $profile, $group, 'API')) { - returnError('error_add_user_profile', 'Could not add user profile.'); + returnError('The user profile could not be added.'); } else { returnData('string', ['type' => 'string', 'data' => __('User profile added.')]); } @@ -11073,12 +11034,12 @@ function api_set_delete_user_profile($id, $thrash1, $other, $thrash2) $profile = $other['data'][1]; if (db_get_value('id_grupo', 'tgrupo', 'id_grupo', $group) === false) { - returnError('error_set_add_user_profile', __('There is not any group with the ID provided.')); + returnError('There is not any group with the ID provided.'); return; } if (db_get_value('id_perfil', 'tperfil', 'id_perfil', $profile) === false) { - returnError('error_set_add_user_profile', __('There is not any profile with the ID provided.')); + returnError('There is not any profile with the ID provided.'); return; } @@ -11093,8 +11054,8 @@ function api_set_delete_user_profile($id, $thrash1, $other, $thrash2) 'id_grupo' => $group, ]; $result = db_process_sql_delete('tusuario_perfil', $where); - if ($return === false) { - returnError('error_delete_user_profile', 'Could not delete user profile.'); + if ($result === false) { + returnError('The user profile could not be deleted.'); } else { returnData('string', ['type' => 'string', 'data' => __('User profile deleted.')]); } @@ -11153,7 +11114,7 @@ function api_get_user_profiles_info($thrash1, $thrash2, $thrash3, $returnType) ); if ($profiles === false) { - returnError('error_list_profiles', __('Profiles could not be retrieved.')); + returnError('Profiles could not be retrieved.'); } else { returnData($returnType, ['type' => 'array', 'data' => $profiles]); } @@ -11209,7 +11170,7 @@ function api_set_create_user_profile_info($thrash1, $thrash2, $other, $returnTyp $return = db_process_sql_insert('tperfil', $values); if ($return === false) { - returnError('error_create_user_profile_info', __('Could not create user profile.')); + returnError('The user profile could not be created.'); } else { returnData($returnType, ['type' => 'array', 'data' => 1]); } @@ -11271,7 +11232,7 @@ function api_set_update_user_profile_info($id_profile, $thrash1, $other, $return $return = db_process_sql_update('tperfil', $values, ['id_perfil' => $id_profile]); if ($return === false) { - returnError('error_update_user_profile_info', __('Could not update user profile')); + returnError('The user profile could not be updated'); } else { returnData($returnType, ['type' => 'array', 'data' => 1]); } @@ -11306,7 +11267,7 @@ function api_set_delete_user_profile_info($id_profile, $thrash1, $thrash2, $retu $return = profile_delete_profile_and_clean_users($id_profile); if ($return === false) { - returnError('error_delete_user_profile_info', __('Could not delete user profile')); + returnError('The user profile could not be deleted'); } else { returnData($returnType, ['type' => 'array', 'data' => 1]); } @@ -11363,8 +11324,8 @@ function api_set_new_incident($thrash1, $thrash2, $other, $thrash3) ]; $idIncident = db_process_sql_insert('tincidencia', $values); - if ($return === false) { - returnError('error_new_incident', 'A new incident could not be created.'); + if ($idIncident === false) { + returnError('A new incident could not be created.'); } else { returnData('string', ['type' => 'string', 'data' => $idIncident]); } @@ -11401,7 +11362,7 @@ function api_set_new_note_incident($id, $id2, $other, $thrash2) $idNote = db_process_sql_insert('tnota', $values); if ($idNote === false) { - returnError('error_new_incident', 'A new incident could not be created+.'); + returnError('A new incident could not be created+.'); } else { returnData('string', ['type' => 'string', 'data' => $idNote]); } @@ -11415,7 +11376,7 @@ function api_set_new_note_incident($id, $id2, $other, $thrash2) * @param string $module_name Name of the module * @param $thrash3 Don't use. * @param $thrash4 Don't use. -// http://localhost/pandora_console/include/api.php?op=set&op2=enable_module&id=garfio&id2=Status + * // http://localhost/pandora_console/include/api.php?op=set&op2=enable_module&id=garfio&id2=Status */ @@ -11829,8 +11790,7 @@ function api_set_disable_module_alerts($agent_name, $module_name, $other, $thras * @param string $module_name Name of the module (for example "Host alive") * @param $thrash3 Don't use. * @param $thrash4 Don't use. - -// http://localhost/pandora_console/include/api.php?op=set&op2=enable_module_alerts&id=garfio&id2=Status + * // http://localhost/pandora_console/include/api.php?op=set&op2=enable_module_alerts&id=garfio&id2=Status */ @@ -11918,7 +11878,7 @@ function api_get_tags($thrash1, $thrash2, $other, $returnType, $user_in_db) if ($other['type'] == 'string') { if ($other['data'] != '') { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else { // Default values @@ -12058,8 +12018,6 @@ function api_get_agent_name($id_agent, $trash1, $trash2, $returnType) **/ function api_get_agent_id($trash1, $trash2, $data, $returnType) { - $response; - if (is_metaconsole()) { return; } @@ -12201,7 +12159,7 @@ function api_get_alert_action_by_group($id_group, $id_action, $trash2, $returnTy $value = db_get_value_sql($sql); if ($value === false) { - returnError('data_not_found', __('No alert found')); + returnError('No alert found'); return; } else if ($value == '') { $value = 0; @@ -12245,6 +12203,7 @@ function api_get_event_info($id_event, $trash1, $trash, $returnType) } } + $result = ''; $i = 0; foreach ($event_data as $key => $data) { $data = strip_tags($data); @@ -12334,7 +12293,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) } if ($other['type'] == 'string') { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else if ($other['type'] == 'array') { $values = []; @@ -12342,7 +12301,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) if ($other['data'][0] != '') { $values['event'] = $other['data'][0]; } else { - returnError('error_parameter', 'Event text required.'); + returnError('Event text required.'); return; } @@ -12355,18 +12314,18 @@ function api_set_create_event($id, $trash1, $other, $returnType) $values['id_grupo'] = $other['data'][1]; if (groups_get_name($values['id_grupo']) === false) { - returnError('error_parameter', 'Group ID does not exist'); + returnError('Group ID does not exist'); return; } } else { - returnError('error_parameter', 'Group ID required.'); + returnError('Group ID required.'); return; } if (!empty($other['data'][17]) && is_metaconsole()) { $id_server = db_get_row_filter('tmetaconsole_setup', ['id' => $other['data'][17]]); if ($id_server === false) { - returnError('error_create_event', __('Server ID does not exist in database.')); + returnError('Server ID does not exist in database.'); return; } @@ -12392,7 +12351,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) } if (!metaconsole_connect(null, $agent_cache['id_tmetaconsole_setup'])) { - returnError('error_create_event', __('Cannot connect with the agent node.')); + returnError('Cannot connect with the agent node.'); return; } @@ -12436,11 +12395,11 @@ function api_set_create_event($id, $trash1, $other, $returnType) if ($error_msg != '') { if ($error_msg == 'id_not_exist') { - returnError('error_parameter', 'Agent ID does not exist.'); + returnError('Agent ID does not exist.'); } else if ($error_msg == 'name_not_exist') { - returnError('error_parameter', 'Agent Name does not exist.'); + returnError('Agent Name does not exist.'); } else if ($error_msg == 'none') { - returnError('error_parameter', 'Agent ID or name required.'); + returnError('Agent ID or name required.'); } return; @@ -12622,7 +12581,7 @@ function api_set_add_event_comment($id, $thrash2, $other, $thrash3) } if ($other['type'] == 'string') { - returnError('error_parameter', 'Parameter error.'); + returnError('Parameter error.'); return; } else if ($other['type'] == 'array') { $comment = $other['data'][0]; @@ -12637,8 +12596,7 @@ function api_set_add_event_comment($id, $thrash2, $other, $thrash3) ); if (is_error($status)) { returnError( - 'error_add_event_comment', - __('Could not add event comment.') + 'The event comment could not be added.' ); return; } @@ -12920,8 +12878,7 @@ function api_set_enable_disable_agent($id, $thrash2, $other, $thrash3) if ($id == '') { returnError( - 'error_enable_disable_agent', - __('Failed switching enable/disable agent. Id_agent cannot be left blank.') + 'Failed switching enable/disable agent. Id_agent cannot be left blank.' ); return; } @@ -12932,16 +12889,14 @@ function api_set_enable_disable_agent($id, $thrash2, $other, $thrash3) if ($other['data'][0] != '0' and $other['data'][0] != '1') { returnError( - 'error_enable_disable_agent', - __('Failed switching enable/disable agent. Enable/disable value cannot be left blank.') + 'Failed switching enable/disable agent. Enable/disable value cannot be left blank.' ); return; } if (agents_get_name($id) == false) { returnError( - 'error_enable_disable_agent', - __('Failed switching enable/disable agent. The agent does not exist.') + 'Failed switching enable/disable agent. The agent does not exist.' ); return; } @@ -12965,7 +12920,7 @@ function api_set_enable_disable_agent($id, $thrash2, $other, $thrash3) if (is_error($result)) { // TODO: Improve the error returning more info - returnError('error_enable_disable_agent', __('Failed switching enable/disable agent.')); + returnError('Failed switching enable/disable agent.'); } else { if ($disabled == 0) { returnData( @@ -13095,7 +13050,7 @@ function api_get_special_days($thrash1, $thrash2, $other, $thrash3) } if (!$special_days) { - returnError('error_get_special_days', __('Could not get special_days.')); + returnError('Could not get special_days.'); } else { returnData('csv', $data, $separator); } @@ -13135,23 +13090,23 @@ function api_set_create_special_day($thrash1, $thrash2, $other, $thrash3) $check_id_special_day = db_get_value('id', 'talert_special_days', 'date', $special_day); if ($check_id_special_day) { - returnError('error_create_special_day', __('Could not create special day. Specified day already exist.')); + returnError('Special Day could not be created. Specified day already exist.'); return; } if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $special_day)) { - returnError('error_create_special_day', __('Could not create special day. Invalid date format.')); + returnError('Special Day could not be created. Invalid date format.'); return; } if (!isset($idGroup) || $idGroup == '') { - returnError('error_create_special_day', __('Could not create special day. Group id cannot be left blank.')); + returnError('Special Day could not be created. Group id cannot be left blank.'); return; } else { $group = groups_get_group_by_id($idGroup); if ($group == false) { - returnError('error_create_special_day', __('Could not create special day. Id_group does not exist.')); + returnError('Special Day could not be created. Id_group does not exist.'); return; } @@ -13169,7 +13124,7 @@ function api_set_create_special_day($thrash1, $thrash2, $other, $thrash3) $idSpecialDay = alerts_create_alert_special_day($special_day, $same_day, $values); if (is_error($idSpecialDay)) { - returnError('error_create_special_day', __('Could not create special day.')); + returnError('Special Day could not be created'); } else { returnData('string', ['type' => 'string', 'data' => $idSpecialDay]); } @@ -13222,7 +13177,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) $server_name = $other['data'][16]; if (empty($name)) { - returnError('error_create_service', __('Could not create service. No name provided.')); + returnError('The service could not be created. No name provided.'); return; } @@ -13245,7 +13200,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) } if (empty($id_agent)) { - returnError('error_create_service', __('Could not create service. No agent ID provided.')); + returnError('The service could not be created. No agent ID provided.'); return; } else { if (!util_api_check_agent_and_print_error($id_agent, 'string', 'AR')) { @@ -13325,7 +13280,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) if ($result) { returnData('string', ['type' => 'string', 'data' => $result]); } else { - returnError('error_create_service', __('Could not create service.')); + returnError('The service could not be created.'); } } @@ -13357,7 +13312,7 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) $id_service = $thrash1; if (empty($id_service)) { - returnError('error_update_service', __('Could not update service. No service ID provided.')); + returnError('The service could not be updated. No service ID provided.'); return; } @@ -13500,7 +13455,7 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) if ($result) { returnData('string', ['type' => 'string', 'data' => $result]); } else { - returnError('error_update_service', __('Could not update service.')); + returnError('The service could not be updated.'); } } @@ -13533,7 +13488,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) $id = $thrash1; if (empty($id)) { - returnError('error_add_service_element', __('Could not add elements to service. No service ID provided.')); + returnError('Could not add elements to service. No service ID provided.'); return; } @@ -13610,7 +13565,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) if ($results) { returnData('string', ['type' => 'string', 'data' => 1]); } else { - returnError('error_add_service_element', __('Could not add elements to service')); + returnError('Could not add elements to service'); } } @@ -13647,19 +13602,19 @@ function api_set_update_special_day($id_special_day, $thrash2, $other, $thrash3) $idGroup = $other['data'][3]; if ($id_special_day == '') { - returnError('error_update_special_day', __('Could not update special day. ID cannot be left blank.')); + returnError('The Special Day could not be updated. ID cannot be left blank.'); return; } $check_id_special_day = db_get_value('id', 'talert_special_days', 'id', $id_special_day); if (!$check_id_special_day) { - returnError('error_update_special_day', __('Could not update special day. ID does not exist.')); + returnError('The Special Day could not be updated. ID does not exist.'); return; } if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $special_day)) { - returnError('error_update_special_day', __('Could not update special day. Invalid date format.')); + returnError('The Special Day could not be updated. Invalid date format.'); return; } @@ -13709,21 +13664,21 @@ function api_set_delete_special_day($id_special_day, $thrash2, $thrash3, $thrash } if ($id_special_day == '') { - returnError('error_update_special_day', __('Could not delete special day. ID cannot be left blank.')); + returnError('The Special Day could not be deleted. ID cannot be left blank.'); return; } $check_id_special_day = db_get_value('id', 'talert_special_days', 'id', $id_special_day); if (!$check_id_special_day) { - returnError('error_delete_special_day', __('Could not delete special day. ID does not exist.')); + returnError('The Special Day could not be deleted. ID does not exist.'); return; } $return = alerts_delete_alert_special_day($id_special_day); if (is_error($return)) { - returnError('error_delete_special_day', __('Could not delete special day.')); + returnError('The Special Day could not be deleted.'); } else { returnData('string', ['type' => 'string', 'data' => $return]); } @@ -13753,7 +13708,7 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) } if (is_nan($id_module) || $id_module <= 0) { - returnError('error_module_graph', __('')); + returnError('Parameter error.'); return; } @@ -13765,7 +13720,8 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) $graph_seconds = (!empty($other) && isset($other['data'][0])) ? $other['data'][0] : SECONDS_1HOUR; // 1 hour by default. $graph_threshold = (!empty($other) && isset($other['data'][2]) && $other['data'][2]) ? $other['data'][2] : 0; - + // TODO. For complete + $width = ''; // Graph height when send email by alert $height = (!empty($other) && isset($other['data'][3]) && $other['data'][3]) ? $other['data'][3] : 225; } else { @@ -13869,7 +13825,7 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) $name_exist = db_process_sql('select count(name) as already_exist from tcluster as already_exist where name = "'.$name.'"'); if ($name_exist[0]['already_exist'] > 0) { - returnError('error_set_new_cluster', __('A cluster with this name already exist.')); + returnError('A cluster with this name already exist.'); return false; } @@ -13951,10 +13907,10 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) ] ); } else { - returnError('error_set_new_cluster', __('A cluster could not be created.')); + returnError('A cluster could not be created.'); } } else { - returnError('error_set_new_cluster', __('Agent name cannot be empty.')); + returnError('Agent name cannot be empty.'); return; } @@ -13989,7 +13945,7 @@ function api_set_add_cluster_agent($thrash1, $thrash2, $other, $thrash3) if ($tcluster_agent !== false) { returnData('string', ['type' => 'string', 'data' => 1]); } else { - returnError('error_add_cluster_element', __('Could not add elements to cluster')); + returnError('The elements could not be added to cluster'); } } @@ -14124,7 +14080,7 @@ function api_set_add_cluster_item($thrash1, $thrash2, $other, $thrash3) if ($id_module !== false) { returnData('string', ['type' => 'string', 'data' => 1]); } else { - returnError('error_add_cluster_element', __('Could not add elements to cluster')); + returnError('The elements could not be added to cluster'); } } @@ -14142,7 +14098,7 @@ function api_set_delete_cluster($id, $thrash1, $thrast2, $thrash3) $cluster = $clusters[0]; if (!check_acl($config['id_user'], $cluster['group'], 'AD')) { - returnError('error_set_delete_cluster', __('The user cannot access to the cluster')); + returnError('The user cannot access to the cluster'); return; } @@ -14161,7 +14117,7 @@ function api_set_delete_cluster($id, $thrash1, $thrast2, $thrash3) $tcluster_agent_delete = $temp_id_cluster[0]['id_agent'] !== null ? agents_delete_agent($temp_id_cluster[0]['id_agent']) : 0; if (($tcluster_modules_delete + $tcluster_items_delete + $tcluster_agents_delete + $tcluster_delete + $tcluster_agent_delete) == 0) { - returnError('error_delete', 'Cluster could not be deleted.'); + returnError('Cluster could not be deleted.'); } else { returnData('string', ['type' => 'string', 'data' => __('Successfully deleted.')]); } @@ -14223,7 +14179,7 @@ function api_set_delete_cluster_item($id, $thrash1, $thrast2, $thrast3) $cluster = $clusters[0]; if (!check_acl($config['id_user'], $cluster['group'], 'AD')) { - returnError('error_set_delete_cluster_item', __('The user cannot access the cluster')); + returnError('The user cannot access the cluster'); return; } @@ -14232,7 +14188,7 @@ function api_set_delete_cluster_item($id, $thrash1, $thrast2, $thrast3) $delete_item = db_process_sql('delete from tcluster_item where id = '.$id); if (!$delete_item) { - returnError('error_delete', 'Error in delete operation.'); + returnError('Error in delete operation.'); } else { returnData('string', ['type' => 'string', 'data' => __('Successfully deleted.')]); } @@ -14374,9 +14330,9 @@ function api_set_apply_module_template($id_template, $id_agent, $thrash3, $thras if ($error_count > 0) { if (empty($modules_already_added)) { - returnError('set_apply_module_template', __('Could not add modules').sprintf(' (%s)', $error_count)); + returnError(sprintf('Could not add modules (%s)', $error_count)); } else { - returnError('set_apply_module_template', __('Could not add modules. The following errors already exists: ').implode(', ', $modules_already_added)); + returnError('Could not add modules. The following errors already exists: ').implode(', ', $modules_already_added); } } @@ -14400,7 +14356,7 @@ function api_get_cluster_status($id_cluster, $trash1, $trash2, $returnType) $cluster = $clusters[0]; if (!check_acl($config['id_user'], $cluster['group'], 'AR')) { - returnError('error_get_cluster_status', __('The user cannot access to the cluster')); + returnError('The user cannot access to the cluster'); return; } @@ -14440,7 +14396,7 @@ function api_get_cluster_id_by_name($cluster_name, $trash1, $trash2, $returnType $cluster = $clusters[0]; if (!check_acl($config['id_user'], $cluster['group'], 'AR')) { - returnError('error_get_cluster_status', __('The user cannot access to the cluster')); + returnError('The user cannot access to the cluster'); return; } @@ -14470,7 +14426,7 @@ function api_get_agents_id_name_by_cluster_id($cluster_id, $trash1, $trash2, $re $cluster = $clusters[0]; if (!check_acl($config['id_user'], $cluster['group'], 'AR')) { - returnError('error_get_cluster_status', __('The user cannot access to the cluster')); + returnError('The user cannot access to the cluster'); return; } @@ -14491,7 +14447,7 @@ function api_get_agents_id_name_by_cluster_id($cluster_id, $trash1, $trash2, $re returnData('json', $data, JSON_FORCE_OBJECT); } else { - returnError('error_agents', 'No agents retrieved.'); + returnError('No agents retrieved.'); } } @@ -14509,7 +14465,7 @@ function api_get_agents_id_name_by_cluster_name($cluster_name, $trash1, $trash2, $cluster = $clusters[0]; if (!check_acl($config['id_user'], $cluster['group'], 'AR')) { - returnError('error_get_cluster_status', __('The user cannot access to the cluster')); + returnError('The user cannot access to the cluster'); return; } @@ -14530,7 +14486,7 @@ function api_get_agents_id_name_by_cluster_name($cluster_name, $trash1, $trash2, returnData('json', $data, JSON_FORCE_OBJECT); } else { - returnError('error_agents', 'No agents retrieved.'); + returnError('No agents retrieved.'); } } @@ -14570,7 +14526,7 @@ function api_get_agents_id_name_by_alias($alias, $strict, $trash2, $returnType) returnData('json', $data, JSON_FORCE_OBJECT); } else { - returnError('error_agents', 'Alias did not match any agent.'); + returnError('Alias does not match any agent.'); } } @@ -14586,13 +14542,13 @@ function api_get_modules_id_name_by_cluster_id($cluster_id) $clusters = Cluster::search(['id' => $cluster_id]); if ($clusters === false) { - returnError('error_clusters', 'ID does not exist in database.'); + returnError('ID does not exist in database.'); } $cluster = $clusters[0]; if (!check_acl($config['id_user'], $cluster['group'], 'AR')) { - returnError('error_get_cluster_status', __('The user cannot access to the cluster')); + returnError('The user cannot access to the cluster'); return; } @@ -14621,7 +14577,7 @@ function api_get_modules_id_name_by_cluster_id($cluster_id) returnData('json', $data); } else { - returnError('error_agent_modules', 'No modules were retrieved.'); + returnError('No modules were retrieved.'); } } @@ -14639,7 +14595,7 @@ function api_get_modules_id_name_by_cluster_name($cluster_name) $cluster = $clusters[0]; if (!check_acl($config['id_user'], $cluster['group'], 'AR')) { - returnError('error_get_cluster_status', __('The user cannot access to the cluster')); + returnError('The user cannot access to the cluster'); return; } @@ -14668,7 +14624,7 @@ function api_get_modules_id_name_by_cluster_name($cluster_name) returnData('json', $data); } else { - returnError('error_agent_modules', 'No modules were retrieved.'); + returnError('No modules were retrieved.'); } } @@ -14849,7 +14805,7 @@ function api_get_cluster_items($cluster_id) $cluster = $clusters[0]; if (!check_acl($config['id_user'], $cluster['group'], 'AR')) { - returnError('error_get_cluster_status', __('The user cannot access to the cluster')); + returnError('The user cannot access to the cluster'); return; } @@ -14909,7 +14865,7 @@ function api_get_cluster_items($cluster_id) returnData('json', $data); } else { - returnError('error_cluster_items', 'No items were retrieved.'); + returnError('No items were retrieved.'); } } @@ -14933,8 +14889,7 @@ function api_set_create_event_filter($name, $thrash1, $other, $thrash3) { if ($name == '') { returnError( - 'error_create_event_filter', - __('Could not create event filter. Event filter name cannot be left blank.') + 'The event filter could not be created. Event filter name cannot be left blank.' ); return; } @@ -15074,7 +15029,7 @@ function api_set_create_event_filter($name, $thrash1, $other, $thrash3) $id_filter = db_process_sql_insert('tevent_filter', $values); if ($id_filter === false) { - returnError('error_create_event_filter', __('Could not create event filter.')); + returnError('The event filter could not be created.'); } else { returnData( 'string', @@ -15116,8 +15071,7 @@ function api_set_update_event_filter($id_event_filter, $thrash1, $other, $thrash if ($id_event_filter == '') { returnError( - 'error_update_event_filter', - __('Could not update event filter. Event filter ID cannot be left blank.') + 'The event filter could not be updated. Event filter ID cannot be left blank.' ); return; } @@ -15127,8 +15081,7 @@ function api_set_update_event_filter($id_event_filter, $thrash1, $other, $thrash if (!$result_event_filter) { returnError( - 'error_update_event_filter', - __('Could not update event filter. Event filter ID does not exist.') + 'The event filter could not be updated. Event filter ID does not exist.' ); return; } @@ -15309,7 +15262,7 @@ function api_set_update_event_filter($id_event_filter, $thrash1, $other, $thrash ); if ($result === false) { - returnError('error_update_event_filter', __('Could not update event filter.')); + returnError('The event filter could not be updated'); } else { returnData( 'string', @@ -15340,8 +15293,7 @@ function api_set_delete_event_filter($id_event_filter, $thrash1, $other, $thrash { if ($id_event_filter == '') { returnError( - 'error_delete_event_filter', - __('Could not delete event_filter. Event filter ID cannot be left blank.') + 'The event filter could not be deleted. Event filter ID cannot be left blank.' ); return; } @@ -15350,8 +15302,7 @@ function api_set_delete_event_filter($id_event_filter, $thrash1, $other, $thrash if ($result == 0) { returnError( - 'error_delete_event_filter', - __('Could not delete event filter.') + 'The event filter could not be deleted.' ); } else { returnData( @@ -15405,8 +15356,7 @@ function api_get_all_event_filters($thrash1, $thrash2, $other, $thrash3) if (!$event_filters) { returnError( - 'error_get_all_event_filters', - __('Could not get all event filters.') + 'Could not get all event filters.' ); } else { returnData('csv', $data, $separator); @@ -15636,7 +15586,7 @@ function api_set_validate_traps($id, $thrash2, $other, $thrash3) if (is_error($result)) { // TODO: Improve the error returning more info - returnError('error_update_trap', __('Could not update trap.')); + returnError('Trap could not be updated.'); } else { returnData( 'string', @@ -15663,7 +15613,7 @@ function api_set_delete_traps($id, $thrash2, $other, $thrash3) if (is_error($result)) { // TODO: Improve the error returning more info - returnError('error_delete_trap', __('Could not deleted trap.')); + returnError('Trap could not be deleted.'); } else { returnData( 'string', @@ -15697,7 +15647,7 @@ function api_get_group_id_by_name($thrash1, $thrash2, $other, $thrash3) returnData('csv', $data, ';'); } else { - returnError('error_group_name', 'No groups were retrieved.'); + returnError('No groups were retrieved.'); } } @@ -15723,7 +15673,7 @@ function api_get_timezone($thrash1, $thrash2, $other, $thrash3) returnData('string', ['type' => 'string', 'data' => $data['data'][0]['value']]); } else { - returnError('error_timezone', 'No timezone were retrieved.'); + returnError('No timezone were retrieved.'); } } @@ -15749,7 +15699,7 @@ function api_get_language($thrash1, $thrash2, $other, $thrash3) returnData('string', ['type' => 'string', 'data' => $data['data'][0]['value']]); } else { - returnError('error_language', 'No language were retrieved.'); + returnError('No language were retrieved.'); } } @@ -15775,7 +15725,7 @@ function api_get_session_timeout($thrash1, $thrash2, $other, $thrash3) returnData('string', ['type' => 'string', 'data' => $data['data'][0]['value']]); } else { - returnError('error_session_timeout', 'No session timeout were retrieved.'); + returnError('No session timeout were retrieved.'); } } @@ -15800,7 +15750,7 @@ function api_get_users($thrash1, $thrash2, $other, $returnType) if (count($data) > 0 and $data !== false) { returnData($returnType, $data, $separator); } else { - returnError('error_users', 'No users were retrieved.'); + returnError('No users were retrieved.'); } } @@ -15827,14 +15777,14 @@ function api_set_reset_agent_counts($id, $thrash1, $thrash2, $thrash3) } if ($id == '' || !$id) { - returnError('error_parameter', __('Error. Agent cannot be left blank.')); + returnError('Error. Agent cannot be left blank.'); return; } if ($id != 'All') { $agent = db_get_row_filter('tagente', ['id_agente' => $id]); if (empty($agent)) { - returnError('error_agent', __('This agent does not exist.')); + returnError('This agent does not exist.'); return; } else { $return = db_process_sql_update( @@ -15862,7 +15812,7 @@ function api_set_reset_agent_counts($id, $thrash1, $thrash2, $thrash3) } if ($return === false) { - returnError('error_reset_agent_counts', 'Could not be updated module/alert counts in id agent %d.', $id); + returnError('Could not be updated module/alert counts in id agent %d.', $id); } else { returnData('string', ['type' => 'string', 'data' => $data]); } @@ -15932,7 +15882,7 @@ function api_get_list_all_user($thrash1, $thrash2, $other, $returnType) } if ($values === false) { - returnError('Error_user', __('Users could not be found.')); + returnError('Users could not be found.'); return; } @@ -16136,14 +16086,14 @@ function api_set_delete_user_permission($thrash1, $thrash2, $other, $returnType) 'id_up' => io_safe_output($other['data'][0]), ]; } else { - returnError('Error_delete', __('User profile could not be deleted.')); + returnError('User profile could not be deleted.'); return; } $deleted_permission = db_process_sql_delete('tusuario_perfil', $values); if ($deleted_permission == false) { - returnError('Error_delete', __('User profile could not be deleted.')); + returnError('User profile could not be deleted.'); return; } @@ -16191,7 +16141,7 @@ function api_set_add_permission_user_to_group($thrash1, $thrash2, $other, $retur $exist_profile = db_get_value_sql($sql); if ($other['data'][3] < 0 || $other['data'][3] > 1) { - returnError('Error_insert', __('User profile could not be available.')); + returnError('User profile could not be available.'); return; } @@ -16218,7 +16168,7 @@ function api_set_add_permission_user_to_group($thrash1, $thrash2, $other, $retur } if ($sucessfull_insert == false) { - returnError('Error_insert', __('User profile could not be available.')); + returnError('User profile could not be available.'); return; } @@ -16279,17 +16229,17 @@ function remove_agent_from_policy($id_policy, $use_agent_name, $params) $policy_agent = (is_metaconsole()) ? db_get_row_filter('tpolicy_agents', ['id_policy' => $id_policy, 'id_agent' => $id_agent, 'id_node' => $id_node]) : db_get_row_filter('tpolicy_agents', ['id_policy' => $id_policy, 'id_agent' => $id_agent]); if (empty($policy)) { - returnError('error_policy', __('This policy does not exist.')); + returnError('This policy does not exist.'); return; } if (empty($agent)) { - returnError('error_agent', __('This agent does not exist.')); + returnError('This agent does not exist.'); return; } if (empty($policy_agent)) { - returnError('error_policy_agent', __('This agent does not exist in this policy.')); + returnError('This agent does not exist in this policy.'); return; } @@ -16297,7 +16247,7 @@ function remove_agent_from_policy($id_policy, $use_agent_name, $params) $data = __('Successfully added to delete pending id agent %d to id policy %d.', $id_agent, $id_policy); if ($return === false) { - returnError('error_delete_policy_agent', 'Could not be deleted id agent %d from id policy %d', $id_agent, $id_policy); + returnError('Could not be deleted id agent %d from id policy %d', $id_agent, $id_policy); } else { returnData('string', ['type' => 'string', 'data' => $data]); } From 91b74fe19f79388c73b05d76bb826a45e413f116 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Wed, 20 Jan 2021 17:55:11 +0100 Subject: [PATCH 11/49] Fixed little issue with the URL --- pandora_console/godmode/wizards/DiscoveryTaskList.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index 1dfc7063e7..abe97b023b 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -494,7 +494,7 @@ class DiscoveryTaskList extends HTML if (check_acl($config['id_user'], 0, 'AW')) { $data[0] = '{'id_recon_server'} ne $master_server) { + my $this_server_status = get_db_value ($dbh, 'SELECT status FROM tserver WHERE id_server = ?', $task->{'id_recon_server'}); + if (!defined($this_server_status) || $this_server_status eq -1) { + my $updated_task = db_process_update ($dbh, 'trecon_task', { 'id_recon_server' => $master_server }, { 'id_rt' => $task->{'id_rt'} }); + log_message('FORGOTTEN DISCOVERY TASKS', 'Updated discovery task '.$task->{'name'}); + } + } + } + + log_message('FORGOTTEN DISCOVERY TASKS', 'Step ended'); +} + + # Init pandora_init_pdb(\%conf); From 5283771e3224cb643c9e2c91c041bebb9dc34ff8 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Thu, 21 Jan 2021 13:33:14 +0100 Subject: [PATCH 13/49] Solved issue with verbosity parameters --- pandora_server/lib/PandoraFMS/Config.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 34f3f468f9..ea378b623e 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -826,7 +826,9 @@ sub pandora_load_config { $pa_config->{"snmp_proc_deadresponse"} = clean_blank($1); } elsif ($parametro =~ m/^verbosity\s+([0-9]*)/i) { - $pa_config->{"verbosity"} = clean_blank($1); + if ($pa_config->{"verbosity"} == 0) { + $pa_config->{"verbosity"} = clean_blank($1); + } } elsif ($parametro =~ m/^server_threshold\s+([0-9]*)/i) { $pa_config->{"server_threshold"} = clean_blank($1); From aee474e43c634a06a28aa692592b1ad5992ae367 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Thu, 4 Feb 2021 14:54:11 +0100 Subject: [PATCH 14/49] Fixed issue with date --- pandora_console/include/functions_events.php | 3 +-- pandora_console/operation/events/events.php | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 75c8e32f80..bbb08c5435 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -4844,8 +4844,7 @@ function events_page_general($event) $user_ack = $event['id_usuario']; } - $date_ack = io_safe_output($event['ack_utimestamp']); - $data[1] = $user_ack.' ('.$date_ack.')'; + $data[1] = $user_ack.' ( '.date($config['date_format'], $event['ack_utimestamp_raw']).' ) '; } else { $data[1] = ''.__('N/A').''; } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index a9f05150b4..99feb96640 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -374,6 +374,9 @@ if (is_ajax()) { } $tmp->agent_name = io_safe_output($tmp->agent_name); + + $tmp->ack_utimestamp_raw = strtotime($tmp->ack_utimestamp); + $tmp->ack_utimestamp = ui_print_timestamp( $tmp->ack_utimestamp, true From d9d82e1803a1a89408ca5a8c59d524e90039cf9e Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 8 Feb 2021 10:22:38 +0100 Subject: [PATCH 15/49] Fixed sorting by description --- .../include/javascript/tree/TreeController.js | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 17f0539848..66aa6ffb35 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -1058,6 +1058,7 @@ var TreeController = { $node.addClass("children-loaded"); }, success: function(data, textStatus, xhr) { + console.log(data); if (data.success) { var $group = $node.children("ul.tree-group"); if ( @@ -1073,7 +1074,22 @@ var TreeController = { $node.append($group); } - _.each(data.tree, function(element) { + // Get the main values of the tree. + var rawTree = Object.values(data.tree); + // Sorting tree by description (services.treeview_services.php). + rawTree.sort(function(a, b) { + var x = a.description.toLowerCase(); + var y = b.description.toLowerCase(); + if (x < y) { + return -1; + } + if (x > y) { + return 1; + } + return 0; + }); + + _.each(rawTree, function(element) { element.jqObject = _processNode($group, element); }); @@ -1112,7 +1128,7 @@ var TreeController = { }); } } - + //console.log($node); return $node; } From 2521b32f1365363dcc0bd7ed8ab589cf481559fd Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 8 Feb 2021 16:33:54 +0100 Subject: [PATCH 16/49] WIP: Backup upload --- .../massive/massive_add_action_alerts.php | 3 +- .../godmode/massive/massive_edit_modules.php | 3 +- .../godmode/massive/massive_operations.php | 18 ++++--- pandora_console/include/functions_ui.php | 52 +++++++++++++++++++ pandora_console/include/styles/pandora.css | 13 +++++ 5 files changed, 80 insertions(+), 9 deletions(-) diff --git a/pandora_console/godmode/massive/massive_add_action_alerts.php b/pandora_console/godmode/massive/massive_add_action_alerts.php index 4107c193ec..7bfbbee09f 100755 --- a/pandora_console/godmode/massive/massive_add_action_alerts.php +++ b/pandora_console/godmode/massive/massive_add_action_alerts.php @@ -259,6 +259,7 @@ echo ''; echo ''; +ui_require_javascript_file('massive_operations'); ui_require_jquery_file('form'); ui_require_jquery_file('pandora.controls'); ?> @@ -276,7 +277,7 @@ $(document).ready (function () { get_parameters_count + post_parameters_count; if (count_parameters > limit_parameters_massive) { - alert(""); + showMassiveOperationMessage(); return false; } }); diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 07a3d94174..a097b460ca 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -1185,6 +1185,7 @@ $table->data['edit1'][1] = ''; // Hack to translate text "none" in PHP to javascript echo ''; echo ''; + ui_require_javascript_file('massive_operations'); ui_require_jquery_file('pandora.controls'); if ($selection_mode == 'modules') { @@ -1213,7 +1214,7 @@ $(document).ready (function () { get_parameters_count + post_parameters_count; if (count_parameters > limit_parameters_massive) { - alert(""); + showMassiveOperationMessage(''); return false; } }); diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php index 8aa329508b..b82d4dcda9 100755 --- a/pandora_console/godmode/massive/massive_operations.php +++ b/pandora_console/godmode/massive/massive_operations.php @@ -316,11 +316,15 @@ $submit_template_enabled = get_parameter('id_alert_template_enabled'); $submit_template_not_standby = get_parameter('id_alert_template_not_standby'); $submit_template_standby = get_parameter('id_alert_template_standby'); $submit_add = get_parameter('crtbutton'); - -echo '
'; -echo html_print_image('images/wait.gif', true, ['border' => '0']).'
'; -echo ''.__('Please wait...').''; -echo '
'; +// Waiting spinner. +ui_print_spinner(__('Loading')); +// Modal for show messages. +html_print_div( + [ + 'id' => 'massive_modal', + 'content' => '', + ] +); ?> diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index d3005d5639..fcf9adce0d 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -6273,3 +6273,55 @@ function ui_print_reveal_password(string $name, bool $return=false) echo $output; } + + +/** + * Generate a spinner box for waiting times + * + * @param string $text Text for show in spinner. English Loading for default. + * @param boolean $return If true, return the string with the formed element. + * + * @return string + */ +function ui_print_spinner(string $text='Loading', bool $return=false) +{ + $output = ''; + + $output .= '
'; + + $output .= html_print_div( + [ + 'id' => 'loading_spinner', + 'class' => 'white_box invisible', + 'content' => ''.$text.'...'.html_print_image( + 'images/spinner.gif', + true, + [ + 'border' => '0', + 'width' => '25px', + 'heigth' => '25px', + ] + ), + ], + true + ); + + $output .= '
'; + + $output .= ' + + '; + + if ($return === true) { + return $output; + } else { + echo $output; + } +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 9a1ce23dca..c2cb379ea4 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -792,6 +792,7 @@ p.center { cursor: help; } +/* Legacy spinner */ #loading { position: fixed; width: 200px; @@ -802,6 +803,18 @@ p.center { padding: 20px; } +/* New standard spinner */ +#loading_spinner { + position: fixed; + margin-left: 30%; + text-align: center; + top: 50%; + background-color: #fff; + border: 2px solid #82b92e; + box-shadow: 2px 2px 2px #9dbba1; + padding: 20px; +} + .tactical_set legend { text-align: left; color: #3f3f3f; From e727f7c276a63d515f1fc89c040b4e732056d17b Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Fri, 12 Feb 2021 11:28:13 +0100 Subject: [PATCH 17/49] Added modals and fixed some bugs --- .../massive/massive_add_action_alerts.php | 67 ++++++------- .../godmode/massive/massive_add_alerts.php | 14 ++- .../godmode/massive/massive_add_profiles.php | 48 +++++---- .../godmode/massive/massive_copy_modules.php | 60 +++++++----- .../massive/massive_delete_action_alerts.php | 45 ++++++--- .../godmode/massive/massive_delete_agents.php | 64 ++++++------ .../godmode/massive/massive_delete_alerts.php | 49 ++++++---- .../massive/massive_delete_modules.php | 71 +++++++------- .../massive/massive_delete_profiles.php | 48 +++++---- .../godmode/massive/massive_edit_agents.php | 85 +++++++++------- .../godmode/massive/massive_edit_modules.php | 93 +++++++++--------- .../godmode/massive/massive_edit_plugins.php | 44 ++++++--- .../massive/massive_enable_disable_alerts.php | 39 +++++--- .../godmode/massive/massive_operations.php | 84 ++++++++++------ .../massive/massive_standby_alerts.php | 43 +++++--- .../include/functions_massive_operations.php | 97 +++++++++++++++++++ pandora_console/include/functions_ui.php | 3 +- .../include/javascript/massive_operations.js | 93 ++++++++++++++++++ pandora_console/include/styles/pandora.css | 1 + 19 files changed, 690 insertions(+), 358 deletions(-) create mode 100644 pandora_console/include/functions_massive_operations.php create mode 100644 pandora_console/include/javascript/massive_operations.js diff --git a/pandora_console/godmode/massive/massive_add_action_alerts.php b/pandora_console/godmode/massive/massive_add_action_alerts.php index 7bfbbee09f..f9a02c8545 100755 --- a/pandora_console/godmode/massive/massive_add_action_alerts.php +++ b/pandora_console/godmode/massive/massive_add_action_alerts.php @@ -1,17 +1,32 @@ data[1][0] .= ''; $table->data[1][1] = html_print_select([], 'id_agents[]', 0, false, __('Any'), '', true, true); $table->data[2][0] = __('Alert templates'); -$table->data[2][0] .= ''; $table->data[2][1] = html_print_select([], 'id_alert_templates[]', '', '', '', '', true, true, true, '', $alert_templates == 0); $table->data[2][2] = __('When select agents'); $table->data[2][2] .= '
'; @@ -251,10 +263,8 @@ $agents_with_templates_json = json_encode($agents_with_templates_json); echo ""; -echo '
'; -html_print_input_hidden('add', 1); -html_print_submit_button(__('Add'), 'go', false, 'class="sub add"'); -echo '
'; +attachActionButton('add', 'create', $table->width); + echo ''; echo ''; @@ -265,23 +275,8 @@ ui_require_jquery_file('pandora.controls'); ?> - - "+value+""; }); $("#id_alert_templates").append (options); - $("#template_loading").hide (); + hideSpinner(); $select_template.enable (); }, "json" diff --git a/pandora_console/include/functions_massive_operations.php b/pandora_console/include/functions_massive_operations.php new file mode 100644 index 0000000000..389d87ddcc --- /dev/null +++ b/pandora_console/include/functions_massive_operations.php @@ -0,0 +1,97 @@ + 'action-buttons', + 'style' => sprintf('width: %s', $tableWidth), + 'content' => html_print_input_hidden( + $action, + 1 + ).html_print_button( + __($caption), + 'go', + false, + '', + sprintf('class="sub %s"', $class), + true + ), + ], + $return + ); +} diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index fcf9adce0d..8cb234db8e 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -6277,8 +6277,9 @@ function ui_print_reveal_password(string $name, bool $return=false) /** * Generate a spinner box for waiting times + * TIP: It's made for Massive Operations, but it migth used in entire project. * - * @param string $text Text for show in spinner. English Loading for default. + * @param string $text Text for show in spinner. English term Loading for default. * @param boolean $return If true, return the string with the formed element. * * @return string diff --git a/pandora_console/include/javascript/massive_operations.js b/pandora_console/include/javascript/massive_operations.js new file mode 100644 index 0000000000..dd1c8acd13 --- /dev/null +++ b/pandora_console/include/javascript/massive_operations.js @@ -0,0 +1,93 @@ +/** global $ */ +function massiveOperationValidation(contents, totalCount, limit, thisForm) { + var output = false; + + // If the amount of changes exceed the limit, the operation stops. + if (totalCount > limit) { + // Set the content. + $("#massive_modal") + .empty() + .html(contents.html); + // Set the title. + $("#massive_modal").prop("title", contents.title); + // Build the dialog for show the mesage. + $("#massive_modal").dialog({ + resizable: true, + draggable: true, + modal: true, + width: 800, + buttons: [ + { + text: "OK", + click: function() { + hideSpinner(); + $(this).dialog("close"); + return false; + } + } + ], + overlay: { + opacity: 0.5, + background: "black" + }, + closeOnEscape: false, + open: function(event, ui) { + $(".ui-dialog-titlebar-close").hide(); + } + }); + + return false; + } else { + confirmDialog({ + title: contents.title, + message: contents.question, + ok: contents.ok, + cancel: contents.cancel, + onAccept: function() { + showSpinner(); + output = true; + $("#" + thisForm).submit(); + }, + onDeny: function() { + hideSpinner(); + return false; + } + }); + } + + return output; +} + +/* +function showMassiveOperationMessage(message) { + $("#massive_modal") + .empty() + .html(message); + + $("#massive_modal").prop("title", "Massive operations"); + + $("#massive_modal").dialog({ + resizable: true, + draggable: true, + modal: true, + width: 800, + buttons: [ + { + text: "OK", + click: function() { + $(this).dialog("close"); + hideSpinner(); + } + } + ], + overlay: { + opacity: 0.5, + background: "black" + }, + closeOnEscape: false, + open: function(event, ui) { + $(".ui-dialog-titlebar-close").hide(); + } + }); +} +*/ diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index c2cb379ea4..79e5572823 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -813,6 +813,7 @@ p.center { border: 2px solid #82b92e; box-shadow: 2px 2px 2px #9dbba1; padding: 20px; + z-index: 100; } .tactical_set legend { From 64ae9641911ce55923b36ada623f1242c069440a Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Fri, 19 Feb 2021 14:30:09 +0100 Subject: [PATCH 18/49] Fixed forced 2FA --- pandora_console/general/register.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pandora_console/general/register.php b/pandora_console/general/register.php index 9f90e7ad39..9147a0e016 100644 --- a/pandora_console/general/register.php +++ b/pandora_console/general/register.php @@ -234,8 +234,8 @@ if (!$double_auth_enabled && $config['2FA_all_users'] != '' } }); - $("div#doble_auth_window").dialog({ + $("div#doble_auth_window").dialog({ resizable: true, draggable: true, modal: true, @@ -247,12 +247,6 @@ if (!$double_auth_enabled && $config['2FA_all_users'] != '' width: 500, height: 400, close: function (event, ui) { - - // Abort the ajax request if (typeof request != 'undefined'){ request.abort(); From af680b5d924469c8ab1cf385fff2442fe9acbf7a Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 1 Mar 2021 13:58:04 +0100 Subject: [PATCH 19/49] permissions limitation for command management --- .../godmode/alerts/alert_commands.php | 35 +++++++++++++++++-- .../alerts/configure_alert_command.php | 4 +-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 001cfc0430..20a84f0dc1 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -28,6 +28,12 @@ if (! check_acl($config['id_user'], 0, 'LM')) { exit; } +if (!check_acl($config['id_user'], 0, 'PM') && !is_user_admin($config['id_user'])) { + echo "'; +} + if (is_metaconsole()) { $sec = 'advanced'; } else { @@ -558,7 +564,7 @@ foreach ($commands as $command) { $data['name'] = ''; // (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group. - if (!$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'LM')) { + if (!$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'PM')) { $data['name'] .= ''.$command['name'].''; } else { $data['name'] .= $command['name']; @@ -584,7 +590,7 @@ foreach ($commands as $command) { $table->cellclass[]['action'] = 'action_buttons'; // (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group. - if ($is_central_policies_on_node === false && !$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'LM')) { + if ($is_central_policies_on_node === false && !$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'PM')) { $data['action'] = ''; $data['action'] .= ''.html_print_image('images/copy.png', true).''; @@ -602,7 +608,7 @@ if (count($table->data) > 0) { ui_print_info_message(['no_close' => true, 'message' => __('No alert commands configured') ]); } -if ($is_central_policies_on_node === false) { +if ($is_central_policies_on_node === false && check_acl_restricted_all($config['id_user'], $command['id_group'], 'PM')) { echo '
'; echo '
'; html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); @@ -612,3 +618,26 @@ if ($is_central_policies_on_node === false) { } enterprise_hook('close_meta_frame'); + +?> + + \ No newline at end of file diff --git a/pandora_console/godmode/alerts/configure_alert_command.php b/pandora_console/godmode/alerts/configure_alert_command.php index 2882d260db..88da3e5abf 100644 --- a/pandora_console/godmode/alerts/configure_alert_command.php +++ b/pandora_console/godmode/alerts/configure_alert_command.php @@ -21,7 +21,7 @@ check_login(); enterprise_hook('open_meta_frame'); -if (! check_acl($config['id_user'], 0, 'LM')) { +if (! check_acl($config['id_user'], 0, 'PM')) { db_pandora_audit( 'ACL Violation', 'Trying to access Alert Management' @@ -51,7 +51,7 @@ if (is_metaconsole() === true) { if ($id > 0) { $alert = alerts_get_alert_command($id); - if ($alert['internal'] || !check_acl_restricted_all($config['id_user'], $alert['id_group'], 'LM')) { + if ($alert['internal'] || !check_acl_restricted_all($config['id_user'], $alert['id_group'], 'PM')) { db_pandora_audit('ACL Violation', 'Trying to access Alert Management'); include 'general/noaccess.php'; exit; From 9b3f6f1efb925d0d3fdf78344d09a120ca8800c5 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Tue, 2 Mar 2021 10:42:08 +0100 Subject: [PATCH 20/49] added option to disable selected agents massively --- .../godmode/agentes/module_manager.php | 82 ++++++++++++++++--- 1 file changed, 71 insertions(+), 11 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 35f4c7943a..1d900b192d 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -222,9 +222,9 @@ if (! isset($id_agente)) { } -$multiple_delete = (bool) get_parameter('multiple_delete'); +$module_action = (string) get_parameter('module_action'); -if ($multiple_delete) { +if ($module_action === 'delete') { $id_agent_modules_delete = (array) get_parameter('id_delete'); $count_correct_delete_modules = 0; @@ -400,23 +400,63 @@ if ($multiple_delete) { if ($count_correct_delete_modules == 0) { ui_print_error_message( sprintf( - __('There was a problem deleting %s modules, none deleted.'), + __('There was a problem completing the operation. Applied to 0/%d modules.'), $count_modules_to_delete ) ); } else { if ($count_correct_delete_modules == $count_modules_to_delete) { - ui_print_success_message(__('All Modules deleted succesfully')); + ui_print_success_message(__('Operation finished successfully.')); } else { ui_print_error_message( sprintf( - __('There was a problem only deleted %s modules of %s total.'), - count_correct_delete_modules, + __('There was a problem completing the operation. Applied to %d/%d modules.'), + $count_correct_delete_modules, $count_modules_to_delete ) ); } } +} else if ($module_action === 'disable') { + $id_agent_modules_disable = (array) get_parameter('id_delete'); + + $count_correct_delete_modules = 0; + $updated_count = 0; + + foreach ($id_agent_modules_disable as $id_agent_module_disable) { + $sql = sprintf( + 'UPDATE tagente_modulo + SET disabled = 1 + WHERE id_agente_modulo = %d', + $id_agent_module_disable + ); + + if (db_process_sql($sql)) { + $updated_count++; + } + } + + $count_modules_to_disable = count($id_agent_modules_disable); + if ($updated_count === 0) { + ui_print_error_message( + sprintf( + __('There was a problem completing the operation. Applied to 0/%d modules.'), + $count_modules_to_disable + ) + ); + } else { + if ($updated_count == $count_modules_to_disable) { + ui_print_success_message(__('Operation finished successfully.')); + } else { + ui_print_error_message( + sprintf( + __('There was a problem completing the operation. Applied to %d/%d modules.'), + $updated_count, + $count_modules_to_disable + ) + ); + } + } } @@ -845,6 +885,9 @@ foreach ($modules as $module) { 'id_delete[]', $module['id_agente_modulo'], false, + true, + false, + '', true ); } @@ -1123,12 +1166,29 @@ html_print_table($table); if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { echo '
'; - html_print_input_hidden('multiple_delete', 1); - html_print_submit_button( - __('Delete'), - 'multiple_delete', + + html_print_input_hidden('submit_modules_action', 1); + + html_print_select( + [ + 'disable' => 'Disable selected modules', + 'delete' => 'Delete selected modules', + ], + 'module_action', + '', + '', + '', + 0, false, - 'class="sub delete"' + false, + false + ); + + html_print_submit_button( + __('Execute action'), + 'submit_modules_action', + false, + 'class="sub next"' ); echo '
'; echo ''; From 6ee5b9c3e9c43b1a54856cf3d8f4c637a146513a Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Thu, 4 Mar 2021 11:33:21 +0100 Subject: [PATCH 21/49] Fix issues --- .../godmode/massive/massive_edit_plugins.php | 35 ++-------- .../include/javascript/massive_operations.js | 65 ++++++++++--------- 2 files changed, 39 insertions(+), 61 deletions(-) diff --git a/pandora_console/godmode/massive/massive_edit_plugins.php b/pandora_console/godmode/massive/massive_edit_plugins.php index 1b721ac1a5..bcbed6238d 100644 --- a/pandora_console/godmode/massive/massive_edit_plugins.php +++ b/pandora_console/godmode/massive/massive_edit_plugins.php @@ -417,35 +417,6 @@ echo ''; canSubmit = val; $submitButton.prop('disabled', !val); } - - var showSpinner = function () { - var $loadingSpinner = $pluginsSelect.siblings('img#loading_spinner'); - - if ($loadingSpinner.length > 0) { - // Display inline instead using the show function - // cause its absolute positioning. - $loadingSpinner.css('display', 'inline'); - return; - } - - $loadingSpinner = $(''); - - $loadingSpinner - .prop('id', 'loading_spinner') - .css('padding-left', '5px') - .css('position', 'absolute') - .css('top', $pluginsSelect.position().top + 'px') - .prop('src', "images/spinner.gif"); - - $pluginsSelect.parent().append($loadingSpinner); - } - - var hideSpinner = function () { - var $loadingSpinner = $pluginsSelect.siblings('img#loading_spinner'); - - if ($loadingSpinner.length > 0) - $loadingSpinner.hide(); - } var clearModulePluginMacrosValues = function () { $('input.plugin-macro') @@ -876,6 +847,7 @@ echo ''; } var errorHandler = function (error) { + hideSpinner(); console.log(": " + error.message); // alert(": " + err.message); @@ -939,7 +911,10 @@ echo ''; $agentModulesRow.show(); } else { - alert(""); + var contents = {}; + contents.html = ''; + contents.title = ''; + showMassiveModal(contents); // Abort the another call if (typeof pluginXHR !== 'undefined') { diff --git a/pandora_console/include/javascript/massive_operations.js b/pandora_console/include/javascript/massive_operations.js index dd1c8acd13..2335c2a305 100644 --- a/pandora_console/include/javascript/massive_operations.js +++ b/pandora_console/include/javascript/massive_operations.js @@ -4,37 +4,7 @@ function massiveOperationValidation(contents, totalCount, limit, thisForm) { // If the amount of changes exceed the limit, the operation stops. if (totalCount > limit) { - // Set the content. - $("#massive_modal") - .empty() - .html(contents.html); - // Set the title. - $("#massive_modal").prop("title", contents.title); - // Build the dialog for show the mesage. - $("#massive_modal").dialog({ - resizable: true, - draggable: true, - modal: true, - width: 800, - buttons: [ - { - text: "OK", - click: function() { - hideSpinner(); - $(this).dialog("close"); - return false; - } - } - ], - overlay: { - opacity: 0.5, - background: "black" - }, - closeOnEscape: false, - open: function(event, ui) { - $(".ui-dialog-titlebar-close").hide(); - } - }); + showMassiveModal(contents); return false; } else { @@ -58,6 +28,39 @@ function massiveOperationValidation(contents, totalCount, limit, thisForm) { return output; } +function showMassiveModal(contents) { + $("#massive_modal") + .empty() + .html(contents.html); + // Set the title. + $("#massive_modal").prop("title", contents.title); + // Build the dialog for show the mesage. + $("#massive_modal").dialog({ + resizable: true, + draggable: true, + modal: true, + width: 800, + buttons: [ + { + text: "OK", + click: function() { + hideSpinner(); + $(this).dialog("close"); + return false; + } + } + ], + overlay: { + opacity: 0.5, + background: "black" + }, + closeOnEscape: false, + open: function(event, ui) { + $(".ui-dialog-titlebar-close").hide(); + } + }); +} + /* function showMassiveOperationMessage(message) { $("#massive_modal") From eb912405a6fcd270c6492b5ec6053115d010f362 Mon Sep 17 00:00:00 2001 From: artica Date: Fri, 5 Mar 2021 01:00:53 +0100 Subject: [PATCH 22/49] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 6a4a4dc198..fe171e560d 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.752-210304 +Version: 7.0NG.752-210305 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 2990cb5a3f..63cc18fa59 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.752-210304" +pandora_version="7.0NG.752-210305" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 1cdd231861..c0846947b3 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1016,7 +1016,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.752'; -use constant AGENT_BUILD => '210304'; +use constant AGENT_BUILD => '210305'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 0629182cd7..36bcae854c 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.752 -%define release 210304 +%define release 210305 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index ecf9b558d4..83360a8948 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.752 -%define release 210304 +%define release 210305 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 25435c6c2d..2223521c32 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.752" -PI_BUILD="210304" +PI_BUILD="210305" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index c0171698cf..b50a2bbe83 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{210304} +{210305} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 7ef00c586a..23085532cd 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.752(Build 210304)") +#define PANDORA_VERSION ("7.0NG.752(Build 210305)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index db55fbfdcf..23a2ccab7c 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.752(Build 210304))" + VALUE "ProductVersion", "(7.0NG.752(Build 210305))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 2874b6e3a6..e806ac9741 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.752-210304 +Version: 7.0NG.752-210305 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 1c4d4a4832..2729c114e2 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.752-210304" +pandora_version="7.0NG.752-210305" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 8911534e01..8a3f100825 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC210304'; +$build_version = 'PC210305'; $pandora_version = 'v7.0NG.752'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 4ee596ad39..bf39316e96 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index f23be19971..d9c7939d23 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.752 -%define release 210304 +%define release 210305 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 1be43fa3bd..f31a44d953 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.752 -%define release 210304 +%define release 210305 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 9c1c2f0c06..3419be6cb3 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.752" -PI_BUILD="210304" +PI_BUILD="210305" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index cd73da832f..c62b80fa1a 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.752 PS210304"; +my $version = "7.0NG.752 PS210305"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 21e1917f48..6c3f54084c 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.752 PS210304"; +my $version = "7.0NG.752 PS210305"; # save program name for logging my $progname = basename($0); From 1534fd9c40ea48c42367e14524ccd728ca4281fb Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 5 Mar 2021 10:30:14 +0100 Subject: [PATCH 23/49] API module graph width --- pandora_console/include/chart_generator.php | 11 ++++++++--- pandora_console/include/functions_api.php | 8 +++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index 50d81a87e9..8a49d52436 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -178,14 +178,19 @@ if (file_exists('languages/'.$user_language.'.mo') === true) { $params_combined = json_decode($data_combined, true); $module_list = json_decode($data_module_list, true); - $type_graph_pdf = $type_graph_pdf; if (isset($params['vconsole']) === false || $params['vconsole'] === false) { - $params['width'] = (int) $viewport_width; + if ((int) $viewport_width > 0) { + $params['width'] = (int) $viewport_width; + } + if ((isset($params['width']) === false || ($params['width'] <= 0)) ) { - $params['width'] = 650; + if ((int) $params['width'] <= 0) { + $params['width'] = 650; + } + if ((int) $params['landscape'] === 1) { $params['width'] = 850; } diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index ef49a94ad9..dfc0fe1dc5 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -13767,16 +13767,18 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) } if (is_array($other['data']) === true) { + // Parameters received by user call. $graph_seconds = (!empty($other) && isset($other['data'][0])) ? $other['data'][0] : SECONDS_1HOUR; // 1 hour by default. - $graph_threshold = (!empty($other) && isset($other['data'][2]) && $other['data'][2]) ? $other['data'][2] : 0; + $graph_threshold = (!empty($other) && isset($other['data'][1]) && $other['data'][1]) ? $other['data'][1] : 0; // Graph height when send email by alert - $height = (!empty($other) && isset($other['data'][3]) && $other['data'][3]) ? $other['data'][3] : 225; + $height = (!empty($other) && isset($other['data'][2]) && $other['data'][2]) ? $other['data'][2] : 225; // Graph width (optional). - $width = (!empty($other) && isset($other['data'][4]) && $other['data'][4]) ? $other['data'][4] : 225; + $width = (!empty($other) && isset($other['data'][3]) && $other['data'][3]) ? $other['data'][3] : ''; } else { + // Fixed parameters for _modulegraph_nh_. $graph_seconds = $other['data']; $graph_threshold = 0; $other['data'][1] = 0; From ae3d54cedf14af7fcf4ee93fe363a1d7947471a4 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 5 Mar 2021 11:11:19 +0100 Subject: [PATCH 24/49] B64 included in user options --- pandora_console/include/functions_api.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index dfc0fe1dc5..4a14cd1e56 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -13766,17 +13766,23 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) return; } + $user_defined = false; if (is_array($other['data']) === true) { + $user_defined = true; // Parameters received by user call. $graph_seconds = (!empty($other) && isset($other['data'][0])) ? $other['data'][0] : SECONDS_1HOUR; - // 1 hour by default. + + // Base64. $graph_threshold = (!empty($other) && isset($other['data'][1]) && $other['data'][1]) ? $other['data'][1] : 0; + // 1 hour by default. + $graph_threshold = (!empty($other) && isset($other['data'][2]) && $other['data'][2]) ? $other['data'][2] : 0; + // Graph height when send email by alert - $height = (!empty($other) && isset($other['data'][2]) && $other['data'][2]) ? $other['data'][2] : 225; + $height = (!empty($other) && isset($other['data'][3]) && $other['data'][3]) ? $other['data'][3] : 225; // Graph width (optional). - $width = (!empty($other) && isset($other['data'][3]) && $other['data'][3]) ? $other['data'][3] : ''; + $width = (!empty($other) && isset($other['data'][4]) && $other['data'][4]) ? $other['data'][4] : ''; } else { // Fixed parameters for _modulegraph_nh_. $graph_seconds = $other['data']; From bcde9f940e538d71e8aadea0ec2e1419c263d4e5 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 5 Mar 2021 11:17:50 +0100 Subject: [PATCH 25/49] b64 --- pandora_console/include/functions_api.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 4a14cd1e56..5038f05328 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -13773,7 +13773,7 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) $graph_seconds = (!empty($other) && isset($other['data'][0])) ? $other['data'][0] : SECONDS_1HOUR; // Base64. - $graph_threshold = (!empty($other) && isset($other['data'][1]) && $other['data'][1]) ? $other['data'][1] : 0; + $base64 = $other['data'][1]; // 1 hour by default. $graph_threshold = (!empty($other) && isset($other['data'][2]) && $other['data'][2]) ? $other['data'][2] : 0; @@ -13787,7 +13787,7 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) // Fixed parameters for _modulegraph_nh_. $graph_seconds = $other['data']; $graph_threshold = 0; - $other['data'][1] = 0; + $base64 = 0; $height = 225; $width = '90%'; } @@ -13823,7 +13823,7 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) $graph_html = grafico_modulo_sparse($params); - if ($other['data'][1]) { + if ($base64) { header('Content-type: text/html'); returnData('string', ['type' => 'string', 'data' => '']); } else { From cfded31e1bcb26422e72599e233a235a2e5f641f Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 5 Mar 2021 11:18:47 +0100 Subject: [PATCH 26/49] minor fix --- 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 5038f05328..26abc0db54 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -13823,7 +13823,7 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) $graph_html = grafico_modulo_sparse($params); - if ($base64) { + if ((bool) $base64 === false) { header('Content-type: text/html'); returnData('string', ['type' => 'string', 'data' => '']); } else { From 0860b6e647e0944fa65d15bd88c6126e896d430a Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Fri, 5 Mar 2021 13:07:53 +0100 Subject: [PATCH 27/49] Fix ordenation with subservices --- pandora_console/include/javascript/tree/TreeController.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 66aa6ffb35..38e9e7cedd 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -1058,7 +1058,6 @@ var TreeController = { $node.addClass("children-loaded"); }, success: function(data, textStatus, xhr) { - console.log(data); if (data.success) { var $group = $node.children("ul.tree-group"); if ( @@ -1078,8 +1077,8 @@ var TreeController = { var rawTree = Object.values(data.tree); // Sorting tree by description (services.treeview_services.php). rawTree.sort(function(a, b) { - var x = a.description.toLowerCase(); - var y = b.description.toLowerCase(); + var x = a.elementDescription.toLowerCase(); + var y = b.elementDescription.toLowerCase(); if (x < y) { return -1; } @@ -1128,7 +1127,7 @@ var TreeController = { }); } } - //console.log($node); + return $node; } From 80c568bbdd780ebc462d26607a149525ebdc6ea8 Mon Sep 17 00:00:00 2001 From: artica Date: Sat, 6 Mar 2021 01:00:19 +0100 Subject: [PATCH 28/49] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index fe171e560d..c8eff88a47 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.752-210305 +Version: 7.0NG.752-210306 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 63cc18fa59..c53fe17356 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.752-210305" +pandora_version="7.0NG.752-210306" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index c0846947b3..fba21aee8a 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1016,7 +1016,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.752'; -use constant AGENT_BUILD => '210305'; +use constant AGENT_BUILD => '210306'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 36bcae854c..da042cad6b 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.752 -%define release 210305 +%define release 210306 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 83360a8948..675f4ee531 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.752 -%define release 210305 +%define release 210306 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 2223521c32..6725b267c2 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.752" -PI_BUILD="210305" +PI_BUILD="210306" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index b50a2bbe83..63c710b816 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{210305} +{210306} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 23085532cd..5bb2d08c51 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.752(Build 210305)") +#define PANDORA_VERSION ("7.0NG.752(Build 210306)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 23a2ccab7c..ddf32831a5 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.752(Build 210305))" + VALUE "ProductVersion", "(7.0NG.752(Build 210306))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index e806ac9741..8a4edaa0aa 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.752-210305 +Version: 7.0NG.752-210306 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 2729c114e2..590e089d8e 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.752-210305" +pandora_version="7.0NG.752-210306" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 8a3f100825..2c09a98ae7 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC210305'; +$build_version = 'PC210306'; $pandora_version = 'v7.0NG.752'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index bf39316e96..205b313762 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index d9c7939d23..ff47eba267 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.752 -%define release 210305 +%define release 210306 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index f31a44d953..35a34c13c5 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.752 -%define release 210305 +%define release 210306 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 3419be6cb3..6b49659b33 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.752" -PI_BUILD="210305" +PI_BUILD="210306" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index c62b80fa1a..d0857ec667 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.752 PS210305"; +my $version = "7.0NG.752 PS210306"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 6c3f54084c..9e584b19a3 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.752 PS210305"; +my $version = "7.0NG.752 PS210306"; # save program name for logging my $progname = basename($0); From 438c388423f30c743e935ca99590a0489f4279b9 Mon Sep 17 00:00:00 2001 From: artica Date: Sun, 7 Mar 2021 01:00:17 +0100 Subject: [PATCH 29/49] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index c8eff88a47..6ad47e68c0 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.752-210306 +Version: 7.0NG.752-210307 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index c53fe17356..87d421a613 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.752-210306" +pandora_version="7.0NG.752-210307" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index fba21aee8a..528dbfe451 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1016,7 +1016,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.752'; -use constant AGENT_BUILD => '210306'; +use constant AGENT_BUILD => '210307'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index da042cad6b..9ef1379afe 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.752 -%define release 210306 +%define release 210307 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 675f4ee531..ed47f685b4 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.752 -%define release 210306 +%define release 210307 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 6725b267c2..10c10ddf69 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.752" -PI_BUILD="210306" +PI_BUILD="210307" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 63c710b816..b1128417d4 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{210306} +{210307} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 5bb2d08c51..7467df422c 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.752(Build 210306)") +#define PANDORA_VERSION ("7.0NG.752(Build 210307)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index ddf32831a5..bc890ab989 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.752(Build 210306))" + VALUE "ProductVersion", "(7.0NG.752(Build 210307))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 8a4edaa0aa..1ccc47a726 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.752-210306 +Version: 7.0NG.752-210307 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 590e089d8e..6b3d1e6575 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.752-210306" +pandora_version="7.0NG.752-210307" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 2c09a98ae7..c64fc9cee0 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC210306'; +$build_version = 'PC210307'; $pandora_version = 'v7.0NG.752'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 205b313762..3d536a5de4 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index ff47eba267..da061c1f08 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.752 -%define release 210306 +%define release 210307 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 35a34c13c5..b50af0eb45 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.752 -%define release 210306 +%define release 210307 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 6b49659b33..6ef451fe42 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.752" -PI_BUILD="210306" +PI_BUILD="210307" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index d0857ec667..1ae50e1f22 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.752 PS210306"; +my $version = "7.0NG.752 PS210307"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 9e584b19a3..21b112a2e8 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.752 PS210306"; +my $version = "7.0NG.752 PS210307"; # save program name for logging my $progname = basename($0); From 2bd9515152333ad1b3c0543ff23cf05ca4c8cf65 Mon Sep 17 00:00:00 2001 From: artica Date: Mon, 8 Mar 2021 01:00:14 +0100 Subject: [PATCH 30/49] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 6ad47e68c0..3f82a619ac 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.752-210307 +Version: 7.0NG.752-210308 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 87d421a613..95e1c73ad9 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.752-210307" +pandora_version="7.0NG.752-210308" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 528dbfe451..1f84562473 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1016,7 +1016,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.752'; -use constant AGENT_BUILD => '210307'; +use constant AGENT_BUILD => '210308'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 9ef1379afe..a3fc37b3a2 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.752 -%define release 210307 +%define release 210308 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index ed47f685b4..9e61f17a0e 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.752 -%define release 210307 +%define release 210308 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 10c10ddf69..cc25c5f884 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.752" -PI_BUILD="210307" +PI_BUILD="210308" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index b1128417d4..8ebe9018c8 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{210307} +{210308} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 7467df422c..c37e5a6d36 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.752(Build 210307)") +#define PANDORA_VERSION ("7.0NG.752(Build 210308)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index bc890ab989..3e53ce3508 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.752(Build 210307))" + VALUE "ProductVersion", "(7.0NG.752(Build 210308))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 1ccc47a726..9fd4f4cfdf 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.752-210307 +Version: 7.0NG.752-210308 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 6b3d1e6575..362856d1b5 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.752-210307" +pandora_version="7.0NG.752-210308" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index c64fc9cee0..cbe6f85d52 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC210307'; +$build_version = 'PC210308'; $pandora_version = 'v7.0NG.752'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 3d536a5de4..8b4d142c75 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index da061c1f08..eb1805f7e4 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.752 -%define release 210307 +%define release 210308 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index b50af0eb45..f02df44325 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.752 -%define release 210307 +%define release 210308 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 6ef451fe42..be4198f1a1 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.752" -PI_BUILD="210307" +PI_BUILD="210308" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 1ae50e1f22..7a92bd1fcf 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.752 PS210307"; +my $version = "7.0NG.752 PS210308"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 21b112a2e8..dcd87d9b31 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.752 PS210307"; +my $version = "7.0NG.752 PS210308"; # save program name for logging my $progname = basename($0); From c235cfb01a10cd4620396c669f680ab220a04333 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 8 Mar 2021 08:21:45 +0100 Subject: [PATCH 31/49] Fixed --- pandora_console/include/functions_events.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index bbb08c5435..d60cabd354 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -4833,15 +4833,19 @@ function events_page_general($event) $data[0] = __('Acknowledged by'); if ($event['estado'] == 1) { - $user_ack = db_get_value( - 'fullname', - 'tusuario', - 'id_user', - $event['id_usuario'] - ); + if (empty($event['id_usuario']) === true) { + $user_ack = __('Autovalidated'); + } else { + $user_ack = db_get_value( + 'fullname', + 'tusuario', + 'id_user', + $event['id_usuario'] + ); - if (empty($user_ack) === true) { - $user_ack = $event['id_usuario']; + if (empty($user_ack) === true) { + $user_ack = $event['id_usuario']; + } } $data[1] = $user_ack.' ( '.date($config['date_format'], $event['ack_utimestamp_raw']).' ) '; From 34b7c1003b87a29a174994a85c83e8bbc76e9c10 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 8 Mar 2021 11:20:50 +0100 Subject: [PATCH 32/49] Fixed error with sorting --- .../include/javascript/tree/TreeController.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 38e9e7cedd..ee8de7a5d9 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -1077,13 +1077,16 @@ var TreeController = { var rawTree = Object.values(data.tree); // Sorting tree by description (services.treeview_services.php). rawTree.sort(function(a, b) { - var x = a.elementDescription.toLowerCase(); - var y = b.elementDescription.toLowerCase(); - if (x < y) { - return -1; - } - if (x > y) { - return 1; + // Only the services are ordered since only they have the elementDescription property. + if (a.elementDescription && b.elementDescription) { + var x = a.elementDescription.toLowerCase(); + var y = b.elementDescription.toLowerCase(); + if (x < y) { + return -1; + } + if (x > y) { + return 1; + } } return 0; }); From 0a8c478c473afb960cff1c0b59f7c05f3ba8b559 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 8 Mar 2021 17:48:59 +0100 Subject: [PATCH 33/49] visual fixes in agent view graphs --- pandora_console/include/ajax/graph.ajax.php | 8 +++++++- pandora_console/include/functions.php | 12 ++++++++++++ pandora_console/operation/agentes/graphs.php | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/ajax/graph.ajax.php b/pandora_console/include/ajax/graph.ajax.php index 09c4355b57..554f8c8118 100644 --- a/pandora_console/include/ajax/graph.ajax.php +++ b/pandora_console/include/ajax/graph.ajax.php @@ -55,9 +55,15 @@ if ($save_custom_graph) { if ($print_custom_graph) { ob_clean(); + $width_value = (int) get_parameter('width', CHART_DEFAULT_WIDTH); + + if ($width_value === -1) { + $width_value = ''; + } + $params = [ 'period' => (int) get_parameter('period', SECONDS_5MINUTES), - 'width' => (int) get_parameter('width', CHART_DEFAULT_WIDTH), + 'width' => $width_value, 'height' => (int) get_parameter('height', CHART_DEFAULT_HEIGHT), 'unit_name' => get_parameter('unit_list', []), 'date' => (int) get_parameter('date', time()), diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index accda15dd8..0896912edd 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3910,6 +3910,18 @@ function series_type_graph_array($data, $show_elements_graph) $name_legend = $show_elements_graph['labels'][$value['agent_module_id']][$label_interfaces[$value['agent_module_id']]].': '; } else if (is_array($show_elements_graph['labels'][$value['agent_module_id']]) === true) { $name_legend = 'Avg: '; + + if (array_key_exists('agent_alias', $value) + && array_key_exists('module_name', $value) + && array_key_exists('unit', $value) + ) { + $name_legend .= $value['agent_alias']; + $name_legend .= ' / '; + $name_legend .= $value['module_name']; + $name_legend .= ' / '; + $name_legend .= __('Unit ').' '; + $name_legend .= $value['unit'].': '; + } } else { $name_legend = $show_elements_graph['labels'][$value['agent_module_id']].': '; } diff --git a/pandora_console/operation/agentes/graphs.php b/pandora_console/operation/agentes/graphs.php index 279661e02e..d33298b014 100644 --- a/pandora_console/operation/agentes/graphs.php +++ b/pandora_console/operation/agentes/graphs.php @@ -516,7 +516,7 @@ echo "
"; $container.html($errorMessage.html()); } - requestCustomGraph(0, width, height, period, stacked, date, modules) + requestCustomGraph(0, -1, height, period, stacked, date, modules) .done(handleSuccess) .fail(handleError); } From f9d5767027b02d354666e2c1492989ea35ba133e Mon Sep 17 00:00:00 2001 From: artica Date: Tue, 9 Mar 2021 01:00:17 +0100 Subject: [PATCH 34/49] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 3f82a619ac..b376e6b3ea 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.752-210308 +Version: 7.0NG.752-210309 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 95e1c73ad9..4ea40466f3 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.752-210308" +pandora_version="7.0NG.752-210309" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 1f84562473..706e5b3d58 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1016,7 +1016,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.752'; -use constant AGENT_BUILD => '210308'; +use constant AGENT_BUILD => '210309'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index a3fc37b3a2..12cca53c8d 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.752 -%define release 210308 +%define release 210309 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 9e61f17a0e..bcd7497f83 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.752 -%define release 210308 +%define release 210309 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index cc25c5f884..6605ed7080 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.752" -PI_BUILD="210308" +PI_BUILD="210309" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 8ebe9018c8..68e6cb8c2f 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{210308} +{210309} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index c37e5a6d36..78b8576ca2 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.752(Build 210308)") +#define PANDORA_VERSION ("7.0NG.752(Build 210309)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 3e53ce3508..5057e8d157 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.752(Build 210308))" + VALUE "ProductVersion", "(7.0NG.752(Build 210309))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 9fd4f4cfdf..2c236ee219 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.752-210308 +Version: 7.0NG.752-210309 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 362856d1b5..b7862a9927 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.752-210308" +pandora_version="7.0NG.752-210309" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index cbe6f85d52..0922085c26 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC210308'; +$build_version = 'PC210309'; $pandora_version = 'v7.0NG.752'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 8b4d142c75..fb3381a361 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index eb1805f7e4..cfd687dcaa 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.752 -%define release 210308 +%define release 210309 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index f02df44325..11dc4e5820 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.752 -%define release 210308 +%define release 210309 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index be4198f1a1..8510be6afa 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.752" -PI_BUILD="210308" +PI_BUILD="210309" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 7a92bd1fcf..938c54c0a2 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.752 PS210308"; +my $version = "7.0NG.752 PS210309"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index dcd87d9b31..d3867bcfb7 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.752 PS210308"; +my $version = "7.0NG.752 PS210309"; # save program name for logging my $progname = basename($0); From b384e97da5db05ff518f9136dcda4195babca1f0 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 9 Mar 2021 10:17:29 +0100 Subject: [PATCH 35/49] Test REGEXP is valid before apply in MySQL --- pandora_console/include/ajax/graph.ajax.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/ajax/graph.ajax.php b/pandora_console/include/ajax/graph.ajax.php index 09c4355b57..bd6d246eb4 100644 --- a/pandora_console/include/ajax/graph.ajax.php +++ b/pandora_console/include/ajax/graph.ajax.php @@ -253,7 +253,12 @@ if ($get_graphs) { case 'dynamic_graph': if ($value['agent'] != '') { - $alias = " AND alias REGEXP '".$value['agent']."'"; + if (@preg_match($value['agent'], '') !== false) { + $alias = " AND alias REGEXP '".$value['agent']."'"; + } else { + // Not a valid REGEXP. + $alias = " AND alias LIKE '".$value['agent']."'"; + } } if ($value['id_group'] === '0') { @@ -277,7 +282,11 @@ if ($get_graphs) { } if ($value['module'] != '') { - $module_name = " AND nombre REGEXP '".$value['module']."'"; + if (@preg_match($value['module'], '') !== false) { + $module_name = " AND nombre REGEXP '".$value['module']."'"; + } else { + $module_name = " AND nombre LIKE '".$value['module']."'"; + } } $id_agent_module = db_get_all_rows_sql( From 219ca1914d09dd6a74419967bf620031d235100a Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Tue, 9 Mar 2021 16:02:05 +0100 Subject: [PATCH 36/49] cambio de dominio --- extras/deploy-scripts/pandora_deploy_community.sh | 2 +- pandora_console/general/login_page.php | 4 ++-- pandora_console/include/functions_config.php | 4 ++-- pandora_console/install.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh index 51f61c2b8a..aa858eec3a 100644 --- a/extras/deploy-scripts/pandora_deploy_community.sh +++ b/extras/deploy-scripts/pandora_deploy_community.sh @@ -71,7 +71,7 @@ check_pre_pandora () { check_repo_connection () { execute_cmd "ping -c 2 8.8.8.8" "Checking internet connection" execute_cmd "ping -c 2 firefly.artica.es" "Checking Community repo" - execute_cmd "ping -c 2 support.artica.es" "Checking Enterprise repo" + execute_cmd "ping -c 2 support.pandorafms.com" "Checking Enterprise repo" } check_root_permissions () { diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index cf7bce6c4d..9238810636 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -146,8 +146,8 @@ if (isset($config['custom_support_url'])) { echo '
  • '.__('Support').'
  • '; } } else if (!$custom_conf_enabled) { - echo '
  • support
  • '; - echo '
  • '.__('Docs').'
  • '; + echo '
  • support
  • '; + echo '
  • '.__('Docs').'
  • '; } echo '
    '; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 70744ef78a..0c2bcc1403 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -2224,7 +2224,7 @@ function config_process_config() } if (!isset($config['custom_support_url'])) { - config_update_value('custom_support_url', 'https://support.artica.es'); + config_update_value('custom_support_url', 'https://support.pandorafms.com'); } if (!isset($config['rb_product_name'])) { @@ -2240,7 +2240,7 @@ function config_process_config() } if (!isset($config['meta_custom_support_url'])) { - config_update_value('meta_custom_support_url', 'https://support.artica.es'); + config_update_value('meta_custom_support_url', 'https://support.pandorafms.com'); } if (!isset($config['meta_custom_logo'])) { diff --git a/pandora_console/install.php b/pandora_console/install.php index fb3381a361..c9c5a74592 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -909,7 +909,7 @@ function install_step4() // $config["custom_title2_login_alt"] = "NEXT GENERATION"; // $config["rb_product_name_alt"] = "Pandora FMS"; // $config["custom_docs_url_alt"] = "http://wiki.pandorafms.com/"; - // $config["custom_support_url_alt"] = "https://support.artica.es"; + // $config["custom_support_url_alt"] = "https://support.pandorafms.com"; @@ -1026,7 +1026,7 @@ function install_step4() // $config["custom_title2_login_alt"] = "NEXT GENERATION"; // $config["rb_product_name_alt"] = "Pandora FMS"; // $config["custom_docs_url_alt"] = "http://wiki.pandorafms.com/"; - // $config["custom_support_url_alt"] = "https://support.artica.es"; + // $config["custom_support_url_alt"] = "https://support.pandorafms.com"; /* ----------Attention-------------------- From 6e0188fac18d5fd37a188697667203119ac728f0 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 9 Mar 2021 16:32:12 +0000 Subject: [PATCH 37/49] add summary report availability graph --- pandora_console/extras/mr/45.sql | 3 ++ .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 ++ .../reporting_builder.item_editor.php | 27 ++++++++++++++- .../godmode/reporting/reporting_builder.php | 11 ++++++- .../include/functions_reporting.php | 33 +++++++++---------- .../include/functions_reporting_html.php | 31 ++++++++++++++++- pandora_console/pandoradb.sql | 2 ++ visual_console_client/src/Item.ts | 3 +- 8 files changed, 91 insertions(+), 21 deletions(-) diff --git a/pandora_console/extras/mr/45.sql b/pandora_console/extras/mr/45.sql index a1259e4a77..90f821dae5 100644 --- a/pandora_console/extras/mr/45.sql +++ b/pandora_console/extras/mr/45.sql @@ -1,5 +1,8 @@ START TRANSACTION; +ALTER TABLE `treport_content` ADD COLUMN `summary` tinyint(1) DEFAULT 0; +ALTER TABLE `treport_content_template` ADD COLUMN `summary` tinyint(1) DEFAULT 0; + ALTER TABLE `tinventory_alert` ADD COLUMN `alert_groups` TEXT NOT NULL; UPDATE `tinventory_alert` t1 INNER JOIN `tinventory_alert` t2 ON t1.id = t2.id SET t1.alert_groups = t2.id_group; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 8f4cbf6209..2742e7e197 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -865,6 +865,7 @@ ALTER TABLE `treport_content_template` ADD COLUMN `agent_min_value` TINYINT(1) D ALTER TABLE `treport_content_template` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `failover_type` tinyint(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `summary` tinyint(1) DEFAULT 0; ALTER TABLE `treport_content_template` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0'; ALTER TABLE `treport_content_template` MODIFY COLUMN `historical_db` tinyint(1) unsigned NOT NULL DEFAULT '0', MODIFY COLUMN `lapse_calc` tinyint(1) unsigned NOT NULL DEFAULT '0', @@ -1725,6 +1726,7 @@ ALTER TABLE `treport_content` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1 ALTER TABLE `treport_content` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '0'; ALTER TABLE `treport_content` ADD COLUMN `failover_type` tinyint(1) DEFAULT '0'; +ALTER TABLE `treport_content` ADD COLUMN `summary` tinyint(1) DEFAULT 0; ALTER table `treport_content` MODIFY COLUMN `name` varchar(300) NULL; ALTER TABLE `treport_content` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0'; ALTER TABLE `treport_content` MODIFY COLUMN `historical_db` tinyint(1) unsigned NOT NULL DEFAULT '0', diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index f3c3070ef1..e90acee5cb 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -185,6 +185,7 @@ switch ($action) { $dyn_height = 230; $landscape = false; $pagebreak = false; + $summary = 0; break; case 'save': @@ -314,11 +315,12 @@ switch ($action) { $idCustomGraph = $item['id_gs']; break; + case 'availability_graph': + $summary = $item['summary']; case 'SLA': case 'SLA_weekly': case 'SLA_monthly': case 'SLA_hourly': - case 'availability_graph': $description = $item['description']; $only_display_wrong = $item['only_display_wrong']; $monday = $item['monday']; @@ -2750,6 +2752,27 @@ $class = 'databox filters'; +
    + + + +
    + + + +