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