Project

General

Profile

Download (23.9 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	firewall_rules.php
4
*/
5
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *
8
 *	Some or all of this file is based on the m0n0wall project which is
9
 *	Copyright (c)  2004 Manuel Kasper (BSD 2 clause)
10
 *
11
 *	Redistribution and use in source and binary forms, with or without modification,
12
 *	are permitted provided that the following conditions are met:
13
 *
14
 *	1. Redistributions of source code must retain the above copyright notice,
15
 *		this list of conditions and the following disclaimer.
16
 *
17
 *	2. Redistributions in binary form must reproduce the above copyright
18
 *		notice, this list of conditions and the following disclaimer in
19
 *		the documentation and/or other materials provided with the
20
 *		distribution.
21
 *
22
 *	3. All advertising materials mentioning features or use of this software
23
 *		must display the following acknowledgment:
24
 *		"This product includes software developed by the pfSense Project
25
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
26
 *
27
 *	4. The names "pfSense" and "pfSense Project" must not be used to
28
 *		 endorse or promote products derived from this software without
29
 *		 prior written permission. For written permission, please contact
30
 *		 coreteam@pfsense.org.
31
 *
32
 *	5. Products derived from this software may not be called "pfSense"
33
 *		nor may "pfSense" appear in their names without prior written
34
 *		permission of the Electric Sheep Fencing, LLC.
35
 *
36
 *	6. Redistributions of any form whatsoever must retain the following
37
 *		acknowledgment:
38
 *
39
 *	"This product includes software developed by the pfSense Project
40
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
41
 *
42
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
43
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
46
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
54
 *
55
 *	====================================================================
56
 *
57
 */
58
/*
59
	pfSense_MODULE: filter
60
*/
61

    
62
##|+PRIV
63
##|*IDENT=page-firewall-rules
64
##|*NAME=Firewall: Rules page
65
##|*DESCR=Allow access to the 'Firewall: Rules' page.
66
##|*MATCH=firewall_rules.php*
67
##|-PRIV
68

    
69
require("guiconfig.inc");
70
require_once("functions.inc");
71
require_once("filter.inc");
72
require_once("shaper.inc");
73

    
74
$pgtitle = array(gettext("Firewall"), gettext("Rules"));
75
$shortcut_section = "firewall";
76

    
77
function delete_nat_association($id) {
78
	global $config;
79

    
80
	if (!$id || !is_array($config['nat']['rule'])) {
81
		return;
82
	}
83

    
84
	$a_nat = &$config['nat']['rule'];
85

    
86
	foreach ($a_nat as &$natent) {
87
		if ($natent['associated-rule-id'] == $id) {
88
			$natent['associated-rule-id'] = '';
89
		}
90
	}
91
}
92

    
93
if (!is_array($config['filter']['rule'])) {
94
	$config['filter']['rule'] = array();
95
}
96

    
97
filter_rules_sort();
98
$a_filter = &$config['filter']['rule'];
99

    
100
$if = $_GET['if'];
101
if ($_POST['if']) {
102
	$if = $_POST['if'];
103
}
104

    
105
$ifdescs = get_configured_interface_with_descr();
106

    
107
/* add group interfaces */
108
if (is_array($config['ifgroups']['ifgroupentry'])) {
109
	foreach ($config['ifgroups']['ifgroupentry'] as $ifgen) {
110
		if (have_ruleint_access($ifgen['ifname'])) {
111
			$iflist[$ifgen['ifname']] = $ifgen['ifname'];
112
		}
113
	}
114
}
115

    
116
foreach ($ifdescs as $ifent => $ifdesc) {
117
	if (have_ruleint_access($ifent)) {
118
		$iflist[$ifent] = $ifdesc;
119
	}
120
}
121

    
122
if ($config['l2tp']['mode'] == "server") {
123
	if (have_ruleint_access("l2tp")) {
124
		$iflist['l2tp'] = "L2TP VPN";
125
	}
126
}
127

    
128
if (is_array($config['pppoes']['pppoe'])) {
129
	foreach ($config['pppoes']['pppoe'] as $pppoes) {
130
		if (($pppoes['mode'] == 'server') && have_ruleint_access("pppoe")) {
131
			$iflist['pppoe'] = "PPPoE Server";
132
		}
133
	}
134
}
135

    
136
/* add ipsec interfaces */
137
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) {
138
	if (have_ruleint_access("enc0")) {
139
		$iflist["enc0"] = "IPsec";
140
	}
141
}
142

    
143
/* add openvpn/tun interfaces */
144
if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) {
145
	$iflist["openvpn"] = "OpenVPN";
146
}
147

    
148
if (!$if || !isset($iflist[$if])) {
149
	if ("any" == $if) {
150
		$if = "FloatingRules";
151
	} else if ("FloatingRules" != $if) {
152
		if (isset($iflist['wan'])) {
153
			$if = "wan";
154
		} else {
155
			$if = "FloatingRules";
156
		}
157
	}
158
}
159

    
160
if ($_POST) {
161
	$pconfig = $_POST;
162

    
163
	if ($_POST['apply']) {
164
		$retval = 0;
165
		$retval = filter_configure();
166

    
167
		clear_subsystem_dirty('filter');
168

    
169
		$savemsg = sprintf(gettext("The settings have been applied. The firewall rules are now reloading in the background.<br />You can also %s monitor %s the reload progress"), "<a href='status_filter_reload.php'>", "</a>");
170
	}
171
}
172

    
173

    
174
if ($_GET['act'] == "del") {
175
	if ($a_filter[$_GET['id']]) {
176
		if (!empty($a_filter[$_GET['id']]['associated-rule-id'])) {
177
			delete_nat_association($a_filter[$_GET['id']]['associated-rule-id']);
178
		}
179
		unset($a_filter[$_GET['id']]);
180
		if (write_config()) {
181
			mark_subsystem_dirty('filter');
182
		}
183

    
184
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
185
		exit;
186
	}
187
}
188

    
189
// Handle save msg if defined
190
if ($_REQUEST['savemsg']) {
191
	$savemsg = htmlentities($_REQUEST['savemsg']);
192
}
193

    
194
if (isset($_POST['del_x'])) {
195
	/* delete selected rules */
196
	$deleted = false;
197

    
198
	if (is_array($_POST['rule']) && count($_POST['rule'])) {
199
		foreach ($_POST['rule'] as $rulei) {
200
			delete_nat_association($a_filter[$rulei]['associated-rule-id']);
201
			unset($a_filter[$rulei]);
202
			$deleted = true;
203
		}
204

    
205
		if($deleted) {
206
			if (write_config()) {
207
				mark_subsystem_dirty('filter');
208
			}
209
		}
210

    
211
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
212
		exit;
213
	}
214
} else if ($_GET['act'] == "toggle") {
215
	if ($a_filter[$_GET['id']]) {
216
		if (isset($a_filter[$_GET['id']]['disabled'])) {
217
			unset($a_filter[$_GET['id']]['disabled']);
218
		} else {
219
			$a_filter[$_GET['id']]['disabled'] = true;
220
		}
221
		if (write_config()) {
222
			mark_subsystem_dirty('filter');
223
		}
224

    
225
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
226
		exit;
227
	}
228
} else if($_POST['order-store']) {
229
	/* update rule order, POST[rule] is an array of ordered IDs */
230
	if (is_array($_POST['rule']) && !empty($_POST['rule'])) {
231
		$a_filter_new = array();
232

    
233
		// if a rule is not in POST[rule], it has been deleted by the user
234
		foreach ($_POST['rule'] as $id)
235
			$a_filter_new[] = $a_filter[$id];
236

    
237
		$a_filter = $a_filter_new;
238
		if (write_config()) {
239
			mark_subsystem_dirty('filter');
240
		}
241

    
242
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
243
		exit;
244
	}
245
}
246

    
247
include("head.inc");
248
$nrules = 0;
249

    
250
if ($savemsg)
251
	print_info_box($savemsg, 'success');
