diff options
author | Phil Davis <phil.davis@inf.org> | 2016-01-17 20:50:53 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2016-01-17 20:50:53 +0545 |
commit | 7cfa20da95d60097af3463ca51ce5cee9a0d3ff1 (patch) | |
tree | 45055189e2c35e2342f14f9ad920b3b89138a25c /src/usr | |
parent | daf566f10c75cb50458de9c50a50da69e346459f (diff) | |
download | pfsense-7cfa20da95d60097af3463ca51ce5cee9a0d3ff1.zip pfsense-7cfa20da95d60097af3463ca51ce5cee9a0d3ff1.tar.gz |
Rationalize message display on diag_testport
1) The logic of the various tests that determined which messages were displayed was all a bit odd, and there were ways that things could happen and no message was displayed. Now it displays the "warning" information message the first time, and 1 of the 4 possible result messages depending on the result status and if showtest was on.
2) Internationalize - put the gettext() into calls with full sentences and sprintf() wrappers as necessary.
Now I can get each of the 4 possible result messages, and always get a result message.
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/local/www/diag_testport.php | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/src/usr/local/www/diag_testport.php b/src/usr/local/www/diag_testport.php index 63e55c9..6b3d010 100644 --- a/src/usr/local/www/diag_testport.php +++ b/src/usr/local/www/diag_testport.php @@ -222,28 +222,28 @@ include("head.inc"); if ($input_errors) { print_input_errors($input_errors); } else { - // New page - if (empty($result) && $retval != 0 && !$showtext) { - print('<div class="alert alert-warning" role="alert">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.' . - ' 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>'); - } - - // Good host & port - if ($retval == 0 && $do_testport == 1) { - if (!$showtext) { - print('<div class="alert alert-success" role="alert">'.gettext("Port test to host: " . $host . " Port: " . $port . " successful").'</div>'); - } else { - print('<div class="alert alert-success" role="alert">'.gettext("Port test to host: " . $host . " Port: " . $port . " successful") . '. Any text received from the host will be shown below the form.</div>'); - } - } - - // netcat exit value != 0 - if ($retval != 0 && !empty($result)) { - 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>'); + 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 { - print('<div class="alert alert-danger" role="alert">'.gettext('Connection failed.').'</div>'); + // 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>'); + } } + } 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>'); } } @@ -300,15 +300,18 @@ $section->addInput(new Form_Select( $form->add($section); print $form; -if ($ncoutput && !empty($result) && $showtext && $retval == 0): ?> +// If the command succeeded, the user asked to see the output and there is output, then show it. +if ($retval == 0 && $showtext && !empty($ncoutput)): +?> <div class="panel panel-default"> <div class="panel-heading"> - <h2 class="panel-title">Received Remote Text</h2> + <h2 class="panel-title"><?=gettext('Received Remote Text')?></h2> </div> <div class="panel-body"> <pre><?= $ncoutput ?></pre> </div> </div> -<?php endif; +<?php +endif; include("foot.inc"); |