diff options
author | Ermal Luçi <eri@pfsense.org> | 2009-07-23 21:44:05 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2009-07-23 21:44:05 +0000 |
commit | 5e34cdb24e183ab797b05c6217678fe78211fbac (patch) | |
tree | 38ba35f9dc90dd829596bc44bfa4b4155f8f3aa2 /usr | |
parent | 7581a05043051f2cce37749a99d8c3d2e65db6c5 (diff) | |
download | pfsense-5e34cdb24e183ab797b05c6217678fe78211fbac.zip pfsense-5e34cdb24e183ab797b05c6217678fe78211fbac.tar.gz |
* If editing an alias do not display itself on the autocompletion list
* Prevent that the user mixes wrong type of aliases, only host and network type mixing is allowed. Openvpn may be added later on too.
* Instead of checking for nested loops when unwinding aliases just prevent the loops. It is easier and allows some rare cases when nesting is needed.
Diffstat (limited to 'usr')
-rwxr-xr-x | usr/local/www/firewall_aliases_edit.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/usr/local/www/firewall_aliases_edit.php b/usr/local/www/firewall_aliases_edit.php index 3adb0e3..d99e368 100755 --- a/usr/local/www/firewall_aliases_edit.php +++ b/usr/local/www/firewall_aliases_edit.php @@ -50,6 +50,23 @@ if (!is_array($config['aliases']['alias'])) aliases_sort(); $a_aliases = &$config['aliases']['alias']; +function alias_same_type($name, $type) { + global $config; + + foreach ($config['aliases']['alias'] as $alias) { + if ($name == $alias['name']) { + if (in_array($type, array("host", network")) && + in_array($alias['type'], array("host", "network"))) + return true; + if ($type == $alias['type']) + return true; + else + return false; + } + } + return true; +} + $id = $_GET['id']; if (isset($_POST['id'])) $id = $_POST['id']; @@ -191,6 +208,7 @@ if ($_POST) { $address = ""; $isfirst = 0; /* item is a normal alias type */ + $wrongaliases = ""; for($x=0; $x<4999; $x++) { if($_POST["address{$x}"] <> "") { if ($isfirst > 0) @@ -208,7 +226,13 @@ if ($_POST) { $final_address_details .= "||"; $isfirst++; } + if (is_alias($_POST["address{$x}"])) { + if (!alias_same_type($_POST["address{$x}"], $_POST['type'])) + $wrongaliases .= " " . $_POST["address{$x}"]; + } } + if ($wrongaliases <> "") + $input_errors[] = "The following aliases: {$wrongaliases} \ncannot be nested cause they are not of the same type."; } if (!$input_errors) { @@ -555,6 +579,8 @@ EOD; $aliasesaddr = ""; if(isset($config['aliases']['alias']) && is_array($config['aliases']['alias'])) foreach($config['aliases']['alias'] as $alias_name) { + if ($pconfig['name'] <> "" && $pconfig['name'] == $alias_name['name']) + continue; if($addrisfirst == 1) $aliasesaddr .= ","; $aliasesaddr .= "'" . $alias_name['name'] . "'"; $addrisfirst = 1; |