Project

General

Profile

Download (36 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
$closehead = false;
226

    
227
include("head.inc");
228
?>
229
<link type="text/css" rel="stylesheet" href="/javascript/chosen/chosen.css" />
230
</head>
231

    
232
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
233
<script src="/javascript/chosen/chosen.jquery.js" type="text/javascript"></script>
234
<?php include("fbegin.inc"); ?>
235
<form action="firewall_rules.php" method="post">
236

    
237
<script type="text/javascript" src="/javascript/row_toggle.js"></script>
238
<?php if ($savemsg) print_info_box($savemsg); ?>
239
<?php if (is_subsystem_dirty('filter')): ?><p>
240
<?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); ?>
241
<br />
242
<?php endif; ?>
243
<?php
244
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/before_table");
245
?>
246
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="firewall rules">
247
	<tr><td class="tabnavtbl">
248
	<?php
249
	/* active tabs */
250
	$tab_array = array();
251
	if ("FloatingRules" == $if)
252
		$active = true;
253
	else
254
		$active = false;
255
	$tab_array[] = array(gettext("Floating"), $active, "firewall_rules.php?if=FloatingRules");
256
	$tabscounter = 0; $i = 0; foreach ($iflist as $ifent => $ifname) {
257
		if ($ifent == $if)
258
			$active = true;
259
		else
260
			$active = false;
261
		$tab_array[] = array($ifname, $active, "firewall_rules.php?if={$ifent}");
262
	}
263
	display_top_tabs($tab_array);
264
	?>
265
	</td></tr>
266
	<tr><td>
267
		<div id="mainarea">
268
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
269
			<?php
270
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/before_first_tr");
271
			?>
272
			<tr id="frheader">
273
			<td width="3%" class="list">&nbsp;</td>
274
			<td width="5%" class="list">&nbsp;</td>
275
			<td width="3%" class="listhdrr"><?=gettext("ID");?></td>
276
			<?php
277
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_id_tablehead");
278
			?>
279
			<td width="6%" class="listhdrr"><?=gettext("Proto");?></td>
280
			<td width="12%" class="listhdrr"><?=gettext("Source");?></td>
281
			<td width="6%" class="listhdrr"><?=gettext("Port");?></td>
282
			<td width="12%" class="listhdrr"><?=gettext("Destination");?></td>
283
			<td width="6%" class="listhdrr"><?=gettext("Port");?></td>
284
			<td width="5%" class="listhdrr"><?=gettext("Gateway");?></td>
285
			<td width="8%" class="listhdrr"><?=gettext("Queue");?></td>
286
			<td width="5%" class="listhdrr"><?=gettext("Schedule");?></td>
287
			<?php
288
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_desc_tablehead");
289
			?>
290
			<td width="19%" class="listhdr"><?=gettext("Description");?></td>
291
			<td width="10%" class="list">
292
				<table border="0" cellspacing="0" cellpadding="1" summary="delete selected rules">
293
					<tr>
294
					<?php
295
						$nrules = 0;
296
						for ($i = 0; isset($a_filter[$i]); $i++) {
297
							$filterent = $a_filter[$i];
298
							if ($filterent['interface'] != $if && !isset($filterent['floating']))
299
								continue;
300
							if (isset($filterent['floating']) && "FloatingRules" != $if)
301
								continue;
302
							$nrules++;
303
						}
304
					?>
305
					<td>
306
					<?php if ($nrules == 0): ?>
307
						<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?gettext("delete selected rules"); ?>" border="0" alt="delete" /><?php else: ?>
308
						<input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" style="width:17;height:17" title="<?=gettext("delete selected rules");?>" onclick="return confirm('<?=gettext('Do you really want to delete the selected rules?');?>')" />
309
					<?php endif; ?>
310
					</td>
311
					<td align="center" valign="middle"><a href="firewall_rules_edit.php?if=<?=htmlspecialchars($if);?>&amp;after=-1"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add new rule");?>" width="17" height="17" border="0" alt="add" /></a></td>
312
					</tr>
313
				</table>
314
			</td>
315
			</tr>
316
			<?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.
317
				if (!isset($config['system']['webgui']['noantilockout']) &&
318
					(((count($config['interfaces']) > 1) && ($if == 'lan'))
319
					|| ((count($config['interfaces']) == 1) && ($if == 'wan')))):
