Project

General

Profile

Download (32.2 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
$pgtitle = array("Firewall", "Rules");
35
require("guiconfig.inc");
36

    
37
if (!is_array($config['filter']['rule'])) {
38
	$config['filter']['rule'] = array();
39
}
40
filter_rules_sort();
41
$a_filter = &$config['filter']['rule'];
42

    
43
$if = $_GET['if'];
44
if ($_POST['if'])
45
	$if = $_POST['if'];
46

    
47
$iflist = array();
48

    
49
if(have_ruleint_access("lan")) 
50
	$iflist['lan'] = "LAN";
51
if(have_ruleint_access("wan")) 
52
	$iflist['wan'] = "WAN";
53

    
54
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) 
55
	if(have_ruleint_access("opt{$i}")) 
56
		$iflist['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
57

    
58
if ($config['pptpd']['mode'] == "server")
59
	if(have_ruleint_access("pptp")) 
60
		$iflist['pptp'] = "PPTP VPN";
61

    
62
if ($config['pppoe']['mode'] == "server")
63
	if(have_ruleint_access("pppoe")) 
64
		$iflist['pppoe'] = "PPPoE VPN";
65

    
66
/* add ipsec interfaces */
67
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
68
	if(have_ruleint_access("enc0")) 
69
		$iflist["enc0"] = "IPsec";
70

    
71
if (!$if || !isset($iflist[$if])) {
72
	if ("any" == $if)
73
                $if = "GerneralRules";
74
        else if ("FloatingRules" != $if)
75
                $if = "wan";
76
}
77

    
78
$security_url = "firewall_rules.php?if=". strtolower($if);
79
if (!isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER'])) {
80
	if(!in_array($security_url, $allowed)) {
81
		// User does not have access
82
//		echo "displaying error {$security_url}"; print_r($allowed);
83
		echo display_error_form("401", "Unauthorized. You do not have access to the page {$pagereq} for interface {$if}");
84
		exit;
85
	}
86
}
87

    
88
if ($_POST) {
89

    
90
	$pconfig = $_POST;
91

    
92
	if ($_POST['apply']) {
93
		$retval = 0;
94
		config_lock();
95
		$retval = filter_configure();
96
		config_unlock();
97

    
98
		if (file_exists($d_filterconfdirty_path))
99
			unlink($d_filterconfdirty_path);
100

    
101
		$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.";
102
	}
103
}
104

    
105
if ($_GET['act'] == "del") {
106
        if ($a_filter[$_GET['id']]) {
107
                unset($a_filter[$_GET['id']]);
108
                write_config();
109
                touch($d_filterconfdirty_path);
110
                header("Location: firewall_rules.php?if={$if}");
111
                exit;
112
        }
113
}
114

    
115
if (isset($_POST['del_x'])) {
116
	/* delete selected rules */
117
	if (is_array($_POST['rule']) && count($_POST['rule'])) {
118
		foreach ($_POST['rule'] as $rulei) {
119
			unset($a_filter[$rulei]);
120
		}
121
		write_config();
122
		touch($d_filterconfdirty_path);
123
		header("Location: firewall_rules.php?if={$if}");
124
		exit;
125
	}
126
} else if ($_GET['act'] == "toggle") {
127
	if ($a_filter[$_GET['id']]) {
128
                if(isset($a_filter[$_GET['id']]['disabled']))
129
                        unset($a_filter[$_GET['id']]['disabled']);
130
                else
131
                        $a_filter[$_GET['id']]['disabled'] = true;
132
		write_config();
133
		touch($d_filterconfdirty_path);
134
		header("Location: firewall_rules.php?if={$if}");
135
		exit;
136
	}
137
} else {
138
	/* yuck - IE won't send value attributes for image buttons, while Mozilla does -
139
	   so we use .x/.y to fine move button clicks instead... */
140
	unset($movebtn);
141
	foreach ($_POST as $pn => $pd) {
142
		if (preg_match("/move_(\d+)_x/", $pn, $matches)) {
143
			$movebtn = $matches[1];
144
			break;
145
		}
146
	}
147
	/* move selected rules before this rule */
148
	if (isset($movebtn) && is_array($_POST['rule']) && count($_POST['rule'])) {
149
		$a_filter_new = array();
150

    
151
		/* copy all rules < $movebtn and not selected */
152
		for ($i = 0; $i < $movebtn; $i++) {
153
			if (!in_array($i, $_POST['rule']))
154
				$a_filter_new[] = $a_filter[$i];
155
		}
156

    
157
		/* copy all selected rules */
158
		for ($i = 0; $i < count($a_filter); $i++) {
159
			if ($i == $movebtn)
160
				continue;
161
			if (in_array($i, $_POST['rule']))
162
				$a_filter_new[] = $a_filter[$i];
163
		}
164

    
165
		/* copy $movebtn rule */
166
		if ($movebtn < count($a_filter))
167
			$a_filter_new[] = $a_filter[$movebtn];
168

    
169
		/* copy all rules > $movebtn and not selected */
170
		for ($i = $movebtn+1; $i < count($a_filter); $i++) {
171
			if (!in_array($i, $_POST['rule']))
172
				$a_filter_new[] = $a_filter[$i];
173
		}
174

    
175
		$a_filter = $a_filter_new;
176
		write_config();
177
		touch($d_filterconfdirty_path);
178
		header("Location: firewall_rules.php?if={$if}");
179
		exit;
180
	}
181
}
182
$closehead = false;
183

    
184
include("head.inc");
185

    
186
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
187
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
188
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
189
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
190
?>
191
</head>
192

    
193
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
194
<?php include("fbegin.inc"); ?>
195
<form action="firewall_rules.php" method="post">
196
<script type="text/javascript" language="javascript" src="row_toggle.js">
197
</script>
198
<?php if ($savemsg) print_info_box($savemsg); ?>
199
<?php if (file_exists($d_filterconfdirty_path)): ?><p>
200
<?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>
201
<?php endif; ?>
202
<?php
203
	$aliases_array = array();
204
	if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
205
	{
206
		foreach($config['aliases']['alias'] as $alias_name) 
207
		{	
208
		 	$alias_addresses = explode (" ", $alias_name['address']);
209
		 	$alias_details = explode ("||", $alias_name['detail']);
210
		 	$alias_objects_with_details = "";
211
		 	$counter = 0;
212
		 	foreach($alias_addresses as $alias_ports_address)
213
		 	{
214
				$alias_objects_with_details .= $alias_addresses[$counter];
215
				$alias_detail_default = strpos ($alias_details[$counter],"Entry added");
216
				if ($alias_details[$counter] != "" && $alias_detail_default === False){
217
					$alias_objects_with_details .=" - " . $alias_details[$counter];
218
				}  
219
				$alias_objects_with_details .= "<br>";
220
				$counter++;
221
			}
222
			$aliases_array[] = array($alias_name['name'], $alias_name['descr'], $alias_objects_with_details);
223
		}		
224
	}
225
?>
226
<table width="100%" border="0" cellpadding="0" cellspacing="0">
227
  <tr><td class="tabnavtbl">
228
  <?php
229
	/* active tabs */
230
	$tab_array = array();
231
       if ("FloatingRules" == $if)
232
                        $active = true;
233
                else
234
                        $active = false;
235
        $tab_array[] = array("Floating", $active, "firewall_rules.php?if=FloatingRules");
236
	$tabscounter = 0; $i = 0; foreach ($iflist as $ifent => $ifname) {
237
		if ($ifent == $if)
238
			$active = true;
239
		else
240
			$active = false;
241
		$tab_array[] = array($ifname, $active, "firewall_rules.php?if={$ifent}");
242
	}
243
	display_top_tabs($tab_array);
244
  ?>
245
  </td></tr>
246
  <tr>
247
    <td>
248
	<div id="mainarea">
249
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
250
                <tr id="frheader">
251
                  <td width="3%" class="list">&nbsp;</td>
252
                  <td width="5%" class="list">&nbsp;</td>
253
                  <td width="6%" class="listhdrr">Proto</td>
254
                  <td width="15%" class="listhdrr">Source</td>
255
                  <td width="7%" class="listhdrr">Port</td>
256
                  <td width="15%" class="listhdrr">Destination</td>
257
                  <td width="7%" class="listhdrr">Port</td>
258
		  <td width="5%" class="listhdrr">Gateway</td>
259
		  <td width="10%" class="listhdrr">Queue</td>
260
		  <td width="5%" class="listhdrr">Schedule</td>
261
                  <td width="22%" class="listhdr">Description</td>
262
                  <td width="10%" class="list">
263
			<table border="0" cellspacing="0" cellpadding="1">
264
			   <tr>
265
				<?php
266
					$nrules = 0;
267
					for ($i = 0; isset($a_filter[$i]); $i++) {
268
						$filterent = $a_filter[$i];
269
						if ($filterent['interface'] != $if && !isset($filterent['floating']))
270
                                                       continue;
271
                                               if (isset($filterent['floating']) && "FloatingRules" != $if)
272
							continue;
273
						$nrules++;
274
					}
275
				?>
276
				<td>
277
				<?php if ($nrules == 0): ?>
278
				<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="delete selected rules" border="0"><?php else: ?>
279
				<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; ?>
280
				</td>
281
				<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>
282
			   </tr>
283
			</table>
284
		  </td>
285
		</tr>
286
<?php if (($if == "wan") && isset($config['interfaces']['wan']['blockpriv'])): ?>
287
                <tr valign="top" id="frrfc1918">
288
                  <td width="3%" class="list">&nbsp;</td>
289
                  <td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0"></td>
290
                  <td class="listlr" style="background-color: #e0e0e0">*</td>
291
                  <td class="listr" style="background-color: #e0e0e0">RFC 1918 networks</td>
292
                  <td class="listr" style="background-color: #e0e0e0">*</td>
293
                  <td class="listr" style="background-color: #e0e0e0">*</td>
294
                  <td class="listr" style="background-color: #e0e0e0">*</td>
295
                  <td class="listr" style="background-color: #e0e0e0">*</td>
296
		<td class="listr" style="background-color: #e0e0e0">Default</td>
297
	 		 <td class="listr" style="background-color: #e0e0e0">*</td>
298
                  <td class="listbg" style="background-color: #990000"><font color="white">Block private networks</td>
299
                  <td valign="middle" nowrap class="list">
300
				    <table border="0" cellspacing="0" cellpadding="1">
301
					<tr>
302
					  <td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="move selected rules before this rule"></td>
303
					  <td><a href="interfaces_wan.php#rfc1918"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit rule" width="17" height="17" border="0"></a></td>
304
					</tr>
305
					<tr>
306
					  <td align="center" valign="middle"></td>
307
					  <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>
308
					</tr>
309
					</table>
310
				  </td>
311
				</tr>
312
<?php endif; ?>
313
<?php if (($if == "wan") && isset($config['interfaces']['wan']['blockbogons'])): ?>
314
                <tr valign="top" id="frrfc1918">
315
                  <td width="3%" class="list">&nbsp;</td>
316
                  <td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0"></td>
317
                  <td class="listlr" style="background-color: #e0e0e0">*</td>
318
                  <td class="listr" style="background-color: #e0e0e0">Reserved/not assigned by IANA</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" style="background-color: #990000"><font color="white">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_wan.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 $nrules = 0; for ($i = 0; isset($a_filter[$i]); $i++):
340
					$filterent = $a_filter[$i];
341
					if ($filterent['interface'] != $if && !isset($filterent['floating']))
342
                                               continue;
343
                                        if (isset($filterent['floating']) && "FloatingRules" != $if)
344
                                                continue;
345
				?>
346
                <tr valign="top" id="fr<?=$nrules;?>">
347
                  <td class="listt"><input type="checkbox" id="frc<?=$nrules;?>" name="rule[]" value="<?=$i;?>" onClick="fr_bgcolor('<?=$nrules;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;"></td>
348
                  <td class="listt" align="center">
349
				  <?php if ($filterent['type'] == "block")
350
				  			$iconfn = "block";
351
						else if ($filterent['type'] == "reject") {
352
							if ($filterent['protocol'] == "tcp" || $filterent['protocol'] == "udp" || $filterent['protocol'] == "tcp/udp")
353
								$iconfn = "reject";
354
							else
355
								$iconfn = "block";
356
						} else
357
							$iconfn = "pass";
358
						if (isset($filterent['disabled'])) {
359
							$textss = "<span class=\"gray\">";
360
							$textse = "</span>";
361
							$iconfn .= "_d";
362
						} else {
363
							$textss = $textse = "";
364
						}
365
				  ?>
366
				  <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>
367
				  <?php if (isset($filterent['log'])):
368
							$iconfnlog = "log_s";
369
						if (isset($filterent['disabled']))
370
							$iconfnlog .= "_d";
371
				  	?>
372
				  <br><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfnlog;?>.gif" width="11" height="15" border="0">
373
				  <?php endif; ?>
374
				  </td>
375
				<?php
376
				//build Alias popup box
377
				$span_begin = "";
378
				$span_end = "";
379
				$alias_src_span_begin = "";
380
				$alias_src_span_end = "";
381
				$alias_src_port_span_begin = "";
382
				$alias_src_port_span_end = "";
383
				$alias_dst_span_begin = "";
384
				$alias_dst_span_end = "";
385
				$alias_dst_port_span_begin = "";
386
				$alias_dst_port_span_end = "";
387
				$alias_content_text = "";
388
				//max character length for caption field
389
				$maxlength = 60;
390
				
391
				foreach ($aliases_array as $alias)
392
				{
393
					$alias_id_substr = $alias[0];
394
					$alias_descr_substr = $alias[1];
395
					$alias_content_text = htmlspecialchars($alias[2]);
396
					$alias_caption = htmlspecialchars($alias_descr_substr . ":");
397
					$strlength = strlen ($alias_caption);
398
					if ($strlength >= $maxlength) 
399
						$alias_caption = substr($alias_caption, 0, $maxlength) . "...";					
400
					
401
					$alias_check_src = $filterent['source']['address'];
402
					$alias_check_srcport = pprint_port($filterent['source']['port']);
403
					$alias_check_dst = $filterent['destination']['address'];
404
					$alias_check_dstport = pprint_port($filterent['destination']['port']);
405
					
406
					$span_begin = "<span style=\"cursor: help;\" onmouseover=\"domTT_activate(this, event, 'content', '<h1>$alias_caption</h1><p>$alias_content_text</p>', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\" onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\"><U>";
407
					$span_end = "</U></span>";
408
					
409
				 	if ($alias_id_substr == $alias_check_src)
410
				 	{										
411
						$alias_src_span_begin = $span_begin;
412
						$alias_src_span_end = $span_end;
413
					}
414
				 	if ($alias_id_substr == $alias_check_srcport)
415
				 	{									
416
						$alias_src_port_span_begin = $span_begin;
417
						$alias_src_port_span_end = $span_end;					
418
					}
419
					if ($alias_id_substr == $alias_check_dst)
420
				 	{										
421
						$alias_dst_span_begin = $span_begin;
422
						$alias_dst_span_end = $span_end;											
423
					}
424
					if ($alias_id_substr == $alias_check_dstport)
425
				 	{											
426
						$alias_dst_port_span_begin = $span_begin;
427
						$alias_dst_port_span_end = $span_end;											
428
					}										
429
				}
430
				
431
				//build Schedule popup box
432
				$a_schedules = &$config['schedules']['schedule'];
433
				$schedule_span_begin = "";
434
				$schedule_span_end = "";
435
				$sched_caption = "";
436
				$sched_content = "";
437
				$schedstatus = false;
438
				$dayArray = array ('Mon','Tues','Wed','Thur','Fri','Sat','Sun');
439
				$monthArray = array ('January','February','March','April','May','June','July','August','September','October','November','December');
440
				if($config['schedules']['schedule'] <> "" and is_array($config['schedules']['schedule'])){
441
					foreach ($a_schedules as $schedule)
442
					{
443
						if ($schedule['name'] == $filterent['sched'] ){
444
							$schedstatus = get_time_based_rule_status($schedule);
445
							
446
							foreach($schedule['timerange'] as $timerange) {
447
								$tempFriendlyTime = "";
448
								$tempID = "";
449
								$firstprint = false;
450
								if ($timerange){
451
									$dayFriendly = "";
452
									$tempFriendlyTime = "";							
453
										
454
									//get hours
455
									$temptimerange = $timerange['hour'];
456
									$temptimeseparator = strrpos($temptimerange, "-");
457
									
458
									$starttime = substr ($temptimerange, 0, $temptimeseparator); 
459
									$stoptime = substr ($temptimerange, $temptimeseparator+1); 
460
										
461
									if ($timerange['month']){
462
										$tempmontharray = explode(",", $timerange['month']);
463
										$tempdayarray = explode(",",$timerange['day']);
464
										$arraycounter = 0;
465
										$firstDayFound = false;
466
										$firstPrint = false;
467
										foreach ($tempmontharray as $monthtmp){
468
											$month = $tempmontharray[$arraycounter];
469
											$day = $tempdayarray[$arraycounter];
470
											
471
											if (!$firstDayFound)
472
											{
473
												$firstDay = $day;
474
												$firstmonth = $month;
475
												$firstDayFound = true;
476
											}
477
												
478
											$currentDay = $day;
479
											$nextDay = $tempdayarray[$arraycounter+1];
480
											$currentDay++;
481
											if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])){
482
												if ($firstPrint)
483
													$dayFriendly .= ", ";
484
												$currentDay--;
485
												if ($currentDay != $firstDay)
486
													$dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ;
487
												else
488
													$dayFriendly .=  $monthArray[$month-1] . " " . $day;
489
												$firstDayFound = false;	
490
												$firstPrint = true;
491
											}													
492
											$arraycounter++;	
493
										}
494
									}
495
									else
496
									{
497
										$tempdayFriendly = $timerange['position'];
498
										$firstDayFound = false;
499
										$tempFriendlyDayArray = explode(",", $tempdayFriendly);								
500
										$currentDay = "";
501
										$firstDay = "";
502
										$nextDay = "";
503
										$counter = 0;													
504
										foreach ($tempFriendlyDayArray as $day){
505
											if ($day != ""){
506
												if (!$firstDayFound)
507
												{
508
													$firstDay = $tempFriendlyDayArray[$counter];
509
													$firstDayFound = true;
510
												}
511
												$currentDay =$tempFriendlyDayArray[$counter];
512
												//get next day
513
												$nextDay = $tempFriendlyDayArray[$counter+1];
514
												$currentDay++;					
515
												if ($currentDay != $nextDay){
516
													if ($firstprint)
517
														$dayFriendly .= ", ";
518
													$currentDay--;
519
													if ($currentDay != $firstDay)
520
														$dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
521
													else
522
														$dayFriendly .= $dayArray[$firstDay-1];
523
													$firstDayFound = false;	
524
													$firstprint = true;			
525
												}
526
												$counter++;
527
											}
528
										}
529
									}		
530
									$timeFriendly = $starttime . " - " . $stoptime;
531
									$description = $timerange['rangedescr'];
532
									$sched_content .= $dayFriendly . "; " . $timeFriendly . "<br>";
533
								}
534
							}
535
							$sched_caption = $schedule['descr'];
536
							$schedule_span_begin = "<span style=\"cursor: help;\" onmouseover=\"domTT_activate(this, event, 'content', '<h1>$sched_caption</h1><p>$sched_content</p>', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\" onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\"><U>";
537
							$schedule_span_end = "</U></span>";
538
						}