252

    
253
if (is_subsystem_dirty('filter'))
254
	print_info_box_np(gettext("The firewall rule configuration has been changed.") . "<br />" . gettext("You must apply the changes in order for them to take effect."), "apply", "", true);
255

    
256
$tab_array = array(array(gettext("Floating"), ("FloatingRules" == $if), "firewall_rules.php?if=FloatingRules"));
257

    
258
foreach ($iflist as $ifent => $ifname)
259
	$tab_array[] = array($ifname, ($ifent == $if), "firewall_rules.php?if={$ifent}");
260

    
261
display_top_tabs($tab_array);
262

    
263
?>
264
<form method="post">
265
	<div class="panel panel-default">
266
		<div class="panel-heading"><?=gettext("Rules (Drag to change order)")?></div>
267
		<div id="mainarea" class="table-responsive panel-body">
268
			<table name="ruletable" class="table table-hover table-condensed">
269
				<thead>
270
					<tr>
271
						<th><!-- checkbox --></th>
272
						<th><!-- status icons --></th>
273
						<th><?=gettext("Proto")?></th>
274
						<th><?=gettext("Source")?></th>
275
						<th><?=gettext("Port")?></th>
276
						<th><?=gettext("Destination")?></th>
277
						<th><?=gettext("Port")?></th>
