1 |
5da58a38
|
Renato Botelho
|
<?php
|
2 |
5b237745
|
Scott Ullrich
|
/*
|
3 |
|
|
system_routes_edit.php
|
4 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
5 |
5da58a38
|
Renato Botelho
|
|
6 |
5b237745
|
Scott Ullrich
|
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 |
5da58a38
|
Renato Botelho
|
|
10 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
5da58a38
|
Renato Botelho
|
|
13 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
5da58a38
|
Renato Botelho
|
|
16 |
5b237745
|
Scott Ullrich
|
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 |
5da58a38
|
Renato Botelho
|
|
20 |
5b237745
|
Scott Ullrich
|
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 |
5da58a38
|
Renato Botelho
|
global $g, $config;
|
48 |
0d64af59
|
Ermal Lu?i
|
|
49 |
5da58a38
|
Renato Botelho
|
if (!is_array($config['staticroutes']['route']))
|
50 |
|
|
return;
|
51 |
0d64af59
|
Ermal Lu?i
|
|
52 |
5da58a38
|
Renato Botelho
|
usort($config['staticroutes']['route'], "staticroutecmp");
|
53 |
0d64af59
|
Ermal Lu?i
|
}
|
54 |
6b07c15a
|
Matthew Grooms
|
|
55 |
4fd2fed2
|
jim-p
|
require_once("guiconfig.inc");
|
56 |
|
|
require_once("filter.inc");
|
57 |
|
|
require_once("util.inc");
|
58 |
|
|
require_once("gwlb.inc");
|
59 |
5b237745
|
Scott Ullrich
|
|
60 |
|
|
if (!is_array($config['staticroutes']['route']))
|
61 |
|
|
$config['staticroutes']['route'] = array();
|
62 |
|
|
|
63 |
|
|
$a_routes = &$config['staticroutes']['route'];
|
64 |
6fdea6a2
|
smos
|
$a_gateways = return_gateways_array(true, true);
|
65 |
5b237745
|
Scott Ullrich
|
|
66 |
0e6cf71b
|
Renato Botelho
|
if (is_numericint($_GET['id']))
|
67 |
|
|
$id = $_GET['id'];
|
68 |
|
|
if (isset($_POST['id']) && is_numericint($_POST['id']))
|
69 |
5b237745
|
Scott Ullrich
|
$id = $_POST['id'];
|
70 |
|
|
|
71 |
0e6cf71b
|
Renato Botelho
|
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
|
72 |
18f7352b
|
Seth Mos
|
$id = $_GET['dup'];
|
73 |
|
|
|
74 |
5b237745
|
Scott Ullrich
|
if (isset($id) && $a_routes[$id]) {
|
75 |
5da58a38
|
Renato Botelho
|
list($pconfig['network'],$pconfig['network_subnet']) =
|
76 |
5b237745
|
Scott Ullrich
|
explode('/', $a_routes[$id]['network']);
|
77 |
|
|
$pconfig['gateway'] = $a_routes[$id]['gateway'];
|
78 |
|
|
$pconfig['descr'] = $a_routes[$id]['descr'];
|
79 |
bfe407e5
|
Warren Baker
|
$pconfig['disabled'] = isset($a_routes[$id]['disabled']);
|
80 |
5b237745
|
Scott Ullrich
|
}
|
81 |
|
|
|
82 |
0e6cf71b
|
Renato Botelho
|
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
|
83 |
18f7352b
|
Seth Mos
|
unset($id);
|
84 |
|
|
|
85 |
5b237745
|
Scott Ullrich
|
if ($_POST) {
|
86 |
|
|
|
87 |
f0867239
|
Renato Botelho
|
global $aliastable;
|
88 |
|
|
|
89 |
5b237745
|
Scott Ullrich
|
unset($input_errors);
|
90 |
|
|
$pconfig = $_POST;
|
91 |
|
|
|
92 |
|
|
/* input validation */
|
93 |
dde169d9
|
Vinicius Coque
|
$reqdfields = explode(" ", "network network_subnet gateway");
|
94 |
38fb1109
|
Vinicius Coque
|
$reqdfieldsn = explode(",",
|
95 |
|
|
gettext("Destination network") . "," .
|
96 |
|
|
gettext("Destination network bit count") . "," .
|
97 |
5da58a38
|
Renato Botelho
|
gettext("Gateway"));
|
98 |
|
|
|
99 |
5b237745
|
Scott Ullrich
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
100 |
5da58a38
|
Renato Botelho
|
|
101 |
f898c1a9
|
jim-p
|
if (($_POST['network'] && !is_ipaddr($_POST['network']) && !is_alias($_POST['network']))) {
|
102 |
ad700f39
|
Seth Mos
|
$input_errors[] = gettext("A valid IPv4 or IPv6 destination network must be specified.");
|
103 |
5b237745
|
Scott Ullrich
|
}
|
104 |
|
|
if (($_POST['network_subnet'] && !is_numeric($_POST['network_subnet']))) {
|
105 |
169e0008
|
Carlos Eduardo Ramos
|
$input_errors[] = gettext("A valid destination network bit count must be specified.");
|
106 |
5b237745
|
Scott Ullrich
|
}
|
107 |
ad700f39
|
Seth Mos
|
if (($_POST['gateway']) && is_ipaddr($_POST['network'])) {
|
108 |
a529aced
|
Ermal
|
if (!isset($a_gateways[$_POST['gateway']]))
|
109 |
169e0008
|
Carlos Eduardo Ramos
|
$input_errors[] = gettext("A valid gateway must be specified.");
|
110 |
1831a00d
|
Seth Mos
|
if(!validate_address_family($_POST['network'], lookup_gateway_ip_by_name($_POST['gateway'])))
|
111 |
|
|
$input_errors[] = gettext("The gateway '{$a_gateways[$_POST['gateway']]['gateway']}' is a different Address Family as network '{$_POST['network']}'.");
|
112 |
5b237745
|
Scott Ullrich
|
}
|
113 |
|
|
|
114 |
|
|
/* check for overlaps */
|
115 |
f898c1a9
|
jim-p
|
$current_targets = get_staticroutes(true);
|
116 |
|
|
$new_targets = array();
|
117 |
14f565b4
|
Seth Mos
|
if(is_ipaddrv6($_POST['network'])) {
|
118 |
88cc00db
|
Ermal
|
$osn = gen_subnetv6($_POST['network'], $_POST['network_subnet']) . "/" . $_POST['network_subnet'];
|
119 |
f898c1a9
|
jim-p
|
$new_targets[] = $osn;
|
120 |
14f565b4
|
Seth Mos
|
}
|
121 |
71f4a2b7
|
smos
|
if (is_ipaddrv4($_POST['network'])) {
|
122 |
1831a00d
|
Seth Mos
|
if($_POST['network_subnet'] > 32)
|
123 |
|
|
$input_errors[] = gettext("A IPv4 subnet can not be over 32 bits.");
|
124 |
f898c1a9
|
jim-p
|
else {
|
125 |
1831a00d
|
Seth Mos
|
$osn = gen_subnet($_POST['network'], $_POST['network_subnet']) . "/" . $_POST['network_subnet'];
|
126 |
f898c1a9
|
jim-p
|
$new_targets[] = $osn;
|
127 |
|
|
}
|
128 |
|
|
} elseif (is_alias($_POST['network'])) {
|
129 |
|
|
$osn = $_POST['network'];
|
130 |
8543a5bb
|
Renato Botelho
|
$fqdn_found = 0;
|
131 |
90bc28cc
|
Renato Botelho
|
foreach (filter_expand_alias_array($osn, true) as $tgt) {
|
132 |
87f61101
|
Renato Botelho
|
if (is_ipaddrv4($tgt))
|
133 |
f898c1a9
|
jim-p
|
$tgt .= "/32";
|
134 |
87f61101
|
Renato Botelho
|
if (is_ipaddrv6($tgt))
|
135 |
71f4a2b7
|
smos
|
$tgt .= "/128";
|
136 |
90bc28cc
|
Renato Botelho
|
if (is_fqdn($tgt)) {
|
137 |
|
|
$input_errors[] = sprintf(gettext("The alias (%s) has one or more FQDNs configured and cannot be used to configure a static route."), $_POST['network']);
|
138 |
|
|
$fqdn_found = 1;
|
139 |
|
|
break;
|
140 |
|
|
}
|
141 |
|
|
if (is_subnet($tgt))
|
142 |
|
|
$new_targets[] = $tgt;
|
143 |
f898c1a9
|
jim-p
|
}
|
144 |
14f565b4
|
Seth Mos
|
}
|
145 |
f898c1a9
|
jim-p
|
if (!isset($id))
|
146 |
|
|
$id = count($a_routes);
|
147 |
|
|
$oroute = $a_routes[$id];
|
148 |
71f4a2b7
|
smos
|
$old_targets = array();
|
149 |
f898c1a9
|
jim-p
|
if (!empty($oroute)) {
|
150 |
|
|
if (is_alias($oroute['network'])) {
|
151 |
|
|
foreach (filter_expand_alias_array($oroute['network']) as $tgt) {
|
152 |
ef593cd3
|
Renato Botelho
|
if (is_ipaddrv4($tgt))
|
153 |
f898c1a9
|
jim-p
|
$tgt .= "/32";
|
154 |
ef593cd3
|
Renato Botelho
|
else if (is_ipaddrv6($tgt))
|
155 |
|
|
$tgt .= "/128";
|
156 |
f898c1a9
|
jim-p
|
if (!is_subnet($tgt))
|
157 |
|
|
continue;
|
158 |
|
|
$old_targets[] = $tgt;
|
159 |
|
|
}
|
160 |
|
|
} else {
|
161 |
|
|
$old_targets[] = $oroute['network'];
|
162 |
5b237745
|
Scott Ullrich
|
}
|
163 |
|
|
}
|
164 |
|
|
|
165 |
f898c1a9
|
jim-p
|
$overlaps = array_intersect($current_targets, $new_targets);
|
166 |
|
|
$overlaps = array_diff($overlaps, $old_targets);
|
167 |
|
|
if (count($overlaps)) {
|
168 |
|
|
$input_errors[] = gettext("A route to these destination networks already exists") . ": " . implode(", ", $overlaps);
|
169 |
|
|
}
|
170 |
|
|
|
171 |
74889b22
|
Renato Botelho
|
if (is_array($config['interfaces'])) {
|
172 |
|
|
foreach ($config['interfaces'] as $if) {
|
173 |
|
|
if (is_ipaddrv4($_POST['network'])
|
174 |
|
|
&& isset($if['ipaddr']) && isset($if['subnet'])
|
175 |
|
|
&& is_ipaddrv4($if['ipaddr']) && is_numeric($if['subnet'])
|
176 |
|
|
&& ($_POST['network_subnet'] == $if['subnet'])
|
177 |
|
|
&& (gen_subnet($_POST['network'], $_POST['network_subnet']) == gen_subnet($if['ipaddr'], $if['subnet'])))
|
178 |
|
|
$input_errors[] = sprintf(gettext("This network conflicts with address configured on interface %s."), $if['descr']);
|
179 |
|
|
|
180 |
|
|
else if (is_ipaddrv6($_POST['network'])
|
181 |
|
|
&& isset($if['ipaddrv6']) && isset($if['subnetv6'])
|
182 |
|
|
&& is_ipaddrv6($if['ipaddrv6']) && is_numeric($if['subnetv6'])
|
183 |
|
|
&& ($_POST['network_subnet'] == $if['subnetv6'])
|
184 |
|
|
&& (gen_subnetv6($_POST['network'], $_POST['network_subnet']) == gen_subnetv6($if['ipaddrv6'], $if['subnetv6'])))
|
185 |
|
|
$input_errors[] = sprintf(gettext("This network conflicts with address configured on interface %s."), $if['descr']);
|
186 |
|
|
}
|
187 |
|
|
}
|
188 |
|
|
|
189 |
5b237745
|
Scott Ullrich
|
if (!$input_errors) {
|
190 |
|
|
$route = array();
|
191 |
|
|
$route['network'] = $osn;
|
192 |
|
|
$route['gateway'] = $_POST['gateway'];
|
193 |
|
|
$route['descr'] = $_POST['descr'];
|
194 |
bfe407e5
|
Warren Baker
|
if ($_POST['disabled'])
|
195 |
|
|
$route['disabled'] = true;
|
196 |
|
|
else
|
197 |
|
|
unset($route['disabled']);
|
198 |
5b237745
|
Scott Ullrich
|
|
199 |
f898c1a9
|
jim-p
|
if (file_exists("{$g['tmp_path']}/.system_routes.apply"))
|
200 |
|
|
$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.system_routes.apply"));
|
201 |
|
|
else
|
202 |
|
|
$toapplylist = array();
|
203 |
e8471084
|
Ermal
|
$a_routes[$id] = $route;
|
204 |
|
|
|
205 |
|
|
if (!empty($oroute)) {
|
206 |
f898c1a9
|
jim-p
|
$delete_targets = array_diff($old_targets, $new_targets);
|
207 |
|
|
if (count($delete_targets))
|
208 |
|
|
foreach ($delete_targets as $dts) {
|
209 |
|
|
if(is_ipaddrv6($dts))
|
210 |
|
|
$family = "-inet6";
|
211 |
5da58a38
|
Renato Botelho
|
$toapplylist[] = "/sbin/route delete {$family} {$dts}";
|
212 |
f898c1a9
|
jim-p
|
}
|
213 |
e8471084
|
Ermal
|
}
|
214 |
|
|
file_put_contents("{$g['tmp_path']}/.system_routes.apply", serialize($toapplylist));
|
215 |
0e3aa71c
|
Erik Fonnesbeck
|
staticroutes_sort();
|
216 |
5da58a38
|
Renato Botelho
|
|
217 |
a368a026
|
Ermal Lu?i
|
mark_subsystem_dirty('staticroutes');
|
218 |
5da58a38
|
Renato Botelho
|
|
219 |
5b237745
|
Scott Ullrich
|
write_config();
|
220 |
5da58a38
|
Renato Botelho
|
|
221 |
5b237745
|
Scott Ullrich
|
header("Location: system_routes.php");
|
222 |
|
|
exit;
|
223 |
|
|
}
|
224 |
|
|
}
|
225 |
4df96eff
|
Scott Ullrich
|
|
226 |
169e0008
|
Carlos Eduardo Ramos
|
$pgtitle = array(gettext("System"),gettext("Static Routes"),gettext("Edit route"));
|
227 |
b32dd0a6
|
jim-p
|
$shortcut_section = "routing";
|
228 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
229 |
5b237745
|
Scott Ullrich
|
?>
|
230 |
4df96eff
|
Scott Ullrich
|
|
231 |
5b237745
|
Scott Ullrich
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
232 |
87744d53
|
Darren Embry
|
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
|
233 |
dcdff6fa
|
Colin Fleming
|
<script type="text/javascript" src="/javascript/autosuggest.js"></script>
|
234 |
|
|
<script type="text/javascript" src="/javascript/suggestions.js"></script>
|
235 |
f898c1a9
|
jim-p
|
<?php include("fbegin.inc");?>
|
236 |
5b237745
|
Scott Ullrich
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
237 |
5da58a38
|
Renato Botelho
|
<form action="system_routes_edit.php" method="post" name="iform" id="iform">
|
238 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="system routes edit">
|
239 |
|
|
<tr>
|
240 |
|
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit route entry"); ?></td>
|
241 |
|
|
</tr>
|
242 |
|
|
<tr>
|
243 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination network"); ?></td>
|
244 |
|
|
<td width="78%" class="vtable">
|
245 |
|
|
<input name="network" type="text" class="formfldalias ipv4v6" id="network" size="20" value="<?=htmlspecialchars($pconfig['network']);?>" />
|
246 |
|
|
/
|
247 |
|
|
<select name="network_subnet" class="formselect ipv4v6" id="network_subnet">
|
248 |
|
|
<?php for ($i = 129; $i >= 1; $i--): ?>
|
249 |
|
|
<option value="<?=$i;?>" <?php if ($i == $pconfig['network_subnet']) echo "selected=\"selected\""; ?>>
|
250 |
|
|
<?=$i;?>
|
251 |
|
|
</option>
|
252 |
|
|
<?php endfor; ?>
|
253 |
|
|
</select>
|
254 |
|
|
<br/><span class="vexpl"><?=gettext("Destination network for this static route"); ?></span>
|
255 |
|
|
</td>
|
256 |
|
|
</tr>
|
257 |
|
|
<tr>
|
258 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Gateway"); ?></td>
|
259 |
|
|
<td width="78%" class="vtable">
|
260 |
|
|
<select name="gateway" id="gateway" class="formselect">
|
261 |
|
|
<?php
|
262 |
|
|
foreach ($a_gateways as $gateway) {
|
263 |
|
|
echo "<option value='{$gateway['name']}' ";
|
264 |
|
|
if ($gateway['name'] == $pconfig['gateway'])
|
265 |
|
|
echo "selected=\"selected\"";
|
266 |
|
|
echo ">" . htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']) . "</option>\n";
|
267 |
|
|
}
|
268 |
|
|
?>
|
269 |
|
|
</select> <br />
|
270 |
|
|
<div id='addgwbox'>
|
271 |
|
|
<?=gettext("Choose which gateway this route applies to or"); ?> <a onclick="show_add_gateway();" href="#"><?=gettext("add a new one.");?></a>
|
272 |
|
|
</div>
|
273 |
|
|
<div id='notebox'>
|
274 |
|
|
</div>
|
275 |
|
|
<div style="display:none" id="status">
|
276 |
|
|
</div>
|
277 |
|
|
<div style="display:none" id="addgateway">
|
278 |
|
|
<table border="1" style="background:#990000; border-style: none none none none; width:225px;" summary="add gateway">
|
279 |
|
|
<tr>
|
280 |
|
|
<td>
|
281 |
|
|
<table bgcolor="#990000" cellpadding="1" cellspacing="1" summary="add">
|
282 |
|
|
<tr><td> </td></tr>
|
283 |
|
|
<tr>
|
284 |
|
|
<td colspan="2" align="center"><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></td>
|
285 |
|
|
</tr>
|
286 |
|
|
<tr><td> </td></tr>
|
287 |
|
|
<tr>
|
288 |
|
|
<td width="45%" align="right"><font color="white"><?=gettext("Default gateway:"); ?></font></td><td><input type="checkbox" id="defaultgw" name="defaultgw" /></td>
|
289 |
|
|
</tr>
|
290 |
|
|
<tr>
|
291 |
|
|
<td width="45%" align="right"><font color="white"><?=gettext("Interface:"); ?></font></td>
|
292 |
|
|
<td>
|
293 |
|
|
<select name="addinterfacegw" id="addinterfacegw">
|
294 |
38936dc7
|
Ermal Lu?i
|
<?php $gwifs = get_configured_interface_with_descr();
|
295 |
|
|
foreach($gwifs as $fif => $dif)
|
296 |
|
|
echo "<option value=\"{$fif}\">{$dif}</option>\n";
|
297 |
|
|
?>
|
298 |
5da58a38
|
Renato Botelho
|
</select>
|
299 |
|
|
</td>
|
300 |
|
|
</tr>
|
301 |
|
|
<tr>
|
302 |
|
|
<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></font></td><td><input id="name" name="name" value="GW" /></td>
|
303 |
|
|
</tr>
|
304 |
|
|
<tr>
|
305 |
|
|
<td align="right"><font color="white"><?=gettext("Gateway IP:"); ?></font></td><td><input id="gatewayip" name="gatewayip" /></td>
|
306 |
|
|
</tr>
|
307 |
|
|
<tr>
|
308 |
|
|
<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescr" name="gatewaydescr" /></td>
|
309 |
|
|
</tr>
|
310 |
|
|
<tr><td> </td></tr>
|
311 |
|
|
<tr>
|
312 |
|
|
<td colspan="2" align="center">
|
313 |
|
|
<div id='savebuttondiv'>
|
314 |
|
|
<input type="hidden" name="addrtype" id="addrtype" value="IPv4" />
|
315 |
|
|
<input id="gwsave" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave();' />
|
316 |
|
|
<input id="gwcancel" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway();' />
|
317 |
|
|
</div>
|
318 |
|
|
</td>
|
319 |
|
|
</tr>
|
320 |
|
|
<tr><td> </td></tr>
|
321 |
|
|
</table>
|
322 |
|
|
</td>
|
323 |
|
|
</tr>
|
324 |
|
|
</table>
|
325 |
|
|
</div>
|
326 |
|
|
</td>
|
327 |
|
|
</tr>
|
328 |
|
|
<tr>
|
329 |
|
|
<td width="22%" valign="top" class="vncell"><?=gettext("Disabled");?></td>
|
330 |
|
|
<td width="78%" class="vtable">
|
331 |
|
|
<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked=\"checked\""; ?> />
|
332 |
|
|
<strong><?=gettext("Disable this static route");?></strong><br />
|
333 |
|
|
<span class="vexpl"><?=gettext("Set this option to disable this static route without removing it from the list.");?></span>
|
334 |
|
|
</td>
|
335 |
|
|
</tr>
|
336 |
|
|
<tr>
|
337 |
|
|
<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
|
338 |
|
|
<td width="78%" class="vtable">
|
339 |
|
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
|
340 |
|
|
<br/><span class="vexpl"><?=gettext("You may enter a description here for your reference (not parsed)."); ?></span>
|
341 |
|
|
</td>
|
342 |
|
|
</tr>
|
343 |
|
|
<tr>
|
344 |
|
|
<td width="22%" valign="top"> </td>
|
345 |
|
|
<td width="78%">
|
346 |
|
|
<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()" />
|
347 |
|
|
<?php if (isset($id) && $a_routes[$id]): ?>
|
348 |
|
|
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
|
349 |
|
|
<?php endif; ?>
|
350 |
|
|
</td>
|
351 |
|
|
</tr>
|
352 |
|
|
</table>
|
353 |
|
|
</form>
|
354 |
38936dc7
|
Ermal Lu?i
|
<script type="text/javascript">
|
355 |
dcdff6fa
|
Colin Fleming
|
//<![CDATA[
|
356 |
5da58a38
|
Renato Botelho
|
var gatewayip;
|
357 |
|
|
var name;
|
358 |
|
|
function show_add_gateway() {
|
359 |
|
|
document.getElementById("addgateway").style.display = '';
|
360 |
|
|
document.getElementById("addgwbox").style.display = 'none';
|
361 |
|
|
document.getElementById("gateway").style.display = 'none';
|
362 |
|
|
document.getElementById("save").style.display = 'none';
|
363 |
|
|
document.getElementById("cancel").style.display = 'none';
|
364 |
|
|
document.getElementById("gwsave").style.display = '';
|
365 |
|
|
document.getElementById("gwcancel").style.display = '';
|
366 |
|
|
jQuery('#notebox').html("");
|
367 |
|
|
}
|
368 |
|
|
function hide_add_gateway() {
|
369 |
|
|
document.getElementById("addgateway").style.display = 'none';
|
370 |
|
|
document.getElementById("addgwbox").style.display = '';
|
371 |
|
|
document.getElementById("gateway").style.display = '';
|
372 |
|
|
document.getElementById("save").style.display = '';
|
373 |
|
|
document.getElementById("cancel").style.display = '';
|
374 |
|
|
document.getElementById("gwsave").style.display = '';
|
375 |
|
|
document.getElementById("gwcancel").style.display = '';
|
376 |
|
|
}
|
377 |
|
|
function hide_add_gatewaysave() {
|
378 |
|
|
document.getElementById("addgateway").style.display = 'none';
|
379 |
09f26fb7
|
Renato Botelho
|
jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif"> One moment please...');
|
380 |
5da58a38
|
Renato Botelho
|
var iface = jQuery('#addinterfacegw').val();
|
381 |
|
|
name = jQuery('#name').val();
|
382 |
|
|
var descr = jQuery('#gatewaydescr').val();
|
383 |
|
|
gatewayip = jQuery('#gatewayip').val();
|
384 |
|
|
addrtype = jQuery('#addrtype').val();
|
385 |
|
|
var defaultgw = '';
|
386 |
|
|
if (jQuery('#defaultgw').checked)
|
387 |
|
|
defaultgw = 'yes';
|
388 |
|
|
var url = "system_gateways_edit.php";
|
389 |
|
|
var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip) + '&type=' + escape(addrtype);
|
390 |
|
|
jQuery.ajax(
|
391 |
|
|
url,
|
392 |
|
|
{
|
393 |
|
|
type: 'post',
|
394 |
|
|
data: pars,
|
395 |
|
|
error: report_failure,
|
396 |
|
|
complete: save_callback
|
397 |
|
|
});
|
398 |
|
|
}
|
399 |
|
|
function addOption(selectbox,text,value)
|
400 |
|
|
{
|
401 |
|
|
var optn = document.createElement("OPTION");
|
402 |
|
|
optn.text = text;
|
403 |
|
|
optn.value = value;
|
404 |
|
|
selectbox.append(optn);
|
405 |
|
|
selectbox.prop('selectedIndex',selectbox.children('option').length-1);
|
406 |
|
|
jQuery('#notebox').html("<p><strong><?=gettext("NOTE:");?><\/strong> <?php printf(gettext("You can manage Gateways %shere%s."), "<a target='_blank' href='system_gateways.php'>", "<\/a>");?> <\/strong><\/p>");
|
407 |
|
|
}
|
408 |
|
|
function report_failure() {
|
409 |
|
|
alert("<?=gettext("Sorry, we could not create your gateway at this time."); ?>");
|
410 |
|
|
hide_add_gateway();
|
411 |
|
|
}
|
412 |
|
|
function save_callback(transport) {
|
413 |
|
|
var response = transport.responseText;
|
414 |
|
|
if (response) {
|
415 |
|
|
document.getElementById("addgateway").style.display = 'none';
|
416 |
|
|
hide_add_gateway();
|
417 |
|
|
jQuery('#status').html('');
|
418 |
|
|
addOption(jQuery('#gateway'), name, name);
|
419 |
|
|
} else {
|
420 |
|
|
report_failure();
|
421 |
|
|
}
|
422 |
|
|
}
|
423 |
|
|
var addressarray = <?= json_encode(get_alias_list(array("host", "network"))) ?>;
|
424 |
|
|
var oTextbox1 = new AutoSuggestControl(document.getElementById("network"), new StateSuggestions(addressarray));
|
425 |
dcdff6fa
|
Colin Fleming
|
//]]>
|
426 |
5da58a38
|
Renato Botelho
|
</script>
|
427 |
5b237745
|
Scott Ullrich
|
<?php include("fend.inc"); ?>
|
428 |
|
|
</body>
|
429 |
|
|
</html>
|