Project

General

Profile

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