Project

General

Profile

Download (29.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
$ifdescs = get_configured_interface_with_descr();
48

    
49
foreach ($ifdescs as $ifent => $ifdesc)
50
	if(have_ruleint_access($ifent)) 
51
		$iflist[$ifent] = $ifdesc;
52

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

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

    
61
/* add ipsec interfaces */
62
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
63
	if(have_ruleint_access("enc0")) 
64
		$iflist["enc0"] = "IPsec";
65

    
66
/* add openvpn/tun interfaces */
67
if  ($config['installedpackages']["openvpnserver"] || $config['installedpackages']["openvpnclient"]) {
68
	if (is_array($config['installedpackages']["openvpnserver"]['config']) ||
69
		is_array($config['installedpackages']["openvpnclient"]['config']))
70
                	$iflist["openvpn"] = "OpenVPN";
71
}
72

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

    
80
if ($_POST) {
81

    
82
	$pconfig = $_POST;
83

    
84
	if ($_POST['apply']) {
85
		$retval = 0;
86
		config_lock();
87
		$retval = filter_configure();
88
		config_unlock();
89

    
90
		if (file_exists($d_filterconfdirty_path))
91
			unlink($d_filterconfdirty_path);
92

    
93
		$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.";
94
	}
95
}
96

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

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

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

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

    
157
		/* copy $movebtn rule */
158
		if ($movebtn < count($a_filter))
159
			$a_filter_new[] = $a_filter[$movebtn];
160

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

    
167
		$a_filter = $a_filter_new;
168
		write_config();
169
		touch($d_filterconfdirty_path);
170
		header("Location: firewall_rules.php?if={$if}");
171
		exit;
172
	}
173
}
174
$closehead = false;
175

    
176
include("head.inc");
177

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

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