Project

General

Profile

Download (31.4 KB) Statistics
| Branch: | Tag: | Revision:
1 b2ffe419 Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3 37e2071c Scott Ullrich
	firewall_rules.php
4 5b237745 Scott Ullrich
*/
5 fd9ebcd5 Stephen Beaver
/* ====================================================================
6 6cb366de Stephen Beaver
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7 9da2cf1c Stephen Beaver
 *
8 cb41dd63 Renato Botelho
 *	Some or all of this file is based on the m0n0wall project which is
9
 *	Copyright (c)  2004 Manuel Kasper (BSD 2 clause)
10 fd9ebcd5 Stephen Beaver
 *
11 6cb366de Stephen Beaver
 *	Redistribution and use in source and binary forms, with or without modification,
12
 *	are permitted provided that the following conditions are met:
13 fd9ebcd5 Stephen Beaver
 *
14 6cb366de Stephen Beaver
 *	1. Redistributions of source code must retain the above copyright notice,
15
 *		this list of conditions and the following disclaimer.
16 fd9ebcd5 Stephen Beaver
 *
17 6cb366de Stephen Beaver
 *	2. Redistributions in binary form must reproduce the above copyright
18
 *		notice, this list of conditions and the following disclaimer in
19
 *		the documentation and/or other materials provided with the
20
 *		distribution.
21 fd9ebcd5 Stephen Beaver
 *
22 6cb366de Stephen Beaver
 *	3. All advertising materials mentioning features or use of this software
23
 *		must display the following acknowledgment:
24
 *		"This product includes software developed by the pfSense Project
25
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
26 fd9ebcd5 Stephen Beaver
 *
27 6cb366de Stephen Beaver
 *	4. The names "pfSense" and "pfSense Project" must not be used to
28
 *		 endorse or promote products derived from this software without
29
 *		 prior written permission. For written permission, please contact
30
 *		 coreteam@pfsense.org.
31 fd9ebcd5 Stephen Beaver
 *
32 6cb366de Stephen Beaver
 *	5. Products derived from this software may not be called "pfSense"
33
 *		nor may "pfSense" appear in their names without prior written
34
 *		permission of the Electric Sheep Fencing, LLC.
35 fd9ebcd5 Stephen Beaver
 *
36 6cb366de Stephen Beaver
 *	6. Redistributions of any form whatsoever must retain the following
37
 *		acknowledgment:
38 fd9ebcd5 Stephen Beaver
 *
39 6cb366de Stephen Beaver
 *	"This product includes software developed by the pfSense Project
40
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
41 919d91f9 Phil Davis
 *
42 6cb366de Stephen Beaver
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
43
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
46
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
54 fd9ebcd5 Stephen Beaver
 *
55 6cb366de Stephen Beaver
 *	====================================================================
56 fd9ebcd5 Stephen Beaver
 *
57
 */