320

    
321
					$alports = implode('<br />', filter_get_antilockout_ports(true));
322
			?>
323
			<tr valign="top" id="antilockout">
324
			<td class="list">&nbsp;</td>
325
			<td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif" width="11" height="11" border="0" alt="pass" /></td>
326
			<td class="listlr" style="background-color: #E0E0E0">&nbsp;</td>
327
			<?php
328
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_id_tr_antilockout");
329
			?>
330
			<td class="listr" style="background-color: #E0E0E0">*</td>
331
			<td class="listr" style="background-color: #E0E0E0">*</td>
332
			<td class="listr" style="background-color: #E0E0E0">*</td>
333
			<td class="listr" style="background-color: #E0E0E0"><?=$iflist[$if];?> Address</td>
334
			<td class="listr" style="background-color: #E0E0E0"><?= $alports ?></td>
335
			<td class="listr" style="background-color: #E0E0E0">*</td>
336
			<td class="listr" style="background-color: #E0E0E0">*</td>
337
			<td class="listr" style="background-color: #E0E0E0">&nbsp;</td>
338
			<td class="listbg"><?=gettext("Anti-Lockout Rule");?></td>
339
			<td valign="middle" class="list nowrap">
340
			<table border="0" cellspacing="0" cellpadding="1" summary="move rules before">
341
				<tr>
342
					<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected rules before this rule");?>" alt="move" /></td>
343
					<td><a href="system_advanced_admin.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit rule");?>" width="17" height="17" border="0" alt="edit" /></a></td>
344
				</tr>
345
				<tr>
346
					<td align="center" valign="middle"></td>
347
					<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus_d.gif" title="<?=gettext("add a new rule based on this one");?>" width="17" height="17" border="0" alt="add" /></td>
348
				</tr>
349
				</table>
350
			</td>
351
			</tr>
352
<?php endif; ?>
353

    
354
<?php if (isset($config['interfaces'][$if]['blockpriv'])): ?>
355
			<tr valign="top" id="frrfc1918">
356
			<td class="list">&nbsp;</td>
357
			<td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0" alt="block" /></td>
358
			<td class="listlr" style="background-color: #E0E0E0">&nbsp;</td>
359
			<td class="listr" style="background-color: #E0E0E0">*</td>
360
			<td class="listr" style="background-color: #E0E0E0"><?=gettext("RFC 1918 networks");?></td>
361
			<td class="listr" style="background-color: #E0E0E0">*</td>
362
			<td class="listr" style="background-color: #E0E0E0">*</td>
363
			<td class="listr" style="background-color: #E0E0E0">*</td>
364
			<td class="listr" style="background-color: #E0E0E0">*</td>
365
			<td class="listr" style="background-color: #E0E0E0">*</td>
366
			<td class="listr" style="background-color: #E0E0E0">&nbsp;</td>
367
			<td class="listbg"><?=gettext("Block private networks");?></td>
368
			<td valign="middle" class="list nowrap">
369
				<table border="0" cellspacing="0" cellpadding="1" summary="move rules before">
370
					<tr>
371
					<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected rules before this rule");?>" alt="edit" /></td>
372
					<td><a href="interfaces.php?if=<?=htmlspecialchars($if)?>#rfc1918"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit rule");?>" width="17" height="17" border="0" alt="edit" /></a></td>
373
					</tr>
374
					<tr>
375
					<td align="center" valign="middle"></td>
376
					<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus_d.gif" title="<?=gettext("add a new rule based on this one");?>" width="17" height="17" border="0" alt="add" /></td>
377
					</tr>
378
				</table>
379
			</td>
380
			</tr>
381
<?php endif; ?>
382
<?php if (isset($config['interfaces'][$if]['blockbogons'])): ?>
383
			<tr valign="top" id="frrfc1918">
384
			<td class="list">&nbsp;</td>
385
			<td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0" alt="block" /></td>
386
			<td class="listlr" style="background-color: #E0E0E0">&nbsp;</td>
387
			<td class="listr" style="background-color: #E0E0E0">*</td>
388
			<td class="listr" style="background-color: #E0E0E0"><?=gettext("Reserved/not assigned by IANA");?></td>
