Project

General

Profile

Download (29.9 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
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
50
	$iflist['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
51
}
52

    
53
if ($config['pptpd']['mode'] == "server")
54
	$iflist['pptp'] = "PPTP VPN";
55

    
56
if ($config['pppoe']['mode'] == "server")
57
	$iflist['pppoe'] = "PPPoE VPN";
58

    
59
/* add ipsec interfaces */
60
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable'])){ 
61
	$iflist["enc0"] = "IPSEC";
62
}
63

    
64
if (!$if || !isset($iflist[$if]))
65
	$if = "wan";
66

    
67
if ($_POST) {
68

    
69
	$pconfig = $_POST;
70

    
71
	if ($_POST['apply']) {
72
		$retval = 0;
73
		config_lock();
74
		$retval = filter_configure();
75
		config_unlock();
76

    
77
		if (file_exists($d_filterconfdirty_path))
78
			unlink($d_filterconfdirty_path);
79

    
80
		$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.";
81
	}
82
}
83

    
84
if ($_GET['act'] == "del") {
85
        if ($a_filter[$_GET['id']]) {
86
                unset($a_filter[$_GET['id']]);
87
                write_config();
88
                touch($d_filterconfdirty_path);
89
                header("Location: firewall_rules.php?if={$if}");
90
                exit;
91
        }
92
}
93

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

    
130
		/* copy all rules < $movebtn and not selected */
131
		for ($i = 0; $i < $movebtn; $i++) {
132
			if (!in_array($i, $_POST['rule']))
133
				$a_filter_new[] = $a_filter[$i];
134
		}
135

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

    
144
		/* copy $movebtn rule */
145
		if ($movebtn < count($a_filter))
146
			$a_filter_new[] = $a_filter[$movebtn];
147

    
148
		/* copy all rules > $movebtn and not selected */
149
		for ($i = $movebtn+1; $i < count($a_filter); $i++) {
150
			if (!in_array($i, $_POST['rule']))
151
				$a_filter_new[] = $a_filter[$i];
152
		}
153

    
154
		$a_filter = $a_filter_new;
155
		write_config();
156
		touch($d_filterconfdirty_path);
157
		header("Location: firewall_rules.php?if={$if}");
158
		exit;
159
	}
160
}
161
$closehead = false;
162

    
163
$pgtitle = "Firewall: Rules";
164
include("head.inc");
165

    
166
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
167
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
168
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
169
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
170
?>
171
</head>
172

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