58 5b237745 Scott Ullrich
59 6b07c15a Matthew Grooms
##|+PRIV
60
##|*IDENT=page-firewall-rules
61 5230f468 jim-p
##|*NAME=Firewall: Rules
62 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Firewall: Rules' page.
63
##|*MATCH=firewall_rules.php*
64
##|-PRIV
65
66 5b237745 Scott Ullrich
require("guiconfig.inc");
67 7a927e67 Scott Ullrich
require_once("functions.inc");
68
require_once("filter.inc");
69 179ab6b3 Luiz Otavio O Souza
require_once("ipsec.inc");
70 7a927e67 Scott Ullrich
require_once("shaper.inc");
71 5b237745 Scott Ullrich
72 6c07db48 Phil Davis
$pgtitle = array(gettext("Firewall"), gettext("Rules"));
73 b32dd0a6 jim-p
$shortcut_section = "firewall";
74 7a808e01 Carlos Eduardo Ramos
75 cc2cff0b Luiz Otavio O Souza
function get_pf_rules($rules, $tracker) {
76
77
	if ($rules == NULL || !is_array($rules))
78
		return (NULL);
79
80
	$arr = array();
81 227c1181 NOYB
	foreach ($rules as $rule) {
82
		if ($rule['tracker'] === $tracker) {
83
			$arr[] = $rule;
84
		}
85 cc2cff0b Luiz Otavio O Souza
	}
86
87
	if (count($arr) == 0)
88
		return (NULL);
89
90
	return ($arr);
91
}
92
93
function print_states($tracker) {
94
	global $rulescnt;
95
96
	$rulesid = "";
97
	$bytes = 0;
98
	$states = 0;
99
	$packets = 0;
100
	$evaluations = 0;
101
	$stcreations = 0;
102
	$rules = get_pf_rules($rulescnt, $tracker);
103 227c1181 NOYB
	if (is_array($rules)) {
104
		foreach ($rules as $rule) {
105
			$bytes += $rule['bytes'];
106
			$states += $rule['states'];
107
			$packets += $rule['packets'];
108
			$evaluations += $rule['evaluations'];
109
			$stcreations += $rule['state creations'];
110
			if (strlen($rulesid) > 0) {
111
				$rulesid .= ",";
112
			}
113
			$rulesid .= "{$rule['id']}";
114
		}
115 cc2cff0b Luiz Otavio O Souza
	}
116 227c1181 NOYB
117 cc2cff0b Luiz Otavio O Souza
	printf("<a href=\"diag_dump_states.php?ruleid=%s\" data-toggle=\"popover\" data-trigger=\"hover focus\" title=\"%s\" ",
118
	    $rulesid, gettext("States details"));
119
	printf("data-content=\"evaluations: %s<br>packets: %s<br>bytes: %s<br>states: %s<br>state creations: %s\" data-html=\"true\">",
120
	    format_number($evaluations), format_number($packets), format_bytes($bytes),
121
	    format_number($states), format_number($stcreations));
122
	printf("%d/%s</a><br>", format_number($states), format_bytes($bytes));
123
}
124
125 00c82782 Renato Botelho
function delete_nat_association($id) {
126
	global $config;
127
128 603d3c16 Phil Davis
	if (!$id || !is_array($config['nat']['rule'])) {
129 673d29c0 Renato Botelho
		return;
130 603d3c16 Phil Davis
	}
131 673d29c0 Renato Botelho
132 00c82782 Renato Botelho
	$a_nat = &$config['nat']['rule'];
133
134 603d3c16 Phil Davis
	foreach ($a_nat as &$natent) {
135
		if ($natent['associated-rule-id'] == $id) {
136 00c82782 Renato Botelho
			$natent['associated-rule-id'] = '';
137 603d3c16 Phil Davis
		}
138
	}
139 673d29c0 Renato Botelho
}
140
141 5b237745 Scott Ullrich
if (!is_array($config['filter']['rule'])) {
142
	$config['filter']['rule'] = array();
143
}
144 c821a6cd Stephen Beaver
145 5b237745 Scott Ullrich
filter_rules_sort();
146
$a_filter = &$config['filter']['rule'];
147
148 07bd3f83 Scott Ullrich
$if = $_GET['if'];
149 824329d2 Stephen Beaver
150 603d3c16 Phil Davis
if ($_POST['if']) {
151 07bd3f83 Scott Ullrich
	$if = $_POST['if'];
152 603d3c16 Phil Davis
}
153 b2ffe419 Scott Ullrich
154 cbe3ea96 Ermal Luçi
$ifdescs = get_configured_interface_with_descr();
155 07bd3f83 Scott Ullrich
156 90ba56ad Scott Ullrich
/* add group interfaces */
157 603d3c16 Phil Davis
if (is_array($config['ifgroups']['ifgroupentry'])) {
158
	foreach ($config['ifgroups']['ifgroupentry'] as $ifgen) {
159
		if (have_ruleint_access($ifgen['ifname'])) {
160 90ba56ad Scott Ullrich
			$iflist[$ifgen['ifname']] = $ifgen['ifname'];
161 603d3c16 Phil Davis
		}
162
	}
163
}
164 90ba56ad Scott Ullrich
165 603d3c16 Phil Davis
foreach ($ifdescs as $ifent => $ifdesc) {
166
	if (have_ruleint_access($ifent)) {
167 aef4dc74 Ermal Luçi
		$iflist[$ifent] = $ifdesc;
168 603d3c16 Phil Davis
	}
169
}
170 88bcd1d2 Scott Dale
171 603d3c16 Phil Davis
if ($config['l2tp']['mode'] == "server") {
172
	if (have_ruleint_access("l2tp")) {
173 d62e733b Phil Davis
		$iflist['l2tp'] = gettext("L2TP VPN");
174 603d3c16 Phil Davis
	}
175
}
176 617f8d25 Ermal Lu?i
177 b0899ee4 Ermal
if (is_array($config['pppoes']['pppoe'])) {
178 603d3c16 Phil Davis
	foreach ($config['pppoes']['pppoe'] as $pppoes) {
179
		if (($pppoes['mode'] == 'server') && have_ruleint_access("pppoe")) {
180 d62e733b Phil Davis
			$iflist['pppoe'] = gettext("PPPoE Server");
181 603d3c16 Phil Davis
		}
182
	}
183 b0899ee4 Ermal
}
184 0c554ff6 Scott Ullrich
185 88bcd1d2 Scott Dale
/* add ipsec interfaces */
186 67c2baf1 Phil Davis
if (ipsec_enabled() && have_ruleint_access("enc0")) {
187 d62e733b Phil Davis
	$iflist["enc0"] = gettext("IPsec");
188 67c2baf1 Phil Davis
}
189 07bd3f83 Scott Ullrich
190 bfb60ac8 Ermal Luçi
/* add openvpn/tun interfaces */
191 6c07db48 Phil Davis
if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) {
192 d62e733b Phil Davis
	$iflist["openvpn"] = gettext("OpenVPN");
193 603d3c16 Phil Davis
}
194 bfb60ac8 Ermal Luçi
195 92125c97 Ermal Luçi
if (!$if || !isset($iflist[$if])) {
196 603d3c16 Phil Davis
	if ("any" == $if) {
197 56dda8e0 Renato Botelho
		$if = "FloatingRules";
198 603d3c16 Phil Davis
	} else if ("FloatingRules" != $if) {
199
		if (isset($iflist['wan'])) {
200 0416d9a0 Darren Embry
			$if = "wan";
201 603d3c16 Phil Davis
		} else {
202 0416d9a0 Darren Embry
			$if = "FloatingRules";
203 603d3c16 Phil Davis
		}
204 0416d9a0 Darren Embry
	}
205 92125c97 Ermal Luçi
}
206 07bd3f83 Scott Ullrich
207 5b237745 Scott Ullrich
if ($_POST) {
208
	$pconfig = $_POST;
209
210
	if ($_POST['apply']) {
211 37e2071c Scott Ullrich
		$retval = 0;
212 9a7e416c Scott Ullrich
		$retval = filter_configure();
213
214 a368a026 Ermal Lu?i
		clear_subsystem_dirty('filter');
215 a985eac2 Scott Ullrich
216 8545adde k-paulius
		$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."),
217 824329d2 Stephen Beaver
									"<a href='status_filter_reload.php'>", "</a>");
218 5b237745 Scott Ullrich
	}
