Project

General

Profile

Download (24.8 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
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("ipsec.inc");
73
require_once("shaper.inc");
74

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

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

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

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

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

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

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

    
101
$if = $_GET['if'];
102

    
103
if ($_POST['if']) {
104
	$if = $_POST['if'];
105
}
106

    
107
$ifdescs = get_configured_interface_with_descr();
108

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

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

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

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

    
138
/* add ipsec interfaces */
139
if (ipsec_enabled() && have_ruleint_access("enc0"))
140
	$iflist["enc0"] = "IPsec";
141

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

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

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

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

    
166
		clear_subsystem_dirty('filter');
167

    
168
		$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"),
169
									"<a href='status_filter_reload.php'>", "</a>");
170
	}
171
}
172

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

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

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

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

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

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

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

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

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

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

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

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

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

    
251
foreach ($tab_array as $dtab) {
252
	if($dtab[1]) {
253
		$bctab = $dtab[0];
254
		break;
255
	}
256
}
257

    
258
$pgtitle = array(gettext("Firewall"), gettext("Rules"), $bctab);
259
$shortcut_section = "firewall";
260

    
261
include("head.inc");
262
$nrules = 0;
263

    
264
if ($savemsg)
265
	print_info_box($savemsg, 'success');
266

    
267
if (is_subsystem_dirty('filter'))
268
	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);
269

    
270

    
271

    
272
display_top_tabs($tab_array);
273

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

    
359
			<tbody class="user-entries">
360
<?php
361
$nrules = 0;
362
for ($i = 0; isset($a_filter[$i]); $i++):
363
	$filterent = $a_filter[$i];
364

    
365
	if ( ($filterent['interface'] != $if && !isset($filterent['floating'])) || (isset($filterent['floating']) && "FloatingRules" != $if) ) {
366
		$display = 'style="display: none;"';
367
	} else {
368
		$display = "";
369
	}
370
?>
371
					<tr id="fr<?=$nrules;?>" <?=$display?> onClick="fr_toggle(<?=$nrules;?>)" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';" <?=(isset($filterent['disabled']) ? ' class="disabled"' : '')?>>
372
						<td >
373
							<input type="checkbox" id="frc<?=$nrules;?>" onClick="fr_toggle(<?=$nrules;?>)" name="rule[]" value="<?=$i;?>"/>
374
						</td>
375

    
376
	<?php
377
		if ($filterent['type'] == "block") {
378
			$iconfn = "times";
379
			$title_text = gettext("traffic is blocked");
380
		} else if ($filterent['type'] == "reject") {
381
			$iconfn = "hand-stop-o";
382
			$title_text = gettext("traffic is rejected");
383
		} else if ($filterent['type'] == "match") {
384
			$iconfn = "filter";
385
			$title_text = gettext("traffic is matched");
386
		} else {
387
			$iconfn = "check";
388
			$title_text = gettext("traffic is passed");
389
		}
390
	?>
391
						<td title="<?=$title_text?>">
392

    
393
							<i class="fa fa-<?=$iconfn?>"></i>
394
	<?php
395
		$isadvset = firewall_check_for_advanced_options($filterent);
396
		if ($isadvset)
397
			print '<i class="fa fa-cog" title="'. gettext("advanced setting") .': '. $isadvset .'"></i>';
398

    
399
		if (isset($filterent['log']))
400
			print '<i class="fa fa-tasks" title="'. gettext("traffic is logged") .'"></i>';
401
	?>
402
						</td>
403
	<?php
404
		$alias = rule_columns_with_alias(
405
			$filterent['source']['address'],
406
			pprint_port($filterent['source']['port']),
407
			$filterent['destination']['address'],
408
			pprint_port($filterent['destination']['port'])
409
		);
410

    
411
		//build Schedule popup box
412
		$a_schedules = &$config['schedules']['schedule'];
413
		$schedule_span_begin = "";
414
		$schedule_span_end = "";
415
		$sched_caption_escaped = "";
416
		$sched_content = "";
417
		$schedstatus = false;
418
		$dayArray = array (gettext('Mon'), gettext('Tues'), gettext('Wed'), gettext('Thur'), gettext('Fri'), gettext('Sat'), gettext('Sun'));
419
		$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'));
