Project

General

Profile

Download (31.6 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
function delete_nat_association($id) {
74
	global $config;
75

    
76
	if (!$id || !is_array($config['nat']['rule']))
77
		return;
78

    
79
	$a_nat = &$config['nat']['rule'];
80

    
81
	foreach ($a_nat as &$natent)
82
		if ($natent['associated-rule-id'] == $id)
83
			$natent['associated-rule-id'] = '';
84
}
85

    
86
if (!is_array($config['filter']['rule'])) {
87
	$config['filter']['rule'] = array();
88
}
89
filter_rules_sort();
90
$a_filter = &$config['filter']['rule'];
91

    
92
$if = $_GET['if'];
93
if ($_POST['if'])
94
	$if = $_POST['if'];
95

    
96
$ifdescs = get_configured_interface_with_descr();
97

    
98
/* add group interfaces */
99
if (is_array($config['ifgroups']['ifgroupentry']))
100
	foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
101
		if (have_ruleint_access($ifgen['ifname']))
102
			$iflist[$ifgen['ifname']] = $ifgen['ifname'];
103

    
104
foreach ($ifdescs as $ifent => $ifdesc)
105
	if(have_ruleint_access($ifent)) 
106
		$iflist[$ifent] = $ifdesc;
107

    
108
if ($config['l2tp']['mode'] == "server")
109
        if(have_ruleint_access("l2tp"))
110
                $iflist['l2tp'] = "L2TP VPN";
111

    
112
if ($config['pptpd']['mode'] == "server")
113
	if(have_ruleint_access("pptp")) 
114
		$iflist['pptp'] = "PPTP VPN";
115

    
116
if ($config['pppoe']['mode'] == "server")
117
	if(have_ruleint_access("pppoe")) 
118
		$iflist['pppoe'] = "PPPoE VPN";
119

    
120
/* add ipsec interfaces */
121
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
122
	if(have_ruleint_access("enc0")) 
123
		$iflist["enc0"] = "IPsec";
124

    
125
/* add openvpn/tun interfaces */
126
if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
127
   	$iflist["openvpn"] = "OpenVPN";
128

    
129
if (!$if || !isset($iflist[$if])) {
130
	if ("any" == $if)
131
                $if = "FloatingRules";
132
        else if ("FloatingRules" != $if)
133
                $if = "wan";
134
}
135

    
136
if ($_POST) {
137

    
138
	$pconfig = $_POST;
139

    
140
	if ($_POST['apply']) {
141
		$retval = 0;
142
		$retval = filter_configure();
143

    
144
		clear_subsystem_dirty('filter');
145

    
146
		$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.";
147
	}
148
}
149

    
150
if ($_GET['act'] == "del") {
151
	if ($a_filter[$_GET['id']]) {
152
		if (!empty($a_filter[$_GET['id']]['associated-rule-id'])) {
153
			delete_nat_association($a_filter[$_GET['id']]['associated-rule-id']);
154
		}
155
		unset($a_filter[$_GET['id']]);
156
		write_config();
157
		mark_subsystem_dirty('filter');
158
		header("Location: firewall_rules.php?if={$if}");
159
		exit;
160
	}
161
}
162

    
163
if (isset($_POST['del_x'])) {
164
	/* delete selected rules */
165
	if (is_array($_POST['rule']) && count($_POST['rule'])) {
166
		foreach ($_POST['rule'] as $rulei) {
167
			delete_nat_association($a_filter[$rulei]['associated-rule-id']);
168
			unset($a_filter[$rulei]);
169
		}
170
		write_config();
171
		mark_subsystem_dirty('filter');
172
		header("Location: firewall_rules.php?if={$if}");
173
		exit;
174
	}
175
} else if ($_GET['act'] == "toggle") {
176
	if ($a_filter[$_GET['id']]) {
177
                if(isset($a_filter[$_GET['id']]['disabled']))
178
                        unset($a_filter[$_GET['id']]['disabled']);
179
                else
180
                        $a_filter[$_GET['id']]['disabled'] = true;
181
		write_config();
182
		mark_subsystem_dirty('filter');
183
		header("Location: firewall_rules.php?if={$if}");
184
		exit;
185
	}
186
} else {
187
	/* yuck - IE won't send value attributes for image buttons, while Mozilla does -
188
	   so we use .x/.y to fine move button clicks instead... */
189
	unset($movebtn);
190
	foreach ($_POST as $pn => $pd) {
191
		if (preg_match("/move_(\d+)_x/", $pn, $matches)) {
192
			$movebtn = $matches[1];
193
			break;
194
		}
195
	}
196
	/* move selected rules before this rule */
197
	if (isset($movebtn) && is_array($_POST['rule']) && count($_POST['rule'])) {
198
		$a_filter_new = array();
199

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

    
206
		/* copy all selected rules */
207
		for ($i = 0; $i < count($a_filter); $i++) {
208
			if ($i == $movebtn)
209
				continue;
210
			if (in_array($i, $_POST['rule']))
211
				$a_filter_new[] = $a_filter[$i];
212
		}
213

    
214
		/* copy $movebtn rule */
215
		if ($movebtn < count($a_filter))
216
			$a_filter_new[] = $a_filter[$movebtn];
217

    
218
		/* copy all rules > $movebtn and not selected */
219
		for ($i = $movebtn+1; $i < count($a_filter); $i++) {
220
			if (!in_array($i, $_POST['rule']))
221
				$a_filter_new[] = $a_filter[$i];
222
		}
223

    
224
		$a_filter = $a_filter_new;
225
		write_config();
226
		mark_subsystem_dirty('filter');
227
		header("Location: firewall_rules.php?if={$if}");
228
		exit;
229
	}
230
}
231
$closehead = false;
232

    
233
include("head.inc");
234

    
235
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
236
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
237
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
238
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
239
?>
240
</head>
241

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