Project

General

Profile

Download (39.1 KB) Statistics
| Branch: | Tag: | Revision:
1 b2ffe419 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4 37e2071c Scott Ullrich
	firewall_rules.php
5 e4cabb75 Scott Ullrich
	part of pfSense (http://www.pfsense.com)
6 56dda8e0 Renato Botelho
	Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
7 b2ffe419 Scott Ullrich
8 e4cabb75 Scott Ullrich
	originally part of m0n0wall (http://m0n0.ch/wall)
9
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10 37e2071c Scott Ullrich
	All rights reserved.
11 b2ffe419 Scott Ullrich
12 37e2071c Scott Ullrich
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14 b2ffe419 Scott Ullrich
15 37e2071c Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17 b2ffe419 Scott Ullrich
18 37e2071c Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21 b2ffe419 Scott Ullrich
22 37e2071c Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32 5b237745 Scott Ullrich
*/
33 7ac5a4cb Scott Ullrich
/*
34
	pfSense_MODULE:	filter
35
*/
36 5b237745 Scott Ullrich
37 6b07c15a Matthew Grooms
##|+PRIV
38
##|*IDENT=page-firewall-rules
39
##|*NAME=Firewall: Rules page
40
##|*DESCR=Allow access to the 'Firewall: Rules' page.
41
##|*MATCH=firewall_rules.php*
42
##|-PRIV
43
44 5b237745 Scott Ullrich
require("guiconfig.inc");
45 7a927e67 Scott Ullrich
require_once("functions.inc");
46
require_once("filter.inc");
47
require_once("shaper.inc");
48 5b237745 Scott Ullrich
49 7a808e01 Carlos Eduardo Ramos
$pgtitle = array(gettext("Firewall"),gettext("Rules"));
50 b32dd0a6 jim-p
$shortcut_section = "firewall";
51 7a808e01 Carlos Eduardo Ramos
52 00c82782 Renato Botelho
function delete_nat_association($id) {
53
	global $config;
54
55
	if (!$id || !is_array($config['nat']['rule']))
56 673d29c0 Renato Botelho
		return;
57
58 00c82782 Renato Botelho
	$a_nat = &$config['nat']['rule'];
59
60
	foreach ($a_nat as &$natent)
61
		if ($natent['associated-rule-id'] == $id)
62
			$natent['associated-rule-id'] = '';
63 673d29c0 Renato Botelho
}
64
65 5b237745 Scott Ullrich
if (!is_array($config['filter']['rule'])) {
66
	$config['filter']['rule'] = array();
67
}
68
filter_rules_sort();
69
$a_filter = &$config['filter']['rule'];
70
71 07bd3f83 Scott Ullrich
$if = $_GET['if'];
72
if ($_POST['if'])
73
	$if = $_POST['if'];
74 b2ffe419 Scott Ullrich
75 cbe3ea96 Ermal Luçi
$ifdescs = get_configured_interface_with_descr();
76 07bd3f83 Scott Ullrich
77 32c58070 Scott Ullrich
// Drag and drop reordering
78
if($_REQUEST['dragdroporder']) {
79
	// First create a new ruleset array and tmp arrays
80 cb53651f Erik Fonnesbeck
	$a_filter_before = array();
81 32c58070 Scott Ullrich
	$a_filter_order = array();
82
	$a_filter_order_tmp = array();
83 cb53651f Erik Fonnesbeck
	$a_filter_after = array();
84
	$found = false;
85 32c58070 Scott Ullrich
	$drag_order = $_REQUEST['dragtable'];
86
	// Next traverse through rules building a new order for interface
87
	for ($i = 0; isset($a_filter[$i]); $i++) {
88 cb53651f Erik Fonnesbeck
		if(( $_REQUEST['if'] == "FloatingRules" && isset($a_filter[$i]['floating']) ) || ( $a_filter[$i]['interface'] == $_REQUEST['if'] && !isset($a_filter[$i]['floating']) )) {
89 32c58070 Scott Ullrich
			$a_filter_order_tmp[] = $a_filter[$i];
90 cb53651f Erik Fonnesbeck
			$found = true;
91
		} else if (!$found)
92
			$a_filter_before[] = $a_filter[$i];
93
		else
94
			$a_filter_after[] = $a_filter[$i];
95 32c58070 Scott Ullrich
	}
96
	// Reorder rules with the posted order
97 cb53651f Erik Fonnesbeck
	for ($i = 0; $i<count($drag_order); $i++)
98 32c58070 Scott Ullrich
		$a_filter_order[] = $a_filter_order_tmp[$drag_order[$i]];
99 cb53651f Erik Fonnesbeck
	// In case $drag_order didn't account for some rules, make sure we don't lose them
100
	if(count($a_filter_order) < count($a_filter_order_tmp)) {
101
		for ($i = 0; $i<count($a_filter_order_tmp); $i++)
102
			if(!in_array($i, $drag_order))
103
				$a_filter_order[] = $a_filter_order_tmp[$i];
104
	}
105 32c58070 Scott Ullrich
	// Overwrite filter rules with newly created items
106 cb53651f Erik Fonnesbeck
	$config['filter']['rule'] = array_merge($a_filter_before, $a_filter_order, $a_filter_after);
107 32c58070 Scott Ullrich
	// Write configuration
108
	$config = write_config("Drag and drop firewall rules ordering update.");
109
	// Redirect back to page
110 68cbabcb Scott Ullrich
	mark_subsystem_dirty('filter');
111 619f2dbd Scott Ullrich
	$undo = array();
112 56dda8e0 Renato Botelho
	foreach($_REQUEST['dragtable'] as $dt)
113 619f2dbd Scott Ullrich
		$undo[] = "";
114
	$counter = 0;
115
	foreach($_REQUEST['dragtable'] as $dt) {
116
		$undo[$dt] = $counter;
117
		$counter++;
118
	}
119 56dda8e0 Renato Botelho
	foreach($undo as $dt)
120 619f2dbd Scott Ullrich
		$undotxt .= "&dragtable[]={$dt}";
121
	Header("Location: firewall_rules.php?if=" . $_REQUEST['if'] . "&undodrag=true" . $undotxt);
122 32c58070 Scott Ullrich
	exit;
123
}
124
125 be81b340 Erik Fonnesbeck
$icmptypes = array(
126
	"" => gettext("any"),
127 a01ce4c7 jim-p
	"echoreq" => gettext("Echo request"),
128 be81b340 Erik Fonnesbeck
	"echorep" => gettext("Echo reply"),
129
	"unreach" => gettext("Destination unreachable"),
130
	"squench" => gettext("Source quench"),
131
	"redir" => gettext("Redirect"),
132
	"althost" => gettext("Alternate Host"),
133
	"routeradv" => gettext("Router advertisement"),
134
	"routersol" => gettext("Router solicitation"),
135
	"timex" => gettext("Time exceeded"),
136
	"paramprob" => gettext("Invalid IP header"),
137
	"timereq" => gettext("Timestamp"),
138
	"timerep" => gettext("Timestamp reply"),
139
	"inforeq" => gettext("Information request"),
140
	"inforep" => gettext("Information reply"),
141
	"maskreq" => gettext("Address mask request"),
142
	"maskrep" => gettext("Address mask reply")
143
);
144
145 90ba56ad Scott Ullrich
/* add group interfaces */
146
if (is_array($config['ifgroups']['ifgroupentry']))
147
	foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
148
		if (have_ruleint_access($ifgen['ifname']))
149
			$iflist[$ifgen['ifname']] = $ifgen['ifname'];
150
151 aef4dc74 Ermal Luçi
foreach ($ifdescs as $ifent => $ifdesc)
152 56dda8e0 Renato Botelho
	if(have_ruleint_access($ifent))
153 aef4dc74 Ermal Luçi
		$iflist[$ifent] = $ifdesc;
154 88bcd1d2 Scott Dale
155 617f8d25 Ermal Lu?i
if ($config['l2tp']['mode'] == "server")
156 56dda8e0 Renato Botelho
	if(have_ruleint_access("l2tp"))
157
		$iflist['l2tp'] = "L2TP VPN";
158 617f8d25 Ermal Lu?i
159 07bd3f83 Scott Ullrich
if ($config['pptpd']['mode'] == "server")
160 56dda8e0 Renato Botelho
	if(have_ruleint_access("pptp"))
161 d81c2ad1 Scott Ullrich
		$iflist['pptp'] = "PPTP VPN";
162 50e0d2a1 Scott Ullrich
163 b0899ee4 Ermal
if (is_array($config['pppoes']['pppoe'])) {
164
	foreach ($config['pppoes']['pppoe'] as $pppoes)
165
		if (($pppoes['mode'] == 'server') && have_ruleint_access("pppoe"))
166
			$iflist['pppoe'] = "PPPoE Server";
167
}
168 0c554ff6 Scott Ullrich
169 88bcd1d2 Scott Dale
/* add ipsec interfaces */
170 c6dfd289 jim-p
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']))
171 56dda8e0 Renato Botelho
	if(have_ruleint_access("enc0"))
172 0f266b2e Chris Buechler
		$iflist["enc0"] = "IPsec";
173 07bd3f83 Scott Ullrich
174 bfb60ac8 Ermal Luçi
/* add openvpn/tun interfaces */
175 d799787e Matthew Grooms
if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
176 56dda8e0 Renato Botelho
	$iflist["openvpn"] = "OpenVPN";
177 bfb60ac8 Ermal Luçi
178 4a6cf823 Scott Ullrich
pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/interfaces_override");
179
180 92125c97 Ermal Luçi
if (!$if || !isset($iflist[$if])) {
181
	if ("any" == $if)
182 56dda8e0 Renato Botelho
		$if = "FloatingRules";
183
	else if ("FloatingRules" != $if) {
184 0416d9a0 Darren Embry
		if (isset($iflist['wan']))
185
			$if = "wan";
186
		else
187
			$if = "FloatingRules";
188
	}
189 92125c97 Ermal Luçi
}
190 07bd3f83 Scott Ullrich
191 5b237745 Scott Ullrich
if ($_POST) {
192
193
	$pconfig = $_POST;
194
195
	if ($_POST['apply']) {
196 37e2071c Scott Ullrich
		$retval = 0;
197 9a7e416c Scott Ullrich
		$retval = filter_configure();
198
199 a368a026 Ermal Lu?i
		clear_subsystem_dirty('filter');
200 a985eac2 Scott Ullrich
201 1a700ea6 Scott Ullrich
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/apply");
202
203 b807a161 Scott Ullrich
		$savemsg = sprintf(gettext("The settings have been applied. The firewall rules are now reloading in the background.<br/>You can also %s monitor %s the reload progress"),"<a href='status_filter_reload.php'>","</a>");
204 5b237745 Scott Ullrich
	}
205
}
206
207 d97c50cd Bill Marquette
if ($_GET['act'] == "del") {
208 673d29c0 Renato Botelho
	if ($a_filter[$_GET['id']]) {
209
		if (!empty($a_filter[$_GET['id']]['associated-rule-id'])) {
210 00c82782 Renato Botelho
			delete_nat_association($a_filter[$_GET['id']]['associated-rule-id']);
211 673d29c0 Renato Botelho
		}
212
		unset($a_filter[$_GET['id']]);
213 3a343d73 jim-p
		if (write_config())
214 bec92ab9 jim-p
			mark_subsystem_dirty('filter');
215 e653b6e1 jim-p
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
216 673d29c0 Renato Botelho
		exit;
217
	}
218 d97c50cd Bill Marquette
}
219
220 32c58070 Scott Ullrich
// Handle save msg if defined
221 56dda8e0 Renato Botelho
if($_REQUEST['savemsg'])
222 32c58070 Scott Ullrich
	$savemsg = htmlentities($_REQUEST['savemsg']);
223
224 07bd3f83 Scott Ullrich
if (isset($_POST['del_x'])) {
225
	/* delete selected rules */
226
	if (is_array($_POST['rule']) && count($_POST['rule'])) {
227
		foreach ($_POST['rule'] as $rulei) {
228 00c82782 Renato Botelho
			delete_nat_association($a_filter[$rulei]['associated-rule-id']);
229 07bd3f83 Scott Ullrich
			unset($a_filter[$rulei]);
230
		}
231 3a343d73 jim-p
		if (write_config())
232 bec92ab9 jim-p
			mark_subsystem_dirty('filter');
233 e653b6e1 jim-p
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
234 5b237745 Scott Ullrich
		exit;
235
	}
236 07bd3f83 Scott Ullrich
} else if ($_GET['act'] == "toggle") {
237
	if ($a_filter[$_GET['id']]) {
238 56dda8e0 Renato Botelho
		if(isset($a_filter[$_GET['id']]['disabled']))
239
			unset($a_filter[$_GET['id']]['disabled']);
240
		else
241
			$a_filter[$_GET['id']]['disabled'] = true;
242 3a343d73 jim-p
		if (write_config())
243 bec92ab9 jim-p
			mark_subsystem_dirty('filter');
244 e653b6e1 jim-p
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
245 5b237745 Scott Ullrich
		exit;
246
	}
247 07bd3f83 Scott Ullrich
} else {
248 b2ffe419 Scott Ullrich
	/* yuck - IE won't send value attributes for image buttons, while Mozilla does -
249 37e2071c Scott Ullrich
	   so we use .x/.y to fine move button clicks instead... */
250 07bd3f83 Scott Ullrich
	unset($movebtn);
251
	foreach ($_POST as $pn => $pd) {
252
		if (preg_match("/move_(\d+)_x/", $pn, $matches)) {
253
			$movebtn = $matches[1];
254
			break;
255
		}
256 5b237745 Scott Ullrich
	}
257 07bd3f83 Scott Ullrich
	/* move selected rules before this rule */
258
	if (isset($movebtn) && is_array($_POST['rule']) && count($_POST['rule'])) {
259
		$a_filter_new = array();
260 b2ffe419 Scott Ullrich
261 07bd3f83 Scott Ullrich
		/* copy all rules < $movebtn and not selected */
262
		for ($i = 0; $i < $movebtn; $i++) {
263
			if (!in_array($i, $_POST['rule']))
264
				$a_filter_new[] = $a_filter[$i];
265
		}
266 b2ffe419 Scott Ullrich
267 07bd3f83 Scott Ullrich
		/* copy all selected rules */
268
		for ($i = 0; $i < count($a_filter); $i++) {
269
			if ($i == $movebtn)
270
				continue;
271
			if (in_array($i, $_POST['rule']))
272
				$a_filter_new[] = $a_filter[$i];
273
		}
274 b2ffe419 Scott Ullrich
275 07bd3f83 Scott Ullrich
		/* copy $movebtn rule */
276
		if ($movebtn < count($a_filter))
277
			$a_filter_new[] = $a_filter[$movebtn];
278 b2ffe419 Scott Ullrich
279 07bd3f83 Scott Ullrich
		/* copy all rules > $movebtn and not selected */
280
		for ($i = $movebtn+1; $i < count($a_filter); $i++) {
281
			if (!in_array($i, $_POST['rule']))
282
				$a_filter_new[] = $a_filter[$i];
283
		}
284 b2ffe419 Scott Ullrich
285 07bd3f83 Scott Ullrich
		$a_filter = $a_filter_new;
286 3a343d73 jim-p
		if (write_config())
287 bec92ab9 jim-p
			mark_subsystem_dirty('filter');
288 e653b6e1 jim-p
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
289 5b237745 Scott Ullrich
		exit;
290
	}
291
}
292 3a54b6ca Scott Dale
$closehead = false;
293 5b237745 Scott Ullrich
294 9a25487b Scott Ullrich
include("head.inc");
295 5b237745 Scott Ullrich
?>
296 44605bc8 Colin Fleming
<link type="text/css" rel="stylesheet" href="/javascript/chosen/chosen.css" />
297 3a54b6ca Scott Dale
</head>
298
299 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
300 6134cc8f Vinicius Coque
<script src="/javascript/chosen/chosen.jquery.js" type="text/javascript"></script>
301 5b237745 Scott Ullrich
<?php include("fbegin.inc"); ?>
302
<form action="firewall_rules.php" method="post">
303 6dc83d52 Scott Ullrich
304 f4245bbc Colin Fleming
<script type="text/javascript" language="javascript" src="/javascript/row_toggle.js"></script>
305 5b237745 Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
306 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('filter')): ?><p>
307 619f2dbd Scott Ullrich
<?php
308
if($_REQUEST['undodrag']) {
309 56dda8e0 Renato Botelho
	foreach($_REQUEST['dragtable'] as $dt)
310 619f2dbd Scott Ullrich
		$dragtable .= "&dragtable[]={$dt}";
311 f4245bbc Colin Fleming
	print_info_box_np_undo(gettext("The firewall rule configuration has been changed.<br/>You must apply the changes in order for them to take effect."), "apply" , gettext("Apply changes") , "firewall_rules.php?if={$_REQUEST['if']}&dragdroporder=true&{$dragtable}");
312 619f2dbd Scott Ullrich
} else {
313 f4245bbc Colin Fleming
	print_info_box_np(gettext("The firewall rule configuration has been changed.<br/>You must apply the changes in order for them to take effect."));
314 619f2dbd Scott Ullrich
}
315
?>
316 f4245bbc Colin Fleming
<br/>
317 5b237745 Scott Ullrich
<?php endif; ?>
318 df222163 Scott Ullrich
<div id="loading" style="visibity:hidden">
319 f4245bbc Colin Fleming
	<img src="/themes/<?=$g['theme']?>/images/misc/loader.gif" alt="loader" /> Loading, please wait...
320 44605bc8 Colin Fleming
	<p>&nbsp;</p>
321 6dc83d52 Scott Ullrich
</div>
322 3a4ca65e Scott Ullrich
<?php
323
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/before_table");
324
?>
325 44605bc8 Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="firewall rules">
326 56dda8e0 Renato Botelho
	<tr><td class="tabnavtbl">
327
	<?php
328 0366b748 Scott Ullrich
	/* active tabs */
329
	$tab_array = array();
330 56dda8e0 Renato Botelho
	if ("FloatingRules" == $if)
331
		$active = true;
332
	else
333
		$active = false;
334
	$tab_array[] = array(gettext("Floating"), $active, "firewall_rules.php?if=FloatingRules");
335 0366b748 Scott Ullrich
	$tabscounter = 0; $i = 0; foreach ($iflist as $ifent => $ifname) {
336
		if ($ifent == $if)
337
			$active = true;
338
		else
339
			$active = false;
340
		$tab_array[] = array($ifname, $active, "firewall_rules.php?if={$ifent}");
341
	}
342
	display_top_tabs($tab_array);
343 56dda8e0 Renato Botelho
	?>
344
	</td></tr>
345
	<tr><td>
346
		<div id="mainarea">
347 44605bc8 Colin Fleming
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
348 56dda8e0 Renato Botelho
			<?php
349
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/before_first_tr");
350
			?>
351 1db196b2 Scott Ullrich
			<tr id="frheader">
352
			<td width="3%" class="list">&nbsp;</td>
353
			<td width="5%" class="list">&nbsp;</td>
354 5fec5fe4 Scott Ullrich
			<td width="3%" class="listhdrr"><?=gettext("ID");?></td>
355 56dda8e0 Renato Botelho
			<?php
356 1db196b2 Scott Ullrich
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_id_tablehead");
357 56dda8e0 Renato Botelho
			?>
358 1db196b2 Scott Ullrich
			<td width="6%" class="listhdrr"><?=gettext("Proto");?></td>
359
			<td width="12%" class="listhdrr"><?=gettext("Source");?></td>
360
			<td width="6%" class="listhdrr"><?=gettext("Port");?></td>
361
			<td width="12%" class="listhdrr"><?=gettext("Destination");?></td>
362
			<td width="6%" class="listhdrr"><?=gettext("Port");?></td>
363
			<td width="5%" class="listhdrr"><?=gettext("Gateway");?></td>
364
			<td width="8%" class="listhdrr"><?=gettext("Queue");?></td>
365
			<td width="5%" class="listhdrr"><?=gettext("Schedule");?></td>
366 56dda8e0 Renato Botelho
			<?php
367 10995178 Scott Ullrich
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_desc_tablehead");
368 56dda8e0 Renato Botelho
			?>
369 1db196b2 Scott Ullrich
			<td width="19%" class="listhdr"><?=gettext("Description");?></td>
370
			<td width="10%" class="list">
371 44605bc8 Colin Fleming
				<table border="0" cellspacing="0" cellpadding="1" summary="delete selected rules">
372 56dda8e0 Renato Botelho
					<tr>
373
					<?php
374
						$nrules = 0;
375
						for ($i = 0; isset($a_filter[$i]); $i++) {
376
							$filterent = $a_filter[$i];
377
							if ($filterent['interface'] != $if && !isset($filterent['floating']))
378
								continue;
379
							if (isset($filterent['floating']) && "FloatingRules" != $if)
380
								continue;
381
							$nrules++;
382
						}
383
					?>
384
					<td>
385
					<?php if ($nrules == 0): ?>
386 f4245bbc Colin Fleming
						<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?gettext("delete selected rules"); ?>" border="0" alt="delete" /><?php else: ?>
387
						<input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" style="width:17;height:17" title="<?=gettext("delete selected rules");?>" onclick="return confirm('<?=gettext('Do you really want to delete the selected rules?');?>')" />
388 56dda8e0 Renato Botelho
					<?php endif; ?>
389
					</td>
390 f4245bbc Colin Fleming
					<td align="center" valign="middle"><a href="firewall_rules_edit.php?if=<?=htmlspecialchars($if);?>&amp;after=-1"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add new rule");?>" width="17" height="17" border="0" alt="add" /></a></td>
391 56dda8e0 Renato Botelho
					</tr>
392
				</table>
393
			</td>
394
			</tr>
395
			<?php   // Show the anti-lockout rule if it's enabled, and we are on LAN with an if count > 1, or WAN with an if count of 1.
396
				if (!isset($config['system']['webgui']['noantilockout']) &&
397
					(((count($config['interfaces']) > 1) && ($if == 'lan'))
398
					|| ((count($config['interfaces']) == 1) && ($if == 'wan')))):
399
400
					$alports = implode('<br/>', filter_get_antilockout_ports(true));
401
			?>
402
			<tr valign="top" id="antilockout">
403 03976254 jim-p
			<td class="list">&nbsp;</td>
404 f4245bbc Colin Fleming
			<td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif" width="11" height="11" border="0" alt="pass" /></td>
405 4e8854c6 Charlie Root
			<td class="listlr" style="background-color: #E0E0E0">&nbsp;</td>
406 56dda8e0 Renato Botelho
			<?php
407 5fec5fe4 Scott Ullrich
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_id_tr_antilockout");
408 56dda8e0 Renato Botelho
			?>
409 03976254 jim-p
			<td class="listr" style="background-color: #E0E0E0">*</td>
410
			<td class="listr" style="background-color: #E0E0E0">*</td>
411
			<td class="listr" style="background-color: #E0E0E0">*</td>
412
			<td class="listr" style="background-color: #E0E0E0"><?=$iflist[$if];?> Address</td>
413 31f0ef21 jim-p
			<td class="listr" style="background-color: #E0E0E0"><?= $alports ?></td>
414 03976254 jim-p
			<td class="listr" style="background-color: #E0E0E0">*</td>
415
			<td class="listr" style="background-color: #E0E0E0">*</td>
416 4e8854c6 Charlie Root
			<td class="listr" style="background-color: #E0E0E0">&nbsp;</td>
417 03976254 jim-p
			<td class="listbg"><?=gettext("Anti-Lockout Rule");?></td>
418 f4245bbc Colin Fleming
			<td valign="middle" class="list nowrap">
419 44605bc8 Colin Fleming
			<table border="0" cellspacing="0" cellpadding="1" summary="move rules before">
420 03976254 jim-p
				<tr>
421 f4245bbc Colin Fleming
					<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected rules before this rule");?>" alt="move" /></td>
422
					<td><a href="system_advanced_admin.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit rule");?>" width="17" height="17" border="0" alt="edit" /></a></td>
