Project

General

Profile

Download (45 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 38809d47 Renato Botelho do Couto
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8 a68f7a3d Luiz Otavio O Souza
 * Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
9 c5d81585 Renato Botelho
 * All rights reserved.
10 fd9ebcd5 Stephen Beaver
 *
11 c5d81585 Renato Botelho
 * originally based on m0n0wall (http://m0n0.ch/wall)
12
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
13
 * All rights reserved.
14 fd9ebcd5 Stephen Beaver
 *
15 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
16
 * you may not use this file except in compliance with the License.
17
 * You may obtain a copy of the License at
18 fd9ebcd5 Stephen Beaver
 *
19 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
20 fd9ebcd5 Stephen Beaver
 *
21 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
22
 * distributed under the License is distributed on an "AS IS" BASIS,
23
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
 * See the License for the specific language governing permissions and
25
 * limitations under the License.
26 fd9ebcd5 Stephen Beaver
 */
27 5b237745 Scott Ullrich
28 6b07c15a Matthew Grooms
##|+PRIV
29
##|*IDENT=page-firewall-rules
30 5230f468 jim-p
##|*NAME=Firewall: Rules
31 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Firewall: Rules' page.
32
##|*MATCH=firewall_rules.php*
33
##|-PRIV
34
35 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
36 7a927e67 Scott Ullrich
require_once("functions.inc");
37
require_once("filter.inc");
38 179ab6b3 Luiz Otavio O Souza
require_once("ipsec.inc");
39 7a927e67 Scott Ullrich
require_once("shaper.inc");
40 5b237745 Scott Ullrich
41 a7893b72 Stephen Beaver
$XmoveTitle = gettext("Move checked rules above this one. Shift+Click to move checked rules below.");
42
$ShXmoveTitle = gettext("Move checked rules below this one. Release shift to move checked rules above.");
43 d830a7f4 Stephen Beaver
44 b32dd0a6 jim-p
$shortcut_section = "firewall";
45 7a808e01 Carlos Eduardo Ramos
46 e729ecf8 Marcos Mendoza
$filter_srcdsttype_flags = [
47
	SPECIALNET_ANY, SPECIALNET_COMPAT_ADDRAL, SPECIALNET_NET, SPECIALNET_SELF,
48
	SPECIALNET_CLIENTS, SPECIALNET_IFADDR, SPECIALNET_IFNET, SPECIALNET_GROUP
49
];
50
51 1574802c Renato Botelho do Couto
function get_pf_rules($rules, $tracker_start, $tracker_end) {
52 cc2cff0b Luiz Otavio O Souza
53 1574802c Renato Botelho do Couto
	if ($rules == NULL || !is_array($rules)) {
54 cc2cff0b Luiz Otavio O Souza
		return (NULL);
55 1574802c Renato Botelho do Couto
	}
56 cc2cff0b Luiz Otavio O Souza
57
	$arr = array();
58 483512b3 Reid Linnemann
	foreach ($rules as $key => $rule) {
59
		/* key 'error' indicates a call to pfctl_get_rule() returned
60
		 * nonzero. We may have a partial list of rules if that is the case */
61
		if ($key != 'error' &&
62
			$rule['tracker'] >= $tracker_start &&
63 1574802c Renato Botelho do Couto
		    $rule['tracker'] <= $tracker_end) {
64 227c1181 NOYB
			$arr[] = $rule;
65
		}
66 cc2cff0b Luiz Otavio O Souza
	}
67
68
	if (count($arr) == 0)
69
		return (NULL);
70
71
	return ($arr);
72
}
73
74 1574802c Renato Botelho do Couto
function print_states($tracker_start, $tracker_end = -1) {
75 cc2cff0b Luiz Otavio O Souza
	global $rulescnt;
76
77 1574802c Renato Botelho do Couto
	if (empty($tracker_start)) {
78
		return;
79
	}
80
81
	if ($tracker_end === -1) {
82
		$tracker_end = $tracker_start;
83
	} elseif ($tracker_end < $tracker_start) {
84
		return;
85
	}
86
87 cc2cff0b Luiz Otavio O Souza
	$rulesid = "";
88
	$bytes = 0;
89
	$states = 0;
90
	$packets = 0;
91
	$evaluations = 0;
92
	$stcreations = 0;
93 1574802c Renato Botelho do Couto
	$rules = get_pf_rules($rulescnt, $tracker_start, $tracker_end);
94 227c1181 NOYB
	if (is_array($rules)) {
95
		foreach ($rules as $rule) {
96
			$bytes += $rule['bytes'];
97
			$states += $rule['states'];
98
			$packets += $rule['packets'];
99
			$evaluations += $rule['evaluations'];
100
			$stcreations += $rule['state creations'];
101
			if (strlen($rulesid) > 0) {
102
				$rulesid .= ",";
103
			}
104
			$rulesid .= "{$rule['id']}";
105
		}
106 cc2cff0b Luiz Otavio O Souza
	}
107 227c1181 NOYB
108 1574802c Renato Botelho do Couto
	$trackertext = "Tracking ID: {$tracker_start}";
109
	if ($tracker_end != $tracker_start) {
110
		$trackertext .= '-' . $tracker_end;
111
	}
112
	$trackertext .= "<br />";
113
114
	printf("<a href=\"diag_dump_states.php?ruleid=%s\" " .
115
	    "data-toggle=\"popover\" data-trigger=\"hover focus\" " .
116
	    "title=\"%s\" ", $rulesid, gettext("States details"));
117
	printf("data-content=\"{$trackertext}evaluations: %s<br />packets: " .
118
	    "%s<br />bytes: %s<br />states: %s<br />state creations: " .
119
	    "%s\" data-html=\"true\" usepost>",
120
	    format_number($evaluations), format_number($packets),
121
	    format_bytes($bytes), format_number($states),
122
	    format_number($stcreations));
123
	printf("%s/%s</a><br />", format_number($states), format_bytes($bytes));
124 cc2cff0b Luiz Otavio O Souza
}
125
126 00c82782 Renato Botelho
function delete_nat_association($id) {
127
	global $config;
128
129 603d3c16 Phil Davis
	if (!$id || !is_array($config['nat']['rule'])) {
130 673d29c0 Renato Botelho
		return;
131 603d3c16 Phil Davis
	}
132 673d29c0 Renato Botelho
133 00c82782 Renato Botelho
	$a_nat = &$config['nat']['rule'];
134
135 603d3c16 Phil Davis
	foreach ($a_nat as &$natent) {
136
		if ($natent['associated-rule-id'] == $id) {
137 00c82782 Renato Botelho
			$natent['associated-rule-id'] = '';
138 603d3c16 Phil Davis
		}
139
	}
140 673d29c0 Renato Botelho
}
141
142 c6c398c6 jim-p
init_config_arr(array('filter', 'rule'));
143 5b237745 Scott Ullrich
filter_rules_sort();
144
$a_filter = &$config['filter']['rule'];
145
146 84147b7b Steve Beaver
if ($_REQUEST['if']) {
147
	$if = $_REQUEST['if'];
148 603d3c16 Phil Davis
}
149 b2ffe419 Scott Ullrich
150 cbe3ea96 Ermal Luçi
$ifdescs = get_configured_interface_with_descr();
151 07bd3f83 Scott Ullrich
152 c64c8773 jim-p
$iflist = filter_get_interface_list();
153 bfb60ac8 Ermal Luçi
154 92125c97 Ermal Luçi
if (!$if || !isset($iflist[$if])) {
155 b9b25969 Christian McDonald
	if ($if != 'any' &&
156
	    $if != 'EthernetRules' &&
157 c4518538 jim-p
	    $if != 'FloatingRules' &&
158
	    !config_path_enabled('system/webgui', 'requirefirewallinterface')) {
159 b9b25969 Christian McDonald
		/* default to the first configured interface */
160
		$if = array_key_first($ifdescs);
161 0416d9a0 Darren Embry
	}
162 92125c97 Ermal Luçi
}
163 07bd3f83 Scott Ullrich
164 e3947e77 Steve Beaver
if ($_POST['apply']) {
165 373fdb53 Steve Beaver
	$retval = 0;
166
	$retval |= filter_configure();
167
168
	clear_subsystem_dirty('filter');
169 5b237745 Scott Ullrich
}
170
171 e3947e77 Steve Beaver
if ($_POST['act'] == "del") {
172 373fdb53 Steve Beaver
	if ($a_filter[$_POST['id']]) {
173 9602c76c Marcos Mendoza
		// separators must be updated before the rule is removed
174 abc8192b Marcos Mendoza
		$ridx = get_interface_ruleindex($if, $_POST['id']);
175
		$a_separators = config_get_path('filter/separator/' . strtolower($if), []);
176
		shift_separators($a_separators, $ridx['index'], true);
177
		config_set_path('filter/separator/' . strtolower($if), $a_separators);
178 373fdb53 Steve Beaver
179 9602c76c Marcos Mendoza
		// remove the rule
180
		if (!empty($a_filter[$_POST['id']]['associated-rule-id'])) {
181
			delete_nat_association($a_filter[$_POST['id']]['associated-rule-id']);
182
		}
183
		unset($a_filter[$_POST['id']]);
184
185 373fdb53 Steve Beaver
		if (write_config(gettext("Firewall: Rules - deleted a firewall rule."))) {
186
			mark_subsystem_dirty('filter');
187
		}
188
189
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
190
		exit;
191
	}
192 d97c50cd Bill Marquette
}
193
194 c5d0d75d Jim Pingle
if (($_POST['act'] == 'killid') &&
195
    (!empty($_POST['tracker'])) &&
196
    (!empty($if))) {
197
	mwexec("/sbin/pfctl -k label -k " . escapeshellarg("id:{$_POST['tracker']}"));
198
	header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
199
	exit;
200
}
201
202 32c58070 Scott Ullrich
// Handle save msg if defined
203 603d3c16 Phil Davis
if ($_REQUEST['savemsg']) {
204 32c58070 Scott Ullrich
	$savemsg = htmlentities($_REQUEST['savemsg']);
205 603d3c16 Phil Davis
}
206 32c58070 Scott Ullrich
207 6cb366de Stephen Beaver
if (isset($_POST['del_x'])) {
208 373fdb53 Steve Beaver
	if (is_array($_POST['rule']) && count($_POST['rule'])) {
209 abc8192b Marcos Mendoza
		$removed = false;
210
		$a_separators = config_get_path('filter/separator/' . strtolower($if), []);
211 373fdb53 Steve Beaver
		foreach ($_POST['rule'] as $rulei) {
212 abc8192b Marcos Mendoza
			// separators must be updated before the rule is removed
213
			$ridx = get_interface_ruleindex($if, $rulei);
214
			shift_separators($a_separators, $ridx['index'], true);
215
216
			// remove the rule
217 373fdb53 Steve Beaver
			delete_nat_association($a_filter[$rulei]['associated-rule-id']);
218
			unset($a_filter[$rulei]);
219 abc8192b Marcos Mendoza
			$removed = true;
220 373fdb53 Steve Beaver
		}
221 abc8192b Marcos Mendoza
		config_set_path('filter/separator/' . strtolower($if), $a_separators);
222 373fdb53 Steve Beaver
223 abc8192b Marcos Mendoza
		if ($removed) {
224 373fdb53 Steve Beaver
			if (write_config(gettext("Firewall: Rules - deleted selected firewall rules."))) {
225
				mark_subsystem_dirty('filter');
226
			}
227
		}
228
229 7e288965 Viktor G
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
230
		exit;
231
	}
232
} elseif (isset($_POST['toggle_x'])) {
233
	if (is_array($_POST['rule']) && count($_POST['rule'])) {
234
		foreach ($_POST['rule'] as $rulei) {
235
			if (isset($a_filter[$rulei]['disabled'])) {
236
				unset($a_filter[$rulei]['disabled']);
237
			} else {
238
				$a_filter[$rulei]['disabled'] = true;
239
			}
240
		}
241
		if (write_config(gettext("Firewall: Rules - toggle selected firewall rules."))) {
242
			mark_subsystem_dirty('filter');
243
		}
244
245 373fdb53 Steve Beaver
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
246
		exit;
247
	}
248 e3947e77 Steve Beaver
} else if ($_POST['act'] == "toggle") {
249 373fdb53 Steve Beaver
	if ($a_filter[$_POST['id']]) {
250
		if (isset($a_filter[$_POST['id']]['disabled'])) {
251
			unset($a_filter[$_POST['id']]['disabled']);
252
			$wc_msg = gettext('Firewall: Rules - enabled a firewall rule.');
253
		} else {
254
			$a_filter[$_POST['id']]['disabled'] = true;
255
			$wc_msg = gettext('Firewall: Rules - disabled a firewall rule.');
256
		}
257
		if (write_config($wc_msg)) {
258
			mark_subsystem_dirty('filter');
259
		}
260
261
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
262
		exit;
263
	}
264 67c2baf1 Phil Davis
} else if ($_POST['order-store']) {
265 373fdb53 Steve Beaver
	$updated = false;
266
	$dirty = false;
267
268
	/* update rule order, POST[rule] is an array of ordered IDs */
269
	if (is_array($_POST['rule']) && !empty($_POST['rule'])) {
270
		$a_filter_new = array();
271
272
		// Include the rules of other interfaces listed in config before this (the selected) interface.
273 877cff6f jim-p
		$filteri_before = null;
274
		foreach ($a_filter as $idx => $filterent) {
275 373fdb53 Steve Beaver
			if (($filterent['interface'] == $if && !isset($filterent['floating'])) || (isset($filterent['floating']) && "FloatingRules" == $if)) {
276 877cff6f jim-p
				$filteri_before = $idx;
277 373fdb53 Steve Beaver
				break;
278
			} else {
279
				$a_filter_new[] = $filterent;
280
			}
281
		}
282
283
		// Include the rules of this (the selected) interface.
284
		// If a rule is not in POST[rule], it has been deleted by the user
285
		foreach ($_POST['rule'] as $id) {
286
			$a_filter_new[] = $a_filter[$id];
287
		}
288
289
		// Include the rules of other interfaces listed in config after this (the selected) interface.
290
		foreach ($a_filter as $filteri_after => $filterent) {
291
			if ($filteri_before > $filteri_after) {
292
				continue;
293
			}
294
			if (($filterent['interface'] == $if && !isset($filterent['floating'])) || (isset($filterent['floating']) && "FloatingRules" == $if)) {
295
				continue;
296
			} else {
297
				$a_filter_new[] = $filterent;
298
			}
299
		}
300
301
		if ($a_filter !== $a_filter_new) {
302
			$a_filter = $a_filter_new;
303
			$dirty = true;
304
		}
305
	}
306
307 022cb5c4 jim-p
	$a_separators = config_get_path('filter/separator/' . strtolower($if), []);
308 373fdb53 Steve Beaver
309
	/* update separator order, POST[separator] is an array of ordered IDs */
310
	if (is_array($_POST['separator']) && !empty($_POST['separator'])) {
311
		$new_separator = array();
312
		$idx = 0;
313
314
		foreach ($_POST['separator'] as $separator) {
315
			$new_separator['sep' . $idx++] = $separator;
316
		}
317
318
		if ($a_separators !== $new_separator) {
319
			$a_separators = $new_separator;
320
			$updated = true;
321
		}
322
	} else if (!empty($a_separators)) {
323
		$a_separators = "";
324
		$updated = true;
325
	}
326
327
	if ($updated || $dirty) {
328 022cb5c4 jim-p
		config_set_path('filter/separator/' . strtolower($if), $a_separators);
329 373fdb53 Steve Beaver
		if (write_config(gettext("Firewall: Rules - reordered firewall rules."))) {
330
			if ($dirty) {
331
				mark_subsystem_dirty('filter');
332
			}
333
		}
334
	}
335
336
	header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
337
	exit;
338 2e3018c5 Viktor G
} elseif (isset($_POST['dstif']) && !empty($_POST['dstif']) &&
339 b9b25969 Christian McDonald
    isset($iflist[$_POST['dstif']]) && have_ruleint_access($_POST['dstif']) &&
340 2e3018c5 Viktor G
    is_array($_POST['rule']) && count($_POST['rule'])) {
341 2e534ffe jim-p
	$confiflist = get_configured_interface_list();
342
	/* Use this as a starting point and increase as we go, otherwise if the
343
	 * loop runs fast there can be duplicates.
344
	 * https://redmine.pfsense.org/issues/13507 */
345
	$tracker = (int)microtime(true);
346 2e3018c5 Viktor G
	foreach ($_POST['rule'] as $rulei) {
347
		$filterent = $a_filter[$rulei];
348 2e534ffe jim-p
		$filterent['tracker'] = $tracker++;
349 2e3018c5 Viktor G
		$filterent['interface'] = $_POST['dstif'];
350 77e16886 jim-p
		if (($_POST['convertif'] == 'true') && ($if != $_POST['dstif']) &&
351 2e3018c5 Viktor G
		    in_array($_POST['dstif'], $confiflist)) {
352
			if (isset($filterent['source']['network']) &&
353
			    ($filterent['source']['network'] == $if)) {
354
				$filterent['source']['network'] = $_POST['dstif'];
355
			}
356
			if (isset($filterent['destination']['network']) &&
357
			    ($filterent['destination']['network'] == $if)) {
358
				$filterent['destination']['network'] = $_POST['dstif'];
359
			}
360
			if (isset($filterent['source']['network']) &&
361
			    ($filterent['source']['network'] == ($if . 'ip'))) {
362 749af017 jim-p
				$filterent['source']['network'] = $_POST['dstif'] . 'ip';
363 2e3018c5 Viktor G
			}
364
			if (isset($filterent['destination']['network']) &&
365
			    ($filterent['destination']['network'] == ($if . 'ip'))) {
366 749af017 jim-p
				$filterent['destination']['network'] = $_POST['dstif'] . 'ip';
367 2e3018c5 Viktor G
			}
368
		}
369
		$a_filter[] = $filterent;
370
	}
371
	if (write_config(gettext("Firewall: Rules - copying selected firewall rules."))) {
372
		mark_subsystem_dirty('filter');
373
	}
374
375
	header("Location: firewall_rules.php?if=" . htmlspecialchars($_POST['dstif']));
376
	exit;
377 5b237745 Scott Ullrich
}
378
379 df95836a Stephen Beaver
$tab_array = array(array(gettext("Floating"), ("FloatingRules" == $if), "firewall_rules.php?if=FloatingRules"));
380
381 67c2baf1 Phil Davis
foreach ($iflist as $ifent => $ifname) {
382 df95836a Stephen Beaver
	$tab_array[] = array($ifname, ($ifent == $if), "firewall_rules.php?if={$ifent}");
383 67c2baf1 Phil Davis
}
384 df95836a Stephen Beaver
385
foreach ($tab_array as $dtab) {
386 67c2baf1 Phil Davis
	if ($dtab[1]) {
387 df95836a Stephen Beaver
		$bctab = $dtab[0];
388
		break;
389
	}
390
}
391
392
$pgtitle = array(gettext("Firewall"), gettext("Rules"), $bctab);
393 edcd7535 Phil Davis
$pglinks = array("", "firewall_rules.php", "@self");
394 df95836a Stephen Beaver
$shortcut_section = "firewall";
395
396 9a25487b Scott Ullrich
include("head.inc");
397 3b2c83b8 Sjon Hortensius
$nrules = 0;
398
399 67c2baf1 Phil Davis
if ($savemsg) {
400 42a6bcbd Stephen Beaver
	print_info_box($savemsg, 'success');
401 67c2baf1 Phil Davis
}
402 42a6bcbd Stephen Beaver
403 815398fb Phil Davis
if ($_POST['apply']) {
404
	print_apply_result_box($retval);
405
}
406
407 67c2baf1 Phil Davis
if (is_subsystem_dirty('filter')) {
408 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."));
409 67c2baf1 Phil Davis
}
410 3b2c83b8 Sjon Hortensius
411 e4e78af3 jim-p
display_top_tabs($tab_array, false, 'pills');
412 ea5665c7 Sjon Hortensius
413 a2c5280d Stephen Beaver
$showantilockout = false;
414
$showprivate = false;
415
$showblockbogons = false;
416
417
if (!isset($config['system']['webgui']['noantilockout']) &&
418
    (((count($config['interfaces']) > 1) && ($if == 'lan')) ||
419
    ((count($config['interfaces']) == 1) && ($if == 'wan')))) {
420
	$showantilockout = true;
421
}
422
423
if (isset($config['interfaces'][$if]['blockpriv'])) {
424
	$showprivate = true;
425
}
426
427
if (isset($config['interfaces'][$if]['blockbogons'])) {
428
	$showblockbogons = true;
429
}
430
431 fd4dc22e luckman212
if (isset($config['system']['webgui']['roworderdragging'])) {
432 988b786d luckman212
	$rules_header_text = gettext("Rules");
433 fd4dc22e luckman212
} else {
434 988b786d luckman212
	$rules_header_text = gettext("Rules (Drag to Change Order)");
435 fd4dc22e luckman212
}
436
437 cc2cff0b Luiz Otavio O Souza
/* Load the counter data of each pf rule. */
438
$rulescnt = pfSense_get_pf_rules();
439 b13a8425 Stephen Beaver
440 c54a42ea Renato Botelho
// Update this if you add or remove columns!
441 10ae204f Stephen Beaver
$columns_in_table = 13;
442
443 f9e65650 jim-p
/* Floating rules tab has one extra column
444
 * https://redmine.pfsense.org/issues/10667 */
445
if ($if == "FloatingRules") {
446
	$columns_in_table++;
447
}
448
449 c4518538 jim-p
// Only show rules table if interface is set.
450
if (isset($if)):
451
452 cc2cff0b Luiz Otavio O Souza
?>
453 dd455f50 Steve Beaver
<!-- Allow table to scroll when dragging outside of the display window -->
454
<style>
455
.table-responsive {
456
    clear: both;
457
    overflow-x: visible;
458
    margin-bottom: 0px;
459
}
460
</style>
461
462 2e3018c5 Viktor G
<form id="mainform" method="post">
463 285aa44d Steve Beaver
	<input name="if" id="if" type="hidden" value="<?=$if?>" />
464 2e3018c5 Viktor G
	<input name="dstif" id="dstif" type="hidden" value="" />
465
	<input name="convertif" id="convertif" type="hidden" value="" />
466 c821a6cd Stephen Beaver
	<div class="panel panel-default">
467 988b786d luckman212
		<div class="panel-heading"><h2 class="panel-title"><?=$rules_header_text?></h2></div>
468 c821a6cd Stephen Beaver
		<div id="mainarea" class="table-responsive panel-body">
469 dd455f50 Steve Beaver
			<table id="ruletable" class="table table-hover table-striped table-condensed" style="overflow-x: 'visible'">
470 c821a6cd Stephen Beaver
				<thead>
471
					<tr>
472 4ad34942 Steve Beaver
						<th><input type="checkbox" id="selectAll" name="selectAll" /></th>
473 c821a6cd Stephen Beaver
						<th><!-- status icons --></th>
474 cc2cff0b Luiz Otavio O Souza
						<th><?=gettext("States")?></th>
475 bf83fb9a Viktor G
				<?php
476
					if ('FloatingRules' == $if) {
477
				?>
478
						<th><?=gettext("Interfaces")?></th>
479
				<?php
480
					}
481
				?>
482 66c62a1a NewEraCracker
						<th><?=gettext("Protocol")?></th>
483 f25dac2d Stephen Beaver
						<th><?=gettext("Source")?></th>
484
						<th><?=gettext("Port")?></th>
485
						<th><?=gettext("Destination")?></th>
486
						<th><?=gettext("Port")?></th>
487
						<th><?=gettext("Gateway")?></th>
488
						<th><?=gettext("Queue")?></th>
489
						<th><?=gettext("Schedule")?></th>
490
						<th><?=gettext("Description")?></th>
491
						<th><?=gettext("Actions")?></th>
492 c821a6cd Stephen Beaver
					</tr>
493
				</thead>
494 a2c5280d Stephen Beaver
495
<?php if ($showblockbogons || $showantilockout || $showprivate) :
496
?>
497 c821a6cd Stephen Beaver
				<tbody>
498 3b2c83b8 Sjon Hortensius
<?php
499 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.
500 a2c5280d Stephen Beaver
		if ($showantilockout):
501
			$alports = implode('<br />', filter_get_antilockout_ports(true));
502 3b2c83b8 Sjon Hortensius
?>
503 b54ae90f Jared Dillard
					<tr id="antilockout">
504 6cb366de Stephen Beaver
						<td></td>
505 e0cb987c Marcos Mendoza
						<td title="<?=gettext("traffic is passed")?>"><i class="fa-solid fa-check text-success"></i></td>
506 1574802c Renato Botelho do Couto
						<td><?php print_states(intval(ANTILOCKOUT_TRACKER_START), intval(ANTILOCKOUT_TRACKER_END)); ?></td>
507 c821a6cd Stephen Beaver
						<td>*</td>
508
						<td>*</td>
509
						<td>*</td>
510
						<td><?=$iflist[$if];?> Address</td>
511
						<td><?=$alports?></td>
512
						<td>*</td>
513
						<td>*</td>
514
						<td></td>
515 b54ae90f Jared Dillard
						<td><?=gettext("Anti-Lockout Rule");?></td>
516 c821a6cd Stephen Beaver
						<td>
517 e0cb987c Marcos Mendoza
							<a href="system_advanced_admin.php" title="<?=gettext("Settings");?>"><i class="fa-solid fa-cog"></i></a>
518 c821a6cd Stephen Beaver
						</td>
519
					</tr>
520 a2c5280d Stephen Beaver
<?php 	endif;?>
521
<?php 	if ($showprivate): ?>
522 f72e8ee1 NOYB
					<tr id="private">
523 6cb366de Stephen Beaver
						<td></td>
524 e0cb987c Marcos Mendoza
						<td title="<?=gettext("traffic is blocked")?>"><i class="fa-solid fa-times text-danger"></i></td>
525 1574802c Renato Botelho do Couto
						<td><?php print_states(intval(RFC1918_TRACKER_START), intval(RFC1918_TRACKER_END)); ?></td>
526 c821a6cd Stephen Beaver
						<td>*</td>
527
						<td><?=gettext("RFC 1918 networks");?></td>
528
						<td>*</td>
529
						<td>*</td>
530
						<td>*</td>
531
						<td>*</td>
532
						<td>*</td>
533
						<td></td>
534 b54ae90f Jared Dillard
						<td><?=gettext("Block private networks");?></td>
535 c821a6cd Stephen Beaver
						<td>
536 e0cb987c Marcos Mendoza
							<a href="interfaces.php?if=<?=htmlspecialchars($if)?>" title="<?=gettext("Settings");?>" usepost><i class="fa-solid fa-cog"></i></a>
537 c821a6cd Stephen Beaver
						</td>
538
					</tr>
539 a2c5280d Stephen Beaver
<?php 	endif;?>
540
<?php 	if ($showblockbogons): ?>
541 f72e8ee1 NOYB
					<tr id="bogons">
542 0c61e497 Stephen Beaver
						<td></td>
543 e0cb987c Marcos Mendoza
						<td title="<?=gettext("traffic is blocked")?>"><i class="fa-solid fa-times text-danger"></i></td>
544 1574802c Renato Botelho do Couto
						<td><?php print_states(intval(BOGONS_TRACKER_START), intval(BOGONS_TRACKER_END)); ?></td>
545 c821a6cd Stephen Beaver
						<td>*</td>
546 0c61e497 Stephen Beaver
						<td><?=sprintf(gettext("Reserved%sNot assigned by IANA"), "<br />");?></td>
547 c821a6cd Stephen Beaver
						<td>*</td>
548
						<td>*</td>
549
						<td>*</td>
550
						<td>*</td>
551
						<td>*</td>
552 ea548271 Phil Davis
						<td></td>
553 b54ae90f Jared Dillard
						<td><?=gettext("Block bogon networks");?></td>
554 c821a6cd Stephen Beaver
						<td>
555 e0cb987c Marcos Mendoza
							<a href="interfaces.php?if=<?=htmlspecialchars($if)?>" title="<?=gettext("Settings");?>" usepost><i class="fa-solid fa-cog"></i></a>
556 c821a6cd Stephen Beaver
						</td>
557
					</tr>
558 a2c5280d Stephen Beaver
<?php 	endif;?>
559 c821a6cd Stephen Beaver
			</tbody>
560 a2c5280d Stephen Beaver
<?php endif;?>
561 c821a6cd Stephen Beaver
			<tbody class="user-entries">
562 6cb366de Stephen Beaver
<?php
563
$nrules = 0;
564 829322b3 Christian McDonald
$separators = config_get_path('filter/separator/'.strtolower($if));
565 a361a19b Stephen Beaver
566 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).
567
// More efficient than looping through the list of separators on every row.
568
$seprows = separator_rows($separators);
569 a361a19b Stephen Beaver
570 87011dce jim-p
/* Cache gateway status for this page load.
571
 * See https://redmine.pfsense.org/issues/12174 */
572
$gateways_status = return_gateways_status(true);
573
574 a61d68dd Marcos Mendoza
global $user_settings;
575
$show_system_alias_popup = (array_key_exists('webgui', $user_settings) && !$user_settings['webgui']['disablealiaspopupdetail']);
576
$system_alias_specialnet = get_specialnet('', [SPECIALNET_IFNET, SPECIALNET_GROUP]);
577 227c1181 NOYB
foreach ($a_filter as $filteri => $filterent):
578
579 fdb83ce0 NOYB
	if (($filterent['interface'] == $if && !isset($filterent['floating'])) || (isset($filterent['floating']) && "FloatingRules" == $if)) {
580 36bf13fd NOYB
581
		// Display separator(s) for section beginning at rule n
582
		if ($seprows[$nrules]) {
583
			display_separator($separators, $nrules, $columns_in_table);
584
		}
585 56dda8e0 Renato Botelho
?>
586 f2066870 NOYB
					<tr id="fr<?=$nrules;?>" onClick="fr_toggle(<?=$nrules;?>)" ondblclick="document.location='firewall_rules_edit.php?id=<?=$filteri;?>';" <?=(isset($filterent['disabled']) ? ' class="disabled"' : '')?>>
587 a42399ac Colin Fleming
						<td>
588 f2066870 NOYB
							<input type="checkbox" id="frc<?=$nrules;?>" onClick="fr_toggle(<?=$nrules;?>)" name="rule[]" value="<?=$filteri;?>"/>
589 6cb366de Stephen Beaver
						</td>
590
591 3b2c83b8 Sjon Hortensius
	<?php
592 d08aeac1 Phil Davis
		if ($filterent['type'] == "block") {
593 d365c2c7 Marcos Mendoza
			$iconfn = "fa-solid fa-times text-danger";
594 d08aeac1 Phil Davis
			$title_text = gettext("traffic is blocked");
595
		} else if ($filterent['type'] == "reject") {
596 b8c13d95 Marcos Mendoza
			$iconfn = "fa-regular fa-hand text-warning";
597 d08aeac1 Phil Davis
			$title_text = gettext("traffic is rejected");
598
		} else if ($filterent['type'] == "match") {
599 d365c2c7 Marcos Mendoza
			$iconfn = "fa-solid fa-filter";
600 d08aeac1 Phil Davis
			$title_text = gettext("traffic is matched");
601
		} else {
602 d365c2c7 Marcos Mendoza
			$iconfn = "fa-solid fa-check text-success";
603 d08aeac1 Phil Davis
			$title_text = gettext("traffic is passed");
604
		}
605 3b2c83b8 Sjon Hortensius
	?>
606 d08aeac1 Phil Davis
						<td title="<?=$title_text?>">
607 e3947e77 Steve Beaver
							<a href="?if=<?=htmlspecialchars($if);?>&amp;act=toggle&amp;id=<?=$filteri;?>" usepost>
608 d365c2c7 Marcos Mendoza
								<i class="<?=$iconfn?>" title="<?=gettext("click to toggle enabled/disabled status");?>"></i>
609 d4cb4cf3 Stephen Beaver
							</a>
610 3b2c83b8 Sjon Hortensius
	<?php
611 e2461a2f Stephen Beaver
		if ($filterent['quick'] == 'yes') {
612 e0cb987c Marcos Mendoza
			print '<i class="fa-solid fa-forward text-success" title="'. gettext("&quot;Quick&quot; rule. Applied immediately on match.") .'" style="cursor: pointer;"></i>';
613 e2461a2f Stephen Beaver
		}
614
615 3b2c83b8 Sjon Hortensius
		$isadvset = firewall_check_for_advanced_options($filterent);
616 67c2baf1 Phil Davis
		if ($isadvset) {
617 e0cb987c Marcos Mendoza
			print '<i class="fa-solid fa-cog" title="'. gettext("advanced setting") .': '. $isadvset .'" style="cursor: pointer;"></i>';
618 67c2baf1 Phil Davis
		}
619 3b2c83b8 Sjon Hortensius
620 67c2baf1 Phil Davis
		if (isset($filterent['log'])) {
621 e0cb987c Marcos Mendoza
			print '<i class="fa-solid fa-tasks" title="'. gettext("traffic is logged") .'" style="cursor: pointer;"></i>';
622 67c2baf1 Phil Davis
		}
623 e6df5881 Viktor G
624 d297504c Viktor G
		if (isset($filterent['direction']) && ($if == "FloatingRules")) {
625 e6df5881 Viktor G
			if ($filterent['direction'] == 'in') {
626 c1d304b3 Marcos Mendoza
				print '<i class="fa-regular fa-circle-left" title="'. gettext("direction is in") .'" style="cursor: pointer;"></i>';
627 e6df5881 Viktor G
			} elseif ($filterent['direction'] == 'out') {
628 c1d304b3 Marcos Mendoza
				print '<i class="fa-regular fa-circle-right" title="'. gettext("direction is out") .'" style="cursor: pointer;"></i>';
629 e6df5881 Viktor G
			}
630
		}
631 3b2c83b8 Sjon Hortensius
	?>
632 d08aeac1 Phil Davis
						</td>
633 3b2c83b8 Sjon Hortensius
	<?php
634
		$alias = rule_columns_with_alias(
635
			$filterent['source']['address'],
636
			pprint_port($filterent['source']['port']),
637
			$filterent['destination']['address'],
638
			pprint_port($filterent['destination']['port'])
639
		);
640
641
		//build Schedule popup box
642 c6c398c6 jim-p
		init_config_arr(array('schedules', 'schedule'));
643 3b2c83b8 Sjon Hortensius
		$a_schedules = &$config['schedules']['schedule'];
644
		$schedule_span_begin = "";
645
		$schedule_span_end = "";
646
		$sched_caption_escaped = "";
647
		$sched_content = "";
648
		$schedstatus = false;
649 e6f34d22 Phil Davis
		$dayArray = array (gettext('Mon'), gettext('Tues'), gettext('Wed'), gettext('Thur'), gettext('Fri'), gettext('Sat'), gettext('Sun'));
650
		$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'));
651 ea5665c7 Sjon Hortensius
		if ($config['schedules']['schedule'] != "" && is_array($config['schedules']['schedule'])) {
652 bdfea2e7 Stephen Beaver
			$idx = 0;
653 67c2baf1 Phil Davis
			foreach ($a_schedules as $schedule) {
654 dc65689a Renato Botelho
				if (!empty($schedule['name']) &&
655
				    $schedule['name'] == $filterent['sched']) {
656 3b2c83b8 Sjon Hortensius
					$schedstatus = filter_get_time_based_rule_status($schedule);
657
658 e6f34d22 Phil Davis
					foreach ($schedule['timerange'] as $timerange) {
659 3b2c83b8 Sjon Hortensius
						$tempFriendlyTime = "";
660
						$tempID = "";
661
						$firstprint = false;
662 e6f34d22 Phil Davis
						if ($timerange) {
663 3b2c83b8 Sjon Hortensius
							$dayFriendly = "";
664
							$tempFriendlyTime = "";
665
666
							//get hours
667
							$temptimerange = $timerange['hour'];
668
							$temptimeseparator = strrpos($temptimerange, "-");
669
670
							$starttime = substr ($temptimerange, 0, $temptimeseparator);
671
							$stoptime = substr ($temptimerange, $temptimeseparator+1);
672
673 e6f34d22 Phil Davis
							if ($timerange['month']) {
674 3b2c83b8 Sjon Hortensius
								$tempmontharray = explode(",", $timerange['month']);
675 e6f34d22 Phil Davis
								$tempdayarray = explode(",", $timerange['day']);
676 3b2c83b8 Sjon Hortensius
								$arraycounter = 0;
677
								$firstDayFound = false;
678
								$firstPrint = false;
679 e6f34d22 Phil Davis
								foreach ($tempmontharray as $monthtmp) {
680 3b2c83b8 Sjon Hortensius
									$month = $tempmontharray[$arraycounter];
681
									$day = $tempdayarray[$arraycounter];
682
683 67c2baf1 Phil Davis
									if (!$firstDayFound) {
684 3b2c83b8 Sjon Hortensius
										$firstDay = $day;
685
										$firstmonth = $month;
686
										$firstDayFound = true;
687
									}
688
689
									$currentDay = $day;
690
									$nextDay = $tempdayarray[$arraycounter+1];
691
									$currentDay++;
692 e6f34d22 Phil Davis
									if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])) {
693 67c2baf1 Phil Davis
										if ($firstPrint) {
694 3b2c83b8 Sjon Hortensius
											$dayFriendly .= ", ";
695 67c2baf1 Phil Davis
										}
696 3b2c83b8 Sjon Hortensius
										$currentDay--;
697 67c2baf1 Phil Davis
										if ($currentDay != $firstDay) {
698 3b2c83b8 Sjon Hortensius
											$dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ;
699 67c2baf1 Phil Davis
										} else {
700 c821a6cd Stephen Beaver
											$dayFriendly .=	 $monthArray[$month-1] . " " . $day;
701 67c2baf1 Phil Davis
										}
702 8ce97a08 Scott Dale
										$firstDayFound = false;
703 3b2c83b8 Sjon Hortensius
										$firstPrint = true;
704
									}
705
									$arraycounter++;
706
								}
707 67c2baf1 Phil Davis
							} else {
708 3b2c83b8 Sjon Hortensius
								$tempdayFriendly = $timerange['position'];
709
								$firstDayFound = false;
710
								$tempFriendlyDayArray = explode(",", $tempdayFriendly);
711
								$currentDay = "";
712
								$firstDay = "";
713
								$nextDay = "";
714
								$counter = 0;
715 e6f34d22 Phil Davis
								foreach ($tempFriendlyDayArray as $day) {
716
									if ($day != "") {
717 67c2baf1 Phil Davis
										if (!$firstDayFound) {
718 3b2c83b8 Sjon Hortensius
											$firstDay = $tempFriendlyDayArray[$counter];
719
											$firstDayFound = true;
720 8ce97a08 Scott Dale
										}
721 3b2c83b8 Sjon Hortensius
										$currentDay =$tempFriendlyDayArray[$counter];
722
										//get next day
723
										$nextDay = $tempFriendlyDayArray[$counter+1];
724
										$currentDay++;
725 e6f34d22 Phil Davis
										if ($currentDay != $nextDay) {
726 67c2baf1 Phil Davis
											if ($firstprint) {
727 3b2c83b8 Sjon Hortensius
												$dayFriendly .= ", ";
728 67c2baf1 Phil Davis
											}
729 3b2c83b8 Sjon Hortensius
											$currentDay--;
730 67c2baf1 Phil Davis
											if ($currentDay != $firstDay) {
731 3b2c83b8 Sjon Hortensius
												$dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
732 67c2baf1 Phil Davis
											} else {
733 3b2c83b8 Sjon Hortensius
												$dayFriendly .= $dayArray[$firstDay-1];
734 67c2baf1 Phil Davis
											}
735 3b2c83b8 Sjon Hortensius
											$firstDayFound = false;
736
											$firstprint = true;
737
										}
738
										$counter++;
739 56dda8e0 Renato Botelho
									}
740 8ce97a08 Scott Dale
								}
741 2a113ca9 Scott Dale
							}
742 3b2c83b8 Sjon Hortensius
							$timeFriendly = $starttime . " - " . $stoptime;
743
							$description = $timerange['rangedescr'];
744
							$sched_content .= $dayFriendly . "; " . $timeFriendly . "<br />";
745 56dda8e0 Renato Botelho
						}
746
					}
747 ea5665c7 Sjon Hortensius
					#FIXME
748 3b2c83b8 Sjon Hortensius
					$sched_caption_escaped = str_replace("'", "\'", $schedule['descr']);
749 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="' .
750 84147b7b Steve Beaver
						$sched_caption_escaped . '" data-html="true">';
751 a42399ac Colin Fleming
					$schedule_span_end = "</a>";
752 616dd997 Scott Dale
				}
753 92da593a Chris Buechler
				$idx++;
754 3b2c83b8 Sjon Hortensius
			}