219
}
220
221 d97c50cd Bill Marquette
if ($_GET['act'] == "del") {
222 673d29c0 Renato Botelho
	if ($a_filter[$_GET['id']]) {
223
		if (!empty($a_filter[$_GET['id']]['associated-rule-id'])) {
224 00c82782 Renato Botelho
			delete_nat_association($a_filter[$_GET['id']]['associated-rule-id']);
225 673d29c0 Renato Botelho
		}
226
		unset($a_filter[$_GET['id']]);
227 a4eef0c7 Stephen Beaver
228
		// Update the separators
229 e1e1ab07 Stephen Beaver
		$a_separators = &$config['filter']['separator'][strtolower($if)];
230 a4f41878 NOYB
		$ridx = ifridx($if, $_GET['id']);	// get rule index within interface
231
		$mvnrows = -1;
232
		move_separators($a_separators, $ridx, $mvnrows);
233 a4eef0c7 Stephen Beaver
234 603d3c16 Phil Davis
		if (write_config()) {
235 bec92ab9 jim-p
			mark_subsystem_dirty('filter');
236 603d3c16 Phil Davis
		}
237 6cb366de Stephen Beaver
238 e653b6e1 jim-p
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
239 673d29c0 Renato Botelho
		exit;
240
	}
241 d97c50cd Bill Marquette
}
242
243 32c58070 Scott Ullrich
// Handle save msg if defined
244 603d3c16 Phil Davis
if ($_REQUEST['savemsg']) {
245 32c58070 Scott Ullrich
	$savemsg = htmlentities($_REQUEST['savemsg']);
246 603d3c16 Phil Davis
}
247 32c58070 Scott Ullrich
248 6cb366de Stephen Beaver
if (isset($_POST['del_x'])) {
249
	/* delete selected rules */
250
	$deleted = false;
251
252
	if (is_array($_POST['rule']) && count($_POST['rule'])) {
253 e1e1ab07 Stephen Beaver
		$a_separators = &$config['filter']['separator'][strtolower($if)];
254 a4eef0c7 Stephen Beaver
255 6cb366de Stephen Beaver
		foreach ($_POST['rule'] as $rulei) {
256
			delete_nat_association($a_filter[$rulei]['associated-rule-id']);
257
			unset($a_filter[$rulei]);
258
			$deleted = true;
259 a4eef0c7 Stephen Beaver
260
			// Update the separators
261 a4f41878 NOYB
			$ridx = ifridx($if, $rulei);	// get rule index within interface
262
			$mvnrows = -1;
263
			move_separators($a_separators, $ridx, $mvnrows);
264 6cb366de Stephen Beaver
		}
265
266 67c2baf1 Phil Davis
		if ($deleted) {
267 6cb366de Stephen Beaver
			if (write_config()) {
268
				mark_subsystem_dirty('filter');
269
			}
270
		}
271
272
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
273
		exit;
274
	}
275
} else if ($_GET['act'] == "toggle") {
276 07bd3f83 Scott Ullrich
	if ($a_filter[$_GET['id']]) {
277 603d3c16 Phil Davis
		if (isset($a_filter[$_GET['id']]['disabled'])) {
278 56dda8e0 Renato Botelho
			unset($a_filter[$_GET['id']]['disabled']);
279 603d3c16 Phil Davis
		} else {
280 56dda8e0 Renato Botelho
			$a_filter[$_GET['id']]['disabled'] = true;
281 603d3c16 Phil Davis
		}
282
		if (write_config()) {
283 bec92ab9 jim-p
			mark_subsystem_dirty('filter');
284 603d3c16 Phil Davis
		}
285 6cb366de Stephen Beaver
286 e653b6e1 jim-p
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
287 5b237745 Scott Ullrich
		exit;
288
	}
289 67c2baf1 Phil Davis
} else if ($_POST['order-store']) {
290 7d8552fc Stephen Beaver
291 ea5665c7 Sjon Hortensius
	/* update rule order, POST[rule] is an array of ordered IDs */
292
	if (is_array($_POST['rule']) && !empty($_POST['rule'])) {
293 07bd3f83 Scott Ullrich
		$a_filter_new = array();
294 b2ffe419 Scott Ullrich
295 acd05d2b NOYB
		// Include the rules of other interfaces listed in config before this (the selected) interface.
296
		foreach ($a_filter as $filteri_before => $filterent) {
297
			if (($filterent['interface'] == $if && !isset($filterent['floating'])) || (isset($filterent['floating']) && "FloatingRules" == $if)) {
298
				break;
299
			} else {
300
				$a_filter_new[] = $filterent;
301
			}
302 fdb83ce0 NOYB
		}
303
304 acd05d2b NOYB
		// Include the rules of this (the selected) interface.
305
		// If a rule is not in POST[rule], it has been deleted by the user
306 67c2baf1 Phil Davis
		foreach ($_POST['rule'] as $id) {
307 ea5665c7 Sjon Hortensius
			$a_filter_new[] = $a_filter[$id];
308 67c2baf1 Phil Davis
		}
309 b2ffe419 Scott Ullrich
310 acd05d2b NOYB
		// Include the rules of other interfaces listed in config after this (the selected) interface.
311
		foreach ($a_filter as $filteri_after => $filterent) {
312
			if ($filteri_before > $filteri_after) {
313
				continue;
314
			}
315
			if (($filterent['interface'] == $if && !isset($filterent['floating'])) || (isset($filterent['floating']) && "FloatingRules" == $if)) {
316
				continue;
317
			} else {
318
				$a_filter_new[] = $filterent;
319 fdb83ce0 NOYB
			}
320
		}
321
322 07bd3f83 Scott Ullrich
		$a_filter = $a_filter_new;
323 c64c9278 Stephen Beaver
324 a361a19b Stephen Beaver
		$config['filter']['separator'][strtolower($if)] = "";
325 c64c9278 Stephen Beaver
326
		if ($_POST['separator']) {
327
			$idx = 0;
328
			foreach ($_POST['separator'] as $separator) {
329 a361a19b Stephen Beaver
				$config['filter']['separator'][strtolower($separator['if'])]['sep' . $idx++] = $separator;
330 c64c9278 Stephen Beaver
			}
331
		}
332
333 603d3c16 Phil Davis
		if (write_config()) {
334 bec92ab9 jim-p
			mark_subsystem_dirty('filter');
335 603d3c16 Phil Davis
		}
336 6cb366de Stephen Beaver
337 e653b6e1 jim-p
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
338 5b237745 Scott Ullrich
		exit;
339
	}
340
}
341
342 df95836a Stephen Beaver
$tab_array = array(array(gettext("Floating"), ("FloatingRules" == $if), "firewall_rules.php?if=FloatingRules"));
343
344 67c2baf1 Phil Davis
foreach ($iflist as $ifent => $ifname) {
345 df95836a Stephen Beaver
	$tab_array[] = array($ifname, ($ifent == $if), "firewall_rules.php?if={$ifent}");
346 67c2baf1 Phil Davis
}
347 df95836a Stephen Beaver
348
foreach ($tab_array as $dtab) {
349 67c2baf1 Phil Davis
	if ($dtab[1]) {
350 df95836a Stephen Beaver
		$bctab = $dtab[0];
351
		break;
352
	}
353
}
354
355
$pgtitle = array(gettext("Firewall"), gettext("Rules"), $bctab);
356
$shortcut_section = "firewall";
357
358 9a25487b Scott Ullrich
include("head.inc");
359 3b2c83b8 Sjon Hortensius
$nrules = 0;
360
361 67c2baf1 Phil Davis
if ($savemsg) {
362 42a6bcbd Stephen Beaver
	print_info_box($savemsg, 'success');
363 67c2baf1 Phil Davis
}
364 42a6bcbd Stephen Beaver
365 67c2baf1 Phil Davis
if (is_subsystem_dirty('filter')) {
366 3b3a95e5 Phil Davis
	print_apply_box(gettext("The firewall rule configuration has been changed.") . "<br />" . gettext("You must apply the changes in order for them to take effect."));
367 67c2baf1 Phil Davis
}
368 3b2c83b8 Sjon Hortensius
369
display_top_tabs($tab_array);
370 ea5665c7 Sjon Hortensius
371 a2c5280d Stephen Beaver
$showantilockout = false;
372
$showprivate = false;
373
$showblockbogons = false;
374
375
if (!isset($config['system']['webgui']['noantilockout']) &&
376
    (((count($config['interfaces']) > 1) && ($if == 'lan')) ||
377
    ((count($config['interfaces']) == 1) && ($if == 'wan')))) {
378
	$showantilockout = true;
379
}
380
381
if (isset($config['interfaces'][$if]['blockpriv'])) {
382
	$showprivate = true;
383
}
384
385
if (isset($config['interfaces'][$if]['blockbogons'])) {
386
	$showblockbogons = true;
387
}
388
389 cc2cff0b Luiz Otavio O Souza
/* Load the counter data of each pf rule. */
390
$rulescnt = pfSense_get_pf_rules();
391 b13a8425 Stephen Beaver
392 c54a42ea Renato Botelho
// Update this if you add or remove columns!
393 10ae204f Stephen Beaver
$columns_in_table = 13;
394
395 cc2cff0b Luiz Otavio O Souza
?>
396 c821a6cd Stephen Beaver
<form method="post">
397
	<div class="panel panel-default">
398 3d7a8696 k-paulius
		<div class="panel-heading"><h2 class="panel-title"><?=gettext("Rules (Drag to Change Order)")?></h2></div>
399 c821a6cd Stephen Beaver
		<div id="mainarea" class="table-responsive panel-body">
400 576437f5 Stephen Beaver
			<table id="ruletable" class="table table-hover table-striped table-condensed">
