Project

General

Profile

« Previous | Next » 

Revision a3c9510c

Added by Phil Davis over 10 years ago

Allow blank source port in diag_testport

Reported by forum https://forum.pfsense.org/index.php?topic=86146.0
Also, if there are input validation errors, save the user-entered data and re-display it, making it easier for the user to just correct the data in error and press Test again. It was blanking out all the entered data.

View differences:

usr/local/www/diag_testport.php
50 50
require("guiconfig.inc");
51 51

  
52 52
define('NC_TIMEOUT', 10);
53
$do_testport = false;
53 54

  
54 55
if ($_POST || $_REQUEST['host']) {
55 56
	unset($input_errors);
56
	unset($do_testport);
57 57

  
58 58
	/* input validation */
59 59
	$reqdfields = explode(" ", "host port");
......
68 68
		$input_errors[] = gettext("Please enter a valid port number.");
69 69
	}
70 70

  
71
	if (!is_numeric($_REQUEST['srcport']) || !is_port($_REQUEST['srcport'])) {
71
	if (($_REQUEST['srcport'] != "") && (!is_numeric($_REQUEST['srcport']) || !is_port($_REQUEST['srcport']))) {
72 72
		$input_errors[] = gettext("Please enter a valid source port number, or leave the field blank.");
73 73
	}
74 74

  
......
81 81

  
82 82
	if (!$input_errors) {
83 83
		$do_testport = true;
84
		$host = $_REQUEST['host'];
85
		$sourceip = $_REQUEST['sourceip'];
86
		$port = $_REQUEST['port'];
87
		$srcport = $_REQUEST['srcport'];
88
		$showtext = isset($_REQUEST['showtext']);
89
		$ipprotocol = $_REQUEST['ipprotocol'];
90 84
		$timeout = NC_TIMEOUT;
91 85
	}
92
}
93
if (!isset($do_testport)) {
94
	$do_testport = false;
95
	$host = '';
96
	$port = '';
97
	$srcport = '';
98
	unset($showtext);
86
	
87
	/* Save these request vars even if there were input errors. Then the fields are refilled for the user to correct. */
88
	$host = $_REQUEST['host'];
89
	$sourceip = $_REQUEST['sourceip'];
90
	$port = $_REQUEST['port'];
91
	$srcport = $_REQUEST['srcport'];
92
	$showtext = isset($_REQUEST['showtext']);
93
	$ipprotocol = $_REQUEST['ipprotocol'];
99 94
}
100 95

  
101 96
include("head.inc"); ?>

Also available in: Unified diff