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($config['interfaces']['lan']) 
50
	if(have_ruleint_access("lan")) 
51
		$iflist['lan'] = "LAN";
52

    
53
if(have_ruleint_access("wan")) 
54
	$iflist['wan'] = "WAN";
55

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

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

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

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

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

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

    
90
if ($_POST) {
91

    
92
	$pconfig = $_POST;
93

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

    
100
		if (file_exists($d_filterconfdirty_path))
101
			unlink($d_filterconfdirty_path);
102

    
103
		$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.";
104
	}
105
}
106

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

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

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

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

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

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

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

    
186
include("head.inc");
187

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

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