755
		}
756
		$printicon = false;
757
		$alttext = "";
758
		$image = "";
759
		if (!isset($filterent['disabled'])) {
760
			if ($schedstatus) {
761 5db29ca7 Phil Davis
				if ($filterent['type'] == "block" || $filterent['type'] == "reject") {
762 d365c2c7 Marcos Mendoza
					$image = "fa-solid fa-times-circle";
763 bdfea2e7 Stephen Beaver
					$dispcolor = "text-danger";
764 3b2c83b8 Sjon Hortensius
					$alttext = gettext("Traffic matching this rule is currently being denied");
765 56dda8e0 Renato Botelho
				} else {
766 d365c2c7 Marcos Mendoza
					$image = "fa-solid fa-play-circle";
767 bdfea2e7 Stephen Beaver
					$dispcolor = "text-success";
768 3b2c83b8 Sjon Hortensius
					$alttext = gettext("Traffic matching this rule is currently being allowed");
769 be81b340 Erik Fonnesbeck
				}
770 3b2c83b8 Sjon Hortensius
				$printicon = true;
771
			} else if ($filterent['sched']) {
772 5db29ca7 Phil Davis
				if ($filterent['type'] == "block" || $filterent['type'] == "reject") {
773 d365c2c7 Marcos Mendoza
					$image = "fa-solid fa-times-circle";
774 67c2baf1 Phil Davis
				} else {
775 d365c2c7 Marcos Mendoza
					$image = "fa-solid fa-play-circle";
776 67c2baf1 Phil Davis
				}
777 3b2c83b8 Sjon Hortensius
				$alttext = gettext("This rule is not currently active because its period has expired");
778 5db29ca7 Phil Davis
				$dispcolor = "text-warning";
779 3b2c83b8 Sjon Hortensius
				$printicon = true;
780
			}
781
		}