420
		if ($config['schedules']['schedule'] != "" && is_array($config['schedules']['schedule'])) {
421
			foreach ($a_schedules as $schedule)
422
			{
423
				if ($schedule['name'] == $filterent['sched']) {
424
					$schedstatus = filter_get_time_based_rule_status($schedule);
425

    
426
					foreach ($schedule['timerange'] as $timerange) {
427
						$tempFriendlyTime = "";
428
						$tempID = "";
429
						$firstprint = false;
430
						if ($timerange) {
431
							$dayFriendly = "";
432
							$tempFriendlyTime = "";
433

    
434
							//get hours
435
							$temptimerange = $timerange['hour'];
436
							$temptimeseparator = strrpos($temptimerange, "-");
437

    
438
							$starttime = substr ($temptimerange, 0, $temptimeseparator);
439
							$stoptime = substr ($temptimerange, $temptimeseparator+1);
440

    
441
							if ($timerange['month']) {
442
								$tempmontharray = explode(",", $timerange['month']);
443
								$tempdayarray = explode(",", $timerange['day']);
444
								$arraycounter = 0;
445
								$firstDayFound = false;
446
								$firstPrint = false;
447
								foreach ($tempmontharray as $monthtmp) {
448
									$month = $tempmontharray[$arraycounter];
449
									$day = $tempdayarray[$arraycounter];
450

    
451
									if (!$firstDayFound)
452
									{
453
										$firstDay = $day;
454
										$firstmonth = $month;
455
										$firstDayFound = true;
456
									}
457

    
458
									$currentDay = $day;
459
									$nextDay = $tempdayarray[$arraycounter+1];
460
									$currentDay++;
461
									if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])) {
462
										if ($firstPrint)
463
											$dayFriendly .= ", ";
464
										$currentDay--;
465
										if ($currentDay != $firstDay)
466
											$dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ;
467
										else
468
											$dayFriendly .=	 $monthArray[$month-1] . " " . $day;
469
										$firstDayFound = false;
470
										$firstPrint = true;
471
									}
472
									$arraycounter++;
473
								}
474
							}
475
							else
476
							{
477
								$tempdayFriendly = $timerange['position'];
478
								$firstDayFound = false;
479
								$tempFriendlyDayArray = explode(",", $tempdayFriendly);
480
								$currentDay = "";
481
								$firstDay = "";
482
								$nextDay = "";
483
								$counter = 0;
484
								foreach ($tempFriendlyDayArray as $day) {
485
									if ($day != "") {
486
										if (!$firstDayFound)
487
										{
488
											$firstDay = $tempFriendlyDayArray[$counter];
489
											$firstDayFound = true;
490
										}
491
										$currentDay =$tempFriendlyDayArray[$counter];
492
										//get next day
493
										$nextDay = $tempFriendlyDayArray[$counter+1];
494
										$currentDay++;
495
										if ($currentDay != $nextDay) {
496
											if ($firstprint)
497
												$dayFriendly .= ", ";
498
											$currentDay--;
499
											if ($currentDay != $firstDay)
500
												$dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
501
											else
502
												$dayFriendly .= $dayArray[$firstDay-1];
503
											$firstDayFound = false;
504
											$firstprint = true;
505
										}
506
										$counter++;
507
									}
508
								}
509
							}
510
							$timeFriendly = $starttime . " - " . $stoptime;
511
							$description = $timerange['rangedescr'];
512
							$sched_content .= $dayFriendly . "; " . $timeFriendly . "<br />";
513
						}
514
					}
515
					#FIXME
516
					$sched_caption_escaped = str_replace("'", "\'", $schedule['descr']);
517
					$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>";
518
					$schedule_span_end = "</u></span>";
519
				}
520
			}
521
		}
522
		$printicon = false;
523
		$alttext = "";
524
		$image = "";
525
		if (!isset($filterent['disabled'])) {
526
			if ($schedstatus) {
527
				if ($iconfn == "block" || $iconfn == "reject") {
528
					$image = "times-circle";
529
					$alttext = gettext("Traffic matching this rule is currently being denied");
530
				} else {
531
					$image = "play-circle";
532
					$alttext = gettext("Traffic matching this rule is currently being allowed");
533
				}
534
				$printicon = true;
535
			} else if ($filterent['sched']) {
536
				if ($iconfn == "block" || $iconfn == "reject")
537
					$image = "times-circle";
538
				else
539
					$image = "times-circle";
540
				$alttext = gettext("This rule is not currently active because its period has expired");
541
				$printicon = true;
542
			}
543
		}