423 03976254 jim-p
				</tr>
424
				<tr>
425
					<td align="center" valign="middle"></td>
426 f4245bbc Colin Fleming
					<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus_d.gif" title="<?=gettext("add a new rule based on this one");?>" width="17" height="17" border="0" alt="add" /></td>
427 03976254 jim-p
				</tr>
428
				</table>
429
			</td>
430
			</tr>
431
<?php endif; ?>
432
433 f1f60c92 Ermal Luçi
<?php if (isset($config['interfaces'][$if]['blockpriv'])): ?>
434 56dda8e0 Renato Botelho
			<tr valign="top" id="frrfc1918">
435
			<td class="list">&nbsp;</td>
436 fd35c8c1 Colin Fleming
			<td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0" alt="block" /></td>
437 56dda8e0 Renato Botelho
			<td class="listlr" style="background-color: #E0E0E0">&nbsp;</td>
438
			<td class="listr" style="background-color: #E0E0E0">*</td>
439
			<td class="listr" style="background-color: #E0E0E0"><?=gettext("RFC 1918 networks");?></td>
440
			<td class="listr" style="background-color: #E0E0E0">*</td>
441
			<td class="listr" style="background-color: #E0E0E0">*</td>
442
			<td class="listr" style="background-color: #E0E0E0">*</td>