782
	?>
783 2af731f8 NewEraCracker
				<td><?php print_states(intval($filterent['tracker'])); ?></td>
784 bf83fb9a Viktor G
	<?php
785
		if ($if == 'FloatingRules') {
786
	?>
787
			<td onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
788
	<?php
789
			if (isset($filterent['interface'])) {
790
				$selected_interfaces = explode(',', $filterent['interface']);
791
				unset($selected_descs);
792
				foreach ($selected_interfaces as $interface) {
793
					if (isset($ifdescs[$interface])) {
794
						$selected_descs[] = $ifdescs[$interface];
795
					} else {
796
						switch ($interface) {
797
						case 'l2tp':
798 5f121e6a jim-p
							if (config_get_path('l2tp/mode') == 'server') {
799 bf83fb9a Viktor G
								$selected_descs[] = 'L2TP VPN';
800 5f121e6a jim-p
							}
801 bf83fb9a Viktor G
							break;
802
						case 'pppoe':
803 5f121e6a jim-p
							if (is_pppoe_server_enabled()) {
804 bf83fb9a Viktor G
								$selected_descs[] = 'PPPoE Server';
805 5f121e6a jim-p
							}
806 bf83fb9a Viktor G
							break;
807
						case 'enc0':
808 5f121e6a jim-p
							if (ipsec_enabled()) {
809 bf83fb9a Viktor G
								$selected_descs[] = 'IPsec';
810 5f121e6a jim-p
							}
811 bf83fb9a Viktor G
							break;
812
						case 'openvpn':
813 5f121e6a jim-p
							if (!empty(config_get_path('openvpn/openvpn-server', [])) ||
814
							    !empty(config_get_path('openvpn/openvpn-client', []))) {
815 bf83fb9a Viktor G
								$selected_descs[] = 'OpenVPN';
816 5f121e6a jim-p
							}
817 bf83fb9a Viktor G
							break;
818 af3320b2 Viktor G
						case 'any':
819
							$selected_descs[] = 'Any';
820
							break;
821 bf83fb9a Viktor G
						default:
822
							$selected_descs[] = $interface;
823
							break;
824
						}
825
					}
826
				}
827 65d935bf Viktor G
				if (!empty($selected_descs)) {
828 03c0fd1e Viktor G
					$desclist = '';
829
					$desclength = 0;
830 d35a18fc Christian McDonald
					foreach ($selected_descs as $desc) {
831 03c0fd1e Viktor G
						$desclength += strlen($desc);
832
						if ($desclength > 18) {
833
							$desclist .= ',<br/>';
834
							$desclength = 0;
835
						} elseif ($desclist) {
836
							$desclist .= ', ';
837
							$desclength += 2;
838
						}
839
						$desclist .= $desc;
840
					}
841
					echo $desclist;
842 65d935bf Viktor G
				}
843 bf83fb9a Viktor G
			}
844
	?>
845
			</td>
846
	<?php
847
		}