278
						<th><?=gettext("Gateway")?></th>
279
						<th><?=gettext("Queue")?></th>
280
						<th><?=gettext("Schedule")?></th>
281
						<th><?=gettext("Description")?></th>
282
						<th><?=gettext("Actions")?></th>
283
					</tr>
284
				</thead>
285
				<tbody>
286
<?php
287
		// 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.
288
	if (!isset($config['system']['webgui']['noantilockout']) &&
289
		(((count($config['interfaces']) > 1) && ($if == 'lan')) ||
290
		 ((count($config['interfaces']) == 1) && ($if == 'wan')))):
291
		$alports = implode('<br />', filter_get_antilockout_ports(true));
292
?>
293
					<tr id="antilockout">
294
						<td></td>
295
						<td title="<?=gettext("traffic is passed")?>"><i class="icon icon-ok"></i></td>
296
						<td>*</td>
297
						<td>*</td>
298
						<td>*</td>
299
						<td><?=$iflist[$if];?> Address</td>
300
						<td><?=$alports?></td>
301
						<td>*</td>
302
						<td>*</td>
303
						<td></td>
304
						<td><?=gettext("Anti-Lockout Rule");?></td>
305
						<td>
306
							<a href="system_advanced_admin.php" class="fa fa-cog" title="<?=gettext("Settings");?>"></a>
307
						</td>
308
					</tr>
309
<?php endif;?>
310
<?php if (isset($config['interfaces'][$if]['blockpriv'])): ?>
311
					<tr id="frrfc1918">
312
						<td></td>
313
						<td title="<?=gettext("traffic is blocked")?>"><i class="icon icon-remove"></i></td>
314
						<td>*</td>
315
						<td><?=gettext("RFC 1918 networks");?></td>
316
						<td>*</td>
317
						<td>*</td>
318
						<td>*</td>
319
						<td>*</td>
320
						<td>*</td>
321
						<td></td>
322
						<td><?=gettext("Block private networks");?></td>
323
						<td>
324
							<a href="interfaces.php?if=<?=htmlspecialchars($if)?>" class="fa fa-cog" title="<?=gettext("Settings");?>"></a>
325
						</td>
326
					</tr>
327
<?php endif;?>
328
<?php if (isset($config['interfaces'][$if]['blockbogons'])): ?>
329
					<tr id="frrfc1918">
330
					<td></td>
331
						<td title="<?=gettext("traffic is blocked")?>"><i class="icon icon-remove"></i></td>
332
						<td>*</td>
333
						<td><?=gettext("Reserved/not assigned by IANA");?></td>
334
						<td>*</td>
335
						<td>*</td>
336
						<td>*</td>
337
						<td>*</td>
338
						<td>*</td>
339
						<td>*</td>
340
						<td><?=gettext("Block bogon networks");?></td>
341
						<td>
342
							<a href="interfaces.php?if=<?=htmlspecialchars($if)?>" class="fa fa-cog" title="<?=gettext("Settings");?>"></a>
343
						</td>
344
					</tr>
345
<?php endif;?>
346
			</tbody>
347

    
348
			<tbody class="user-entries">
