diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php index b50a7ec828..2f45242942 100644 --- a/pandora_console/extensions/quick_shell.php +++ b/pandora_console/extensions/quick_shell.php @@ -79,8 +79,6 @@ function quickShell() return; } - $method = get_parameter('method', null); - $setup_anchor = html_print_anchor( [ 'href' => 'index.php?sec=gsetup&sec2=godmode/setup/setup§ion=quickshell', @@ -89,6 +87,15 @@ function quickShell() true ); + $fetch_result = get_parameter('fetch-result', null); + + if (isset($fetch_result) === true && $fetch_result === '0') { + ui_print_error_message(__('Connection error. Please check your settings at %s', $setup_anchor)); + return; + } + + $method = get_parameter('method', null); + if ((bool) $config['gotty_ssh_enabled'] === false && (bool) $config['gotty_telnet_enabled'] === false ) { @@ -118,6 +125,9 @@ function quickShell() $connectionURL = buildConnectionURL($method); $gotty_addr = $connectionURL.$args; + $connectionURLSSH = buildConnectionURL('ssh'); + $connectionURLTelnet = buildConnectionURL('telnet'); + // Username. Retrieve from form. if (empty($username) === true) { // No username provided, ask for it. @@ -160,6 +170,7 @@ function quickShell() 'label' => __('Username'), 'arguments' => [ 'type' => 'text', + 'id' => 'username', 'name' => 'username', 'required' => true, ], @@ -191,7 +202,7 @@ function quickShell() html_print_action_buttons( html_print_submit_button( __('Connect'), - 'submit', + 'submit-btn', false, [ 'icon' => 'cog', @@ -200,30 +211,57 @@ function quickShell() true ) ); + + echo ""; + return; } - // Check gotty connection before trying to load iframe. - $ch = curl_init($gotty_addr); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - // Maximum time for the entire request. - curl_setopt($ch, CURLOPT_TIMEOUT, 3); - // Maximum time to establish a connection. - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_MAXREDIRS, 10); - - $response = curl_exec($ch); - $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - $finalUrl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); - - curl_close($ch); - - if ($responseCode !== 200) { - ui_print_error_message(__('Connection error. Please check your settings at %s', $setup_anchor)); - exit; - } - ?>