id_name)) or filters filtered * Used also in Cloud Wizard. * * @param string $tree SNMP tree returned by snmp_broser_get_tree. * @param string $id Level ID. Do not set, used for recursion. * @param string $depth Branch depth. Do not set, used for recursion. * @param integer $last Last. * @param array $last_array Last_array. * @param string $sufix Sufix. * @param array $checked Checked. * @param boolean $descriptive_ids Descriptive_ids. * @param string $previous_id Previous_id. * * @return string HTML code with complete tree. */ function snmp_browser_get_html_tree( $tree, $id=0, $depth=0, $last=0, $last_array=[], $sufix=false, $checked=[], $descriptive_ids=false, $previous_id='' ) { static $url = false; $output = ''; // Get the base URL for images. if ($url === false) { $url = ui_get_full_url('operation/tree', false, false, false); } // Leaf. if (empty($tree['__LEAVES__'])) { return ''; } $count = 0; $total = (count(array_keys($tree['__LEAVES__'])) - 1); $last_array[$depth] = $last; $class = 'item_'.$depth; if ($depth > 0) { $output .= '
'; if ($return) { return $output; } echo $output; } /** * Print browser container. * * @param boolean $return The result is printed * if set to true or returned if set to false. * @param string $width Width of the SNMP browser. * Units must be specified. * @param string $height Height of the SNMP browser. * Units must be specified. * @param string $display CSS display value for the * container div. Set to none to hide the div. * @param boolean $show_massive_buttons Massive buttons. * * @return string html. */ function snmp_browser_print_container( $return=false, $width='100%', $height='60%', $display='', $show_massive_buttons=false ) { $snmp_version = get_parameter('snmp_browser_version', '2c'); // Target selection. $table = new stdClass(); $table->width = '100%'; $table->class = 'databox filters'; $table->size = []; $table->data = []; $table->data[0][0] = ''.__('Target IP').' '; $table->data[0][0] .= html_print_input_text( 'target_ip', get_parameter('target_ip', ''), '', 25, 0, true ); $table->data[0][1] = ''.__('Community').' '; $table->data[0][1] .= html_print_input_text( 'community', get_parameter('community', ''), '', 25, 0, true ); $table->data[0][2] = ''.__('Starting OID').' '; $table->data[0][2] .= html_print_input_text( 'starting_oid', get_parameter('starting_oid', '.1.3.6.1.2'), '', 25, 0, true ); $table->data[1][0] = ''.__('Version').' '; $table->data[1][0] .= html_print_select( [ '1' => 'v. 1', '2' => 'v. 2', '2c' => 'v. 2c', '3' => 'v. 3', ], 'snmp_browser_version', get_parameter('snmp_browser_version', '2c'), 'checkSNMPVersion();', '', '', true, false, false, '' ); $servers_to_exec = []; $servers_to_exec[0] = __('Local console'); if (enterprise_installed()) { enterprise_include_once('include/functions_satellite.php'); $rows = get_proxy_servers(); if ($rows !== false) { foreach ($rows as $row) { if ($row['server_type'] != 13) { $s_type = ' (Standard)'; } else { $s_type = ' (Satellite)'; } $servers_to_exec[$row['id_server']] = $row['name'].$s_type; } } } $table->data[1][1] = ''; $table->data[1][1] .= __('Server to execute'); $table->data[1][1] .= ' '; $table->data[1][1] .= html_print_select( $servers_to_exec, 'server_to_exec', '', '', '', '', true ); $table->data[1][2] = html_print_button( __('Browse'), 'browse', false, 'snmpBrowse()', 'class="sub search" style="margin-top:0px;"', true ); // SNMP v3 options. $snmp3_auth_user = get_parameter('snmp3_auth_user', ''); $snmp3_security_level = get_parameter('snmp3_security_level', 'authNoPriv'); $snmp3_auth_method = get_parameter('snmp3_auth_method', 'MD5'); $snmp3_auth_pass = get_parameter('snmp3_auth_pass', ''); $snmp3_privacy_method = get_parameter('snmp3_privacy_method', 'AES'); $snmp3_privacy_pass = get_parameter('snmp3_privacy_pass', ''); $table3 = new stdClass(); $table3->width = '100%'; $table3->valign[0] = ''; $table3->valign[1] = ''; $table3->data[2][1] = ''.__('Auth user').''; $table3->data[2][2] = html_print_input_text( 'snmp3_browser_auth_user', $snmp3_auth_user, '', 15, 60, true ); $table3->data[2][3] = ''.__('Auth password').''; $table3->data[2][4] = html_print_input_password( 'snmp3_browser_auth_pass', $snmp3_auth_pass, '', 15, 60, true ); $table3->data[2][4] .= html_print_input_hidden_extended( 'active_snmp_v3', 0, 'active_snmp_v3_fsb', true ); $table3->data[5][0] = ''.__('Privacy method').''; $table3->data[5][1] = html_print_select( [ 'DES' => __('DES'), 'AES' => __('AES'), ], 'snmp3_browser_privacy_method', $snmp3_privacy_method, '', '', '', true ); $table3->data[5][2] = ''.__('Privacy pass').''; $table3->data[5][3] = html_print_input_password( 'snmp3_browser_privacy_pass', $snmp3_privacy_pass, '', 15, 60, true ); $table3->data[6][0] = ''.__('Auth method').''; $table3->data[6][1] = html_print_select( [ 'MD5' => __('MD5'), 'SHA' => __('SHA'), ], 'snmp3_browser_auth_method', $snmp3_auth_method, '', '', '', true ); $table3->data[6][2] = ''.__('Security level').''; $table3->data[6][3] = html_print_select( [ 'noAuthNoPriv' => __('Not auth and not privacy method'), 'authNoPriv' => __('Auth and not privacy method'), 'authPriv' => __('Auth and privacy method'), ], 'snmp3_browser_security_level', $snmp3_security_level, '', '', '', true ); // Search tools. $table2 = new stdClass(); $table2->width = '100%'; $table2->class = 'databox filters'; $table2->size = []; $table2->data = []; $table2->data[0][0] = html_print_input_text( 'search_text', '', '', 25, 0, true ); $table2->data[0][0] .= ''; $table2->data[0][0] .= html_print_image( 'images/zoom.png', true, [ 'title' => __('Search'), 'style' => 'vertical-align: middle;', 'onclick' => 'searchText();', ] ); $table2->data[0][0] .= ''; $table2->data[0][1] = ' '; $table2->data[0][1] .= ''; $table2->data[0][1] .= html_print_image( 'images/go_first.png', true, [ 'title' => __('First match'), 'style' => 'vertical-align: middle;', 'onclick' => 'searchFirstMatch();', ] ); $table2->data[0][1] .= ''; $table2->data[0][1] .= ' '; $table2->data[0][1] .= ''; $table2->data[0][1] .= html_print_image( 'images/go_previous.png', true, [ 'title' => __('Previous match'), 'style' => 'vertical-align: middle;', 'onclick' => 'searchPrevMatch();', ] ); $table2->data[0][1] .= ''; $table2->data[0][1] .= ' '; $table2->data[0][1] .= ''; $table2->data[0][1] .= html_print_image( 'images/go_next.png', true, [ 'title' => __('Next match'), 'style' => 'vertical-align: middle;', 'onclick' => 'searchNextMatch();', ] ); $table2->data[0][1] .= ''; $table2->data[0][1] .= ' '; $table2->data[0][1] .= ''; $table2->data[0][1] .= html_print_image( 'images/go_last.png', true, [ 'title' => __('Last match'), 'style' => 'vertical-align: middle;', 'onclick' => 'searchLastMatch();', ] ); $table2->data[0][1] .= ''; $table2->cellstyle[0][1] = 'text-align:center;'; $table2->data[0][2] = ' '; $table2->data[0][2] .= ''.html_print_image( 'images/expand.png', true, [ 'title' => __('Expand the tree (can be slow)'), 'style' => 'vertical-align: middle;', 'onclick' => 'expandAll();', ] ); $table2->data[0][2] .= ''; $table2->data[0][2] .= ' '; $table2->data[0][2] .= ''; $table2->data[0][2] .= html_print_image( 'images/collapse.png', true, [ 'title' => __('Collapse the tree'), 'style' => 'vertical-align: middle;', 'onclick' => 'collapseAll();', ] ); $table2->data[0][2] .= ''; $table2->cellstyle[0][2] = 'text-align:center;'; // This extra div that can be handled by jquery's dialog. $output = '