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
|
$statusurl = "status_filter_reload.php";
|
46
|
$logurl = "diag_logs_filter.php";
|
47
|
|
48
|
require("guiconfig.inc");
|
49
|
require_once("functions.inc");
|
50
|
require_once("filter.inc");
|
51
|
require_once("shaper.inc");
|
52
|
|
53
|
function check_for_advaned_options(&$item) {
|
54
|
$item_set = "";
|
55
|
if($item['max'])
|
56
|
$item_set .= "max {$item['max']} ";
|
57
|
if($item['max-src-nodes'])
|
58
|
$item_set .= "max-src-nodes {$item['max-src-nodes']} ";
|
59
|
if($item['max-src-conn'])
|
60
|
$item_set .= "max-src-conn {$item['max-src-conn']} ";
|
61
|
if($item['max-src-states'])
|
62
|
$item_set .= "max-src-states {$item['max-src-states']} ";
|
63
|
if($item['statetype'] != "keep state" && $item['statetype'] != "")
|
64
|
$item_set .= "statetype {$item['statetype']} {$item['statetype']}";
|
65
|
if($item['statetimeout'])
|
66
|
$item_set .= "statetimeout {$item['statetimeout']}";
|
67
|
if($item['nosync'])
|
68
|
$item_set .= "nosync ";
|
69
|
if($item['max-src-conn-rate'])
|
70
|
$item_set .= "max-src-conn-rate {$item['max-src-conn-rate']} ";
|
71
|
if($item['max-src-conn-rates'])
|
72
|
$item_set .= "max-src-conn-rates {$item['max-src-conn-rates']} ";
|
73
|
return $item_set;
|
74
|
}
|
75
|
|
76
|
function delete_nat_association($id) {
|
77
|
global $config;
|
78
|
|
79
|
if (!$id || !is_array($config['nat']['rule']))
|
80
|
return;
|
81
|
|
82
|
$a_nat = &$config['nat']['rule'];
|
83
|
|
84
|
foreach ($a_nat as &$natent)
|
85
|
if ($natent['associated-rule-id'] == $id)
|
86
|
$natent['associated-rule-id'] = '';
|
87
|
}
|
88
|
|
89
|
if (!is_array($config['filter']['rule'])) {
|
90
|
$config['filter']['rule'] = array();
|
91
|
}
|
92
|
filter_rules_sort();
|
93
|
$a_filter = &$config['filter']['rule'];
|
94
|
|
95
|
$if = $_GET['if'];
|
96
|
if ($_POST['if'])
|
97
|
$if = $_POST['if'];
|
98
|
|
99
|
$ifdescs = get_configured_interface_with_descr();
|
100
|
|
101
|
// Drag and drop reordering
|
102
|
if($_REQUEST['dragdroporder']) {
|
103
|
// First create a new ruleset array and tmp arrays
|
104
|
$a_filter_unorder = array();
|
105
|
$a_filter_order = array();
|
106
|
$a_filter_order_tmp = array();
|
107
|
// Pointer to id of item being reordered
|
108
|
$found = 0;
|
109
|
$drag_order = $_REQUEST['dragtable'];
|
110
|
// Next traverse through rules building a new order for interface
|
111
|
for ($i = 0; isset($a_filter[$i]); $i++) {
|
112
|
if($a_filter[$i]['interface'] <> $_REQUEST['if'])
|
113
|
$a_filter_unorder[] = $a_filter[$i];
|
114
|
else
|
115
|
$a_filter_order_tmp[] = $a_filter[$i];
|
116
|
}
|
117
|
// Reorder rules with the posted order
|
118
|
for ($i = 0; $i<count($drag_order); $i++)
|
119
|
$a_filter_order[] = $a_filter_order_tmp[$drag_order[$i]];
|
120
|
unset($config['filter']['rule']);
|
121
|
// Overwrite filter rules with newly created items
|
122
|
$config['filter']['rule'] = $a_filter_order;
|
123
|
foreach($a_filter_unorder as $aa)
|
124
|
$config['filter']['rule'][] = $aa;
|
125
|
// Write configuration
|
126
|
$config = write_config("Drag and drop firewall rules ordering update.");
|
127
|
// Redirect back to page
|
128
|
Header("Location: firewall_rules.php?if=" . $_REQUEST['if'] . "&savemsg=" . urlencode("The filter rules order has been updated."));
|
129
|
exit;
|
130
|
}
|
131
|
|
132
|
/* add group interfaces */
|
133
|
if (is_array($config['ifgroups']['ifgroupentry']))
|
134
|
foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
|
135
|
if (have_ruleint_access($ifgen['ifname']))
|
136
|
$iflist[$ifgen['ifname']] = $ifgen['ifname'];
|
137
|
|
138
|
foreach ($ifdescs as $ifent => $ifdesc)
|
139
|
if(have_ruleint_access($ifent))
|
140
|
$iflist[$ifent] = $ifdesc;
|
141
|
|
142
|
if ($config['l2tp']['mode'] == "server")
|
143
|
if(have_ruleint_access("l2tp"))
|
144
|
$iflist['l2tp'] = "L2TP VPN";
|
145
|
|
146
|
if ($config['pptpd']['mode'] == "server")
|
147
|
if(have_ruleint_access("pptp"))
|
148
|
$iflist['pptp'] = "PPTP VPN";
|
149
|
|
150
|
if ($config['pppoe']['mode'] == "server")
|
151
|
if(have_ruleint_access("pppoe"))
|
152
|
$iflist['pppoe'] = "PPPoE VPN";
|
153
|
|
154
|
/* add ipsec interfaces */
|
155
|
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
|
156
|
if(have_ruleint_access("enc0"))
|
157
|
$iflist["enc0"] = "IPsec";
|
158
|
|
159
|
/* add openvpn/tun interfaces */
|
160
|
if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
|
161
|
$iflist["openvpn"] = "OpenVPN";
|
162
|
|
163
|
if (!$if || !isset($iflist[$if])) {
|
164
|
if ("any" == $if)
|
165
|
$if = "FloatingRules";
|
166
|
else if ("FloatingRules" != $if)
|
167
|
$if = "wan";
|
168
|
}
|
169
|
|
170
|
if ($_POST) {
|
171
|
|
172
|
$pconfig = $_POST;
|
173
|
|
174
|
if ($_POST['apply']) {
|
175
|
$retval = 0;
|
176
|
$retval = filter_configure();
|
177
|
|
178
|
clear_subsystem_dirty('filter');
|
179
|
|
180
|
$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.";
|
181
|
}
|
182
|
}
|
183
|
|
184
|
if ($_GET['act'] == "del") {
|
185
|
if ($a_filter[$_GET['id']]) {
|
186
|
if (!empty($a_filter[$_GET['id']]['associated-rule-id'])) {
|
187
|
delete_nat_association($a_filter[$_GET['id']]['associated-rule-id']);
|
188
|
}
|
189
|
unset($a_filter[$_GET['id']]);
|
190
|
write_config();
|
191
|
mark_subsystem_dirty('filter');
|
192
|
header("Location: firewall_rules.php?if={$if}");
|
193
|
exit;
|
194
|
}
|
195
|
}
|
196
|
|
197
|
// Handle save msg if defined
|
198
|
if($_REQUEST['savemsg'])
|
199
|
$savemsg = htmlentities($_REQUEST['savemsg']);
|
200
|
|
201
|
if (isset($_POST['del_x'])) {
|
202
|
/* delete selected rules */
|
203
|
if (is_array($_POST['rule']) && count($_POST['rule'])) {
|
204
|
foreach ($_POST['rule'] as $rulei) {
|
205
|
delete_nat_association($a_filter[$rulei]['associated-rule-id']);
|
206
|
unset($a_filter[$rulei]);
|
207
|
}
|
208
|
write_config();
|
209
|
mark_subsystem_dirty('filter');
|
210
|
header("Location: firewall_rules.php?if={$if}");
|
211
|
exit;
|
212
|
}
|
213
|
} else if ($_GET['act'] == "toggle") {
|
214
|
if ($a_filter[$_GET['id']]) {
|
215
|
if(isset($a_filter[$_GET['id']]['disabled']))
|
216
|
unset($a_filter[$_GET['id']]['disabled']);
|
217
|
else
|
218
|
$a_filter[$_GET['id']]['disabled'] = true;
|
219
|
write_config();
|
220
|
mark_subsystem_dirty('filter');
|
221
|
header("Location: firewall_rules.php?if={$if}");
|
222
|
exit;
|
223
|
}
|
224
|
} else {
|
225
|
/* yuck - IE won't send value attributes for image buttons, while Mozilla does -
|
226
|
so we use .x/.y to fine move button clicks instead... */
|
227
|
unset($movebtn);
|
228
|
foreach ($_POST as $pn => $pd) {
|
229
|
if (preg_match("/move_(\d+)_x/", $pn, $matches)) {
|
230
|
$movebtn = $matches[1];
|
231
|
break;
|
232
|
}
|
233
|
}
|
234
|
/* move selected rules before this rule */
|
235
|
if (isset($movebtn) && is_array($_POST['rule']) && count($_POST['rule'])) {
|
236
|
$a_filter_new = array();
|
237
|
|
238
|
/* copy all rules < $movebtn and not selected */
|
239
|
for ($i = 0; $i < $movebtn; $i++) {
|
240
|
if (!in_array($i, $_POST['rule']))
|
241
|
$a_filter_new[] = $a_filter[$i];
|
242
|
}
|
243
|
|
244
|
/* copy all selected rules */
|
245
|
for ($i = 0; $i < count($a_filter); $i++) {
|
246
|
if ($i == $movebtn)
|
247
|
continue;
|
248
|
if (in_array($i, $_POST['rule']))
|
249
|
$a_filter_new[] = $a_filter[$i];
|
250
|
}
|
251
|
|
252
|
/* copy $movebtn rule */
|
253
|
if ($movebtn < count($a_filter))
|
254
|
$a_filter_new[] = $a_filter[$movebtn];
|
255
|
|
256
|
/* copy all rules > $movebtn and not selected */
|
257
|
for ($i = $movebtn+1; $i < count($a_filter); $i++) {
|
258
|
if (!in_array($i, $_POST['rule']))
|
259
|
$a_filter_new[] = $a_filter[$i];
|
260
|
}
|
261
|
|
262
|
$a_filter = $a_filter_new;
|
263
|
write_config();
|
264
|
mark_subsystem_dirty('filter');
|
265
|
header("Location: firewall_rules.php?if={$if}");
|
266
|
exit;
|
267
|
}
|
268
|
}
|
269
|
$closehead = false;
|
270
|
|
271
|
include("head.inc");
|
272
|
|
273
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
|
274
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
|
275
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
|
276
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
|
277
|
?>
|
278
|
</head>
|
279
|
|
280
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
281
|
<?php include("fbegin.inc"); ?>
|
282
|
<form action="firewall_rules.php" method="post">
|
283
|
|
284
|
<script type="text/javascript" language="javascript" src="/javascript/row_toggle.js">
|
285
|
</script>
|
286
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
287
|
<?php if (is_subsystem_dirty('filter')): ?><p>
|
288
|
<?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>
|
289
|
<?php endif; ?>
|
290
|
<div id="loading">
|
291
|
<img src="/themes/<?=$g['theme']?>/images/misc/loader.gif"> Loading, please wait...
|
292
|
<p/>
|
293
|
</div>
|
294
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
295
|
<tr><td class="tabnavtbl">
|
296
|
<?php
|
297
|
/* active tabs */
|
298
|
$tab_array = array();
|
299
|
if ("FloatingRules" == $if)
|
300
|
$active = true;
|
301
|
else
|
302
|
$active = false;
|
303
|
$tab_array[] = array("Floating", $active, "firewall_rules.php?if=FloatingRules");
|
304
|
$tabscounter = 0; $i = 0; foreach ($iflist as $ifent => $ifname) {
|
305
|
if ($ifent == $if)
|
306
|
$active = true;
|
307
|
else
|
308
|
$active = false;
|
309
|
$tab_array[] = array($ifname, $active, "firewall_rules.php?if={$ifent}");
|
310
|
}
|
311
|
display_top_tabs($tab_array);
|
312
|
?>
|
313
|
</td></tr>
|
314
|
<tr>
|
315
|
<td>
|
316
|
<div id="mainarea">
|
317
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
318
|
<tr id="frheader">
|
319
|
<td width="3%" class="list"> </td>
|
320
|
<td width="5%" class="list"> </td>
|
321
|
<td width="3%" class="listhdrr">ID</td>
|
322
|
<td width="6%" class="listhdrr">Proto</td>
|
323
|
<td width="12%" class="listhdrr">Source</td>
|
324
|
<td width="6%" class="listhdrr">Port</td>
|
325
|
<td width="12%" class="listhdrr">Destination</td>
|
326
|
<td width="6%" class="listhdrr">Port</td>
|
327
|
<td width="5%" class="listhdrr">Gateway</td>
|
328
|
<td width="8%" class="listhdrr">Queue</td>
|
329
|
<td width="5%" class="listhdrr">Schedule</td>
|
330
|
<td width="19%" class="listhdr">Description</td>
|
331
|
<td width="10%" class="list">
|
332
|
<table border="0" cellspacing="0" cellpadding="1">
|
333
|
<tr>
|
334
|
<?php
|
335
|
$nrules = 0;
|
336
|
for ($i = 0; isset($a_filter[$i]); $i++) {
|
337
|
$filterent = $a_filter[$i];
|
338
|
if ($filterent['interface'] != $if && !isset($filterent['floating']))
|
339
|
continue;
|
340
|
if (isset($filterent['floating']) && "FloatingRules" != $if)
|
341
|
continue;
|
342
|
$nrules++;
|
343
|
}
|
344
|
?>
|
345
|
<td>
|
346
|
<?php if ($nrules == 0): ?>
|
347
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="delete selected rules" border="0"><?php else: ?>
|
348
|
<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; ?>
|
349
|
</td>
|
350
|
<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>
|
351
|
</tr>
|
352
|
</table>
|
353
|
</td>
|
354
|
</tr>
|
355
|
<?php if (isset($config['interfaces'][$if]['blockpriv'])): ?>
|
356
|
<tr valign="top" id="frrfc1918">
|
357
|
<td class="list"> </td>
|
358
|
<td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0"></td>
|
359
|
<td class="listlr" style="background-color: #e0e0e0"></td>
|
360
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
361
|
<td class="listr" style="background-color: #e0e0e0">RFC 1918 networks</td>
|
362
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
363
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
364
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
365
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
366
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
367
|
<td class="listr" style="background-color: #e0e0e0"></td>
|
368
|
<td class="listbg">Block private networks</td>
|
369
|
<td valign="middle" nowrap class="list">
|
370
|
<table border="0" cellspacing="0" cellpadding="1">
|
371
|
<tr>
|
372
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="move selected rules before this rule"></td>
|
373
|
<td><a href="interfaces.php?if=<?=$if?>#rfc1918"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit rule" width="17" height="17" border="0"></a></td>
|
374
|
</tr>
|
375
|
<tr>
|
376
|
<td align="center" valign="middle"></td>
|
377
|
<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>
|
378
|
</tr>
|
379
|
</table>
|
380
|
</td>
|
381
|
</tr>
|
382
|
<?php endif; ?>
|
383
|
<?php if (isset($config['interfaces'][$if]['blockbogons'])): ?>
|
384
|
<tr valign="top" id="frrfc1918">
|
385
|
<td class="list"> </td>
|
386
|
<td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0"></td>
|
387
|
<td class="listlr" style="background-color: #e0e0e0"></td>
|
388
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
389
|
<td class="listr" style="background-color: #e0e0e0">Reserved/not assigned by IANA</td>
|
390
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
391
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
392
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
393
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
394
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
395
|
<td class="listr" style="background-color: #e0e0e0">*</td>
|
396
|
<td class="listbg">Block bogon networks</td>
|
397
|
<td valign="middle" nowrap class="list">
|
398
|
<table border="0" cellspacing="0" cellpadding="1">
|
399
|
<tr>
|
400
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="move selected rules before this rule"></td>
|
401
|
<td><a href="interfaces.php?if=<?=$if?>#rfc1918"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit rule" width="17" height="17" border="0"></a></td>
|
402
|
</tr>
|
403
|
<tr>
|
404
|
<td align="center" valign="middle"></td>
|
405
|
<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>
|
406
|
</tr>
|
407
|
</table>
|
408
|
</td>
|
409
|
</tr>
|
410
|
<?php endif; ?>
|
411
|
<tbody id="dragtable" width="100%">
|
412
|
<?php $nrules = 0; for ($i = 0; isset($a_filter[$i]); $i++):
|
413
|
$filterent = $a_filter[$i];
|
414
|
if ($filterent['interface'] != $if && !isset($filterent['floating']))
|
415
|
continue;
|
416
|
if (isset($filterent['floating']) && "FloatingRules" != $if)
|
417
|
continue;
|
418
|
$isadvset = check_for_advaned_options($filterent);
|
419
|
if($isadvset)
|
420
|
$advanced_set = "<img src=\"./themes/{$g['theme']}/images/icons/icon_advanced.gif\" title=\"advanced settings set: $isadvset\" border=\"0\">";
|
421
|
else
|
422
|
$advanced_set = ""
|
423
|
?>
|
424
|
<tr valign="top" id="fr<?=$nrules;?>">
|
425
|
<td class="listt">
|
426
|
<input type="checkbox" id="frc<?=$nrules;?>" name="rule[]" value="<?=$i;?>" onClick="fr_bgcolor('<?=$nrules;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;">
|
427
|
<?php echo $advanced_set; ?>
|
428
|
</td>
|
429
|
<td class="listt" align="center">
|
430
|
<?php if ($filterent['type'] == "block")
|
431
|
$iconfn = "block";
|
432
|
else if ($filterent['type'] == "reject") {
|
433
|
$iconfn = "reject";
|
434
|
} else
|
435
|
$iconfn = "pass";
|
436
|
if (isset($filterent['disabled'])) {
|
437
|
$textss = "<span class=\"gray\">";
|
438
|
$textse = "</span>";
|
439
|
$iconfn .= "_d";
|
440
|
} else {
|
441
|
$textss = $textse = "";
|
442
|
}
|
443
|
?>
|
444
|
<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>
|
445
|
<?php if (isset($filterent['log'])):
|
446
|
$iconfnlog = "log_s";
|
447
|
if (isset($filterent['disabled']))
|
448
|
$iconfnlog .= "_d";
|
449
|
?>
|
450
|
<br><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfnlog;?>.gif" width="11" height="15" border="0">
|
451
|
<?php endif; ?>
|
452
|
</td>
|
453
|
<?php
|
454
|
|
455
|
//build Alias popup box
|
456
|
$span_end = "";
|
457
|
$alias_src_span_begin = "";
|
458
|
$alias_src_port_span_begin = "";
|
459
|
$alias_dst_span_begin = "";
|
460
|
$alias_dst_port_span_begin = "";
|
461
|
|
462
|
$alias_popup = rule_popup($filterent['source']['address'],pprint_port($filterent['source']['port']),$filterent['destination']['address'],pprint_port($filterent['destination']['port']));
|
463
|
$span_end = "</U></span>";
|
464
|
|
465
|
$alias_src_span_begin = $alias_popup["src"];
|
466
|
|
467
|
$alias_src_port_span_begin = $alias_popup["srcport"];
|
468
|
|
469
|
$alias_dst_span_begin = $alias_popup["dst"];
|
470
|
|
471
|
$alias_dst_port_span_begin = $alias_popup["dstport"];
|
472
|
|
473
|
//build Schedule popup box
|
474
|
$a_schedules = &$config['schedules']['schedule'];
|
475
|
$schedule_span_begin = "";
|
476
|
$schedule_span_end = "";
|
477
|
$sched_caption_escaped = "";
|
478
|
$sched_content = "";
|
479
|
$schedstatus = false;
|
480
|
$dayArray = array ('Mon','Tues','Wed','Thur','Fri','Sat','Sun');
|
481
|
$monthArray = array ('January','February','March','April','May','June','July','August','September','October','November','December');
|
482
|
if($config['schedules']['schedule'] <> "" and is_array($config['schedules']['schedule'])){
|
483
|
foreach ($a_schedules as $schedule)
|
484
|
{
|
485
|
if ($schedule['name'] == $filterent['sched'] ){
|
486
|
$schedstatus = filter_get_time_based_rule_status($schedule);
|
487
|
|
488
|
foreach($schedule['timerange'] as $timerange) {
|
489
|
$tempFriendlyTime = "";
|
490
|
$tempID = "";
|
491
|
$firstprint = false;
|
492
|
if ($timerange){
|
493
|
$dayFriendly = "";
|
494
|
$tempFriendlyTime = "";
|
495
|
|
496
|
//get hours
|
497
|
$temptimerange = $timerange['hour'];
|
498
|
$temptimeseparator = strrpos($temptimerange, "-");
|
499
|
|
500
|
$starttime = substr ($temptimerange, 0, $temptimeseparator);
|
501
|
$stoptime = substr ($temptimerange, $temptimeseparator+1);
|
502
|
|
503
|
if ($timerange['month']){
|
504
|
$tempmontharray = explode(",", $timerange['month']);
|
505
|
$tempdayarray = explode(",",$timerange['day']);
|
506
|
$arraycounter = 0;
|
507
|
$firstDayFound = false;
|
508
|
$firstPrint = false;
|
509
|
foreach ($tempmontharray as $monthtmp){
|
510
|
$month = $tempmontharray[$arraycounter];
|
511
|
$day = $tempdayarray[$arraycounter];
|
512
|
|
513
|
if (!$firstDayFound)
|
514
|
{
|
515
|
$firstDay = $day;
|
516
|
$firstmonth = $month;
|
517
|
$firstDayFound = true;
|
518
|
}
|
519
|
|
520
|
$currentDay = $day;
|
521
|
$nextDay = $tempdayarray[$arraycounter+1];
|
522
|
$currentDay++;
|
523
|
if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])){
|
524
|
if ($firstPrint)
|
525
|
$dayFriendly .= ", ";
|
526
|
$currentDay--;
|
527
|
if ($currentDay != $firstDay)
|
528
|
$dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ;
|
529
|
else
|
530
|
$dayFriendly .= $monthArray[$month-1] . " " . $day;
|
531
|
$firstDayFound = false;
|
532
|
$firstPrint = true;
|
533
|
}
|
534
|
$arraycounter++;
|
535
|
}
|
536
|
}
|
537
|
else
|
538
|
{
|
539
|
$tempdayFriendly = $timerange['position'];
|
540
|
$firstDayFound = false;
|
541
|
$tempFriendlyDayArray = explode(",", $tempdayFriendly);
|
542
|
$currentDay = "";
|
543
|
$firstDay = "";
|
544
|
$nextDay = "";
|
545
|
$counter = 0;
|
546
|
foreach ($tempFriendlyDayArray as $day){
|
547
|
if ($day != ""){
|
548
|
if (!$firstDayFound)
|
549
|
{
|
550
|
$firstDay = $tempFriendlyDayArray[$counter];
|
551
|
$firstDayFound = true;
|
552
|
}
|
553
|
$currentDay =$tempFriendlyDayArray[$counter];
|
554
|
//get next day
|
555
|
$nextDay = $tempFriendlyDayArray[$counter+1];
|
556
|
$currentDay++;
|
557
|
if ($currentDay != $nextDay){
|
558
|
if ($firstprint)
|
559
|
$dayFriendly .= ", ";
|
560
|
$currentDay--;
|
561
|
if ($currentDay != $firstDay)
|
562
|
$dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
|
563
|
else
|
564
|
$dayFriendly .= $dayArray[$firstDay-1];
|
565
|
$firstDayFound = false;
|
566
|
$firstprint = true;
|
567
|
}
|
568
|
$counter++;
|
569
|
}
|
570
|
}
|
571
|
}
|
572
|
$timeFriendly = $starttime . " - " . $stoptime;
|
573
|
$description = $timerange['rangedescr'];
|
574
|
$sched_content .= $dayFriendly . "; " . $timeFriendly . "<br>";
|
575
|
}
|
576
|
}
|
577
|
$sched_caption_escaped = str_replace("'", "\'", $schedule['descr']);
|
578
|
$schedule_span_begin = "<span style=\"cursor: help;\" onmouseover=\"domTT_activate(this, event, 'content', '<h1>{$sched_caption_escaped}</h1><p>{$sched_content}</p>', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\" onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\"><U>";
|
579
|
$schedule_span_end = "</U></span>";
|
580
|
}
|
581
|
}
|
582
|
}
|
583
|
$printicon = false;
|
584
|
$alttext = "";
|
585
|
$image = "";
|
586
|
if (!isset($filterent['disabled'])){
|
587
|
if ($schedstatus)
|
588
|
{
|
589
|
if ($iconfn == "block" || $iconfn == "reject")
|
590
|
{
|
591
|
$image = "icon_block";
|
592
|
$alttext = "Traffic matching this rule is currently being denied";
|
593
|
}
|
594
|
else
|
595
|
{
|
596
|
$image = "icon_pass";
|
597
|
$alttext = "Traffic matching this rule is currently being allowed";
|
598
|
}
|
599
|
$printicon = true;
|
600
|
}
|
601
|
else if ($filterent['sched'])
|
602
|
{
|
603
|
if ($iconfn == "block" || $iconfn == "reject")
|
604
|
$image = "icon_block_d";
|
605
|
else
|
606
|
$image = "icon_block";
|
607
|
$alttext = "This rule is not currently active because its period has expired";
|
608
|
$printicon = true;
|
609
|
}
|
610
|
}
|
611
|
?>
|
612
|
<td class="listlr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
|
613
|
<?=$textss;?><?php if (isset($filterent['id'])) echo $filterent['id']; else echo ""; ?><?=$textse;?>
|
614
|
</td>
|
615
|
<td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
|
616
|
<?=$textss;?><?php if (isset($filterent['protocol'])) echo strtoupper($filterent['protocol']); else echo "*"; ?><?=$textse;?>
|
617
|
</td>
|
618
|
<td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
|
619
|
<?=$textss;?><?php echo $alias_src_span_begin;?><?php echo htmlspecialchars(pprint_address($filterent['source']));?><?php echo $alias_src_span_end;?><?=$textse;?>
|
620
|
</td>
|
621
|
<td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
|
622
|
<?=$textss;?><?php echo $alias_src_port_span_begin;?><?php echo htmlspecialchars(pprint_port($filterent['source']['port'])); ?><?php echo $alias_src_port_span_end;?><?=$textse;?>
|
623
|
</td>
|
624
|
<td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
|
625
|
<?=$textss;?><?php echo $alias_dst_span_begin;?><?php echo htmlspecialchars(pprint_address($filterent['destination'])); ?><?php echo $alias_dst_span_end;?><?=$textse;?>
|
626
|
</td>
|
627
|
<td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
|
628
|
<?=$textss;?><?php echo $alias_dst_port_span_begin;?><?php echo htmlspecialchars(pprint_port($filterent['destination']['port'])); ?><?php echo $alias_dst_port_span_end;?><?=$textse;?>
|
629
|
</td>
|
630
|
<td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
|
631
|
<?=$textss;?><?php if (isset($config['interfaces'][$filterent['gateway']]['descr'])) echo htmlspecialchars($config['interfaces'][$filterent['gateway']]['descr']); else echo htmlspecialchars(pprint_port($filterent['gateway'])); ?><?=$textse;?>
|
632
|
</td>
|
633
|
<td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';"><?=$textss;?>
|
634
|
<?php
|
635
|
if (isset($filterent['ackqueue']) && isset($filterent['defaultqueue'])) {
|
636
|
$desc = $filterent['ackqueue'] ;
|
637
|
echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['ackqueue']}&action=show\">{$desc}</a>";
|
638
|
$desc = $filterent['defaultqueue'];
|
639
|
echo "/<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&action=show\">{$desc}</a>";
|
640
|
} else if (isset($filterent['defaultqueue'])) {
|
641
|
$desc = $filterent['defaultqueue'];
|
642
|
echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&action=show\">{$desc}</a>"; }
|
643
|
else echo "none";
|
644
|
?><?=$textse;?>
|
645
|
</td>
|
646
|
<td class="listr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';"><font color="black">
|
647
|
<?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;?>
|
648
|
</td>
|
649
|
<td class="listbg" onClick="fr_toggle(<?=$nrules;?>)" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';" class="descr">
|
650
|
<?=$textss;?><?=htmlspecialchars($filterent['descr']);?> <?=$textse;?>
|
651
|
</td>
|
652
|
<td valign="middle" nowrap class="list">
|
653
|
<table border="0" cellspacing="0" cellpadding="1">
|
654
|
<tr>
|
655
|
<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>
|
656
|
<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>
|
657
|
</tr>
|
658
|
<tr>
|
659
|
<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>
|
660
|
<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>
|
661
|
</tr>
|
662
|
</table>
|
663
|
</td>
|
664
|
</tr>
|
665
|
<?php $nrules++; endfor; ?>
|
666
|
</tbody>
|
667
|
<?php if ($nrules == 0): ?>
|
668
|
<td class="listt"></td>
|
669
|
<td class="listt"></td>
|
670
|
<td class="listlr" colspan="10" align="center" valign="middle">
|
671
|
<span class="gray">
|
672
|
No rules are currently defined for this interface.<br>
|
673
|
All incoming connections on this interface will be blocked until you add pass rules.<br><br>
|
674
|
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>
|
675
|
</td>
|
676
|
<?php endif; ?>
|
677
|
<tr id="fr<?=$nrules;?>">
|
678
|
<td class="list"></td>
|
679
|
<td class="list"></td>
|
680
|
<td class="list"> </td>
|
681
|
<td class="list"> </td>
|
682
|
<td class="list"> </td>
|
683
|
<td class="list"> </td>
|
684
|
<td class="list"> </td>
|
685
|
<td class="list"> </td>
|
686
|
<td class="list"> </td>
|
687
|
<td class="list"> </td>
|
688
|
<td class="list"> </td>
|
689
|
<td class="list"> </td>
|
690
|
<td class="list">
|
691
|
<table border="0" cellspacing="0" cellpadding="1">
|
692
|
<tr>
|
693
|
<td>
|
694
|
<?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="
|
695
|
(<?=$nrules;?>, false)"><?php endif; ?></td>
|
696
|
<td></td>
|
697
|
</tr>
|
698
|
<tr>
|
699
|
<td>
|
700
|
<?php if ($nrules == 0): ?>
|
701
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="delete selected rules" border="0"><?php else: ?>
|
702
|
<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; ?>
|
703
|
</td>
|
704
|
<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>
|
705
|
</tr>
|
706
|
</table>
|
707
|
</td>
|
708
|
</tr>
|
709
|
</table>
|
710
|
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
|
711
|
<tr>
|
712
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif" width="11" height="11"></td>
|
713
|
<td>pass</td>
|
714
|
<td width="14"></td>
|
715
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11"></td>
|
716
|
<td>block</td>
|
717
|
<td width="14"></td>
|
718
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_reject.gif" width="11" height="11"></td>
|
719
|
<td>reject</td>
|
720
|
<td width="14"></td>
|
721
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_log.gif" width="11" height="11"></td>
|
722
|
<td>log</td>
|
723
|
</tr>
|
724
|
<tr>
|
725
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass_d.gif" width="11" height="11"></td>
|
726
|
<td nowrap>pass (disabled)</td>
|
727
|
<td> </td>
|
728
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block_d.gif" width="11" height="11"></td>
|
729
|
<td nowrap>block (disabled)</td>
|
730
|
<td> </td>
|
731
|
<td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_reject_d.gif" width="11" height="11"></td>
|
732
|
<td nowrap>reject (disabled)</td>
|
733
|
<td> </td>
|
734
|
<td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_log_d.gif" width="11" height="11"></td>
|
735
|
<td nowrap>log (disabled)</td>
|
736
|
</tr>
|
737
|
<tr>
|
738
|
<td colspan="10">
|
739
|
<p>
|
740
|
<strong><span class="red">Hint:<br>
|
741
|
</span></strong>Rules are evaluated on a first-match basis (i.e.
|
742
|
the action of the first rule to match a packet will be executed).
|
743
|
This means that if you use block rules, you'll have to pay attention
|
744
|
to the rule order. Everything that isn't explicitly passed is blocked
|
745
|
by default.</p>
|
746
|
</td>
|
747
|
</tr>
|
748
|
</table>
|
749
|
</div>
|
750
|
</td>
|
751
|
</tr>
|
752
|
</table>
|
753
|
<input type="hidden" name="if" value="<?=$if;?>">
|
754
|
<script type="text/javascript">
|
755
|
var number_of_rules = <?=$nrules?>;
|
756
|
<?php $nrules = 0; for ($i = 0; isset($a_filter[$i]); $i++): ?>
|
757
|
Sortable.create("dragtable", {
|
758
|
tag:"tr",
|
759
|
format:"fr([0-9999999])",
|
760
|
containment:["dragtable"],
|
761
|
onChange:function(affected) {
|
762
|
document.body.style.cursor = 'move';
|
763
|
},
|
764
|
onUpdate:function(container) {
|
765
|
document.body.style.cursor = 'move';
|
766
|
updateOrder(Sortable.serialize('dragtable', 'tr'));
|
767
|
}
|
768
|
});
|
769
|
<?php endfor; ?>
|
770
|
function updateOrder(order) {
|
771
|
if(document.getElementById("redboxtable"))
|
772
|
$('redboxtable').hide();
|
773
|
$('loading').show();
|
774
|
document.body.style.cursor = 'wait';
|
775
|
document.location = 'firewall_rules.php?if=<?=$if?>&dragdroporder=true&' + Sortable.serialize('dragtable', 'tr');
|
776
|
return;
|
777
|
}
|
778
|
$('loading').hide();
|
779
|
</script>
|
780
|
</form>
|
781
|
<?php include("fend.inc"); ?>
|
782
|
</body>
|
783
|
</html>
|