Project

General

Profile

Download (31.4 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
	pfSense_MODULE:	filter
35
*/
36

    
37
##|+PRIV
38
##|*IDENT=page-firewall-rules
39
##|*NAME=Firewall: Rules page
40
##|*DESCR=Allow access to the 'Firewall: Rules' page.
41
##|*MATCH=firewall_rules.php*
42
##|-PRIV
43

    
44
$pgtitle = array("Firewall", "Rules");
45
require("guiconfig.inc");
46
require_once("functions.inc");
47
require_once("filter.inc");
48
require_once("shaper.inc");
49

    
50
function check_for_advaned_options(&$item) {
51
	$item_set = "";
52
	if($item['max-src-nodes'])
53
		$item_set .= "max-src-nodes {$item['max-src-nodes']} ";
54
	if($item['max-src-conn'])
55
		$item_set .= "max-src-conn {$item['max-src-conn']} ";
56
	if($item['max-src-states'])
57
		$item_set .= "max-src-states {$item['max-src-states']} ";
58
	if($item['statetype'] != "keep state" && $item['statetype'] != "")
59
		$item_set .= "statetype {$item['statetype']} {$item['statetype']}";
60
	if($item['statetimeout'])
61
		$item_set .= "statetimeout {$item['statetimeout']}";
62
	if($item['nosync'])
63
		$item_set .= "nosync ";
64
	if($item['max-src-conn-rate'])
65
		$item_set .= "max-src-conn-rate {$item['max-src-conn-rate']} ";
66
	if($item['max-src-conn-rates'])
67
		$item_set .= "max-src-conn-rates {$item['max-src-conn-rates']} ";
68
	return $item_set;
69
}
70

    
71
if (!is_array($config['filter']['rule'])) {
72
	$config['filter']['rule'] = array();
73
}
74
filter_rules_sort();
75
$a_filter = &$config['filter']['rule'];
76

    
77
$if = $_GET['if'];
78
if ($_POST['if'])
79
	$if = $_POST['if'];
80

    
81
$ifdescs = get_configured_interface_with_descr();
82

    
83
/* add group interfaces */
84
if (is_array($config['ifgroups']['ifgroupentry']))
85
	foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
86
		if (have_ruleint_access($ifgen['ifname']))
87
			$iflist[$ifgen['ifname']] = $ifgen['ifname'];
88

    
89
foreach ($ifdescs as $ifent => $ifdesc)
90
	if(have_ruleint_access($ifent)) 
91
		$iflist[$ifent] = $ifdesc;
92

    
93
if ($config['l2tp']['mode'] == "server")
94
        if(have_ruleint_access("l2tp"))
95
                $iflist['l2tp'] = "L2TP VPN";
96

    
97
if ($config['pptpd']['mode'] == "server")
98
	if(have_ruleint_access("pptp")) 
99
		$iflist['pptp'] = "PPTP VPN";
100

    
101
if ($config['pppoe']['mode'] == "server")
102
	if(have_ruleint_access("pppoe")) 
103
		$iflist['pppoe'] = "PPPoE VPN";
104

    
105
/* add ipsec interfaces */
106
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
107
	if(have_ruleint_access("enc0")) 
108
		$iflist["enc0"] = "IPsec";
109

    
110
/* add openvpn/tun interfaces */
111
if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
112
   	$iflist["openvpn"] = "OpenVPN";
113

    
114
if (!$if || !isset($iflist[$if])) {
115
	if ("any" == $if)
116
                $if = "FloatingRules";
117
        else if ("FloatingRules" != $if)
118
                $if = "wan";
119
}
120

    
121
if ($_POST) {
122

    
123
	$pconfig = $_POST;
124

    
125
	if ($_POST['apply']) {
126
		$retval = 0;
127
		$retval = filter_configure();
128

    
129
		clear_subsystem_dirty('filter');
130

    
131
		$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.";
132
	}
133
}
134

    
135
if ($_GET['act'] == "del") {
136
        if ($a_filter[$_GET['id']]) {
137
                unset($a_filter[$_GET['id']]);
138
                write_config();
139
		mark_subsystem_dirty('filter');
140
                header("Location: firewall_rules.php?if={$if}");
141
                exit;
142
        }
143
}
144

    
145
if (isset($_POST['del_x'])) {
146
	/* delete selected rules */
147
	if (is_array($_POST['rule']) && count($_POST['rule'])) {
148
		foreach ($_POST['rule'] as $rulei) {
149
			unset($a_filter[$rulei]);
150
		}
151
		write_config();
152
		mark_subsystem_dirty('filter');
153
		header("Location: firewall_rules.php?if={$if}");
154
		exit;
155
	}
156
} else if ($_GET['act'] == "toggle") {
157
	if ($a_filter[$_GET['id']]) {
158
                if(isset($a_filter[$_GET['id']]['disabled']))
159
                        unset($a_filter[$_GET['id']]['disabled']);
160
                else
161
                        $a_filter[$_GET['id']]['disabled'] = true;
162
		write_config();
163
		mark_subsystem_dirty('filter');
164
		header("Location: firewall_rules.php?if={$if}");
165
		exit;
166
	}
167
} else {
168
	/* yuck - IE won't send value attributes for image buttons, while Mozilla does -
169
	   so we use .x/.y to fine move button clicks instead... */
170
	unset($movebtn);
171
	foreach ($_POST as $pn => $pd) {
172
		if (preg_match("/move_(\d+)_x/", $pn, $matches)) {
173
			$movebtn = $matches[1];
174
			break;
175
		}
176
	}
177
	/* move selected rules before this rule */
178
	if (isset($movebtn) && is_array($_POST['rule']) && count($_POST['rule'])) {
179
		$a_filter_new = array();
180

    
181
		/* copy all rules < $movebtn and not selected */
182
		for ($i = 0; $i < $movebtn; $i++) {
183
			if (!in_array($i, $_POST['rule']))
184
				$a_filter_new[] = $a_filter[$i];
185
		}
186

    
187
		/* copy all selected rules */
188
		for ($i = 0; $i < count($a_filter); $i++) {
189
			if ($i == $movebtn)
190
				continue;
191
			if (in_array($i, $_POST['rule']))
192
				$a_filter_new[] = $a_filter[$i];
193
		}
194

    
195
		/* copy $movebtn rule */
196
		if ($movebtn < count($a_filter))
197
			$a_filter_new[] = $a_filter[$movebtn];
198

    
199
		/* copy all rules > $movebtn and not selected */
200
		for ($i = $movebtn+1; $i < count($a_filter); $i++) {
201
			if (!in_array($i, $_POST['rule']))
202
				$a_filter_new[] = $a_filter[$i];
203
		}
204

    
205
		$a_filter = $a_filter_new;
206
		write_config();
207
		mark_subsystem_dirty('filter');
208
		header("Location: firewall_rules.php?if={$if}");
209
		exit;
210
	}
211
}
212
$closehead = false;
213

    
214
include("head.inc");
215

    
216
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
217
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
218
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
219
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
220
?>
221
</head>
222

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