Project

General

Profile

Download (29.8 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
		clear_subsystem_dirty('filter');
104

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

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

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

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

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

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

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

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

    
188
include("head.inc");
189

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

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