Copyright (C) 2003-2004 Manuel Kasper 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_once("guiconfig.inc"); require_once("filter.inc"); require_once("system.inc"); $a_filter = &config_read_array('filter', 'rule'); if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_GET['if'])) { $current_if = htmlspecialchars($_GET['if']); } else { $current_if = "FloatingRules"; } $pconfig = $_POST; if (isset($pconfig['id']) && isset($a_filter[$pconfig['id']])) { // id found and valid $id = $pconfig['id']; } if (isset($pconfig['apply'])) { system_cron_configure(); filter_configure(); clear_subsystem_dirty('filter'); $savemsg = gettext('The settings have been applied and the rules are now reloading in the background.'); } elseif (isset($pconfig['act']) && $pconfig['act'] == 'del' && isset($id)) { // delete single item if (!empty($a_filter[$id]['associated-rule-id'])) { // unlink nat entry if (isset($config['nat']['rule'])) { $a_nat = &config_read_array('nat', 'rule'); foreach ($a_nat as &$natent) { if ($natent['associated-rule-id'] == $a_filter[$id]['associated-rule-id']) { $natent['associated-rule-id'] = ''; } } } } unset($a_filter[$id]); write_config(); mark_subsystem_dirty('filter'); header(url_safe('Location: /firewall_rules.php?if=%s', array($current_if))); exit; } elseif (isset($pconfig['act']) && $pconfig['act'] == 'del_x' && isset($pconfig['rule']) && count($pconfig['rule']) > 0) { // delete selected rules foreach ($pconfig['rule'] as $rulei) { // unlink nat entry if (isset($config['nat']['rule'])) { $a_nat = &config_read_array('nat', 'rule'); foreach ($a_nat as &$natent) { if ($natent['associated-rule-id'] == $a_filter[$rulei]['associated-rule-id']) { $natent['associated-rule-id'] = ''; } } } unset($a_filter[$rulei]); } write_config(); mark_subsystem_dirty('filter'); header(url_safe('Location: /firewall_rules.php?if=%s', array($current_if))); exit; } elseif (isset($pconfig['act']) && in_array($pconfig['act'], array('toggle_enable', 'toggle_disable')) && isset($pconfig['rule']) && count($pconfig['rule']) > 0) { foreach ($pconfig['rule'] as $rulei) { $a_filter[$rulei]['disabled'] = $pconfig['act'] == 'toggle_disable'; } write_config(); mark_subsystem_dirty('filter'); header(url_safe('Location: /firewall_rules.php?if=%s', array($current_if))); exit; } elseif ( isset($pconfig['act']) && $pconfig['act'] == 'move' && isset($pconfig['rule']) && count($pconfig['rule']) > 0) { // move selected rules if (!isset($id)) { // if rule not set/found, move to end $id = count($a_filter); } $a_filter = legacy_move_config_list_items($a_filter, $id, $pconfig['rule']); write_config(); mark_subsystem_dirty('filter'); header(url_safe('Location: /firewall_rules.php?if=%s', array($current_if))); exit; } elseif (isset($pconfig['act']) && $pconfig['act'] == 'toggle' && isset($id)) { // toggle item if(isset($a_filter[$id]['disabled'])) { unset($a_filter[$id]['disabled']); } else { $a_filter[$id]['disabled'] = true; } write_config(); mark_subsystem_dirty('filter'); header(url_safe('Location: /firewall_rules.php?if=%s', array($current_if))); exit; } } if (isset($_GET['if'])) { $selected_if = htmlspecialchars($_GET['if']); } else { $selected_if = "FloatingRules"; } if (isset($_GET['category'])) { $selected_category = !is_array($_GET['category']) ? array($_GET['category']) : $_GET['category']; } else { $selected_category = array(); } include("head.inc"); $main_buttons = array( array('label' => gettext('Add'), 'href' => 'firewall_rules_edit.php?if=' . $selected_if), ); ?>

You must apply the changes in order for them to take effect."));?>

$filterent): if ( (!isset($filterent['floating']) && $selected_if == $filterent['interface']) || ( (isset($filterent['floating']) || empty($filterent['interface'])) && $selected_if == 'FloatingRules' ) ): // calculate a hash so we can track these records in the rulset, new style (mvc) code will // automatically provide us with a uuid, this is a workaround to provide some help with tracking issues. $filterent['md5'] = md5(json_encode($filterent)); $interface_has_rules = true; // select icon if ($filterent['type'] == "block" && empty($filterent['disabled'])) { $iconfn = "fa fa-times text-danger"; } elseif ($filterent['type'] == "block" && !empty($filterent['disabled'])) { $iconfn = "fa fa-times text-muted"; } elseif ($filterent['type'] == "reject" && empty($filterent['disabled'])) { $iconfn = "fa fa-times-circle text-danger"; } elseif ($filterent['type'] == "reject" && !empty($filterent['disabled'])) { $iconfn = "fa fa-times-circle text-muted"; } elseif (empty($filterent['disabled'])) { $iconfn = "fa fa-play text-success"; } else { $iconfn = "fa fa-play text-muted"; } // construct line ipprotocol if (isset($filterent['ipprotocol'])) { switch($filterent['ipprotocol']) { case "inet": $record_ipprotocol = "IPv4 "; break; case "inet6": $record_ipprotocol = "IPv6 "; break; case "inet46": $record_ipprotocol = "IPv4+6 "; break; } } else { $record_ipprotocol = "IPv4 "; } ?> " data-category="">
 
  IPv6 * *
  * *
  * *
  *
"> "> "> gettext("any"), "echoreq" => gettext("Echo Request"), "echorep" => gettext("Echo Reply"), "unreach" => gettext("Destination Unreachable"), "squench" => gettext("Source Quench (Deprecated)"), "redir" => gettext("Redirect"), "althost" => gettext("Alternate Host Address (Deprecated)"), "routeradv" => gettext("Router Advertisement"), "routersol" => gettext("Router Solicitation"), "timex" => gettext("Time Exceeded"), "paramprob" => gettext("Parameter Problem"), "timereq" => gettext("Timestamp"), "timerep" => gettext("Timestamp Reply"), "inforeq" => gettext("Information Request (Deprecated)"), "inforep" => gettext("Information Reply (Deprecated)"), "maskreq" => gettext("Address Mask Request (Deprecated)"), "maskrep" => gettext("Address Mask Reply (Deprecated)") ); if (isset($filterent['protocol']) && $filterent['protocol'] == "icmp" && !empty($filterent['icmptype'])): ?>   " data-toggle="tooltip">