1 |
5b237745
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
|
|
system_routes_edit.php
|
4 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
5 |
|
|
|
6 |
|
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
7 |
38936dc7
|
Ermal Lu?i
|
Copyright (C) 2010 Scott Ullrich
|
8 |
5b237745
|
Scott Ullrich
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
|
|
|
20 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
1d333258
|
Scott Ullrich
|
/*
|
32 |
|
|
pfSense_MODULE: routing
|
33 |
|
|
*/
|
34 |
5b237745
|
Scott Ullrich
|
|
35 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
36 |
|
|
##|*IDENT=page-system-staticroutes-editroute
|
37 |
|
|
##|*NAME=System: Static Routes: Edit route page
|
38 |
|
|
##|*DESCR=Allow access to the 'System: Static Routes: Edit route' page.
|
39 |
|
|
##|*MATCH=system_routes_edit.php*
|
40 |
|
|
##|-PRIV
|
41 |
|
|
|
42 |
4504a769
|
Ermal Lu?i
|
function staticroutecmp($a, $b) {
|
43 |
|
|
return strcmp($a['network'], $b['network']);
|
44 |
|
|
}
|
45 |
|
|
|
46 |
0d64af59
|
Ermal Lu?i
|
function staticroutes_sort() {
|
47 |
|
|
global $g, $config;
|
48 |
|
|
|
49 |
|
|
if (!is_array($config['staticroutes']['route']))
|
50 |
|
|
return;
|
51 |
|
|
|
52 |
|
|
usort($config['staticroutes']['route'], "staticroutecmp");
|
53 |
|
|
}
|
54 |
6b07c15a
|
Matthew Grooms
|
|
55 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
56 |
|
|
|
57 |
|
|
if (!is_array($config['staticroutes']['route']))
|
58 |
|
|
$config['staticroutes']['route'] = array();
|
59 |
|
|
|
60 |
|
|
$a_routes = &$config['staticroutes']['route'];
|
61 |
6fdea6a2
|
smos
|
$a_gateways = return_gateways_array(true, true);
|
62 |
5b237745
|
Scott Ullrich
|
|
63 |
|
|
$id = $_GET['id'];
|
64 |
|
|
if (isset($_POST['id']))
|
65 |
|
|
$id = $_POST['id'];
|
66 |
|
|
|
67 |
18f7352b
|
Seth Mos
|
if (isset($_GET['dup'])) {
|
68 |
|
|
$id = $_GET['dup'];
|
69 |
|
|
}
|
70 |
|
|
|
71 |
5b237745
|
Scott Ullrich
|
if (isset($id) && $a_routes[$id]) {
|
72 |
|
|
list($pconfig['network'],$pconfig['network_subnet']) =
|
73 |
|
|
explode('/', $a_routes[$id]['network']);
|
74 |
|
|
$pconfig['gateway'] = $a_routes[$id]['gateway'];
|
75 |
|
|
$pconfig['descr'] = $a_routes[$id]['descr'];
|
76 |
bfe407e5
|
Warren Baker
|
$pconfig['disabled'] = isset($a_routes[$id]['disabled']);
|
77 |
5b237745
|
Scott Ullrich
|
}
|
78 |
|
|
|
79 |
18f7352b
|
Seth Mos
|
if (isset($_GET['dup']))
|
80 |
|
|
unset($id);
|
81 |
|
|
|
82 |
5b237745
|
Scott Ullrich
|
if ($_POST) {
|
83 |
|
|
|
84 |
|
|
unset($input_errors);
|
85 |
|
|
$pconfig = $_POST;
|
86 |
|
|
|
87 |
|
|
/* input validation */
|
88 |
dde169d9
|
Vinicius Coque
|
$reqdfields = explode(" ", "network network_subnet gateway");
|
89 |
38fb1109
|
Vinicius Coque
|
$reqdfieldsn = explode(",",
|
90 |
|
|
gettext("Destination network") . "," .
|
91 |
|
|
gettext("Destination network bit count") . "," .
|
92 |
|
|
gettext("Gateway"));
|
93 |
5b237745
|
Scott Ullrich
|
|
94 |
|
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
95 |
|
|
|
96 |
f898c1a9
|
jim-p
|
if (($_POST['network'] && !is_ipaddr($_POST['network']) && !is_alias($_POST['network']))) {
|
97 |
ad700f39
|
Seth Mos
|
$input_errors[] = gettext("A valid IPv4 or IPv6 destination network must be specified.");
|
98 |
5b237745
|
Scott Ullrich
|
}
|
99 |
|
|
if (($_POST['network_subnet'] && !is_numeric($_POST['network_subnet']))) {
|
100 |
169e0008
|
Carlos Eduardo Ramos
|
$input_errors[] = gettext("A valid destination network bit count must be specified.");
|
101 |
5b237745
|
Scott Ullrich
|
}
|
102 |
ad700f39
|
Seth Mos
|
if (($_POST['gateway']) && is_ipaddr($_POST['network'])) {
|
103 |
a529aced
|
Ermal
|
if (!isset($a_gateways[$_POST['gateway']]))
|
104 |
169e0008
|
Carlos Eduardo Ramos
|
$input_errors[] = gettext("A valid gateway must be specified.");
|
105 |
1831a00d
|
Seth Mos
|
if(!validate_address_family($_POST['network'], lookup_gateway_ip_by_name($_POST['gateway'])))
|
106 |
|
|
$input_errors[] = gettext("The gateway '{$a_gateways[$_POST['gateway']]['gateway']}' is a different Address Family as network '{$_POST['network']}'.");
|
107 |
5b237745
|
Scott Ullrich
|
}
|
108 |
|
|
|
109 |
|
|
/* check for overlaps */
|
110 |
f898c1a9
|
jim-p
|
$current_targets = get_staticroutes(true);
|
111 |
|
|
$new_targets = array();
|
112 |
14f565b4
|
Seth Mos
|
if(is_ipaddrv6($_POST['network'])) {
|
113 |
|
|
$osn = Net_IPv6::compress(gen_subnetv6($_POST['network'], $_POST['network_subnet'])) . "/" . $_POST['network_subnet'];
|
114 |
f898c1a9
|
jim-p
|
$new_targets[] = $osn;
|
115 |
14f565b4
|
Seth Mos
|
}
|
116 |
71f4a2b7
|
smos
|
if (is_ipaddrv4($_POST['network'])) {
|
117 |
1831a00d
|
Seth Mos
|
if($_POST['network_subnet'] > 32)
|
118 |
|
|
$input_errors[] = gettext("A IPv4 subnet can not be over 32 bits.");
|
119 |
f898c1a9
|
jim-p
|
else {
|
120 |
1831a00d
|
Seth Mos
|
$osn = gen_subnet($_POST['network'], $_POST['network_subnet']) . "/" . $_POST['network_subnet'];
|
121 |
f898c1a9
|
jim-p
|
$new_targets[] = $osn;
|
122 |
|
|
}
|
123 |
|
|
} elseif (is_alias($_POST['network'])) {
|
124 |
|
|
$osn = $_POST['network'];
|
125 |
|
|
foreach (filter_expand_alias_array($_POST['network']) as $tgt) {
|
126 |
|
|
if (is_ipaddr($tgt))
|
127 |
|
|
$tgt .= "/32";
|
128 |
71f4a2b7
|
smos
|
if (is_ipaddr($tgt))
|
129 |
|
|
$tgt .= "/128";
|
130 |
f898c1a9
|
jim-p
|
if (!is_subnet($tgt))
|
131 |
|
|
continue;
|
132 |
06392e40
|
jim-p
|
if (!is_subnetv6($tgt))
|
133 |
71f4a2b7
|
smos
|
continue;
|
134 |
f898c1a9
|
jim-p
|
$new_targets[] = $tgt;
|
135 |
|
|
}
|
136 |
14f565b4
|
Seth Mos
|
}
|
137 |
f898c1a9
|
jim-p
|
if (!isset($id))
|
138 |
|
|
$id = count($a_routes);
|
139 |
|
|
$oroute = $a_routes[$id];
|
140 |
71f4a2b7
|
smos
|
$old_targets = array();
|
141 |
f898c1a9
|
jim-p
|
if (!empty($oroute)) {
|
142 |
|
|
if (is_alias($oroute['network'])) {
|
143 |
|
|
foreach (filter_expand_alias_array($oroute['network']) as $tgt) {
|
144 |
|
|
if (is_ipaddr($tgt))
|
145 |
|
|
$tgt .= "/32";
|
146 |
|
|
if (!is_subnet($tgt))
|
147 |
|
|
continue;
|
148 |
|
|
$old_targets[] = $tgt;
|
149 |
|
|
}
|
150 |
|
|
} else {
|
151 |
|
|
$old_targets[] = $oroute['network'];
|
152 |
5b237745
|
Scott Ullrich
|
}
|
153 |
|
|
}
|
154 |
|
|
|
155 |
f898c1a9
|
jim-p
|
$overlaps = array_intersect($current_targets, $new_targets);
|
156 |
|
|
$overlaps = array_diff($overlaps, $old_targets);
|
157 |
|
|
if (count($overlaps)) {
|
158 |
|
|
$input_errors[] = gettext("A route to these destination networks already exists") . ": " . implode(", ", $overlaps);
|
159 |
|
|
}
|
160 |
|
|
|
161 |
5b237745
|
Scott Ullrich
|
if (!$input_errors) {
|
162 |
|
|
$route = array();
|
163 |
|
|
$route['network'] = $osn;
|
164 |
|
|
$route['gateway'] = $_POST['gateway'];
|
165 |
|
|
$route['descr'] = $_POST['descr'];
|
166 |
bfe407e5
|
Warren Baker
|
if ($_POST['disabled'])
|
167 |
|
|
$route['disabled'] = true;
|
168 |
|
|
else
|
169 |
|
|
unset($route['disabled']);
|
170 |
5b237745
|
Scott Ullrich
|
|
171 |
f898c1a9
|
jim-p
|
if (file_exists("{$g['tmp_path']}/.system_routes.apply"))
|
172 |
|
|
$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.system_routes.apply"));
|
173 |
|
|
else
|
174 |
|
|
$toapplylist = array();
|
175 |
e8471084
|
Ermal
|
$a_routes[$id] = $route;
|
176 |
|
|
|
177 |
|
|
if (!empty($oroute)) {
|
178 |
f898c1a9
|
jim-p
|
$delete_targets = array_diff($old_targets, $new_targets);
|
179 |
|
|
if (count($delete_targets))
|
180 |
|
|
foreach ($delete_targets as $dts) {
|
181 |
|
|
if(is_ipaddrv6($dts))
|
182 |
|
|
$family = "-inet6";
|
183 |
|
|
$toapplylist[] = "/sbin/route delete {$family} {$dts}";
|
184 |
|
|
}
|
185 |
e8471084
|
Ermal
|
}
|
186 |
|
|
file_put_contents("{$g['tmp_path']}/.system_routes.apply", serialize($toapplylist));
|
187 |
0e3aa71c
|
Erik Fonnesbeck
|
staticroutes_sort();
|
188 |
5b237745
|
Scott Ullrich
|
|
189 |
a368a026
|
Ermal Lu?i
|
mark_subsystem_dirty('staticroutes');
|
190 |
5b237745
|
Scott Ullrich
|
|
191 |
|
|
write_config();
|
192 |
|
|
|
193 |
|
|
header("Location: system_routes.php");
|
194 |
|
|
exit;
|
195 |
|
|
}
|
196 |
|
|
}
|
197 |
4df96eff
|
Scott Ullrich
|
|
198 |
169e0008
|
Carlos Eduardo Ramos
|
$pgtitle = array(gettext("System"),gettext("Static Routes"),gettext("Edit route"));
|
199 |
b32dd0a6
|
jim-p
|
$shortcut_section = "routing";
|
200 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
201 |
5b237745
|
Scott Ullrich
|
?>
|
202 |
4df96eff
|
Scott Ullrich
|
|
203 |
5b237745
|
Scott Ullrich
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
204 |
87744d53
|
Darren Embry
|
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
|
205 |
f898c1a9
|
jim-p
|
<script type="text/javascript" src="/javascript/autosuggest.js">
|
206 |
|
|
</script>
|
207 |
|
|
<script type="text/javascript" src="/javascript/suggestions.js">
|
208 |
|
|
</script>
|
209 |
|
|
<?php include("fbegin.inc");?>
|
210 |
5b237745
|
Scott Ullrich
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
211 |
|
|
<form action="system_routes_edit.php" method="post" name="iform" id="iform">
|
212 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
213 |
0cece4a2
|
Scott Ullrich
|
<tr>
|
214 |
169e0008
|
Carlos Eduardo Ramos
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit route entry"); ?></td>
|
215 |
0cece4a2
|
Scott Ullrich
|
</tr>
|
216 |
5b237745
|
Scott Ullrich
|
<tr>
|
217 |
169e0008
|
Carlos Eduardo Ramos
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination network"); ?></td>
|
218 |
5b237745
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
219 |
f898c1a9
|
jim-p
|
<input name="network" type="text" class="formfldalias ipv4v6" id="network" size="20" value="<?=htmlspecialchars($pconfig['network']);?>">
|
220 |
5b237745
|
Scott Ullrich
|
/
|
221 |
87744d53
|
Darren Embry
|
<select name="network_subnet" class="formselect ipv4v6" id="network_subnet"
|
222 |
bb5a2d0e
|
Seth Mos
|
<?php
|
223 |
3d36f9d1
|
smos
|
for ($i = 129; $i >= 1; $i--): ?>
|
224 |
5b237745
|
Scott Ullrich
|
<option value="<?=$i;?>" <?php if ($i == $pconfig['network_subnet']) echo "selected"; ?>>
|
225 |
|
|
<?=$i;?>
|
226 |
|
|
</option>
|
227 |
|
|
<?php endfor; ?>
|
228 |
|
|
</select>
|
229 |
169e0008
|
Carlos Eduardo Ramos
|
<br> <span class="vexpl"><?=gettext("Destination network for this static route"); ?></span></td>
|
230 |
5b237745
|
Scott Ullrich
|
</tr>
|
231 |
300e2c0b
|
Vinicius Coque
|
<tr>
|
232 |
169e0008
|
Carlos Eduardo Ramos
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Gateway"); ?></td>
|
233 |
d173230c
|
Seth Mos
|
<td width="78%" class="vtable">
|
234 |
38936dc7
|
Ermal Lu?i
|
<select name="gateway" id="gateway" class="formselect">
|
235 |
d173230c
|
Seth Mos
|
<?php
|
236 |
a529aced
|
Ermal
|
foreach ($a_gateways as $gateway) {
|
237 |
a63d867a
|
Ermal
|
echo "<option value='{$gateway['name']}' ";
|
238 |
|
|
if ($gateway['name'] == $pconfig['gateway'])
|
239 |
|
|
echo "selected";
|
240 |
189ceb32
|
Chris Buechler
|
echo ">" . htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']) . "</option>\n";
|
241 |
a529aced
|
Ermal
|
}
|
242 |
|
|
?>
|
243 |
38936dc7
|
Ermal Lu?i
|
</select> <br />
|
244 |
|
|
<div id='addgwbox'>
|
245 |
ea53e38f
|
Renato Botelho
|
<?=gettext("Choose which gateway this route applies to or"); ?> <a OnClick="show_add_gateway();" href="#"><?=gettext("add a new one.");?></a>
|
246 |
38936dc7
|
Ermal Lu?i
|
</div>
|
247 |
|
|
<div id='notebox'>
|
248 |
|
|
</div>
|
249 |
|
|
<div style="display:none" name ="status" id="status">
|
250 |
|
|
</div>
|
251 |
|
|
<div style="display:none" id="addgateway" name="addgateway">
|
252 |
|
|
<p>
|
253 |
|
|
<table border="1" style="background:#990000; border-style: none none none none; width:225px;"><tr><td>
|
254 |
|
|
<table bgcolor="#990000" cellpadding="1" cellspacing="1">
|
255 |
|
|
<tr><td> </td>
|
256 |
|
|
<tr>
|
257 |
ea53e38f
|
Renato Botelho
|
<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></b></center></td>
|
258 |
38936dc7
|
Ermal Lu?i
|
</tr>
|
259 |
|
|
<tr><td> </td>
|
260 |
|
|
<tr>
|
261 |
a980df9c
|
Ermal
|
<td width="45%" align="right"><font color="white"><?=gettext("Default gateway:"); ?></td><td><input type="checkbox" id="defaultgw" name="defaultgw"></td>
|
262 |
38936dc7
|
Ermal Lu?i
|
</tr>
|
263 |
|
|
<tr>
|
264 |
ea53e38f
|
Renato Botelho
|
<td width="45%" align="right"><font color="white"><?=gettext("Interface:"); ?></td>
|
265 |
38936dc7
|
Ermal Lu?i
|
<td><select name="addinterfacegw" id="addinterfacegw">
|
266 |
|
|
<?php $gwifs = get_configured_interface_with_descr();
|
267 |
|
|
foreach($gwifs as $fif => $dif)
|
268 |
|
|
echo "<option value=\"{$fif}\">{$dif}</option>\n";
|
269 |
|
|
?>
|
270 |
|
|
</select></td>
|
271 |
|
|
</tr>
|
272 |
|
|
<tr>
|
273 |
ea53e38f
|
Renato Botelho
|
<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="GW"></td>
|
274 |
38936dc7
|
Ermal Lu?i
|
</tr>
|
275 |
|
|
<tr>
|
276 |
ea53e38f
|
Renato Botelho
|
<td align="right"><font color="white"><?=gettext("Gateway IP:"); ?></td><td><input id="gatewayip" name="gatewayip"></td>
|
277 |
38936dc7
|
Ermal Lu?i
|
</tr>
|
278 |
|
|
<tr>
|
279 |
ea53e38f
|
Renato Botelho
|
<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td>
|
280 |
38936dc7
|
Ermal Lu?i
|
</tr>
|
281 |
|
|
<tr><td> </td>
|
282 |
|
|
<tr>
|
283 |
|
|
<td colspan="2">
|
284 |
|
|
<center>
|
285 |
|
|
<div id='savebuttondiv'>
|
286 |
|
|
<input type="hidden" name="addrtype" id="addrtype" value="IPv4" />
|
287 |
169e0008
|
Carlos Eduardo Ramos
|
<input id="gwsave" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave();'>
|
288 |
|
|
<input id="gwcancel" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway();'>
|
289 |
38936dc7
|
Ermal Lu?i
|
</div>
|
290 |
|
|
</center>
|
291 |
|
|
</td>
|
292 |
|
|
</tr>
|
293 |
|
|
<tr><td> </td>
|
294 |
|
|
</table>
|
295 |
|
|
</td></tr></table>
|
296 |
|
|
<p/>
|
297 |
|
|
</div>
|
298 |
5b237745
|
Scott Ullrich
|
</tr>
|
299 |
bfe407e5
|
Warren Baker
|
<tr>
|
300 |
|
|
<td width="22%" valign="top" class="vncell"><?=gettext("Disabled");?></td>
|
301 |
|
|
<td width="78%" class="vtable">
|
302 |
|
|
<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
|
303 |
|
|
<strong><?=gettext("Disable this static route");?></strong><br />
|
304 |
|
|
<span class="vexpl"><?=gettext("Set this option to disable this static route without removing it from the list.");?></span>
|
305 |
|
|
</td>
|
306 |
|
|
</tr>
|
307 |
d173230c
|
Seth Mos
|
<tr>
|
308 |
169e0008
|
Carlos Eduardo Ramos
|
<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
|
309 |
5b237745
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
310 |
b5c78501
|
Seth Mos
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
|
311 |
ea53e38f
|
Renato Botelho
|
<br> <span class="vexpl"><?=gettext("You may enter a description here for your reference (not parsed)."); ?></span></td>
|
312 |
5b237745
|
Scott Ullrich
|
</tr>
|
313 |
|
|
<tr>
|
314 |
|
|
<td width="22%" valign="top"> </td>
|
315 |
|
|
<td width="78%">
|
316 |
bfb0b9dc
|
Vinicius Coque
|
<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>"> <input id="cancel" type="button" value="<?=gettext("Cancel"); ?>" class="formbtn" onclick="history.back()">
|
317 |
5b237745
|
Scott Ullrich
|
<?php if (isset($id) && $a_routes[$id]): ?>
|
318 |
225a2f0b
|
Scott Ullrich
|
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>">
|
319 |
5b237745
|
Scott Ullrich
|
<?php endif; ?>
|
320 |
|
|
</td>
|
321 |
|
|
</tr>
|
322 |
|
|
</table>
|
323 |
|
|
</form>
|
324 |
38936dc7
|
Ermal Lu?i
|
<script type="text/javascript">
|
325 |
|
|
var gatewayip;
|
326 |
|
|
var name;
|
327 |
|
|
function show_add_gateway() {
|
328 |
|
|
document.getElementById("addgateway").style.display = '';
|
329 |
|
|
document.getElementById("addgwbox").style.display = 'none';
|
330 |
|
|
document.getElementById("gateway").style.display = 'none';
|
331 |
|
|
document.getElementById("save").style.display = 'none';
|
332 |
|
|
document.getElementById("cancel").style.display = 'none';
|
333 |
|
|
document.getElementById("gwsave").style.display = '';
|
334 |
|
|
document.getElementById("gwcancel").style.display = '';
|
335 |
300e2c0b
|
Vinicius Coque
|
jQuery('#notebox').html("");
|
336 |
38936dc7
|
Ermal Lu?i
|
}
|
337 |
|
|
function hide_add_gateway() {
|
338 |
|
|
document.getElementById("addgateway").style.display = 'none';
|
339 |
|
|
document.getElementById("addgwbox").style.display = '';
|
340 |
|
|
document.getElementById("gateway").style.display = '';
|
341 |
|
|
document.getElementById("save").style.display = '';
|
342 |
|
|
document.getElementById("cancel").style.display = '';
|
343 |
|
|
document.getElementById("gwsave").style.display = '';
|
344 |
|
|
document.getElementById("gwcancel").style.display = '';
|
345 |
|
|
}
|
346 |
|
|
function hide_add_gatewaysave() {
|
347 |
|
|
document.getElementById("addgateway").style.display = 'none';
|
348 |
300e2c0b
|
Vinicius Coque
|
jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
|
349 |
|
|
var iface = jQuery('#addinterfacegw').val();
|
350 |
|
|
name = jQuery('#name').val();
|
351 |
|
|
var descr = jQuery('#gatewaydescr').val();
|
352 |
|
|
gatewayip = jQuery('#gatewayip').val();
|
353 |
|
|
addrtype = jQuery('#addrtype').val();
|
354 |
a980df9c
|
Ermal
|
var defaultgw = '';
|
355 |
300e2c0b
|
Vinicius Coque
|
if (jQuery('#defaultgw').checked)
|
356 |
a980df9c
|
Ermal
|
defaultgw = 'yes';
|
357 |
38936dc7
|
Ermal Lu?i
|
var url = "system_gateways_edit.php";
|
358 |
|
|
var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip) + '&type=' + escape(addrtype);
|
359 |
300e2c0b
|
Vinicius Coque
|
jQuery.ajax(
|
360 |
38936dc7
|
Ermal Lu?i
|
url,
|
361 |
|
|
{
|
362 |
300e2c0b
|
Vinicius Coque
|
type: 'post',
|
363 |
|
|
data: pars,
|
364 |
|
|
error: report_failure,
|
365 |
|
|
complete: save_callback
|
366 |
|
|
});
|
367 |
38936dc7
|
Ermal Lu?i
|
}
|
368 |
|
|
function addOption(selectbox,text,value)
|
369 |
|
|
{
|
370 |
|
|
var optn = document.createElement("OPTION");
|
371 |
|
|
optn.text = text;
|
372 |
|
|
optn.value = value;
|
373 |
300e2c0b
|
Vinicius Coque
|
selectbox.append(optn);
|
374 |
|
|
selectbox.prop('selectedIndex',selectbox.children('option').length-1);
|
375 |
|
|
jQuery('#notebox').html("<p/><strong><?=gettext("NOTE:");?></strong> <?php printf(gettext("You can manage Gateways %shere%s."), "<a target='_new' href='system_gateways.php'>", "</a>");?> </strong>");
|
376 |
38936dc7
|
Ermal Lu?i
|
}
|
377 |
|
|
function report_failure() {
|
378 |
ea53e38f
|
Renato Botelho
|
alert("<?=gettext("Sorry, we could not create your gateway at this time."); ?>");
|
379 |
38936dc7
|
Ermal Lu?i
|
hide_add_gateway();
|
380 |
|
|
}
|
381 |
|
|
function save_callback(transport) {
|
382 |
|
|
var response = transport.responseText;
|
383 |
|
|
if (response) {
|
384 |
|
|
document.getElementById("addgateway").style.display = 'none';
|
385 |
|
|
hide_add_gateway();
|
386 |
300e2c0b
|
Vinicius Coque
|
jQuery('#status').html('');
|
387 |
|
|
addOption(jQuery('#gateway'), name, name);
|
388 |
38936dc7
|
Ermal Lu?i
|
} else {
|
389 |
|
|
report_failure();
|
390 |
|
|
}
|
391 |
|
|
}
|
392 |
4dfd930e
|
Darren Embry
|
var addressarray = <?= json_encode(get_alias_list(array("host", "network"))) ?>;
|
393 |
f898c1a9
|
jim-p
|
var oTextbox1 = new AutoSuggestControl(document.getElementById("network"), new StateSuggestions(addressarray));
|
394 |
|
|
|
395 |
38936dc7
|
Ermal Lu?i
|
</script>
|
396 |
5b237745
|
Scott Ullrich
|
<?php include("fend.inc"); ?>
|
397 |
|
|
</body>
|
398 |
|
|
</html>
|