. 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("pfsense-utils.inc"); if (!isset($config['filter']['rule'])) { $config['filter']['rule'] = array(); } $a_filter = &$config['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'])) { filter_configure(); clear_subsystem_dirty('filter'); $savemsg = sprintf(gettext("The settings have been applied. The firewall rules are now reloading in the background.
You can also %s monitor %s the reload progress"),"",""); } 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['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]); if (write_config()) { mark_subsystem_dirty('filter'); } header("Location: firewall_rules.php?if=" . htmlspecialchars($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['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]); } if (write_config()) { mark_subsystem_dirty('filter'); } header("Location: firewall_rules.php?if=" . htmlspecialchars($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']); if (write_config()) { mark_subsystem_dirty('filter'); } header("Location: firewall_rules.php?if=" . htmlspecialchars($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; } if (write_config()) { mark_subsystem_dirty('filter'); } header("Location: firewall_rules.php?if=" . htmlspecialchars($current_if)); exit; } } if (isset($_GET['if'])) { $selected_if = htmlspecialchars($_GET['if']); } else { $selected_if = "FloatingRules"; } include("head.inc"); ?>

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

$ifdesc) $iflist_tabs[$ifent] = $ifdesc; if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == "server") $iflist_tabs['l2tp'] = "L2TP VPN"; if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == "server") $iflist_tabs['pptp'] = "PPTP VPN"; if (isset($config['pppoes']['pppoe'])) { foreach ($config['pppoes']['pppoe'] as $pppoes) { if (($pppoes['mode'] == 'server')) { $iflist_tabs['pppoe'] = "PPPoE Server"; } } } /* add ipsec interfaces */ if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) { $iflist_tabs['enc0'] = 'IPsec'; } /* add openvpn/tun interfaces */ if (isset($config['openvpn']['openvpn-server']) || isset($config['openvpn']['openvpn-client'])) { $iflist_tabs['openvpn'] = 'OpenVPN'; } $tab_array = array(); foreach ($iflist_tabs as $ifent => $ifname) { $active = false; // mark active if selected or mark floating active when none is selected if ($ifent == $selected_if) { $active = true; } $tab_array[] = array($ifname, $active, "firewall_rules.php?if={$ifent}"); } display_top_tabs($tab_array); ?>
1, or WAN with an if count of 1. if (!isset($config['system']['webgui']['noantilockout']) && (((count($config['interfaces']) > 1) && ($selected_if == 'lan')) || ((count($config['interfaces']) == 1) && ($selected_if == 'wan')))): $alports = implode('
', filter_get_antilockout_ports(true)); ?> $filterent): if ( (isset($filterent['interface']) && $filterent['interface'] == $selected_if) || (isset($filterent['floating']) && $selected_if == "FloatingRules" )): $interface_has_rules = true; // select icon if (!isset($filterent['type']) && empty($filterent['disabled'])) { // not very nice.... associated NAT rules don't have a type... $iconfn = "glyphicon-play text-success"; } else if (!isset($filterent['type']) && !empty($filterent['disabled'])) { $iconfn = "glyphicon-play text-muted"; } elseif ($filterent['type'] == "block" && empty($filterent['disabled'])) { $iconfn = "glyphicon-remove text-danger"; } elseif ($filterent['type'] == "block" && !empty($filterent['disabled'])) { $iconfn = "glyphicon-remove text-muted"; } elseif ($filterent['type'] == "reject" && empty($filterent['disabled'])) { $iconfn = "glyphicon-remove text-warning"; } elseif ($filterent['type'] == "reject" && !empty($filterent['disabled'])) { $iconfn = "glyphicon-remove text-muted"; } else if ($filterent['type'] == "match" && empty($filterent['disabled'])) { $iconfn = "glyphicon-ok"; } else if ($filterent['type'] == "match" && !empty($filterent['disabled'])) { $iconfn = "glyphicon-ok text-muted"; } elseif (empty($filterent['disabled'])) { $iconfn = "glyphicon-play text-success"; } else { $iconfn = "glyphicon-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 "; } ?>
   
  IPv6 * * " class="btn btn-default btn-xs">
  * * " class="btn btn-default btn-xs">
  * * " class="btn btn-default btn-xs">
  * " class="btn btn-default btn-xs">
"> "> "> "> "> gettext("any"), "echoreq" => gettext("Echo request"), "echorep" => gettext("Echo reply"), "unreach" => gettext("Destination unreachable"), "squench" => gettext("Source quench"), "redir" => gettext("Redirect"), "althost" => gettext("Alternate Host"), "routeradv" => gettext("Router advertisement"), "routersol" => gettext("Router solicitation"), "timex" => gettext("Time exceeded"), "paramprob" => gettext("Invalid IP header"), "timereq" => gettext("Timestamp"), "timerep" => gettext("Timestamp reply"), "inforeq" => gettext("Information request"), "inforep" => gettext("Information reply"), "maskreq" => gettext("Address mask request"), "maskrep" => gettext("Address mask reply") ); if (isset($filterent['protocol']) && $filterent['protocol'] == "icmp" && !empty($filterent['icmptype'])): ?>   " class="act_move btn btn-default btn-xs"> " class="btn btn-default btn-xs"> " data-toggle="tooltip" class="act_delete btn btn-default btn-xs"> ">





" class="act_move btn btn-default btn-xs"> " data-toggle="tooltip" class="act_delete btn btn-default btn-xs"> ">