349
<?php
350
$nrules = 0;
351
for ($i = 0; isset($a_filter[$i]); $i++):
352
	$filterent = $a_filter[$i];
353

    
354
	if ($filterent['interface'] != $if && !isset($filterent['floating']))
355
		continue;
356

    
357
	if (isset($filterent['floating']) && "FloatingRules" != $if)
358
		continue;
359
?>
360
					<tr id="fr<?=$nrules;?>" onClick="fr_toggle(<?=$nrules;?>)" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';" <?=(isset($filterent['disabled']) ? ' class="disabled"' : '')?>>
361
						<td >
362
							<input type="checkbox" id="frc<?=$nrules;?>" onClick="fr_toggle(<?=$nrules;?>)" name="rule[]" value="<?=$i;?>"/>
363
						</td>
364

    
365
						<td title="<?=gettext("traffic is ").$filterent['type']."ed"?>">
366

    
367
	<?php
368
		if ($filterent['type'] == "block")
369
			$iconfn = "remove";
370
		else if ($filterent['type'] == "reject")
371
			$iconfn = "fire";
372
		else if ($filterent['type'] == "match")
373
			$iconfn = "filter";
374
		else
375
			$iconfn = "ok";
376
	?>
377
					<i class="icon icon-<?=$iconfn?>"></i>
378
	<?php
379
		$isadvset = firewall_check_for_advanced_options($filterent);
380
		if ($isadvset)
381
			print '<i class="icon icon-cog" title="'. gettext("advanced setting") .': '. $isadvset .'"></i>';
382

    
383
		if (isset($filterent['log']))
384
			print '<i class="icon icon-tasks" title="'. gettext("traffic is logged") .'"></i>';
385
	?>
386
				</td>
387
	<?php
388
		$alias = rule_columns_with_alias(
389
			$filterent['source']['address'],
390
			pprint_port($filterent['source']['port']),
391
			$filterent['destination']['address'],
392
			pprint_port($filterent['destination']['port'])
393
		);
394

    
395
		//build Schedule popup box
396
		$a_schedules = &$config['schedules']['schedule'];
397
		$schedule_span_begin = "";
398
		$schedule_span_end = "";
399
		$sched_caption_escaped = "";
400
		$sched_content = "";
401
		$schedstatus = false;
402
		$dayArray = array (gettext('Mon'), gettext('Tues'), gettext('Wed'), gettext('Thur'), gettext('Fri'), gettext('Sat'), gettext('Sun'));
403
		$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'));
