Project

General

Profile

Download (30.5 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();
48

    
49
if(have_ruleint_access("lan")) 
50
	$iflist['lan'] = "LAN";
51
if(have_ruleint_access("wan")) 
52
	$iflist['wan'] = "WAN";
53

    
54
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) 
55
	if(have_ruleint_access("opt{$i}")) 
56
		$iflist['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
57

    
58
if ($config['pptpd']['mode'] == "server")
59
	if(have_ruleint_access("pptp")) 
60
		$iflist['pptp'] = "PPTP VPN";
61

    
62
if ($config['pppoe']['mode'] == "server")
63
	if(have_ruleint_access("pppoe")) 
64
		$iflist['pppoe'] = "PPPoE VPN";
65

    
66
/* add ipsec interfaces */
67
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
68
	if(have_ruleint_access("enc0")) 
69
		$iflist["enc0"] = "IPSEC";
70

    
71
if (!$if || !isset($iflist[$if]))
72
	foreach($iflist as $if => $ifname) 
73
		break;
74

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

    
85
if ($_POST) {
86

    
87
	$pconfig = $_POST;
88

    
89
	if ($_POST['apply']) {
90
		$retval = 0;
91
		config_lock();
92
		$retval = filter_configure();
93
		config_unlock();
94

    
95
		if (file_exists($d_filterconfdirty_path))
96
			unlink($d_filterconfdirty_path);
97

    
98
		$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.";
99
	}
100
}
101

    
102
if ($_GET['act'] == "del") {
103
        if ($a_filter[$_GET['id']]) {
104
                unset($a_filter[$_GET['id']]);
105
                write_config();
106
                touch($d_filterconfdirty_path);
107
                header("Location: firewall_rules.php?if={$if}");
108
                exit;
109
        }
110
}
111

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

    
148
		/* copy all rules < $movebtn and not selected */
149
		for ($i = 0; $i < $movebtn; $i++) {
150
			if (!in_array($i, $_POST['rule']))
151
				$a_filter_new[] = $a_filter[$i];
152
		}
153

    
154
		/* copy all selected rules */
155
		for ($i = 0; $i < count($a_filter); $i++) {
156
			if ($i == $movebtn)
157
				continue;
158
			if (in_array($i, $_POST['rule']))
159
				$a_filter_new[] = $a_filter[$i];
160
		}
161

    
162
		/* copy $movebtn rule */
163
		if ($movebtn < count($a_filter))
164
			$a_filter_new[] = $a_filter[$movebtn];
165

    
166
		/* copy all rules > $movebtn and not selected */
167
		for ($i = $movebtn+1; $i < count($a_filter); $i++) {
168
			if (!in_array($i, $_POST['rule']))
169
				$a_filter_new[] = $a_filter[$i];
170
		}
171

    
172
		$a_filter = $a_filter_new;
173
		write_config();
174
		touch($d_filterconfdirty_path);
175
		header("Location: firewall_rules.php?if={$if}");
176
		exit;
177
	}
178
}
179
$closehead = false;
180

    
181
include("head.inc");
182

    
183
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
184
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
185
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
186
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
187
?>
188
</head>
189

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