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
/* add group interfaces */
58
if (is_array($config['ifgroups']['ifgroupentry']))
59
	foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
60
		if (have_ruleint_access($ifgen['ifname']))
61
			$iflist[$ifgen['ifname']] = $ifgen['ifname'];
62

    
63
foreach ($ifdescs as $ifent => $ifdesc)
64
	if(have_ruleint_access($ifent)) 
65
		$iflist[$ifent] = $ifdesc;
66

    
67
if ($config['l2tp']['mode'] == "server")
68
        if(have_ruleint_access("l2tp"))
69
                $iflist['l2tp'] = "L2TP VPN";
70

    
71
if ($config['pptpd']['mode'] == "server")
72
	if(have_ruleint_access("pptp")) 
73
		$iflist['pptp'] = "PPTP VPN";
74

    
75
if ($config['pppoe']['mode'] == "server")
76
	if(have_ruleint_access("pppoe")) 
77
		$iflist['pppoe'] = "PPPoE VPN";
78

    
79
/* add ipsec interfaces */
80
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
81
	if(have_ruleint_access("enc0")) 
82
		$iflist["enc0"] = "IPsec";
83

    
84
/* add openvpn/tun interfaces */
85
if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
86
   	$iflist["openvpn"] = "OpenVPN";
87

    
88
if (!$if || !isset($iflist[$if])) {
89
	if ("any" == $if)
90
                $if = "FloatingRules";
91
        else if ("FloatingRules" != $if)
92
                $if = "wan";
93
}
94

    
95
if ($_POST) {
96

    
97
	$pconfig = $_POST;
98

    
99
	if ($_POST['apply']) {
100
		$retval = 0;
101
		$retval = filter_configure();
102

    
103
		if (file_exists($d_filterconfdirty_path))
104
			unlink($d_filterconfdirty_path);
105

    
106
		$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.";
107
	}
108
}
109

    
110
if ($_GET['act'] == "del") {
111
        if ($a_filter[$_GET['id']]) {
112
                unset($a_filter[$_GET['id']]);
113
                write_config();
114
                touch($d_filterconfdirty_path);
115
                header("Location: firewall_rules.php?if={$if}");
116
                exit;
117
        }
118
}
119

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

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

    
162
		/* copy all selected rules */
163
		for ($i = 0; $i < count($a_filter); $i++) {
164
			if ($i == $movebtn)
165
				continue;
166
			if (in_array($i, $_POST['rule']))
167
				$a_filter_new[] = $a_filter[$i];
168
		}
169

    
170
		/* copy $movebtn rule */
171
		if ($movebtn < count($a_filter))
172
			$a_filter_new[] = $a_filter[$movebtn];
173

    
174
		/* copy all rules > $movebtn and not selected */
175
		for ($i = $movebtn+1; $i < count($a_filter); $i++) {
176
			if (!in_array($i, $_POST['rule']))
177
				$a_filter_new[] = $a_filter[$i];
178
		}
179

    
180
		$a_filter = $a_filter_new;
181
		write_config();
182
		touch($d_filterconfdirty_path);
183
		header("Location: firewall_rules.php?if={$if}");
184
		exit;
185
	}
186
}
187
$closehead = false;
188

    
189
include("head.inc");
190

    
191
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
192
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
193
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
194
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
195
?>
196
</head>
197

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