404
		if ($config['schedules']['schedule'] != "" && is_array($config['schedules']['schedule'])) {
405
			foreach ($a_schedules as $schedule)
406
			{
407
				if ($schedule['name'] == $filterent['sched']) {
408
					$schedstatus = filter_get_time_based_rule_status($schedule);
409

    
410
					foreach ($schedule['timerange'] as $timerange) {
411
						$tempFriendlyTime = "";
412
						$tempID = "";
413
						$firstprint = false;
414
						if ($timerange) {
415
							$dayFriendly = "";
416
							$tempFriendlyTime = "";
417

    
418
							//get hours
419
							$temptimerange = $timerange['hour'];
420
							$temptimeseparator = strrpos($temptimerange, "-");
421

    
422
							$starttime = substr ($temptimerange, 0, $temptimeseparator);
423
							$stoptime = substr ($temptimerange, $temptimeseparator+1);
424

    
425
							if ($timerange['month']) {
426
								$tempmontharray = explode(",", $timerange['month']);
427
								$tempdayarray = explode(",", $timerange['day']);
428
								$arraycounter = 0;
429
								$firstDayFound = false;
430
								$firstPrint = false;
431
								foreach ($tempmontharray as $monthtmp) {
432
									$month = $tempmontharray[$arraycounter];
433
									$day = $tempdayarray[$arraycounter];
434

    
435
									if (!$firstDayFound)
436
									{
437
										$firstDay = $day;
438
										$firstmonth = $month;
439
										$firstDayFound = true;
440
									}
441

    
442
									$currentDay = $day;
443
									$nextDay = $tempdayarray[$arraycounter+1];
444
									$currentDay++;
445
									if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])) {
446
										if ($firstPrint)
447
											$dayFriendly .= ", ";
448
										$currentDay--;
449
										if ($currentDay != $firstDay)
450
											$dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ;
451
										else
452
											$dayFriendly .=	 $monthArray[$month-1] . " " . $day;
453
										$firstDayFound = false;
454
										$firstPrint = true;
455
									}
456
									$arraycounter++;
457
								}
458
							}
459
							else
460
							{
461
								$tempdayFriendly = $timerange['position'];
462
								$firstDayFound = false;
463
								$tempFriendlyDayArray = explode(",", $tempdayFriendly);
464
								$currentDay = "";
465
								$firstDay = "";
466
								$nextDay = "";
467
								$counter = 0;
468
								foreach ($tempFriendlyDayArray as $day) {
469
									if ($day != "") {
470
										if (!$firstDayFound)
471
										{
472
											$firstDay = $tempFriendlyDayArray[$counter];
473
											$firstDayFound = true;
474
										}
475
										$currentDay =$tempFriendlyDayArray[$counter];
476
										//get next day
477
										$nextDay = $tempFriendlyDayArray[$counter+1];
478
										$currentDay++;
479
										if ($currentDay != $nextDay) {
480
											if ($firstprint)
481
												$dayFriendly .= ", ";
482
											$currentDay--;
483
											if ($currentDay != $firstDay)
484
												$dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
485
											else
486
												$dayFriendly .= $dayArray[$firstDay-1];
487
											$firstDayFound = false;
488
											$firstprint = true;
489
										}
490
										$counter++;
491
									}
492
								}
493
							}
494
							$timeFriendly = $starttime . " - " . $stoptime;
495
							$description = $timerange['rangedescr'];
496
							$sched_content .= $dayFriendly . "; " . $timeFriendly . "<br />";
497
						}
498
					}
499
					#FIXME
500
					$sched_caption_escaped = str_replace("'", "\'", $schedule['descr']);
501
					$schedule_span_begin = "<span style=\"cursor: help;\" onmouseover=\"domTT_activate(this, event, 'content', '<h1>{$sched_caption_escaped}</h1><p>{$sched_content}</p>', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\" onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\"><u>";
502
					$schedule_span_end = "</u></span>";
503
				}
504
			}
505
		}
506
		$printicon = false;
507
		$alttext = "";
508
		$image = "";
509
		if (!isset($filterent['disabled'])) {
510
			if ($schedstatus) {
511
				if ($iconfn == "block" || $iconfn == "reject") {
512
					$image = "icon_block";
513
					$alttext = gettext("Traffic matching this rule is currently being denied");
514
				} else {
515
					$image = "icon_pass";
516
					$alttext = gettext("Traffic matching this rule is currently being allowed");
517
				}
518
				$printicon = true;
519
			} else if ($filterent['sched']) {
520
				if ($iconfn == "block" || $iconfn == "reject")
521
					$image = "icon_block_d";
522
				else
523
					$image = "icon_block";
524
				$alttext = gettext("This rule is not currently active because its period has expired");
525
				$printicon = true;
526
			}
527
		}
528
	?>
529
				<td>
530
	<?php
531
		if (isset($filterent['ipprotocol'])) {
532
			switch ($filterent['ipprotocol']) {
533
				case "inet":
534
					echo "IPv4 ";
535
					break;
536
				case "inet6":
537
					echo "IPv6 ";
538
					break;
539
				case "inet46":
540
					echo "IPv4+6 ";
541
					break;
542
			}
543
		} else {
544
			echo "IPv4 ";
545
		}
546

    
547
		if (isset($filterent['protocol'])) {
548
			echo strtoupper($filterent['protocol']);
549

    
550
			if (strtoupper($filterent['protocol']) == "ICMP" && !empty($filterent['icmptype'])) {
551
				echo ' <span style="cursor: help;" title="ICMP type: ' .
552
					($filterent['ipprotocol'] == "inet6" ? $icmp6types[$filterent['icmptype']] : $icmptypes[$filterent['icmptype']]) .
553
					'"><u>';
554
				echo $filterent['icmptype'];
555
				echo '</u></span>';
556
			}
557
		} else echo "*";
