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
##|+PRIV
35
##|*IDENT=page-firewall-rules
36
##|*NAME=Firewall: Rules page
37
##|*DESCR=Allow access to the 'Firewall: Rules' page.
38
##|*MATCH=firewall_rules.php*
39
##|-PRIV
40

    
41

    
42
$pgtitle = array("Firewall", "Rules");
43
require("guiconfig.inc");
44

    
45
if (!is_array($config['filter']['rule'])) {
46
	$config['filter']['rule'] = array();
47
}
48
filter_rules_sort();
49
$a_filter = &$config['filter']['rule'];
50

    
51
$if = $_GET['if'];
52
if ($_POST['if'])
53
	$if = $_POST['if'];
54

    
55
$ifdescs = get_configured_interface_with_descr();
56

    
57
foreach ($ifdescs as $ifent => $ifdesc)
58
	if(have_ruleint_access($ifent)) 
59
		$iflist[$ifent] = $ifdesc;
60

    
61
if ($config['pptpd']['mode'] == "server")
62
	if(have_ruleint_access("pptp")) 
63
		$iflist['pptp'] = "PPTP VPN";
64

    
65
if ($config['pppoe']['mode'] == "server")
66
	if(have_ruleint_access("pppoe")) 
67
		$iflist['pppoe'] = "PPPoE VPN";
68

    
69
/* add ipsec interfaces */
70
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
71
	if(have_ruleint_access("enc0")) 
72
		$iflist["enc0"] = "IPsec";
73

    
74
/* add openvpn/tun interfaces */
75
if  ($config['installedpackages']["openvpnserver"] || $config['installedpackages']["openvpnclient"]) {
76
	if (is_array($config['installedpackages']["openvpnserver"]['config']) ||
77
		is_array($config['installedpackages']["openvpnclient"]['config']))
78
                	$iflist["openvpn"] = "OpenVPN";
79
}
80

    
81
if (!$if || !isset($iflist[$if])) {
82
	if ("any" == $if)
83
                $if = "FloatingRules";
84
        else if ("FloatingRules" != $if)
85
                $if = "wan";
86
}
87

    
88
if ($_POST) {
89

    
90
	$pconfig = $_POST;
91

    
92
	if ($_POST['apply']) {
93
		$retval = 0;
94
		config_lock();
95
		$retval = filter_configure();
96
		config_unlock();
97

    
98
		if (file_exists($d_filterconfdirty_path))
99
			unlink($d_filterconfdirty_path);
100

    
101
		$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.";
102
	}
103
}
104

    
105
if ($_GET['act'] == "del") {
106
        if ($a_filter[$_GET['id']]) {
107
                unset($a_filter[$_GET['id']]);
108
                write_config();
109
                touch($d_filterconfdirty_path);
110
                header("Location: firewall_rules.php?if={$if}");
111
                exit;
112
        }
113
}
114

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

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

    
157
		/* copy all selected rules */
158
		for ($i = 0; $i < count($a_filter); $i++) {
159
			if ($i == $movebtn)
160
				continue;
161
			if (in_array($i, $_POST['rule']))
162
				$a_filter_new[] = $a_filter[$i];
163
		}
164

    
165
		/* copy $movebtn rule */
166
		if ($movebtn < count($a_filter))
167
			$a_filter_new[] = $a_filter[$movebtn];
168

    
169
		/* copy all rules > $movebtn and not selected */
170
		for ($i = $movebtn+1; $i < count($a_filter); $i++) {
171
			if (!in_array($i, $_POST['rule']))
172
				$a_filter_new[] = $a_filter[$i];
173
		}
174

    
175
		$a_filter = $a_filter_new;
176
		write_config();
177
		touch($d_filterconfdirty_path);
178
		header("Location: firewall_rules.php?if={$if}");
179
		exit;
180
	}
181
}
182
$closehead = false;
183

    
184
include("head.inc");
185

    
186
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
187
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
188
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
189
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
190
?>
191
</head>
192

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