Project

General

Profile

Download (23.1 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 ($config['pptpd']['mode'] == "server") {
130
	if (have_ruleint_access("pptp")) {
131
		$iflist['pptp'] = "PPTP VPN";
132
	}
133
}
134

    
135
if (is_array($config['pppoes']['pppoe'])) {
136
	foreach ($config['pppoes']['pppoe'] as $pppoes) {
137
		if (($pppoes['mode'] == 'server') && have_ruleint_access("pppoe")) {
138
			$iflist['pppoe'] = "PPPoE Server";
139
		}
140
	}
141
}
142

    
143
/* add ipsec interfaces */
144
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) {
145
	if (have_ruleint_access("enc0")) {
146
		$iflist["enc0"] = "IPsec";
147
	}
148
}
149

    
150
/* add openvpn/tun interfaces */
151
if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) {
152
	$iflist["openvpn"] = "OpenVPN";
153
}
154

    
155
if (!$if || !isset($iflist[$if])) {
156
	if ("any" == $if) {
157
		$if = "FloatingRules";
158
	} else if ("FloatingRules" != $if) {
159
		if (isset($iflist['wan'])) {
160
			$if = "wan";
161
		} else {
162
			$if = "FloatingRules";
163
		}
164
	}
165
}
166

    
167
if ($_POST) {
168
	$pconfig = $_POST;
169

    
170
	if ($_POST['apply']) {
171
		$retval = 0;
172
		$retval = filter_configure();
173

    
174
		clear_subsystem_dirty('filter');
175

    
176
		$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>");
177
	}
178
}
179

    
180
if ($_GET['act'] == "del") {
181
	if ($a_filter[$_GET['id']]) {
182
		if (!empty($a_filter[$_GET['id']]['associated-rule-id'])) {
183
			delete_nat_association($a_filter[$_GET['id']]['associated-rule-id']);
184
		}
185
		unset($a_filter[$_GET['id']]);
186
		if (write_config()) {
187
			mark_subsystem_dirty('filter');
188
		}
189
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
190
		exit;
191
	}
192
}
193

    
194
// Handle save msg if defined
195
if ($_REQUEST['savemsg']) {
196
	$savemsg = htmlentities($_REQUEST['savemsg']);
197
}
198

    
199
if ($_GET['act'] == "toggle") {
200
	if ($a_filter[$_GET['id']]) {
201
		if (isset($a_filter[$_GET['id']]['disabled'])) {
202
			unset($a_filter[$_GET['id']]['disabled']);
203
		} else {
204
			$a_filter[$_GET['id']]['disabled'] = true;
205
		}
206
		if (write_config()) {
207
			mark_subsystem_dirty('filter');
208
		}
209
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
210
		exit;
211
	}
212
} else {
213
	/* update rule order, POST[rule] is an array of ordered IDs */
214
	if (is_array($_POST['rule']) && !empty($_POST['rule'])) {
215
		$a_filter_new = array();
216

    
217
		// if a rule is not in POST[rule], it has been deleted by the user
218
		foreach ($_POST['rule'] as $id)
219
			$a_filter_new[] = $a_filter[$id];
220

    
221
		$a_filter = $a_filter_new;
222
		if (write_config()) {
223
			mark_subsystem_dirty('filter');
224
		}
225
		header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
226
		exit;
227
	}
228
}
229

    
230
include("head.inc");
231
$nrules = 0;
232

    
233
if ($savemsg)
234
	print_info_box($savemsg, 'success');
235

    
236
if (is_subsystem_dirty('filter'))
237
	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);
238

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

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

    
244
display_top_tabs($tab_array);
245

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

    
327
			<tbody class="user-entries">
328
<?php for ($i = 0; isset($a_filter[$i]); $i++):
329
	$filterent = $a_filter[$i];
330
	
331
	if ($filterent['interface'] != $if && !isset($filterent['floating']))
332
		continue;
333
	if (isset($filterent['floating']) && "FloatingRules" != $if)
334
		continue;
335

    
336
	$nrules++;
337
?>
338
					<tr<?=(isset($filterent['disabled']) ? ' class="disabled"' : '')?>>
339
						<td title="<?=gettext("traffic is ").$filterent['type']."ed"?>">
340
							<input type="hidden" name="rule[]" value="<?=$i?>" />
341

    
342
	<?php
343
		if ($filterent['type'] == "block")
344
			$iconfn = "remove";
345
		else if ($filterent['type'] == "reject")
346
			$iconfn = "fire";
347
		else if ($filterent['type'] == "match")
348
			$iconfn = "filter";
349
		else
350
			$iconfn = "ok";
351
	?>
352
					<i class="icon icon-<?=$iconfn?>"></i>
353
	<?php
354
		$isadvset = firewall_check_for_advanced_options($filterent);
355
		if ($isadvset)
356
			print '<i class="icon icon-cog" title="'. gettext("advanced setting") .': '. $isadvset .'"></i>';
357

    
358
		if (isset($filterent['log']))