401 c821a6cd Stephen Beaver
				<thead>
402
					<tr>
403 6cb366de Stephen Beaver
						<th><!-- checkbox --></th>
404 c821a6cd Stephen Beaver
						<th><!-- status icons --></th>
405 cc2cff0b Luiz Otavio O Souza
						<th><?=gettext("States")?></th>
406 66c62a1a NewEraCracker
						<th><?=gettext("Protocol")?></th>
407 f25dac2d Stephen Beaver
						<th><?=gettext("Source")?></th>
408
						<th><?=gettext("Port")?></th>
409
						<th><?=gettext("Destination")?></th>
410
						<th><?=gettext("Port")?></th>
411
						<th><?=gettext("Gateway")?></th>
412
						<th><?=gettext("Queue")?></th>
413
						<th><?=gettext("Schedule")?></th>
414
						<th><?=gettext("Description")?></th>
415
						<th><?=gettext("Actions")?></th>
416 c821a6cd Stephen Beaver
					</tr>
417
				</thead>
418 a2c5280d Stephen Beaver
419
<?php if ($showblockbogons || $showantilockout || $showprivate) :
420
?>
421 c821a6cd Stephen Beaver
				<tbody>
422 3b2c83b8 Sjon Hortensius
<?php
423 ea5665c7 Sjon Hortensius
		// 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.
424 a2c5280d Stephen Beaver
		if ($showantilockout):
425
			$alports = implode('<br />', filter_get_antilockout_ports(true));
426 3b2c83b8 Sjon Hortensius
?>
427 b54ae90f Jared Dillard
					<tr id="antilockout">
428 6cb366de Stephen Beaver
						<td></td>
429 29620ab5 Jared Dillard
						<td title="<?=gettext("traffic is passed")?>"><i class="fa fa-check text-success"></i></td>
430 2af731f8 NewEraCracker
						<td><?php print_states(intval(ANTILOCKOUT_TRACKER)); ?></td>
431 c821a6cd Stephen Beaver
						<td>*</td>
432
						<td>*</td>
433
						<td>*</td>
434
						<td><?=$iflist[$if];?> Address</td>
435
						<td><?=$alports?></td>
436
						<td>*</td>
437
						<td>*</td>
438
						<td></td>
439 b54ae90f Jared Dillard
						<td><?=gettext("Anti-Lockout Rule");?></td>
440 c821a6cd Stephen Beaver
						<td>
441 45e849c1 Jared Dillard
							<a href="system_advanced_admin.php" title="<?=gettext("Settings");?>"><i class="fa fa-cog"></i></a>
442 c821a6cd Stephen Beaver
						</td>
443
					</tr>
444 a2c5280d Stephen Beaver
<?php 	endif;?>
445
<?php 	if ($showprivate): ?>
446 b54ae90f Jared Dillard
					<tr id="frrfc1918">
447 6cb366de Stephen Beaver
						<td></td>
448 29620ab5 Jared Dillard
						<td title="<?=gettext("traffic is blocked")?>"><i class="fa fa-times text-danger"></i></td>
449 2af731f8 NewEraCracker
						<td><?php print_states(intval(RFC1918_TRACKER)); ?></td>
450 c821a6cd Stephen Beaver
						<td>*</td>
451
						<td><?=gettext("RFC 1918 networks");?></td>
452
						<td>*</td>
453
						<td>*</td>
454
						<td>*</td>
455
						<td>*</td>
456
						<td>*</td>
457
						<td></td>
458 b54ae90f Jared Dillard
						<td><?=gettext("Block private networks");?></td>
459 c821a6cd Stephen Beaver
						<td>
460 45e849c1 Jared Dillard
							<a href="interfaces.php?if=<?=htmlspecialchars($if)?>" title="<?=gettext("Settings");?>"><i class="fa fa-cog"></i></a>
461 c821a6cd Stephen Beaver
						</td>
462
					</tr>
463 a2c5280d Stephen Beaver
<?php 	endif;?>
464
<?php 	if ($showblockbogons): ?>
465 b54ae90f Jared Dillard
					<tr id="frrfc1918">
466 0c61e497 Stephen Beaver
						<td></td>
467 29620ab5 Jared Dillard
						<td title="<?=gettext("traffic is blocked")?>"><i class="fa fa-times text-danger"></i></td>
468 2af731f8 NewEraCracker
						<td><?php print_states(intval(BOGONS_TRACKER)); ?></td>
469 c821a6cd Stephen Beaver
						<td>*</td>
470 0c61e497 Stephen Beaver
						<td><?=sprintf(gettext("Reserved%sNot assigned by IANA"), "<br />");?></td>
471 c821a6cd Stephen Beaver
						<td>*</td>
472
						<td>*</td>
473
						<td>*</td>
474
						<td>*</td>
475
						<td>*</td>
476 ea548271 Phil Davis
						<td></td>
477 b54ae90f Jared Dillard
						<td><?=gettext("Block bogon networks");?></td>
478 c821a6cd Stephen Beaver
						<td>
479 45e849c1 Jared Dillard
							<a href="interfaces.php?if=<?=htmlspecialchars($if)?>" title="<?=gettext("Settings");?>"><i class="fa fa-cog"></i></a>
480 c821a6cd Stephen Beaver
						</td>
481
					</tr>
482 a2c5280d Stephen Beaver
<?php 	endif;?>
483 c821a6cd Stephen Beaver
			</tbody>
484 a2c5280d Stephen Beaver
<?php endif;?>
485 c821a6cd Stephen Beaver
			<tbody class="user-entries">