544
	?>
545
				<td>
546
	<?php
547
		if (isset($filterent['ipprotocol'])) {
548
			switch ($filterent['ipprotocol']) {
549
				case "inet":
550
					echo "IPv4 ";
551
					break;
552
				case "inet6":
553
					echo "IPv6 ";
554
					break;
555
				case "inet46":
556
					echo "IPv4+6 ";
557
					break;
558
			}
559
		} else {
560
			echo "IPv4 ";
561
		}
562

    
563
		if (isset($filterent['protocol'])) {
564
			echo strtoupper($filterent['protocol']);
565

    
566
			if (strtoupper($filterent['protocol']) == "ICMP" && !empty($filterent['icmptype'])) {
567
				echo ' <span style="cursor: help;" title="ICMP type: ' .
568
					($filterent['ipprotocol'] == "inet6" ? $icmp6types[$filterent['icmptype']] : $icmptypes[$filterent['icmptype']]) .
569
					'"><u>';
570
				echo $filterent['icmptype'];
571
				echo '</u></span>';
572
			}
573
		} else echo "*";
574

    
575
	?>
576
						</td>
577
						<td>
578
							<?php if (isset($alias['src'])): ?>
579
								<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">
580
							<?php endif; ?>
581
							<?=htmlspecialchars(pprint_address($filterent['source']))?>
582
						</td>
583
						<td>
584
							<?php if (isset($alias['srcport'])): ?>
585
								<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">
586
							<?php endif; ?>
587
							<?=htmlspecialchars(pprint_port($filterent['source']['port']))?>
588
						</td>
589
						<td>
590
							<?php if (isset($alias['dst'])): ?>
591
								<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">
592
							<?php endif; ?>
593
							<?=htmlspecialchars(pprint_address($filterent['destination']))?>
594
						</td>
595
						<td>
596
							<?php if (isset($alias['dstport'])): ?>
597
								<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">
598
							<?php endif; ?>
599
							<?=htmlspecialchars(pprint_port($filterent['destination']['port']))?>
600
						</td>
601
						<td>
602
							<?php if (isset($config['interfaces'][$filterent['gateway']]['descr'])):?>
603
								<?=htmlspecialchars($config['interfaces'][$filterent['gateway']]['descr'])?>
604
							<?php else: ?>
605
								<?=htmlspecialchars(pprint_port($filterent['gateway']))?>
606
							<?php endif; ?>
607
						</td>
608
						<td>
609
							<?php
610
								if (isset($filterent['ackqueue']) && isset($filterent['defaultqueue'])) {
611
									$desc = $filterent['ackqueue'] ;
612
									echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['ackqueue']}&amp;action=show\">{$desc}</a>";
613
									$desc = $filterent['defaultqueue'];
614
									echo "/<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
615
								} else if (isset($filterent['defaultqueue'])) {
616
									$desc = $filterent['defaultqueue'];
617
									echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
618
								} else
619
									echo gettext("none");
620
							?>
621
						</td>
622
						<td>
623
							<?php if ($printicon) { ?>
624
								<i class="fa fa-<?=$image;?>" title="<?=$alttext;?>" alt="icon" />
625
							<?php } ?>
626
							<?=$schedule_span_begin;?><?=htmlspecialchars($filterent['sched']);?>&nbsp;<?=$schedule_span_end;?>
627
						</td>
628
						<td>
629
							<?=htmlspecialchars($filterent['descr']);?>
630
						</td>
631
						<td>
632
						<!-- <?=(isset($filterent['disabled']) ? 'enable' : 'disable')?> -->
633
							<a href="firewall_rules_edit.php?id=<?=$i;?>" class="fa fa-pencil" title="<?=gettext('Edit')?>"></a>
634
							<a href="firewall_rules_edit.php?dup=<?=$i;?>" class="fa fa-clone" title="<?=gettext('Copy')?>"></a>
635
<?php if (isset($filterent['disabled'])) {
636
?>
637
							<a href="?act=toggle&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>" class="fa fa-check-square-o" title="<?=gettext('Enable')?>"></a>
638
<?php } else {
639
?>
640
							<a href="?act=toggle&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>" class="fa fa-ban" title="<?=gettext('Disable')?>"></a>
641
<?php }
642
?>
643
							<a href="?act=del&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>" class="fa fa-trash" title="<?=gettext('Delete')?>"></a>
