From 8d4e3e78a30369be7b834a5ac8f0934e4a720eb1 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Thu, 7 Dec 2023 16:00:42 +0100 Subject: [PATCH 1/5] #12579 fixed icons as buttons in action on satellite server agents --- .../include/class/SatelliteAgent.class.php | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/pandora_console/include/class/SatelliteAgent.class.php b/pandora_console/include/class/SatelliteAgent.class.php index 29fa2e3b77..09b023958d 100644 --- a/pandora_console/include/class/SatelliteAgent.class.php +++ b/pandora_console/include/class/SatelliteAgent.class.php @@ -388,26 +388,38 @@ class SatelliteAgent extends HTML $tmp->actions = ''; if ($delete === false) { - $tmp->actions .= html_print_image( - ($disable === true) ? 'images/lightbulb_off.png' : 'images/lightbulb.png', - true, + $tmp->actions .= html_print_anchor( [ - 'border' => '0', - 'class' => 'main_menu_icon mrgn_lft_05em invert_filter', - 'onclick' => 'disable_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $disable.'\',\''.$id_agente.'\')', - ] + 'href' => '#', + 'content' => html_print_image( + ($disable === true) ? 'images/lightbulb_off.png' : 'images/lightbulb.png', + true, + [ + 'border' => '0', + 'class' => 'main_menu_icon mrgn_lft_05em invert_filter', + 'onclick' => 'disable_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $disable.'\',\''.$id_agente.'\')', + ] + ), + ], + true ); } if ($disable === false) { - $tmp->actions .= html_print_image( - ($delete === true) ? 'images/add.png' : 'images/delete.svg', - true, + $tmp->actions .= html_print_anchor( [ - 'border' => '0', - 'class' => 'main_menu_icon mrgn_lft_05em invert_filter', - 'onclick' => 'delete_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $delete.'\',\''.$id_agente.'\')', - ] + 'href' => '#', + 'content' => html_print_image( + ($delete === true) ? 'images/add.png' : 'images/delete.svg', + true, + [ + 'border' => '0', + 'class' => 'main_menu_icon mrgn_lft_05em invert_filter', + 'onclick' => 'delete_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $delete.'\',\''.$id_agente.'\')', + ] + ), + ], + true ); } From c6d29ea60ed57927d7ce3afbaeba80be084704a9 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 14 Dec 2023 16:59:39 +0100 Subject: [PATCH 2/5] #12435 external link users fix --- pandora_console/extras/mr/68.sql | 2 ++ pandora_console/godmode/users/configure_user.php | 4 ++-- pandora_console/godmode/users/user_management.php | 2 +- pandora_console/pandoradb.sql | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql index 3095941187..e988817a54 100644 --- a/pandora_console/extras/mr/68.sql +++ b/pandora_console/extras/mr/68.sql @@ -1,5 +1,7 @@ START TRANSACTION; +ALTER TABLE `tusuario` CHANGE COLUMN `metaconsole_data_section` `metaconsole_data_section` TEXT NOT NULL DEFAULT '' ; + DELETE FROM `twelcome_tip` WHERE `title` = 'Automatic agent provision system'; INSERT INTO `twelcome_tip` (`id_lang`,`id_profile`,`title`,`text`,`url`,`enable`) VALUES ('en_GB',0,'Automatic agent provision system','The agent self-provisioning system allows an agent recently entered into the system to automatically apply changes to their configuration (such as moving them from group, assigning them certain values in custom fields) and of course applying certain monitoring policies. It is one of the most powerful functionalities, aimed at managing very large system parks.','https://pandorafms.com/manual/start?id=en/documentation/02_installation/05_configuration_agents#conf',1); diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 83e54f24c5..dbca522db4 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -427,7 +427,7 @@ if ($create_user === true) { } else if ($values['section'] === HOME_SCREEN_OTHER) { $values['data_section'] = get_parameter('data_section_other'); } else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { - $values['data_section'] = get_parameter('data_section_external'); + $values['data_section'] = get_parameter('data_section'); } // $values['section'] = $homeScreenValues[$values['section']]; @@ -727,7 +727,7 @@ if ($update_user) { } else if ($values['section'] === HOME_SCREEN_OTHER) { $values['data_section'] = get_parameter('data_section_other'); } else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { - $values['data_section'] = get_parameter('data_section_external'); + $values['data_section'] = get_parameter('data_section'); } // $values['section'] = $homeScreenValues[$values['section']]; diff --git a/pandora_console/godmode/users/user_management.php b/pandora_console/godmode/users/user_management.php index b1212c11ec..2f8aecd47e 100644 --- a/pandora_console/godmode/users/user_management.php +++ b/pandora_console/godmode/users/user_management.php @@ -118,7 +118,7 @@ $customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text( $user_info['data_section'], '', 60, - 255, + 999, true ); $customHomeScreenDataField = ''; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 56e49ad467..a4df08742c 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1292,7 +1292,7 @@ CREATE TABLE IF NOT EXISTS `tusuario` ( `section` TEXT, `data_section` TEXT, `metaconsole_section` VARCHAR(255) NOT NULL DEFAULT 'Default', - `metaconsole_data_section` VARCHAR(255) NOT NULL DEFAULT '', + `metaconsole_data_section` TEXT, `force_change_pass` TINYINT UNSIGNED NOT NULL DEFAULT 0, `last_pass_change` DATETIME, `last_failed_login` DATETIME, From 0627ea07cd02a0d91551f16589110b47aae5c734 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Fri, 29 Dec 2023 13:43:28 +0100 Subject: [PATCH 3/5] #12503 changed unique ip in agent --- .../godmode/agentes/agent_manager.php | 82 +++++++++++++++---- .../godmode/agentes/configurar_agente.php | 19 +---- pandora_console/include/ajax/agent.php | 26 ++++++ pandora_console/include/styles/pandora.css | 9 ++ 4 files changed, 104 insertions(+), 32 deletions(-) diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 1af5e3d780..09c6ea3939 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -399,12 +399,12 @@ if ($new_agent === true) { // Ip adress. $tableAgent->data['caption_ip_address'] = __('IP Address'); -$tableAgent->rowclass['ip_address'] = 'w540px'; +$tableAgent->rowclass['ip_address'] = 'w400px'; $tableAgent->data['ip_address'][0] = html_print_input_text('direccion', $direccion_agente, '', 16, 100, true, false, false, '', 'w540px'); +$tableAgent->data['ip_address'][1] = html_print_button(__('Check unique IP'), 'check_unique_ip', false, '', ['class' => 'secondary w130px'], true); +$tableAgent->data['message_check_ip'][0] = html_print_div(['id' => 'message_check_ip'], true); $tableAgent->rowclass['additional_ip_address'] = 'subinput'; -$tableAgent->data['additional_ip_address'][0] = html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true); -$tableAgent->data['additional_ip_address'][1] = __('Unique IP'); $tableAgent->cellclass['additional_ip_address'][1] = 'w120px'; $tableAgent->data['additional_ip_address'][2] = html_print_input( [ @@ -1301,6 +1301,7 @@ ui_require_jquery_file('bgiframe'); ?> diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 3da403ef80..c2e3a2f4f6 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -102,7 +102,6 @@ $alias_as_name = 0; $direccion_agente = get_parameter('direccion', ''); $direccion_agente = trim(io_safe_output($direccion_agente)); $direccion_agente = io_safe_input($direccion_agente); -$unique_ip = 0; $intervalo = SECONDS_5MINUTES; $ff_interval = 0; $quiet_module = 0; @@ -186,7 +185,6 @@ if ($create_agent) { $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output))); $alias_as_name = (int) get_parameter_post('alias_as_name', 0); $direccion_agente = (string) get_parameter_post('direccion', ''); - $unique_ip = (int) get_parameter_post('unique_ip', 0); // Safe_output only validate ip. $direccion_agente = trim(io_safe_output($direccion_agente)); @@ -269,12 +267,7 @@ if ($create_agent) { $nombre_agente = $alias; } - if ($unique_ip && $direccion_agente != '') { - $sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"'; - $exists_ip = db_get_row_sql($sql); - } - - if (!$exists_alias && !$exists_ip) { + if (!$exists_alias) { $id_agente = db_process_sql_insert( 'tagente', [ @@ -371,8 +364,6 @@ if ($create_agent) { $agent_creation_error = __('Could not be created'); if ($exists_alias) { $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'); } } } @@ -962,7 +953,6 @@ if ($update_agent) { $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output))); $alias_as_name = (int) get_parameter_post('alias_as_name', 0); $direccion_agente = (string) get_parameter_post('direccion', ''); - $unique_ip = (int) get_parameter_post('unique_ip', 0); // Safe_output only validate ip. $direccion_agente = trim(io_safe_output($direccion_agente)); @@ -1097,18 +1087,11 @@ if ($update_agent) { // If there is an agent with the same name, but a different ID. } - if ($direccion_agente !== $address_list && (bool) $unique_ip === true && $direccion_agente != '') { - $sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"'; - $exists_ip = db_get_row_sql($sql); - } - $old_group = agents_get_agent_group($id_agente); if ($grupo <= 0) { ui_print_error_message(__('The group id %d is incorrect.', $grupo)); } else if ($old_group !== $grupo && group_allow_more_agents($grupo, true, 'update') === false) { ui_print_error_message(__('Agent cannot be updated due to the maximum agent limit for this group')); - } else if ($exists_ip) { - ui_print_error_message(__('Duplicate main IP address')); } else { // If different IP is specified than previous, add the IP. if ($direccion_agente != '' diff --git a/pandora_console/include/ajax/agent.php b/pandora_console/include/ajax/agent.php index 65dcd96aef..b03a9e5b40 100644 --- a/pandora_console/include/ajax/agent.php +++ b/pandora_console/include/ajax/agent.php @@ -39,6 +39,7 @@ $get_agent_filters = get_parameter('get_agent_filters', 0); $save_agent_filter = get_parameter('save_agent_filter', 0); $update_agent_filter = get_parameter('update_agent_filter', 0); $delete_agent_filter = get_parameter('delete_agent_filter', 0); +$check_unique_ip = (bool) get_parameter('check_unique_ip', 0); if (https_is_running()) { header('Content-type: application/json'); @@ -1020,4 +1021,29 @@ $(document).ready(function() { return; } +if ($check_unique_ip === true) { + $direccion_agente = (string) get_parameter_post('direccion', ''); + $ip_all = get_parameter_post('ip_all', ''); + + if (empty($direccion_agente) === true) { + echo json_encode(['success' => false, 'message' => __('Please enter an IP address.')]); + return; + } + + $sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"'; + $exists_ip = db_get_row_sql($sql); + + if ($exists_ip !== false) { + if (is_array($ip_all) === true && in_array($direccion_agente, $ip_all) === true) { + echo json_encode(['success' => true, 'message' => __('Success! but this IP is already in the list.')]); + } else { + echo json_encode(['success' => false, 'message' => __('This IP is already being used'), 'exist_ip' => true]); + } + } else { + echo json_encode(['success' => true, 'message' => __('Success! this IP is available to be used.')]); + } + + return; +} + return; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 94d337bdbe..78425214ec 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -481,6 +481,11 @@ select:-internal-list-box { max-width: 120px; } +.w130px { + width: 130px; + max-width: 130px; +} + .w200px { width: 200px; max-width: 200px; @@ -598,6 +603,10 @@ select:-internal-list-box { min-width: 120px; } +.mw130px { + min-width: 130px; +} + .mw180px { min-width: 180px; } From 0b18397095782751b4162bf3c79e3bcd4c188d28 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 15 Jan 2024 09:19:37 +0100 Subject: [PATCH 4/5] #12503 fixed empty all_ip in create agent --- pandora_console/godmode/agentes/agent_manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 09c6ea3939..d0c255e25e 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -1513,7 +1513,7 @@ ui_require_jquery_file('bgiframe'); function check_unique_ip() { const direccion = $('#text-direccion').val(); let ip_all = ; - if (!ip_all) { + if (ip_all) { ip_all = Object.keys(ip_all); } $.ajax({ From 234f4d2df1626b0762b46721a33771fb99c2b6c2 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 15 Jan 2024 14:32:52 +0100 Subject: [PATCH 5/5] #12579 add title on images --- pandora_console/include/class/SatelliteAgent.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/include/class/SatelliteAgent.class.php b/pandora_console/include/class/SatelliteAgent.class.php index 09b023958d..a40b3ecc7a 100644 --- a/pandora_console/include/class/SatelliteAgent.class.php +++ b/pandora_console/include/class/SatelliteAgent.class.php @@ -395,6 +395,7 @@ class SatelliteAgent extends HTML ($disable === true) ? 'images/lightbulb_off.png' : 'images/lightbulb.png', true, [ + 'title' => ($disable === true) ? __('Enable') : __('Disable'), 'border' => '0', 'class' => 'main_menu_icon mrgn_lft_05em invert_filter', 'onclick' => 'disable_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $disable.'\',\''.$id_agente.'\')', @@ -413,6 +414,7 @@ class SatelliteAgent extends HTML ($delete === true) ? 'images/add.png' : 'images/delete.svg', true, [ + 'title' => ($delete === true) ? __('Add') : __('Delete'), 'border' => '0', 'class' => 'main_menu_icon mrgn_lft_05em invert_filter', 'onclick' => 'delete_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $delete.'\',\''.$id_agente.'\')',