Project

General

Profile

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