Project

General

Profile

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

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

    
70
require("guiconfig.inc");
71
require_once("functions.inc");
72
require_once("filter.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
if ($_POST['if']) {
103
	$if = $_POST['if'];
104
}
105

    
106
$ifdescs = get_configured_interface_with_descr();
107

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

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

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

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

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

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

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

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

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

    
168
		clear_subsystem_dirty('filter');
169

    
170
		$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>");
171
	}
172
}
173

    
174

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

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

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

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

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

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

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

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

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

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

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

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

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

    
254
if (is_subsystem_dirty('filter'))
255
	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);
256

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

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

    
262
display_top_tabs($tab_array);
263

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
551
			if (strtoupper($filterent['protocol']) == "ICMP" && !empty($filterent['icmptype'])) {
552
				echo ' <span style="cursor: help;" title="ICMP type: ' .
553
					($filterent['ipprotocol'] == "inet6" ? $icmp6types[$filterent['icmptype']] : $icmptypes[$filterent['icmptype']]) .
554
					'"><u>';
555
				echo $filterent['icmptype'];
556
				echo '</u></span>';
557
			}
558
		} else echo "*";
559
	?>
560
						</td>
561
						<td>
562
							<?php if (isset($alias['src'])): ?>
563
								<a href="/firewall_aliases_edit.php?id=<?=$alias['src']?>" data-toggle="popover" data-trigger="hover focus" title="Alias details" data-content="<?=alias_info_popup($alias['src'])?>" data-html="true">
564
							<?php endif; ?>
565
							<?=htmlspecialchars(pprint_address($filterent['source']))?>
566
							<?php if (isset($alias['src'])): ?>
567
								<i class='icon icon-pencil'></i></a>
568
							<?php endif; ?>
569
						</td>
570
						<td>
571
							<?php if (isset($alias['srcport'])): ?>
572
								<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">
573
							<?php endif; ?>
574
							<?=htmlspecialchars(pprint_port($filterent['source']['port']))?>
575
							<?php if (isset($alias['srcport'])): ?>
576
								<i class='icon icon-pencil'></i></a>
577
							<?php endif; ?>
578
						</td>
579
						<td>
580
							<?php if (isset($alias['dst'])): ?>
581
								<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">
582
							<?php endif; ?>
583
							<?=htmlspecialchars(pprint_address($filterent['destination']))?>
584
							<?php if (isset($alias['dst'])): ?>
585
								<i class='icon icon-pencil'></i></a>
586
							<?php endif; ?>
587
						</td>
588
						<td>
589
							<?php if (isset($alias['dstport'])): ?>
590
								<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">
591
							<?php endif; ?>
592
							<?=htmlspecialchars(pprint_port($filterent['destination']['port']))?>
593
							<?php if (isset($alias['dstport'])): ?>
594
								<i class='icon icon-pencil'></i></a>
595
							<?php endif; ?>
596
						</td>
597
						<td>
598
							<?php if (isset($config['interfaces'][$filterent['gateway']]['descr'])):?>
599
								<?=htmlspecialchars($config['interfaces'][$filterent['gateway']]['descr'])?>
600
							<?php else: ?>
601
								<?=htmlspecialchars(pprint_port($filterent['gateway']))?>
602
							<?php endif; ?>
603
						</td>
604
						<td>
605
							<?php
606
								if (isset($filterent['ackqueue']) && isset($filterent['defaultqueue'])) {
607
									$desc = $filterent['ackqueue'] ;
608
									echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['ackqueue']}&amp;action=show\">{$desc}</a>";
609
									$desc = $filterent['defaultqueue'];
610
									echo "/<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
611
								} else if (isset($filterent['defaultqueue'])) {
612
									$desc = $filterent['defaultqueue'];
613
									echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
614
								} else
615
									echo gettext("none");
616
							?>
617
						</td>
618
						<td>
619
							<?php if ($printicon) { ?><img src="./themes/<?= $g['theme'];?>/images/icons/<?=$image;?>.gif" title="<?=$alttext;?>" border="0" alt="icon" /><?php } ?>
620
							<?=$schedule_span_begin;?><?=htmlspecialchars($filterent['sched']);?>&nbsp;<?=$schedule_span_end;?>
621
						</td>
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
633
		$nrules++;
634
		endfor;
635
?>
636
				</tbody>
637
			</table>
638
		</div>
639
	</div>
640

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

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

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

    
690
?>
691

    
692
<script>
693
function fr_toggle(id, prefix) {
694
	if (!prefix)
695
		prefix = 'fr';
696

    
697
	var checkbox = document.getElementById(prefix + 'c' + id);
698
	checkbox.checked = !checkbox.checked;
699
	fr_bgcolor(id, prefix);
700
}
701

    
702
function fr_bgcolor(id, prefix) {
703
	if (!prefix)
704
		prefix = 'fr';
705

    
706
	var row = document.getElementById(prefix + id);
707
	var checkbox = document.getElementById(prefix + 'c' + id);
708
	var cells = row.getElementsByTagName('td');
709
	var cellcnt = cells.length;
710

    
711
	for (i = 0; i < cellcnt-1; i++) {
712
		cells[i].style.backgroundColor = checkbox.checked ? "#DDF4FF" : "#FFFFFF";
713
	}
714
}
715
</script>
716

    
717
<script>
718
events.push(function() {
719
	// Make rules sortable
720
	$('table tbody.user-entries').sortable({
721
		cursor: 'grabbing',
722
		update: function(event, ui) {
723
			$('#order-store').removeAttr('disabled');
724
		}
725
	});
726

    
727
	// Check all of the rule checkboxes so that their values are posted
728
	$('#order-store').click(function () {
729
	   $('[id^=frc]').prop('checked', true);
730
	   alert();
731
	});
732

    
733
	// Replace direct delete with quicker front-end action
734
/*FIXME: event ordering
735
	$('.btn-danger').on('click', function(e){
736
		$(this).parents('tr').remove();
737

    
738
		$('#order-store').removeAttr('disabled');
739
	});
740
*/});
741
</script>
742
<?php include("foot.inc");?>
(61-61/235)