486 6cb366de Stephen Beaver
<?php
487
$nrules = 0;
488 ccc62f13 NOYB
$separators = $config['filter']['separator'][strtolower($if)];
489 a361a19b Stephen Beaver
490 36bf13fd NOYB
// Get a list of separator rows and use it to call the display separator function only for rows which there are separator(s).
491
// More efficient than looping through the list of separators on every row.
492
$seprows = separator_rows($separators);
493 a361a19b Stephen Beaver
494 227c1181 NOYB
foreach ($a_filter as $filteri => $filterent):
495
496 fdb83ce0 NOYB
	if (($filterent['interface'] == $if && !isset($filterent['floating'])) || (isset($filterent['floating']) && "FloatingRules" == $if)) {
497 36bf13fd NOYB
498
		// Display separator(s) for section beginning at rule n
499
		if ($seprows[$nrules]) {
500
			display_separator($separators, $nrules, $columns_in_table);
501
		}
502 56dda8e0 Renato Botelho
?>
503 f2066870 NOYB
					<tr id="fr<?=$nrules;?>" onClick="fr_toggle(<?=$nrules;?>)" ondblclick="document.location='firewall_rules_edit.php?id=<?=$filteri;?>';" <?=(isset($filterent['disabled']) ? ' class="disabled"' : '')?>>
504 a42399ac Colin Fleming
						<td>
505 f2066870 NOYB
							<input type="checkbox" id="frc<?=$nrules;?>" onClick="fr_toggle(<?=$nrules;?>)" name="rule[]" value="<?=$filteri;?>"/>
506 6cb366de Stephen Beaver
						</td>
507
508 3b2c83b8 Sjon Hortensius
	<?php
509 d08aeac1 Phil Davis
		if ($filterent['type'] == "block") {
510 29620ab5 Jared Dillard
			$iconfn = "times text-danger";
511 d08aeac1 Phil Davis
			$title_text = gettext("traffic is blocked");
512
		} else if ($filterent['type'] == "reject") {
513 29620ab5 Jared Dillard
			$iconfn = "hand-stop-o text-warning";
514 d08aeac1 Phil Davis
			$title_text = gettext("traffic is rejected");
515
		} else if ($filterent['type'] == "match") {
516 3b2c83b8 Sjon Hortensius
			$iconfn = "filter";
517 d08aeac1 Phil Davis
			$title_text = gettext("traffic is matched");
518
		} else {
519 29620ab5 Jared Dillard
			$iconfn = "check text-success";
520 d08aeac1 Phil Davis
			$title_text = gettext("traffic is passed");
521
		}
522 3b2c83b8 Sjon Hortensius
	?>
523 d08aeac1 Phil Davis
						<td title="<?=$title_text?>">
524 f2066870 NOYB
							<a href="?if=<?=htmlspecialchars($if);?>&amp;act=toggle&amp;id=<?=$filteri;?>">
525 d4cb4cf3 Stephen Beaver
								<i class="fa fa-<?=$iconfn?>" title="<?=gettext("click to toggle enabled/disabled status");?>"></i>
526
							</a>
527 3b2c83b8 Sjon Hortensius
	<?php
528 e2461a2f Stephen Beaver
		if ($filterent['quick'] == 'yes') {
529 b04d849d Stephen Beaver
			print '<i class="fa fa-forward text-success" title="'. gettext("&quot;Quick&quot; rule. Applied immediately on match.") .'" style="cursor: pointer;"></i>';
530 e2461a2f Stephen Beaver
		}
531
532 3b2c83b8 Sjon Hortensius
		$isadvset = firewall_check_for_advanced_options($filterent);
533 67c2baf1 Phil Davis
		if ($isadvset) {
534 7ea65674 Jared Dillard
			print '<i class="fa fa-cog" title="'. gettext("advanced setting") .': '. $isadvset .'"></i>';
535 67c2baf1 Phil Davis
		}
536 3b2c83b8 Sjon Hortensius
537 67c2baf1 Phil Davis
		if (isset($filterent['log'])) {
538 e2461a2f Stephen Beaver
			print '<i class="fa fa-tasks" title="'. gettext("traffic is logged") .'" style="cursor: pointer;"></i>';
539 67c2baf1 Phil Davis
		}
540 3b2c83b8 Sjon Hortensius
	?>
541 d08aeac1 Phil Davis
						</td>
542 3b2c83b8 Sjon Hortensius
	<?php
543
		$alias = rule_columns_with_alias(
544
			$filterent['source']['address'],
545
			pprint_port($filterent['source']['port']),
546
			$filterent['destination']['address'],
547
			pprint_port($filterent['destination']['port'])
548
		);
549
550
		//build Schedule popup box
551
		$a_schedules = &$config['schedules']['schedule'];
552
		$schedule_span_begin = "";
553
		$schedule_span_end = "";
554
		$sched_caption_escaped = "";
555
		$sched_content = "";
556
		$schedstatus = false;
557 e6f34d22 Phil Davis
		$dayArray = array (gettext('Mon'), gettext('Tues'), gettext('Wed'), gettext('Thur'), gettext('Fri'), gettext('Sat'), gettext('Sun'));
558
		$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'));
559 ea5665c7 Sjon Hortensius
		if ($config['schedules']['schedule'] != "" && is_array($config['schedules']['schedule'])) {
560 bdfea2e7 Stephen Beaver
			$idx = 0;
561 67c2baf1 Phil Davis
			foreach ($a_schedules as $schedule) {
562 e6f34d22 Phil Davis
				if ($schedule['name'] == $filterent['sched']) {
563 3b2c83b8 Sjon Hortensius
					$schedstatus = filter_get_time_based_rule_status($schedule);
564
565 e6f34d22 Phil Davis
					foreach ($schedule['timerange'] as $timerange) {
566 3b2c83b8 Sjon Hortensius
						$tempFriendlyTime = "";
567
						$tempID = "";
568
						$firstprint = false;
569 e6f34d22 Phil Davis
						if ($timerange) {
570 3b2c83b8 Sjon Hortensius
							$dayFriendly = "";
571
							$tempFriendlyTime = "";
572
573
							//get hours
574
							$temptimerange = $timerange['hour'];
575
							$temptimeseparator = strrpos($temptimerange, "-");
576
577
							$starttime = substr ($temptimerange, 0, $temptimeseparator);
578
							$stoptime = substr ($temptimerange, $temptimeseparator+1);
579
580 e6f34d22 Phil Davis
							if ($timerange['month']) {
581 3b2c83b8 Sjon Hortensius
								$tempmontharray = explode(",", $timerange['month']);
582 e6f34d22 Phil Davis
								$tempdayarray = explode(",", $timerange['day']);
583 3b2c83b8 Sjon Hortensius
								$arraycounter = 0;
584
								$firstDayFound = false;
585
								$firstPrint = false;
586 e6f34d22 Phil Davis
								foreach ($tempmontharray as $monthtmp) {
587 3b2c83b8 Sjon Hortensius
									$month = $tempmontharray[$arraycounter];
588
									$day = $tempdayarray[$arraycounter];
589
590 67c2baf1 Phil Davis
									if (!$firstDayFound) {
591 3b2c83b8 Sjon Hortensius
										$firstDay = $day;
592
										$firstmonth = $month;
593
										$firstDayFound = true;
594
									}
595
596
									$currentDay = $day;
597
									$nextDay = $tempdayarray[$arraycounter+1];
598
									$currentDay++;
599 e6f34d22 Phil Davis
									if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])) {
600 67c2baf1 Phil Davis
										if ($firstPrint) {
601 3b2c83b8 Sjon Hortensius
											$dayFriendly .= ", ";
602 67c2baf1 Phil Davis
										}
603 3b2c83b8 Sjon Hortensius
										$currentDay--;
604 67c2baf1 Phil Davis
										if ($currentDay != $firstDay) {
605 3b2c83b8 Sjon Hortensius
											$dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ;
606 67c2baf1 Phil Davis
										} else {
607 c821a6cd Stephen Beaver
											$dayFriendly .=	 $monthArray[$month-1] . " " . $day;
608 67c2baf1 Phil Davis
										}
609 8ce97a08 Scott Dale
										$firstDayFound = false;
610 3b2c83b8 Sjon Hortensius
										$firstPrint = true;
611
									}
612
									$arraycounter++;
613
								}
614 67c2baf1 Phil Davis
							} else {
615 3b2c83b8 Sjon Hortensius
								$tempdayFriendly = $timerange['position'];
616
								$firstDayFound = false;
617
								$tempFriendlyDayArray = explode(",", $tempdayFriendly);
618
								$currentDay = "";
619
								$firstDay = "";
620
								$nextDay = "";
621
								$counter = 0;
622 e6f34d22 Phil Davis
								foreach ($tempFriendlyDayArray as $day) {
623
									if ($day != "") {
624 67c2baf1 Phil Davis
										if (!$firstDayFound) {
625 3b2c83b8 Sjon Hortensius
											$firstDay = $tempFriendlyDayArray[$counter];
626
											$firstDayFound = true;
627 8ce97a08 Scott Dale
										}
628 3b2c83b8 Sjon Hortensius
										$currentDay =$tempFriendlyDayArray[$counter];
629
										//get next day
630
										$nextDay = $tempFriendlyDayArray[$counter+1];
631
										$currentDay++;
632 e6f34d22 Phil Davis
										if ($currentDay != $nextDay) {
633 67c2baf1 Phil Davis
											if ($firstprint) {
634 3b2c83b8 Sjon Hortensius
												$dayFriendly .= ", ";
635 67c2baf1 Phil Davis
											}
636 3b2c83b8 Sjon Hortensius
											$currentDay--;
637 67c2baf1 Phil Davis
											if ($currentDay != $firstDay) {
638 3b2c83b8 Sjon Hortensius
												$dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
639 67c2baf1 Phil Davis
											} else {
640 3b2c83b8 Sjon Hortensius
												$dayFriendly .= $dayArray[$firstDay-1];
641 67c2baf1 Phil Davis
											}
642 3b2c83b8 Sjon Hortensius
											$firstDayFound = false;
643
											$firstprint = true;
644
										}
645
										$counter++;
646 56dda8e0 Renato Botelho
									}
647 8ce97a08 Scott Dale
								}
648 2a113ca9 Scott Dale
							}
649 3b2c83b8 Sjon Hortensius
							$timeFriendly = $starttime . " - " . $stoptime;
650
							$description = $timerange['rangedescr'];
651
							$sched_content .= $dayFriendly . "; " . $timeFriendly . "<br />";
652 56dda8e0 Renato Botelho
						}
653
					}
654 ea5665c7 Sjon Hortensius
					#FIXME
655 3b2c83b8 Sjon Hortensius
					$sched_caption_escaped = str_replace("'", "\'", $schedule['descr']);
656 bdfea2e7 Stephen Beaver
					$schedule_span_begin = '<a href="/firewall_schedule_edit.php?id=' . $idx . '" data-toggle="popover" data-trigger="hover focus" title="' . $schedule['name'] . '" data-content="' .
657 c64c9278 Stephen Beaver
						$sched_caption_escaped . '" data-html="true">';
658 a42399ac Colin Fleming
					$schedule_span_end = "</a>";
659 616dd997 Scott Dale
				}