558

    
559
	?>
560
						</td>
561
						<td>
562
							<?php if (isset($alias['src'])): ?>
563
								<a href="/firewall_aliases_edit.php?id=<?=$alias['src']?>" data-toggle="popover" data-trigger="hover focus" title="Alias details" data-content="<?=alias_info_popup($alias['src'])?>" data-html="true">
564
							<?php endif; ?>
565
							<?=htmlspecialchars(pprint_address($filterent['source']))?>
566
						</td>
567
						<td>
568
							<?php if (isset($alias['srcport'])): ?>
569
								<a href="/firewall_aliases_edit.php?id=<?=$alias['srcport']?>" data-toggle="popover" data-trigger="hover focus" title="Alias details" data-content="<?=alias_info_popup($alias['srcport'])?>" data-html="true">
570
							<?php endif; ?>
571
							<?=htmlspecialchars(pprint_port($filterent['source']['port']))?>
572
						</td>
573
						<td>
574
							<?php if (isset($alias['dst'])): ?>
575
								<a href="/firewall_aliases_edit.php?id=<?=$alias['dst']?>" data-toggle="popover" data-trigger="hover focus" title="Alias details" data-content="<?=alias_info_popup($alias['dst'])?>" data-html="true">
576
							<?php endif; ?>
577
							<?=htmlspecialchars(pprint_address($filterent['destination']))?>
578
						</td>
579
						<td>
580
							<?php if (isset($alias['dstport'])): ?>
581
								<a href="/firewall_aliases_edit.php?id=<?=$alias['dstport']?>" data-toggle="popover" data-trigger="hover focus" title="Alias details" data-content="<?=alias_info_popup($alias['dstport'])?>" data-html="true">
582
							<?php endif; ?>
583
							<?=htmlspecialchars(pprint_port($filterent['destination']['port']))?>
584
						</td>
585
						<td>
586
							<?php if (isset($config['interfaces'][$filterent['gateway']]['descr'])):?>
587
								<?=htmlspecialchars($config['interfaces'][$filterent['gateway']]['descr'])?>
588
							<?php else: ?>
589
								<?=htmlspecialchars(pprint_port($filterent['gateway']))?>
590
							<?php endif; ?>
591
						</td>
592
						<td>
593
							<?php
594
								if (isset($filterent['ackqueue']) && isset($filterent['defaultqueue'])) {
595
									$desc = $filterent['ackqueue'] ;
596
									echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['ackqueue']}&amp;action=show\">{$desc}</a>";
597
									$desc = $filterent['defaultqueue'];
598
									echo "/<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
599
								} else if (isset($filterent['defaultqueue'])) {
600
									$desc = $filterent['defaultqueue'];
601
									echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
602
								} else
603
									echo gettext("none");
604
							?>
605
						</td>
606
						<td>
607
							<?php if ($printicon) { ?>
608
								<i class="icon-large <?=$image;?>" title="<?=$alttext;?>" alt="icon" />
609
							<?php } ?>
610
							<?=$schedule_span_begin;?><?=htmlspecialchars($filterent['sched']);?>&nbsp;<?=$schedule_span_end;?>
611
						</td>
612
						<td>
613
							<?=htmlspecialchars($filterent['descr']);?>
614
						</td>
615
						<td>
616
						<!-- <?=(isset($filterent['disabled']) ? 'enable' : 'disable')?> -->
617
							<a href="firewall_rules_edit.php?id=<?=$i;?>" class="fa fa-pencil" title="<?=gettext('Edit')?>"></a>
618
							<a href="firewall_rules_edit.php?dup=<?=$i;?>" class="fa fa-clone" title="<?=gettext('Copy')?>"></a>
619
<?php if (isset($filterent['disabled'])) {
620
?>
621
							<a href="?act=toggle&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>" class="fa fa-check-square-o" title="<?=gettext('Enable')?>"></a>
622
<?php } else {
623
?>
624
							<a href="?act=toggle&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>" class="fa fa-ban" title="<?=gettext('Disable')?>"></a>
625
<?php }
626
?>
627
							<a href="?act=del&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>" class="fa fa-trash" title="<?=gettext('Delete')?>"></a>