389
			<td class="listr" style="background-color: #E0E0E0">*</td>
390
			<td class="listr" style="background-color: #E0E0E0">*</td>
391
			<td class="listr" style="background-color: #E0E0E0">*</td>
392
			<td class="listr" style="background-color: #E0E0E0">*</td>
393
			<td class="listr" style="background-color: #E0E0E0">*</td>
394
			<td class="listr" style="background-color: #E0E0E0">*</td>
395
			<td class="listbg"><?=gettext("Block bogon networks");?></td>
396
			<td valign="middle" class="list nowrap">
397
				<table border="0" cellspacing="0" cellpadding="1" summary="move rules before">
398
					<tr>
399
					<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected rules before this rule");?>" alt="move" /></td>
400
					<td><a href="interfaces.php?if=<?=htmlspecialchars($if)?>#rfc1918"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit rule");?>" width="17" height="17" border="0" alt=" edit" /></a></td>
401
					</tr>
402
					<tr>
403
					<td align="center" valign="middle"></td>
404
					<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus_d.gif" title="<?=gettext("add a new rule based on this one");?>" width="17" height="17" border="0" alt="add" /></td>
405
					</tr>
406
				</table>
407
			</td>
408
			</tr>
409
<?php endif; ?>
410
			<tbody>
411
<?php $nrules = 0; for ($i = 0; isset($a_filter[$i]); $i++):
412
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/row_start");
413
	$filterent = $a_filter[$i];
414
	if ($filterent['interface'] != $if && !isset($filterent['floating']))
415
		continue;
416
	if (isset($filterent['floating']) && "FloatingRules" != $if)
417
		continue;
418
	$isadvset = firewall_check_for_advanced_options($filterent);
419
	if($isadvset)
420
		$advanced_set = "<img src=\"./themes/{$g['theme']}/images/icons/icon_advanced.gif\" title=\"" . gettext("advanced settings set") . ": {$isadvset}\" border=\"0\" alt=\"avanced\" />";
421
	else
422
		$advanced_set = "";
423
?>
424
			<tr valign="top" id="fr<?=$nrules;?>">
425
			<td class="listt">
426
				<input type="checkbox" id="frc<?=$nrules;?>" name="rule[]" value="<?=$i;?>" onclick="fr_bgcolor('<?=$nrules;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" />
427
				<?php echo $advanced_set; ?>
428
			</td>
429
			<td class="listt" align="center">
430
			<?php
431
				if ($filterent['type'] == "block")
432
					$iconfn = "block";
433
				else if ($filterent['type'] == "reject")
434
					$iconfn = "reject";
435
				else if ($filterent['type'] == "match")
436
					$iconfn = "match";
437
				else
438
					$iconfn = "pass";
439
				if (isset($filterent['disabled'])) {
440
					$textss = "<span class=\"gray\">";
441
					$textse = "</span>";
442
					$iconfn .= "_d";
443
				} else {
444
					$textss = $textse = "";
445
				}
446
			?>
447
				<a href="?if=<?=htmlspecialchars($if);?>&amp;act=toggle&amp;id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfn;?>.gif" width="11" height="11" border="0" title="<?=gettext("click to toggle enabled/disabled status");?>" alt="icon" /></a>
448
			<?php
449
				if (isset($filterent['log'])):
450
					$iconfnlog = "log_s";
451
				if (isset($filterent['disabled']))
452
					$iconfnlog .= "_d";
453
			?>
454
			<br /><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfnlog;?>.gif" width="11" height="15" border="0" alt="icon" />
455
<?php endif; ?>
456
			</td>
457
			<?php
458

    
459
				//build Alias popup box
460
				$alias_src_span_begin = "";
461
				$alias_src_port_span_begin = "";
462
				$alias_dst_span_begin = "";
463
				$alias_dst_port_span_begin = "";
464

    
465
				$alias_popup = rule_popup($filterent['source']['address'],pprint_port($filterent['source']['port']),$filterent['destination']['address'],pprint_port($filterent['destination']['port']));
466

    
467
				$alias_src_span_begin = $alias_popup["src"];
468
				$alias_src_port_span_begin = $alias_popup["srcport"];
469
				$alias_dst_span_begin = $alias_popup["dst"];
