. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ require("guiconfig.inc"); if (!is_array($config['aliases']['alias'])) $config['aliases']['alias'] = array(); aliases_sort(); $a_aliases = &$config['aliases']['alias']; $id = $_GET['id']; if (isset($_POST['id'])) $id = $_POST['id']; if (isset($id) && $a_aliases[$id]) { $pconfig['name'] = $a_aliases[$id]['name']; $addresses = explode(' ', $a_aliases[$id]['address']); if (is_array($addresses)) $address = $addresses[0]; else $address = $addresses; list($pconfig['address'],$pconfig['address_subnet']) = explode('/', $address); if ($pconfig['address_subnet']) $pconfig['type'] = "network"; else if (is_ipaddr($pconfig['address'])) $pconfig['type'] = "host"; else $pconfig['type'] = "port"; $pconfig['descr'] = $a_aliases[$id]['descr']; } if ($_POST) { unset($input_errors); $pconfig = $_POST; /* input validation */ $reqdfields = explode(" ", "name address"); $reqdfieldsn = explode(",", "Name,Address"); if ($_POST['type'] == "network") { $reqdfields[] = "address_subnet"; $reqdfieldsn[] = "Subnet bit count"; } do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); if(strtolower($_POST['name']) == "lan") $input_errors[] = "Aliases may not be named LAN."; if(strtolower($_POST['name']) == "wan") $input_errors[] = "Aliases may not be named WAN."; $x = is_validaliasname($_POST['name']); if (!isset($x)) { $input_errors[] = "Reserved word used for alias name."; } else { if (is_validaliasname($_POST['name']) == false) $input_errors[] = "The alias name may only consist of the characters a-z, A-Z, 0-9."; } if ($_POST['type'] == "host") if (!is_ipaddr($_POST['address'])) { $input_errors[] = "A valid address must be specified."; } if ($_POST['type'] == "network") { if (!is_ipaddr($_POST['address'])) { $input_errors[] = "A valid address must be specified."; } if (!is_numeric($_POST['address_subnet'])) { $input_errors[] = "A valid subnet bit count must be specified."; } } if ($_POST['type'] == "port") if (!is_port($_POST['address'])) $input_errors[] = "The port must be an integer between 1 and 65535."; /* check for name conflicts */ foreach ($a_aliases as $alias) { if (isset($id) && ($a_aliases[$id]) && ($a_aliases[$id] === $alias)) continue; if ($alias['name'] == $_POST['name']) { $input_errors[] = "An alias with this name already exists."; break; } } if (!$input_errors) { $alias = array(); $alias['name'] = $_POST['name']; if ($_POST['type'] == "network") $alias['address'] = $_POST['address'] . "/" . $_POST['address_subnet']; else $alias['address'] = $_POST['address']; $address = $alias['address']; $isfirst = 0; for($x=0; $x<99; $x++) { $comd = "\$subnet = \$_POST['address" . $x . "'];"; eval($comd); $comd = "\$subnet_address = \$_POST['address_subnet" . $x . "'];"; eval($comd); if($subnet <> "") { $address .= " "; $address .= $subnet; if($subnet_address <> "") $address .= "/" . $subnet_address; } } $alias['address'] = $address; $alias['descr'] = $_POST['descr']; if (isset($id) && $a_aliases[$id]) $a_aliases[$id] = $alias; else $a_aliases[] = $alias; touch($d_aliasesdirty_path); write_config(); filter_configure(); header("Location: firewall_aliases.php"); exit; } } $pgtitle = "System: Firewall: Aliases: Edit"; include("head.inc"); ?>
=$pgtitle?>