443
			<td class="listr" style="background-color: #E0E0E0">*</td>
444
			<td class="listr" style="background-color: #E0E0E0">*</td>
445
			<td class="listr" style="background-color: #E0E0E0">&nbsp;</td>
446
			<td class="listbg"><?=gettext("Block private networks");?></td>
447 f4245bbc Colin Fleming
			<td valign="middle" class="list nowrap">
448 44605bc8 Colin Fleming
				<table border="0" cellspacing="0" cellpadding="1" summary="move rules before">
449 d9eeccbd Scott Ullrich
					<tr>
450 f4245bbc Colin Fleming
					<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected rules before this rule");?>" alt="edit" /></td>
451
					<td><a href="interfaces.php?if=<?=htmlspecialchars($if)?>#rfc1918"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit rule");?>" width="17" height="17" border="0" alt="edit" /></a></td>
452 d9eeccbd Scott Ullrich
					</tr>
453
					<tr>
454 56dda8e0 Renato Botelho
					<td align="center" valign="middle"></td>
455 f4245bbc Colin Fleming
					<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus_d.gif" title="<?=gettext("add a new rule based on this one");?>" width="17" height="17" border="0" alt="add" /></td>
456 d9eeccbd Scott Ullrich
					</tr>
457 56dda8e0 Renato Botelho
				</table>