628
						</td>
629
					</tr>
630
<?php
631
		$nrules++;
632
		endfor;
633
?>
634
				</tbody>
635
			</table>
636
		</div>
637
	</div>
638

    
639
<?php if ($nrules == 0): ?>
640
	<div class="alert alert-warning" role="alert">
641
		<p>
642
		<?php if ($_REQUEST['if'] == "FloatingRules"): ?>
643
			<?=gettext("No floating rules are currently defined.");?>
644
		<?php else: ?>
645
			<?=gettext("No rules are currently defined for this interface");?><br />
646
			<?=gettext("All incoming connections on this interface will be blocked until you add pass rules.");?>
647
		<?php endif;?>
648
			<?=gettext("Click the button to add a new rule.");?>
649
		</p>
650
	</div>
651
<?php endif;?>
652

    
653
	<nav class="action-buttons">
654
		<a href="firewall_rules_edit.php?if=<?=htmlspecialchars($if);?>" role="button" class="btn btn-sm btn-success">
655
			<i class="fa fa-plus icon-embed-btn"></i>
656
			<?=gettext("Add");?>
657
		</a>
658
		<button name="del_x" type="submit" class="btn btn-danger btn-sm" value="<?=gettext("Delete selected rules"); ?>">
659
			<i class="fa fa-trash icon-embed-btn"></i>
660
			<?=gettext("Delete"); ?>
661
		</button>
662
		<button type="submit" id="order-store" name="order-store" class="btn btn-sm btn-primary" value="store changes" disabled="disabled">
663
			<i class="fa fa-save icon-embed-btn"></i>
664
			<?=gettext("Save")?>
665
		</button>
666
	</nav>
667
</form>
668
<!-- Legend -->
669
<div>
670
	<dl class="dl-horizontal responsive">
671
		<dt><?=gettext('Legend')?></dt>				<dd></dd>
672
		<dt><i class="icon icon-ok"></i></dt>		<dd><?=gettext("pass");?></dd>
673
		<dt><i class="icon icon-filter"></i></dt>	<dd><?=gettext("match");?></dd>
674
		<dt><i class="icon icon-remove"></i></dt>	<dd><?=gettext("block");?></dd>
675
		<dt><i class="icon icon-fire"></i></dt>		<dd><?=gettext("reject");?></dd>
676
		<dt><i class="icon icon-tasks"></i></dt>	<dd> <?=gettext("log");?></dd>
677
		<dt><i class="icon icon-cog"></i></dt>		<dd> <?=gettext("advanced filter");?></dd>
678
	</dl>
679
</div>
680

    
681
<div id="infoblock">
682
	<?php
683
	if ("FloatingRules" != $if)
684
		print_info_box(gettext("Rules are evaluated on a first-match basis (i.e. " .
685
			"the action of the first rule to match a packet will be executed). ") . '<br />' .
686
			gettext("This means that if you use block rules, you'll have to pay attention " .
687
			"to the rule order. Everything that isn't explicitly passed is blocked " .
688
			"by default. "), info);
689
	else
690
		print_info_box(gettext("Floating rules are evaluated on a first-match basis (i.e. " .
691
			"the action of the first rule to match a packet will be executed) only " .
692
			"if the 'quick' option is checked on a rule. Otherwise they will only apply if no " .
693
			"other rules match. Pay close attention to the rule order and options " .
694
			"chosen. If no rule here matches, the per-interface or default rules are used. "), info);
695
	?>
696
</div>
697
<script>
698

    
699
events.push(function() {
700

    
701
	stripe_table();
702

    
703
	// Make rules sortable
704
	$('table tbody.user-entries').sortable({
705
		cursor: 'grabbing',
706
		update: function(event, ui) {
707
			$('#order-store').removeAttr('disabled');
708
			stripe_table();
709
		}
710
	});
711

    
712
	// Check all of the rule checkboxes so that their values are posted
713
	$('#order-store').click(function () {
714
	   $('[id^=frc]').prop('checked', true);
715
	});
716
});
717
</script>
718
<?php include("foot.inc");?>
(60-60/234)