660 3b2c83b8 Sjon Hortensius
			}
661 bdfea2e7 Stephen Beaver
			$idx++;
662 3b2c83b8 Sjon Hortensius
		}
663
		$printicon = false;
664
		$alttext = "";
665
		$image = "";
666
		if (!isset($filterent['disabled'])) {
667
			if ($schedstatus) {
668 5db29ca7 Phil Davis
				if ($filterent['type'] == "block" || $filterent['type'] == "reject") {
669 7ea65674 Jared Dillard
					$image = "times-circle";
670 bdfea2e7 Stephen Beaver
					$dispcolor = "text-danger";
671 3b2c83b8 Sjon Hortensius
					$alttext = gettext("Traffic matching this rule is currently being denied");
672 56dda8e0 Renato Botelho
				} else {
673 7ea65674 Jared Dillard
					$image = "play-circle";
674 bdfea2e7 Stephen Beaver
					$dispcolor = "text-success";
675 3b2c83b8 Sjon Hortensius
					$alttext = gettext("Traffic matching this rule is currently being allowed");
676 be81b340 Erik Fonnesbeck
				}
677 3b2c83b8 Sjon Hortensius
				$printicon = true;
678
			} else if ($filterent['sched']) {
679 5db29ca7 Phil Davis
				if ($filterent['type'] == "block" || $filterent['type'] == "reject") {
680 7ea65674 Jared Dillard
					$image = "times-circle";
681 67c2baf1 Phil Davis
				} else {
682 5db29ca7 Phil Davis
					$image = "play-circle";
683 67c2baf1 Phil Davis
				}
684 3b2c83b8 Sjon Hortensius
				$alttext = gettext("This rule is not currently active because its period has expired");
685 5db29ca7 Phil Davis
				$dispcolor = "text-warning";
686 3b2c83b8 Sjon Hortensius
				$printicon = true;
687
			}
688
		}
689
	?>
690 2af731f8 NewEraCracker
				<td><?php print_states(intval($filterent['tracker'])); ?></td>
691 ea5665c7 Sjon Hortensius
				<td>
692 3b2c83b8 Sjon Hortensius
	<?php
693
		if (isset($filterent['ipprotocol'])) {
694 e6f34d22 Phil Davis
			switch ($filterent['ipprotocol']) {
695 3b2c83b8 Sjon Hortensius
				case "inet":
696
					echo "IPv4 ";
697
					break;
698
				case "inet6":
699
					echo "IPv6 ";
700
					break;
701
				case "inet46":
702
					echo "IPv4+6 ";
703
					break;
704
			}
705
		} else {
706
			echo "IPv4 ";
707
		}
708
709
		if (isset($filterent['protocol'])) {
710
			echo strtoupper($filterent['protocol']);
711
712
			if (strtoupper($filterent['protocol']) == "ICMP" && !empty($filterent['icmptype'])) {
713 d62e733b Phil Davis
				echo ' <span style="cursor: help;" title="' . gettext('ICMP type') . ': ' .
714 e6f34d22 Phil Davis
					($filterent['ipprotocol'] == "inet6" ? $icmp6types[$filterent['icmptype']] : $icmptypes[$filterent['icmptype']]) .
715 3b2c83b8 Sjon Hortensius
					'"><u>';
716
				echo $filterent['icmptype'];
717
				echo '</u></span>';
718
			}
719
		} else echo "*";
720 e83aaa50 Stephen Beaver
721 3b2c83b8 Sjon Hortensius
	?>
722 c821a6cd Stephen Beaver
						</td>
723
						<td>
724
							<?php if (isset($alias['src'])): ?>
725 d62e733b Phil Davis
								<a href="/firewall_aliases_edit.php?id=<?=$alias['src']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['src'])?>" data-html="true">
726 a42399ac Colin Fleming
									<?=htmlspecialchars(pprint_address($filterent['source']))?>
727
								</a>
728
							<?php else: ?>
729
								<?=htmlspecialchars(pprint_address($filterent['source']))?>
730 c821a6cd Stephen Beaver
							<?php endif; ?>
731
						</td>
