Project

General

Profile

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

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

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

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

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

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

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

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

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

    
47
$iflist = array("lan" => "LAN", "wan" => "WAN");
48

    
49
if ($config['pptpd']['mode'] == "server")
50
	$iflist['pptp'] = "PPTP VPN";
51

    
52
if ($config['pppoe']['mode'] == "server")
53
	$iflist['pppoe'] = "PPPoE VPN";
54

    
55
/* add ipsec filter gif interfaces */
56
if (is_array($config['ipsec']['tunnel']) && isset($config['ipsec']['enable'])) {
57
	$a_ipsec = &$config['ipsec']['tunnel'];
58
	if(is_array($a_ipsec)) {
59
		$iflist["enc0"] = "IPsec";
60
		$i = 0; foreach ($a_ipsec as $ipsecent) {
61
			if(isset($ipsecent['creategif'])) {
62
				$iflist["gif{$i}"] = "{$ipsecent['descr']}";
63
				$i++;
64
			}
65
		}
66
	}
67
}
68

    
69
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
70
	$iflist['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
71
}
72

    
73
if (!$if || !isset($iflist[$if]))
74
	$if = "wan";
75

    
76
if ($_POST) {
77

    
78
	$pconfig = $_POST;
79

    
80
	if ($_POST['apply']) {
81
		$retval = 0;
82
		config_lock();
83
		$retval = filter_configure();
84
		config_unlock();
85

    
86
		if (file_exists($d_filterconfdirty_path))
87
			unlink($d_filterconfdirty_path);
88

    
89
		$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.";
90
	}
91
}
92

    
93
if ($_GET['act'] == "del") {
94
        if ($a_filter[$_GET['id']]) {
95
                unset($a_filter[$_GET['id']]);
96
                write_config();
97
                touch($d_filterconfdirty_path);
98
                header("Location: firewall_rules.php?if={$if}");
99
                exit;
100
        }
101
}
102

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

    
139
		/* copy all rules < $movebtn and not selected */
140
		for ($i = 0; $i < $movebtn; $i++) {
141
			if (!in_array($i, $_POST['rule']))
142
				$a_filter_new[] = $a_filter[$i];
143
		}
144

    
145
		/* copy all selected rules */
146
		for ($i = 0; $i < count($a_filter); $i++) {
147
			if ($i == $movebtn)
148
				continue;
149
			if (in_array($i, $_POST['rule']))
150
				$a_filter_new[] = $a_filter[$i];
151
		}
152

    
153
		/* copy $movebtn rule */
154
		if ($movebtn < count($a_filter))
155
			$a_filter_new[] = $a_filter[$movebtn];
156

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

    
163
		$a_filter = $a_filter_new;
164
		write_config();
165
		touch($d_filterconfdirty_path);
166
		header("Location: firewall_rules.php?if={$if}");
167
		exit;
168
	}
169
}
170
$closehead = false;
171

    
172
$pgtitle = "Firewall: Rules";
173
include("head.inc");
174

    
175
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
176
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
177
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
178
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
179
?>
180
</head>
181

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