1 |
d173230c
|
Seth Mos
|
<?php
|
2 |
|
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* system_gateways.php
|
4 |
|
|
*
|
5 |
|
|
* part of pfSense (https://www.pfsense.org)
|
6 |
b8f91b7c
|
Luiz Souza
|
* Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* Copyright (c) 2010 Seth Mos <seth.mos@dds.nl>
|
8 |
|
|
* All rights reserved.
|
9 |
|
|
*
|
10 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
11 |
|
|
* you may not use this file except in compliance with the License.
|
12 |
|
|
* You may obtain a copy of the License at
|
13 |
c5d81585
|
Renato Botelho
|
*
|
14 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
15 |
c5d81585
|
Renato Botelho
|
*
|
16 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
17 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
18 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19 |
|
|
* See the License for the specific language governing permissions and
|
20 |
|
|
* limitations under the License.
|
21 |
6ff05704
|
Stephen Beaver
|
*/
|
22 |
d173230c
|
Seth Mos
|
|
23 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
24 |
|
|
##|*IDENT=page-system-gateways
|
25 |
5230f468
|
jim-p
|
##|*NAME=System: Gateways
|
26 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'System: Gateways' page.
|
27 |
|
|
##|*MATCH=system_gateways.php*
|
28 |
|
|
##|-PRIV
|
29 |
|
|
|
30 |
c81ef6e2
|
Phil Davis
|
require_once("guiconfig.inc");
|
31 |
7a927e67
|
Scott Ullrich
|
require_once("functions.inc");
|
32 |
|
|
require_once("filter.inc");
|
33 |
|
|
require_once("shaper.inc");
|
34 |
43a9b03d
|
PiBa-NL
|
require_once("gwlb.inc");
|
35 |
|
|
|
36 |
|
|
$simplefields = array('defaultgw4', 'defaultgw6');
|
37 |
d173230c
|
Seth Mos
|
|
38 |
5aa0c748
|
Steve Beaver
|
if (!is_array($config['gateways'])) {
|
39 |
|
|
$config['gateways'] = array();
|
40 |
|
|
}
|
41 |
|
|
|
42 |
e0c7b2fe
|
Phil Davis
|
if (!is_array($config['gateways']['gateway_item'])) {
|
43 |
d251a8d4
|
Renato Botelho
|
$config['gateways']['gateway_item'] = array();
|
44 |
e0c7b2fe
|
Phil Davis
|
}
|
45 |
616e1956
|
Seth Mos
|
|
46 |
|
|
$a_gateway_item = &$config['gateways']['gateway_item'];
|
47 |
|
|
|
48 |
4611e283
|
Steve Beaver
|
$pconfig = $_REQUEST;
|
49 |
d173230c
|
Seth Mos
|
|
50 |
e311cb79
|
PiBa-NL
|
if ($_POST['order-store']) {
|
51 |
|
|
// Include the rules of this (the selected) interface.
|
52 |
|
|
// If a rule is not in POST[rule], it has been deleted by the user
|
53 |
|
|
$a_gateway_item_new = array();
|
54 |
|
|
//print "<pre>";
|
55 |
|
|
foreach ($_POST['row'] as $id) {
|
56 |
|
|
//print " $id";
|
57 |
|
|
$a_gateway_item_new[] = $a_gateway_item[$id];
|
58 |
|
|
}
|
59 |
|
|
//print_r($a_gateway_item);
|
60 |
|
|
//print_r($a_gateway_item_new);
|
61 |
|
|
//print "</pre>";
|
62 |
|
|
$a_gateway_item = $a_gateway_item_new;
|
63 |
|
|
//mark_subsystem_dirty('staticroutes');
|
64 |
|
|
write_config("System - Gateways: save default gateway");
|
65 |
|
|
} else if ($_POST['save']) {
|
66 |
43a9b03d
|
PiBa-NL
|
unset($input_errors);
|
67 |
|
|
$pconfig = $_POST;
|
68 |
|
|
foreach($simplefields as $field) {
|
69 |
|
|
$config['gateways'][$field] = $pconfig[$field];
|
70 |
|
|
}
|
71 |
|
|
mark_subsystem_dirty('staticroutes');
|
72 |
|
|
write_config("System - Gateways: save default gateway");
|
73 |
|
|
}
|
74 |
|
|
|
75 |
e311cb79
|
PiBa-NL
|
$a_gateways = return_gateways_array(true, false, true, true);
|
76 |
|
|
|
77 |
4611e283
|
Steve Beaver
|
if ($_POST['apply']) {
|
78 |
d173230c
|
Seth Mos
|
|
79 |
4611e283
|
Steve Beaver
|
$retval = 0;
|
80 |
d173230c
|
Seth Mos
|
|
81 |
4611e283
|
Steve Beaver
|
$retval |= system_routing_configure();
|
82 |
|
|
$retval |= system_resolvconf_generate();
|
83 |
|
|
$retval |= filter_configure();
|
84 |
|
|
/* reconfigure our gateway monitor */
|
85 |
|
|
setup_gateways_monitor();
|
86 |
|
|
/* Dynamic DNS on gw groups may have changed */
|
87 |
|
|
send_event("service reload dyndnsall");
|
88 |
d173230c
|
Seth Mos
|
|
89 |
4611e283
|
Steve Beaver
|
if ($retval == 0) {
|
90 |
|
|
clear_subsystem_dirty('staticroutes');
|
91 |
d173230c
|
Seth Mos
|
}
|
92 |
|
|
}
|
93 |
|
|
|
94 |
4611e283
|
Steve Beaver
|
|
95 |
028ff8f8
|
Phil Davis
|
function can_delete_disable_gateway_item($id, $disable = false) {
|
96 |
e97df865
|
Renato Botelho
|
global $config, $input_errors, $a_gateways;
|
97 |
d251a8d4
|
Renato Botelho
|
|
98 |
e0c7b2fe
|
Phil Davis
|
if (!isset($a_gateways[$id])) {
|
99 |
e97df865
|
Renato Botelho
|
return false;
|
100 |
e0c7b2fe
|
Phil Davis
|
}
|
101 |
e97df865
|
Renato Botelho
|
|
102 |
|
|
if (is_array($config['gateways']['gateway_group'])) {
|
103 |
|
|
foreach ($config['gateways']['gateway_group'] as $group) {
|
104 |
|
|
foreach ($group['item'] as $item) {
|
105 |
|
|
$items = explode("|", $item);
|
106 |
|
|
if ($items[0] == $a_gateways[$id]['name']) {
|
107 |
205178aa
|
Phil Davis
|
if (!$disable) {
|
108 |
762faef5
|
Phil Davis
|
$input_errors[] = sprintf(gettext('Gateway "%1$s" cannot be deleted because it is in use on Gateway Group "%2$s"'), $a_gateways[$id]['name'], $group['name']);
|
109 |
205178aa
|
Phil Davis
|
} else {
|
110 |
762faef5
|
Phil Davis
|
$input_errors[] = sprintf(gettext('Gateway "%1$s" cannot be disabled because it is in use on Gateway Group "%2$s"'), $a_gateways[$id]['name'], $group['name']);
|
111 |
028ff8f8
|
Phil Davis
|
}
|
112 |
f78302e8
|
Ermal
|
}
|
113 |
|
|
}
|
114 |
|
|
}
|
115 |
e97df865
|
Renato Botelho
|
}
|
116 |
|
|
|
117 |
|
|
if (is_array($config['staticroutes']['route'])) {
|
118 |
|
|
foreach ($config['staticroutes']['route'] as $route) {
|
119 |
|
|
if ($route['gateway'] == $a_gateways[$id]['name']) {
|
120 |
205178aa
|
Phil Davis
|
if (!$disable) {
|
121 |
028ff8f8
|
Phil Davis
|
// The user wants to delete this gateway, but there is a static route (enabled or disabled) that refers to the gateway.
|
122 |
762faef5
|
Phil Davis
|
$input_errors[] = sprintf(gettext('Gateway "%1$s" cannot be deleted because it is in use on Static Route "%2$s"'), $a_gateways[$id]['name'], $route['network']);
|
123 |
205178aa
|
Phil Davis
|
} else if (!isset($route['disabled'])) {
|
124 |
|
|
// The user wants to disable this gateway.
|
125 |
|
|
// But there is a static route that uses this gateway and is enabled (not disabled).
|
126 |
762faef5
|
Phil Davis
|
$input_errors[] = sprintf(gettext('Gateway "%1$s" cannot be disabled because it is in use on Static Route "%2$s"'), $a_gateways[$id]['name'], $route['network']);
|
127 |
028ff8f8
|
Phil Davis
|
}
|
128 |
f78302e8
|
Ermal
|
}
|
129 |
|
|
}
|
130 |
e97df865
|
Renato Botelho
|
}
|
131 |
|
|
|
132 |
e0c7b2fe
|
Phil Davis
|
if (isset($input_errors)) {
|
133 |
e97df865
|
Renato Botelho
|
return false;
|
134 |
e0c7b2fe
|
Phil Davis
|
}
|
135 |
e97df865
|
Renato Botelho
|
|
136 |
|
|
return true;
|
137 |
|
|
}
|
138 |
|
|
|
139 |
|
|
function delete_gateway_item($id) {
|
140 |
dde20226
|
Renato Botelho
|
global $config, $a_gateways;
|
141 |
|
|
|
142 |
e0c7b2fe
|
Phil Davis
|
if (!isset($a_gateways[$id])) {
|
143 |
e97df865
|
Renato Botelho
|
return;
|
144 |
e0c7b2fe
|
Phil Davis
|
}
|
145 |
32a9eb18
|
Ermal
|
|
146 |
1be1b87b
|
jim-p
|
/* If the removed gateway was the default route, remove the default route */
|
147 |
|
|
if (!empty($a_gateways[$id]) && is_ipaddr($a_gateways[$id]['gateway']) &&
|
148 |
|
|
!isset($a_gateways[$id]['disabled']) &&
|
149 |
43a9b03d
|
PiBa-NL
|
isset($a_gateways[$id]['isdefaultgw'])) {
|
150 |
1be1b87b
|
jim-p
|
$inet = (!is_ipaddrv4($a_gateways[$id]['gateway']) ? '-inet6' : '-inet');
|
151 |
43a9b03d
|
PiBa-NL
|
file_put_contents("/dev/console", "\n[".getmypid()."] DEL_GW, route= delete {$inet} default");
|
152 |
1be1b87b
|
jim-p
|
mwexec("/sbin/route delete {$inet} default");
|
153 |
|
|
}
|
154 |
|
|
|
155 |
e75f0e7d
|
PiBa-NL
|
/* NOTE: Cleanup static routes for the interface route if any */
|
156 |
d61309a0
|
Phil Davis
|
if (!empty($a_gateways[$id]) && is_ipaddr($a_gateways[$id]['gateway']) &&
|
157 |
|
|
$gateway['gateway'] != $a_gateways[$id]['gateway'] &&
|
158 |
|
|
isset($a_gateways[$id]["nonlocalgateway"])) {
|
159 |
e75f0e7d
|
PiBa-NL
|
$realif = get_real_interface($a_gateways[$id]['interface']);
|
160 |
|
|
$inet = (!is_ipaddrv4($a_gateways[$id]['gateway']) ? "-inet6" : "-inet");
|
161 |
43a9b03d
|
PiBa-NL
|
file_put_contents("/dev/console", "\n[".getmypid()."] DEL_GW, route= $inet " . escapeshellarg($a_gateways[$id]['gateway']) . " -iface " . escapeshellarg($realif));
|
162 |
e75f0e7d
|
PiBa-NL
|
$cmd = "/sbin/route delete $inet " . escapeshellarg($a_gateways[$id]['gateway']) . " -iface " . escapeshellarg($realif);
|
163 |
|
|
mwexec($cmd);
|
164 |
|
|
}
|
165 |
e97df865
|
Renato Botelho
|
/* NOTE: Cleanup static routes for the monitor ip if any */
|
166 |
|
|
if (!empty($a_gateways[$id]['monitor']) &&
|
167 |
d61309a0
|
Phil Davis
|
$a_gateways[$id]['monitor'] != "dynamic" &&
|
168 |
|
|
is_ipaddr($a_gateways[$id]['monitor']) &&
|
169 |
|
|
$a_gateways[$id]['gateway'] != $a_gateways[$id]['monitor']) {
|
170 |
e0c7b2fe
|
Phil Davis
|
if (is_ipaddrv4($a_gateways[$id]['monitor'])) {
|
171 |
e97df865
|
Renato Botelho
|
mwexec("/sbin/route delete " . escapeshellarg($a_gateways[$id]['monitor']));
|
172 |
e0c7b2fe
|
Phil Davis
|
} else {
|
173 |
e97df865
|
Renato Botelho
|
mwexec("/sbin/route delete -inet6 " . escapeshellarg($a_gateways[$id]['monitor']));
|
174 |
e0c7b2fe
|
Phil Davis
|
}
|
175 |
e97df865
|
Renato Botelho
|
}
|
176 |
|
|
|
177 |
e0c7b2fe
|
Phil Davis
|
if ($config['interfaces'][$a_gateways[$id]['friendlyiface']]['gateway'] == $a_gateways[$id]['name']) {
|
178 |
e97df865
|
Renato Botelho
|
unset($config['interfaces'][$a_gateways[$id]['friendlyiface']]['gateway']);
|
179 |
e0c7b2fe
|
Phil Davis
|
}
|
180 |
e97df865
|
Renato Botelho
|
unset($config['gateways']['gateway_item'][$a_gateways[$id]['attribute']]);
|
181 |
|
|
}
|
182 |
|
|
|
183 |
|
|
unset($input_errors);
|
184 |
4611e283
|
Steve Beaver
|
if ($_REQUEST['act'] == "del") {
|
185 |
|
|
if (can_delete_disable_gateway_item($_REQUEST['id'])) {
|
186 |
|
|
$realid = $a_gateways[$_REQUEST['id']]['attribute'];
|
187 |
|
|
delete_gateway_item($_REQUEST['id']);
|
188 |
e97df865
|
Renato Botelho
|
write_config("Gateways: removed gateway {$realid}");
|
189 |
|
|
mark_subsystem_dirty('staticroutes');
|
190 |
|
|
header("Location: system_gateways.php");
|
191 |
|
|
exit;
|
192 |
|
|
}
|
193 |
|
|
}
|
194 |
|
|
|
195 |
4611e283
|
Steve Beaver
|
if (isset($_REQUEST['del_x'])) {
|
196 |
e97df865
|
Renato Botelho
|
/* delete selected items */
|
197 |
4611e283
|
Steve Beaver
|
if (is_array($_REQUEST['rule']) && count($_REQUEST['rule'])) {
|
198 |
|
|
foreach ($_REQUEST['rule'] as $rulei) {
|
199 |
028ff8f8
|
Phil Davis
|
if (!can_delete_disable_gateway_item($rulei)) {
|
200 |
e97df865
|
Renato Botelho
|
break;
|
201 |
e0c7b2fe
|
Phil Davis
|
}
|
202 |
|
|
}
|
203 |
e97df865
|
Renato Botelho
|
|
204 |
|
|
if (!isset($input_errors)) {
|
205 |
|
|
$items_deleted = "";
|
206 |
4611e283
|
Steve Beaver
|
foreach ($_REQUEST['rule'] as $rulei) {
|
207 |
e97df865
|
Renato Botelho
|
delete_gateway_item($rulei);
|
208 |
|
|
$items_deleted .= "{$rulei} ";
|
209 |
|
|
}
|
210 |
|
|
if (!empty($items_deleted)) {
|
211 |
762faef5
|
Phil Davis
|
write_config(sprintf(gettext("Gateways: removed gateways %s", $items_deleted)));
|
212 |
e97df865
|
Renato Botelho
|
mark_subsystem_dirty('staticroutes');
|
213 |
|
|
}
|
214 |
f78302e8
|
Ermal
|
header("Location: system_gateways.php");
|
215 |
|
|
exit;
|
216 |
|
|
}
|
217 |
d173230c
|
Seth Mos
|
}
|
218 |
|
|
|
219 |
4611e283
|
Steve Beaver
|
} else if ($_REQUEST['act'] == "toggle" && $a_gateways[$_REQUEST['id']]) {
|
220 |
|
|
$realid = $a_gateways[$_REQUEST['id']]['attribute'];
|
221 |
028ff8f8
|
Phil Davis
|
$disable_gw = !isset($a_gateway_item[$realid]['disabled']);
|
222 |
|
|
if ($disable_gw) {
|
223 |
|
|
// The user wants to disable the gateway, so check if that is OK.
|
224 |
4611e283
|
Steve Beaver
|
$ok_to_toggle = can_delete_disable_gateway_item($_REQUEST['id'], $disable_gw);
|
225 |
e0c7b2fe
|
Phil Davis
|
} else {
|
226 |
028ff8f8
|
Phil Davis
|
// The user wants to enable the gateway. That is always OK.
|
227 |
|
|
$ok_to_toggle = true;
|
228 |
e0c7b2fe
|
Phil Davis
|
}
|
229 |
028ff8f8
|
Phil Davis
|
if ($ok_to_toggle) {
|
230 |
43a9b03d
|
PiBa-NL
|
gateway_set_enabled($a_gateway_item[$realid]['name'], !$disable_gw);
|
231 |
e97df865
|
Renato Botelho
|
|
232 |
028ff8f8
|
Phil Davis
|
if (write_config("Gateways: enable/disable")) {
|
233 |
|
|
mark_subsystem_dirty('staticroutes');
|
234 |
|
|
}
|
235 |
e97df865
|
Renato Botelho
|
|
236 |
028ff8f8
|
Phil Davis
|
header("Location: system_gateways.php");
|
237 |
|
|
exit;
|
238 |
|
|
}
|
239 |
e97df865
|
Renato Botelho
|
}
|
240 |
124aee67
|
Chris Buechler
|
|
241 |
43a9b03d
|
PiBa-NL
|
foreach($simplefields as $field) {
|
242 |
|
|
$pconfig[$field] = $config['gateways'][$field];
|
243 |
|
|
}
|
244 |
|
|
|
245 |
|
|
function gateway_displaygwtiername($gwname) {
|
246 |
|
|
global $config;
|
247 |
|
|
$gw = lookup_gateway_or_group_by_name($gwname);
|
248 |
|
|
if ($config['gateways']['defaultgw4'] == $gwname || $config['gateways']['defaultgw6'] == $gwname) {
|
249 |
|
|
$result = "Default";
|
250 |
|
|
} else {
|
251 |
|
|
if ($gw['ipprotocol'] == 'inet') {
|
252 |
|
|
$defgw = lookup_gateway_or_group_by_name($config['gateways']['defaultgw4']);
|
253 |
|
|
} else {
|
254 |
|
|
$defgw = lookup_gateway_or_group_by_name($config['gateways']['defaultgw6']);
|
255 |
|
|
}
|
256 |
|
|
if ($defgw['type'] == "gatewaygroup") {
|
257 |
|
|
$detail = gateway_is_gwgroup_member($gwname, true);
|
258 |
|
|
foreach($detail as $gwitem) {
|
259 |
|
|
if ($gwitem['name'] == $defgw['name']) {
|
260 |
|
|
if (isset($gwitem['tier'])) {
|
261 |
|
|
$result = "Tier " . $gwitem['tier'];
|
262 |
|
|
break;
|
263 |
|
|
}
|
264 |
|
|
}
|
265 |
|
|
}
|
266 |
|
|
}
|
267 |
|
|
}
|
268 |
|
|
if (!empty($result)) {
|
269 |
e311cb79
|
PiBa-NL
|
if ($gw['ipprotocol'] == "inet") {
|
270 |
|
|
$result .= " (IPv4)";
|
271 |
|
|
} elseif ($gw['ipprotocol'] == "inet6") {
|
272 |
|
|
$result .= " (IPv6)";
|
273 |
|
|
}
|
274 |
43a9b03d
|
PiBa-NL
|
}
|
275 |
|
|
return $result;
|
276 |
|
|
}
|
277 |
|
|
|
278 |
d036bc07
|
Stephen Beaver
|
$pgtitle = array(gettext("System"), gettext("Routing"), gettext("Gateways"));
|
279 |
edcd7535
|
Phil Davis
|
$pglinks = array("", "@self", "@self");
|
280 |
b32dd0a6
|
jim-p
|
$shortcut_section = "gateways";
|
281 |
02ca24c9
|
jim-p
|
|
282 |
d173230c
|
Seth Mos
|
include("head.inc");
|
283 |
|
|
|
284 |
d61309a0
|
Phil Davis
|
if ($input_errors) {
|
285 |
c3c692a9
|
Sjon Hortensius
|
print_input_errors($input_errors);
|
286 |
d61309a0
|
Phil Davis
|
}
|
287 |
44c42356
|
Phil Davis
|
|
288 |
|
|
if ($_POST['apply']) {
|
289 |
|
|
print_apply_result_box($retval);
|
290 |
d61309a0
|
Phil Davis
|
}
|
291 |
f74457df
|
Stephen Beaver
|
|
292 |
d61309a0
|
Phil Davis
|
if (is_subsystem_dirty('staticroutes')) {
|
293 |
7fdca5ff
|
NOYB
|
print_apply_box(gettext("The gateway configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
|
294 |
d61309a0
|
Phil Davis
|
}
|
295 |
c3c692a9
|
Sjon Hortensius
|
|
296 |
|
|
$tab_array = array();
|
297 |
|
|
$tab_array[0] = array(gettext("Gateways"), true, "system_gateways.php");
|
298 |
80b4d0c5
|
heper
|
$tab_array[1] = array(gettext("Static Routes"), false, "system_routes.php");
|
299 |
|
|
$tab_array[2] = array(gettext("Gateway Groups"), false, "system_gateway_groups.php");
|
300 |
c3c692a9
|
Sjon Hortensius
|
display_top_tabs($tab_array);
|
301 |
d173230c
|
Seth Mos
|
|
302 |
d251a8d4
|
Renato Botelho
|
?>
|
303 |
e311cb79
|
PiBa-NL
|
<form method="post">
|
304 |
060ed238
|
Stephen Beaver
|
<div class="panel panel-default">
|
305 |
|
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Gateways')?></h2></div>
|
306 |
|
|
<div class="panel-body">
|
307 |
|
|
<div class="table-responsive">
|
308 |
e311cb79
|
PiBa-NL
|
<table id="gateways" class="table table-striped table-hover table-condensed table-rowdblclickedit">
|
309 |
060ed238
|
Stephen Beaver
|
<thead>
|
310 |
|
|
<tr>
|
311 |
e311cb79
|
PiBa-NL
|
<th></th>
|
312 |
060ed238
|
Stephen Beaver
|
<th></th>
|
313 |
|
|
<th><?=gettext("Name")?></th>
|
314 |
43a9b03d
|
PiBa-NL
|
<th><?=gettext("Default")?></th>
|
315 |
060ed238
|
Stephen Beaver
|
<th><?=gettext("Interface")?></th>
|
316 |
|
|
<th><?=gettext("Gateway")?></th>
|
317 |
|
|
<th><?=gettext("Monitor IP")?></th>
|
318 |
|
|
<th><?=gettext("Description")?></th>
|
319 |
|
|
<th><?=gettext("Actions")?></th>
|
320 |
|
|
</tr>
|
321 |
|
|
</thead>
|
322 |
|
|
<tbody>
|
323 |
e97df865
|
Renato Botelho
|
<?php
|
324 |
c3c692a9
|
Sjon Hortensius
|
foreach ($a_gateways as $i => $gateway):
|
325 |
d61309a0
|
Phil Davis
|
if (isset($gateway['inactive'])) {
|
326 |
1b7379f9
|
Jared Dillard
|
$icon = 'fa-times-circle-o';
|
327 |
d61309a0
|
Phil Davis
|
} elseif (isset($gateway['disabled'])) {
|
328 |
1b7379f9
|
Jared Dillard
|
$icon = 'fa-ban';
|
329 |
d61309a0
|
Phil Davis
|
} else {
|
330 |
1b7379f9
|
Jared Dillard
|
$icon = 'fa-check-circle-o';
|
331 |
d61309a0
|
Phil Davis
|
}
|
332 |
c3c692a9
|
Sjon Hortensius
|
|
333 |
d61309a0
|
Phil Davis
|
if (isset($gateway['inactive'])) {
|
334 |
c3c692a9
|
Sjon Hortensius
|
$title = gettext("This gateway is inactive because interface is missing");
|
335 |
d61309a0
|
Phil Davis
|
} else {
|
336 |
c3c692a9
|
Sjon Hortensius
|
$title = '';
|
337 |
d61309a0
|
Phil Davis
|
}
|
338 |
e311cb79
|
PiBa-NL
|
$id = $gateway['attribute'];
|
339 |
e97df865
|
Renato Botelho
|
?>
|
340 |
e311cb79
|
PiBa-NL
|
<tr<?=($icon != 'fa-check-circle-o')? ' class="disabled"' : ''?> onClick="fr_toggle(<?=$id;?>)" id="fr<?=$id;?>">
|
341 |
|
|
<td style="white-space: nowrap;">
|
342 |
|
|
<?php
|
343 |
|
|
if (is_numeric($id)) :?>
|
344 |
|
|
<input type='checkbox' id='frc<?=$id?>' onClick='fr_toggle(<?=$id?>)' name='row[]' value='<?=$id?>'/>
|
345 |
|
|
<a class='fa fa-anchor' id='Xmove_<?=$id?>' title='"<?=gettext("Move checked entries to here")?>"'></a>
|
346 |
|
|
<?php endif; ?>
|
347 |
|
|
</td>
|
348 |
060ed238
|
Stephen Beaver
|
<td title="<?=$title?>"><i class="fa <?=$icon?>"></i></td>
|
349 |
|
|
<td>
|
350 |
|
|
<?=htmlspecialchars($gateway['name'])?>
|
351 |
e97df865
|
Renato Botelho
|
<?php
|
352 |
43a9b03d
|
PiBa-NL
|
if (isset($gateway['isdefaultgw'])) {
|
353 |
|
|
echo " <strong>(default)</strong>";
|
354 |
|
|
}
|
355 |
e97df865
|
Renato Botelho
|
?>
|
356 |
060ed238
|
Stephen Beaver
|
</td>
|
357 |
43a9b03d
|
PiBa-NL
|
<td>
|
358 |
|
|
<?=gateway_displaygwtiername($gateway['name'])?>
|
359 |
|
|
</td>
|
360 |
060ed238
|
Stephen Beaver
|
<td>
|
361 |
|
|
<?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($gateway['friendlyiface']))?>
|
362 |
|
|
</td>
|
363 |
|
|
<td>
|
364 |
|
|
<?=htmlspecialchars($gateway['gateway'])?>
|
365 |
|
|
</td>
|
366 |
|
|
<td>
|
367 |
|
|
<?=htmlspecialchars($gateway['monitor'])?>
|
368 |
|
|
</td>
|
369 |
|
|
<td>
|
370 |
|
|
<?=htmlspecialchars($gateway['descr'])?>
|
371 |
|
|
</td>
|
372 |
e311cb79
|
PiBa-NL
|
<td style="white-space: nowrap;">
|
373 |
4611e283
|
Steve Beaver
|
<a href="system_gateways_edit.php?id=<?=$i?>" class="fa fa-pencil" title="<?=gettext('Edit gateway');?>"></a>
|
374 |
|
|
<a href="system_gateways_edit.php?dup=<?=$i?>" class="fa fa-clone" title="<?=gettext('Copy gateway')?>"></a>
|
375 |
f74457df
|
Stephen Beaver
|
|
376 |
fa172bc5
|
NewEraCracker
|
<?php if (is_numeric($gateway['attribute'])): ?>
|
377 |
1629e8ea
|
heper
|
<?php if (isset($gateway['disabled'])) {
|
378 |
f74457df
|
Stephen Beaver
|
?>
|
379 |
a04f6658
|
Steve Beaver
|
<a href="?act=toggle&id=<?=$i?>" class="fa fa-check-square-o" title="<?=gettext('Enable gateway')?>" usepost></a>
|
380 |
1629e8ea
|
heper
|
<?php } else {
|
381 |
|
|
?>
|
382 |
a04f6658
|
Steve Beaver
|
<a href="?act=toggle&id=<?=$i?>" class="fa fa-ban" title="<?=gettext('Disable gateway')?>" usepost></a>
|
383 |
1629e8ea
|
heper
|
<?php }
|
384 |
f74457df
|
Stephen Beaver
|
?>
|
385 |
a04f6658
|
Steve Beaver
|
<a href="system_gateways.php?act=del&id=<?=$i?>" class="fa fa-trash" title="<?=gettext('Delete gateway')?>" usepost></a>
|
386 |
f74457df
|
Stephen Beaver
|
|
387 |
fa172bc5
|
NewEraCracker
|
<?php endif; ?>
|
388 |
060ed238
|
Stephen Beaver
|
</td>
|
389 |
|
|
</tr>
|
390 |
fa172bc5
|
NewEraCracker
|
<?php endforeach; ?>
|
391 |
060ed238
|
Stephen Beaver
|
</tbody>
|
392 |
|
|
</table>
|
393 |
|
|
</div>
|
394 |
|
|
</div>
|
395 |
|
|
</div>
|
396 |
c3c692a9
|
Sjon Hortensius
|
|
397 |
c10cb196
|
Stephen Beaver
|
<nav class="action-buttons">
|
398 |
e311cb79
|
PiBa-NL
|
<button type="submit" id="order-store" name="order-store" class="btn btn-sm btn-primary" value="store changes" disabled title="<?=gettext('Save rule order')?>">
|
399 |
|
|
<i class="fa fa-save icon-embed-btn"></i>
|
400 |
|
|
<?=gettext("Save")?>
|
401 |
|
|
</button>
|
402 |
4611e283
|
Steve Beaver
|
<a href="system_gateways_edit.php" role="button" class="btn btn-success">
|
403 |
9d5a20cf
|
heper
|
<i class="fa fa-plus icon-embed-btn"></i>
|
404 |
f74457df
|
Stephen Beaver
|
<?=gettext("Add");?>
|
405 |
c3c692a9
|
Sjon Hortensius
|
</a>
|
406 |
|
|
</nav>
|
407 |
e311cb79
|
PiBa-NL
|
</form>
|
408 |
e97df865
|
Renato Botelho
|
<?php
|
409 |
c3c692a9
|
Sjon Hortensius
|
|
410 |
43a9b03d
|
PiBa-NL
|
$form = new Form;
|
411 |
|
|
$section = new Form_Section('Default gateway');
|
412 |
|
|
|
413 |
|
|
$items4 = array();
|
414 |
|
|
$items6 = array();
|
415 |
e311cb79
|
PiBa-NL
|
$items4[''] = "Automatic";
|
416 |
|
|
$items6[''] = "Automatic";
|
417 |
43a9b03d
|
PiBa-NL
|
foreach($a_gateways as $gw) {
|
418 |
|
|
$gwn = $gw['name'];
|
419 |
|
|
if ($gw['ipprotocol'] == "inet6") {
|
420 |
|
|
$items6[$gwn] = $gwn;
|
421 |
|
|
} else {
|
422 |
|
|
$items4[$gwn] = $gwn;
|
423 |
|
|
}
|
424 |
|
|
}
|
425 |
|
|
$groups = return_gateway_groups_array();
|
426 |
|
|
foreach ($groups as $key => $group) {
|
427 |
|
|
$gwn = $group['descr'];
|
428 |
|
|
if ($group['ipprotocol'] == "inet6") {
|
429 |
|
|
$items6[$key] = "$key ($gwn)";
|
430 |
|
|
} else {
|
431 |
|
|
$items4[$key] = "$key ($gwn)";
|
432 |
|
|
}
|
433 |
|
|
}
|
434 |
e311cb79
|
PiBa-NL
|
$items4['-'] = "None";
|
435 |
|
|
$items6['-'] = "None";
|
436 |
43a9b03d
|
PiBa-NL
|
|
437 |
|
|
$section->addInput(new Form_Select(
|
438 |
|
|
'defaultgw4',
|
439 |
|
|
'Default gateway IPv4',
|
440 |
|
|
$pconfig['defaultgw4'],
|
441 |
|
|
$items4
|
442 |
|
|
))->setHelp('Select the gateway or gatewaygroup to use as the default gateway.');
|
443 |
|
|
|
444 |
|
|
$section->addInput(new Form_Select(
|
445 |
|
|
'defaultgw6',
|
446 |
|
|
'Default gateway IPv6',
|
447 |
|
|
$pconfig['defaultgw6'],
|
448 |
|
|
$items6
|
449 |
|
|
))->setHelp('Select the gateway or gatewaygroup to use as the default gateway.');
|
450 |
|
|
|
451 |
|
|
$form->add($section);
|
452 |
|
|
print $form;
|
453 |
|
|
|
454 |
e311cb79
|
PiBa-NL
|
?>
|
455 |
|
|
<script type="text/javascript">
|
456 |
|
|
//<![CDATA[
|
457 |
|
|
events.push(function() {
|
458 |
|
|
$('#order-store').click(function () {
|
459 |
|
|
// Check all of the rule checkboxes so that their values are posted
|
460 |
|
|
$('[id^=frc]').prop('checked', true);
|
461 |
|
|
});
|
462 |
|
|
|
463 |
|
|
$('[id^=Xmove_]').click(function (event) {
|
464 |
|
|
// anchor click to move gateways around..
|
465 |
|
|
moveRowUpAboveAnchor(event.target.id.slice(6),"gateways");
|
466 |
|
|
return false;
|
467 |
|
|
});
|
468 |
|
|
$('[id^=Xmove_]').css('cursor', 'pointer');
|
469 |
|
|
});
|
470 |
|
|
function moveRowUpAboveAnchor(rowId, tableId) {
|
471 |
|
|
var table = $('#'+tableId);
|
472 |
|
|
var viewcheckboxes = $('[id^=frc]input:checked', table);
|
473 |
|
|
var rowview = $("#fr" + rowId, table);
|
474 |
|
|
var moveabove = rowview;
|
475 |
|
|
//var parent = moveabove[0].parentNode;
|
476 |
|
|
|
477 |
|
|
viewcheckboxes.each(function( index ) {
|
478 |
|
|
var moveid = this.value;
|
479 |
|
|
console.log( index + ": " + this.id );
|
480 |
|
|
|
481 |
|
|
var prevrowview = $("#fr" + moveid, table);
|
482 |
|
|
prevrowview.insertBefore(moveabove);
|
483 |
|
|
$('#order-store').removeAttr('disabled');
|
484 |
|
|
});
|
485 |
|
|
}
|
486 |
|
|
//]]>
|
487 |
|
|
</script>
|
488 |
|
|
|
489 |
|
|
<?php include("foot.inc");
|