Project

General

Profile

Download (30.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
$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("lan" => "LAN", "wan" => "WAN");
48

    
49
if ($config['pptpd']['mode'] == "server")
50
	$iflist['pptp'] = "PPTP VPN";
51

    
52
if ($config['pppoe']['mode'] == "server")
53
	$iflist['pppoe'] = "PPPoE VPN";
54

    
55
/* add ipsec filter gif interfaces */
56
if (is_array($config['ipsec']['tunnel']) && isset($config['ipsec']['enable'])) {
57
	$a_ipsec = &$config['ipsec']['tunnel'];
58
	if(is_array($a_ipsec)) {
59
		$iflist["enc0"] = "IPsec";
60
		$i = 0; foreach ($a_ipsec as $ipsecent) {
61
			if(isset($ipsecent['creategif'])) {
62
				$iflist["gif{$i}"] = "{$ipsecent['descr']}";
63
				$i++;
64
			}
65
		}
66
	}
67
}
68

    
69
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
70
	$iflist['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
71
}
72

    
73
if (!$if || !isset($iflist[$if]))
74
	$if = "wan";
75

    
76
if ($_POST) {
77

    
78
	$pconfig = $_POST;
79

    
80
	if ($_POST['apply']) {
81
		$retval = 0;
82
		config_lock();
83
		$retval = filter_configure();
84
		config_unlock();
85

    
86
		if (file_exists($d_filterconfdirty_path))
87
			unlink($d_filterconfdirty_path);
88

    
89
		$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.";
90
	}
91
}
92

    
93
if ($_GET['act'] == "del") {
94
        if ($a_filter[$_GET['id']]) {
95
                unset($a_filter[$_GET['id']]);
96
                write_config();
97
                touch($d_filterconfdirty_path);
98
                header("Location: firewall_rules.php?if={$if}");
99
                exit;
100
        }
101
}
102

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

    
139
		/* copy all rules < $movebtn and not selected */
140
		for ($i = 0; $i < $movebtn; $i++) {
141
			if (!in_array($i, $_POST['rule']))
142
				$a_filter_new[] = $a_filter[$i];
143
		}
144

    
145
		/* copy all selected rules */
146
		for ($i = 0; $i < count($a_filter); $i++) {
147
			if ($i == $movebtn)
148
				continue;
149
			if (in_array($i, $_POST['rule']))
150
				$a_filter_new[] = $a_filter[$i];
151
		}
152

    
153
		/* copy $movebtn rule */
154
		if ($movebtn < count($a_filter))
155
			$a_filter_new[] = $a_filter[$movebtn];
156

    
157
		/* copy all rules > $movebtn and not selected */
158
		for ($i = $movebtn+1; $i < count($a_filter); $i++) {
159
			if (!in_array($i, $_POST['rule']))
160
				$a_filter_new[] = $a_filter[$i];
161
		}
162

    
163
		$a_filter = $a_filter_new;
164
		write_config();
165
		touch($d_filterconfdirty_path);
166
		header("Location: firewall_rules.php?if={$if}");
167
		exit;
168
	}
169
}
170
$closehead = false;
171

    
172
$pgtitle = "Firewall: Rules";
173
include("head.inc");
174

    
175
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
176
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
177
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
178
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
179
?>
180
</head>
181

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