359
			print '<i class="icon icon-tasks" title="'. gettext("traffic is logged") .'"></i>';
360
	?>
361
				</td>
362
	<?php
363
		$alias = rule_columns_with_alias(
364
			$filterent['source']['address'],
365
			pprint_port($filterent['source']['port']),
366
			$filterent['destination']['address'],
367
			pprint_port($filterent['destination']['port'])
368
		);
369

    
370
		//build Schedule popup box
371
		$a_schedules = &$config['schedules']['schedule'];
372
		$schedule_span_begin = "";
373
		$schedule_span_end = "";
374
		$sched_caption_escaped = "";
375
		$sched_content = "";
376
		$schedstatus = false;
377
		$dayArray = array (gettext('Mon'),gettext('Tues'),gettext('Wed'),gettext('Thur'),gettext('Fri'),gettext('Sat'),gettext('Sun'));
378
		$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'));
379
		if ($config['schedules']['schedule'] != "" && is_array($config['schedules']['schedule'])) {
380
			foreach ($a_schedules as $schedule)
381
			{
382
				if ($schedule['name'] == $filterent['sched'] ){
383
					$schedstatus = filter_get_time_based_rule_status($schedule);
384

    
385
					foreach($schedule['timerange'] as $timerange) {
386
						$tempFriendlyTime = "";
387
						$tempID = "";
388
						$firstprint = false;
389
						if ($timerange){
390
							$dayFriendly = "";
391
							$tempFriendlyTime = "";
392

    
393
							//get hours
394
							$temptimerange = $timerange['hour'];
395
							$temptimeseparator = strrpos($temptimerange, "-");
396

    
397
							$starttime = substr ($temptimerange, 0, $temptimeseparator);
398
							$stoptime = substr ($temptimerange, $temptimeseparator+1);
399

    
400
							if ($timerange['month']){
401
								$tempmontharray = explode(",", $timerange['month']);
402
								$tempdayarray = explode(",",$timerange['day']);
403
								$arraycounter = 0;
404
								$firstDayFound = false;
405
								$firstPrint = false;
406
								foreach ($tempmontharray as $monthtmp){
407
									$month = $tempmontharray[$arraycounter];
408
									$day = $tempdayarray[$arraycounter];
409

    
410
									if (!$firstDayFound)
411
									{
412
										$firstDay = $day;
413
										$firstmonth = $month;
414
										$firstDayFound = true;
415
									}
416

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

    
522
		if (isset($filterent['protocol'])) {
523
			echo strtoupper($filterent['protocol']);
524

    
525
			if (strtoupper($filterent['protocol']) == "ICMP" && !empty($filterent['icmptype'])) {
526
				echo ' <span style="cursor: help;" title="ICMP type: ' .
527
					( $filterent['ipprotocol'] == "inet6" ?	 $icmp6types[$filterent['icmptype']] : $icmptypes[$filterent['icmptype']] ) .
528
					'"><u>';
529
				echo $filterent['icmptype'];
530
				echo '</u></span>';
531
			}
532
		} else echo "*";
533
	?>
534
						</td>
535
						<td>
536
							<?php if (isset($alias['src'])): ?>
537
								<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">
538
							<?php endif; ?>
539
							<?=htmlspecialchars(pprint_address($filterent['source']))?>
540
							<?php if (isset($alias['src'])): ?>
541
								<i class='icon icon-pencil'></i></a>
542
							<?php endif; ?>
543
						</td>
544
						<td>
545
							<?php if (isset($alias['srcport'])): ?>
546
								<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">
547
							<?php endif; ?>
548
							<?=htmlspecialchars(pprint_port($filterent['source']['port']))?>
549
							<?php if (isset($alias['srcport'])): ?>
550
								<i class='icon icon-pencil'></i></a>
551
							<?php endif; ?>
552
						</td>
553
						<td>
554
							<?php if (isset($alias['dst'])): ?>
555
								<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">
556
							<?php endif; ?>
557
							<?=htmlspecialchars(pprint_address($filterent['destination']))?>
558
							<?php if (isset($alias['dst'])): ?>
559
								<i class='icon icon-pencil'></i></a>
560
							<?php endif; ?>
561
						</td>
562
						<td>
563
							<?php if (isset($alias['dstport'])): ?>
564
								<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">
565
							<?php endif; ?>
566
							<?=htmlspecialchars(pprint_port($filterent['destination']['port']))?>
567
							<?php if (isset($alias['dstport'])): ?>
568
								<i class='icon icon-pencil'></i></a>
569
							<?php endif; ?>
570
						</td>
571
						<td>
572
							<?php if (isset($config['interfaces'][$filterent['gateway']]['descr'])):?>
573
								<?=htmlspecialchars($config['interfaces'][$filterent['gateway']]['descr'])?>
574
							<?php else: ?>
575
								<?=htmlspecialchars(pprint_port($filterent['gateway']))?>
576
							<?php endif; ?>
577
						</td>
578
						<td>
579
							<?php
580
								if (isset($filterent['ackqueue']) && isset($filterent['defaultqueue'])) {
581
									$desc = $filterent['ackqueue'] ;
582
									echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['ackqueue']}&amp;action=show\">{$desc}</a>";
583
									$desc = $filterent['defaultqueue'];
584
									echo "/<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
585
								} else if (isset($filterent['defaultqueue'])) {
586
									$desc = $filterent['defaultqueue'];
587
									echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
588
								} else
589
									echo gettext("none");
590
							?>
591
						</td>
592
						<td>
593
							<?php if ($printicon) { ?><img src="./themes/<?= $g['theme'];?>/images/icons/<?=$image;?>.gif" title="<?=$alttext;?>" border="0" alt="icon" /><?php } ?>
594
							<?=$schedule_span_begin;?><?=htmlspecialchars($filterent['sched']);?>&nbsp;<?=$schedule_span_end;?>
595
						</td>
596
						<td>
597
							<?=htmlspecialchars($filterent['descr']);?>
598
						</td>
599
						<td>
600
							<a href="firewall_rules_edit.php?id=<?=$i;?>" class="btn btn-xs btn-primary">edit</a>
601
							<a href="firewall_rules_edit.php?dup=<?=$i;?>" class="btn btn-xs btn-default">copy</a>
602
							<a href="?act=toggle&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>" class="btn btn-xs btn-warning"><?=(isset($filterent['disabled']) ? 'enable' : 'disable')?></a>
603
							<a href="?act=del&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>" class="btn btn-xs btn-danger">delete</a>
604
						</td>
605
					</tr>
606
<?php
607
		endfor;
608
?>
609
				</tbody>
610
			</table>
611
		</div>
612
	</div>
613

    
614
<?php if ($nrules == 0): ?>
615
	<div class="alert alert-warning" role="alert">
616
		<p>
617
		<?php if ($_REQUEST['if'] == "FloatingRules"): ?>
618
			<?=gettext("No floating rules are currently defined.");?>
619
		<?php else: ?>
620
			<?=gettext("No rules are currently defined for this interface");?><br />
621
			<?=gettext("All incoming connections on this interface will be blocked until you add pass rules.");?>
622
		<?php endif;?>
623
			<?=gettext("Click the button to add a new rule.");?>
624
		</p>
625
	</div>
626
<?php endif;?>
627

    
628
	<nav class="action-buttons">
629
		<input type="submit" id="order-store" class="btn btn-sm btn-primary" value="store changes" disabled="disabled" />
630
		<a href="firewall_rules_edit.php?if=<?=htmlspecialchars($if);?>" role="button" class="btn btn-sm btn-success">
631
			<?=gettext("add new");?>
632
		</a>
633
	</nav>
634
</form>
635
<!-- Legend -->
636
<div>
637
	<dl class="dl-horizontal responsive">
638
		<dt><?=gettext('Legend')?></dt>				<dd></dd>
639
		<dt><i class="icon icon-ok"></i></dt>		<dd><?=gettext("pass");?></dd>
640
		<dt><i class="icon icon-filter"></i></dt>	<dd><?=gettext("match");?></dd>
641
		<dt><i class="icon icon-remove"></i></dt>	<dd><?=gettext("block");?></dd>
642
		<dt><i class="icon icon-fire"></i></dt>		<dd><?=gettext("reject");?></dd>
643
		<dt><i class="icon icon-tasks"></i></dt>	<dd> <?=gettext("log");?></dd>
644
		<dt><i class="icon icon-cog"></i></dt>		<dd> <?=gettext("advanced filter");?></dd>
645
	</dl>
646
</div>
647

    
648
<?php
649
if ("FloatingRules" != $if)
650
	print_info_box(gettext("Rules are evaluated on a first-match basis (i.e. " .
651
		"the action of the first rule to match a packet will be executed). ") . '<br />' .
652
		gettext("This means that if you use block rules, you'll have to pay attention " .
653
		"to the rule order. Everything that isn't explicitly passed is blocked " .
654
		"by default. "));
655
else
656
	print_info_box(gettext("Floating rules are evaluated on a first-match basis (i.e. " .
657
		"the action of the first rule to match a packet will be executed) only " .
658
		"if the 'quick' option is checked on a rule. Otherwise they will only apply if no " .
659
		"other rules match. Pay close attention to the rule order and options " .
660
		"chosen. If no rule here matches, the per-interface or default rules are used. "));
661

    
662
?>
663

    
664
<script>
665
events.push(function() {
666
	// Make rules sortable
667
	$('table tbody.user-entries').sortable({
668
		cursor: 'grabbing',
669
		update: function(event, ui) {
670
			$('#order-store').removeAttr('disabled');
671
		}
672
	});
673

    
674
	// Replace direct delete with quicker front-end action
675
/*FIXME: event ordering
676
	$('.btn-danger').on('click', function(e){
677
		$(this).parents('tr').remove();
678

    
679
		$('#order-store').removeAttr('disabled');
680
	});
681
*/});
682
</script>
683
<?php include("foot.inc");?>
(61-61/237)