From 7cfa20da95d60097af3463ca51ce5cee9a0d3ff1 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 17 Jan 2016 20:50:53 +0545 Subject: 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. --- src/usr/local/www/diag_testport.php | 49 ++++++++++++++++++++----------------- 1 file 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(''); - } - - // Good host & port - if ($retval == 0 && $do_testport == 1) { - if (!$showtext) { - print(''); - } else { - print(''); - } - } - - // netcat exit value != 0 - if ($retval != 0 && !empty($result)) { - if ($showtext) { - print(''); + if ($do_testport) { + // User asked for a port test + if ($retval == 0) { + // Good host & port + if (!$showtext) { + print(''); + } else { + print(''); + } } else { - print(''); + // netcat exit value != 0 + if ($showtext) { + print(''); + } else { + print(''); + } } + } else { + // First time, new page + print(''); } } @@ -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)): +?>
-

Received Remote Text

+

- Date: Mon, 18 Jan 2016 16:32:59 +0545 Subject: diag_testport alert message logic re-factoring as suggested by @rbgarga --- src/usr/local/www/diag_testport.php | 41 ++++++++++++++++++------------------- 1 file 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(''); - } else { - print(''); - } - } else { - // netcat exit value != 0 - if ($showtext) { - print(''); - } else { - print(''); - } +} elseif ($do_testport) { + // User asked for a port test + if ($retval == 0) { + // Good host & port + $alert_text = '