Project

General

Profile

« Previous | Next » 

Revision 31ace93c

Added by Seth Mos over 16 years ago

Add input validation on the gateway name field.
We apply the same input validation as we use from the aliases page as we do not want a - in the name nor spaces.

View differences:

usr/local/www/system_gateways_edit.php
83 83
	if (! isset($_POST['name'])) {
84 84
		$input_errors[] = "A valid gateway name must be specified.";
85 85
	}
86
	if (! is_validaliasname($_POST['name'])) {
87
		$input_errors[] = "The gateway name must not contain invalid characters.";
88
	}
86 89
	/* skip system gateways which have been automatically added */
87 90
	if ($_POST['gateway'] && (!is_ipaddr($_POST['gateway'])) && ($pconfig['attribute'] != "system")) {
88 91
		$input_errors[] = "A valid gateway IP address must be specified.";
......
91 94
		$input_errors[] = "A valid monitor IP address must be specified.";
92 95
	}
93 96

  
94
	/* check for overlaps */
95
	foreach ($a_gateways as $gateway) {
96
		if (isset($id) && ($a_gateways[$id]) && ($a_gateways[$id] === $gateway))
97
			continue;
97
	if (! isset($_POST['name'])) {
98
		/* check for overlaps */
99
		foreach ($a_gateways as $gateway) {
100
			if (isset($id) && ($a_gateways[$id]) && ($a_gateways[$id] === $gateway))
101
				continue;
98 102

  
99
		if (($gateway['name'] <> "") && (in_array($gateway, $_POST['name']))) {
100
			$input_errors[] = "The name \"{$_POST['name']}\" already exists.";
101
			break;
102
		}
103
		if (($gateway['gateway'] <> "") && (in_array($gateway, $_POST['gateway']))) {
104
			$input_errors[] = "The IP address \"{$_POST['gateway']}\" already exists.";
105
			break;
106
		}
107
		if (($gateway['monitor'] <> "") && (in_array($gateway, $gateway['monitor']))) {
108
			$input_errors[] = "The IP address \"{$_POST['monitor']}\" already exists.";
109
			break;
103
			if (($gateway['name'] <> "") && (in_array($gateway, $_POST['name']))) {
104
				$input_errors[] = "The name \"{$_POST['name']}\" already exists.";
105
				break;
106
			}
107
			if (($gateway['gateway'] <> "") && (in_array($gateway, $_POST['gateway']))) {
108
				$input_errors[] = "The IP address \"{$_POST['gateway']}\" already exists.";
109
				break;
110
			}
111
			if (($gateway['monitor'] <> "") && (in_array($gateway, $gateway['monitor']))) {
112
				$input_errors[] = "The IP address \"{$_POST['monitor']}\" already exists.";
113
				break;
114
			}
110 115
		}
111 116
	}
112 117

  

Also available in: Unified diff