848
	?>
849
			<td>
850 3b2c83b8 Sjon Hortensius
	<?php
851
		if (isset($filterent['ipprotocol'])) {
852 e6f34d22 Phil Davis
			switch ($filterent['ipprotocol']) {
853 3b2c83b8 Sjon Hortensius
				case "inet":
854
					echo "IPv4 ";
855
					break;
856
				case "inet6":
857
					echo "IPv6 ";
858
					break;
859
				case "inet46":
860
					echo "IPv4+6 ";
861
					break;
862
			}
863
		} else {
864
			echo "IPv4 ";
865
		}
866
867
		if (isset($filterent['protocol'])) {
868
			echo strtoupper($filterent['protocol']);
869
870
			if (strtoupper($filterent['protocol']) == "ICMP" && !empty($filterent['icmptype'])) {
871 16b91b19 stilez
				// replace each comma-separated icmptype item by its (localised) full description
872 91822dc6 stilez
				$t = 	implode(', ',
873
						array_map(
874
						        function($type) {
875
								global $icmptypes;
876 c7e31e37 stilez
								return $icmptypes[$type]['descrip'];
877 91822dc6 stilez
							},
878
							explode(',', $filterent['icmptype'])
879
						)
880
					);
881 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']));
882 3b2c83b8 Sjon Hortensius
			}
883 97eebb23 stilez
		} else {
884
			echo " *";
885
		}
