Project

General

Profile

Download (31.7 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
$statusurl = "status_filter_reload.php";
46
$logurl = "diag_logs_filter.php";
47

    
48
require("guiconfig.inc");
49
require_once("functions.inc");
50
require_once("filter.inc");
51
require_once("shaper.inc");
52

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

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

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

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

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

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

    
95
$if = $_GET['if'];
96
if ($_POST['if'])
97
	$if = $_POST['if'];
98

    
99
$ifdescs = get_configured_interface_with_descr();
100

    
101
/* add group interfaces */
102
if (is_array($config['ifgroups']['ifgroupentry']))
103
	foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
104
		if (have_ruleint_access($ifgen['ifname']))
105
			$iflist[$ifgen['ifname']] = $ifgen['ifname'];
106

    
107
foreach ($ifdescs as $ifent => $ifdesc)
108
	if(have_ruleint_access($ifent)) 
109
		$iflist[$ifent] = $ifdesc;
110

    
111
if ($config['l2tp']['mode'] == "server")
112
        if(have_ruleint_access("l2tp"))
113
                $iflist['l2tp'] = "L2TP VPN";
114

    
115
if ($config['pptpd']['mode'] == "server")
116
	if(have_ruleint_access("pptp")) 
117
		$iflist['pptp'] = "PPTP VPN";
118

    
119
if ($config['pppoe']['mode'] == "server")
120
	if(have_ruleint_access("pppoe")) 
121
		$iflist['pppoe'] = "PPPoE VPN";
122

    
123
/* add ipsec interfaces */
124
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
125
	if(have_ruleint_access("enc0")) 
126
		$iflist["enc0"] = "IPsec";
127

    
128
/* add openvpn/tun interfaces */
129
if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
130
   	$iflist["openvpn"] = "OpenVPN";
131

    
132
if (!$if || !isset($iflist[$if])) {
133
	if ("any" == $if)
134
                $if = "FloatingRules";
135
        else if ("FloatingRules" != $if)
136
                $if = "wan";
137
}
138

    
139
if ($_POST) {
140

    
141
	$pconfig = $_POST;
142

    
143
	if ($_POST['apply']) {
144
		$retval = 0;
145
		$retval = filter_configure();
146

    
147
		clear_subsystem_dirty('filter');
148

    
149
		$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.";
150
	}
151
}
152

    
153
if ($_GET['act'] == "del") {
154
	if ($a_filter[$_GET['id']]) {
155
		if (!empty($a_filter[$_GET['id']]['associated-rule-id'])) {
156
			delete_nat_association($a_filter[$_GET['id']]['associated-rule-id']);
157
		}
158
		unset($a_filter[$_GET['id']]);
159
		write_config();
160
		mark_subsystem_dirty('filter');
161
		header("Location: firewall_rules.php?if={$if}");
162
		exit;
163
	}
164
}
165

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

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

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

    
217
		/* copy $movebtn rule */
218
		if ($movebtn < count($a_filter))
219
			$a_filter_new[] = $a_filter[$movebtn];
220

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

    
227
		$a_filter = $a_filter_new;
228
		write_config();
229
		mark_subsystem_dirty('filter');
230
		header("Location: firewall_rules.php?if={$if}");
231
		exit;
232
	}
233
}
234
$closehead = false;
235

    
236
include("head.inc");
237

    
238
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
239
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
240
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
241
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
242
?>
243
</head>
244

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