Project

General

Profile

Download (25 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
##|+PRIV
60
##|*IDENT=page-firewall-rules
61
##|*NAME=Firewall: Rules
62
##|*DESCR=Allow access to the 'Firewall: Rules' page.
63
##|*MATCH=firewall_rules.php*
64
##|-PRIV
65

    
66
require("guiconfig.inc");
67
require_once("functions.inc");
68
require_once("filter.inc");
69
require_once("ipsec.inc");
70
require_once("shaper.inc");
71

    
72
$pgtitle = array(gettext("Firewall"), gettext("Rules"));
73
$shortcut_section = "firewall";
74

    
75
function delete_nat_association($id) {
76
	global $config;
77

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

    
82
	$a_nat = &$config['nat']['rule'];
83

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

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

    
95
filter_rules_sort();
96
$a_filter = &$config['filter']['rule'];
97

    
98
$if = $_GET['if'];
99

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

    
104
$ifdescs = get_configured_interface_with_descr();
105

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

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

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

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

    
135
/* add ipsec interfaces */
136
if (ipsec_enabled() && have_ruleint_access("enc0")) {
137
	$iflist["enc0"] = "IPsec";
138
}
139

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

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

    
157
if ($_POST) {
158
	$pconfig = $_POST;
159

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

    
164
		clear_subsystem_dirty('filter');
165

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

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

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

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

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

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

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

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

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

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

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

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

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

    
247
foreach ($iflist as $ifent => $ifname) {
248
	$tab_array[] = array($ifname, ($ifent == $if), "firewall_rules.php?if={$ifent}");
249
}
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

    
268
if (is_subsystem_dirty('filter')) {
269
	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);
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 text-success"></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 text-danger"></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 text-danger"></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 text-danger";
379
			$title_text = gettext("traffic is blocked");
380
		} else if ($filterent['type'] == "reject") {
381
			$iconfn = "hand-stop-o text-warning";
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 text-success";
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

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

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

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

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

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

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

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

    
565
		if (isset($filterent['protocol'])) {
566
			echo strtoupper($filterent['protocol']);
567

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

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

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

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

    
692
<div id="infoblock">
693
	<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">
694
		<dl class="dl-horizontal responsive">
695
		<!-- Legend -->
696
			<dt><?=gettext('Legend')?></dt>				<dd></dd>
697
			<dt><i class="fa fa-check text-success"></i></dt>		<dd><?=gettext("Pass");?></dd>
698
			<dt><i class="fa fa-filter"></i></dt>	<dd><?=gettext("Match");?></dd>
699
			<dt><i class="fa fa-times text-danger"></i></dt>	<dd><?=gettext("Block");?></dd>
700
			<dt><i class="fa fa-hand-stop-o text-warning"></i></dt>		<dd><?=gettext("Reject");?></dd>
701
			<dt><i class="fa fa-tasks"></i></dt>	<dd> <?=gettext("Log");?></dd>
702
			<dt><i class="fa fa-cog"></i></dt>		<dd> <?=gettext("Advanced filter");?></dd>
703
		</dl>
704

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

    
723
<script type="text/javascript">
724
//<![CDATA[
725
events.push(function() {
726

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

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

    
743
<?php include("foot.inc");?>
(49-49/228)