Project

General

Profile

Download (22.7 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
<form action="firewall_rules.php" method="post">
231

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

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

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

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

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

    
308
<?php if (isset($config['interfaces'][$if]['blockpriv'])): ?>
309
	<tr id="frrfc1918">
310
		<td></td>
311
		<td title="<?=gettext("traffic is blocked")?>"><i class="icon icon-remove"></i></td>
312
		<td></td>
313
		<td>*</td>
314
		<td><?=gettext("RFC 1918 networks");?></td>
315
		<td>*</td>
316
		<td>*</td>
317
		<td>*</td>
318
		<td>*</td>
319
		<td>*</td>
320
		<td></td>
321
		<td><?=gettext("Block private networks");?></td>
322
		<td>
323
			<a href="system_advanced_admin.php" class="btn btn-xs btn-primary" title="<?=gettext("edit rule");?>">edit</a>
324
		</td>
325
	</tr>
326
<?php endif;?>
327
<?php if (isset($config['interfaces'][$if]['blockbogons'])): ?>
328
	<tr id="frrfc1918">
329
		<td></td>
330
		<td title="<?=gettext("traffic is blocked")?>"><i class="icon icon-remove"></i></td>
331
		<td></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="system_advanced_admin.php" class="btn btn-xs btn-primary">edit</a>
343
		</td>
344
	</tr>
345
<?php endif;?>
346

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

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

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

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

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

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

    
417
							$starttime = substr ($temptimerange, 0, $temptimeseparator);
418
							$stoptime = substr ($temptimerange, $temptimeseparator+1);
419

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

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

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

    
545
		if (isset($filterent['protocol'])) {
546
			echo strtoupper($filterent['protocol']);
547

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

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

    
651
<nav class="action-buttons">
652
	<a href="firewall_rules_edit.php?if=<?=htmlspecialchars($if);?>" role="button" class="btn btn-success">
653
		<?=gettext("add new");?>
654
	</a>
655
<?php if ($i > 0): ?>
656
	<a href="#" role="button" class="btn btn-danger">
657
		<?=gettext("delete selected");?>
658
	</a>
659
	<!-- onclick="return confirm('<?=gettext('Do you really want to delete the selected rules?');?>')" />-->
660
<?php endif;?>
661
</nav>
662

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

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