1 |
b2ffe419
|
Scott Ullrich
|
<?php
|
2 |
5b237745
|
Scott Ullrich
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* firewall_rules.php
|
4 |
9da2cf1c
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
38809d47
|
Renato Botelho do Couto
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7 |
|
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8 |
8f585441
|
Luiz Souza
|
* Copyright (c) 2014-2021 Rubicon Communications, LLC (Netgate)
|
9 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
10 |
fd9ebcd5
|
Stephen Beaver
|
*
|
11 |
c5d81585
|
Renato Botelho
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
12 |
|
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
13 |
|
|
* All rights reserved.
|
14 |
fd9ebcd5
|
Stephen Beaver
|
*
|
15 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
16 |
|
|
* you may not use this file except in compliance with the License.
|
17 |
|
|
* You may obtain a copy of the License at
|
18 |
fd9ebcd5
|
Stephen Beaver
|
*
|
19 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
20 |
fd9ebcd5
|
Stephen Beaver
|
*
|
21 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
22 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
23 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
24 |
|
|
* See the License for the specific language governing permissions and
|
25 |
|
|
* limitations under the License.
|
26 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
27 |
5b237745
|
Scott Ullrich
|
|
28 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
29 |
|
|
##|*IDENT=page-firewall-rules
|
30 |
5230f468
|
jim-p
|
##|*NAME=Firewall: Rules
|
31 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Firewall: Rules' page.
|
32 |
|
|
##|*MATCH=firewall_rules.php*
|
33 |
|
|
##|-PRIV
|
34 |
|
|
|
35 |
c81ef6e2
|
Phil Davis
|
require_once("guiconfig.inc");
|
36 |
7a927e67
|
Scott Ullrich
|
require_once("functions.inc");
|
37 |
|
|
require_once("filter.inc");
|
38 |
179ab6b3
|
Luiz Otavio O Souza
|
require_once("ipsec.inc");
|
39 |
7a927e67
|
Scott Ullrich
|
require_once("shaper.inc");
|
40 |
5b237745
|
Scott Ullrich
|
|
41 |
a7893b72
|
Stephen Beaver
|
$XmoveTitle = gettext("Move checked rules above this one. Shift+Click to move checked rules below.");
|
42 |
|
|
$ShXmoveTitle = gettext("Move checked rules below this one. Release shift to move checked rules above.");
|
43 |
d830a7f4
|
Stephen Beaver
|
|
44 |
b32dd0a6
|
jim-p
|
$shortcut_section = "firewall";
|
45 |
7a808e01
|
Carlos Eduardo Ramos
|
|
46 |
1574802c
|
Renato Botelho do Couto
|
function get_pf_rules($rules, $tracker_start, $tracker_end) {
|
47 |
cc2cff0b
|
Luiz Otavio O Souza
|
|
48 |
1574802c
|
Renato Botelho do Couto
|
if ($rules == NULL || !is_array($rules)) {
|
49 |
cc2cff0b
|
Luiz Otavio O Souza
|
return (NULL);
|
50 |
1574802c
|
Renato Botelho do Couto
|
}
|
51 |
cc2cff0b
|
Luiz Otavio O Souza
|
|
52 |
|
|
$arr = array();
|
53 |
227c1181
|
NOYB
|
foreach ($rules as $rule) {
|
54 |
1574802c
|
Renato Botelho do Couto
|
if ($rule['tracker'] >= $tracker_start &&
|
55 |
|
|
$rule['tracker'] <= $tracker_end) {
|
56 |
227c1181
|
NOYB
|
$arr[] = $rule;
|
57 |
|
|
}
|
58 |
cc2cff0b
|
Luiz Otavio O Souza
|
}
|
59 |
|
|
|
60 |
|
|
if (count($arr) == 0)
|
61 |
|
|
return (NULL);
|
62 |
|
|
|
63 |
|
|
return ($arr);
|
64 |
|
|
}
|
65 |
|
|
|
66 |
1574802c
|
Renato Botelho do Couto
|
function print_states($tracker_start, $tracker_end = -1) {
|
67 |
cc2cff0b
|
Luiz Otavio O Souza
|
global $rulescnt;
|
68 |
|
|
|
69 |
1574802c
|
Renato Botelho do Couto
|
if (empty($tracker_start)) {
|
70 |
|
|
return;
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
if ($tracker_end === -1) {
|
74 |
|
|
$tracker_end = $tracker_start;
|
75 |
|
|
} elseif ($tracker_end < $tracker_start) {
|
76 |
|
|
return;
|
77 |
|
|
}
|
78 |
|
|
|
79 |
cc2cff0b
|
Luiz Otavio O Souza
|
$rulesid = "";
|
80 |
|
|
$bytes = 0;
|
81 |
|
|
$states = 0;
|
82 |
|
|
$packets = 0;
|
83 |
|
|
$evaluations = 0;
|
84 |
|
|
$stcreations = 0;
|
85 |
1574802c
|
Renato Botelho do Couto
|
$rules = get_pf_rules($rulescnt, $tracker_start, $tracker_end);
|
86 |
227c1181
|
NOYB
|
if (is_array($rules)) {
|
87 |
|
|
foreach ($rules as $rule) {
|
88 |
|
|
$bytes += $rule['bytes'];
|
89 |
|
|
$states += $rule['states'];
|
90 |
|
|
$packets += $rule['packets'];
|
91 |
|
|
$evaluations += $rule['evaluations'];
|
92 |
|
|
$stcreations += $rule['state creations'];
|
93 |
|
|
if (strlen($rulesid) > 0) {
|
94 |
|
|
$rulesid .= ",";
|
95 |
|
|
}
|
96 |
|
|
$rulesid .= "{$rule['id']}";
|
97 |
|
|
}
|
98 |
cc2cff0b
|
Luiz Otavio O Souza
|
}
|
99 |
227c1181
|
NOYB
|
|
100 |
1574802c
|
Renato Botelho do Couto
|
$trackertext = "Tracking ID: {$tracker_start}";
|
101 |
|
|
if ($tracker_end != $tracker_start) {
|
102 |
|
|
$trackertext .= '-' . $tracker_end;
|
103 |
|
|
}
|
104 |
|
|
$trackertext .= "<br />";
|
105 |
|
|
|
106 |
|
|
printf("<a href=\"diag_dump_states.php?ruleid=%s\" " .
|
107 |
|
|
"data-toggle=\"popover\" data-trigger=\"hover focus\" " .
|
108 |
|
|
"title=\"%s\" ", $rulesid, gettext("States details"));
|
109 |
|
|
printf("data-content=\"{$trackertext}evaluations: %s<br />packets: " .
|
110 |
|
|
"%s<br />bytes: %s<br />states: %s<br />state creations: " .
|
111 |
|
|
"%s\" data-html=\"true\" usepost>",
|
112 |
|
|
format_number($evaluations), format_number($packets),
|
113 |
|
|
format_bytes($bytes), format_number($states),
|
114 |
|
|
format_number($stcreations));
|
115 |
|
|
printf("%s/%s</a><br />", format_number($states), format_bytes($bytes));
|
116 |
cc2cff0b
|
Luiz Otavio O Souza
|
}
|
117 |
|
|
|
118 |
00c82782
|
Renato Botelho
|
function delete_nat_association($id) {
|
119 |
|
|
global $config;
|
120 |
|
|
|
121 |
603d3c16
|
Phil Davis
|
if (!$id || !is_array($config['nat']['rule'])) {
|
122 |
673d29c0
|
Renato Botelho
|
return;
|
123 |
603d3c16
|
Phil Davis
|
}
|
124 |
673d29c0
|
Renato Botelho
|
|
125 |
00c82782
|
Renato Botelho
|
$a_nat = &$config['nat']['rule'];
|
126 |
|
|
|
127 |
603d3c16
|
Phil Davis
|
foreach ($a_nat as &$natent) {
|
128 |
|
|
if ($natent['associated-rule-id'] == $id) {
|
129 |
00c82782
|
Renato Botelho
|
$natent['associated-rule-id'] = '';
|
130 |
603d3c16
|
Phil Davis
|
}
|
131 |
|
|
}
|
132 |
673d29c0
|
Renato Botelho
|
}
|
133 |
|
|
|
134 |
c6c398c6
|
jim-p
|
init_config_arr(array('filter', 'rule'));
|
135 |
5b237745
|
Scott Ullrich
|
filter_rules_sort();
|
136 |
|
|
$a_filter = &$config['filter']['rule'];
|
137 |
|
|
|
138 |
84147b7b
|
Steve Beaver
|
if ($_REQUEST['if']) {
|
139 |
|
|
$if = $_REQUEST['if'];
|
140 |
603d3c16
|
Phil Davis
|
}
|
141 |
b2ffe419
|
Scott Ullrich
|
|
142 |
cbe3ea96
|
Ermal Luçi
|
$ifdescs = get_configured_interface_with_descr();
|
143 |
07bd3f83
|
Scott Ullrich
|
|
144 |
c64c8773
|
jim-p
|
$iflist = filter_get_interface_list();
|
145 |
bfb60ac8
|
Ermal Luçi
|
|
146 |
92125c97
|
Ermal Luçi
|
if (!$if || !isset($iflist[$if])) {
|
147 |
9a2d3fe1
|
stilez
|
if ($if != "any" && $if != "FloatingRules" && isset($iflist['wan'])) {
|
148 |
|
|
$if = "wan";
|
149 |
|
|
} else {
|
150 |
56dda8e0
|
Renato Botelho
|
$if = "FloatingRules";
|
151 |
0416d9a0
|
Darren Embry
|
}
|
152 |
92125c97
|
Ermal Luçi
|
}
|
153 |
07bd3f83
|
Scott Ullrich
|
|
154 |
e3947e77
|
Steve Beaver
|
if ($_POST['apply']) {
|
155 |
|
|
$retval = 0;
|
156 |
|
|
$retval |= filter_configure();
|
157 |
9a7e416c
|
Scott Ullrich
|
|
158 |
e3947e77
|
Steve Beaver
|
clear_subsystem_dirty('filter');
|
159 |
5b237745
|
Scott Ullrich
|
}
|
160 |
|
|
|
161 |
e3947e77
|
Steve Beaver
|
if ($_POST['act'] == "del") {
|
162 |
|
|
if ($a_filter[$_POST['id']]) {
|
163 |
|
|
if (!empty($a_filter[$_POST['id']]['associated-rule-id'])) {
|
164 |
|
|
delete_nat_association($a_filter[$_POST['id']]['associated-rule-id']);
|
165 |
673d29c0
|
Renato Botelho
|
}
|
166 |
e3947e77
|
Steve Beaver
|
unset($a_filter[$_POST['id']]);
|
167 |
a4eef0c7
|
Stephen Beaver
|
|
168 |
|
|
// Update the separators
|
169 |
c6c398c6
|
jim-p
|
init_config_arr(array('filter', 'separator', strtolower($if)));
|
170 |
e1e1ab07
|
Stephen Beaver
|
$a_separators = &$config['filter']['separator'][strtolower($if)];
|
171 |
e3947e77
|
Steve Beaver
|
$ridx = ifridx($if, $_POST['id']); // get rule index within interface
|
172 |
a4f41878
|
NOYB
|
$mvnrows = -1;
|
173 |
|
|
move_separators($a_separators, $ridx, $mvnrows);
|
174 |
a4eef0c7
|
Stephen Beaver
|
|
175 |
68eaa19f
|
doktornotor
|
if (write_config(gettext("Firewall: Rules - deleted a firewall rule."))) {
|
176 |
bec92ab9
|
jim-p
|
mark_subsystem_dirty('filter');
|
177 |
603d3c16
|
Phil Davis
|
}
|
178 |
6cb366de
|
Stephen Beaver
|
|
179 |
e653b6e1
|
jim-p
|
header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
|
180 |
673d29c0
|
Renato Botelho
|
exit;
|
181 |
|
|
}
|
182 |
d97c50cd
|
Bill Marquette
|
}
|
183 |
|
|
|
184 |
32c58070
|
Scott Ullrich
|
// Handle save msg if defined
|
185 |
603d3c16
|
Phil Davis
|
if ($_REQUEST['savemsg']) {
|
186 |
32c58070
|
Scott Ullrich
|
$savemsg = htmlentities($_REQUEST['savemsg']);
|
187 |
603d3c16
|
Phil Davis
|
}
|
188 |
32c58070
|
Scott Ullrich
|
|
189 |
6cb366de
|
Stephen Beaver
|
if (isset($_POST['del_x'])) {
|
190 |
|
|
if (is_array($_POST['rule']) && count($_POST['rule'])) {
|
191 |
c6c398c6
|
jim-p
|
init_config_arr(array('filter', 'separator', strtolower($if)));
|
192 |
e1e1ab07
|
Stephen Beaver
|
$a_separators = &$config['filter']['separator'][strtolower($if)];
|
193 |
a4eef0c7
|
Stephen Beaver
|
|
194 |
5b9723fa
|
dsmackie
|
$first_idx = 0;
|
195 |
|
|
$num_deleted = 0;
|
196 |
6cb366de
|
Stephen Beaver
|
foreach ($_POST['rule'] as $rulei) {
|
197 |
|
|
delete_nat_association($a_filter[$rulei]['associated-rule-id']);
|
198 |
|
|
unset($a_filter[$rulei]);
|
199 |
a4eef0c7
|
Stephen Beaver
|
|
200 |
9e0c9670
|
dsmackie
|
// Capture first changed filter index for later separator shifting
|
201 |
|
|
if (!$first_idx) $first_idx = ifridx($if, $rulei);
|
202 |
00098bc8
|
Steve Beaver
|
$num_deleted++;
|
203 |
6cb366de
|
Stephen Beaver
|
}
|
204 |
|
|
|
205 |
5b9723fa
|
dsmackie
|
if ($num_deleted) {
|
206 |
|
|
move_separators($a_separators, $first_idx, -$num_deleted);
|
207 |
68eaa19f
|
doktornotor
|
if (write_config(gettext("Firewall: Rules - deleted selected firewall rules."))) {
|
208 |
6cb366de
|
Stephen Beaver
|
mark_subsystem_dirty('filter');
|
209 |
|
|
}
|
210 |
|
|
}
|
211 |
|
|
|
212 |
|
|
header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
|
213 |
|
|
exit;
|
214 |
|
|
}
|
215 |
e3947e77
|
Steve Beaver
|
} else if ($_POST['act'] == "toggle") {
|
216 |
|
|
if ($a_filter[$_POST['id']]) {
|
217 |
|
|
if (isset($a_filter[$_POST['id']]['disabled'])) {
|
218 |
|
|
unset($a_filter[$_POST['id']]['disabled']);
|
219 |
68eaa19f
|
doktornotor
|
$wc_msg = gettext('Firewall: Rules - enabled a firewall rule.');
|
220 |
603d3c16
|
Phil Davis
|
} else {
|
221 |
e3947e77
|
Steve Beaver
|
$a_filter[$_POST['id']]['disabled'] = true;
|
222 |
68eaa19f
|
doktornotor
|
$wc_msg = gettext('Firewall: Rules - disabled a firewall rule.');
|
223 |
603d3c16
|
Phil Davis
|
}
|
224 |
68eaa19f
|
doktornotor
|
if (write_config($wc_msg)) {
|
225 |
bec92ab9
|
jim-p
|
mark_subsystem_dirty('filter');
|
226 |
603d3c16
|
Phil Davis
|
}
|
227 |
6cb366de
|
Stephen Beaver
|
|
228 |
e653b6e1
|
jim-p
|
header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
|
229 |
5b237745
|
Scott Ullrich
|
exit;
|
230 |
|
|
}
|
231 |
67c2baf1
|
Phil Davis
|
} else if ($_POST['order-store']) {
|
232 |
c8207c6c
|
dsmackie
|
$updated = false;
|
233 |
|
|
$dirty = false;
|
234 |
7d8552fc
|
Stephen Beaver
|
|
235 |
ea5665c7
|
Sjon Hortensius
|
/* update rule order, POST[rule] is an array of ordered IDs */
|
236 |
|
|
if (is_array($_POST['rule']) && !empty($_POST['rule'])) {
|
237 |
07bd3f83
|
Scott Ullrich
|
$a_filter_new = array();
|
238 |
b2ffe419
|
Scott Ullrich
|
|
239 |
acd05d2b
|
NOYB
|
// Include the rules of other interfaces listed in config before this (the selected) interface.
|
240 |
|
|
foreach ($a_filter as $filteri_before => $filterent) {
|
241 |
|
|
if (($filterent['interface'] == $if && !isset($filterent['floating'])) || (isset($filterent['floating']) && "FloatingRules" == $if)) {
|
242 |
|
|
break;
|
243 |
|
|
} else {
|
244 |
|
|
$a_filter_new[] = $filterent;
|
245 |
|
|
}
|
246 |
fdb83ce0
|
NOYB
|
}
|
247 |
|
|
|
248 |
acd05d2b
|
NOYB
|
// Include the rules of this (the selected) interface.
|
249 |
|
|
// If a rule is not in POST[rule], it has been deleted by the user
|
250 |
67c2baf1
|
Phil Davis
|
foreach ($_POST['rule'] as $id) {
|
251 |
ea5665c7
|
Sjon Hortensius
|
$a_filter_new[] = $a_filter[$id];
|
252 |
67c2baf1
|
Phil Davis
|
}
|
253 |
b2ffe419
|
Scott Ullrich
|
|
254 |
acd05d2b
|
NOYB
|
// Include the rules of other interfaces listed in config after this (the selected) interface.
|
255 |
|
|
foreach ($a_filter as $filteri_after => $filterent) {
|
256 |
|
|
if ($filteri_before > $filteri_after) {
|
257 |
|
|
continue;
|
258 |
|
|
}
|
259 |
|
|
if (($filterent['interface'] == $if && !isset($filterent['floating'])) || (isset($filterent['floating']) && "FloatingRules" == $if)) {
|
260 |
|
|
continue;
|
261 |
|
|
} else {
|
262 |
|
|
$a_filter_new[] = $filterent;
|
263 |
fdb83ce0
|
NOYB
|
}
|
264 |
|
|
}
|
265 |
|
|
|
266 |
c8207c6c
|
dsmackie
|
if ($a_filter !== $a_filter_new) {
|
267 |
|
|
$a_filter = $a_filter_new;
|
268 |
|
|
$dirty = true;
|
269 |
|
|
}
|
270 |
|
|
}
|
271 |
c64c9278
|
Stephen Beaver
|
|
272 |
c8207c6c
|
dsmackie
|
$a_separators = &$config['filter']['separator'][strtolower($if)];
|
273 |
c64c9278
|
Stephen Beaver
|
|
274 |
c8207c6c
|
dsmackie
|
/* update separator order, POST[separator] is an array of ordered IDs */
|
275 |
|
|
if (is_array($_POST['separator']) && !empty($_POST['separator'])) {
|
276 |
|
|
$new_separator = array();
|
277 |
|
|
$idx = 0;
|
278 |
ef3d2cad
|
Steve Beaver
|
|
279 |
c8207c6c
|
dsmackie
|
foreach ($_POST['separator'] as $separator) {
|
280 |
|
|
$new_separator['sep' . $idx++] = $separator;
|
281 |
|
|
}
|
282 |
ef3d2cad
|
Steve Beaver
|
|
283 |
c8207c6c
|
dsmackie
|
if ($a_separators !== $new_separator) {
|
284 |
|
|
$a_separators = $new_separator;
|
285 |
|
|
$updated = true;
|
286 |
c64c9278
|
Stephen Beaver
|
}
|
287 |
c8207c6c
|
dsmackie
|
} else if (!empty($a_separators)) {
|
288 |
|
|
$a_separators = "";
|
289 |
|
|
$updated = true;
|
290 |
|
|
}
|
291 |
c64c9278
|
Stephen Beaver
|
|
292 |
c8207c6c
|
dsmackie
|
if ($updated || $dirty) {
|
293 |
68eaa19f
|
doktornotor
|
if (write_config(gettext("Firewall: Rules - reordered firewall rules."))) {
|
294 |
c8207c6c
|
dsmackie
|
if ($dirty) {
|
295 |
|
|
mark_subsystem_dirty('filter');
|
296 |
|
|
}
|
297 |
603d3c16
|
Phil Davis
|
}
|
298 |
5b237745
|
Scott Ullrich
|
}
|
299 |
c8207c6c
|
dsmackie
|
|
300 |
|
|
header("Location: firewall_rules.php?if=" . htmlspecialchars($if));
|
301 |
|
|
exit;
|
302 |
5b237745
|
Scott Ullrich
|
}
|
303 |
|
|
|
304 |
df95836a
|
Stephen Beaver
|
$tab_array = array(array(gettext("Floating"), ("FloatingRules" == $if), "firewall_rules.php?if=FloatingRules"));
|
305 |
|
|
|
306 |
67c2baf1
|
Phil Davis
|
foreach ($iflist as $ifent => $ifname) {
|
307 |
df95836a
|
Stephen Beaver
|
$tab_array[] = array($ifname, ($ifent == $if), "firewall_rules.php?if={$ifent}");
|
308 |
67c2baf1
|
Phil Davis
|
}
|
309 |
df95836a
|
Stephen Beaver
|
|
310 |
|
|
foreach ($tab_array as $dtab) {
|
311 |
67c2baf1
|
Phil Davis
|
if ($dtab[1]) {
|
312 |
df95836a
|
Stephen Beaver
|
$bctab = $dtab[0];
|
313 |
|
|
break;
|
314 |
|
|
}
|
315 |
|
|
}
|
316 |
|
|
|
317 |
|
|
$pgtitle = array(gettext("Firewall"), gettext("Rules"), $bctab);
|
318 |
edcd7535
|
Phil Davis
|
$pglinks = array("", "firewall_rules.php", "@self");
|
319 |
df95836a
|
Stephen Beaver
|
$shortcut_section = "firewall";
|
320 |
|
|
|
321 |
9a25487b
|
Scott Ullrich
|
include("head.inc");
|
322 |
3b2c83b8
|
Sjon Hortensius
|
$nrules = 0;
|
323 |
|
|
|
324 |
67c2baf1
|
Phil Davis
|
if ($savemsg) {
|
325 |
42a6bcbd
|
Stephen Beaver
|
print_info_box($savemsg, 'success');
|
326 |
67c2baf1
|
Phil Davis
|
}
|
327 |
42a6bcbd
|
Stephen Beaver
|
|
328 |
815398fb
|
Phil Davis
|
if ($_POST['apply']) {
|
329 |
|
|
print_apply_result_box($retval);
|
330 |
|
|
}
|
331 |
|
|
|
332 |
67c2baf1
|
Phil Davis
|
if (is_subsystem_dirty('filter')) {
|
333 |
317b2852
|
NOYB
|
print_apply_box(gettext("The firewall rule configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
|
334 |
67c2baf1
|
Phil Davis
|
}
|
335 |
3b2c83b8
|
Sjon Hortensius
|
|
336 |
e4e78af3
|
jim-p
|
display_top_tabs($tab_array, false, 'pills');
|
337 |
ea5665c7
|
Sjon Hortensius
|
|
338 |
a2c5280d
|
Stephen Beaver
|
$showantilockout = false;
|
339 |
|
|
$showprivate = false;
|
340 |
|
|
$showblockbogons = false;
|
341 |
|
|
|
342 |
|
|
if (!isset($config['system']['webgui']['noantilockout']) &&
|
343 |
|
|
(((count($config['interfaces']) > 1) && ($if == 'lan')) ||
|
344 |
|
|
((count($config['interfaces']) == 1) && ($if == 'wan')))) {
|
345 |
|
|
$showantilockout = true;
|
346 |
|
|
}
|
347 |
|
|
|
348 |
|
|
if (isset($config['interfaces'][$if]['blockpriv'])) {
|
349 |
|
|
$showprivate = true;
|
350 |
|
|
}
|
351 |
|
|
|
352 |
|
|
if (isset($config['interfaces'][$if]['blockbogons'])) {
|
353 |
|
|
$showblockbogons = true;
|
354 |
|
|
}
|
355 |
|
|
|
356 |
fd4dc22e
|
luckman212
|
if (isset($config['system']['webgui']['roworderdragging'])) {
|
357 |
988b786d
|
luckman212
|
$rules_header_text = gettext("Rules");
|
358 |
fd4dc22e
|
luckman212
|
} else {
|
359 |
988b786d
|
luckman212
|
$rules_header_text = gettext("Rules (Drag to Change Order)");
|
360 |
fd4dc22e
|
luckman212
|
}
|
361 |
|
|
|
362 |
cc2cff0b
|
Luiz Otavio O Souza
|
/* Load the counter data of each pf rule. */
|
363 |
|
|
$rulescnt = pfSense_get_pf_rules();
|
364 |
b13a8425
|
Stephen Beaver
|
|
365 |
c54a42ea
|
Renato Botelho
|
// Update this if you add or remove columns!
|
366 |
10ae204f
|
Stephen Beaver
|
$columns_in_table = 13;
|
367 |
|
|
|
368 |
f9e65650
|
jim-p
|
/* Floating rules tab has one extra column
|
369 |
|
|
* https://redmine.pfsense.org/issues/10667 */
|
370 |
|
|
if ($if == "FloatingRules") {
|
371 |
|
|
$columns_in_table++;
|
372 |
|
|
}
|
373 |
|
|
|
374 |
cc2cff0b
|
Luiz Otavio O Souza
|
?>
|
375 |
dd455f50
|
Steve Beaver
|
<!-- Allow table to scroll when dragging outside of the display window -->
|
376 |
|
|
<style>
|
377 |
|
|
.table-responsive {
|
378 |
|
|
clear: both;
|
379 |
|
|
overflow-x: visible;
|
380 |
|
|
margin-bottom: 0px;
|
381 |
|
|
}
|
382 |
|
|
</style>
|
383 |
|
|
|
384 |
c821a6cd
|
Stephen Beaver
|
<form method="post">
|
385 |
285aa44d
|
Steve Beaver
|
<input name="if" id="if" type="hidden" value="<?=$if?>" />
|
386 |
c821a6cd
|
Stephen Beaver
|
<div class="panel panel-default">
|
387 |
988b786d
|
luckman212
|
<div class="panel-heading"><h2 class="panel-title"><?=$rules_header_text?></h2></div>
|
388 |
c821a6cd
|
Stephen Beaver
|
<div id="mainarea" class="table-responsive panel-body">
|
389 |
dd455f50
|
Steve Beaver
|
<table id="ruletable" class="table table-hover table-striped table-condensed" style="overflow-x: 'visible'">
|
390 |
c821a6cd
|
Stephen Beaver
|
<thead>
|
391 |
|
|
<tr>
|
392 |
4ad34942
|
Steve Beaver
|
<th><input type="checkbox" id="selectAll" name="selectAll" /></th>
|
393 |
c821a6cd
|
Stephen Beaver
|
<th><!-- status icons --></th>
|
394 |
cc2cff0b
|
Luiz Otavio O Souza
|
<th><?=gettext("States")?></th>
|
395 |
bf83fb9a
|
Viktor G
|
<?php
|
396 |
|
|
if ('FloatingRules' == $if) {
|
397 |
|
|
?>
|
398 |
|
|
<th><?=gettext("Interfaces")?></th>
|
399 |
|
|
<?php
|
400 |
|
|
}
|
401 |
|
|
?>
|
402 |
66c62a1a
|
NewEraCracker
|
<th><?=gettext("Protocol")?></th>
|
403 |
f25dac2d
|
Stephen Beaver
|
<th><?=gettext("Source")?></th>
|
404 |
|
|
<th><?=gettext("Port")?></th>
|
405 |
|
|
<th><?=gettext("Destination")?></th>
|
406 |
|
|
<th><?=gettext("Port")?></th>
|
407 |
|
|
<th><?=gettext("Gateway")?></th>
|
408 |
|
|
<th><?=gettext("Queue")?></th>
|
409 |
|
|
<th><?=gettext("Schedule")?></th>
|
410 |
|
|
<th><?=gettext("Description")?></th>
|
411 |
|
|
<th><?=gettext("Actions")?></th>
|
412 |
c821a6cd
|
Stephen Beaver
|
</tr>
|
413 |
|
|
</thead>
|
414 |
a2c5280d
|
Stephen Beaver
|
|
415 |
|
|
<?php if ($showblockbogons || $showantilockout || $showprivate) :
|
416 |
|
|
?>
|
417 |
c821a6cd
|
Stephen Beaver
|
<tbody>
|
418 |
3b2c83b8
|
Sjon Hortensius
|
<?php
|
419 |
ea5665c7
|
Sjon Hortensius
|
// Show the anti-lockout rule if it's enabled, and we are on LAN with an if count > 1, or WAN with an if count of 1.
|
420 |
a2c5280d
|
Stephen Beaver
|
if ($showantilockout):
|
421 |
|
|
$alports = implode('<br />', filter_get_antilockout_ports(true));
|
422 |
3b2c83b8
|
Sjon Hortensius
|
?>
|
423 |
b54ae90f
|
Jared Dillard
|
<tr id="antilockout">
|
424 |
6cb366de
|
Stephen Beaver
|
<td></td>
|
425 |
29620ab5
|
Jared Dillard
|
<td title="<?=gettext("traffic is passed")?>"><i class="fa fa-check text-success"></i></td>
|
426 |
1574802c
|
Renato Botelho do Couto
|
<td><?php print_states(intval(ANTILOCKOUT_TRACKER_START), intval(ANTILOCKOUT_TRACKER_END)); ?></td>
|
427 |
c821a6cd
|
Stephen Beaver
|
<td>*</td>
|
428 |
|
|
<td>*</td>
|
429 |
|
|
<td>*</td>
|
430 |
|
|
<td><?=$iflist[$if];?> Address</td>
|
431 |
|
|
<td><?=$alports?></td>
|
432 |
|
|
<td>*</td>
|
433 |
|
|
<td>*</td>
|
434 |
|
|
<td></td>
|
435 |
b54ae90f
|
Jared Dillard
|
<td><?=gettext("Anti-Lockout Rule");?></td>
|
436 |
c821a6cd
|
Stephen Beaver
|
<td>
|
437 |
45e849c1
|
Jared Dillard
|
<a href="system_advanced_admin.php" title="<?=gettext("Settings");?>"><i class="fa fa-cog"></i></a>
|
438 |
c821a6cd
|
Stephen Beaver
|
</td>
|
439 |
|
|
</tr>
|
440 |
a2c5280d
|
Stephen Beaver
|
<?php endif;?>
|
441 |
|
|
<?php if ($showprivate): ?>
|
442 |
f72e8ee1
|
NOYB
|
<tr id="private">
|
443 |
6cb366de
|
Stephen Beaver
|
<td></td>
|
444 |
29620ab5
|
Jared Dillard
|
<td title="<?=gettext("traffic is blocked")?>"><i class="fa fa-times text-danger"></i></td>
|
445 |
1574802c
|
Renato Botelho do Couto
|
<td><?php print_states(intval(RFC1918_TRACKER_START), intval(RFC1918_TRACKER_END)); ?></td>
|
446 |
c821a6cd
|
Stephen Beaver
|
<td>*</td>
|
447 |
|
|
<td><?=gettext("RFC 1918 networks");?></td>
|
448 |
|
|
<td>*</td>
|
449 |
|
|
<td>*</td>
|
450 |
|
|
<td>*</td>
|
451 |
|
|
<td>*</td>
|
452 |
|
|
<td>*</td>
|
453 |
|
|
<td></td>
|
454 |
b54ae90f
|
Jared Dillard
|
<td><?=gettext("Block private networks");?></td>
|
455 |
c821a6cd
|
Stephen Beaver
|
<td>
|
456 |
e3947e77
|
Steve Beaver
|
<a href="interfaces.php?if=<?=htmlspecialchars($if)?>" title="<?=gettext("Settings");?>" usepost><i class="fa fa-cog"></i></a>
|
457 |
c821a6cd
|
Stephen Beaver
|
</td>
|
458 |
|
|
</tr>
|
459 |
a2c5280d
|
Stephen Beaver
|
<?php endif;?>
|
460 |
|
|
<?php if ($showblockbogons): ?>
|
461 |
f72e8ee1
|
NOYB
|
<tr id="bogons">
|
462 |
0c61e497
|
Stephen Beaver
|
<td></td>
|
463 |
29620ab5
|
Jared Dillard
|
<td title="<?=gettext("traffic is blocked")?>"><i class="fa fa-times text-danger"></i></td>
|
464 |
1574802c
|
Renato Botelho do Couto
|
<td><?php print_states(intval(BOGONS_TRACKER_START), intval(BOGONS_TRACKER_END)); ?></td>
|
465 |
c821a6cd
|
Stephen Beaver
|
<td>*</td>
|
466 |
0c61e497
|
Stephen Beaver
|
<td><?=sprintf(gettext("Reserved%sNot assigned by IANA"), "<br />");?></td>
|
467 |
c821a6cd
|
Stephen Beaver
|
<td>*</td>
|
468 |
|
|
<td>*</td>
|
469 |
|
|
<td>*</td>
|
470 |
|
|
<td>*</td>
|
471 |
|
|
<td>*</td>
|
472 |
ea548271
|
Phil Davis
|
<td></td>
|
473 |
b54ae90f
|
Jared Dillard
|
<td><?=gettext("Block bogon networks");?></td>
|
474 |
c821a6cd
|
Stephen Beaver
|
<td>
|
475 |
e3947e77
|
Steve Beaver
|
<a href="interfaces.php?if=<?=htmlspecialchars($if)?>" title="<?=gettext("Settings");?>" usepost><i class="fa fa-cog"></i></a>
|
476 |
c821a6cd
|
Stephen Beaver
|
</td>
|
477 |
|
|
</tr>
|
478 |
a2c5280d
|
Stephen Beaver
|
<?php endif;?>
|
479 |
c821a6cd
|
Stephen Beaver
|
</tbody>
|
480 |
a2c5280d
|
Stephen Beaver
|
<?php endif;?>
|
481 |
c821a6cd
|
Stephen Beaver
|
<tbody class="user-entries">
|
482 |
6cb366de
|
Stephen Beaver
|
<?php
|
483 |
|
|
$nrules = 0;
|
484 |
ccc62f13
|
NOYB
|
$separators = $config['filter']['separator'][strtolower($if)];
|
485 |
a361a19b
|
Stephen Beaver
|
|
486 |
36bf13fd
|
NOYB
|
// Get a list of separator rows and use it to call the display separator function only for rows which there are separator(s).
|
487 |
|
|
// More efficient than looping through the list of separators on every row.
|
488 |
|
|
$seprows = separator_rows($separators);
|
489 |
a361a19b
|
Stephen Beaver
|
|
490 |
227c1181
|
NOYB
|
foreach ($a_filter as $filteri => $filterent):
|
491 |
|
|
|
492 |
fdb83ce0
|
NOYB
|
if (($filterent['interface'] == $if && !isset($filterent['floating'])) || (isset($filterent['floating']) && "FloatingRules" == $if)) {
|
493 |
36bf13fd
|
NOYB
|
|
494 |
|
|
// Display separator(s) for section beginning at rule n
|
495 |
|
|
if ($seprows[$nrules]) {
|
496 |
|
|
display_separator($separators, $nrules, $columns_in_table);
|
497 |
|
|
}
|
498 |
56dda8e0
|
Renato Botelho
|
?>
|
499 |
f2066870
|
NOYB
|
<tr id="fr<?=$nrules;?>" onClick="fr_toggle(<?=$nrules;?>)" ondblclick="document.location='firewall_rules_edit.php?id=<?=$filteri;?>';" <?=(isset($filterent['disabled']) ? ' class="disabled"' : '')?>>
|
500 |
a42399ac
|
Colin Fleming
|
<td>
|
501 |
f2066870
|
NOYB
|
<input type="checkbox" id="frc<?=$nrules;?>" onClick="fr_toggle(<?=$nrules;?>)" name="rule[]" value="<?=$filteri;?>"/>
|
502 |
6cb366de
|
Stephen Beaver
|
</td>
|
503 |
|
|
|
504 |
3b2c83b8
|
Sjon Hortensius
|
<?php
|
505 |
d08aeac1
|
Phil Davis
|
if ($filterent['type'] == "block") {
|
506 |
29620ab5
|
Jared Dillard
|
$iconfn = "times text-danger";
|
507 |
d08aeac1
|
Phil Davis
|
$title_text = gettext("traffic is blocked");
|
508 |
|
|
} else if ($filterent['type'] == "reject") {
|
509 |
29620ab5
|
Jared Dillard
|
$iconfn = "hand-stop-o text-warning";
|
510 |
d08aeac1
|
Phil Davis
|
$title_text = gettext("traffic is rejected");
|
511 |
|
|
} else if ($filterent['type'] == "match") {
|
512 |
3b2c83b8
|
Sjon Hortensius
|
$iconfn = "filter";
|
513 |
d08aeac1
|
Phil Davis
|
$title_text = gettext("traffic is matched");
|
514 |
|
|
} else {
|
515 |
29620ab5
|
Jared Dillard
|
$iconfn = "check text-success";
|
516 |
d08aeac1
|
Phil Davis
|
$title_text = gettext("traffic is passed");
|
517 |
|
|
}
|
518 |
3b2c83b8
|
Sjon Hortensius
|
?>
|
519 |
d08aeac1
|
Phil Davis
|
<td title="<?=$title_text?>">
|
520 |
e3947e77
|
Steve Beaver
|
<a href="?if=<?=htmlspecialchars($if);?>&act=toggle&id=<?=$filteri;?>" usepost>
|
521 |
d4cb4cf3
|
Stephen Beaver
|
<i class="fa fa-<?=$iconfn?>" title="<?=gettext("click to toggle enabled/disabled status");?>"></i>
|
522 |
|
|
</a>
|
523 |
3b2c83b8
|
Sjon Hortensius
|
<?php
|
524 |
e2461a2f
|
Stephen Beaver
|
if ($filterent['quick'] == 'yes') {
|
525 |
b04d849d
|
Stephen Beaver
|
print '<i class="fa fa-forward text-success" title="'. gettext(""Quick" rule. Applied immediately on match.") .'" style="cursor: pointer;"></i>';
|
526 |
e2461a2f
|
Stephen Beaver
|
}
|
527 |
|
|
|
528 |
3b2c83b8
|
Sjon Hortensius
|
$isadvset = firewall_check_for_advanced_options($filterent);
|
529 |
67c2baf1
|
Phil Davis
|
if ($isadvset) {
|
530 |
7ea65674
|
Jared Dillard
|
print '<i class="fa fa-cog" title="'. gettext("advanced setting") .': '. $isadvset .'"></i>';
|
531 |
67c2baf1
|
Phil Davis
|
}
|
532 |
3b2c83b8
|
Sjon Hortensius
|
|
533 |
67c2baf1
|
Phil Davis
|
if (isset($filterent['log'])) {
|
534 |
e2461a2f
|
Stephen Beaver
|
print '<i class="fa fa-tasks" title="'. gettext("traffic is logged") .'" style="cursor: pointer;"></i>';
|
535 |
67c2baf1
|
Phil Davis
|
}
|
536 |
3b2c83b8
|
Sjon Hortensius
|
?>
|
537 |
d08aeac1
|
Phil Davis
|
</td>
|
538 |
3b2c83b8
|
Sjon Hortensius
|
<?php
|
539 |
|
|
$alias = rule_columns_with_alias(
|
540 |
|
|
$filterent['source']['address'],
|
541 |
|
|
pprint_port($filterent['source']['port']),
|
542 |
|
|
$filterent['destination']['address'],
|
543 |
|
|
pprint_port($filterent['destination']['port'])
|
544 |
|
|
);
|
545 |
|
|
|
546 |
|
|
//build Schedule popup box
|
547 |
c6c398c6
|
jim-p
|
init_config_arr(array('schedules', 'schedule'));
|
548 |
3b2c83b8
|
Sjon Hortensius
|
$a_schedules = &$config['schedules']['schedule'];
|
549 |
|
|
$schedule_span_begin = "";
|
550 |
|
|
$schedule_span_end = "";
|
551 |
|
|
$sched_caption_escaped = "";
|
552 |
|
|
$sched_content = "";
|
553 |
|
|
$schedstatus = false;
|
554 |
e6f34d22
|
Phil Davis
|
$dayArray = array (gettext('Mon'), gettext('Tues'), gettext('Wed'), gettext('Thur'), gettext('Fri'), gettext('Sat'), gettext('Sun'));
|
555 |
|
|
$monthArray = array (gettext('January'), gettext('February'), gettext('March'), gettext('April'), gettext('May'), gettext('June'), gettext('July'), gettext('August'), gettext('September'), gettext('October'), gettext('November'), gettext('December'));
|
556 |
ea5665c7
|
Sjon Hortensius
|
if ($config['schedules']['schedule'] != "" && is_array($config['schedules']['schedule'])) {
|
557 |
bdfea2e7
|
Stephen Beaver
|
$idx = 0;
|
558 |
67c2baf1
|
Phil Davis
|
foreach ($a_schedules as $schedule) {
|
559 |
dc65689a
|
Renato Botelho
|
if (!empty($schedule['name']) &&
|
560 |
|
|
$schedule['name'] == $filterent['sched']) {
|
561 |
3b2c83b8
|
Sjon Hortensius
|
$schedstatus = filter_get_time_based_rule_status($schedule);
|
562 |
|
|
|
563 |
e6f34d22
|
Phil Davis
|
foreach ($schedule['timerange'] as $timerange) {
|
564 |
3b2c83b8
|
Sjon Hortensius
|
$tempFriendlyTime = "";
|
565 |
|
|
$tempID = "";
|
566 |
|
|
$firstprint = false;
|
567 |
e6f34d22
|
Phil Davis
|
if ($timerange) {
|
568 |
3b2c83b8
|
Sjon Hortensius
|
$dayFriendly = "";
|
569 |
|
|
$tempFriendlyTime = "";
|
570 |
|
|
|
571 |
|
|
//get hours
|
572 |
|
|
$temptimerange = $timerange['hour'];
|
573 |
|
|
$temptimeseparator = strrpos($temptimerange, "-");
|
574 |
|
|
|
575 |
|
|
$starttime = substr ($temptimerange, 0, $temptimeseparator);
|
576 |
|
|
$stoptime = substr ($temptimerange, $temptimeseparator+1);
|
577 |
|
|
|
578 |
e6f34d22
|
Phil Davis
|
if ($timerange['month']) {
|
579 |
3b2c83b8
|
Sjon Hortensius
|
$tempmontharray = explode(",", $timerange['month']);
|
580 |
e6f34d22
|
Phil Davis
|
$tempdayarray = explode(",", $timerange['day']);
|
581 |
3b2c83b8
|
Sjon Hortensius
|
$arraycounter = 0;
|
582 |
|
|
$firstDayFound = false;
|
583 |
|
|
$firstPrint = false;
|
584 |
e6f34d22
|
Phil Davis
|
foreach ($tempmontharray as $monthtmp) {
|
585 |
3b2c83b8
|
Sjon Hortensius
|
$month = $tempmontharray[$arraycounter];
|
586 |
|
|
$day = $tempdayarray[$arraycounter];
|
587 |
|
|
|
588 |
67c2baf1
|
Phil Davis
|
if (!$firstDayFound) {
|
589 |
3b2c83b8
|
Sjon Hortensius
|
$firstDay = $day;
|
590 |
|
|
$firstmonth = $month;
|
591 |
|
|
$firstDayFound = true;
|
592 |
|
|
}
|
593 |
|
|
|
594 |
|
|
$currentDay = $day;
|
595 |
|
|
$nextDay = $tempdayarray[$arraycounter+1];
|
596 |
|
|
$currentDay++;
|
597 |
e6f34d22
|
Phil Davis
|
if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])) {
|
598 |
67c2baf1
|
Phil Davis
|
if ($firstPrint) {
|
599 |
3b2c83b8
|
Sjon Hortensius
|
$dayFriendly .= ", ";
|
600 |
67c2baf1
|
Phil Davis
|
}
|
601 |
3b2c83b8
|
Sjon Hortensius
|
$currentDay--;
|
602 |
67c2baf1
|
Phil Davis
|
if ($currentDay != $firstDay) {
|
603 |
3b2c83b8
|
Sjon Hortensius
|
$dayFriendly .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ;
|
604 |
67c2baf1
|
Phil Davis
|
} else {
|
605 |
c821a6cd
|
Stephen Beaver
|
$dayFriendly .= $monthArray[$month-1] . " " . $day;
|
606 |
67c2baf1
|
Phil Davis
|
}
|
607 |
8ce97a08
|
Scott Dale
|
$firstDayFound = false;
|
608 |
3b2c83b8
|
Sjon Hortensius
|
$firstPrint = true;
|
609 |
|
|
}
|
610 |
|
|
$arraycounter++;
|
611 |
|
|
}
|
612 |
67c2baf1
|
Phil Davis
|
} else {
|
613 |
3b2c83b8
|
Sjon Hortensius
|
$tempdayFriendly = $timerange['position'];
|
614 |
|
|
$firstDayFound = false;
|
615 |
|
|
$tempFriendlyDayArray = explode(",", $tempdayFriendly);
|
616 |
|
|
$currentDay = "";
|
617 |
|
|
$firstDay = "";
|
618 |
|
|
$nextDay = "";
|
619 |
|
|
$counter = 0;
|
620 |
e6f34d22
|
Phil Davis
|
foreach ($tempFriendlyDayArray as $day) {
|
621 |
|
|
if ($day != "") {
|
622 |
67c2baf1
|
Phil Davis
|
if (!$firstDayFound) {
|
623 |
3b2c83b8
|
Sjon Hortensius
|
$firstDay = $tempFriendlyDayArray[$counter];
|
624 |
|
|
$firstDayFound = true;
|
625 |
8ce97a08
|
Scott Dale
|
}
|
626 |
3b2c83b8
|
Sjon Hortensius
|
$currentDay =$tempFriendlyDayArray[$counter];
|
627 |
|
|
//get next day
|
628 |
|
|
$nextDay = $tempFriendlyDayArray[$counter+1];
|
629 |
|
|
$currentDay++;
|
630 |
e6f34d22
|
Phil Davis
|
if ($currentDay != $nextDay) {
|
631 |
67c2baf1
|
Phil Davis
|
if ($firstprint) {
|
632 |
3b2c83b8
|
Sjon Hortensius
|
$dayFriendly .= ", ";
|
633 |
67c2baf1
|
Phil Davis
|
}
|
634 |
3b2c83b8
|
Sjon Hortensius
|
$currentDay--;
|
635 |
67c2baf1
|
Phil Davis
|
if ($currentDay != $firstDay) {
|
636 |
3b2c83b8
|
Sjon Hortensius
|
$dayFriendly .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
|
637 |
67c2baf1
|
Phil Davis
|
} else {
|
638 |
3b2c83b8
|
Sjon Hortensius
|
$dayFriendly .= $dayArray[$firstDay-1];
|
639 |
67c2baf1
|
Phil Davis
|
}
|
640 |
3b2c83b8
|
Sjon Hortensius
|
$firstDayFound = false;
|
641 |
|
|
$firstprint = true;
|
642 |
|
|
}
|
643 |
|
|
$counter++;
|
644 |
56dda8e0
|
Renato Botelho
|
}
|
645 |
8ce97a08
|
Scott Dale
|
}
|
646 |
2a113ca9
|
Scott Dale
|
}
|
647 |
3b2c83b8
|
Sjon Hortensius
|
$timeFriendly = $starttime . " - " . $stoptime;
|
648 |
|
|
$description = $timerange['rangedescr'];
|
649 |
|
|
$sched_content .= $dayFriendly . "; " . $timeFriendly . "<br />";
|
650 |
56dda8e0
|
Renato Botelho
|
}
|
651 |
|
|
}
|
652 |
ea5665c7
|
Sjon Hortensius
|
#FIXME
|
653 |
3b2c83b8
|
Sjon Hortensius
|
$sched_caption_escaped = str_replace("'", "\'", $schedule['descr']);
|
654 |
bdfea2e7
|
Stephen Beaver
|
$schedule_span_begin = '<a href="/firewall_schedule_edit.php?id=' . $idx . '" data-toggle="popover" data-trigger="hover focus" title="' . $schedule['name'] . '" data-content="' .
|
655 |
84147b7b
|
Steve Beaver
|
$sched_caption_escaped . '" data-html="true">';
|
656 |
a42399ac
|
Colin Fleming
|
$schedule_span_end = "</a>";
|
657 |
616dd997
|
Scott Dale
|
}
|
658 |
92da593a
|
Chris Buechler
|
$idx++;
|
659 |
3b2c83b8
|
Sjon Hortensius
|
}
|
660 |
|
|
}
|
661 |
|
|
$printicon = false;
|
662 |
|
|
$alttext = "";
|
663 |
|
|
$image = "";
|
664 |
|
|
if (!isset($filterent['disabled'])) {
|
665 |
|
|
if ($schedstatus) {
|
666 |
5db29ca7
|
Phil Davis
|
if ($filterent['type'] == "block" || $filterent['type'] == "reject") {
|
667 |
7ea65674
|
Jared Dillard
|
$image = "times-circle";
|
668 |
bdfea2e7
|
Stephen Beaver
|
$dispcolor = "text-danger";
|
669 |
3b2c83b8
|
Sjon Hortensius
|
$alttext = gettext("Traffic matching this rule is currently being denied");
|
670 |
56dda8e0
|
Renato Botelho
|
} else {
|
671 |
7ea65674
|
Jared Dillard
|
$image = "play-circle";
|
672 |
bdfea2e7
|
Stephen Beaver
|
$dispcolor = "text-success";
|
673 |
3b2c83b8
|
Sjon Hortensius
|
$alttext = gettext("Traffic matching this rule is currently being allowed");
|
674 |
be81b340
|
Erik Fonnesbeck
|
}
|
675 |
3b2c83b8
|
Sjon Hortensius
|
$printicon = true;
|
676 |
|
|
} else if ($filterent['sched']) {
|
677 |
5db29ca7
|
Phil Davis
|
if ($filterent['type'] == "block" || $filterent['type'] == "reject") {
|
678 |
7ea65674
|
Jared Dillard
|
$image = "times-circle";
|
679 |
67c2baf1
|
Phil Davis
|
} else {
|
680 |
5db29ca7
|
Phil Davis
|
$image = "play-circle";
|
681 |
67c2baf1
|
Phil Davis
|
}
|
682 |
3b2c83b8
|
Sjon Hortensius
|
$alttext = gettext("This rule is not currently active because its period has expired");
|
683 |
5db29ca7
|
Phil Davis
|
$dispcolor = "text-warning";
|
684 |
3b2c83b8
|
Sjon Hortensius
|
$printicon = true;
|
685 |
|
|
}
|
686 |
|
|
}
|
687 |
|
|
?>
|
688 |
2af731f8
|
NewEraCracker
|
<td><?php print_states(intval($filterent['tracker'])); ?></td>
|
689 |
bf83fb9a
|
Viktor G
|
<?php
|
690 |
|
|
if ($if == 'FloatingRules') {
|
691 |
|
|
?>
|
692 |
|
|
<td onclick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';">
|
693 |
|
|
<?php
|
694 |
|
|
if (isset($filterent['interface'])) {
|
695 |
|
|
$selected_interfaces = explode(',', $filterent['interface']);
|
696 |
|
|
unset($selected_descs);
|
697 |
|
|
foreach ($selected_interfaces as $interface) {
|
698 |
|
|
if (isset($ifdescs[$interface])) {
|
699 |
|
|
$selected_descs[] = $ifdescs[$interface];
|
700 |
|
|
} else {
|
701 |
|
|
switch ($interface) {
|
702 |
|
|
case 'l2tp':
|
703 |
|
|
if ($config['l2tp']['mode'] == 'server')
|
704 |
|
|
$selected_descs[] = 'L2TP VPN';
|
705 |
|
|
break;
|
706 |
|
|
case 'pppoe':
|
707 |
|
|
if (is_pppoe_server_enabled())
|
708 |
|
|
$selected_descs[] = 'PPPoE Server';
|
709 |
|
|
break;
|
710 |
|
|
case 'enc0':
|
711 |
65d935bf
|
Viktor G
|
if (ipsec_enabled())
|
712 |
bf83fb9a
|
Viktor G
|
$selected_descs[] = 'IPsec';
|
713 |
|
|
break;
|
714 |
|
|
case 'openvpn':
|
715 |
|
|
if ($config['openvpn']['openvpn-server'] || $config['openvpn']['openvpn-client'])
|
716 |
|
|
$selected_descs[] = 'OpenVPN';
|
717 |
|
|
break;
|
718 |
|
|
default:
|
719 |
|
|
$selected_descs[] = $interface;
|
720 |
|
|
break;
|
721 |
|
|
}
|
722 |
|
|
}
|
723 |
|
|
}
|
724 |
65d935bf
|
Viktor G
|
if (!empty($selected_descs)) {
|
725 |
03c0fd1e
|
Viktor G
|
$desclist = '';
|
726 |
|
|
$desclength = 0;
|
727 |
|
|
foreach ($selected_descs as $descid => $desc) {
|
728 |
|
|
$desclength += strlen($desc);
|
729 |
|
|
if ($desclength > 18) {
|
730 |
|
|
$desclist .= ',<br/>';
|
731 |
|
|
$desclength = 0;
|
732 |
|
|
} elseif ($desclist) {
|
733 |
|
|
$desclist .= ', ';
|
734 |
|
|
$desclength += 2;
|
735 |
|
|
}
|
736 |
|
|
$desclist .= $desc;
|
737 |
|
|
}
|
738 |
|
|
echo $desclist;
|
739 |
65d935bf
|
Viktor G
|
}
|
740 |
bf83fb9a
|
Viktor G
|
}
|
741 |
|
|
?>
|
742 |
|
|
</td>
|
743 |
|
|
<?php
|
744 |
|
|
}
|
745 |
|
|
?>
|
746 |
|
|
<td>
|
747 |
3b2c83b8
|
Sjon Hortensius
|
<?php
|
748 |
|
|
if (isset($filterent['ipprotocol'])) {
|
749 |
e6f34d22
|
Phil Davis
|
switch ($filterent['ipprotocol']) {
|
750 |
3b2c83b8
|
Sjon Hortensius
|
case "inet":
|
751 |
|
|
echo "IPv4 ";
|
752 |
|
|
break;
|
753 |
|
|
case "inet6":
|
754 |
|
|
echo "IPv6 ";
|
755 |
|
|
break;
|
756 |
|
|
case "inet46":
|
757 |
|
|
echo "IPv4+6 ";
|
758 |
|
|
break;
|
759 |
|
|
}
|
760 |
|
|
} else {
|
761 |
|
|
echo "IPv4 ";
|
762 |
|
|
}
|
763 |
|
|
|
764 |
|
|
if (isset($filterent['protocol'])) {
|
765 |
|
|
echo strtoupper($filterent['protocol']);
|
766 |
|
|
|
767 |
|
|
if (strtoupper($filterent['protocol']) == "ICMP" && !empty($filterent['icmptype'])) {
|
768 |
16b91b19
|
stilez
|
// replace each comma-separated icmptype item by its (localised) full description
|
769 |
91822dc6
|
stilez
|
$t = implode(', ',
|
770 |
|
|
array_map(
|
771 |
|
|
function($type) {
|
772 |
|
|
global $icmptypes;
|
773 |
c7e31e37
|
stilez
|
return $icmptypes[$type]['descrip'];
|
774 |
91822dc6
|
stilez
|
},
|
775 |
|
|
explode(',', $filterent['icmptype'])
|
776 |
|
|
)
|
777 |
|
|
);
|
778 |
675c9e59
|
stilez
|
echo sprintf('<br /><div style="cursor:help;padding:1px;line-height:1.1em;max-height:2.5em;max-width:180px;overflow-y:auto;overflow-x:hidden" title="%s:%s%s"><small><u>%s</u></small></div>', gettext('ICMP subtypes'), chr(13), $t, str_replace(',', '</u>, <u>',$filterent['icmptype']));
|
779 |
3b2c83b8
|
Sjon Hortensius
|
}
|
780 |
97eebb23
|
stilez
|
} else {
|
781 |
|
|
echo " *";
|
782 |
|
|
}
|
783 |
3b2c83b8
|
Sjon Hortensius
|
?>
|
784 |
c821a6cd
|
Stephen Beaver
|
</td>
|
785 |
|
|
<td>
|
786 |
|
|
<?php if (isset($alias['src'])): ?>
|
787 |
84147b7b
|
Steve Beaver
|
<a href="/firewall_aliases_edit.php?id=<?=$alias['src']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['src'])?>" data-html="true">
|
788 |
4b72f68f
|
Steve Beaver
|
<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_address($filterent['source'])))?>
|
789 |
a42399ac
|
Colin Fleming
|
</a>
|
790 |
|
|
<?php else: ?>
|
791 |
|
|
<?=htmlspecialchars(pprint_address($filterent['source']))?>
|
792 |
c821a6cd
|
Stephen Beaver
|
<?php endif; ?>
|
793 |
|
|
</td>
|
794 |
|
|
<td>
|
795 |
|
|
<?php if (isset($alias['srcport'])): ?>
|
796 |
84147b7b
|
Steve Beaver
|
<a href="/firewall_aliases_edit.php?id=<?=$alias['srcport']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['srcport'])?>" data-html="true">
|
797 |
4b72f68f
|
Steve Beaver
|
<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_port($filterent['source']['port'])))?>
|
798 |
a42399ac
|
Colin Fleming
|
</a>
|
799 |
|
|
<?php else: ?>
|
800 |
|
|
<?=htmlspecialchars(pprint_port($filterent['source']['port']))?>
|
801 |
c821a6cd
|
Stephen Beaver
|
<?php endif; ?>
|
802 |
|
|
</td>
|
803 |
|
|
<td>
|
804 |
|
|
<?php if (isset($alias['dst'])): ?>
|
805 |
84147b7b
|
Steve Beaver
|
<a href="/firewall_aliases_edit.php?id=<?=$alias['dst']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['dst'])?>" data-html="true">
|
806 |
4b72f68f
|
Steve Beaver
|
<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_address($filterent['destination'])))?>
|
807 |
a42399ac
|
Colin Fleming
|
</a>
|
808 |
2af731f8
|
NewEraCracker
|
<?php else: ?>
|
809 |
a42399ac
|
Colin Fleming
|
<?=htmlspecialchars(pprint_address($filterent['destination']))?>
|
810 |
c821a6cd
|
Stephen Beaver
|
<?php endif; ?>
|
811 |
|
|
</td>
|
812 |
|
|
<td>
|
813 |
|
|
<?php if (isset($alias['dstport'])): ?>
|
814 |
84147b7b
|
Steve Beaver
|
<a href="/firewall_aliases_edit.php?id=<?=$alias['dstport']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['dstport'])?>" data-html="true">
|
815 |
4b72f68f
|
Steve Beaver
|
<?=str_replace('_', '_<wbr>', htmlspecialchars(pprint_port($filterent['destination']['port'])))?>
|
816 |
a42399ac
|
Colin Fleming
|
</a>
|
817 |
|
|
<?php else: ?>
|
818 |
|
|
<?=htmlspecialchars(pprint_port($filterent['destination']['port']))?>
|
819 |
c821a6cd
|
Stephen Beaver
|
<?php endif; ?>
|
820 |
|
|
</td>
|
821 |
|
|
<td>
|
822 |
e912f0cf
|
Viktor G
|
<?php if (isset($filterent['gateway'])): ?>
|
823 |
|
|
<span data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Gateways details')?>" data-content="<?=gateway_info_popup($filterent['gateway'])?>" data-html="true">
|
824 |
c821a6cd
|
Stephen Beaver
|
<?php else: ?>
|
825 |
e912f0cf
|
Viktor G
|
<span>
|
826 |
c821a6cd
|
Stephen Beaver
|
<?php endif; ?>
|
827 |
e912f0cf
|
Viktor G
|
<?php if (isset($config['interfaces'][$filterent['gateway']]['descr'])): ?>
|
828 |
|
|
<?=str_replace('_', '_<wbr>', htmlspecialchars($config['interfaces'][$filterent['gateway']]['descr']))?>
|
829 |
|
|
<?php else: ?>
|
830 |
|
|
<?=htmlspecialchars(pprint_port($filterent['gateway']))?>
|
831 |
|
|
<?php endif; ?>
|
832 |
|
|
</span>
|
833 |
c821a6cd
|
Stephen Beaver
|
</td>
|
834 |
|
|
<td>
|
835 |
|
|
<?php
|
836 |
|
|
if (isset($filterent['ackqueue']) && isset($filterent['defaultqueue'])) {
|
837 |
ece727a7
|
NOYB
|
$desc = str_replace('_', ' ', $filterent['ackqueue']);
|
838 |
84147b7b
|
Steve Beaver
|
echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['ackqueue']}&action=show\">{$desc}</a>";
|
839 |
4b72f68f
|
Steve Beaver
|
$desc = str_replace('_', '_<wbr>', $filterent['defaultqueue']);
|
840 |
84147b7b
|
Steve Beaver
|
echo "/<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&action=show\">{$desc}</a>";
|
841 |
c821a6cd
|
Stephen Beaver
|
} else if (isset($filterent['defaultqueue'])) {
|
842 |
4b72f68f
|
Steve Beaver
|
$desc = str_replace('_', '_<wbr>', $filterent['defaultqueue']);
|
843 |
84147b7b
|
Steve Beaver
|
echo "<a href=\"firewall_shaper_queues.php?queue={$filterent['defaultqueue']}&action=show\">{$desc}</a>";
|
844 |
67c2baf1
|
Phil Davis
|
} else {
|
845 |
c821a6cd
|
Stephen Beaver
|
echo gettext("none");
|
846 |
67c2baf1
|
Phil Davis
|
}
|
847 |
c821a6cd
|
Stephen Beaver
|
?>
|
848 |
|
|
</td>
|
849 |
|
|
<td>
|
850 |
995df6c3
|
Stephen Beaver
|
<?php if ($printicon) { ?>
|
851 |
a42399ac
|
Colin Fleming
|
<i class="fa fa-<?=$image?> <?=$dispcolor?>" title="<?=$alttext;?>"></i>
|
852 |
995df6c3
|
Stephen Beaver
|
<?php } ?>
|
853 |
4b72f68f
|
Steve Beaver
|
<?=$schedule_span_begin;?><?=str_replace('_', '_<wbr>', htmlspecialchars($filterent['sched']));?> <?=$schedule_span_end;?>
|
854 |
c821a6cd
|
Stephen Beaver
|
</td>
|
855 |
b54ae90f
|
Jared Dillard
|
<td>
|
856 |
c821a6cd
|
Stephen Beaver
|
<?=htmlspecialchars($filterent['descr']);?>
|
857 |
|
|
</td>
|
858 |
45e849c1
|
Jared Dillard
|
<td class="action-icons">
|
859 |
f25dac2d
|
Stephen Beaver
|
<!-- <?=(isset($filterent['disabled']) ? 'enable' : 'disable')?> -->
|
860 |
d830a7f4
|
Stephen Beaver
|
<a class="fa fa-anchor icon-pointer" id="Xmove_<?=$filteri?>" title="<?=$XmoveTitle?>"></a>
|
861 |
84147b7b
|
Steve Beaver
|
<a href="firewall_rules_edit.php?id=<?=$filteri;?>" class="fa fa-pencil" title="<?=gettext('Edit')?>"></a>
|
862 |
|
|
<a href="firewall_rules_edit.php?dup=<?=$filteri;?>" class="fa fa-clone" title="<?=gettext('Copy')?>"></a>
|
863 |
f25dac2d
|
Stephen Beaver
|
<?php if (isset($filterent['disabled'])) {
|
864 |
|
|
?>
|
865 |
e3947e77
|
Steve Beaver
|
<a href="?act=toggle&if=<?=htmlspecialchars($if);?>&id=<?=$filteri;?>" class="fa fa-check-square-o" title="<?=gettext('Enable')?>" usepost></a>
|
866 |
f25dac2d
|
Stephen Beaver
|
<?php } else {
|
867 |
|
|
?>
|
868 |
e3947e77
|
Steve Beaver
|
<a href="?act=toggle&if=<?=htmlspecialchars($if);?>&id=<?=$filteri;?>" class="fa fa-ban" title="<?=gettext('Disable')?>" usepost></a>
|
869 |
f25dac2d
|
Stephen Beaver
|
<?php }
|
870 |
|
|
?>
|
871 |
e3947e77
|
Steve Beaver
|
<a href="?act=del&if=<?=htmlspecialchars($if);?>&id=<?=$filteri;?>" class="fa fa-trash" title="<?=gettext('Delete this rule')?>" usepost></a>
|
872 |
c821a6cd
|
Stephen Beaver
|
</td>
|
873 |
|
|
</tr>
|
874 |
|
|
<?php
|
875 |
6cb366de
|
Stephen Beaver
|
$nrules++;
|
876 |
fdb83ce0
|
NOYB
|
}
|
877 |
227c1181
|
NOYB
|
endforeach;
|
878 |
36bf13fd
|
NOYB
|
|
879 |
|
|
// There can be separator(s) after the last rule listed.
|
880 |
|
|
if ($seprows[$nrules]) {
|
881 |
|
|
display_separator($separators, $nrules, $columns_in_table);
|
882 |
|
|
}
|
883 |
c821a6cd
|
Stephen Beaver
|
?>
|
884 |
|
|
</tbody>
|
885 |
|
|
</table>
|
886 |
|
|
</div>
|
887 |
|
|
</div>
|
888 |
3b2c83b8
|
Sjon Hortensius
|
|
889 |
|
|
<?php if ($nrules == 0): ?>
|
890 |
|
|
<div class="alert alert-warning" role="alert">
|
891 |
06966500
|
Sander van Leeuwen
|
<p>
|
892 |
3b2c83b8
|
Sjon Hortensius
|
<?php if ($_REQUEST['if'] == "FloatingRules"): ?>
|
893 |
|
|
<?=gettext("No floating rules are currently defined.");?>
|
894 |
|
|
<?php else: ?>
|
895 |
|
|
<?=gettext("No rules are currently defined for this interface");?><br />
|
896 |
317b2852
|
NOYB
|
<?=gettext("All incoming connections on this interface will be blocked until pass rules are added.");?>
|
897 |
3b2c83b8
|
Sjon Hortensius
|
<?php endif;?>
|
898 |
06966500
|
Sander van Leeuwen
|
<?=gettext("Click the button to add a new rule.");?>
|
899 |
|
|
</p>
|
900 |
3b2c83b8
|
Sjon Hortensius
|
</div>
|
901 |
|
|
<?php endif;?>
|
902 |
|
|
|
903 |
c10cb196
|
Stephen Beaver
|
<nav class="action-buttons">
|
904 |
84147b7b
|
Steve Beaver
|
<a href="firewall_rules_edit.php?if=<?=htmlspecialchars($if);?>&after=-1" role="button" class="btn btn-sm btn-success" title="<?=gettext('Add rule to the top of the list')?>">
|
905 |
270de3df
|
Stephen Beaver
|
<i class="fa fa-level-up icon-embed-btn"></i>
|
906 |
09415b9e
|
Stephen Beaver
|
<?=gettext("Add");?>
|
907 |
c821a6cd
|
Stephen Beaver
|
</a>
|
908 |
84147b7b
|
Steve Beaver
|
<a href="firewall_rules_edit.php?if=<?=htmlspecialchars($if);?>" role="button" class="btn btn-sm btn-success" title="<?=gettext('Add rule to the end of the list')?>">
|
909 |
270de3df
|
Stephen Beaver
|
<i class="fa fa-level-down icon-embed-btn"></i>
|
910 |
|
|
<?=gettext("Add");?>
|
911 |
|
|
</a>
|
912 |
|
|
<button name="del_x" type="submit" class="btn btn-danger btn-sm" value="<?=gettext("Delete selected rules"); ?>" title="<?=gettext('Delete selected rules')?>">
|
913 |
9d5a20cf
|
heper
|
<i class="fa fa-trash icon-embed-btn"></i>
|
914 |
09415b9e
|
Stephen Beaver
|
<?=gettext("Delete"); ?>
|
915 |
|
|
</button>
|
916 |
c4b60a9a
|
Colin Fleming
|
<button type="submit" id="order-store" name="order-store" class="btn btn-sm btn-primary" value="store changes" disabled title="<?=gettext('Save rule order')?>">
|
917 |
9d5a20cf
|
heper
|
<i class="fa fa-save icon-embed-btn"></i>
|
918 |
09415b9e
|
Stephen Beaver
|
<?=gettext("Save")?>
|
919 |
|
|
</button>
|
920 |
576437f5
|
Stephen Beaver
|
<button type="submit" id="addsep" name="addsep" class="btn btn-sm btn-warning" title="<?=gettext('Add separator')?>">
|
921 |
|
|
<i class="fa fa-plus icon-embed-btn"></i>
|
922 |
|
|
<?=gettext("Separator")?>
|
923 |
|
|
</button>
|
924 |
c821a6cd
|
Stephen Beaver
|
</nav>
|
925 |
|
|
</form>
|
926 |
|
|
|
927 |
35681930
|
Stephen Beaver
|
<div class="infoblock">
|
928 |
c97a3f34
|
Phil Davis
|
<div class="alert alert-info clearfix" role="alert"><div class="pull-left">
|
929 |
270de3df
|
Stephen Beaver
|
<dl class="dl-horizontal responsive">
|
930 |
|
|
<!-- Legend -->
|
931 |
|
|
<dt><?=gettext('Legend')?></dt> <dd></dd>
|
932 |
29620ab5
|
Jared Dillard
|
<dt><i class="fa fa-check text-success"></i></dt> <dd><?=gettext("Pass");?></dd>
|
933 |
1b7379f9
|
Jared Dillard
|
<dt><i class="fa fa-filter"></i></dt> <dd><?=gettext("Match");?></dd>
|
934 |
29620ab5
|
Jared Dillard
|
<dt><i class="fa fa-times text-danger"></i></dt> <dd><?=gettext("Block");?></dd>
|
935 |
|
|
<dt><i class="fa fa-hand-stop-o text-warning"></i></dt> <dd><?=gettext("Reject");?></dd>
|
936 |
1b7379f9
|
Jared Dillard
|
<dt><i class="fa fa-tasks"></i></dt> <dd> <?=gettext("Log");?></dd>
|
937 |
7ea65674
|
Jared Dillard
|
<dt><i class="fa fa-cog"></i></dt> <dd> <?=gettext("Advanced filter");?></dd>
|
938 |
cafd2aa0
|
Stephen Beaver
|
<dt><i class="fa fa-forward text-success"></i></dt><dd> <?=gettext(""Quick" rule. Applied immediately on match.")?></dd>
|
939 |
270de3df
|
Stephen Beaver
|
</dl>
|
940 |
|
|
|
941 |
824329d2
|
Stephen Beaver
|
<?php
|
942 |
67c2baf1
|
Phil Davis
|
if ("FloatingRules" != $if) {
|
943 |
270de3df
|
Stephen Beaver
|
print(gettext("Rules are evaluated on a first-match basis (i.e. " .
|
944 |
09415b9e
|
Stephen Beaver
|
"the action of the first rule to match a packet will be executed). ") . '<br />' .
|
945 |
9e97598a
|
NOYB
|
gettext("This means that if block rules are used, it is important to pay attention " .
|
946 |
09415b9e
|
Stephen Beaver
|
"to the rule order. Everything that isn't explicitly passed is blocked " .
|
947 |
270de3df
|
Stephen Beaver
|
"by default. "));
|
948 |
67c2baf1
|
Phil Davis
|
} else {
|
949 |
270de3df
|
Stephen Beaver
|
print(gettext("Floating rules are evaluated on a first-match basis (i.e. " .
|
950 |
09415b9e
|
Stephen Beaver
|
"the action of the first rule to match a packet will be executed) only " .
|
951 |
04fd7017
|
Stephen Beaver
|
"if the 'quick' option is checked on a rule. Otherwise they will only match if no " .
|
952 |
09415b9e
|
Stephen Beaver
|
"other rules match. Pay close attention to the rule order and options " .
|
953 |
270de3df
|
Stephen Beaver
|
"chosen. If no rule here matches, the per-interface or default rules are used. "));
|
954 |
67c2baf1
|
Phil Davis
|
}
|
955 |
d830a7f4
|
Stephen Beaver
|
|
956 |
702fa4d0
|
Phil Davis
|
printf(gettext('%1$sClick the anchor icon %2$s to move checked rules before the clicked row. Hold down ' .
|
957 |
|
|
'the shift key and click to move the rules after the clicked row.'), '<br /><br />', '<i class="fa fa-anchor"></i>')
|
958 |
824329d2
|
Stephen Beaver
|
?>
|
959 |
270de3df
|
Stephen Beaver
|
</div>
|
960 |
ab6b1f47
|
NOYB
|
</div>
|
961 |
09415b9e
|
Stephen Beaver
|
</div>
|
962 |
2f4323b5
|
Stephen Beaver
|
|
963 |
8fd9052f
|
Colin Fleming
|
<script type="text/javascript">
|
964 |
|
|
//<![CDATA[
|
965 |
7d8552fc
|
Stephen Beaver
|
|
966 |
2af731f8
|
NewEraCracker
|
//Need to create some variables here so that jquery/pfSenseHelpers.js can read them
|
967 |
7d8552fc
|
Stephen Beaver
|
iface = "<?=strtolower($if)?>";
|
968 |
|
|
cncltxt = '<?=gettext("Cancel")?>';
|
969 |
|
|
svtxt = '<?=gettext("Save")?>';
|
970 |
|
|
svbtnplaceholder = '<?=gettext("Enter a description, Save, then drag to final location.")?>';
|
971 |
|
|
configsection = "filter";
|
972 |
|
|
|
973 |
ea5665c7
|
Sjon Hortensius
|
events.push(function() {
|
974 |
2f4323b5
|
Stephen Beaver
|
|
975 |
3f597adb
|
Stephen Beaver
|
// "Move to here" (anchor) action
|
976 |
|
|
$('[id^=Xmove_]').click(function (event) {
|
977 |
|
|
|
978 |
f1d5b8ef
|
Phil Davis
|
// Prevent click from toggling row
|
979 |
3f597adb
|
Stephen Beaver
|
event.stopImmediatePropagation();
|
980 |
|
|
|
981 |
f1d5b8ef
|
Phil Davis
|
// Save the target rule position
|
982 |
3f597adb
|
Stephen Beaver
|
var anchor_row = $(this).parents("tr:first");
|
983 |
|
|
|
984 |
d830a7f4
|
Stephen Beaver
|
if (event.shiftKey) {
|
985 |
|
|
$($('#ruletable > tbody > tr').get().reverse()).each(function() {
|
986 |
|
|
ruleid = this.id.slice(2);
|
987 |
3f597adb
|
Stephen Beaver
|
|
988 |
d830a7f4
|
Stephen Beaver
|
if (ruleid && !isNaN(ruleid)) {
|
989 |
|
|
if ($('#frc' + ruleid).prop('checked')) {
|
990 |
|
|
// Move the selected rows, un-select them and add highlight class
|
991 |
|
|
$(this).insertAfter(anchor_row);
|
992 |
|
|
fr_toggle(ruleid, "fr");
|
993 |
|
|
$('#fr' + ruleid).addClass("highlight");
|
994 |
|
|
}
|
995 |
3f597adb
|
Stephen Beaver
|
}
|
996 |
d830a7f4
|
Stephen Beaver
|
});
|
997 |
|
|
} else {
|
998 |
|
|
$('#ruletable > tbody > tr').each(function() {
|
999 |
|
|
ruleid = this.id.slice(2);
|
1000 |
|
|
|
1001 |
|
|
if (ruleid && !isNaN(ruleid)) {
|
1002 |
|
|
if ($('#frc' + ruleid).prop('checked')) {
|
1003 |
|
|
// Move the selected rows, un-select them and add highlight class
|
1004 |
|
|
$(this).insertBefore(anchor_row);
|
1005 |
|
|
fr_toggle(ruleid, "fr");
|
1006 |
|
|
$('#fr' + ruleid).addClass("highlight");
|
1007 |
|
|
}
|
1008 |
|
|
}
|
1009 |
|
|
});
|
1010 |
|
|
}
|
1011 |
3f597adb
|
Stephen Beaver
|
|
1012 |
f1d5b8ef
|
Phil Davis
|
// Temporarily set background color so user can more easily see the moved rules, then fade
|
1013 |
4dbdb358
|
Stephen Beaver
|
$('.highlight').effect("highlight", {color: "#739b4b;"}, 4000);
|
1014 |
|
|
$('#ruletable tr').removeClass("highlight");
|
1015 |
3f597adb
|
Stephen Beaver
|
$('#order-store').removeAttr('disabled');
|
1016 |
|
|
reindex_rules($(anchor_row).parent('tbody'));
|
1017 |
|
|
dirty = true;
|
1018 |
a7893b72
|
Stephen Beaver
|
}).mouseover(function(e) {
|
1019 |
c6a8ddf8
|
Stephen Beaver
|
var ruleselected = false;
|
1020 |
|
|
|
1021 |
995454f3
|
Stephen Beaver
|
$(this).css("cursor", "default");
|
1022 |
|
|
|
1023 |
c6a8ddf8
|
Stephen Beaver
|
// Are any rules currently selected?
|
1024 |
|
|
$('[id^=frc]').each(function () {
|
1025 |
|
|
if ($(this).prop("checked")) {
|
1026 |
|
|
ruleselected = true;
|
1027 |
|
|
}
|
1028 |
|
|
});
|
1029 |
|
|
|
1030 |
fcf29c87
|
Phil Davis
|
// If so, change the icon to show the insertion point
|
1031 |
c6a8ddf8
|
Stephen Beaver
|
if (ruleselected) {
|
1032 |
|
|
if (e.shiftKey) {
|
1033 |
|
|
$(this).removeClass().addClass("fa fa-lg fa-arrow-down text-danger");
|
1034 |
|
|
} else {
|
1035 |
|
|
$(this).removeClass().addClass("fa fa-lg fa-arrow-up text-danger");
|
1036 |
|
|
}
|
1037 |
a7893b72
|
Stephen Beaver
|
}
|
1038 |
|
|
}).mouseout(function(e) {
|
1039 |
995454f3
|
Stephen Beaver
|
$(this).removeClass().addClass("fa fa-anchor");
|
1040 |
3f597adb
|
Stephen Beaver
|
});
|
1041 |
|
|
|
1042 |
52e91f70
|
PiBa-NL
|
<?php if(!isset($config['system']['webgui']['roworderdragging'])): ?>
|
1043 |
85d49326
|
Stephen Beaver
|
// Make rules sortable. Hiding the table before applying sortable, then showing it again is
|
1044 |
511053ad
|
Stephen Beaver
|
// a work-around for very slow sorting on FireFox
|
1045 |
|
|
$('table tbody.user-entries').hide();
|
1046 |
|
|
|
1047 |
ea5665c7
|
Sjon Hortensius
|
$('table tbody.user-entries').sortable({
|
1048 |
|
|
cursor: 'grabbing',
|
1049 |
7da65ab7
|
Steve Beaver
|
scroll: true,
|
1050 |
|
|
overflow: 'scroll',
|
1051 |
|
|
scrollSensitivity: 100,
|
1052 |
ea5665c7
|
Sjon Hortensius
|
update: function(event, ui) {
|
1053 |
|
|
$('#order-store').removeAttr('disabled');
|
1054 |
1f73ccba
|
Stephen Beaver
|
reindex_rules(ui.item.parent('tbody'));
|
1055 |
5d7b915d
|
Stephen Beaver
|
dirty = true;
|
1056 |
ea5665c7
|
Sjon Hortensius
|
}
|
1057 |
|
|
});
|
1058 |
|
|
|
1059 |
511053ad
|
Stephen Beaver
|
$('table tbody.user-entries').show();
|
1060 |
52e91f70
|
PiBa-NL
|
<?php endif; ?>
|
1061 |
511053ad
|
Stephen Beaver
|
|
1062 |
6cb366de
|
Stephen Beaver
|
// Check all of the rule checkboxes so that their values are posted
|
1063 |
|
|
$('#order-store').click(function () {
|
1064 |
301e4aa0
|
Stephen Beaver
|
$('[id^=frc]').prop('checked', true);
|
1065 |
|
|
|
1066 |
|
|
// Save the separator bar configuration
|
1067 |
|
|
save_separators();
|
1068 |
5d7b915d
|
Stephen Beaver
|
|
1069 |
|
|
// Suppress the "Do you really want to leave the page" message
|
1070 |
|
|
saving = true;
|
1071 |
6cb366de
|
Stephen Beaver
|
});
|
1072 |
576437f5
|
Stephen Beaver
|
|
1073 |
f1d5b8ef
|
Phil Davis
|
// Provide a warning message if the user tries to change page before saving
|
1074 |
5d7b915d
|
Stephen Beaver
|
$(window).bind('beforeunload', function(){
|
1075 |
|
|
if ((!saving && dirty) || newSeperator) {
|
1076 |
317b2852
|
NOYB
|
return ("<?=gettext('One or more rules have been moved but have not yet been saved')?>");
|
1077 |
5d7b915d
|
Stephen Beaver
|
} else {
|
1078 |
|
|
return undefined;
|
1079 |
|
|
}
|
1080 |
|
|
});
|
1081 |
d830a7f4
|
Stephen Beaver
|
|
1082 |
|
|
$(document).on('keyup keydown', function(e){
|
1083 |
|
|
if (e.shiftKey) {
|
1084 |
|
|
$('[id^=Xmove_]').attr("title", "<?=$ShXmoveTitle?>");
|
1085 |
|
|
} else {
|
1086 |
|
|
$('[id^=Xmove_]').attr("title", "<?=$XmoveTitle?>");
|
1087 |
|
|
}
|
1088 |
|
|
});
|
1089 |
e969408d
|
Steve Beaver
|
|
1090 |
|
|
$('#selectAll').click(function() {
|
1091 |
|
|
var checkedStatus = this.checked;
|
1092 |
|
|
$('#ruletable tbody tr').find('td:first :checkbox').each(function() {
|
1093 |
|
|
$(this).prop('checked', checkedStatus);
|
1094 |
|
|
});
|
1095 |
|
|
});
|
1096 |
65a0e193
|
Stephen Beaver
|
});
|
1097 |
8fd9052f
|
Colin Fleming
|
//]]>
|
1098 |
ea5665c7
|
Sjon Hortensius
|
</script>
|
1099 |
824329d2
|
Stephen Beaver
|
|
1100 |
c9d46a8e
|
Renato Botelho
|
<?php include("foot.inc");?>
|