886 3b2c83b8 Sjon Hortensius
	?>
887 c821a6cd Stephen Beaver
						</td>
888
						<td>
889
							<?php if (isset($alias['src'])): ?>
890 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">
891 4b72f68f Steve Beaver
									<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_address($filterent['source'])))?>
892 a42399ac Colin Fleming
								</a>
893 a61d68dd Marcos Mendoza
							<?php elseif ($show_system_alias_popup && array_key_exists($filterent['source']['network'], $system_alias_specialnet)): ?>
894
								<a data-toggle="popover" data-trigger="hover focus" title="<?=gettext('System alias details')?>" data-content="<?=system_alias_info_popup($filterent['source']['network'])?>" data-html="true">
895
									<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_address($filterent['source'], $filter_srcdsttype_flags)))?>
896
								</a>
897 a42399ac Colin Fleming
							<?php else: ?>
898 e729ecf8 Marcos Mendoza
								<?=htmlspecialchars(pprint_address($filterent['source'], $filter_srcdsttype_flags))?>
899 c821a6cd Stephen Beaver
							<?php endif; ?>
900
						</td>
901
						<td>
902
							<?php if (isset($alias['srcport'])): ?>
903 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">
904 4b72f68f Steve Beaver
									<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_port($filterent['source']['port'])))?>