732
						<td>
733
							<?php if (isset($alias['srcport'])): ?>
734 d62e733b Phil Davis
								<a href="/firewall_aliases_edit.php?id=<?=$alias['srcport']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['srcport'])?>" data-html="true">
735 a42399ac Colin Fleming
									<?=htmlspecialchars(pprint_port($filterent['source']['port']))?>
736
								</a>
737
							<?php else: ?>
738
								<?=htmlspecialchars(pprint_port($filterent['source']['port']))?>
739 c821a6cd Stephen Beaver
							<?php endif; ?>
740
						</td>
741
						<td>
742
							<?php if (isset($alias['dst'])): ?>
743 d62e733b Phil Davis
								<a href="/firewall_aliases_edit.php?id=<?=$alias['dst']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['dst'])?>" data-html="true">
744 a42399ac Colin Fleming
									<?=htmlspecialchars(pprint_address($filterent['destination']))?>
745
								</a>
746 2af731f8 NewEraCracker
							<?php else: ?>
747 a42399ac Colin Fleming
								<?=htmlspecialchars(pprint_address($filterent['destination']))?>
748 c821a6cd Stephen Beaver
							<?php endif; ?>
749
						</td>
750
						<td>
751
							<?php if (isset($alias['dstport'])): ?>
752 d62e733b Phil Davis
								<a href="/firewall_aliases_edit.php?id=<?=$alias['dstport']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['dstport'])?>" data-html="true">
753 a42399ac Colin Fleming
									<?=htmlspecialchars(pprint_port($filterent['destination']['port']))?>
754
								</a>
755
							<?php else: ?>
756
								<?=htmlspecialchars(pprint_port($filterent['destination']['port']))?>
757 c821a6cd Stephen Beaver
							<?php endif; ?>
758
						</td>
759
						<td>
760
							<?php if (isset($config['interfaces'][$filterent['gateway']]['descr'])):?>
761
								<?=htmlspecialchars($config['interfaces'][$filterent['gateway']]['descr'])?>
762
							<?php else: ?>
763
								<?=htmlspecialchars(pprint_port($filterent['gateway']))?>
764
							<?php endif; ?>
765
						</td>
766
						<td>
767
							<?php
768
								if (isset($filterent['ackqueue']) && isset($filterent['defaultqueue'])) {
769
									$desc = $filterent['ackqueue'] ;
770
									echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['ackqueue']}&amp;action=show\">{$desc}</a>";
771
									$desc = $filterent['defaultqueue'];
772
									echo "/<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
773
								} else if (isset($filterent['defaultqueue'])) {
774
									$desc = $filterent['defaultqueue'];
775
									echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
776 67c2baf1 Phil Davis
								} else {
777 c821a6cd Stephen Beaver
									echo gettext("none");
778 67c2baf1 Phil Davis
								}
779 c821a6cd Stephen Beaver
							?>
780
						</td>
781
						<td>
782 995df6c3 Stephen Beaver
							<?php if ($printicon) { ?>
783 a42399ac Colin Fleming
								<i class="fa fa-<?=$image?> <?=$dispcolor?>" title="<?=$alttext;?>"></i>
784 995df6c3 Stephen Beaver
							<?php } ?>
785 c821a6cd Stephen Beaver
							<?=$schedule_span_begin;?><?=htmlspecialchars($filterent['sched']);?>&nbsp;<?=$schedule_span_end;?>
786
						</td>
787 b54ae90f Jared Dillard
						<td>
788 c821a6cd Stephen Beaver
							<?=htmlspecialchars($filterent['descr']);?>
789
						</td>
790 45e849c1 Jared Dillard
						<td class="action-icons">
791 f25dac2d Stephen Beaver
						<!-- <?=(isset($filterent['disabled']) ? 'enable' : 'disable')?> -->
792 f2066870 NOYB
							<a href="firewall_rules_edit.php?id=<?=$filteri;?>" class="fa fa-pencil" title="<?=gettext('Edit')?>"></a>
793
							<a href="firewall_rules_edit.php?dup=<?=$filteri;?>" class="fa fa-clone" title="<?=gettext('Copy')?>"></a>
794 f25dac2d Stephen Beaver
<?php if (isset($filterent['disabled'])) {
795
?>
796 f2066870 NOYB
							<a href="?act=toggle&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$filteri;?>" class="fa fa-check-square-o" title="<?=gettext('Enable')?>"></a>
797 f25dac2d Stephen Beaver
<?php } else {
798
?>
799 f2066870 NOYB
							<a href="?act=toggle&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$filteri;?>" class="fa fa-ban" title="<?=gettext('Disable')?>"></a>
800 f25dac2d Stephen Beaver
<?php }
801
?>
802 f2066870 NOYB
							<a href="?act=del&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$filteri;?>" class="fa fa-trash" title="<?=gettext('Delete this rule')?>"></a>
803 c821a6cd Stephen Beaver
						</td>
804
					</tr>
805
<?php
806 6cb366de Stephen Beaver
		$nrules++;
807 fdb83ce0 NOYB
	}
808 227c1181 NOYB
endforeach;
809 36bf13fd NOYB
810
// There can be separator(s) after the last rule listed.
811
if ($seprows[$nrules]) {
812
	display_separator($separators, $nrules, $columns_in_table);
813
}
814 c821a6cd Stephen Beaver
?>
815
				</tbody>
816
			</table>
817
		</div>
818
	</div>
819 3b2c83b8 Sjon Hortensius
820
<?php if ($nrules == 0): ?>
821
	<div class="alert alert-warning" role="alert">
822 06966500 Sander van Leeuwen
		<p>
823 3b2c83b8 Sjon Hortensius
		<?php if ($_REQUEST['if'] == "FloatingRules"): ?>
824
			<?=gettext("No floating rules are currently defined.");?>
825
		<?php else: ?>
826
			<?=gettext("No rules are currently defined for this interface");?><br />
827
			<?=gettext("All incoming connections on this interface will be blocked until you add pass rules.");?>
828
		<?php endif;?>
829 06966500 Sander van Leeuwen
			<?=gettext("Click the button to add a new rule.");?>
830
		</p>
831 3b2c83b8 Sjon Hortensius
	</div>
832
<?php endif;?>
833
834 c10cb196 Stephen Beaver
	<nav class="action-buttons">
835 270de3df Stephen Beaver
		<a href="firewall_rules_edit.php?if=<?=htmlspecialchars($if);?>&amp;after=-1" role="button" class="btn btn-sm btn-success" title="<?=gettext('Add rule to the top of the list')?>">
836
			<i class="fa fa-level-up icon-embed-btn"></i>
837 09415b9e Stephen Beaver
			<?=gettext("Add");?>
838 c821a6cd Stephen Beaver
		</a>
839 270de3df Stephen Beaver
		<a href="firewall_rules_edit.php?if=<?=htmlspecialchars($if);?>" role="button" class="btn btn-sm btn-success" title="<?=gettext('Add rule to the end of the list')?>">
