diff options
author | Renato Botelho <garga@FreeBSD.org> | 2013-03-01 09:51:32 -0300 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2013-03-01 09:51:32 -0300 |
commit | 0692dea8739c9bcba7578fc16fb7d024f0fd3c2c (patch) | |
tree | edf486a69d3d6033db4936ee5bc3a2306b7df11a /usr/local/www | |
parent | 02421eca477490080cd9e8c4ed82a2692c092efb (diff) | |
download | pfsense-0692dea8739c9bcba7578fc16fb7d024f0fd3c2c.zip pfsense-0692dea8739c9bcba7578fc16fb7d024f0fd3c2c.tar.gz |
Simplify code
Diffstat (limited to 'usr/local/www')
-rwxr-xr-x | usr/local/www/firewall_virtual_ip_edit.php | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/usr/local/www/firewall_virtual_ip_edit.php b/usr/local/www/firewall_virtual_ip_edit.php index c732c80..db36848 100755 --- a/usr/local/www/firewall_virtual_ip_edit.php +++ b/usr/local/www/firewall_virtual_ip_edit.php @@ -147,23 +147,21 @@ if ($_POST) { if (empty($_POST['password'])) $input_errors[] = gettext("You must specify a CARP password that is shared between the two VHID members."); - if(is_ipaddrv4($_POST['subnet'])) { + if (is_ipaddrv4($_POST['subnet'])) { $parent_ip = get_interface_ip($_POST['interface']); $parent_sn = get_interface_subnet($_POST['interface']); - if (!ip_in_subnet($_POST['subnet'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn) && !ip_in_interface_alias_subnet($_POST['interface'], $_POST['subnet'])) { - $cannot_find = $_POST['subnet'] . "/" . $_POST['subnet_bits'] ; - $input_errors[] = sprintf(gettext("Sorry, we could not locate an interface with a matching subnet for %s. Please add an IP alias in this subnet on this interface."),$cannot_find); - } - } - if(is_ipaddrv6($_POST['subnet'])) { + $subnet = gen_subnet($parent_ip, $parent_sn); + } else if (is_ipaddrv6($_POST['subnet'])) { $parent_ip = get_interface_ipv6($_POST['interface']); $parent_sn = get_interface_subnetv6($_POST['interface']); $subnet = gen_subnetv6($parent_ip, $parent_sn); - if (!ip_in_subnet($_POST['subnet'], "{$subnet}/{$parent_sn}") && !ip_in_interface_alias_subnet($_POST['interface'], $_POST['subnet'])) { - $cannot_find = $_POST['subnet'] . "/" . $_POST['subnet_bits'] ; - $input_errors[] = sprintf(gettext("Sorry, we could not locate an interface with a matching subnet for %s. Please add an IP alias in this subnet on this interface."),$cannot_find); - } } + + if (isset($parent_ip) && !ip_in_subnet($_POST['subnet'], "{$subnet}/{$parent_sn}") && !ip_in_interface_alias_subnet($_POST['interface'], $_POST['subnet'])) { + $cannot_find = $_POST['subnet'] . "/" . $_POST['subnet_bits'] ; + $input_errors[] = sprintf(gettext("Sorry, we could not locate an interface with a matching subnet for %s. Please add an IP alias in this subnet on this interface."),$cannot_find); + } + if (strstr($_POST['interface'], "_vip")) $input_errors[] = gettext("For this type of vip a carp parent is not allowed."); break; @@ -183,7 +181,6 @@ if ($_POST) { break; } - if (!$input_errors) { $vipent = array(); |