470
				$alias_dst_port_span_begin = $alias_popup["dstport"];
471

    
472
				$alias_src_span_end = $alias_popup["src_end"];
473
				$alias_src_port_span_end = $alias_popup["srcport_end"];
474
				$alias_dst_span_end = $alias_popup["dst_end"];
475
				$alias_dst_port_span_end = $alias_popup["dstport_end"];
476

    
477
				//build Schedule popup box
478
				$a_schedules = &$config['schedules']['schedule'];
479
				$schedule_span_begin = "";
480
				$schedule_span_end = "";
481
				$sched_caption_escaped = "";
482
				$sched_content = "";
483
				$schedstatus = false;
484
				$dayArray = array (gettext('Mon'),gettext('Tues'),gettext('Wed'),gettext('Thur'),gettext('Fri'),gettext('Sat'),gettext('Sun'));
485
				$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'));
486
				if($config['schedules']['schedule'] <> "" and is_array($config['schedules']['schedule'])) {
487
					foreach ($a_schedules as $schedule)
488
					{
489
						if ($schedule['name'] == $filterent['sched'] ){
490
							$schedstatus = filter_get_time_based_rule_status($schedule);
491

    
492
							foreach($schedule['timerange'] as $timerange) {
493
								$tempFriendlyTime = "";
494
								$tempID = "";
495
								$firstprint = false;
496
								if ($timerange){
497
									$dayFriendly = "";
498
									$tempFriendlyTime = "";
499

    
500
									//get hours
501
									$temptimerange = $timerange['hour'];
502
									$temptimeseparator = strrpos($temptimerange, "-");
503

    
504
									$starttime = substr ($temptimerange, 0, $temptimeseparator);
505
									$stoptime = substr ($temptimerange, $temptimeseparator+1);
506

    
507
									if ($timerange['month']){
508
										$tempmontharray = explode(",", $timerange['month']);
509
										$tempdayarray = explode(",",$timerange['day']);
510
										$arraycounter = 0;
511
										$firstDayFound = false;
512
										$firstPrint = false;
513
										foreach ($tempmontharray as $monthtmp){
514
											$month = $tempmontharray[$arraycounter];
515
											$day = $tempdayarray[$arraycounter];
516

    
517
											if (!$firstDayFound)
518
											{
519
												$firstDay = $day;
520
												$firstmonth = $month;
521
												$firstDayFound = true;
522
											}
523

    
524
											$currentDay = $day;
525
											$nextDay = $tempdayarray[$arraycounter+1];
526
											$currentDay++;
527
											if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])){
528
												if ($firstPrint)
529
													$dayFriendly .= ", ";
530
												$currentDay--;
531
												if ($currentDay != $firstDay)
532
													$dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ;
533
												else
534
													$dayFriendly .=  $monthArray[$month-1] . " " . $day;
535
												$firstDayFound = false;
536
												$firstPrint = true;
537
											}
538
											$arraycounter++;
539
										}
540
									}
541
									else
542
									{
543
										$tempdayFriendly = $timerange['position'];
544
										$firstDayFound = false;
545
										$tempFriendlyDayArray = explode(",", $tempdayFriendly);
546
										$currentDay = "";
547
										$firstDay = "";
548
										$nextDay = "";
549
										$counter = 0;
550
										foreach ($tempFriendlyDayArray as $day){
551
											if ($day != ""){
552
												if (!$firstDayFound)
553
												{
554
													$firstDay = $tempFriendlyDayArray[$counter];
555
													$firstDayFound = true;
556
												}
557
												$currentDay =$tempFriendlyDayArray[$counter];
558
												//get next day
559
												$nextDay = $tempFriendlyDayArray[$counter+1];
560
												$currentDay++;
561
												if ($currentDay != $nextDay){
562
													if ($firstprint)
563
														$dayFriendly .= ", ";
564
													$currentDay--;
565
													if ($currentDay != $firstDay)
566
														$dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
567
													else
568
														$dayFriendly .= $dayArray[$firstDay-1];
569
													$firstDayFound = false;
570
													$firstprint = true;
571
												}
572
												$counter++;
573
											}
574
										}
575
									}
576
									$timeFriendly = $starttime . " - " . $stoptime;
577
									$description = $timerange['rangedescr'];
578
									$sched_content .= $dayFriendly . "; " . $timeFriendly . "<br />";
579
								}
580
							}