458
			</td>
459
			</tr>
460 c20c0f5a Scott Ullrich
<?php endif; ?>
461 f1f60c92 Ermal Luçi
<?php if (isset($config['interfaces'][$if]['blockbogons'])): ?>
462 56dda8e0 Renato Botelho
			<tr valign="top" id="frrfc1918">
463
			<td class="list">&nbsp;</td>
464 f4245bbc Colin Fleming
			<td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0" alt="block" /></td>
465 56dda8e0 Renato Botelho
			<td class="listlr" style="background-color: #E0E0E0">&nbsp;</td>
466
			<td class="listr" style="background-color: #E0E0E0">*</td>
467
			<td class="listr" style="background-color: #E0E0E0"><?=gettext("Reserved/not assigned by IANA");?></td>
468
			<td class="listr" style="background-color: #E0E0E0">*</td>
469
			<td class="listr" style="background-color: #E0E0E0">*</td>
470
			<td class="listr" style="background-color: #E0E0E0">*</td>
471
			<td class="listr" style="background-color: #E0E0E0">*</td>
472
			<td class="listr" style="background-color: #E0E0E0">*</td>
473
			<td class="listr" style="background-color: #E0E0E0">*</td>
474
			<td class="listbg"><?=gettext("Block bogon networks");?></td>