905 a42399ac Colin Fleming
								</a>
906
							<?php else: ?>
907
								<?=htmlspecialchars(pprint_port($filterent['source']['port']))?>
908 c821a6cd Stephen Beaver
							<?php endif; ?>
909
						</td>
910
						<td>
911
							<?php if (isset($alias['dst'])): ?>
912 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">
913 4b72f68f Steve Beaver
									<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_address($filterent['destination'])))?>
914 a42399ac Colin Fleming
								</a>
915 a61d68dd Marcos Mendoza
							<?php elseif ($show_system_alias_popup && array_key_exists($filterent['destination']['network'], $system_alias_specialnet)): ?>
916
								<a data-toggle="popover" data-trigger="hover focus" title="<?=gettext('System alias details')?>" data-content="<?=system_alias_info_popup($filterent['destination']['network'])?>" data-html="true">
917
									<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_address($filterent['destination'], $filter_srcdsttype_flags)))?>
918
								</a>
919 2af731f8 NewEraCracker
							<?php else: ?>
920 e729ecf8 Marcos Mendoza
								<?=htmlspecialchars(pprint_address($filterent['destination'], $filter_srcdsttype_flags))?>
921 c821a6cd Stephen Beaver
							<?php endif; ?>
922
						</td>
923
						<td>
924
							<?php if (isset($alias['dstport'])): ?>
925 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">
926 4b72f68f Steve Beaver
									<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_port($filterent['destination']['port'])))?>
927 a42399ac Colin Fleming
								</a>
928
							<?php else: ?>
929
								<?=htmlspecialchars(pprint_port($filterent['destination']['port']))?>
930 c821a6cd Stephen Beaver
							<?php endif; ?>
931
						</td>
932
						<td>
933 f8993f22 luftegrof
							<?php if (isset($filterent['gateway'])): ?>
934
								<?php
935
									/* Cache gateway status for this page load.
936
									 * See https://redmine.pfsense.org/issues/12174 */
937 85ea410d luftegrof
									if (!is_array($gw_info)) {
938
										$gw_info = array();
939 c79b9cfe luftegrof
									}
940 85ea410d luftegrof
									if (empty($gw_info[$filterent['gateway']])) {
941 0ef74a74 luftegrof
										$gw_info[$filterent['gateway']] = gateway_info_popup($filterent['gateway'], $gateways_status);
942 c79b9cfe luftegrof
									}
943 f8993f22 luftegrof
								?>
944
								<?php if (!empty($gw_info[$filterent['gateway']])): ?>
945 2c21b4a4 Viktor G
									<?=$gw_info[$filterent['gateway']]?>
946 f8993f22 luftegrof
								<?php else: ?>
947
									<span>
948
								<?php endif; ?>
949
							<?php else: ?>
950
								<span>
951
							<?php endif; ?>
952 e912f0cf Viktor G
								<?php if (isset($config['interfaces'][$filterent['gateway']]['descr'])): ?>
953
									<?=str_replace('_', '_<wbr>', htmlspecialchars($config['interfaces'][$filterent['gateway']]['descr']))?>
954
								<?php else: ?>
955
									<?=htmlspecialchars(pprint_port($filterent['gateway']))?>
956
								<?php endif; ?>
957
							</span>
958 c821a6cd Stephen Beaver
						</td>
959
						<td>
960
							<?php
961
								if (isset($filterent['ackqueue']) && isset($filterent['defaultqueue'])) {
962 ece727a7 NOYB
									$desc = str_replace('_', ' ', $filterent['ackqueue']);
963 84147b7b Steve Beaver
									echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['ackqueue']}&amp;action=show\">{$desc}</a>";
964 4b72f68f Steve Beaver
									$desc = str_replace('_', '_<wbr>', $filterent['defaultqueue']);
965 84147b7b Steve Beaver
									echo "/<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
966 c821a6cd Stephen Beaver
								} else if (isset($filterent['defaultqueue'])) {
967 4b72f68f Steve Beaver
									$desc = str_replace('_', '_<wbr>', $filterent['defaultqueue']);
968 84147b7b Steve Beaver
									echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
969 67c2baf1 Phil Davis
								} else {
970 c821a6cd Stephen Beaver
									echo gettext("none");
971 67c2baf1 Phil Davis
								}
972 c821a6cd Stephen Beaver
							?>
973
						</td>
974
						<td>
975 995df6c3 Stephen Beaver
							<?php if ($printicon) { ?>
976 d365c2c7 Marcos Mendoza
								<i class="<?=$image?> <?=$dispcolor?>" title="<?=$alttext;?>"></i>
977 995df6c3 Stephen Beaver
							<?php } ?>
978 4b72f68f Steve Beaver
							<?=$schedule_span_begin;?><?=str_replace('_', '_<wbr>', htmlspecialchars($filterent['sched']));?>&nbsp;<?=$schedule_span_end;?>
979 c821a6cd Stephen Beaver
						</td>
980 b54ae90f Jared Dillard
						<td>
981 c821a6cd Stephen Beaver
							<?=htmlspecialchars($filterent['descr']);?>
982
						</td>
983 45e849c1 Jared Dillard
						<td class="action-icons">
984 f25dac2d Stephen Beaver
						<!-- <?=(isset($filterent['disabled']) ? 'enable' : 'disable')?> -->
985 e0cb987c Marcos Mendoza
							<a	class="fa-solid fa-anchor icon-pointer" id="Xmove_<?=$filteri?>" title="<?=$XmoveTitle?>"></a>
986
							<a href="firewall_rules_edit.php?id=<?=$filteri;?>" class="fa-solid fa-pencil" title="<?=gettext('Edit')?>"></a>
987 c1d304b3 Marcos Mendoza
							<a href="firewall_rules_edit.php?dup=<?=$filteri;?>" class="fa-regular fa-clone" title="<?=gettext('Copy')?>"></a>
988 f25dac2d Stephen Beaver
<?php if (isset($filterent['disabled'])) {
989
?>
990 c1d304b3 Marcos Mendoza
							<a href="?act=toggle&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$filteri;?>" class="fa-regular fa-square-check" title="<?=gettext('Enable')?>" usepost></a>
991 f25dac2d Stephen Beaver
<?php } else {
992
?>
993 e0cb987c Marcos Mendoza
							<a href="?act=toggle&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$filteri;?>" class="fa-solid fa-ban" title="<?=gettext('Disable')?>" usepost></a>
994 f25dac2d Stephen Beaver
<?php }
995
?>
996 c1d304b3 Marcos Mendoza
							<a href="?act=del&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$filteri;?>" class="fa-solid fa-trash-can" title="<?=gettext('Delete this rule')?>" usepost></a>
997 c5d0d75d Jim Pingle
<?php if (($filterent['type'] == 'pass') &&
998
	    !empty($filterent['tracker'])): ?>
999 e0cb987c Marcos Mendoza
							<a href="?act=killid&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$filteri;?>&amp;tracker=<?=$filterent['tracker']?>" class="fa-solid fa-times do-confirm" title="<?=gettext('Kill states on this interface created by this rule')?>" usepost></a>
1000 c5d0d75d Jim Pingle
<?php endif; ?>
1001 c821a6cd Stephen Beaver
						</td>
1002
					</tr>
1003
<?php
1004 6cb366de Stephen Beaver
		$nrules++;
1005 fdb83ce0 NOYB
	}
