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