475 f4245bbc Colin Fleming
			<td valign="middle" class="list nowrap">
476 44605bc8 Colin Fleming
				<table border="0" cellspacing="0" cellpadding="1" summary="move rules before">
477 c20c0f5a Scott Ullrich
					<tr>
478 f4245bbc Colin Fleming
					<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected rules before this rule");?>" alt="move" /></td>
479
					<td><a href="interfaces.php?if=<?=htmlspecialchars($if)?>#rfc1918"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit rule");?>" width="17" height="17" border="0" alt=" edit" /></a></td>
480 c20c0f5a Scott Ullrich
					</tr>
481
					<tr>
482 56dda8e0 Renato Botelho
					<td align="center" valign="middle"></td>
483 f4245bbc Colin Fleming
					<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus_d.gif" title="<?=gettext("add a new rule based on this one");?>" width="17" height="17" border="0" alt="add" /></td>
484 c20c0f5a Scott Ullrich
					</tr>
485 56dda8e0 Renato Botelho
				</table>
486
			</td>
487
			</tr>
488 c20c0f5a Scott Ullrich
<?php endif; ?>
489 f4245bbc Colin Fleming
			<tbody id="dragtable">
490 56dda8e0 Renato Botelho
<?php $nrules = 0; for ($i = 0; isset($a_filter[$i]); $i++):
491
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/row_start");
492
	$filterent = $a_filter[$i];
493
	if ($filterent['interface'] != $if && !isset($filterent['floating']))
494
		continue;
495
	if (isset($filterent['floating']) && "FloatingRules" != $if)
496
		continue;
497
	$isadvset = firewall_check_for_advanced_options($filterent);
498
	if($isadvset)
499 f4245bbc Colin Fleming
		$advanced_set = "<img src=\"./themes/{$g['theme']}/images/icons/icon_advanced.gif\" title=\"" . gettext("advanced settings set") . ": {$isadvset}\" border=\"0\" alt=\"avanced\" />";
500 56dda8e0 Renato Botelho
	else
501
		$advanced_set = "";
502
?>
503
			<tr valign="top" id="fr<?=$nrules;?>">
504
			<td class="listt">
505 f4245bbc Colin Fleming
				<input type="checkbox" id="frc<?=$nrules;?>" name="rule[]" value="<?=$i;?>" onclick="fr_bgcolor('<?=$nrules;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" />
506 56dda8e0 Renato Botelho
				<?php echo $advanced_set; ?>
507
			</td>
508
			<td class="listt" align="center">
509
			<?php
510
				if ($filterent['type'] == "block")
511
					$iconfn = "block";
512
				else if ($filterent['type'] == "reject")
513
					$iconfn = "reject";
514
				else
515
					$iconfn = "pass";
516
				if (isset($filterent['disabled'])) {
517
					$textss = "<span class=\"gray\">";
518
					$textse = "</span>";
519
					$iconfn .= "_d";
520
				} else {
521
					$textss = $textse = "";
522
				}
523
			?>
524 f4245bbc Colin Fleming
				<a href="?if=<?=htmlspecialchars($if);?>&amp;act=toggle&amp;id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfn;?>.gif" width="11" height="11" border="0" title="<?=gettext("click to toggle enabled/disabled status");?>" alt="icon" /></a>
525 56dda8e0 Renato Botelho
			<?php
526
				if (isset($filterent['log'])):
527
					$iconfnlog = "log_s";
528
				if (isset($filterent['disabled']))
529
					$iconfnlog .= "_d";
530
			?>
531 f4245bbc Colin Fleming
			<br/><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfnlog;?>.gif" width="11" height="15" border="0" alt="icon" />
532 56dda8e0 Renato Botelho
<?php endif; ?>
533
			</td>
534
			<?php
535
536 2a113ca9 Scott Dale
				//build Alias popup box
537 3a54b6ca Scott Dale
				$alias_src_span_begin = "";
538
				$alias_src_port_span_begin = "";
539
				$alias_dst_span_begin = "";
540
				$alias_dst_port_span_begin = "";
541 56dda8e0 Renato Botelho
542 2a9db752 Scott Dale
				$alias_popup = rule_popup($filterent['source']['address'],pprint_port($filterent['source']['port']),$filterent['destination']['address'],pprint_port($filterent['destination']['port']));
543 56dda8e0 Renato Botelho
544 2a9db752 Scott Dale
				$alias_src_span_begin = $alias_popup["src"];
545
				$alias_src_port_span_begin = $alias_popup["srcport"];
546
				$alias_dst_span_begin = $alias_popup["dst"];
547
				$alias_dst_port_span_begin = $alias_popup["dstport"];
548 56dda8e0 Renato Botelho
549 59167b10 Darren Embry
				$alias_src_span_end = $alias_popup["src_end"];
550
				$alias_src_port_span_end = $alias_popup["srcport_end"];
551
				$alias_dst_span_end = $alias_popup["dst_end"];
552
				$alias_dst_port_span_end = $alias_popup["dstport_end"];
553 56dda8e0 Renato Botelho
554 2a113ca9 Scott Dale
				//build Schedule popup box
555
				$a_schedules = &$config['schedules']['schedule'];
556
				$schedule_span_begin = "";
557
				$schedule_span_end = "";
558 d2aa8cd6 sullrich
				$sched_caption_escaped = "";
559 eace1363 Scott Dale
				$sched_content = "";
560 3b907eb1 Scott Dale
				$schedstatus = false;
561 38f90dc8 Rafael Lucas
				$dayArray = array (gettext('Mon'),gettext('Tues'),gettext('Wed'),gettext('Thur'),gettext('Fri'),gettext('Sat'),gettext('Sun'));
562
				$monthArray = array (gettext('January'),gettext('February'),gettext('March'),gettext('April'),gettext('May'),gettext('June'),gettext('July'),gettext('August'),gettext('September'),gettext('October'),gettext('November'),gettext('December'));
