Project

General

Profile

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