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 = "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
|
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
|
50
|
$iflist['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
|
51
|
}
|
52
|
|
53
|
if ($config['pptpd']['mode'] == "server")
|
54
|
$iflist['pptp'] = "PPTP VPN";
|
55
|
|
56
|
if ($config['pppoe']['mode'] == "server")
|
57
|
$iflist['pppoe'] = "PPPoE VPN";
|
58
|
|
59
|
/* add ipsec interfaces */
|
60
|
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable'])){
|
61
|
$iflist["enc0"] = "IPsec";
|
62
|
}
|
63
|
|
64
|
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
|
65
|
$iflist['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
|
66
|
}
|
67
|
|
68
|
if (!$if || !isset($iflist[$if]))
|
69
|
$if = "wan";
|
70
|
|
71
|
if ($_POST) {
|
72
|
|
73
|
$pconfig = $_POST;
|
74
|
|
75
|
if ($_POST['apply']) {
|
76
|
$retval = 0;
|
77
|
config_lock();
|
78
|
$retval = filter_configure();
|
79
|
config_unlock();
|
80
|
|
81
|
if (file_exists($d_filterconfdirty_path))
|
82
|
unlink($d_filterconfdirty_path);
|
83
|
|
84
|
$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.";
|
85
|
}
|
86
|
}
|
87
|
|
88
|
if ($_GET['act'] == "del") {
|
89
|
if ($a_filter[$_GET['id']]) {
|
90
|
unset($a_filter[$_GET['id']]);
|
91
|
write_config();
|
92
|
touch($d_filterconfdirty_path);
|
93
|
header("Location: firewall_rules.php?if={$if}");
|
94
|
exit;
|
95
|
}
|
96
|
}
|
97
|
|
98
|
if (isset($_POST['del_x'])) {
|
99
|
/* delete selected rules */
|
100
|
if (is_array($_POST['rule']) && count($_POST['rule'])) {
|
101
|
foreach ($_POST['rule'] as $rulei) {
|
102
|
unset($a_filter[$rulei]);
|
103
|
}
|
104
|
write_config();
|
105
|
touch($d_filterconfdirty_path);
|
106
|
header("Location: firewall_rules.php?if={$if}");
|
107
|
exit;
|
108
|
}
|
109
|
} else if ($_GET['act'] == "toggle") {
|
110
|
if ($a_filter[$_GET['id']]) {
|
111
|
if(isset($a_filter[$_GET['id']]['disabled']))
|
112
|
unset($a_filter[$_GET['id']]['disabled']);
|
113
|
else
|
114
|
$a_filter[$_GET['id']]['disabled'] = true;
|
115
|
write_config();
|
116
|
touch($d_filterconfdirty_path);
|
117
|
header("Location: firewall_rules.php?if={$if}");
|
118
|
exit;
|
119
|
}
|
120
|
} else {
|
121
|
/* yuck - IE won't send value attributes for image buttons, while Mozilla does -
|
122
|
so we use .x/.y to fine move button clicks instead... */
|
123
|
unset($movebtn);
|
124
|
foreach ($_POST as $pn => $pd) {
|
125
|
if (preg_match("/move_(\d+)_x/", $pn, $matches)) {
|
126
|
$movebtn = $matches[1];
|
127
|
break;
|
128
|
}
|
129
|
}
|
130
|
/* move selected rules before this rule */
|
131
|
if (isset($movebtn) && is_array($_POST['rule']) && count($_POST['rule'])) {
|
132
|
$a_filter_new = array();
|
133
|
|
134
|
/* copy all rules < $movebtn and not selected */
|
135
|
for ($i = 0; $i < $movebtn; $i++) {
|
136
|
if (!in_array($i, $_POST['rule']))
|
137
|
$a_filter_new[] = $a_filter[$i];
|
138
|
}
|
139
|
|
140
|
/* copy all selected rules */
|
141
|
for ($i = 0; $i < count($a_filter); $i++) {
|
142
|
if ($i == $movebtn)
|
143
|
continue;
|
144
|
if (in_array($i, $_POST['rule']))
|
145
|
$a_filter_new[] = $a_filter[$i];
|
146
|
}
|
147
|
|
148
|
/* copy $movebtn rule */
|
149
|
if ($movebtn < count($a_filter))
|
150
|
$a_filter_new[] = $a_filter[$movebtn];
|
151
|
|
152
|
/* copy all rules > $movebtn and not selected */
|
153
|
for ($i = $movebtn+1; $i < count($a_filter); $i++) {
|
154
|
if (!in_array($i, $_POST['rule']))
|
155
|
$a_filter_new[] = $a_filter[$i];
|
156
|
}
|
157
|
|
158
|
$a_filter = $a_filter_new;
|
159
|
write_config();
|
160
|
touch($d_filterconfdirty_path);
|
161
|
header("Location: firewall_rules.php?if={$if}");
|
162
|
exit;
|
163
|
}
|
164
|
}
|
165
|
$closehead = false;
|
166
|
include("head.inc");
|
167
|
|
168
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
|
169
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
|
170
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
|
171
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
|
172
|
?>
|
173
|
</head>
|
174
|
|
175
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
176
|
<?php include("fbegin.inc"); ?>
|
177
|
<p class="pgtitle"><?=$pgtitle?></p>
|
178
|
<form action="firewall_rules.php" method="post">
|
179
|
<script type="text/javascript" language="javascript" src="row_toggle.js">
|
180
|
</script>
|
181
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
182
|
<?php if (file_exists($d_filterconfdirty_path)): ?><p>
|
183
|
<?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>
|
184
|
<?php endif; ?>
|
185
|
<?php
|
186
|
$aliases_array = array();
|
187
|
if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
|
188
|
{
|
189
|
foreach($config['aliases']['alias'] as $alias_name)
|
190
|
{
|
191
|
$alias_addresses = explode (" ", $alias_name['address']);
|
192
|
$alias_details = explode ("||", $alias_name['detail']);
|
193
|
$alias_objects_with_details = "";
|
194
|
$counter = 0;
|
195
|
foreach($alias_addresses as $alias_ports_address)
|
196
|
{
|
197
|
$alias_objects_with_details .= $alias_addresses[$counter];
|
198
|
$alias_detail_default = strpos ($alias_details[$counter],"Entry added");
|
199
|
if ($alias_details[$counter] != "" && $alias_detail_default === False){
|
200
|
$alias_objects_with_details .=" - " . $alias_details[$counter];
|
201
|
}
|
202
|
$alias_objects_with_details .= "<br>";
|
203
|
$counter++;
|
204
|
}
|
205
|
$aliases_array[] = array($alias_name['name'], $alias_name['descr'], $alias_objects_with_details);
|
206
|
}
|
207
|
}
|
208
|
?>
|
209
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
210
|
<tr><td class="tabnavtbl">
|
211
|
<?php
|
212
|
/* active tabs */
|
213
|
$tab_array = array();
|
214
|
$tabscounter = 0; $i = 0; foreach ($iflist as $ifent => $ifname) {
|
215
|
if ($ifent == $if)
|
216
|
$active = true;
|
217
|
else
|
218
|
$active = false;
|
219
|
$tab_array[] = array($ifname, $active, "firewall_rules.php?if={$ifent}");
|
220
|
}
|
221
|
display_top_tabs($tab_array);
|
222
|
?>
|
223
|
</td></tr>
|
224
|
<tr>
|
225
|
<td>
|
226
|
<div id="mainarea">
|
227
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
228
|
<tr id="frheader">
|
229
|
<td width="3%" class="list"> </td>
|
230
|
<td width="5%" class="list"> </td>
|
231
|
<td width="10%" class="listhdrr">Proto</td>
|
232
|
<td width="15%" class="listhdrr">Source</td>
|
233
|
<td width="10%" class="listhdrr">Port</td>
|
234
|
<td width="15%" class="listhdrr">Destination</td>
|
235
|
<td width="10%" class="listhdrr">Port</td>
|
236
|
<td width="5%" class="listhdrr">Gateway</td>
|
237
|
<td width="5%" class="listhdrr">Schedule</td>
|
238
|
<td width="22%" class="listhdr">Description</td>
|
239
|
<td width="10%" class="list">
|
240
|
<table border="0" cellspacing="0" cellpadding="1">
|
241
|
<tr>
|
242
|
<?php
|
243
|
$nrules = 0;
|
244
|
for ($i = 0; isset($a_filter[$i]); $i++) {
|
245
|
$filterent = $a_filter[$i];
|
246
|
if ($filterent['interface'] != $if)
|
247
|
continue;
|
248
|
$nrules++;
|
249
|
}
|
250
|
?>
|
251
|
<td>
|
252
|
<?php if ($nrules == 0): ?>
|
253
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="delete selected rules" border="0"><?php else: ?>
|
254
|
<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; ?>
|
255
|
</td>
|
256
|
<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>
|
257
|
</tr>
|
258
|
</table>
|
259
|
</td>
|
260
|
</tr>
|
261
|
<?php if (($if == "wan") && isset($config['interfaces']['wan']['blockpriv'])): ?>
|
262
|
<tr valign="top" id="frrfc1918">
|
263
|
<td width="3%" class="list"> </td>
|
264
|
<td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0"></td>
|
265
|
<td class="listlr" style="background-color: #e0e0e0">*</td>
|
266
|
<td class="listr" style="background-color: #e0e0e0">RFC 1918 networks</td>
|
267
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
268
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
269
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
270
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
271
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
272
|
<td class="listbg" style="background-color: #990000"><font color="white">Block private networks</td>
|
273
|
<td valign="middle" nowrap class="list">
|
274
|
<table border="0" cellspacing="0" cellpadding="1">
|
275
|
<tr>
|
276
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="move selected rules before this rule"></td>
|
277
|
<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>
|
278
|
</tr>
|
279
|
<tr>
|
280
|
<td align="center" valign="middle"></td>
|
281
|
<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>
|
282
|
</tr>
|
283
|
</table>
|
284
|
</td>
|
285
|
</tr>
|
286
|
<?php endif; ?>
|
287
|
<?php if (($if == "wan") && isset($config['interfaces']['wan']['blockbogons'])): ?>
|
288
|
<tr valign="top" id="frrfc1918">
|
289
|
<td width="3%" class="list"> </td>
|
290
|
<td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0"></td>
|
291
|
<td class="listlr" style="background-color: #e0e0e0">*</td>
|
292
|
<td class="listr" style="background-color: #e0e0e0">Reserved/not assigned by IANA</td>
|
293
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
294
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
295
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
296
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
297
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
298
|
<td class="listbg" style="background-color: #990000"><font color="white">Block bogon networks</td>
|
299
|
<td valign="middle" nowrap class="list">
|
300
|
<table border="0" cellspacing="0" cellpadding="1">
|
301
|
<tr>
|
302
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="move selected rules before this rule"></td>
|
303
|
<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>
|
304
|
</tr>
|
305
|
<tr>
|
306
|
<td align="center" valign="middle"></td>
|
307
|
<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>
|
308
|
</tr>
|
309
|
</table>
|
310
|
</td>
|
311
|
</tr>
|
312
|
<?php endif; ?>
|
313
|
<?php $nrules = 0; for ($i = 0; isset($a_filter[$i]); $i++):
|
314
|
$filterent = $a_filter[$i];
|
315
|
if ($filterent['interface'] != $if)
|
316
|
continue;
|
317
|
?>
|
318
|
<tr valign="top" id="fr<?=$nrules;?>">
|
319
|
<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>
|
320
|
<td class="listt" align="center">
|
321
|
<?php if ($filterent['type'] == "block")
|
322
|
$iconfn = "block";
|
323
|
else if ($filterent['type'] == "reject") {
|
324
|
$iconfn = "reject";
|
325
|
} else
|
326
|
$iconfn = "pass";
|
327
|
if (isset($filterent['disabled'])) {
|
328
|
$textss = "<span class=\"gray\">";
|
329
|
$textse = "</span>";
|
330
|
$iconfn .= "_d";
|
331
|
} else {
|
332
|
$textss = $textse = "";
|
333
|
}
|
334
|
?>
|
335
|
<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>
|
336
|
<?php if (isset($filterent['log'])):
|
337
|
$iconfnlog = "log_s";
|
338
|
if (isset($filterent['disabled']))
|
339
|
$iconfnlog .= "_d";
|
340
|
?>
|
341
|
<br><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfnlog;?>.gif" width="11" height="15" border="0">
|
342
|
<?php endif; ?>
|
343
|
</td>
|
344
|
<?php
|
345
|
$span_begin = "";
|
346
|
$span_end = "";
|
347
|
$alias_src_span_begin = "";
|
348
|
$alias_src_span_end = "";
|
349
|
$alias_src_port_span_begin = "";
|
350
|
$alias_src_port_span_end = "";
|
351
|
$alias_dst_span_begin = "";
|
352
|
$alias_dst_span_end = "";
|
353
|
$alias_dst_port_span_begin = "";
|
354
|
$alias_dst_port_span_end = "";
|
355
|
$alias_content_text = "";
|
356
|
//max character length for caption field
|
357
|
$maxlength = 60;
|
358
|
|
359
|
foreach ($aliases_array as $alias)
|
360
|
{
|
361
|
$alias_id_substr = $alias[0];
|
362
|
$alias_descr_substr = $alias[1];
|
363
|
$alias_content_text = htmlentities($alias[2], ENT_QUOTES);
|
364
|
$alias_caption = htmlspecialchars($alias_descr_substr . ":", ENT_QUOTES);
|
365
|
$strlength = strlen ($alias_caption);
|
366
|
if ($strlength >= $maxlength)
|
367
|
$alias_caption = substr($alias_caption, 0, $maxlength) . "...";
|
368
|
|
369
|
$alias_check_src = $filterent['source']['address'];
|
370
|
$alias_check_srcport = pprint_port($filterent['source']['port']);
|
371
|
$alias_check_dst = $filterent['destination']['address'];
|
372
|
$alias_check_dstport = pprint_port($filterent['destination']['port']);
|
373
|
|
374
|
$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>";
|
375
|
$span_end = "</U></span>";
|
376
|
|
377
|
if ($alias_id_substr == $alias_check_src)
|
378
|
{
|
379
|
$alias_src_span_begin = $span_begin;
|
380
|
$alias_src_span_end = $span_end;
|
381
|
}
|
382
|
if ($alias_id_substr == $alias_check_srcport)
|
383
|
{
|
384
|
$alias_src_port_span_begin = $span_begin;
|
385
|
$alias_src_port_span_end = $span_end;
|
386
|
}
|
387
|
if ($alias_id_substr == $alias_check_dst)
|
388
|
{
|
389
|
$alias_dst_span_begin = $span_begin;
|
390
|
$alias_dst_span_end = $span_end;
|
391
|
}
|
392
|
if ($alias_id_substr == $alias_check_dstport)
|
393
|
{
|
394
|
$alias_dst_port_span_begin = $span_begin;
|
395
|
$alias_dst_port_span_end = $span_end;
|
396
|
}
|
397
|
}
|
398
|
$printicon = false;
|
399
|
if ($schedstatus)
|
400
|
{
|
401
|
if ($iconfn == "block" || $iconfn == "reject")
|
402
|
{
|
403
|
$image = "icon_clock_red";
|
404
|
$alttest = "Traffic matching this rule is currently being denied";
|
405
|
}
|
406
|
else
|
407
|
{
|
408
|
$image = "icon_clock_green";
|
409
|
$alttest = "Traffic matching this rule is currently being allowed";
|
410
|
}
|
411
|
$printicon = true;
|
412
|
}
|
413
|
else if ($filterent['sched'] )
|
414
|
{
|
415
|
if ($iconfn == "block" || $iconfn == "reject")
|
416
|
{
|
417
|
$image = "icon_clock_green";
|
418
|
$alttext = "Traffic matching this rule is currently being allowed";
|
419
|
}
|
420
|
else
|
421
|
{
|
422
|
$image = "icon_clock_red";
|
423
|
$alttext = "Traffic matching this rule is currently being denied";
|
424
|
}
|
425
|
$printicon = true;
|
426
|
}
|
427
|
|
428
|
//build Schedule popup box
|
429
|
$a_schedules = &$config['schedules']['schedule'];
|
430
|
$schedule_span_begin = "";
|
431
|
$schedule_span_end = "";
|
432
|
$sched_caption = "";
|
433
|
$sched_content = "";
|
434
|
$schedstatus = false;
|
435
|
$dayArray = array ('Mon','Tues','Wed','Thur','Fri','Sat','Sun');
|
436
|
$monthArray = array ('January','February','March','April','May','June','July','August','September','October','November','December');
|
437
|
if(is_array($a_schedules))
|
438
|
foreach ($a_schedules as $schedule)
|
439
|
{
|
440
|
if ($schedule['name'] == $filterent['sched'] ){
|
441
|
$schedstatus = get_time_based_rule_status($schedule);
|
442
|
|
443
|
foreach($schedule['timerange'] as $timerange) {
|
444
|
$tempFriendlyTime = "";
|
445
|
$tempID = "";
|
446
|
$firstprint = false;
|
447
|
if ($timerange){
|
448
|
$dayFriendly = "";
|
449
|
$tempFriendlyTime = "";
|
450
|
|
451
|
//get hours
|
452
|
$temptimerange = $timerange['hour'];
|
453
|
$temptimeseparator = strrpos($temptimerange, "-");
|
454
|
|
455
|
$starttime = substr ($temptimerange, 0, $temptimeseparator);
|
456
|
$stoptime = substr ($temptimerange, $temptimeseparator+1);
|
457
|
|
458
|
if ($timerange['month']){
|
459
|
$tempmontharray = explode(",", $timerange['month']);
|
460
|
$tempdayarray = explode(",",$timerange['day']);
|
461
|
$arraycounter = 0;
|
462
|
$firstDayFound = false;
|
463
|
$firstPrint = false;
|
464
|
foreach ($tempmontharray as $monthtmp){
|
465
|
$month = $tempmontharray[$arraycounter];
|
466
|
$day = $tempdayarray[$arraycounter];
|
467
|
|
468
|
if (!$firstDayFound)
|
469
|
{
|
470
|
$firstDay = $day;
|
471
|
$firstmonth = $month;
|
472
|
$firstDayFound = true;
|
473
|
}
|
474
|
|
475
|
$currentDay = $day;
|
476
|
$nextDay = $tempdayarray[$arraycounter+1];
|
477
|
$currentDay++;
|
478
|
if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])){
|
479
|
if ($firstPrint)
|
480
|
$dayFriendly .= ", ";
|
481
|
$currentDay--;
|
482
|
if ($currentDay != $firstDay)
|
483
|
$dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ;
|
484
|
else
|
485
|
$dayFriendly .= $monthArray[$month-1] . " " . $day;
|
486
|
$firstDayFound = false;
|
487
|
$firstPrint = true;
|
488
|
}
|
489
|
$arraycounter++;
|
490
|
}
|
491
|
}
|
492
|
else
|
493
|
{
|
494
|
$tempdayFriendly = $timerange['position'];
|
495
|
$firstDayFound = false;
|
496
|
$tempFriendlyDayArray = explode(",", $tempdayFriendly);
|
497
|
$currentDay = "";
|
498
|
$firstDay = "";
|
499
|
$nextDay = "";
|
500
|
$counter = 0;
|
501
|
foreach ($tempFriendlyDayArray as $day){
|
502
|
if ($day != ""){
|
503
|
if (!$firstDayFound)
|
504
|
{
|
505
|
$firstDay = $tempFriendlyDayArray[$counter];
|
506
|
$firstDayFound = true;
|
507
|
}
|
508
|
$currentDay =$tempFriendlyDayArray[$counter];
|
509
|
//get next day
|
510
|
$nextDay = $tempFriendlyDayArray[$counter+1];
|
511
|
$currentDay++;
|
512
|
if ($currentDay != $nextDay){
|
513
|
if ($firstprint)
|
514
|
$dayFriendly .= ", ";
|
515
|
$currentDay--;
|
516
|
if ($currentDay != $firstDay)
|
517
|
$dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
|
518
|
else
|
519
|
$dayFriendly .= $dayArray[$firstDay-1];
|
520
|
$firstDayFound = false;
|
521
|
$firstprint = true;
|
522
|
}
|
523
|
$counter++;
|
524
|
}
|
525
|
}
|
526
|
}
|
527
|
$timeFriendly = $starttime . " - " . $stoptime;
|
528
|
$description = $timerange['rangedescr'];
|
529
|
$sched_content .= $dayFriendly . "; " . $timeFriendly . "<br>";
|
530
|
}
|
531
|
}
|
532
|
$sched_caption = $schedule['descr'];
|
533
|
$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>";
|
534
|
$schedule_span_end = "</U></span>";
|
535
|
}
|
536
|
}
|
537
|
$printicon = false;
|
538
|
$alttext = "";
|
539
|
$image = "";
|
540
|
if (!isset($filterent['disabled'])){
|
541
|
if ($schedstatus)
|
542
|
{
|
543
|
if ($iconfn == "block" || $iconfn == "reject")
|
544
|
{
|
545
|
$image = "icon_block";
|
546
|
$alttext = "Traffic matching this rule is currently being denied";
|
547
|
}
|
548
|
else
|
549
|
{
|
550
|
$image = "icon_pass";
|
551
|
$alttext = "Traffic matching this rule is currently being allowed";
|
552
|
}
|
553
|
$printicon = true;
|
554
|
}
|
555
|
else if ($filterent['sched'])
|
556
|
{
|
557
|
if ($iconfn == "block" || $iconfn == "reject")
|
558
|
{
|
559
|
$image = "icon_block_d";
|
560
|
$alttext = "Traffic matching this rule is currently being allowed";
|
561
|
}
|
562
|
else
|
563
|
{
|
564
|
$image = "icon_block";
|
565
|
$alttext = "Traffic matching this rule is currently being denied";
|
566
|
}
|
567
|
$printicon = true;
|
568
|
}
|
569
|
}
|
570
|
?>
|
571
|
<td class="listlr" 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;?>';"><font color="black">
|
590
|
<?php if ($printicon) { ?><img src="./themes/<?= $g['theme']; ?>/images/icons/<?php echo $image; ?>.gif" title="<?php echo $alttext;?>" border="0"><?php } ?> <?=$textss;?><?php echo $schedule_span_begin;?><?=htmlspecialchars($filterent['sched']);?><?php echo $schedule_span_end; ?><?=$textse;?>
|
591
|
</td>
|
592
|
<td class="listbg" onClick="fr_toggle(<?=$nrules;?>)" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';" bcolor="#990000"><font color="white">
|
593
|
<?=$textss;?><?=htmlspecialchars($filterent['descr']);?> <?=$textse;?>
|
594
|
</td>
|
595
|
<td valign="middle" nowrap class="list">
|
596
|
<table border="0" cellspacing="0" cellpadding="1">
|
597
|
<tr>
|
598
|
<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>
|
599
|
<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>
|
600
|
</tr>
|
601
|
<tr>
|
602
|
<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>
|
603
|
<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>
|
604
|
</tr>
|
605
|
</table>
|
606
|
</td>
|
607
|
</tr>
|
608
|
<?php $nrules++; endfor; ?>
|
609
|
<?php if ($nrules == 0): ?>
|
610
|
<td class="listt"></td>
|
611
|
<td class="listt"></td>
|
612
|
<td class="listlr" colspan="8" align="center" valign="middle">
|
613
|
<span class="gray">
|
614
|
No rules are currently defined for this interface.<br>
|
615
|
All incoming connections on this interface will be blocked until you add pass rules.<br><br>
|
616
|
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>
|
617
|
</td>
|
618
|
<?php endif; ?>
|
619
|
<tr id="fr<?=$nrules;?>">
|
620
|
<td class="list"></td>
|
621
|
<td class="list"></td>
|
622
|
<td class="list"> </td>
|
623
|
<td class="list"> </td>
|
624
|
<td class="list"> </td>
|
625
|
<td class="list"> </td>
|
626
|
<td class="list"> </td>
|
627
|
<td class="list"> </td>
|
628
|
<td class="list"> </td>
|
629
|
<td class="list"> </td>
|
630
|
<td class="list">
|
631
|
<table border="0" cellspacing="0" cellpadding="1">
|
632
|
<tr>
|
633
|
<td>
|
634
|
<?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>
|
635
|
<td></td>
|
636
|
</tr>
|
637
|
<tr>
|
638
|
<td>
|
639
|
<?php if ($nrules == 0): ?>
|
640
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="delete selected rules" border="0"><?php else: ?>
|
641
|
<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; ?>
|
642
|
</td>
|
643
|
<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>
|
644
|
</tr>
|
645
|
</table>
|
646
|
</td>
|
647
|
</tr>
|
648
|
</table>
|
649
|
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
|
650
|
<tr>
|
651
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif" width="11" height="11"></td>
|
652
|
<td>pass</td>
|
653
|
<td width="14"></td>
|
654
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11"></td>
|
655
|
<td>block</td>
|
656
|
<td width="14"></td>
|
657
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_reject.gif" width="11" height="11"></td>
|
658
|
<td>reject</td>
|
659
|
<td width="14"></td>
|
660
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_log.gif" width="11" height="11"></td>
|
661
|
<td>log</td>
|
662
|
</tr>
|
663
|
<tr>
|
664
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass_d.gif" width="11" height="11"></td>
|
665
|
<td nowrap>pass (disabled)</td>
|
666
|
<td> </td>
|
667
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block_d.gif" width="11" height="11"></td>
|
668
|
<td nowrap>block (disabled)</td>
|
669
|
<td> </td>
|
670
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_reject_d.gif" width="11" height="11"></td>
|
671
|
<td nowrap>reject (disabled)</td>
|
672
|
<td> </td>
|
673
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_log_d.gif" width="11" height="11"></td>
|
674
|
<td nowrap>log (disabled)</td>
|
675
|
</tr>
|
676
|
<tr>
|
677
|
<td colspan="10">
|
678
|
<p>
|
679
|
<strong><span class="red">Hint:<br>
|
680
|
</span></strong>Rules are evaluated on a first-match basis (i.e.
|
681
|
the action of the first rule to match a packet will be executed).
|
682
|
This means that if you use block rules, you'll have to pay attention
|
683
|
to the rule order. Everything that isn't explicitly passed is blocked
|
684
|
by default.</p>
|
685
|
</td>
|
686
|
</tr>
|
687
|
</table>
|
688
|
</div>
|
689
|
</td>
|
690
|
</tr>
|
691
|
</table>
|
692
|
<input type="hidden" name="if" value="<?=$if;?>">
|
693
|
</form>
|
694
|
<?php include("fend.inc"); ?>
|
695
|
</body>
|
696
|
</html>
|