563 b6ab9bd2 Ermal
				if($config['schedules']['schedule'] <> "" and is_array($config['schedules']['schedule'])) {
564 8ce97a08 Scott Dale
					foreach ($a_schedules as $schedule)
565
					{
566
						if ($schedule['name'] == $filterent['sched'] ){
567 60120e37 Ermal Lu?i
							$schedstatus = filter_get_time_based_rule_status($schedule);
568 56dda8e0 Renato Botelho
569 8ce97a08 Scott Dale
							foreach($schedule['timerange'] as $timerange) {
570
								$tempFriendlyTime = "";
571
								$tempID = "";
572
								$firstprint = false;
573
								if ($timerange){
574
									$dayFriendly = "";
575 56dda8e0 Renato Botelho
									$tempFriendlyTime = "";
576
577 8ce97a08 Scott Dale
									//get hours
578
									$temptimerange = $timerange['hour'];
579
									$temptimeseparator = strrpos($temptimerange, "-");
580 56dda8e0 Renato Botelho
581
									$starttime = substr ($temptimerange, 0, $temptimeseparator);
582
									$stoptime = substr ($temptimerange, $temptimeseparator+1);
583
584 8ce97a08 Scott Dale
									if ($timerange['month']){
585
										$tempmontharray = explode(",", $timerange['month']);
586
										$tempdayarray = explode(",",$timerange['day']);
587
										$arraycounter = 0;
588
										$firstDayFound = false;
589
										$firstPrint = false;
590
										foreach ($tempmontharray as $monthtmp){
591
											$month = $tempmontharray[$arraycounter];
592
											$day = $tempdayarray[$arraycounter];
593 56dda8e0 Renato Botelho
594 2a113ca9 Scott Dale
											if (!$firstDayFound)
595
											{
596 8ce97a08 Scott Dale
												$firstDay = $day;
597
												$firstmonth = $month;
598 2a113ca9 Scott Dale
												$firstDayFound = true;
599
											}
600 56dda8e0 Renato Botelho
601 8ce97a08 Scott Dale
											$currentDay = $day;
602
											$nextDay = $tempdayarray[$arraycounter+1];
603
											$currentDay++;
604
											if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])){
605
												if ($firstPrint)
606 2a113ca9 Scott Dale
													$dayFriendly .= ", ";
607
												$currentDay--;
608
												if ($currentDay != $firstDay)
609 8ce97a08 Scott Dale
													$dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ;
610 2a113ca9 Scott Dale
												else
611 8ce97a08 Scott Dale
													$dayFriendly .=  $monthArray[$month-1] . " " . $day;
612 56dda8e0 Renato Botelho
												$firstDayFound = false;
613 8ce97a08 Scott Dale
												$firstPrint = true;
614 56dda8e0 Renato Botelho
											}
615
											$arraycounter++;
616 2a113ca9 Scott Dale
										}
617
									}
618 8ce97a08 Scott Dale
									else
619
									{
620
										$tempdayFriendly = $timerange['position'];
621
										$firstDayFound = false;
622 56dda8e0 Renato Botelho
										$tempFriendlyDayArray = explode(",", $tempdayFriendly);
623 8ce97a08 Scott Dale
										$currentDay = "";
624
										$firstDay = "";
625
										$nextDay = "";
626 56dda8e0 Renato Botelho
										$counter = 0;
627 8ce97a08 Scott Dale
										foreach ($tempFriendlyDayArray as $day){
628
											if ($day != ""){
629
												if (!$firstDayFound)
630
												{
631
													$firstDay = $tempFriendlyDayArray[$counter];
632
													$firstDayFound = true;
633
												}
634
												$currentDay =$tempFriendlyDayArray[$counter];
635
												//get next day
636
												$nextDay = $tempFriendlyDayArray[$counter+1];
637 56dda8e0 Renato Botelho
												$currentDay++;
638 8ce97a08 Scott Dale
												if ($currentDay != $nextDay){
639
													if ($firstprint)
640
														$dayFriendly .= ", ";
641
													$currentDay--;
642
													if ($currentDay != $firstDay)
643
														$dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
644
													else
645
														$dayFriendly .= $dayArray[$firstDay-1];
646 56dda8e0 Renato Botelho
													$firstDayFound = false;
647
													$firstprint = true;
648 8ce97a08 Scott Dale
												}
649
												$counter++;
650
											}
651
										}
652 56dda8e0 Renato Botelho
									}
653 8ce97a08 Scott Dale
									$timeFriendly = $starttime . " - " . $stoptime;
654
									$description = $timerange['rangedescr'];
655 f4245bbc Colin Fleming
									$sched_content .= $dayFriendly . "; " . $timeFriendly . "<br/>";
656 8ce97a08 Scott Dale
								}
657 2a113ca9 Scott Dale
							}
658 d2aa8cd6 sullrich
							$sched_caption_escaped = str_replace("'", "\'", $schedule['descr']);
659 59167b10 Darren Embry
							$schedule_span_begin = "<span style=\"cursor: help;\" onmouseover=\"domTT_activate(this, event, 'content', '<h1>{$sched_caption_escaped}</h1><p>{$sched_content}</p>', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\" onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\"><u>";
660
							$schedule_span_end = "</u></span>";
661 2a113ca9 Scott Dale
						}
662
					}
663
				}
664 6fecc73b Scott Dale
				$printicon = false;
665 616dd997 Scott Dale
				$alttext = "";
666
				$image = "";
667 56dda8e0 Renato Botelho
				if (!isset($filterent['disabled'])) {
668
					if ($schedstatus) {
669
						if ($iconfn == "block" || $iconfn == "reject") {
670
							$image = "icon_block";
671
							$alttext = gettext("Traffic matching this rule is currently being denied");
672
						} else {
673
							$image = "icon_pass";
674
							$alttext = gettext("Traffic matching this rule is currently being allowed");
675
						}
676
						$printicon = true;
677
					} else if ($filterent['sched']) {
678
						if ($iconfn == "block" || $iconfn == "reject")
679
							$image = "icon_block_d";
680
						else
681
							$image = "icon_block";
682
						$alttext = gettext("This rule is not currently active because its period has expired");
683
						$printicon = true;
684
					}
685 616dd997 Scott Dale
				}
686 56dda8e0 Renato Botelho
			?>
687 f4245bbc Colin Fleming
			<td class="listlr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
688 56dda8e0 Renato Botelho
				<?=$textss;?><?php if (isset($filterent['id'])) echo $filterent['id']."&nbsp;"; else echo "&nbsp;"; ?><?=$textse;?>
689
			</td>
690
			<?php
691 5fec5fe4 Scott Ullrich
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_id_tr");
692 56dda8e0 Renato Botelho
			?>
693 f4245bbc Colin Fleming
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
694 56dda8e0 Renato Botelho
			<?=$textss;?>
695
			<?php
696
				if (isset($filterent['ipprotocol'])) {
697
					switch($filterent['ipprotocol']) {
698
						case "inet":
699
							echo "IPv4 ";
700
							break;
701
						case "inet6":
702
							echo "IPv6 ";
703
							break;
704
						case "inet46":
705
							echo "IPv4+6 ";
706
							break;
707
					}
708
				} else {
709
					echo "IPv4 ";
710 be81b340 Erik Fonnesbeck
				}
711 56dda8e0 Renato Botelho
				if (isset($filterent['protocol'])) {
712
					echo strtoupper($filterent['protocol']);
713
					if (strtoupper($filterent['protocol']) == "ICMP" && !empty($filterent['icmptype'])) {
714
						echo ' <span style="cursor: help;" title="ICMP type: ' . $icmptypes[$filterent['icmptype']] . '"><u>';
715
						echo $filterent['icmptype'];
716
						echo '</u></span>';
717
					}
718
				} else echo "*";
719
			?>
720
			<?=$textse;?>
721
			</td>
