diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index 60d39d26d9..6cb7f55227 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -1,17 +1,32 @@ = 15 && $type <= 18) { + // New support for snmp v3. + $tcp_send = $snmp_version; + $plugin_user = $snmp3_auth_user; + $plugin_pass = $snmp3_auth_pass; + $plugin_parameter = $snmp3_auth_method; + $custom_string_1 = $snmp3_privacy_method; + $custom_string_2 = $snmp3_privacy_pass; + $custom_string_3 = $snmp3_security_level; +} else if ($type >= 34 && $type <= 37) { + $tcp_send = $command_text; + $custom_string_1 = $command_credential_identifier; + $custom_string_2 = $command_os; +} + if ($create_component) { - $custom_string_1 = ''; - $custom_string_2 = ''; - $custom_string_3 = ''; $name_check = db_get_value( 'name', 'tnetwork_component', @@ -201,25 +236,6 @@ if ($create_component) { $name ); - // remote_snmp = 15 - // remote_snmp_proc = 18 - if ($type >= 15 && $type <= 18) { - // New support for snmp v3 - $tcp_send = $snmp_version; - $plugin_user = $snmp3_auth_user; - $plugin_pass = $snmp3_auth_pass; - $plugin_parameter = $snmp3_auth_method; - $custom_string_1 = $snmp3_privacy_method; - $custom_string_2 = $snmp3_privacy_pass; - $custom_string_3 = $snmp3_security_level; - $name_check = db_get_value( - 'name', - 'tnetwork_component', - 'name', - $name - ); - } - if ($name && !$name_check) { $id = network_components_create_network_component( $name, @@ -283,13 +299,16 @@ if ($create_component) { } if ($id === false || !$id) { - db_pandora_audit('Module management', 'Fail try to create network component'); + db_pandora_audit( + 'Module management', + 'Fail try to create network component' + ); ui_print_error_message(__('Could not be created')); include_once 'godmode/modules/manage_network_components_form.php'; return; } - db_pandora_audit('Module management', "Create network component #$id"); + db_pandora_audit('Module management', 'Create network component #'.$id); ui_print_success_message(__('Created successfully')); $id = 0; } @@ -297,23 +316,6 @@ if ($create_component) { if ($update_component) { $id = (int) get_parameter('id'); - $custom_string_1 = ''; - $custom_string_2 = ''; - $custom_string_3 = ''; - - // $name_check = db_get_value ('name', 'tnetwork_component', 'name', $name); - if ($type >= 15 && $type <= 18) { - // New support for snmp v3 - $tcp_send = $snmp_version; - $plugin_user = $snmp3_auth_user; - $plugin_pass = $snmp3_auth_pass; - $plugin_parameter = $snmp3_auth_method; - $custom_string_1 = $snmp3_privacy_method; - $custom_string_2 = $snmp3_privacy_pass; - $custom_string_3 = $snmp3_security_level; - // $name_check = db_get_value ('name', 'tnetwork_component', 'name', $name); - } - if (!empty($name)) { $result = network_components_update_network_component( $id, @@ -380,14 +382,14 @@ if ($update_component) { if ($result === false || !$result) { db_pandora_audit( 'Module management', - "Fail try to update network component #$id" + 'Fail try to update network component #'.$id ); ui_print_error_message(__('Could not be updated')); include_once 'godmode/modules/manage_network_components_form.php'; return; } - db_pandora_audit('Module management', "Update network component #$id"); + db_pandora_audit('Module management', 'Update network component #'.$id); ui_print_success_message(__('Updated successfully')); $id = 0; @@ -401,12 +403,12 @@ if ($delete_component) { if ($result) { db_pandora_audit( 'Module management', - "Delete network component #$id" + 'Delete network component #'.$id ); } else { db_pandora_audit( 'Module management', - "Fail try to delete network component #$id" + 'Fail try to delete network component #'.$id ); } @@ -433,12 +435,12 @@ if ($multiple_delete) { if ($result) { db_pandora_audit( 'Module management', - "Multiple delete network component: $str_ids" + 'Multiple delete network component:'.$str_ids ); } else { db_pandora_audit( 'Module management', - "Fail try to delete network component: $str_ids" + 'Fail try to delete network component:'.$str_ids ); } @@ -451,7 +453,10 @@ if ($multiple_delete) { $id = 0; } -if ($id || $new_component || $create_network_from_module || $create_network_from_snmp_browser) { +if ($id || $new_component + || $create_network_from_module + || $create_network_from_snmp_browser +) { include_once $config['homedir'].'/godmode/modules/manage_network_components_form.php'; return; } @@ -540,7 +545,7 @@ if ($component_groups === false) { foreach ($component_groups as $component_group_key => $component_group_val) { $num_components = db_get_num_rows( 'SELECT id_nc - FROM tnetwork_component + FROM tnetwork_component WHERE id_group = '.$component_group_key ); @@ -551,14 +556,14 @@ foreach ($component_groups as $component_group_key => $component_group_val) { if ($childs !== false) { foreach ($childs as $child) { $num_components_childs += db_get_num_rows( - 'SELECT id - FROM tlocal_component + 'SELECT id + FROM tlocal_component WHERE id_network_component_group = '.$child['id_sg'] ); } } - // Only show component groups with local components + // Only show component groups with local components. if ($num_components == 0 && $num_components_childs == 0) { unset($component_groups[$component_group_key]); } @@ -622,7 +627,11 @@ if ($search_string != '') { $filter[] = '(name LIKE '."'%".$search_string."%'".'OR description LIKE '."'%".$search_string."%'".'OR tcp_send LIKE '."'%".$search_string."%'".'OR tcp_rcv LIKE '."'%".$search_string."%'".')'; } -$total_components = network_components_get_network_components(false, $filter, 'COUNT(*) AS total'); +$total_components = network_components_get_network_components( + false, + $filter, + 'COUNT(*) AS total' +); $total_components = $total_components[0]['total']; ui_pagination($total_components, $url); $filter['offset'] = (int) get_parameter('offset'); @@ -651,7 +660,13 @@ unset($table); $table->width = '100%'; $table->head = []; $table->class = 'info_table'; -$table->head['checkbox'] = html_print_checkbox('all_delete', 0, false, true, false); +$table->head['checkbox'] = html_print_checkbox( + 'all_delete', + 0, + false, + true, + false +); $table->head[0] = __('Module name'); $table->head[1] = __('Type'); $table->head[3] = __('Description'); @@ -669,12 +684,21 @@ foreach ($components as $component) { $data = []; if ($component['max'] == $component['min'] && $component['max'] == 0) { - $component['max'] = $component['min'] = __('N/A'); + $component['max'] = __('N/A'); + $component['min'] = __('N/A'); } - $data['checkbox'] = html_print_checkbox_extended('delete_multiple[]', $component['id_nc'], false, false, '', 'class="check_delete"', true); + $data['checkbox'] = html_print_checkbox_extended( + 'delete_multiple[]', + $component['id_nc'], + false, + false, + '', + 'class="check_delete"', + true + ); - $data[0] = ''; + $data[0] = ''; $data[0] .= io_safe_output($component['name']); $data[0] .= ''; $data[1] = ui_print_moduletype_icon($component['type'], true); @@ -702,6 +726,10 @@ foreach ($components as $component) { ['title' => __('Plug-in module')] ); break; + + default: + // Not possible. + break; } $data[3] = "".mb_strimwidth(io_safe_output($component['description']), 0, 60, '...').''; @@ -719,13 +747,32 @@ if (isset($data)) { echo "
'; } else { - ui_print_info_message(['no_close' => true, 'message' => __('There are no defined network components') ]); + ui_print_info_message( + [ + 'no_close' => true, + 'message' => __('There are no defined network components'), + ] + ); } echo ''; @@ -752,30 +804,33 @@ enterprise_hook('close_meta_frame'); ?> diff --git a/pandora_console/godmode/modules/manage_network_components_form.php b/pandora_console/godmode/modules/manage_network_components_form.php index fd922046d1..114be6a969 100644 --- a/pandora_console/godmode/modules/manage_network_components_form.php +++ b/pandora_console/godmode/modules/manage_network_components_form.php @@ -1,17 +1,32 @@ $id_agentmodule]); + $data_module = db_get_row_filter( + 'tagente_modulo', + ['id_agente_modulo' => $id_agentmodule] + ); $name = $data_module['nombre']; $description = $data_module['descripcion']; @@ -139,16 +160,25 @@ if (isset($id)) { $each_ff = $component['each_ff']; if ($type >= 15 && $type <= 18) { - // New support for snmp v3 + // New support for snmp v3. $snmp_version = $component['tcp_send']; $snmp3_auth_user = $component['plugin_user']; $snmp3_auth_pass = io_output_password($component['plugin_pass']); $snmp3_auth_method = $component['plugin_parameter']; $snmp3_privacy_method = $component['custom_string_1']; - $snmp3_privacy_pass = io_output_password($component['custom_string_2']); + $snmp3_privacy_pass = io_output_password( + $component['custom_string_2'] + ); $snmp3_security_level = $component['custom_string_3']; + } else if ($type >= 34 && $type <= 37) { + $command_text = $component['tcp_send']; + $command_credential_identifier = $component['custom_string_1']; + $command_os = $component['custom_string_2']; } - } else if (isset($new_component) && $new_component && !$create_network_from_snmp_browser) { + } else if (isset($new_component) + && $new_component + && !$create_network_from_snmp_browser + ) { $name = ''; $snmp_oid = ''; $description = ''; @@ -204,21 +234,13 @@ if (isset($id)) { $snmp3_privacy_pass = ''; $snmp3_auth_method = ''; $snmp3_security_level = ''; + + $command_text = ''; + $command_os = 'inherited'; + $command_credential_identifier = ''; } } -if ($create_network_from_snmp_browser) { -} - -/* - * $id_component_type has these values: - * 6 - Module WMI - * 4 - Plugin component - * 2 - network component - * - * You can see this values in file godmode/modules/manage_network_components.php - * in the last lines (in the call function "html_print_select"). - */ $table = new stdClass(); if ($id_component_type == 6) { @@ -242,6 +264,7 @@ if ($id_component_type == 6) { 3, 4, 5, + 10, ]; include $config['homedir'].'/godmode/modules/manage_network_components_form_common.php'; include $config['homedir'].'/godmode/modules/manage_network_components_form_network.php'; @@ -253,7 +276,7 @@ echo '