Project

General

Profile

Download (31.3 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'])
53
		$item_set .= "max {$item['max']} ";
54
	if($item['max-src-nodes'])
55
		$item_set .= "max-src-nodes {$item['max-src-nodes']} ";
56
	if($item['max-src-conn'])
57
		$item_set .= "max-src-conn {$item['max-src-conn']} ";
58
	if($item['max-src-states'])
59
		$item_set .= "max-src-states {$item['max-src-states']} ";
60
	if($item['statetype'] != "keep state" && $item['statetype'] != "")
61
		$item_set .= "statetype {$item['statetype']} {$item['statetype']}";
62
	if($item['statetimeout'])
63
		$item_set .= "statetimeout {$item['statetimeout']}";
64
	if($item['nosync'])
65
		$item_set .= "nosync ";
66
	if($item['max-src-conn-rate'])
67
		$item_set .= "max-src-conn-rate {$item['max-src-conn-rate']} ";
68
	if($item['max-src-conn-rates'])
69
		$item_set .= "max-src-conn-rates {$item['max-src-conn-rates']} ";
70
	return $item_set;
71
}
72

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

    
79
$if = $_GET['if'];
80
if ($_POST['if'])
81
	$if = $_POST['if'];
82

    
83
$ifdescs = get_configured_interface_with_descr();
84

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

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

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

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

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

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

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

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

    
123
if ($_POST) {
124

    
125
	$pconfig = $_POST;
126

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

    
131
		clear_subsystem_dirty('filter');
132

    
133
		$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.";
134
	}
135
}
136

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

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

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

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

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

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

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

    
216
include("head.inc");
217

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

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