722 f4245bbc Colin Fleming
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
723 56dda8e0 Renato Botelho
				<?=$textss;?><?php echo $alias_src_span_begin;?><?php echo htmlspecialchars(pprint_address($filterent['source']));?><?php echo $alias_src_span_end;?><?=$textse;?>
724
			</td>
725 f4245bbc Colin Fleming
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
726 56dda8e0 Renato Botelho
				<?=$textss;?><?php echo $alias_src_port_span_begin;?><?php echo htmlspecialchars(pprint_port($filterent['source']['port'])); ?><?php echo $alias_src_port_span_end;?><?=$textse;?>
727
			</td>
728 f4245bbc Colin Fleming
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
729 56dda8e0 Renato Botelho
				<?=$textss;?><?php echo $alias_dst_span_begin;?><?php echo htmlspecialchars(pprint_address($filterent['destination'])); ?><?php echo $alias_dst_span_end;?><?=$textse;?>
730
			</td>
731 f4245bbc Colin Fleming
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
732 56dda8e0 Renato Botelho
				<?=$textss;?><?php echo $alias_dst_port_span_begin;?><?php echo htmlspecialchars(pprint_port($filterent['destination']['port'])); ?><?php echo $alias_dst_port_span_end;?><?=$textse;?>
733
			</td>
734 f4245bbc Colin Fleming
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
735 56dda8e0 Renato Botelho
				<?=$textss;?><?php if (isset($config['interfaces'][$filterent['gateway']]['descr'])) echo htmlspecialchars($config['interfaces'][$filterent['gateway']]['descr']); else  echo htmlspecialchars(pprint_port($filterent['gateway'])); ?><?=$textse;?>
736
			</td>
737 f4245bbc Colin Fleming
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
738 56dda8e0 Renato Botelho
			<?=$textss;?>
739
			<?php
740
				if (isset($filterent['ackqueue']) && isset($filterent['defaultqueue'])) {
741
					$desc = $filterent['ackqueue'] ;
742 f4245bbc Colin Fleming
					echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['ackqueue']}&amp;action=show\">{$desc}</a>";
743 56dda8e0 Renato Botelho
					$desc = $filterent['defaultqueue'];
744 f4245bbc Colin Fleming
					echo "/<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
745 56dda8e0 Renato Botelho
				} else if (isset($filterent['defaultqueue'])) {
746
					$desc = $filterent['defaultqueue'];
747 f4245bbc Colin Fleming
					echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
748 56dda8e0 Renato Botelho
				} else
749
					echo gettext("none");
750
			?>
751
			<?=$textse;?>
752
			</td>
753 f4245bbc Colin Fleming
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';"><font color="black">
754 44605bc8 Colin Fleming
				<?php if ($printicon) { ?><img src="./themes/<?= $g['theme']; ?>/images/icons/<?php echo $image; ?>.gif" title="<?php echo $alttext;?>" border="0" alt="icon" /><?php } ?><?=$textss;?><?php echo $schedule_span_begin;?><?=htmlspecialchars($filterent['sched']);?>&nbsp;<?php echo $schedule_span_end; ?><?=$textse;?>
755 f4245bbc Colin Fleming
			</font></td>
756 56dda8e0 Renato Botelho
			<?php
757 1db196b2 Scott Ullrich
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_descr_tr");
758 56dda8e0 Renato Botelho
			?>
759 f4245bbc Colin Fleming
			<td class="listbg descr" onclick="fr_toggle(<?=$nrules;?>)" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
760 56dda8e0 Renato Botelho
				<?=$textss;?><?=htmlspecialchars($filterent['descr']);?>&nbsp;<?=$textse;?>
761
			</td>
762 f4245bbc Colin Fleming
			<td valign="middle" class="list nowrap">
763 44605bc8 Colin Fleming
				<table border="0" cellspacing="0" cellpadding="1" summary="move before">
764 07bd3f83 Scott Ullrich
					<tr>
765 f4245bbc Colin Fleming
					<td><input name="move_<?=$i;?>" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" style="width:17;height:17" title="<?=gettext("move selected rules before this rule"); ?>" onmouseover="fr_insline(<?=$nrules;?>, true)" onmouseout="fr_insline(<?=$nrules;?>, false)" /></td>
766
					<td><a href="firewall_rules_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit rule"); ?>" width="17" height="17" border="0" alt="edit" /></a></td>
767 07bd3f83 Scott Ullrich
					</tr>
768
					<tr>
769 f4245bbc Colin Fleming
					<td align="center" valign="middle"><a href="firewall_rules.php?act=del&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete rule"); ?>" onclick="return confirm('Do you really want to delete this rule?')" alt="delete" /></a></td>
770
					<td><a href="firewall_rules_edit.php?dup=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add a new rule based on this one"); ?>" width="17" height="17" border="0" alt="add" /></a></td>
771 07bd3f83 Scott Ullrich
					</tr>
772 56dda8e0 Renato Botelho
				</table>
773
			</td>
774
			</tr>
775
			<?php $nrules++; endfor; ?>
776 f4245bbc Colin Fleming
			  <tr><td></td></tr></tbody>
777 56dda8e0 Renato Botelho
<?php if ($nrules == 0): ?>
778 f4245bbc Colin Fleming
			<tr>
779 56dda8e0 Renato Botelho
			<td class="listt"></td>
780
			<td class="listt"></td>
781
			<td class="listlr" colspan="10" align="center" valign="middle">
782
			<span class="gray">
783
	<?php if ($_REQUEST['if'] == "FloatingRules"): ?>
784
				<?=gettext("No floating rules are currently defined."); ?><br/><br/>
785
	<?php else: ?>
786
				<?=gettext("No rules are currently defined for this interface"); ?><br/>
787
				<?=gettext("All incoming connections on this interface will be blocked until you add pass rules."); ?><br/><br/>
788
	<?php endif; ?>
789 f4245bbc Colin Fleming
				<?=gettext("Click the"); ?> <a href="firewall_rules_edit.php?if=<?=htmlspecialchars($if);?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add new rule");?>" border="0" width="17" height="17" align="middle" alt="add" /></a><?=gettext(" button to add a new rule.");?></span>
790 56dda8e0 Renato Botelho
			</td>
791 f4245bbc Colin Fleming
			</tr>
792 56dda8e0 Renato Botelho
<?php endif; ?>
793
			<tr id="fr<?=$nrules;?>">
794
			<td class="list"></td>
795
			<td class="list"></td>
796
			<?php
797 8c5bf3d7 Scott Ullrich
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_id_tr_belowtable");
798 56dda8e0 Renato Botelho
			?>
799
			<td class="list">&nbsp;</td>
800
			<td class="list">&nbsp;</td>
801
			<td class="list">&nbsp;</td>
802
			<td class="list">&nbsp;</td>
803
			<td class="list">&nbsp;</td>
804
			<td class="list">&nbsp;</td>
805
			<td class="list">&nbsp;</td>
806
			<td class="list">&nbsp;</td>
807
			<td class="list">&nbsp;</td>
808
			<td class="list">&nbsp;</td>
809
			<td class="list">