1006 227c1181 NOYB
endforeach;
1007 36bf13fd NOYB
1008
// There can be separator(s) after the last rule listed.
1009 8a12728d Marcos Mendoza
foreach ($seprows as $idx => $sep) {
1010
	if ($idx >= $nrules) {
1011
		display_separator($separators, $idx, $columns_in_table);
1012
	}
1013 36bf13fd NOYB
}
1014 c821a6cd Stephen Beaver
?>
1015
				</tbody>
1016
			</table>
1017
		</div>
1018
	</div>
1019 3b2c83b8 Sjon Hortensius
1020
<?php if ($nrules == 0): ?>
1021
	<div class="alert alert-warning" role="alert">
1022 06966500 Sander van Leeuwen
		<p>
1023 3b2c83b8 Sjon Hortensius
		<?php if ($_REQUEST['if'] == "FloatingRules"): ?>
1024
			<?=gettext("No floating rules are currently defined.");?>
1025
		<?php else: ?>
1026
			<?=gettext("No rules are currently defined for this interface");?><br />
1027 317b2852 NOYB
			<?=gettext("All incoming connections on this interface will be blocked until pass rules are added.");?>
1028 3b2c83b8 Sjon Hortensius
		<?php endif;?>
1029 06966500 Sander van Leeuwen
			<?=gettext("Click the button to add a new rule.");?>
1030
		</p>
1031 3b2c83b8 Sjon Hortensius
	</div>
1032
<?php endif;?>
1033
1034 c10cb196 Stephen Beaver
	<nav class="action-buttons">
1035 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')?>">
1036 c1d304b3 Marcos Mendoza
			<i class="fa-solid fa-turn-up icon-embed-btn"></i>
1037 09415b9e Stephen Beaver
			<?=gettext("Add");?>
1038 c821a6cd Stephen Beaver
		</a>
1039 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')?>">
1040 c1d304b3 Marcos Mendoza
			<i class="fa-solid fa-turn-down icon-embed-btn"></i>
1041 270de3df Stephen Beaver
			<?=gettext("Add");?>
1042
		</a>
1043 64b2a187 Viktor G
		<button id="del_x" name="del_x" type="submit" class="btn btn-danger btn-sm" value="<?=gettext("Delete selected rules"); ?>" disabled title="<?=gettext('Delete selected rules')?>">
1044 c1d304b3 Marcos Mendoza
			<i class="fa-solid fa-trash-can icon-embed-btn"></i>
1045 09415b9e Stephen Beaver
			<?=gettext("Delete"); ?>
1046
		</button>
1047 64b2a187 Viktor G
		<button id="toggle_x" name="toggle_x" type="submit" class="btn btn-primary btn-sm" value="<?=gettext("Toggle selected rules"); ?>" disabled title="<?=gettext('Toggle selected rules')?>">
1048 e0cb987c Marcos Mendoza
			<i class="fa-solid fa-ban icon-embed-btn"></i>
1049 7e288965 Viktor G
			<?=gettext("Toggle"); ?>
1050
		</button>
1051 2e3018c5 Viktor G
		<?php if ($if != 'FloatingRules'):?>
1052 64b2a187 Viktor G
		<button id="copy_x" name="copy_x" type="button" class="btn btn-primary btn-sm" value="<?=gettext("Copy selected rules"); ?>" disabled title="<?=gettext('Copy selected rules')?>" data-toggle="modal" data-target="#rulescopy">
1053 c1d304b3 Marcos Mendoza
			<i class="fa-regular fa-clone icon-embed-btn"></i>
1054 2e3018c5 Viktor G
			<?=gettext("Copy"); ?>
1055
		</button>
1056
		<?php endif;?>
1057 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')?>">
1058 e0cb987c Marcos Mendoza
			<i class="fa-solid fa-save icon-embed-btn"></i>
1059 09415b9e Stephen Beaver
			<?=gettext("Save")?>
1060
		</button>
1061 576437f5 Stephen Beaver
		<button type="submit" id="addsep" name="addsep" class="btn btn-sm btn-warning" title="<?=gettext('Add separator')?>">
1062 e0cb987c Marcos Mendoza
			<i class="fa-solid fa-plus icon-embed-btn"></i>
1063 576437f5 Stephen Beaver
			<?=gettext("Separator")?>
1064
		</button>
1065 c821a6cd Stephen Beaver
	</nav>
1066
</form>
1067 2e3018c5 Viktor G
<?php
1068
// Create a Modal object to display Rules Copy window
1069
$form = new Form(false);
1070
$modal = new Modal('Copy selected rules', 'rulescopy', true);
1071
$modal->addInput(new Form_Select(
1072
	'copyr_dstif',
1073
	'*Destination Interface',
1074
	$if,
1075
	filter_get_interface_list()
1076
))->setHelp('Select the destination interface where the rules should be copied. Rules will be added after existing rules on that interface.');
1077
$modal->addInput(new Form_Checkbox(
1078
	'copyr_convertif',
1079
	'Convert interface definitions',
1080
	'Enable Interface Address/Net conversion',
1081
	false
1082
))->setHelp('Convert source Interface Address/Net definitions to the destination Interface Address/Net.%1$s' .
1083 b9b25969 Christian McDonald
	    'For example: LAN Address -> OPT1 Address, or LAN net -> OPT1 net.%1$s' .
1084 2e3018c5 Viktor G
	    'Interface groups and some special interfaces (IPsec, OpenVPN), do not support this feature.', '<br />');
1085
$btncopyrules = new Form_Button(
1086
	'copyr',
1087 15ae0ea0 Viktor G
	'Paste',
1088 2e3018c5 Viktor G
	null,
1089 e6f78714 Marcos Mendoza
	'fa-regular fa-clone'
1090 2e3018c5 Viktor G
);
1091
$btncopyrules->setAttribute('type','button')->addClass('btn-success');
1092
$btncancelcopyrules = new Form_Button(
1093
	'cancel_copyr',
1094
	'Cancel',
1095
	null,
1096 e6f78714 Marcos Mendoza
	'fa-solid fa-undo'
1097 2e3018c5 Viktor G
);
1098
$btncancelcopyrules->setAttribute('type','button')->addClass('btn-warning');
1099
$modal->addInput(new Form_StaticText(
1100
	null,
1101
	$btncopyrules . $btncancelcopyrules
1102
));
1103
$form->add($modal);
1104
print($form);
1105 c4518538 jim-p
1106
else: ?>
1107
	<div class="alert alert-warning" role="alert">
1108
		<p>
1109
			<?= gettext("Select an interface to view firewall rules.") ?>
1110
			<br />
1111
			<?php
1112
				echo sprintf(gettext("See %sSystem > General Setup%s, %sRequire Firewall Interface%s."),
1113
				'<a href="/system.php">',
1114
				'</a>',
1115
				'<strong>',
1116
				'</strong>');
1117
			?>
1118
		</p>
1119
	</div>
1120
1121
<?php endif; ?>
1122
1123 35681930 Stephen Beaver
<div class="infoblock">
1124 c97a3f34 Phil Davis
	<div class="alert alert-info clearfix" role="alert"><div class="pull-left">
1125 270de3df Stephen Beaver
		<dl class="dl-horizontal responsive">
1126
		<!-- Legend -->
1127
			<dt><?=gettext('Legend')?></dt>				<dd></dd>
1128 e0cb987c Marcos Mendoza
			<dt><i class="fa-solid fa-check text-success"></i></dt>		<dd><?=gettext("Pass");?></dd>
1129
			<dt><i class="fa-solid fa-filter"></i></dt>	<dd><?=gettext("Match");?></dd>
1130
			<dt><i class="fa-solid fa-times text-danger"></i></dt>	<dd><?=gettext("Block");?></dd>
1131 c1d304b3 Marcos Mendoza
			<dt><i class="fa-regular fa-hand text-warning"></i></dt>		<dd><?=gettext("Reject");?></dd>
1132 e0cb987c Marcos Mendoza
			<dt><i class="fa-solid fa-tasks"></i></dt>	<dd> <?=gettext("Log");?></dd>
1133
			<dt><i class="fa-solid fa-cog"></i></dt>		<dd> <?=gettext("Advanced filter");?></dd>
1134
			<dt><i class="fa-solid fa-forward text-success"></i></dt><dd> <?=gettext("&quot;Quick&quot; rule. Applied immediately on match.")?></dd>
1135 270de3df Stephen Beaver
		</dl>
1136
1137 824329d2 Stephen Beaver
<?php
1138 67c2baf1 Phil Davis
	if ("FloatingRules" != $if) {
1139 270de3df Stephen Beaver
		print(gettext("Rules are evaluated on a first-match basis (i.e. " .
1140 09415b9e Stephen Beaver
			"the action of the first rule to match a packet will be executed). ") . '<br />' .
1141 9e97598a NOYB
			gettext("This means that if block rules are used, it is important to pay attention " .
1142 09415b9e Stephen Beaver
			"to the rule order. Everything that isn't explicitly passed is blocked " .
1143 270de3df Stephen Beaver
			"by default. "));
1144 67c2baf1 Phil Davis
	} else {
1145 270de3df Stephen Beaver
		print(gettext("Floating rules are evaluated on a first-match basis (i.e. " .
1146 09415b9e Stephen Beaver
			"the action of the first rule to match a packet will be executed) only " .
1147 04fd7017 Stephen Beaver
			"if the 'quick' option is checked on a rule. Otherwise they will only match if no " .
1148 09415b9e Stephen Beaver
			"other rules match. Pay close attention to the rule order and options " .
1149 270de3df Stephen Beaver
			"chosen. If no rule here matches, the per-interface or default rules are used. "));
1150 67c2baf1 Phil Davis
	}
