Project

General

Profile

Download (31.8 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	firewall_rules.php
5
	part of pfSense (http://www.pfsense.com)
6
        Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
7

    
8
	originally part of m0n0wall (http://m0n0.ch/wall)
9
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11

    
12
	Redistribution and use in source and binary forms, with or without
13
	modification, 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 the
20
	   documentation and/or other materials provided with the distribution.
21

    
22
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33
/*
34
	pfSense_MODULE:	filter
35
*/
36

    
37
##|+PRIV
38
##|*IDENT=page-firewall-rules
39
##|*NAME=Firewall: Rules page
40
##|*DESCR=Allow access to the 'Firewall: Rules' page.
41
##|*MATCH=firewall_rules.php*
42
##|-PRIV
43

    
44
$pgtitle = array("Firewall", "Rules");
45
require("guiconfig.inc");
46
require_once("functions.inc");
47
require_once("filter.inc");
48
require_once("shaper.inc");
49

    
50
function check_for_advaned_options(&$item) {
51
	$item_set = "";
52
	if($item['max'])
53
		$item_set .= "max {$item['max']} ";
54
	if($item['max-src-nodes'])
55
		$item_set .= "max-src-nodes {$item['max-src-nodes']} ";
56
	if($item['max-src-conn'])
57
		$item_set .= "max-src-conn {$item['max-src-conn']} ";
58
	if($item['max-src-states'])
59
		$item_set .= "max-src-states {$item['max-src-states']} ";
60
	if($item['statetype'] != "keep state" && $item['statetype'] != "")
61
		$item_set .= "statetype {$item['statetype']} {$item['statetype']}";
62
	if($item['statetimeout'])
63
		$item_set .= "statetimeout {$item['statetimeout']}";
64
	if($item['nosync'])
65
		$item_set .= "nosync ";
66
	if($item['max-src-conn-rate'])
67
		$item_set .= "max-src-conn-rate {$item['max-src-conn-rate']} ";
68
	if($item['max-src-conn-rates'])
69
		$item_set .= "max-src-conn-rates {$item['max-src-conn-rates']} ";
70
	return $item_set;
71
}
72

    
73
function delete_nat_association(&$a_nat, $id) {
74
	if (!$id || !is_array($a_nat))
75
		return;
76

    
77
	for ($pos = 0; $pos < sizeof($a_nat); $pos++) {
78
		if ($a_nat[$pos]['associated-rule-id'] == $id)
79
			$a_nat[$pos]['associated-rule-id'] = '';
80
	}
81
}
82

    
83
if (!is_array($config['filter']['rule'])) {
84
	$config['filter']['rule'] = array();
85
}
86
filter_rules_sort();
87
$a_filter = &$config['filter']['rule'];
88

    
89
$if = $_GET['if'];
90
if ($_POST['if'])
91
	$if = $_POST['if'];
92

    
93
$ifdescs = get_configured_interface_with_descr();
94

    
95
/* add group interfaces */
96
if (is_array($config['ifgroups']['ifgroupentry']))
97
	foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
98
		if (have_ruleint_access($ifgen['ifname']))
99
			$iflist[$ifgen['ifname']] = $ifgen['ifname'];
100

    
101
foreach ($ifdescs as $ifent => $ifdesc)
102
	if(have_ruleint_access($ifent)) 
103
		$iflist[$ifent] = $ifdesc;
104

    
105
if ($config['l2tp']['mode'] == "server")
106
        if(have_ruleint_access("l2tp"))
107
                $iflist['l2tp'] = "L2TP VPN";
108

    
109
if ($config['pptpd']['mode'] == "server")
110
	if(have_ruleint_access("pptp")) 
111
		$iflist['pptp'] = "PPTP VPN";
112

    
113
if ($config['pppoe']['mode'] == "server")
114
	if(have_ruleint_access("pppoe")) 
115
		$iflist['pppoe'] = "PPPoE VPN";
116

    
117
/* add ipsec interfaces */
118
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
119
	if(have_ruleint_access("enc0")) 
120
		$iflist["enc0"] = "IPsec";
121

    
122
/* add openvpn/tun interfaces */
123
if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
124
   	$iflist["openvpn"] = "OpenVPN";
125

    
126
if (!$if || !isset($iflist[$if])) {
127
	if ("any" == $if)
128
                $if = "FloatingRules";
129
        else if ("FloatingRules" != $if)
130
                $if = "wan";
131
}
132

    
133
if ($_POST) {
134

    
135
	$pconfig = $_POST;
136

    
137
	if ($_POST['apply']) {
138
		$retval = 0;
139
		$retval = filter_configure();
140

    
141
		clear_subsystem_dirty('filter');
142

    
143
		$savemsg = "The settings have been applied.  The firewall rules are now reloading in the background.  You can also <a href='status_filter_reload.php'>monitor</a> the reload progress.";
144
	}
145
}
146

    
147
if ($_GET['act'] == "del") {
148
	if ($a_filter[$_GET['id']]) {
149
		if (!empty($a_filter[$_GET['id']]['associated-rule-id'])) {
150
			$a_nat = &$config['nat']['rule'];
151
			delete_nat_association($a_nat, $a_filter[$_GET['id']]['associated-rule-id']);
152
		}
153
		unset($a_filter[$_GET['id']]);
154
		write_config();
155
		mark_subsystem_dirty('filter');
156
		header("Location: firewall_rules.php?if={$if}");
157
		exit;
158
	}
159
}
160

    
161
if (isset($_POST['del_x'])) {
162
	/* delete selected rules */
163
	if (is_array($_POST['rule']) && count($_POST['rule'])) {
164
		$a_nat = &$config['nat']['rule'];
165
		foreach ($_POST['rule'] as $rulei) {
166
			delete_nat_association($a_nat, $a_filter[$rulei]['associated-rule-id']);
167
			unset($a_filter[$rulei]);
168
		}
169
		write_config();
170
		mark_subsystem_dirty('filter');
171
		header("Location: firewall_rules.php?if={$if}");
172
		exit;
173
	}
174
} else if ($_GET['act'] == "toggle") {
175
	if ($a_filter[$_GET['id']]) {
176
                if(isset($a_filter[$_GET['id']]['disabled']))
177
                        unset($a_filter[$_GET['id']]['disabled']);
178
                else
179
                        $a_filter[$_GET['id']]['disabled'] = true;
180
		write_config();
181
		mark_subsystem_dirty('filter');
182
		header("Location: firewall_rules.php?if={$if}");
183
		exit;
184
	}
185
} else {
186
	/* yuck - IE won't send value attributes for image buttons, while Mozilla does -
187
	   so we use .x/.y to fine move button clicks instead... */
188
	unset($movebtn);
189
	foreach ($_POST as $pn => $pd) {
190
		if (preg_match("/move_(\d+)_x/", $pn, $matches)) {
191
			$movebtn = $matches[1];
192
			break;
193
		}
194
	}
195
	/* move selected rules before this rule */
196
	if (isset($movebtn) && is_array($_POST['rule']) && count($_POST['rule'])) {
197
		$a_filter_new = array();
198

    
199
		/* copy all rules < $movebtn and not selected */
200
		for ($i = 0; $i < $movebtn; $i++) {
201
			if (!in_array($i, $_POST['rule']))
202
				$a_filter_new[] = $a_filter[$i];
203
		}
204

    
205
		/* copy all selected rules */
206
		for ($i = 0; $i < count($a_filter); $i++) {
207
			if ($i == $movebtn)
208
				continue;
209
			if (in_array($i, $_POST['rule']))
210
				$a_filter_new[] = $a_filter[$i];
211
		}
212

    
213
		/* copy $movebtn rule */
214
		if ($movebtn < count($a_filter))
215
			$a_filter_new[] = $a_filter[$movebtn];
216

    
217
		/* copy all rules > $movebtn and not selected */
218
		for ($i = $movebtn+1; $i < count($a_filter); $i++) {
219
			if (!in_array($i, $_POST['rule']))
220
				$a_filter_new[] = $a_filter[$i];
221
		}
222

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

    
232
include("head.inc");
233

    
234
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
235
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
236
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
237
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
238
?>
239
</head>
240

    
241
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
242
<?php include("fbegin.inc"); ?>
243
<form action="firewall_rules.php" method="post">
244
<script type="text/javascript" language="javascript" src="/javascript/row_toggle.js">
245
</script>
246
<?php if ($savemsg) print_info_box($savemsg); ?>
247
<?php if (is_subsystem_dirty('filter')): ?><p>
248
<?php print_info_box_np("The firewall rule configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
249
<?php endif; ?>
250
<table width="100%" border="0" cellpadding="0" cellspacing="0">
251
  <tr><td class="tabnavtbl">
252
  <?php
253
	/* active tabs */
254
	$tab_array = array();
255
       if ("FloatingRules" == $if)
256
                        $active = true;
257
                else
258
                        $active = false;
259
        $tab_array[] = array("Floating", $active, "firewall_rules.php?if=FloatingRules");
260
	$tabscounter = 0; $i = 0; foreach ($iflist as $ifent => $ifname) {
261
		if ($ifent == $if)
262
			$active = true;
263
		else
264
			$active = false;
265
		$tab_array[] = array($ifname, $active, "firewall_rules.php?if={$ifent}");
266
	}
267
	display_top_tabs($tab_array);
268
  ?>
269
  </td></tr>
270
  <tr>
271
    <td>
272
	<div id="mainarea">
273
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
274
                <tr id="frheader">
275
                  <td width="3%" class="list">&nbsp;</td>
276
                  <td width="5%" class="list">&nbsp;</td>
277
                  <td width="3%" class="listhdrr">ID</td>
278
                  <td width="6%" class="listhdrr">Proto</td>
279
                  <td width="12%" class="listhdrr">Source</td>
280
                  <td width="6%" class="listhdrr">Port</td>
281
                  <td width="12%" class="listhdrr">Destination</td>
282
                  <td width="6%" class="listhdrr">Port</td>
283
		  <td width="5%" class="listhdrr">Gateway</td>
284
		  <td width="8%" class="listhdrr">Queue</td>
285
		  <td width="5%" class="listhdrr">Schedule</td>
286
                  <td width="19%" class="listhdr">Description</td>
287
                  <td width="10%" class="list">
288
			<table border="0" cellspacing="0" cellpadding="1">
289
			   <tr>
290
				<?php
291
					$nrules = 0;
292
					for ($i = 0; isset($a_filter[$i]); $i++) {
293
						$filterent = $a_filter[$i];
294
						if ($filterent['interface'] != $if && !isset($filterent['floating']))
295
							continue;
296
						if (isset($filterent['floating']) && "FloatingRules" != $if)
297
							continue;
298
						$nrules++;
299
					}
300
				?>
301
				<td>
302
				<?php if ($nrules == 0): ?>
303
				<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="delete selected rules" border="0"><?php else: ?>
304
				<input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" title="delete selected rules" onclick="return confirm('Do you really want to delete the selected rules?')"><?php endif; ?>
305
				</td>
306
				<td align="center" valign="middle"><a href="firewall_rules_edit.php?if=<?=$if;?>&after=-1"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="add new rule" width="17" height="17" border="0"></a></td>
307
			   </tr>
308
			</table>
309
		  </td>
310
		</tr>
311
<?php if (isset($config['interfaces'][$if]['blockpriv'])): ?>
312
                <tr valign="top" id="frrfc1918">
313
                  <td class="list">&nbsp;</td>
314
                  <td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0"></td>
315
                  <td class="listlr" style="background-color: #e0e0e0"></td>
316
                  <td class="listr" style="background-color: #e0e0e0">*</td>
317
                  <td class="listr" style="background-color: #e0e0e0">RFC 1918 networks</td>
318
                  <td class="listr" style="background-color: #e0e0e0">*</td>
319
                  <td class="listr" style="background-color: #e0e0e0">*</td>
320
                  <td class="listr" style="background-color: #e0e0e0">*</td>
321
                  <td class="listr" style="background-color: #e0e0e0">*</td>
322
		<td class="listr" style="background-color: #e0e0e0">*</td>
323
	 		 <td class="listr" style="background-color: #e0e0e0"></td>
324
                  <td class="listbg">Block private networks</td>
325
                  <td valign="middle" nowrap class="list">
326
				    <table border="0" cellspacing="0" cellpadding="1">
327
					<tr>
328
					  <td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="move selected rules before this rule"></td>
329
					  <td><a href="interfaces.php#rfc1918"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit rule" width="17" height="17" border="0"></a></td>
330
					</tr>
331
					<tr>
332
					  <td align="center" valign="middle"></td>
333
					  <td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus_d.gif" title="add a new rule based on this one" width="17" height="17" border="0"></td>
334
					</tr>
335
					</table>
336
				  </td>
337
				</tr>
338
<?php endif; ?>
339
<?php if (isset($config['interfaces'][$if]['blockbogons'])): ?>
340
                <tr valign="top" id="frrfc1918">
341
                  <td class="list">&nbsp;</td>
342
                  <td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0"></td>
343
                  <td class="listlr" style="background-color: #e0e0e0"></td>
344
                  <td class="listr" style="background-color: #e0e0e0">*</td>
345
                  <td class="listr" style="background-color: #e0e0e0">Reserved/not assigned by IANA</td>
346
                  <td class="listr" style="background-color: #e0e0e0">*</td>
347
                  <td class="listr" style="background-color: #e0e0e0">*</td>
348
                  <td class="listr" style="background-color: #e0e0e0">*</td>
349
				  <td class="listr" style="background-color: #e0e0e0">*</td>
350
				   <td class="listr" style="background-color: #e0e0e0">*</td>
351
		  <td class="listr" style="background-color: #e0e0e0">*</td>
352
                  <td class="listbg">Block bogon networks</td>
353
                  <td valign="middle" nowrap class="list">
354
				    <table border="0" cellspacing="0" cellpadding="1">
355
					<tr>
356
					  <td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="move selected rules before this rule"></td>
357
					  <td><a href="interfaces.php#rfc1918"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit rule" width="17" height="17" border="0"></a></td>
358
					</tr>
359
					<tr>
360
					  <td align="center" valign="middle"></td>
361
					  <td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus_d.gif" title="add a new rule based on this one" width="17" height="17" border="0"></td>
362
					</tr>
363
					</table>
364
				  </td>
365
				</tr>
366
<?php endif; ?>
367
				<?php $nrules = 0; for ($i = 0; isset($a_filter[$i]); $i++):
368
					$filterent = $a_filter[$i];
369
					if ($filterent['interface'] != $if && !isset($filterent['floating']))
370
						continue;
371
					if (isset($filterent['floating']) && "FloatingRules" != $if)
372
						continue;
373
					$isadvset = check_for_advaned_options($filterent);
374
					if($isadvset)
375
						$advanced_set = "<img src=\"./themes/{$g['theme']}/images/icons/icon_advanced.gif\" title=\"advanced settings set: $isadvset\" border=\"0\">";
376
					else 
377
						$advanced_set = ""
378
				?>
379
                <tr valign="top" id="fr<?=$nrules;?>">
380
                  <td class="listt">
381
					<input type="checkbox" id="frc<?=$nrules;?>" name="rule[]" value="<?=$i;?>" onClick="fr_bgcolor('<?=$nrules;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;">
382
					<?php echo $advanced_set; ?>
383
				  </td>
384
                  <td class="listt" align="center">
385
				  <?php if ($filterent['type'] == "block")
386
				  			$iconfn = "block";
387
						else if ($filterent['type'] == "reject") {
388
							$iconfn = "reject";
389
						} else
390
							$iconfn = "pass";
391
						if (isset($filterent['disabled'])) {
392
							$textss = "<span class=\"gray\">";
393
							$textse = "</span>";
394
							$iconfn .= "_d";
395
						} else {
396
							$textss = $textse = "";
397
						}
398
				  ?>
399
				  <a href="?if=<?=$if;?>&act=toggle&id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfn;?>.gif" width="11" height="11" border="0" title="click to toggle enabled/disabled status"></a>
400
				  <?php if (isset($filterent['log'])):
401
							$iconfnlog = "log_s";
402
						if (isset($filterent['disabled']))
403
							$iconfnlog .= "_d";
404
				  	?>
405
				  <br><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfnlog;?>.gif" width="11" height="15" border="0">
406
				  <?php endif; ?>
407
				  </td>
408
				<?php
409
				
410
				//build Alias popup box
411
				$span_end = "";
412
				$alias_src_span_begin = "";
413
				$alias_src_port_span_begin = "";
414
				$alias_dst_span_begin = "";
415
				$alias_dst_port_span_begin = "";
416
				
417
				$alias_popup = rule_popup($filterent['source']['address'],pprint_port($filterent['source']['port']),$filterent['destination']['address'],pprint_port($filterent['destination']['port']));
418
				$span_end = "</U></span>";
419
					
420
				$alias_src_span_begin = $alias_popup["src"];
421
				 									
422
				$alias_src_port_span_begin = $alias_popup["srcport"];
423
													
424
				$alias_dst_span_begin = $alias_popup["dst"];
425
														
426
				$alias_dst_port_span_begin = $alias_popup["dstport"];
427
					
428
				//build Schedule popup box
429
				$a_schedules = &$config['schedules']['schedule'];
430
				$schedule_span_begin = "";
431
				$schedule_span_end = "";
432
				$sched_caption_escaped = "";
433
				$sched_content = "";
434
				$schedstatus = false;
435
				$dayArray = array ('Mon','Tues','Wed','Thur','Fri','Sat','Sun');
436
				$monthArray = array ('January','February','March','April','May','June','July','August','September','October','November','December');
437
				if($config['schedules']['schedule'] <> "" and is_array($config['schedules']['schedule'])){
438
					foreach ($a_schedules as $schedule)
439
					{
440
						if ($schedule['name'] == $filterent['sched'] ){
441
							$schedstatus = filter_get_time_based_rule_status($schedule);
442
							
443
							foreach($schedule['timerange'] as $timerange) {
444
								$tempFriendlyTime = "";
445
								$tempID = "";
446
								$firstprint = false;
447
								if ($timerange){
448
									$dayFriendly = "";
449
									$tempFriendlyTime = "";							
450
										
451
									//get hours
452
									$temptimerange = $timerange['hour'];
453
									$temptimeseparator = strrpos($temptimerange, "-");
454
									
455
									$starttime = substr ($temptimerange, 0, $temptimeseparator); 
456
									$stoptime = substr ($temptimerange, $temptimeseparator+1); 
457
										
458
									if ($timerange['month']){
459
										$tempmontharray = explode(",", $timerange['month']);
460
										$tempdayarray = explode(",",$timerange['day']);
461
										$arraycounter = 0;
462
										$firstDayFound = false;
463
										$firstPrint = false;
464
										foreach ($tempmontharray as $monthtmp){
465
											$month = $tempmontharray[$arraycounter];
466
											$day = $tempdayarray[$arraycounter];
467
											
468
											if (!$firstDayFound)
469
											{
470
												$firstDay = $day;
471
												$firstmonth = $month;
472
												$firstDayFound = true;
473
											}
474
												
475
											$currentDay = $day;
476
											$nextDay = $tempdayarray[$arraycounter+1];
477
											$currentDay++;
478
											if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])){
479
												if ($firstPrint)
480
													$dayFriendly .= ", ";
481
												$currentDay--;
482
												if ($currentDay != $firstDay)
483
													$dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ;
484
												else
485
													$dayFriendly .=  $monthArray[$month-1] . " " . $day;
486
												$firstDayFound = false;	
487
												$firstPrint = true;
488
											}													
489
											$arraycounter++;	
490
										}
491
									}
492
									else
493
									{
494
										$tempdayFriendly = $timerange['position'];
495
										$firstDayFound = false;
496
										$tempFriendlyDayArray = explode(",", $tempdayFriendly);								
497
										$currentDay = "";
498
										$firstDay = "";
499
										$nextDay = "";
500
										$counter = 0;													
501
										foreach ($tempFriendlyDayArray as $day){
502
											if ($day != ""){
503
												if (!$firstDayFound)
504
												{
505
													$firstDay = $tempFriendlyDayArray[$counter];
506
													$firstDayFound = true;
507
												}
508
												$currentDay =$tempFriendlyDayArray[$counter];
509
												//get next day
510
												$nextDay = $tempFriendlyDayArray[$counter+1];
511
												$currentDay++;					
512
												if ($currentDay != $nextDay){
513
													if ($firstprint)
514
														$dayFriendly .= ", ";
515
													$currentDay--;
516
													if ($currentDay != $firstDay)
517
														$dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
518
													else
519
														$dayFriendly .= $dayArray[$firstDay-1];
520
													$firstDayFound = false;	
521
													$firstprint = true;			
522
												}
523
												$counter++;
524
											}
525
										}
526
									}		
527
									$timeFriendly = $starttime . " - " . $stoptime;
528
									$description = $timerange['rangedescr'];
529
									$sched_content .= $dayFriendly . "; " . $timeFriendly . "<br>";
530
								}
531
							}
532
							$sched_caption_escaped = str_replace("'", "\'", $schedule['descr']);
533
							$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>";
534
							$schedule_span_end = "</U></span>";
535
						}
536
					}
537
				}
538
				$printicon = false;
539
				$alttext = "";
540
				$image = "";
541
				if (!isset($filterent['disabled'])){
542
					 if ($schedstatus) 
543
					 { 
544
					 	if ($iconfn == "block" || $iconfn == "reject")
545
					 	{
546
					 		$image = "icon_block";
547
					 		$alttext = "Traffic matching this rule is currently being denied";
548
					 	}
549
					 	else
550
					 	{
551
					 		$image = "icon_pass";
552
					 		$alttext = "Traffic matching this rule is currently being allowed";
553
					 	}
554
					 	$printicon = true;
555
					  }
556
					  else if ($filterent['sched'])
557
					  { 
558
					 	if ($iconfn == "block" || $iconfn == "reject")
559
					 	{
560
					 		$image = "icon_block_d";
561
					 		$alttext = "Traffic matching this rule is currently being allowed";
562
					 	}
563
					 	else
564
					 	{
565
					 		$image = "icon_block";
566
					 		$alttext = "Traffic matching this rule is currently being denied";
567
					 	}
568
					 	$printicon = true;				  	
569
					  }
570
				}
571
				?>
572
                  <td class="listlr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
573
                    <?=$textss;?><?php if (isset($filterent['id'])) echo $filterent['id']; else echo ""; ?><?=$textse;?>
574
                  </td>
575
                  <td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
576
                    <?=$textss;?><?php if (isset($filterent['protocol'])) echo strtoupper($filterent['protocol']); else echo "*"; ?><?=$textse;?>
577
                  </td>
578
                  <td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
579
				    <?=$textss;?><?php echo $alias_src_span_begin;?><?php echo htmlspecialchars(pprint_address($filterent['source']));?><?php echo $alias_src_span_end;?><?=$textse;?>
580
                  </td>
581
                  <td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
582
                    <?=$textss;?><?php echo $alias_src_port_span_begin;?><?php echo htmlspecialchars(pprint_port($filterent['source']['port'])); ?><?php echo $alias_src_port_span_end;?><?=$textse;?>
583
                  </td>
584
                  <td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
585
				    <?=$textss;?><?php echo $alias_dst_span_begin;?><?php echo htmlspecialchars(pprint_address($filterent['destination'])); ?><?php echo $alias_dst_span_end;?><?=$textse;?>
586
                  </td>
587
	              <td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
588
                    <?=$textss;?><?php echo $alias_dst_port_span_begin;?><?php echo htmlspecialchars(pprint_port($filterent['destination']['port'])); ?><?php echo $alias_dst_port_span_end;?><?=$textse;?>
589
                  </td>
590
                  <td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
591
                    <?=$textss;?><?php if (isset($config['interfaces'][$filterent['gateway']]['descr'])) echo htmlspecialchars($config['interfaces'][$filterent['gateway']]['descr']); else  echo htmlspecialchars(pprint_port($filterent['gateway'])); ?><?=$textse;?>
592
                  </td>
593
<td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';"><?=$textss;?>
594
                          <?php
595
							if (isset($filterent['ackqueue']) && isset($filterent['defaultqueue'])) {
596
								$desc = $filterent['ackqueue'] ;
597
							    echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['ackqueue']}&action=show\">{$desc}</a>";
598
								$desc = $filterent['defaultqueue'];
599
							    echo "/<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&action=show\">{$desc}</a>";
600
							} else if (isset($filterent['defaultqueue'])) {
601
								$desc = $filterent['defaultqueue'];
602
							    echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&action=show\">{$desc}</a>"; }
603
							else echo "none";
604
						  ?><?=$textse;?>
605
                        </td>
606
                  <td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';"><font color="black">
607
                    <?php if ($printicon) { ?><img src="./themes/<?= $g['theme']; ?>/images/icons/<?php echo $image; ?>.gif" title="<?php echo $alttext;?>" border="0"><?php } ?>&nbsp;<?=$textss;?><?php echo $schedule_span_begin;?><?=htmlspecialchars($filterent['sched']);?><?php echo $schedule_span_end; ?><?=$textse;?>
608
                  </td>
609
                  <td class="listbg" onClick="fr_toggle(<?=$nrules;?>)" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';" class="descr">
610
                    <?=$textss;?><?=htmlspecialchars($filterent['descr']);?>&nbsp;<?=$textse;?>
611
                  </td>
612
                  <td valign="middle" nowrap class="list">
613
				    <table border="0" cellspacing="0" cellpadding="1">
614
					<tr>
615
					  <td><input name="move_<?=$i;?>" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" width="17" height="17" title="move selected rules before this rule" onMouseOver="fr_insline(<?=$nrules;?>, true)" onMouseOut="fr_insline(<?=$nrules;?>, false)"></td>
616
					  <td><a href="firewall_rules_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit rule" width="17" height="17" border="0"></a></td>
617
					</tr>
618
					<tr>
619
					  <td align="center" valign="middle"><a href="firewall_rules.php?act=del&if=<?=$if;?>&id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="delete rule" onclick="return confirm('Do you really want to delete this rule?')"></a></td>
620
					  <td><a href="firewall_rules_edit.php?dup=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="add a new rule based on this one" width="17" height="17" border="0"></a></td>
621
					</tr>
622
					</table>
623
				  </td>
624
				</tr>
625
			  <?php $nrules++; endfor; ?>
626
			  <?php if ($nrules == 0): ?>
627
              <td class="listt"></td>
628
			  <td class="listt"></td>
629
			  <td class="listlr" colspan="10" align="center" valign="middle">
630
			  <span class="gray">
631
			  No rules are currently defined for this interface.<br>
632
			  All incoming connections on this interface will be blocked until you add pass rules.<br><br>
633
			  Click the <a href="firewall_rules_edit.php?if=<?=$if;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="add new rule" border="0" width="17" height="17" align="absmiddle"></a> button to add a new rule.</span>
634
			  </td>
635
			  <?php endif; ?>
636
                <tr id="fr<?=$nrules;?>">
637
                  <td class="list"></td>
638
                  <td class="list"></td>
639
                  <td class="list">&nbsp;</td>
640
                  <td class="list">&nbsp;</td>
641
                  <td class="list">&nbsp;</td>
642
                  <td class="list">&nbsp;</td>
643
		  <td class="list">&nbsp;</td>
644
		  <td class="list">&nbsp;</td>
645
                  <td class="list">&nbsp;</td>
646
                  <td class="list">&nbsp;</td>
647
                  <td class="list">&nbsp;</td>
648
                  <td class="list">&nbsp;</td>
649
                  <td class="list">
650
				    <table border="0" cellspacing="0" cellpadding="1">
651
					<tr>
652
				      <td>
653
					  <?php if ($nrules == 0): ?><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="move selected rules to end" border="0"><?php else: ?><input name="move_<?=$i;?>" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" width="17" height="17" title="move selected rules to end" onMouseOver="fr_insline(<?=$nrules;?>, true)" onMouseOut="fr_insline(<?=$nrules;?>, false)"><?php endif; ?></td>
654
					  <td></td>
655
				    </tr>
656
					<tr>
657
					  <td>
658
					  <?php if ($nrules == 0): ?>
659
					  <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="delete selected rules" border="0"><?php else: ?>
660
					  <input name="del" type="image" src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" title="delete selected rules" onclick="return confirm('Do you really want to delete the selected rules?')"><?php endif; ?>
661
					  </td>
662
			                  <td><a href="firewall_rules_edit.php?if=<?=$if;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="add new rule" width="17" height="17" border="0"></a></td>
663
					</tr>
664
				    </table>
665
				  </td>
666
				</tr>
667
              </table>
668
	      <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
669
                <tr>
670
                  <td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif" width="11" height="11"></td>
671
                  <td>pass</td>
672
                  <td width="14"></td>
673
                  <td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11"></td>
674
                  <td>block</td>
675
                  <td width="14"></td>
676
                  <td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_reject.gif" width="11" height="11"></td>
677
                  <td>reject</td>
678
                  <td width="14"></td>
679
                  <td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_log.gif" width="11" height="11"></td>
680
                  <td>log</td>
681
                </tr>
682
                <tr>
683
                  <td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass_d.gif" width="11" height="11"></td>
684
                  <td nowrap>pass (disabled)</td>
685
                  <td>&nbsp;</td>
686
                  <td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block_d.gif" width="11" height="11"></td>
687
                  <td nowrap>block (disabled)</td>
688
                  <td>&nbsp;</td>
689
                  <td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_reject_d.gif" width="11" height="11"></td>
690
                  <td nowrap>reject (disabled)</td>
691
                  <td>&nbsp;</td>
692
                  <td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_log_d.gif" width="11" height="11"></td>
693
                  <td nowrap>log (disabled)</td>
694
                </tr>
695
		<tr>
696
		  <td colspan="10">
697
  <p>
698
  <strong><span class="red">Hint:<br>
699
  </span></strong>Rules are evaluated on a first-match basis (i.e.
700
  the action of the first rule to match a packet will be executed).
701
  This means that if you use block rules, you'll have to pay attention
702
  to the rule order. Everything that isn't explicitly passed is blocked
703
  by default.</p>
704
		 </td>
705
	        </tr>
706
              </table>
707
	</div>
708
    </td>
709
  </tr>
710
</table>
711
  <input type="hidden" name="if" value="<?=$if;?>">
712
</form>
713
<?php include("fend.inc"); ?>
714
</body>
715
</html>
(55-55/216)