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", "enc0" => "IPSEC");
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
		$i = 0; foreach ($a_ipsec as $ipsecent) {
60
			if(isset($ipsecent['creategif'])) {
61
				$iflist["gif{$i}"] = "{$ipsecent['descr']}";
62
				$i++;
63
			}
64
		}
65
	}
66
}
67

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

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

    
75
if ($_POST) {
76

    
77
	$pconfig = $_POST;
78

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

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

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

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

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

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

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

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

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

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

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

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

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