840
			<i class="fa fa-level-down icon-embed-btn"></i>
841
			<?=gettext("Add");?>
842
		</a>
843
		<button name="del_x" type="submit" class="btn btn-danger btn-sm" value="<?=gettext("Delete selected rules"); ?>" title="<?=gettext('Delete selected rules')?>">
844 9d5a20cf heper
			<i class="fa fa-trash icon-embed-btn"></i>
845 09415b9e Stephen Beaver
			<?=gettext("Delete"); ?>
846
		</button>
847 c4b60a9a Colin Fleming
		<button type="submit" id="order-store" name="order-store" class="btn btn-sm btn-primary" value="store changes" disabled title="<?=gettext('Save rule order')?>">
848 9d5a20cf heper
			<i class="fa fa-save icon-embed-btn"></i>
849 09415b9e Stephen Beaver
			<?=gettext("Save")?>
850
		</button>
851 576437f5 Stephen Beaver
		<button type="submit" id="addsep" name="addsep" class="btn btn-sm btn-warning" title="<?=gettext('Add separator')?>">
852
			<i class="fa fa-plus icon-embed-btn"></i>
853
			<?=gettext("Separator")?>
854
		</button>
855 c821a6cd Stephen Beaver
	</nav>
856
</form>
857
858 35681930 Stephen Beaver
<div class="infoblock">
859 c97a3f34 Phil Davis
	<div class="alert alert-info clearfix" role="alert"><div class="pull-left">
860 270de3df Stephen Beaver
		<dl class="dl-horizontal responsive">
861
		<!-- Legend -->
862
			<dt><?=gettext('Legend')?></dt>				<dd></dd>
863 29620ab5 Jared Dillard
			<dt><i class="fa fa-check text-success"></i></dt>		<dd><?=gettext("Pass");?></dd>
864 1b7379f9 Jared Dillard
			<dt><i class="fa fa-filter"></i></dt>	<dd><?=gettext("Match");?></dd>
865 29620ab5 Jared Dillard
			<dt><i class="fa fa-times text-danger"></i></dt>	<dd><?=gettext("Block");?></dd>
866
			<dt><i class="fa fa-hand-stop-o text-warning"></i></dt>		<dd><?=gettext("Reject");?></dd>
867 1b7379f9 Jared Dillard
			<dt><i class="fa fa-tasks"></i></dt>	<dd> <?=gettext("Log");?></dd>
868 7ea65674 Jared Dillard
			<dt><i class="fa fa-cog"></i></dt>		<dd> <?=gettext("Advanced filter");?></dd>
869 cafd2aa0 Stephen Beaver
			<dt><i class="fa fa-forward text-success"></i></dt><dd> <?=gettext("&quot;Quick&quot; rule. Applied immediately on match.")?></dd>
870 270de3df Stephen Beaver
		</dl>
871
872 824329d2 Stephen Beaver
<?php
873 67c2baf1 Phil Davis
	if ("FloatingRules" != $if) {
874 270de3df Stephen Beaver
		print(gettext("Rules are evaluated on a first-match basis (i.e. " .
875 09415b9e Stephen Beaver
			"the action of the first rule to match a packet will be executed). ") . '<br />' .
876
			gettext("This means that if you use block rules, you'll have to pay attention " .
877
			"to the rule order. Everything that isn't explicitly passed is blocked " .
878 270de3df Stephen Beaver
			"by default. "));
879 67c2baf1 Phil Davis
	} else {
880 270de3df Stephen Beaver
		print(gettext("Floating rules are evaluated on a first-match basis (i.e. " .
881 09415b9e Stephen Beaver
			"the action of the first rule to match a packet will be executed) only " .
882 04fd7017 Stephen Beaver
			"if the 'quick' option is checked on a rule. Otherwise they will only match if no " .
883 09415b9e Stephen Beaver
			"other rules match. Pay close attention to the rule order and options " .
884 270de3df Stephen Beaver
			"chosen. If no rule here matches, the per-interface or default rules are used. "));
885 67c2baf1 Phil Davis
	}
886 824329d2 Stephen Beaver
?>
887 270de3df Stephen Beaver
	</div>
888 ab6b1f47 NOYB
	</div>
889 09415b9e Stephen Beaver
</div>
890 2f4323b5 Stephen Beaver
891 8fd9052f Colin Fleming
<script type="text/javascript">
892
//<![CDATA[
893 7d8552fc Stephen Beaver
894 2af731f8 NewEraCracker
//Need to create some variables here so that jquery/pfSenseHelpers.js can read them
895 7d8552fc Stephen Beaver
iface = "<?=strtolower($if)?>";
896
cncltxt = '<?=gettext("Cancel")?>';
897
svtxt = '<?=gettext("Save")?>';
898
svbtnplaceholder = '<?=gettext("Enter a description, Save, then drag to final location.")?>';
899
configsection = "filter";
900
901 ea5665c7 Sjon Hortensius
events.push(function() {
902 2f4323b5 Stephen Beaver
903 85d49326 Stephen Beaver
	// Make rules sortable. Hiding the table before applying sortable, then showing it again is
904 511053ad Stephen Beaver
	// a work-around for very slow sorting on FireFox
905
	$('table tbody.user-entries').hide();
906
907 ea5665c7 Sjon Hortensius
	$('table tbody.user-entries').sortable({
908
		cursor: 'grabbing',
909
		update: function(event, ui) {
910
			$('#order-store').removeAttr('disabled');
911 1f73ccba Stephen Beaver
			reindex_rules(ui.item.parent('tbody'));
912 5d7b915d Stephen Beaver
			dirty = true;
913 ea5665c7 Sjon Hortensius
		}
914
	});
915
916 511053ad Stephen Beaver
	$('table tbody.user-entries').show();
917
918 6cb366de Stephen Beaver
	// Check all of the rule checkboxes so that their values are posted
919
	$('#order-store').click(function () {
920 301e4aa0 Stephen Beaver
		$('[id^=frc]').prop('checked', true);
921
922
		// Save the separator bar configuration
923
		save_separators();
924 5d7b915d Stephen Beaver
925
		// Suppress the "Do you really want to leave the page" message
926
		saving = true;
927 6cb366de Stephen Beaver
	});
928 576437f5 Stephen Beaver
929 2794ddb4 Stephen Beaver
	// provide a warning message if the user tries to change page before saving
930 5d7b915d Stephen Beaver
	$(window).bind('beforeunload', function(){
931
		if ((!saving && dirty) || newSeperator) {
932 fd4c4bb0 Stephen Beaver
			return ("<?=gettext('You have moved one or more rules but have not yet saved')?>");
933 5d7b915d Stephen Beaver
		} else {
934
			return undefined;
935
		}
936
	});
937
938 65a0e193 Stephen Beaver
});
939 8fd9052f Colin Fleming
//]]>
940 ea5665c7 Sjon Hortensius
</script>
941 824329d2 Stephen Beaver
942 c9d46a8e Renato Botelho
<?php include("foot.inc");?>