Project

General

Profile

Download (22.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	firewall_rules.php
5
	part of pfSense (https://www.pfsense.org)
6
	Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
7
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
8

    
9
	originally part of m0n0wall (http://m0n0.ch/wall)
10
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
	All rights reserved.
12

    
13
	Redistribution and use in source and binary forms, with or without
14
	modification, are permitted provided that the following conditions are met:
15

    
16
	1. Redistributions of source code must retain the above copyright notice,
17
	   this list of conditions and the following disclaimer.
18

    
19
	2. Redistributions in binary form must reproduce the above copyright
20
	   notice, this list of conditions and the following disclaimer in the
21
	   documentation and/or other materials provided with the distribution.
22

    
23
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
	POSSIBILITY OF SUCH DAMAGE.
33
*/
34
/*
35
	pfSense_MODULE:	filter
36
*/
37

    
38
##|+PRIV
39
##|*IDENT=page-firewall-rules
40
##|*NAME=Firewall: Rules page
41
##|*DESCR=Allow access to the 'Firewall: Rules' page.
42
##|*MATCH=firewall_rules.php*
43
##|-PRIV
44

    
45
require("guiconfig.inc");
46
require_once("functions.inc");
47
require_once("filter.inc");
48
require_once("shaper.inc");
49

    
50
$pgtitle = array(gettext("Firewall"),gettext("Rules"));
51
$shortcut_section = "firewall";
52

    
53
function delete_nat_association($id) {
54
	global $config;
55

    
56
	if (!$id || !is_array($config['nat']['rule']))
57
		return;
58

    
59
	$a_nat = &$config['nat']['rule'];
60

    
61
	foreach ($a_nat as &$natent)
62
		if ($natent['associated-rule-id'] == $id)
63
			$natent['associated-rule-id'] = '';
64
}
65

    
66
if (!is_array($config['filter']['rule'])) {
67
	$config['filter']['rule'] = array();
68
}
69
filter_rules_sort();
70
$a_filter = &$config['filter']['rule'];
71

    
72
$if = $_GET['if'];
73
if ($_POST['if'])
74
	$if = $_POST['if'];
75

    
76
$ifdescs = get_configured_interface_with_descr();
77

    
78
/* add group interfaces */
79
if (is_array($config['ifgroups']['ifgroupentry']))
80
	foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
81
		if (have_ruleint_access($ifgen['ifname']))
82
			$iflist[$ifgen['ifname']] = $ifgen['ifname'];
83

    
84
foreach ($ifdescs as $ifent => $ifdesc)
85
	if(have_ruleint_access($ifent))
86
		$iflist[$ifent] = $ifdesc;
87

    
88
if ($config['l2tp']['mode'] == "server")
89
	if(have_ruleint_access("l2tp"))
90
		$iflist['l2tp'] = "L2TP VPN";
91

    
92
if ($config['pptpd']['mode'] == "server")
93
	if(have_ruleint_access("pptp"))
94
		$iflist['pptp'] = "PPTP VPN";
95

    
96
if (is_array($config['pppoes']['pppoe'])) {
97
	foreach ($config['pppoes']['pppoe'] as $pppoes)
98
		if (($pppoes['mode'] == 'server') && have_ruleint_access("pppoe"))
99
			$iflist['pppoe'] = "PPPoE Server";
100
}
101

    
102
/* add ipsec interfaces */
103
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']))
104
	if(have_ruleint_access("enc0"))
105
		$iflist["enc0"] = "IPsec";
106

    
107
/* add openvpn/tun interfaces */
108
if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
109
	$iflist["openvpn"] = "OpenVPN";
110

    
111
pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/interfaces_override");
112

    
113
if (!$if || !isset($iflist[$if])) {
114
	if ("any" == $if)
115
		$if = "FloatingRules";
116
	else if ("FloatingRules" != $if) {
117
		if (isset($iflist['wan']))
118
			$if = "wan";
119
		else
120
			$if = "FloatingRules";
121
	}
122
}
123

    
124
if ($_POST) {
125

    
126
	$pconfig = $_POST;
127

    
128
	if ($_POST['apply']) {
129
		$retval = 0;
130
		$retval = filter_configure();
131

    
132
		clear_subsystem_dirty('filter');
133

    
134
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/apply");
135

    
136
		$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>");
137
	}
138
}
139

    
140
if ($_GET['act'] == "del") {
141
	if ($a_filter[$_GET['id']]) {
142
		if (!empty($a_filter[$_GET['id']]['associated-rule-id'])) {
143
			delete_nat_association($a_filter[$_GET['id']]['associated-rule-id']);
144
		}
145
		unset($a_filter[$_GET['id']]);
146
		if (write_config())
147
			mark_subsystem_dirty('filter');
148
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
149
		exit;
150
	}
151
}
152

    
153
// Handle save msg if defined
154
if($_REQUEST['savemsg'])
155
	$savemsg = htmlentities($_REQUEST['savemsg']);
156

    
157
if (isset($_POST['del_x'])) {
158
	/* delete selected rules */
159
	if (is_array($_POST['rule']) && count($_POST['rule'])) {
160
		foreach ($_POST['rule'] as $rulei) {
161
			delete_nat_association($a_filter[$rulei]['associated-rule-id']);
162
			unset($a_filter[$rulei]);
163
		}
164
		if (write_config())
165
			mark_subsystem_dirty('filter');
166
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
167
		exit;
168
	}
169
} else if ($_GET['act'] == "toggle") {
170
	if ($a_filter[$_GET['id']]) {
171
		if(isset($a_filter[$_GET['id']]['disabled']))
172
			unset($a_filter[$_GET['id']]['disabled']);
173
		else
174
			$a_filter[$_GET['id']]['disabled'] = true;
175
		if (write_config())
176
			mark_subsystem_dirty('filter');
177
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
178
		exit;
179
	}
180
} else {
181
	/* yuck - IE won't send value attributes for image buttons, while Mozilla does -
182
	   so we use .x/.y to fine move button clicks instead... */
183
	unset($movebtn);
184
	foreach ($_POST as $pn => $pd) {
185
		if (preg_match("/move_(\d+)_x/", $pn, $matches)) {
186
			$movebtn = $matches[1];
187
			break;
188
		}
189
	}
190
	/* move selected rules before this rule */
191
	if (isset($movebtn) && is_array($_POST['rule']) && count($_POST['rule'])) {
192
		$a_filter_new = array();
193

    
194
		/* copy all rules < $movebtn and not selected */
195
		for ($i = 0; $i < $movebtn; $i++) {
196
			if (!in_array($i, $_POST['rule']))
197
				$a_filter_new[] = $a_filter[$i];
198
		}
199

    
200
		/* copy all selected rules */
201
		for ($i = 0; $i < count($a_filter); $i++) {
202
			if ($i == $movebtn)
203
				continue;
204
			if (in_array($i, $_POST['rule']))
205
				$a_filter_new[] = $a_filter[$i];
206
		}
207

    
208
		/* copy $movebtn rule */
209
		if ($movebtn < count($a_filter))
210
			$a_filter_new[] = $a_filter[$movebtn];
211

    
212
		/* copy all rules > $movebtn and not selected */
213
		for ($i = $movebtn+1; $i < count($a_filter); $i++) {
214
			if (!in_array($i, $_POST['rule']))
215
				$a_filter_new[] = $a_filter[$i];
216
		}
217

    
218
		$a_filter = $a_filter_new;
219
		if (write_config())
220
			mark_subsystem_dirty('filter');
221
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
222
		exit;
223
	}
224
}
225

    
226
include("head.inc");
227
$nrules = 0;
228

    
229
?>
230
<?php if ($savemsg) print_info_box($savemsg);?>
231
<?php if (is_subsystem_dirty('filter')): ?><p>
232
<?php	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); ?>
233
<br />
234
<?php endif; ?>
235
<?php
236
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/before_table");
237
?>
238

    
239
<?php
240
/* active tabs */
241
$tab_array = array(array(gettext("Floating"), ("FloatingRules" == $if), "firewall_rules.php?if=FloatingRules"));
242

    
243
foreach ($iflist as $ifent => $ifname) {
244
	$tab_array[] = array($ifname, ($ifent == $if), "firewall_rules.php?if={$ifent}");
245
}
246

    
247
display_top_tabs($tab_array);
248
?>
249
<div class="table-responsive">
250
<table class="table table-striped table-hover">
251
<?php
252
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/before_first_tr");
253
?>
254
	<thead>
255
	<tr>
256
		<th colspan="2"></th>
257
		<th><?=gettext("ID");?></th>
258
<?php
259
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_id_tablehead");
260
?>
261
		<th><?=gettext("Proto");?></th>
262
		<th><?=gettext("Source");?></th>
263
		<th><?=gettext("Port");?></th>
264
		<th><?=gettext("Destination");?></th>
265
		<th><?=gettext("Port");?></th>
266
		<th><?=gettext("Gateway");?></th>
267
		<th><?=gettext("Queue");?></th>
268
		<th><?=gettext("Schedule");?></th>
269
<?php
270
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_desc_tablehead");
271
?>
272
		<th><?=gettext("Description");?></th>
273
		<th></th>
274
	</tr>
275
	</thead>
276
	<tbody>
277
	<?php   // 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.
278
		if (!isset($config['system']['webgui']['noantilockout']) &&
279
			(((count($config['interfaces']) > 1) && ($if == 'lan'))
280
			|| ((count($config['interfaces']) == 1) && ($if == 'wan')))):
281

    
282
			$alports = implode('<br />', filter_get_antilockout_ports(true));
283
	?>
284
	<tr id="antilockout">
285
		<td></td>
286
		<td title="<?=gettext("traffic is passed")?>"><i class="icon icon-ok"></i></td>
287
		<td></td>
288
		<?php
289
			pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_id_tr_antilockout");
290
		?>
291
		<td>*</td>
292
		<td>*</td>
293
		<td>*</td>
294
		<td><?=$iflist[$if];?> Address</td>
295
		<td><?=$alports?></td>
296
		<td>*</td>
297
		<td>*</td>
298
		<td></td>
299
		<td><?=gettext("Anti-Lockout Rule");?></td>
300
		<td>
301
			<a href="system_advanced_admin.php" class="btn btn-xs btn-primary">edit</a>
302
		</td>
303
	</tr>
304
<?php endif;?>
305

    
306
<?php if (isset($config['interfaces'][$if]['blockpriv'])): ?>
307
	<tr id="frrfc1918">
308
		<td></td>
309
		<td title="<?=gettext("traffic is blocked")?>"><i class="icon icon-remove"></i></td>
310
		<td></td>
311
		<td>*</td>
312
		<td><?=gettext("RFC 1918 networks");?></td>
313
		<td>*</td>
314
		<td>*</td>
315
		<td>*</td>
316
		<td>*</td>
317
		<td>*</td>
318
		<td></td>
319
		<td><?=gettext("Block private networks");?></td>
320
		<td>
321
			<a href="system_advanced_admin.php" class="btn btn-xs btn-primary" title="<?=gettext("edit rule");?>">edit</a>
322
		</td>
323
	</tr>
324
<?php endif;?>
325
<?php if (isset($config['interfaces'][$if]['blockbogons'])): ?>
326
	<tr id="frrfc1918">
327
		<td></td>
328
		<td title="<?=gettext("traffic is blocked")?>"><i class="icon icon-remove"></i></td>
329
		<td></td>
330
		<td>*</td>
331
		<td><?=gettext("Reserved/not assigned by IANA");?></td>
332
		<td>*</td>
333
		<td>*</td>
334
		<td>*</td>
335
		<td>*</td>
336
		<td>*</td>
337
		<td>*</td>
338
		<td><?=gettext("Block bogon networks");?></td>
339
		<td>
340
			<a href="system_advanced_admin.php" class="btn btn-xs btn-primary">edit</a>
341
		</td>
342
	</tr>
343
<?php endif;?>
344

    
345
<?php for ($i = 0; isset($a_filter[$i]); $i++):
346
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/row_start");
347
	$filterent = $a_filter[$i];
348
	if ($filterent['interface'] != $if && !isset($filterent['floating']))
349
		continue;
350
	if (isset($filterent['floating']) && "FloatingRules" != $if)
351
		continue;
352

    
353
	$nrules++;
354
?>
355
	<tr id="fr<?=$i?>"<?=(isset($filterent['disabled']) ? ' class="disabled"' : '')?>>
356
	<td>
357
		<input type="checkbox" id="frc<?=$i?>" name="rule[]" value="<?=$i?>" />
358
	</td>
359
	<td title="<?=gettext("traffic is ").$filterent['type']."ed"?>">
360
	<?php
361
		if ($filterent['type'] == "block")
362
			$iconfn = "remove";
363
		else if ($filterent['type'] == "reject")
364
			$iconfn = "fire";
365
		else if ($filterent['type'] == "match")
366
			$iconfn = "filter";
367
		else
368
			$iconfn = "ok";
369
	?>
370
	<i class="icon icon-<?=$iconfn?>"></i>
371
	<?php
372
		$isadvset = firewall_check_for_advanced_options($filterent);
373
		if ($isadvset)
374
			print '<i class="icon icon-cog" title="'. gettext("advanced setting") .': '. $isadvset .'"></i>';
375

    
376
		if (isset($filterent['log']))
377
			print '<i class="icon icon-tasks" title="'. gettext("traffic is logged") .'"></i>';
378
	?>
379
	</td>
380
	<?php
381
		$alias = rule_columns_with_alias(
382
			$filterent['source']['address'],
383
			pprint_port($filterent['source']['port']),
384
			$filterent['destination']['address'],
385
			pprint_port($filterent['destination']['port'])
386
		);
387

    
388
		//build Schedule popup box
389
		$a_schedules = &$config['schedules']['schedule'];
390
		$schedule_span_begin = "";
391
		$schedule_span_end = "";
392
		$sched_caption_escaped = "";
393
		$sched_content = "";
394
		$schedstatus = false;
395
		$dayArray = array (gettext('Mon'),gettext('Tues'),gettext('Wed'),gettext('Thur'),gettext('Fri'),gettext('Sat'),gettext('Sun'));
396
		$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'));
397
		if($config['schedules']['schedule'] <> "" and is_array($config['schedules']['schedule'])) {
398
			foreach ($a_schedules as $schedule)
399
			{
400
				if ($schedule['name'] == $filterent['sched'] ){
401
					$schedstatus = filter_get_time_based_rule_status($schedule);
402

    
403
					foreach($schedule['timerange'] as $timerange) {
404
						$tempFriendlyTime = "";
405
						$tempID = "";
406
						$firstprint = false;
407
						if ($timerange){
408
							$dayFriendly = "";
409
							$tempFriendlyTime = "";
410

    
411
							//get hours
412
							$temptimerange = $timerange['hour'];
413
							$temptimeseparator = strrpos($temptimerange, "-");
414

    
415
							$starttime = substr ($temptimerange, 0, $temptimeseparator);
416
							$stoptime = substr ($temptimerange, $temptimeseparator+1);
417

    
418
							if ($timerange['month']){
419
								$tempmontharray = explode(",", $timerange['month']);
420
								$tempdayarray = explode(",",$timerange['day']);
421
								$arraycounter = 0;
422
								$firstDayFound = false;
423
								$firstPrint = false;
424
								foreach ($tempmontharray as $monthtmp){
425
									$month = $tempmontharray[$arraycounter];
426
									$day = $tempdayarray[$arraycounter];
427

    
428
									if (!$firstDayFound)
429
									{
430
										$firstDay = $day;
431
										$firstmonth = $month;
432
										$firstDayFound = true;
433
									}
434

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

    
543
		if (isset($filterent['protocol'])) {
544
			echo strtoupper($filterent['protocol']);
545

    
546
			if (strtoupper($filterent['protocol']) == "ICMP" && !empty($filterent['icmptype'])) {
547
				echo ' <span style="cursor: help;" title="ICMP type: ' .
548
					( $filterent['ipprotocol'] == "inet6" ?  $icmp6types[$filterent['icmptype']] : $icmptypes[$filterent['icmptype']] ) .
549
					'"><u>';
550
				echo $filterent['icmptype'];
551
				echo '</u></span>';
552
			}
553
		} else echo "*";
554
	?>
555
	</td>
556
	<td>
557
		<?php if (isset($alias['src'])): ?>
558
			<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">
559
		<?php endif; ?>
560
		<?=htmlspecialchars(pprint_address($filterent['source']))?>
561
		<?php if (isset($alias['src'])): ?>
562
			<i class='icon icon-pencil'></i></a>
563
		<?php endif; ?>
564
	</td>
565
	<td>
566
		<?php if (isset($alias['srcport'])): ?>
567
			<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">
568
		<?php endif; ?>
569
		<?=htmlspecialchars(pprint_port($filterent['source']['port']))?>
570
		<?php if (isset($alias['srcport'])): ?>
571
			<i class='icon icon-pencil'></i></a>
572
		<?php endif; ?>
573
	</td>
574
	<td>
575
		<?php if (isset($alias['dst'])): ?>
576
			<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['dstport'])?>" data-html="true">
577
		<?php endif; ?>
578
		<?=htmlspecialchars(pprint_address($filterent['destination']['address']))?>
579
		<?php if (isset($alias['dst'])): ?>
580
			<i class='icon icon-pencil'></i></a>
581
		<?php endif; ?>
582
	</td>
583
	<td>
584
		<?php if (isset($alias['dstport'])): ?>
585
			<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">
586
		<?php endif; ?>
587
		<?=htmlspecialchars(pprint_port($filterent['destination']['port']))?>
588
		<?php if (isset($alias['dstport'])): ?>
589
			<i class='icon icon-pencil'></i></a>
590
		<?php endif; ?>
591
	</td>
592
	<td>
593
		<?php if (isset($config['interfaces'][$filterent['gateway']]['descr'])):?>
594
			<?=htmlspecialchars($config['interfaces'][$filterent['gateway']]['descr'])?>
595
		<?php else: ?>
596
			<?=htmlspecialchars(pprint_port($filterent['gateway']))?><a>
597
		<?php endif; ?>
598
	</td>
599
	<td>
600
	<?php
601
		if (isset($filterent['ackqueue']) && isset($filterent['defaultqueue'])) {
602
			$desc = $filterent['ackqueue'] ;
603
			echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['ackqueue']}&amp;action=show\">{$desc}</a>";
604
			$desc = $filterent['defaultqueue'];
605
			echo "/<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
606
		} else if (isset($filterent['defaultqueue'])) {
607
			$desc = $filterent['defaultqueue'];
608
			echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
609
		} else
610
			echo gettext("none");
611
	?>
612
	</td>
613
	<td>
614
		<?php if ($printicon) { ?><img src="./themes/<?= $g['theme'];?>/images/icons/<?=$image;?>.gif" title="<?=$alttext;?>" border="0" alt="icon" /><?php } ?>
615
		<?=$schedule_span_begin;?><?=htmlspecialchars($filterent['sched']);?>&nbsp;<?=$schedule_span_end;?>
616
	</td>
617
	<?php
618
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_descr_tr");
619
	?>
620
	<td>
621
		<?=htmlspecialchars($filterent['descr']);?>
622
	</td>
623
	<td>
624
		<a href="firewall_rules_edit.php?id=<?=$i;?>" class="btn btn-xs btn-primary">edit</a>
625
		<a href="firewall_rules_edit.php?dup=<?=$i;?>" class="btn btn-xs btn-default">copy</a>
626
		<a href="?act=toggle&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>" class="btn btn-xs btn-warning"><?=(isset($filterent['disabled']) ? 'enable' : 'disable')?></a>
627
		<a href="?act=del&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>" class="btn btn-xs btn-danger">delete</a>
628
	</td>
629
	</tr>
630
	<?php endfor;?>
631
</tbody>
632
</table>
633
</div>
634

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

    
649
<nav class="action-buttons">
650
	<a href="firewall_rules_edit.php?if=<?=htmlspecialchars($if);?>" role="button" class="btn btn-success">
651
		<?=gettext("add new");?>
652
	</a>
653
<?php if ($i > 0): ?>
654
	<a href="#" role="button" class="btn btn-danger">
655
		<?=gettext("delete selected");?>
656
	</a>
657
<?php endif;?>
658
</nav>
659

    
660
<h2>Legend</h2>
661
<ul>
662
	<li><i class="icon icon-ok"></i> <?=gettext("pass");?></li>
663
	<li><i class="icon icon-filter"></i> <?=gettext("match");?></li>
664
	<li><i class="icon icon-remove"></i> <?=gettext("block");?></li>
665
	<li><i class="icon icon-fire"></i> <?=gettext("reject");?></li>
666
	<li><i class="icon icon-tasks"></i> <?=gettext("log");?></li>
667
	<li><i class="icon icon-cog"></i> <?=gettext("advanced filter");?></li>
668
</ul>
669

    
670
<p>
671
<?php if ("FloatingRules" != $if): ?>
672
<?=gettext("Rules are evaluated on a first-match basis (i.e. " .
673
	"the action of the first rule to match a packet will be executed). " .
674
	"This means that if you use block rules, you'll have to pay attention " .
675
	"to the rule order. Everything that isn't explicitly passed is blocked " .
676
	"by default. ");?>
677
<?php else: ?>
678
<?=gettext("Floating rules are evaluated on a first-match basis (i.e. " .
679
	"the action of the first rule to match a packet will be executed) only " .
680
	"if the 'quick' option is checked on a rule. Otherwise they will only apply if no " .
681
	"other rules match. Pay close attention to the rule order and options " .
682
	"chosen. If no rule here matches, the per-interface or default rules are used. ");?>
683
<?php endif;?>
684
</p>
685
	<input type="hidden" name="if" value="<?=htmlspecialchars($if);?>" />
686
<?php include("foot.inc");?>
(60-60/241)