diff options
author | Phil Davis <phil.davis@inf.org> | 2016-01-18 16:32:59 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2016-01-18 16:32:59 +0545 |
commit | 294eec0dd85243a2d79d142024e16f8cc457b681 (patch) | |
tree | 4d609ef3419f023d6a4df61cef27cf9e303f2b23 /src/usr/local/www/diag_testport.php | |
parent | 7cfa20da95d60097af3463ca51ce5cee9a0d3ff1 (diff) | |
download | pfsense-294eec0dd85243a2d79d142024e16f8cc457b681.zip pfsense-294eec0dd85243a2d79d142024e16f8cc457b681.tar.gz |
diag_testport alert message logic re-factoring
as suggested by @rbgarga
Diffstat (limited to 'src/usr/local/www/diag_testport.php')
-rw-r--r-- | src/usr/local/www/diag_testport.php | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/usr/local/www/diag_testport.php b/src/usr/local/www/diag_testport.php index 6b3d010..3545315 100644 --- a/src/usr/local/www/diag_testport.php +++ b/src/usr/local/www/diag_testport.php @@ -221,30 +221,29 @@ include("head.inc"); // Handle the display of all messages here where the user can readily see them if ($input_errors) { print_input_errors($input_errors); -} else { - if ($do_testport) { - // User asked for a port test - if ($retval == 0) { - // Good host & port - if (!$showtext) { - print('<div class="alert alert-success" role="alert">' . sprintf(gettext('Port test to host: %1$s Port: %2$s successful'), $host, $port) . '</div>'); - } else { - print('<div class="alert alert-success" role="alert">' . sprintf(gettext('Port test to host: %1$s Port: %2$s successful.'), $host, $port) . ' ' . gettext('Any text received from the host will be shown below the form.') . '</div>'); - } - } else { - // netcat exit value != 0 - if ($showtext) { - print('<div class="alert alert-danger" role="alert">' . gettext('No output received, or connection failed. Try with "Show Remote Text" unchecked first.') . '</div>'); - } else { - print('<div class="alert alert-danger" role="alert">' . gettext('Connection failed.') . '</div>'); - } +} elseif ($do_testport) { + // User asked for a port test + if ($retval == 0) { + // Good host & port + $alert_text = '<div class="alert alert-success" role="alert">' . sprintf(gettext('Port test to host: %1$s Port: %2$s successful'), $host, $port); + if ($showtext) { + $alert_text .= ' ' . gettext('Any text received from the host will be shown below the form.'); } } else { - // First time, new page - print('<div class="alert alert-warning" role="alert">' . - gettext('This page allows you to perform a simple TCP connection test to determine if a host is up and accepting connections on a given port.') . " " . - gettext('This test does not function for UDP since there is no way to reliably determine if a UDP port accepts connections in this manner.') . '</div>'); + // netcat exit value != 0 + $alert_text = '<div class="alert alert-danger" role="alert">'; + if ($showtext) { + $alert_text .= gettext('No output received, or connection failed. Try with "Show Remote Text" unchecked first.'); + } else { + $alert_text .= gettext('Connection failed.'); + } } + print ($alert_text . '</div>'); +} else { + // First time, new page + print('<div class="alert alert-warning" role="alert">' . + gettext('This page allows you to perform a simple TCP connection test to determine if a host is up and accepting connections on a given port.') . " " . + gettext('This test does not function for UDP since there is no way to reliably determine if a UDP port accepts connections in this manner.') . '</div>'); } $form = new Form('Test'); |