810 44605bc8 Colin Fleming
				<table border="0" cellspacing="0" cellpadding="1" summary="move rules">
811 07bd3f83 Scott Ullrich
					<tr>
812 56dda8e0 Renato Botelho
					<td>
813 f4245bbc Colin Fleming
						<?php if ($nrules == 0): ?><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected rules to end");?>" border="0" alt="move" /><?php else: ?><input name="move_<?=$i;?>" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" style="width:17;height:17" title="<?=gettext("move selected rules to end");?>" onmouseover="fr_insline(<?=$nrules;?>, true)" onmouseout="fr_insline(<?=$nrules;?>, false)" /><?php endif; ?></td>
814 56dda8e0 Renato Botelho
					<td></td>
815 07bd3f83 Scott Ullrich
					</tr>
816 56dda8e0 Renato Botelho
					<tr>
817
					<td>
818
<?php if ($nrules == 0): ?>
819 f4245bbc Colin Fleming
						<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected rules");?>" border="0" alt="delete" /><?php else: ?>
820
						<input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" style="width:17;height:17" title="<?=gettext("delete selected rules");?>" onclick="return confirm('<?=gettext('Do you really want to delete the selected rules?');?>')" />
821 a3381369 Colin Fleming
<?php endif; ?>
822 56dda8e0 Renato Botelho
					</td>
823 f4245bbc Colin Fleming
			                <td><a href="firewall_rules_edit.php?if=<?=htmlspecialchars($if);?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add new rule");?>" width="17" height="17" border="0" alt="add" /></a></td>
824 56dda8e0 Renato Botelho
					</tr>
825
				</table>
826
			</td>
827
			</tr>
828
		</table>
829 44605bc8 Colin Fleming
		<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0" summary="icons">
830 56dda8e0 Renato Botelho
			<tr>
831 f4245bbc Colin Fleming
				<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif" width="11" height="11" alt="pass" /></td>
832 56dda8e0 Renato Botelho
				<td><?=gettext("pass");?></td>
833
				<td width="14"></td>
834 f4245bbc Colin Fleming
				<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" alt="block" /></td>
835 56dda8e0 Renato Botelho
				<td><?=gettext("block");?></td>
836
				<td width="14"></td>
837 f4245bbc Colin Fleming
				<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_reject.gif" width="11" height="11" alt="reject" /></td>
838 56dda8e0 Renato Botelho
				<td><?=gettext("reject");?></td>
839
				<td width="14"></td>
840 f4245bbc Colin Fleming
				<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_log.gif" width="11" height="11" alt="log" /></td>
841 56dda8e0 Renato Botelho
				<td><?=gettext("log");?></td>
842
			</tr>
843
			<tr>
844 f4245bbc Colin Fleming
				<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass_d.gif" width="11" height="11" alt="pass disabled" /></td>
845
				<td class="nowrap"><?=gettext("pass (disabled)");?></td>
846 56dda8e0 Renato Botelho
				<td>&nbsp;</td>
847 f4245bbc Colin Fleming
				<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block_d.gif" width="11" height="11" alt="block disabled" /></td>
848
				<td class="nowrap"><?=gettext("block (disabled)");?></td>
849 56dda8e0 Renato Botelho
				<td>&nbsp;</td>
850 f4245bbc Colin Fleming
				<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_reject_d.gif" width="11" height="11" alt="reject disabled" /></td>
851
				<td class="nowrap"><?=gettext("reject (disabled)");?></td>
852 56dda8e0 Renato Botelho
				<td>&nbsp;</td>
853 f4245bbc Colin Fleming
				<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_log_d.gif" width="11" height="11" alt="log disabled" /></td>
854
				<td class="nowrap"><?=gettext("log (disabled)");?></td>
855 56dda8e0 Renato Botelho
			</tr>
856
			<tr>
857
				<td colspan="10">
858 44605bc8 Colin Fleming
					<p>&nbsp;</p>
859 56dda8e0 Renato Botelho
					<strong>
860
						<span class="red"><?=gettext("Hint:");?></span>
861 f4245bbc Colin Fleming
					</strong><br/>
862 56dda8e0 Renato Botelho
					<ul>
863
					<?php if ("FloatingRules" != $if): ?>
864
						<li><?=gettext("Rules are evaluated on a first-match basis (i.e. " .
865
						"the action of the first rule to match a packet will be executed). " .
866
						"This means that if you use block rules, you'll have to pay attention " .
867
						"to the rule order. Everything that isn't explicitly passed is blocked " .
868
						"by default. ");?>
869
						</li>
870
					<?php else: ?>
871
						<li><?=gettext("Floating rules are evaluated on a first-match basis (i.e. " .
872
						"the action of the first rule to match a packet will be executed) only " .
873
						"if the 'quick' option is checked on a rule. Otherwise they will only apply if no " .
874
						"other rules match. Pay close attention to the rule order and options " .
875
						"chosen. If no rule here matches, the per-interface or default rules are used. ");?>
876
						</li>
877
					<?php endif; ?>
878
					</ul>
879
				 </td>
880
			</tr>
881
		</table>
882
		</div>
883
	</td>
884
	</tr>
885 d732f186 Bill Marquette
</table>
886 f4245bbc Colin Fleming
<input type="hidden" name="if" value="<?=htmlspecialchars($if);?>" />
887 56dda8e0 Renato Botelho
<script type="text/javascript">
888 f4245bbc Colin Fleming
//<![CDATA[
889 7abaeb1f Scott Ullrich
	var number_of_rules = <?=$nrules?>;
890 56dda8e0 Renato Botelho
	<?php $nrules = 0; for ($i = 0; isset($a_filter[$i]); $i++): ?>
891
	/*
892
		Sortable.create("dragtable", {
893
			tag:"tr",
894
			format:"fr([0-9999999])",
895
			containment:["dragtable"],
896
			onChange:function(affected) {
897
				document.body.style.cursor = 'move';
898
			},
899
			onUpdate:function(container) {
900
				document.body.style.cursor = 'move';
901
				updateOrder(Sortable.serialize('dragtable', 'tr'));
902
			}
903
		});
904
	*/
905
	<?php endfor; ?>
906 32c58070 Scott Ullrich
	function updateOrder(order) {
907 12c54789 Scott Ullrich
		if(document.getElementById("redboxtable"))
908 df39dd8a Vinicius Coque
			jQuery('#redboxtable').hide();
909
		jQuery('#loading').show();
910 32c58070 Scott Ullrich
		document.body.style.cursor = 'wait';
911 dd5bf424 Scott Ullrich
		document.location = 'firewall_rules.php?if=<?=htmlspecialchars($if);?>&dragdroporder=true&' + Sortable.serialize('dragtable', 'tr');
912 32c58070 Scott Ullrich
		return;
913
	}
914 df39dd8a Vinicius Coque
	jQuery('#loading').hide();
915 f4245bbc Colin Fleming
//]]>
916 56dda8e0 Renato Botelho
</script>
917 07bd3f83 Scott Ullrich
</form>
918 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
919 af4aa061 Scott Ullrich
</body>
920
</html>