1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
firewall_rules.php
|
5
|
part of pfSense (http://www.pfsense.com)
|
6
|
Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
|
7
|
|
8
|
originally part of m0n0wall (http://m0n0.ch/wall)
|
9
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
10
|
All rights reserved.
|
11
|
|
12
|
Redistribution and use in source and binary forms, with or without
|
13
|
modification, are permitted provided that the following conditions are met:
|
14
|
|
15
|
1. Redistributions of source code must retain the above copyright notice,
|
16
|
this list of conditions and the following disclaimer.
|
17
|
|
18
|
2. Redistributions in binary form must reproduce the above copyright
|
19
|
notice, this list of conditions and the following disclaimer in the
|
20
|
documentation and/or other materials provided with the distribution.
|
21
|
|
22
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
23
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
24
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
25
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
26
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31
|
POSSIBILITY OF SUCH DAMAGE.
|
32
|
*/
|
33
|
/*
|
34
|
pfSense_MODULE: filter
|
35
|
*/
|
36
|
|
37
|
##|+PRIV
|
38
|
##|*IDENT=page-firewall-rules
|
39
|
##|*NAME=Firewall: Rules page
|
40
|
##|*DESCR=Allow access to the 'Firewall: Rules' page.
|
41
|
##|*MATCH=firewall_rules.php*
|
42
|
##|-PRIV
|
43
|
|
44
|
$pgtitle = array("Firewall", "Rules");
|
45
|
require("guiconfig.inc");
|
46
|
|
47
|
function check_for_advaned_options(&$item) {
|
48
|
$item_set = "";
|
49
|
if($item['max-src-nodes'])
|
50
|
$item_set .= "max-src-nodes {$item['max-src-nodes']} ";
|
51
|
if($item['max-src-states'])
|
52
|
$item_set .= "max-src-states {$item['max-src-states']} ";
|
53
|
if($item['statetype'] != "keep state" && $item['statetype'] != "")
|
54
|
$item_set .= "statetype {$item['statetype']} {$item['statetype']}";
|
55
|
if($item['statetimeout'])
|
56
|
$item_set .= "statetimeout {$item['statetimeout']}";
|
57
|
if($item['nosync'])
|
58
|
$item_set .= "nosync ";
|
59
|
if($item['max-src-conn-rate'])
|
60
|
$item_set .= "max-src-conn-rate {$item['max-src-conn-rate']} ";
|
61
|
if($item['max-src-conn-rates'])
|
62
|
$item_set .= "max-src-conn-rates {$item['max-src-conn-rates']} ";
|
63
|
return $item_set;
|
64
|
}
|
65
|
|
66
|
if (!is_array($config['filter']['rule'])) {
|
67
|
$config['filter']['rule'] = array();
|
68
|
}
|
69
|
filter_rules_sort();
|
70
|
$a_filter = &$config['filter']['rule'];
|
71
|
|
72
|
$if = $_GET['if'];
|
73
|
if ($_POST['if'])
|
74
|
$if = $_POST['if'];
|
75
|
|
76
|
$ifdescs = get_configured_interface_with_descr();
|
77
|
|
78
|
/* add group interfaces */
|
79
|
if (is_array($config['ifgroups']['ifgroupentry']))
|
80
|
foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
|
81
|
if (have_ruleint_access($ifgen['ifname']))
|
82
|
$iflist[$ifgen['ifname']] = $ifgen['ifname'];
|
83
|
|
84
|
foreach ($ifdescs as $ifent => $ifdesc)
|
85
|
if(have_ruleint_access($ifent))
|
86
|
$iflist[$ifent] = $ifdesc;
|
87
|
|
88
|
if ($config['l2tp']['mode'] == "server")
|
89
|
if(have_ruleint_access("l2tp"))
|
90
|
$iflist['l2tp'] = "L2TP VPN";
|
91
|
|
92
|
if ($config['pptpd']['mode'] == "server")
|
93
|
if(have_ruleint_access("pptp"))
|
94
|
$iflist['pptp'] = "PPTP VPN";
|
95
|
|
96
|
if ($config['pppoe']['mode'] == "server")
|
97
|
if(have_ruleint_access("pppoe"))
|
98
|
$iflist['pppoe'] = "PPPoE VPN";
|
99
|
|
100
|
/* add ipsec interfaces */
|
101
|
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
|
102
|
if(have_ruleint_access("enc0"))
|
103
|
$iflist["enc0"] = "IPsec";
|
104
|
|
105
|
/* add openvpn/tun interfaces */
|
106
|
if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
|
107
|
$iflist["openvpn"] = "OpenVPN";
|
108
|
|
109
|
if (!$if || !isset($iflist[$if])) {
|
110
|
if ("any" == $if)
|
111
|
$if = "FloatingRules";
|
112
|
else if ("FloatingRules" != $if)
|
113
|
$if = "wan";
|
114
|
}
|
115
|
|
116
|
if ($_POST) {
|
117
|
|
118
|
$pconfig = $_POST;
|
119
|
|
120
|
if ($_POST['apply']) {
|
121
|
$retval = 0;
|
122
|
$retval = filter_configure();
|
123
|
|
124
|
clear_subsystem_dirty('filter');
|
125
|
|
126
|
$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.";
|
127
|
}
|
128
|
}
|
129
|
|
130
|
if ($_GET['act'] == "del") {
|
131
|
if ($a_filter[$_GET['id']]) {
|
132
|
unset($a_filter[$_GET['id']]);
|
133
|
write_config();
|
134
|
mark_subsystem_dirty('filter');
|
135
|
header("Location: firewall_rules.php?if={$if}");
|
136
|
exit;
|
137
|
}
|
138
|
}
|
139
|
|
140
|
if (isset($_POST['del_x'])) {
|
141
|
/* delete selected rules */
|
142
|
if (is_array($_POST['rule']) && count($_POST['rule'])) {
|
143
|
foreach ($_POST['rule'] as $rulei) {
|
144
|
unset($a_filter[$rulei]);
|
145
|
}
|
146
|
write_config();
|
147
|
mark_subsystem_dirty('filter');
|
148
|
header("Location: firewall_rules.php?if={$if}");
|
149
|
exit;
|
150
|
}
|
151
|
} else if ($_GET['act'] == "toggle") {
|
152
|
if ($a_filter[$_GET['id']]) {
|
153
|
if(isset($a_filter[$_GET['id']]['disabled']))
|
154
|
unset($a_filter[$_GET['id']]['disabled']);
|
155
|
else
|
156
|
$a_filter[$_GET['id']]['disabled'] = true;
|
157
|
write_config();
|
158
|
mark_subsystem_dirty('filter');
|
159
|
header("Location: firewall_rules.php?if={$if}");
|
160
|
exit;
|
161
|
}
|
162
|
} else {
|
163
|
/* yuck - IE won't send value attributes for image buttons, while Mozilla does -
|
164
|
so we use .x/.y to fine move button clicks instead... */
|
165
|
unset($movebtn);
|
166
|
foreach ($_POST as $pn => $pd) {
|
167
|
if (preg_match("/move_(\d+)_x/", $pn, $matches)) {
|
168
|
$movebtn = $matches[1];
|
169
|
break;
|
170
|
}
|
171
|
}
|
172
|
/* move selected rules before this rule */
|
173
|
if (isset($movebtn) && is_array($_POST['rule']) && count($_POST['rule'])) {
|
174
|
$a_filter_new = array();
|
175
|
|
176
|
/* copy all rules < $movebtn and not selected */
|
177
|
for ($i = 0; $i < $movebtn; $i++) {
|
178
|
if (!in_array($i, $_POST['rule']))
|
179
|
$a_filter_new[] = $a_filter[$i];
|
180
|
}
|
181
|
|
182
|
/* copy all selected rules */
|
183
|
for ($i = 0; $i < count($a_filter); $i++) {
|
184
|
if ($i == $movebtn)
|
185
|
continue;
|
186
|
if (in_array($i, $_POST['rule']))
|
187
|
$a_filter_new[] = $a_filter[$i];
|
188
|
}
|
189
|
|
190
|
/* copy $movebtn rule */
|
191
|
if ($movebtn < count($a_filter))
|
192
|
$a_filter_new[] = $a_filter[$movebtn];
|
193
|
|
194
|
/* copy all rules > $movebtn and not selected */
|
195
|
for ($i = $movebtn+1; $i < count($a_filter); $i++) {
|
196
|
if (!in_array($i, $_POST['rule']))
|
197
|
$a_filter_new[] = $a_filter[$i];
|
198
|
}
|
199
|
|
200
|
$a_filter = $a_filter_new;
|
201
|
write_config();
|
202
|
mark_subsystem_dirty('filter');
|
203
|
header("Location: firewall_rules.php?if={$if}");
|
204
|
exit;
|
205
|
}
|
206
|
}
|
207
|
$closehead = false;
|
208
|
|
209
|
include("head.inc");
|
210
|
|
211
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
|
212
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
|
213
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
|
214
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
|
215
|
?>
|
216
|
</head>
|
217
|
|
218
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
219
|
<?php include("fbegin.inc"); ?>
|
220
|
<form action="firewall_rules.php" method="post">
|
221
|
<script type="text/javascript" language="javascript" src="/javascript/row_toggle.js">
|
222
|
</script>
|
223
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
224
|
<?php if (is_subsystem_dirty('filter')): ?><p>
|
225
|
<?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>
|
226
|
<?php endif; ?>
|
227
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
228
|
<tr><td class="tabnavtbl">
|
229
|
<?php
|
230
|
/* active tabs */
|
231
|
$tab_array = array();
|
232
|
if ("FloatingRules" == $if)
|
233
|
$active = true;
|
234
|
else
|
235
|
$active = false;
|
236
|
$tab_array[] = array("Floating", $active, "firewall_rules.php?if=FloatingRules");
|
237
|
$tabscounter = 0; $i = 0; foreach ($iflist as $ifent => $ifname) {
|
238
|
if ($ifent == $if)
|
239
|
$active = true;
|
240
|
else
|
241
|
$active = false;
|
242
|
$tab_array[] = array($ifname, $active, "firewall_rules.php?if={$ifent}");
|
243
|
}
|
244
|
display_top_tabs($tab_array);
|
245
|
?>
|
246
|
</td></tr>
|
247
|
<tr>
|
248
|
<td>
|
249
|
<div id="mainarea">
|
250
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
251
|
<tr id="frheader">
|
252
|
<td width="3%" class="list"> </td>
|
253
|
<td width="5%" class="list"> </td>
|
254
|
<td width="3%" class="listhdrr">ID</td>
|
255
|
<td width="6%" class="listhdrr">Proto</td>
|
256
|
<td width="14%" class="listhdrr">Source</td>
|
257
|
<td width="7%" class="listhdrr">Port</td>
|
258
|
<td width="14%" class="listhdrr">Destination</td>
|
259
|
<td width="7%" class="listhdrr">Port</td>
|
260
|
<td width="5%" class="listhdrr">Gateway</td>
|
261
|
<td width="10%" class="listhdrr">Queue</td>
|
262
|
<td width="5%" class="listhdrr">Schedule</td>
|
263
|
<td width="21%" class="listhdr">Description</td>
|
264
|
<td width="10%" class="list">
|
265
|
<table border="0" cellspacing="0" cellpadding="1">
|
266
|
<tr>
|
267
|
<?php
|
268
|
$nrules = 0;
|
269
|
for ($i = 0; isset($a_filter[$i]); $i++) {
|
270
|
$filterent = $a_filter[$i];
|
271
|
if ($filterent['interface'] != $if && !isset($filterent['floating']))
|
272
|
continue;
|
273
|
if (isset($filterent['floating']) && "FloatingRules" != $if)
|
274
|
continue;
|
275
|
$nrules++;
|
276
|
}
|
277
|
?>
|
278
|
<td>
|
279
|
<?php if ($nrules == 0): ?>
|
280
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="delete selected rules" border="0"><?php else: ?>
|
281
|
<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; ?>
|
282
|
</td>
|
283
|
<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>
|
284
|
</tr>
|
285
|
</table>
|
286
|
</td>
|
287
|
</tr>
|
288
|
<?php if (isset($config['interfaces'][$if]['blockpriv'])): ?>
|
289
|
<tr valign="top" id="frrfc1918">
|
290
|
<td width="3%" class="list"> </td>
|
291
|
<td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0"></td>
|
292
|
<td class="listlr" style="background-color: #e0e0e0"></td>
|
293
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
294
|
<td class="listr" style="background-color: #e0e0e0">RFC 1918 networks</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="listr" style="background-color: #e0e0e0">*</td>
|
299
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
300
|
<td class="listr" style="background-color: #e0e0e0"></td>
|
301
|
<td class="listbg">Block private networks</td>
|
302
|
<td valign="middle" nowrap class="list">
|
303
|
<table border="0" cellspacing="0" cellpadding="1">
|
304
|
<tr>
|
305
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="move selected rules before this rule"></td>
|
306
|
<td><a href="interfaces.php#rfc1918"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit rule" width="17" height="17" border="0"></a></td>
|
307
|
</tr>
|
308
|
<tr>
|
309
|
<td align="center" valign="middle"></td>
|
310
|
<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>
|
311
|
</tr>
|
312
|
</table>
|
313
|
</td>
|
314
|
</tr>
|
315
|
<?php endif; ?>
|
316
|
<?php if (isset($config['interfaces'][$if]['blockbogons'])): ?>
|
317
|
<tr valign="top" id="frrfc1918">
|
318
|
<td width="3%" class="list"> </td>
|
319
|
<td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0"></td>
|
320
|
<td class="listlr" style="background-color: #e0e0e0"></td>
|
321
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
322
|
<td class="listr" style="background-color: #e0e0e0">Reserved/not assigned by IANA</td>
|
323
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
324
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
325
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
326
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
327
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
328
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
329
|
<td class="listbg">Block bogon networks</td>
|
330
|
<td valign="middle" nowrap class="list">
|
331
|
<table border="0" cellspacing="0" cellpadding="1">
|
332
|
<tr>
|
333
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="move selected rules before this rule"></td>
|
334
|
<td><a href="interfaces.php#rfc1918"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit rule" width="17" height="17" border="0"></a></td>
|
335
|
</tr>
|
336
|
<tr>
|
337
|
<td align="center" valign="middle"></td>
|
338
|
<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>
|
339
|
</tr>
|
340
|
</table>
|
341
|
</td>
|
342
|
</tr>
|
343
|
<?php endif; ?>
|
344
|
<?php $nrules = 0; for ($i = 0; isset($a_filter[$i]); $i++):
|
345
|
$filterent = $a_filter[$i];
|
346
|
if ($filterent['interface'] != $if && !isset($filterent['floating']))
|
347
|
continue;
|
348
|
if (isset($filterent['floating']) && "FloatingRules" != $if)
|
349
|
continue;
|
350
|
$isadvset = check_for_advaned_options($filterent);
|
351
|
if($isadvset)
|
352
|
$advanced_set = "<img src=\"./themes/{$g['theme']}/images/icons/icon_advanced.gif\" title=\"advanced settings set: $isadvset\" border=\"0\">";
|
353
|
else
|
354
|
$advanced_set = ""
|
355
|
?>
|
356
|
<tr valign="top" id="fr<?=$nrules;?>">
|
357
|
<td class="listt">
|
358
|
<input type="checkbox" id="frc<?=$nrules;?>" name="rule[]" value="<?=$i;?>" onClick="fr_bgcolor('<?=$nrules;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;">
|
359
|
<?php echo $advanced_set; ?>
|
360
|
</td>
|
361
|
<td class="listt" align="center">
|
362
|
<?php if ($filterent['type'] == "block")
|
363
|
$iconfn = "block";
|
364
|
else if ($filterent['type'] == "reject") {
|
365
|
if ($filterent['protocol'] == "tcp" || $filterent['protocol'] == "udp" || $filterent['protocol'] == "tcp/udp")
|
366
|
$iconfn = "reject";
|
367
|
else
|
368
|
$iconfn = "block";
|
369
|
} else
|
370
|
$iconfn = "pass";
|
371
|
if (isset($filterent['disabled'])) {
|
372
|
$textss = "<span class=\"gray\">";
|
373
|
$textse = "</span>";
|
374
|
$iconfn .= "_d";
|
375
|
} else {
|
376
|
$textss = $textse = "";
|
377
|
}
|
378
|
?>
|
379
|
<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>
|
380
|
<?php if (isset($filterent['log'])):
|
381
|
$iconfnlog = "log_s";
|
382
|
if (isset($filterent['disabled']))
|
383
|
$iconfnlog .= "_d";
|
384
|
?>
|
385
|
<br><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfnlog;?>.gif" width="11" height="15" border="0">
|
386
|
<?php endif; ?>
|
387
|
</td>
|
388
|
<?php
|
389
|
|
390
|
//build Alias popup box
|
391
|
$span_end = "";
|
392
|
$alias_src_span_begin = "";
|
393
|
$alias_src_port_span_begin = "";
|
394
|
$alias_dst_span_begin = "";
|
395
|
$alias_dst_port_span_begin = "";
|
396
|
|
397
|
$alias_popup = rule_popup($filterent['source']['address'],pprint_port($filterent['source']['port']),$filterent['destination']['address'],pprint_port($filterent['destination']['port']));
|
398
|
$span_end = "</U></span>";
|
399
|
|
400
|
$alias_src_span_begin = $alias_popup["src"];
|
401
|
|
402
|
$alias_src_port_span_begin = $alias_popup["srcport"];
|
403
|
|
404
|
$alias_dst_span_begin = $alias_popup["dst"];
|
405
|
|
406
|
$alias_dst_port_span_begin = $alias_popup["dstport"];
|
407
|
|
408
|
//build Schedule popup box
|
409
|
$a_schedules = &$config['schedules']['schedule'];
|
410
|
$schedule_span_begin = "";
|
411
|
$schedule_span_end = "";
|
412
|
$sched_caption = "";
|
413
|
$sched_content = "";
|
414
|
$schedstatus = false;
|
415
|
$dayArray = array ('Mon','Tues','Wed','Thur','Fri','Sat','Sun');
|
416
|
$monthArray = array ('January','February','March','April','May','June','July','August','September','October','November','December');
|
417
|
if($config['schedules']['schedule'] <> "" and is_array($config['schedules']['schedule'])){
|
418
|
foreach ($a_schedules as $schedule)
|
419
|
{
|
420
|
if ($schedule['name'] == $filterent['sched'] ){
|
421
|
$schedstatus = filter_get_time_based_rule_status($schedule);
|
422
|
|
423
|
foreach($schedule['timerange'] as $timerange) {
|
424
|
$tempFriendlyTime = "";
|
425
|
$tempID = "";
|
426
|
$firstprint = false;
|
427
|
if ($timerange){
|
428
|
$dayFriendly = "";
|
429
|
$tempFriendlyTime = "";
|
430
|
|
431
|
//get hours
|
432
|
$temptimerange = $timerange['hour'];
|
433
|
$temptimeseparator = strrpos($temptimerange, "-");
|
434
|
|
435
|
$starttime = substr ($temptimerange, 0, $temptimeseparator);
|
436
|
$stoptime = substr ($temptimerange, $temptimeseparator+1);
|
437
|
|
438
|
if ($timerange['month']){
|
439
|
$tempmontharray = explode(",", $timerange['month']);
|
440
|
$tempdayarray = explode(",",$timerange['day']);
|
441
|
$arraycounter = 0;
|
442
|
$firstDayFound = false;
|
443
|
$firstPrint = false;
|
444
|
foreach ($tempmontharray as $monthtmp){
|
445
|
$month = $tempmontharray[$arraycounter];
|
446
|
$day = $tempdayarray[$arraycounter];
|
447
|
|
448
|
if (!$firstDayFound)
|
449
|
{
|
450
|
$firstDay = $day;
|
451
|
$firstmonth = $month;
|
452
|
$firstDayFound = true;
|
453
|
}
|
454
|
|
455
|
$currentDay = $day;
|
456
|
$nextDay = $tempdayarray[$arraycounter+1];
|
457
|
$currentDay++;
|
458
|
if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])){
|
459
|
if ($firstPrint)
|
460
|
$dayFriendly .= ", ";
|
461
|
$currentDay--;
|
462
|
if ($currentDay != $firstDay)
|
463
|
$dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ;
|
464
|
else
|
465
|
$dayFriendly .= $monthArray[$month-1] . " " . $day;
|
466
|
$firstDayFound = false;
|
467
|
$firstPrint = true;
|
468
|
}
|
469
|
$arraycounter++;
|
470
|
}
|
471
|
}
|
472
|
else
|
473
|
{
|
474
|
$tempdayFriendly = $timerange['position'];
|
475
|
$firstDayFound = false;
|
476
|
$tempFriendlyDayArray = explode(",", $tempdayFriendly);
|
477
|
$currentDay = "";
|
478
|
$firstDay = "";
|
479
|
$nextDay = "";
|
480
|
$counter = 0;
|
481
|
foreach ($tempFriendlyDayArray as $day){
|
482
|
if ($day != ""){
|
483
|
if (!$firstDayFound)
|
484
|
{
|
485
|
$firstDay = $tempFriendlyDayArray[$counter];
|
486
|
$firstDayFound = true;
|
487
|
}
|
488
|
$currentDay =$tempFriendlyDayArray[$counter];
|
489
|
//get next day
|
490
|
$nextDay = $tempFriendlyDayArray[$counter+1];
|
491
|
$currentDay++;
|
492
|
if ($currentDay != $nextDay){
|
493
|
if ($firstprint)
|
494
|
$dayFriendly .= ", ";
|
495
|
$currentDay--;
|
496
|
if ($currentDay != $firstDay)
|
497
|
$dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
|
498
|
else
|
499
|
$dayFriendly .= $dayArray[$firstDay-1];
|
500
|
$firstDayFound = false;
|
501
|
$firstprint = true;
|
502
|
}
|
503
|
$counter++;
|
504
|
}
|
505
|
}
|
506
|
}
|
507
|
$timeFriendly = $starttime . " - " . $stoptime;
|
508
|
$description = $timerange['rangedescr'];
|
509
|
$sched_content .= $dayFriendly . "; " . $timeFriendly . "<br>";
|
510
|
}
|
511
|
}
|
512
|
$sched_caption = $schedule['descr'];
|
513
|
$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>";
|
514
|
$schedule_span_end = "</U></span>";
|
515
|
}
|
516
|
}
|
517
|
}
|
518
|
$printicon = false;
|
519
|
$alttext = "";
|
520
|
$image = "";
|
521
|
if (!isset($filterent['disabled'])){
|
522
|
if ($schedstatus)
|
523
|
{
|
524
|
if ($iconfn == "block" || $iconfn == "reject")
|
525
|
{
|
526
|
$image = "icon_block";
|
527
|
$alttext = "Traffic matching this rule is currently being denied";
|
528
|
}
|
529
|
else
|
530
|
{
|
531
|
$image = "icon_pass";
|
532
|
$alttext = "Traffic matching this rule is currently being allowed";
|
533
|
}
|
534
|
$printicon = true;
|
535
|
}
|
536
|
else if ($filterent['sched'])
|
537
|
{
|
538
|
if ($iconfn == "block" || $iconfn == "reject")
|
539
|
{
|
540
|
$image = "icon_block_d";
|
541
|
$alttext = "Traffic matching this rule is currently being allowed";
|
542
|
}
|
543
|
else
|
544
|
{
|
545
|
$image = "icon_block";
|
546
|
$alttext = "Traffic matching this rule is currently being denied";
|
547
|
}
|
548
|
$printicon = true;
|
549
|
}
|
550
|
}
|
551
|
?>
|
552
|
<td class="listlr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
|
553
|
<?=$textss;?><?php if (isset($filterent['id'])) echo $filterent['id']; else echo ""; ?><?=$textse;?>
|
554
|
</td>
|
555
|
<td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
|
556
|
<?=$textss;?><?php if (isset($filterent['protocol'])) echo strtoupper($filterent['protocol']); else echo "*"; ?><?=$textse;?>
|
557
|
</td>
|
558
|
<td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
|
559
|
<?=$textss;?><?php echo $alias_src_span_begin;?><?php echo htmlspecialchars(pprint_address($filterent['source']));?><?php echo $alias_src_span_end;?><?=$textse;?>
|
560
|
</td>
|
561
|
<td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
|
562
|
<?=$textss;?><?php echo $alias_src_port_span_begin;?><?php echo htmlspecialchars(pprint_port($filterent['source']['port'])); ?><?php echo $alias_src_port_span_end;?><?=$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_dst_span_begin;?><?php echo htmlspecialchars(pprint_address($filterent['destination'])); ?><?php echo $alias_dst_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_dst_port_span_begin;?><?php echo htmlspecialchars(pprint_port($filterent['destination']['port'])); ?><?php echo $alias_dst_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 if (isset($config['interfaces'][$filterent['gateway']]['descr'])) echo htmlspecialchars($config['interfaces'][$filterent['gateway']]['descr']); else echo htmlspecialchars(pprint_port($filterent['gateway'])); ?><?=$textse;?>
|
572
|
</td>
|
573
|
<td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';"><?=$textss;?>
|
574
|
<?php
|
575
|
if (isset($filterent['ackqueue']) && isset($filterent['defaultqueue'])) {
|
576
|
$desc = $filterent['ackqueue'] ;
|
577
|
echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['ackqueue']}&action=show\">{$desc}</a>";
|
578
|
$desc = $filterent['defaultqueue'];
|
579
|
echo "/<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&action=show\">{$desc}</a>";
|
580
|
} else if (isset($filterent['defaultqueue'])) {
|
581
|
$desc = $filterent['defaultqueue'];
|
582
|
echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&action=show\">{$desc}</a>"; }
|
583
|
else echo "none";
|
584
|
?><?=$textse;?>
|
585
|
</td>
|
586
|
<td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';"><font color="black">
|
587
|
<?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;?>
|
588
|
</td>
|
589
|
<td class="listbg" onClick="fr_toggle(<?=$nrules;?>)" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';" class="descr">
|
590
|
<?=$textss;?><?=htmlspecialchars($filterent['descr']);?> <?=$textse;?>
|
591
|
</td>
|
592
|
<td valign="middle" nowrap class="list">
|
593
|
<table border="0" cellspacing="0" cellpadding="1">
|
594
|
<tr>
|
595
|
<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>
|
596
|
<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>
|
597
|
</tr>
|
598
|
<tr>
|
599
|
<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>
|
600
|
<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>
|
601
|
</tr>
|
602
|
</table>
|
603
|
</td>
|
604
|
</tr>
|
605
|
<?php $nrules++; endfor; ?>
|
606
|
<?php if ($nrules == 0): ?>
|
607
|
<td class="listt"></td>
|
608
|
<td class="listt"></td>
|
609
|
<td class="listlr" colspan="10" align="center" valign="middle">
|
610
|
<span class="gray">
|
611
|
No rules are currently defined for this interface.<br>
|
612
|
All incoming connections on this interface will be blocked until you add pass rules.<br><br>
|
613
|
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>
|
614
|
</td>
|
615
|
<?php endif; ?>
|
616
|
<tr id="fr<?=$nrules;?>">
|
617
|
<td class="list"></td>
|
618
|
<td class="list"></td>
|
619
|
<td class="list"> </td>
|
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">
|
630
|
<table border="0" cellspacing="0" cellpadding="1">
|
631
|
<tr>
|
632
|
<td>
|
633
|
<?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>
|
634
|
<td></td>
|
635
|
</tr>
|
636
|
<tr>
|
637
|
<td>
|
638
|
<?php if ($nrules == 0): ?>
|
639
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="delete selected rules" border="0"><?php else: ?>
|
640
|
<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; ?>
|
641
|
</td>
|
642
|
<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>
|
643
|
</tr>
|
644
|
</table>
|
645
|
</td>
|
646
|
</tr>
|
647
|
</table>
|
648
|
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
|
649
|
<tr>
|
650
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif" width="11" height="11"></td>
|
651
|
<td>pass</td>
|
652
|
<td width="14"></td>
|
653
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11"></td>
|
654
|
<td>block</td>
|
655
|
<td width="14"></td>
|
656
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_reject.gif" width="11" height="11"></td>
|
657
|
<td>reject</td>
|
658
|
<td width="14"></td>
|
659
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_log.gif" width="11" height="11"></td>
|
660
|
<td>log</td>
|
661
|
</tr>
|
662
|
<tr>
|
663
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass_d.gif" width="11" height="11"></td>
|
664
|
<td nowrap>pass (disabled)</td>
|
665
|
<td> </td>
|
666
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block_d.gif" width="11" height="11"></td>
|
667
|
<td nowrap>block (disabled)</td>
|
668
|
<td> </td>
|
669
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_reject_d.gif" width="11" height="11"></td>
|
670
|
<td nowrap>reject (disabled)</td>
|
671
|
<td> </td>
|
672
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_log_d.gif" width="11" height="11"></td>
|
673
|
<td nowrap>log (disabled)</td>
|
674
|
</tr>
|
675
|
<tr>
|
676
|
<td colspan="10">
|
677
|
<p>
|
678
|
<strong><span class="red">Hint:<br>
|
679
|
</span></strong>Rules are evaluated on a first-match basis (i.e.
|
680
|
the action of the first rule to match a packet will be executed).
|
681
|
This means that if you use block rules, you'll have to pay attention
|
682
|
to the rule order. Everything that isn't explicitly passed is blocked
|
683
|
by default.</p>
|
684
|
</td>
|
685
|
</tr>
|
686
|
</table>
|
687
|
</div>
|
688
|
</td>
|
689
|
</tr>
|
690
|
</table>
|
691
|
<input type="hidden" name="if" value="<?=$if;?>">
|
692
|
</form>
|
693
|
<?php include("fend.inc"); ?>
|
694
|
</body>
|
695
|
</html>
|