581
							$sched_caption_escaped = str_replace("'", "\'", $schedule['descr']);
582
							$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>";
583
							$schedule_span_end = "</u></span>";
584
						}
585
					}
586
				}
587
				$printicon = false;
588
				$alttext = "";
589
				$image = "";
590
				if (!isset($filterent['disabled'])) {
591
					if ($schedstatus) {
592
						if ($iconfn == "block" || $iconfn == "reject") {
593
							$image = "icon_block";
594
							$alttext = gettext("Traffic matching this rule is currently being denied");
595
						} else {
596
							$image = "icon_pass";
597
							$alttext = gettext("Traffic matching this rule is currently being allowed");
598
						}
599
						$printicon = true;
600
					} else if ($filterent['sched']) {
601
						if ($iconfn == "block" || $iconfn == "reject")
602
							$image = "icon_block_d";
603
						else
604
							$image = "icon_block";
605
						$alttext = gettext("This rule is not currently active because its period has expired");
606
						$printicon = true;
607
					}
608
				}
609
			?>
610
			<td class="listlr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
611
				<?=$textss;?><?php if (isset($filterent['id'])) echo $filterent['id']."&nbsp;"; else echo "&nbsp;"; ?><?=$textse;?>
612
			</td>
613
			<?php
614
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_id_tr");
615
			?>
616
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
617
			<?=$textss;?>
618
			<?php
619
				if (isset($filterent['ipprotocol'])) {
620
					switch($filterent['ipprotocol']) {
621
						case "inet":
622
							echo "IPv4 ";
623
							break;
624
						case "inet6":
625
							echo "IPv6 ";
626
							break;
627
						case "inet46":
628
							echo "IPv4+6 ";
629
							break;
630
					}
631
				} else {
632
					echo "IPv4 ";
633
				}
634
				if (isset($filterent['protocol'])) {
635
					echo strtoupper($filterent['protocol']);
636
					if (strtoupper($filterent['protocol']) == "ICMP" && !empty($filterent['icmptype'])) {
637
						echo ' <span style="cursor: help;" title="ICMP type: ' .
638
							( $filterent['ipprotocol'] == "inet6" ?  $icmp6types[$filterent['icmptype']] : $icmptypes[$filterent['icmptype']] ) .
639
							'"><u>';
640
						echo $filterent['icmptype'];
641
						echo '</u></span>';
642
					}
643
				} else echo "*";
644
			?>
645
			<?=$textse;?>
646
			</td>
647
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
648
				<?=$textss;?><?php echo $alias_src_span_begin;?><?php echo htmlspecialchars(pprint_address($filterent['source']));?><?php echo $alias_src_span_end;?><?=$textse;?>
649
			</td>
650
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
651
				<?=$textss;?><?php echo $alias_src_port_span_begin;?><?php echo htmlspecialchars(pprint_port($filterent['source']['port'])); ?><?php echo $alias_src_port_span_end;?><?=$textse;?>
652
			</td>
653
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
654
				<?=$textss;?><?php echo $alias_dst_span_begin;?><?php echo htmlspecialchars(pprint_address($filterent['destination'])); ?><?php echo $alias_dst_span_end;?><?=$textse;?>
655
			</td>
656
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
657
				<?=$textss;?><?php echo $alias_dst_port_span_begin;?><?php echo htmlspecialchars(pprint_port($filterent['destination']['port'])); ?><?php echo $alias_dst_port_span_end;?><?=$textse;?>
658
			</td>
659
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
660
				<?=$textss;?><?php if (isset($config['interfaces'][$filterent['gateway']]['descr'])) echo htmlspecialchars($config['interfaces'][$filterent['gateway']]['descr']); else  echo htmlspecialchars(pprint_port($filterent['gateway'])); ?><?=$textse;?>
661
			</td>
662
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
663
			<?=$textss;?>
664
			<?php
665
				if (isset($filterent['ackqueue']) && isset($filterent['defaultqueue'])) {
666
					$desc = $filterent['ackqueue'] ;
667
					echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['ackqueue']}&amp;action=show\">{$desc}</a>";
668
					$desc = $filterent['defaultqueue'];
669
					echo "/<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