644
						</td>
645
					</tr>
646
<?php
647
		$nrules++;
648
		endfor;
649
?>
650
				</tbody>
651
			</table>
652
		</div>
653
	</div>
654

    
655
<?php if ($nrules == 0): ?>
656
	<div class="alert alert-warning" role="alert">
657
		<p>
658
		<?php if ($_REQUEST['if'] == "FloatingRules"): ?>
659
			<?=gettext("No floating rules are currently defined.");?>
660
		<?php else: ?>
661
			<?=gettext("No rules are currently defined for this interface");?><br />
662
			<?=gettext("All incoming connections on this interface will be blocked until you add pass rules.");?>
663
		<?php endif;?>
664
			<?=gettext("Click the button to add a new rule.");?>
665
		</p>
666
	</div>
667
<?php endif;?>
668

    
669
	<nav class="action-buttons">
670
		<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')?>">
671
			<i class="fa fa-level-up icon-embed-btn"></i>
672
			<?=gettext("Add");?>
673
		</a>
674
		<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')?>">
675
			<i class="fa fa-level-down icon-embed-btn"></i>
676
			<?=gettext("Add");?>
677
		</a>
678
		<button name="del_x" type="submit" class="btn btn-danger btn-sm" value="<?=gettext("Delete selected rules"); ?>" title="<?=gettext('Delete selected rules')?>">
679
			<i class="fa fa-trash icon-embed-btn"></i>
680
			<?=gettext("Delete"); ?>
681
		</button>
682
		<button type="submit" id="order-store" name="order-store" class="btn btn-sm btn-primary" value="store changes" disabled title="<?=gettext('Save rule order')?>">
683
			<i class="fa fa-save icon-embed-btn"></i>
684
			<?=gettext("Save")?>
685
		</button>
686
	</nav>
687
</form>
688

    
689
<div id="infoblock">
690
	<div class="alert alert-info clearfix" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><div class="pull-left">
691
		<dl class="dl-horizontal responsive">
692
		<!-- Legend -->
693
			<dt><?=gettext('Legend')?></dt>				<dd></dd>
694
			<dt><i class="fa fa-check"></i></dt>		<dd><?=gettext("Pass");?></dd>
695
			<dt><i class="fa fa-filter"></i></dt>	<dd><?=gettext("Match");?></dd>
696
			<dt><i class="fa fa-times"></i></dt>	<dd><?=gettext("Block");?></dd>
697
			<dt><i class="fa fa-hand-stop-o"></i></dt>		<dd><?=gettext("Reject");?></dd>
698
			<dt><i class="fa fa-tasks"></i></dt>	<dd> <?=gettext("Log");?></dd>
699
			<dt><i class="fa fa-cog"></i></dt>		<dd> <?=gettext("Advanced filter");?></dd>
700
		</dl>
701

    
702
<?php
703
	if ("FloatingRules" != $if)
704
		print(gettext("Rules are evaluated on a first-match basis (i.e. " .
705
			"the action of the first rule to match a packet will be executed). ") . '<br />' .
706
			gettext("This means that if you use block rules, you'll have to pay attention " .
707
			"to the rule order. Everything that isn't explicitly passed is blocked " .
708
			"by default. "));
709
	else
710
		print(gettext("Floating rules are evaluated on a first-match basis (i.e. " .
711
			"the action of the first rule to match a packet will be executed) only " .
712
			"if the 'quick' option is checked on a rule. Otherwise they will only match if no " .
713
			"other rules match. Pay close attention to the rule order and options " .
714
			"chosen. If no rule here matches, the per-interface or default rules are used. "));
715
?>
716
	</div>
717
</div>
718

    
719
<script type="text/javascript">
720
//<![CDATA[
721
events.push(function() {
722

    
723
	// Make rules sortable
724
	$('table tbody.user-entries').sortable({
725
		cursor: 'grabbing',
726
		update: function(event, ui) {
727
			$('#order-store').removeAttr('disabled');
728
		}
729
	});
730

    
731
	// Check all of the rule checkboxes so that their values are posted
732
	$('#order-store').click(function () {
733
	   $('[id^=frc]').prop('checked', true);
734
	});
735
});
736
//]]>
737
</script>
738

    
739
<?php include("foot.inc");?>
(59-59/228)