Project

General

Profile

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