670
				} else if (isset($filterent['defaultqueue'])) {
671
					$desc = $filterent['defaultqueue'];
672
					echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&amp;action=show\">{$desc}</a>";
673
				} else
674
					echo gettext("none");
675
			?>
676
			<?=$textse;?>
677
			</td>
678
			<td class="listr" onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';"><font color="black">
679
				<?php if ($printicon) { ?><img src="./themes/<?= $g['theme']; ?>/images/icons/<?php echo $image; ?>.gif" title="<?php echo $alttext;?>" border="0" alt="icon" /><?php } ?><?=$textss;?><?php echo $schedule_span_begin;?><?=htmlspecialchars($filterent['sched']);?>&nbsp;<?php echo $schedule_span_end; ?><?=$textse;?>
680
			</font></td>
681
			<?php
682
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_descr_tr");
683
			?>
684
			<td class="listbg descr" onclick="fr_toggle(<?=$nrules;?>)" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
685
				<?=$textss;?><?=htmlspecialchars($filterent['descr']);?>&nbsp;<?=$textse;?>
686
			</td>
687
			<td valign="middle" class="list nowrap">
688
				<table border="0" cellspacing="0" cellpadding="1" summary="move before">
689
					<tr>
690
					<td><input name="move_<?=$i;?>" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" style="width:17;height:17" title="<?=gettext("move selected rules before this rule"); ?>" onmouseover="fr_insline(<?=$nrules;?>, true)" onmouseout="fr_insline(<?=$nrules;?>, false)" /></td>
691
					<td><a href="firewall_rules_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit rule"); ?>" width="17" height="17" border="0" alt="edit" /></a></td>
692
					</tr>
693
					<tr>
694
					<td align="center" valign="middle"><a href="firewall_rules.php?act=del&amp;if=<?=htmlspecialchars($if);?>&amp;id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete rule"); ?>" onclick="return confirm('Do you really want to delete this rule?')" alt="delete" /></a></td>
695
					<td><a href="firewall_rules_edit.php?dup=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add a new rule based on this one"); ?>" width="17" height="17" border="0" alt="add" /></a></td>
696
					</tr>
697
				</table>
698
			</td>
699
			</tr>
700
			<?php $nrules++; endfor; ?>
701
			  <tr><td></td></tr></tbody>
702
<?php if ($nrules == 0): ?>
703
			<tr>
704
			<td class="listt"></td>
705
			<td class="listt"></td>
706
			<td class="listlr" colspan="10" align="center" valign="middle">
707
			<span class="gray">
708
	<?php if ($_REQUEST['if'] == "FloatingRules"): ?>
709
				<?=gettext("No floating rules are currently defined."); ?><br /><br />
710
	<?php else: ?>
711
				<?=gettext("No rules are currently defined for this interface"); ?><br />
712
				<?=gettext("All incoming connections on this interface will be blocked until you add pass rules."); ?><br /><br />
713
	<?php endif; ?>
714
				<?=gettext("Click the"); ?> <a href="firewall_rules_edit.php?if=<?=htmlspecialchars($if);?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add new rule");?>" border="0" width="17" height="17" align="middle" alt="add" /></a><?=gettext(" button to add a new rule.");?></span>
715
			</td>
716
			</tr>
717
<?php endif; ?>
718
			<tr id="fr<?=$nrules;?>">
719
			<td class="list"></td>
720
			<td class="list"></td>
721
			<?php
722
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_id_tr_belowtable");
723
			?>
724
			<td class="list">&nbsp;</td>
725
			<td class="list">&nbsp;</td>
726
			<td class="list">&nbsp;</td>
727
			<td class="list">&nbsp;</td>
728
			<td class="list">&nbsp;</td>
729
			<td class="list">&nbsp;</td>
730
			<td class="list">&nbsp;</td>
731
			<td class="list">&nbsp;</td>
732
			<td class="list">&nbsp;</td>
733
			<td class="list">&nbsp;</td>
734
			<td class="list">
735
				<table border="0" cellspacing="0" cellpadding="1" summary="move rules">
736
					<tr>
737
					<td>
