Project

General

Profile

Download (30.1 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	firewall_rules.php
5
	part of pfSense (http://www.pfsense.com)
6
        Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
7

    
8
	originally part of m0n0wall (http://m0n0.ch/wall)
9
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11

    
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14

    
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17

    
18
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21

    
22
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33

    
34
$pgtitle = array("Firewall", "Rules");
35
require("guiconfig.inc");
36

    
37
if (!is_array($config['filter']['rule'])) {
38
	$config['filter']['rule'] = array();
39
}
40
filter_rules_sort();
41
$a_filter = &$config['filter']['rule'];
42

    
43
$if = $_GET['if'];
44
if ($_POST['if'])
45
	$if = $_POST['if'];
46

    
47
$ifdescs = get_configured_interface_with_descr();
48

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

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

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

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

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

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

    
80
$security_url = "firewall_rules.php?if=". strtolower($if);
81
if (!isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER'])) {
82
	if(!in_array($security_url, $allowed)) {
83
		// User does not have access
84
//		echo "displaying error {$security_url}"; print_r($allowed);
85
		echo display_error_form("401", "Unauthorized. You do not have access to the page {$pagereq} for interface {$if}");
86
		exit;
87
	}
88
}
89

    
90
if ($_POST) {
91

    
92
	$pconfig = $_POST;
93

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

    
100
		if (file_exists($d_filterconfdirty_path))
101
			unlink($d_filterconfdirty_path);
102

    
103
		$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.";
104
	}
105
}
106

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

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

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

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

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

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

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

    
186
include("head.inc");
187

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

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