539
					}
540
				}
541
				$printicon = false;
542
				$alttext = "";
543
				$image = "";
544
				if (!isset($filterent['disabled'])){
545
					 if ($schedstatus) 
546
					 { 
547
					 	if ($iconfn == "block" || $iconfn == "reject")
548
					 	{
549
					 		$image = "icon_block";
550
					 		$alttext = "Traffic matching this rule is currently being denied";
551
					 	}
552
					 	else
553
					 	{
554
					 		$image = "icon_pass";
555
					 		$alttext = "Traffic matching this rule is currently being allowed";
556
					 	}
557
					 	$printicon = true;
558
					  }
559
					  else if ($filterent['sched'])
560
					  { 
561
					 	if ($iconfn == "block" || $iconfn == "reject")
562
					 	{
563
					 		$image = "icon_block_d";
564
					 		$alttext = "Traffic matching this rule is currently being allowed";
565
					 	}
566
					 	else
567
					 	{
568
					 		$image = "icon_block";
569
					 		$alttext = "Traffic matching this rule is currently being denied";
570
					 	}
571
					 	$printicon = true;				  	
572
					  }
573
				}
574
				?>
575
                  <td class="listlr" 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;?>';" bcolor="#990000"><font color="white">
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="8" 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">
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>
(50-50/187)