738
						<?php if ($nrules == 0): ?><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected rules to end");?>" border="0" alt="move" /><?php else: ?><input name="move_<?=$i;?>" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" style="width:17;height:17" title="<?=gettext("move selected rules to end");?>" onmouseover="fr_insline(<?=$nrules;?>, true)" onmouseout="fr_insline(<?=$nrules;?>, false)" /><?php endif; ?></td>
739
					<td></td>
740
					</tr>
741
					<tr>
742
					<td>
743
<?php if ($nrules == 0): ?>
744
						<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected rules");?>" border="0" alt="delete" /><?php else: ?>
745
						<input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" style="width:17;height:17" title="<?=gettext("delete selected rules");?>" onclick="return confirm('<?=gettext('Do you really want to delete the selected rules?');?>')" />
746
<?php endif; ?>
747
					</td>
748
			                <td><a href="firewall_rules_edit.php?if=<?=htmlspecialchars($if);?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add new rule");?>" width="17" height="17" border="0" alt="add" /></a></td>
749
					</tr>
750
				</table>
751
			</td>
752
			</tr>
753
		</table>
754
		<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0" summary="icons">
755
			<tr>
756
				<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif" width="11" height="11" alt="pass" /></td>
757
				<td width="100"><?=gettext("pass");?></td>
758
				<td width="14"></td>
759
				<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_match.gif" width="11" height="11" alt="match" /></td>
760
				<td width="100"><?=gettext("match");?></td>
761
				<td width="14"></td>
762
				<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" alt="block" /></td>
763
				<td width="100"><?=gettext("block");?></td>
764
				<td width="14"></td>
765
				<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_reject.gif" width="11" height="11" alt="reject" /></td>
766
				<td width="100"><?=gettext("reject");?></td>
767
				<td width="14"></td>
768
				<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_log.gif" width="11" height="11" alt="log" /></td>
769
				<td width="100"><?=gettext("log");?></td>
770
			</tr>
771
			<tr>
772
				<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass_d.gif" width="11" height="11" alt="pass disabled" /></td>
773
				<td class="nowrap"><?=gettext("pass (disabled)");?></td>
774
				<td>&nbsp;</td>
775
				<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_match_d.gif" width="11" height="11" alt="match disabled" /></td>
776
				<td class="nowrap"><?=gettext("match (disabled)");?></td>
777
				<td>&nbsp;</td>
778
				<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block_d.gif" width="11" height="11" alt="block disabled" /></td>
779
				<td class="nowrap"><?=gettext("block (disabled)");?></td>
780
				<td>&nbsp;</td>
781
				<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_reject_d.gif" width="11" height="11" alt="reject disabled" /></td>
782
				<td class="nowrap"><?=gettext("reject (disabled)");?></td>
783
				<td>&nbsp;</td>
784
				<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_log_d.gif" width="11" height="11" alt="log disabled" /></td>
785
				<td class="nowrap"><?=gettext("log (disabled)");?></td>
786
			</tr>
787
			<tr>
788
				<td colspan="10">
789
					<p>&nbsp;</p>
790
					<strong>
791
						<span class="red"><?=gettext("Hint:");?></span>
792
					</strong><br />
793
					<ul>
794
					<?php if ("FloatingRules" != $if): ?>
795
						<li><?=gettext("Rules are evaluated on a first-match basis (i.e. " .
796
						"the action of the first rule to match a packet will be executed). " .
797
						"This means that if you use block rules, you'll have to pay attention " .
798
						"to the rule order. Everything that isn't explicitly passed is blocked " .
799
						"by default. ");?>
800
						</li>
801
					<?php else: ?>
802
						<li><?=gettext("Floating rules are evaluated on a first-match basis (i.e. " .
803
						"the action of the first rule to match a packet will be executed) only " .
804
						"if the 'quick' option is checked on a rule. Otherwise they will only apply if no " .
805
						"other rules match. Pay close attention to the rule order and options " .
806
						"chosen. If no rule here matches, the per-interface or default rules are used. ");?>
807
						</li>
808
					<?php endif; ?>
809
					</ul>
810
				 </td>
811
			</tr>
812
		</table>
813
		</div>
814
	</td>
815
	</tr>
816
</table>
817
<input type="hidden" name="if" value="<?=htmlspecialchars($if);?>" />
818
</form>
819
<?php include("fend.inc"); ?>
820
</body>
821
</html>
(71-71/252)