1151 d830a7f4 Stephen Beaver
1152 702fa4d0 Phil Davis
	printf(gettext('%1$sClick the anchor icon %2$s to move checked rules before the clicked row. Hold down ' .
1153 e0cb987c Marcos Mendoza
			'the shift key and click to move the rules after the clicked row.'), '<br /><br />', '<i class="fa-solid fa-anchor"></i>');
1154 824329d2 Stephen Beaver
?>
1155 270de3df Stephen Beaver
	</div>
1156 ab6b1f47 NOYB
	</div>
1157 09415b9e Stephen Beaver
</div>
1158 2f4323b5 Stephen Beaver
1159 8fd9052f Colin Fleming
<script type="text/javascript">
1160
//<![CDATA[
1161 7d8552fc Stephen Beaver
1162 2af731f8 NewEraCracker
//Need to create some variables here so that jquery/pfSenseHelpers.js can read them
1163 7d8552fc Stephen Beaver
iface = "<?=strtolower($if)?>";
1164
cncltxt = '<?=gettext("Cancel")?>';
1165
svtxt = '<?=gettext("Save")?>';
1166
svbtnplaceholder = '<?=gettext("Enter a description, Save, then drag to final location.")?>';
1167
configsection = "filter";
1168
1169 ea5665c7 Sjon Hortensius
events.push(function() {
1170 2f4323b5 Stephen Beaver
1171 3f597adb Stephen Beaver
	// "Move to here" (anchor) action
1172
	$('[id^=Xmove_]').click(function (event) {
1173
1174 f1d5b8ef Phil Davis
		// Prevent click from toggling row
1175 3f597adb Stephen Beaver
		event.stopImmediatePropagation();
1176
1177 f1d5b8ef Phil Davis
		// Save the target rule position
1178 3f597adb Stephen Beaver
		var anchor_row = $(this).parents("tr:first");
1179
1180 d830a7f4 Stephen Beaver
		if (event.shiftKey) {
1181
			$($('#ruletable > tbody  > tr').get().reverse()).each(function() {
1182
				ruleid = this.id.slice(2);
1183 3f597adb Stephen Beaver
1184 d830a7f4 Stephen Beaver
				if (ruleid && !isNaN(ruleid)) {
1185
					if ($('#frc' + ruleid).prop('checked')) {
1186
						// Move the selected rows, un-select them and add highlight class
1187
						$(this).insertAfter(anchor_row);
1188
						fr_toggle(ruleid, "fr");
1189
						$('#fr' + ruleid).addClass("highlight");
1190
					}
1191 3f597adb Stephen Beaver
				}
1192 d830a7f4 Stephen Beaver
			});
1193
		} else {
1194
			$('#ruletable > tbody  > tr').each(function() {
1195
				ruleid = this.id.slice(2);
1196
1197
				if (ruleid && !isNaN(ruleid)) {
1198
					if ($('#frc' + ruleid).prop('checked')) {
1199
						// Move the selected rows, un-select them and add highlight class
1200
						$(this).insertBefore(anchor_row);
1201
						fr_toggle(ruleid, "fr");
1202
						$('#fr' + ruleid).addClass("highlight");
1203
					}
1204
				}
1205
			});
1206
		}
1207 3f597adb Stephen Beaver
1208 f1d5b8ef Phil Davis
		// Temporarily set background color so user can more easily see the moved rules, then fade
1209 4dbdb358 Stephen Beaver
		$('.highlight').effect("highlight", {color: "#739b4b;"}, 4000);
1210
		$('#ruletable tr').removeClass("highlight");
1211 3f597adb Stephen Beaver
		$('#order-store').removeAttr('disabled');
1212
		reindex_rules($(anchor_row).parent('tbody'));
1213
		dirty = true;
1214 a7893b72 Stephen Beaver
	}).mouseover(function(e) {
1215 c6a8ddf8 Stephen Beaver
		var ruleselected = false;
1216
1217 995454f3 Stephen Beaver
		$(this).css("cursor", "default");
1218
1219 c6a8ddf8 Stephen Beaver
		// Are any rules currently selected?
1220
		$('[id^=frc]').each(function () {
1221
			if ($(this).prop("checked")) {
1222
				ruleselected = true;
1223
			}
1224
		});
1225
1226 fcf29c87 Phil Davis
		// If so, change the icon to show the insertion point
1227 c6a8ddf8 Stephen Beaver
		if (ruleselected) {
1228
			if (e.shiftKey) {
1229 e0cb987c Marcos Mendoza
				$(this).removeClass().addClass("fa-solid fa-lg fa-arrow-down text-danger");
1230 c6a8ddf8 Stephen Beaver
			} else {
1231 e0cb987c Marcos Mendoza
				$(this).removeClass().addClass("fa-solid fa-lg fa-arrow-up text-danger");
1232 c6a8ddf8 Stephen Beaver
			}
1233 a7893b72 Stephen Beaver
		}
1234
	}).mouseout(function(e) {
1235 e0cb987c Marcos Mendoza
		$(this).removeClass().addClass("fa-solid fa-anchor");
1236 3f597adb Stephen Beaver
	});
1237
1238 52e91f70 PiBa-NL
<?php if(!isset($config['system']['webgui']['roworderdragging'])): ?>
1239 85d49326 Stephen Beaver
	// Make rules sortable. Hiding the table before applying sortable, then showing it again is
1240 511053ad Stephen Beaver
	// a work-around for very slow sorting on FireFox
1241
	$('table tbody.user-entries').hide();
1242
1243 ea5665c7 Sjon Hortensius
	$('table tbody.user-entries').sortable({
1244
		cursor: 'grabbing',
1245 7da65ab7 Steve Beaver
		scroll: true,
1246
		overflow: 'scroll',
1247
		scrollSensitivity: 100,
1248 ea5665c7 Sjon Hortensius
		update: function(event, ui) {
1249
			$('#order-store').removeAttr('disabled');
1250 1f73ccba Stephen Beaver
			reindex_rules(ui.item.parent('tbody'));
1251 5d7b915d Stephen Beaver
			dirty = true;
1252 ea5665c7 Sjon Hortensius
		}
1253
	});
1254
1255 511053ad Stephen Beaver
	$('table tbody.user-entries').show();
1256 52e91f70 PiBa-NL
<?php endif; ?>
1257 511053ad Stephen Beaver
1258 6cb366de Stephen Beaver
	// Check all of the rule checkboxes so that their values are posted
1259
	$('#order-store').click(function () {
1260 301e4aa0 Stephen Beaver
		$('[id^=frc]').prop('checked', true);
1261
1262
		// Save the separator bar configuration
1263
		save_separators();
1264 5d7b915d Stephen Beaver
1265
		// Suppress the "Do you really want to leave the page" message
1266
		saving = true;
1267 6cb366de Stephen Beaver
	});
1268 576437f5 Stephen Beaver
1269 64b2a187 Viktor G
	$('[id^=fr]').click(function () {
1270 e1e388e4 Viktor G
		buttonsmode('frc', ['del_x', 'toggle_x', 'copy_x']);
1271 64b2a187 Viktor G
	});
1272
1273 f1d5b8ef Phil Davis
	// Provide a warning message if the user tries to change page before saving
1274 5d7b915d Stephen Beaver
	$(window).bind('beforeunload', function(){
1275 4864d7f6 Josh Soref
		if ((!saving && dirty) || newSeparator) {
1276 317b2852 NOYB
			return ("<?=gettext('One or more rules have been moved but have not yet been saved')?>");
1277 5d7b915d Stephen Beaver
		} else {
1278
			return undefined;
1279
		}
1280
	});
1281 d830a7f4 Stephen Beaver
1282
	$(document).on('keyup keydown', function(e){
1283
		if (e.shiftKey) {
1284
			$('[id^=Xmove_]').attr("title", "<?=$ShXmoveTitle?>");
1285
		} else {
1286
			$('[id^=Xmove_]').attr("title", "<?=$XmoveTitle?>");
1287
		}
1288
	});
1289 e969408d Steve Beaver
1290
	$('#selectAll').click(function() {
1291
		var checkedStatus = this.checked;
1292
		$('#ruletable tbody tr').find('td:first :checkbox').each(function() {
1293
		$(this).prop('checked', checkedStatus);
1294
		});
1295 e1e388e4 Viktor G
		buttonsmode('frc', ['del_x', 'toggle_x', 'copy_x']);
1296 e969408d Steve Beaver
	});
1297 2e3018c5 Viktor G
1298
	$("#copyr").click(function() {
1299
		$("#rulescopy").modal('hide');
1300
		$("#dstif").val($("#copyr_dstif").val());
1301 77e16886 jim-p
		$("#convertif").val($("#copyr_convertif").prop('checked'));
1302 2e3018c5 Viktor G
		document.getElementById('mainform').submit();
1303
	});
1304
1305
	$("#cancel_copyr").click(function() {
1306
		$("#rulescopy").modal('hide');
1307
	});
1308
1309 65a0e193 Stephen Beaver
});
1310 8fd9052f Colin Fleming
//]]>
1311 ea5665c7 Sjon Hortensius
</script>
1312 824329d2 Stephen Beaver
1313 c9d46a8e Renato Botelho
<?php include("foot.inc");?>