printForm( [ 'form' => [ 'action' => '#', 'class' => 'wizard', 'method' => 'post', 'id' => 'connect_form', ], 'inputs' => [ [ 'label' => __('Username'), 'arguments' => [ 'type' => 'text', 'name' => 'username', ], ], [ 'label' => __('Port'), 'arguments' => [ 'type' => 'text', 'id' => 'port', 'name' => 'port', 'value' => 22, ], ], [ 'label' => __('Method'), 'arguments' => [ 'type' => 'select', 'name' => 'method', 'fields' => [ 'ssh' => __('SSH'), 'telnet' => __('Telnet'), ], 'script' => "p=22; if(this.value == 'telnet') { p=23; } $('#text-port').val(p);", ], ], ], ], false, true ); html_print_action_buttons( html_print_submit_button( __('Connect'), 'submit', false, [ 'icon' => 'cog', 'form' => 'connect_form', ], true ) ); return; } ?>
'; echo ''; $test_start = ' '.html_print_image('images/spinner.gif', true).''; $test_start .= ' '; $ssh_table = new StdClass(); $ssh_table->data = []; $ssh_table->width = '100%'; $ssh_table->class = 'filter-table-adv'; $ssh_table->data = []; $ssh_table->style = []; $ssh_table->style[0] = 'width: 50%;'; $ssh_table->data[0][] = html_print_label_input_block( __('Gotty address'), html_print_input_text( 'gotty_ssh_addr', $config['gotty_ssh_addr'], '', 30, 100, true ) ); $ssh_table->data[0][] = html_print_label_input_block( __('Gotty port'), html_print_input_text( 'gotty_ssh_port', $config['gotty_ssh_port'], '', 30, 100, true ) ); $ssh_table->data[1][] = html_print_label_input_block( __('Gotty user'), html_print_input_text( 'gotty_ssh_user', $config['gotty_ssh_user'], '', 30, 100, true ) ); $ssh_table->data[1][] = html_print_label_input_block( __('Gotty password'), html_print_input_password( 'gotty_ssh_pass', io_output_password($config['gotty_ssh_pass']), '', 30, 100, true ) ); $ssh_table->data[2][] = html_print_label_input_block( __('Use SSL'), html_print_checkbox_switch( 'gotty_ssh_use_ssl', 1, $config['gotty_ssh_use_ssl'], true, $disable_agentaccess ) ); // Test. $row = []; $test_start = ' '.html_print_image('images/spinner.gif', true).''; $test_start .= ' '; $ssh_table->data[2][] = html_print_button( __('Test'), 'test-gotty-ssh', false, 'handleTestSSH()', [ 'icon' => 'cog', 'mode' => 'secondary', 'style' => 'width: 115px;', ], true ).$test_start; html_print_table($ssh_table); echo ''; echo ''; } if (is_ajax() === true) { $address = get_parameter('address'); if (isset($address) === true) { $ch = curl_init($address); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Maximum time for the entire request. curl_setopt($ch, CURLOPT_TIMEOUT, 2); // Maximum time to establish a connection. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1); curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($response_code === 200 || $response_code === 401) { $result = ['status' => 'success']; } else { $result = ['status' => 'error']; } echo json_encode($result); return; } } // This extension is useful only if the agent has associated IP. $agent_id = get_parameter('id_agente'); if (empty($agent_id) === false && get_parameter('sec2', '') == 'operation/agentes/ver_agente' ) { $address = agents_get_address($agent_id); if (empty($address) === false) { // Extension registration. extensions_add_opemode_tab_agent( // TabId. 'quick_shell', // TabName. __('QuickShell'), // TabIcon. 'images/quick-shell@svg.svg', // TabFunction. 'quickShell', // Version. 'N/A', // Acl. 'PM' ); } } echo ''; extensions_add_godmode_function('quickShellSettings');