Revision f193cf92
Added by Simon Cornelius P. Umacob over 16 years ago
usr/local/www/system_gateways_edit.php | ||
---|---|---|
38 | 38 |
|
39 | 39 |
|
40 | 40 |
require("guiconfig.inc"); |
41 |
require_once("IPv6.inc"); |
|
41 | 42 |
|
42 | 43 |
$a_gateways = return_gateways_array(); |
43 |
$a_gateways_arr = array(); |
|
44 |
foreach($a_gateways as $gw) { |
|
45 |
$a_gateways_arr[] = $gw; |
|
46 |
} |
|
47 |
$a_gateways = $a_gateways_arr; |
|
48 | 44 |
|
49 |
$id = $_GET['id']; |
|
50 |
if (isset($_POST['id'])) |
|
45 |
if (isset($_GET['id'])) { |
|
46 |
$id = $_GET['id']; |
|
47 |
} else if (isset($_POST['id'])) { |
|
51 | 48 |
$id = $_POST['id']; |
49 |
} else { |
|
50 |
$id = -1; |
|
51 |
} |
|
52 | 52 |
|
53 | 53 |
if (isset($_GET['dup'])) { |
54 | 54 |
$id = $_GET['dup']; |
... | ... | |
62 | 62 |
$pconfig['monitor'] = $a_gateways[$id]['monitor']; |
63 | 63 |
$pconfig['descr'] = $a_gateways[$id]['descr']; |
64 | 64 |
$pconfig['attribute'] = $a_gateways[$id]['attribute']; |
65 |
$pconfig['type'] = $a_gateways[$id]['type']; |
|
65 | 66 |
} |
66 | 67 |
|
67 | 68 |
if (isset($_GET['dup'])) { |
... | ... | |
80 | 81 |
|
81 | 82 |
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); |
82 | 83 |
|
84 |
/* Does this gateway name already exist? */ |
|
85 |
foreach($config['gateways']['gateway_item'] as $gw) |
|
86 |
if($gw['name'] == $_POST['name']) |
|
87 |
$input_errors[] = "This gateway name already exists."; |
|
88 |
|
|
83 | 89 |
if (! isset($_POST['name'])) { |
84 | 90 |
$input_errors[] = "A valid gateway name must be specified."; |
85 | 91 |
} |
86 |
/* skip system gateways which have been automatically added */ |
|
87 |
if ($_POST['gateway'] && (!is_ipaddr($_POST['gateway'])) && ($pconfig['attribute'] != "system")) { |
|
88 |
$input_errors[] = "A valid gateway IP address must be specified."; |
|
89 |
} |
|
90 |
if ((($_POST['monitor'] <> "") && !is_ipaddr($_POST['monitor']))) { |
|
91 |
$input_errors[] = "A valid monitor IP address must be specified."; |
|
92 |
|
|
93 |
if ($_POST['type'] == 'IPv4') { |
|
94 |
if (!is_ipaddr($_POST['gateway']) && $pconfig['attribute'] != 'system') { |
|
95 |
$input_errors[] = "A valid IPv4 gateway address must be specified."; |
|
96 |
} |
|
97 |
|
|
98 |
if ($_POST['monitor'] && !is_ipaddr($_POST['monitor'])) { |
|
99 |
$input_errors[] = "A valid IPv4 monitor address must be specified."; |
|
100 |
} |
|
101 |
} else if ($_POST['type'] == 'IPv6') { |
|
102 |
if (!Net_IPv6::checkIPv6($_POST['gateway']) && $pconfig['attribute'] != 'system') { |
|
103 |
$input_errors[] = "A valid IPv6 gateway address must be specified."; |
|
104 |
} |
|
105 |
|
|
106 |
if ($_POST['monitor'] && !Net_IPv6::checkIPv6($_POST['monitor'])) { |
|
107 |
$input_errors[] = "A valid IPv6 monitor address must be specified."; |
|
108 |
} |
|
109 |
} else { |
|
110 |
$input_errors[] = "A network type must be specified."; |
|
92 | 111 |
} |
93 | 112 |
|
94 | 113 |
/* check for overlaps */ |
... | ... | |
129 | 148 |
$gateway['name'] = $_POST['name']; |
130 | 149 |
$gateway['gateway'] = $_POST['gateway']; |
131 | 150 |
$gateway['descr'] = $_POST['descr']; |
151 |
$gateway['type'] = $_POST['type']; |
|
132 | 152 |
|
133 | 153 |
if ($_POST['defaultgw'] == "yes") { |
134 |
$i = 0; |
|
135 |
foreach($a_gateways as $gw) { |
|
136 |
unset($config['gateways'][$i]['defaultgw']); |
|
154 |
$i=0; |
|
155 |
foreach ($a_gateways as $gateway) { |
|
156 |
if($id != $i && $config['gateways']['gateway_item'][$i]['type'] == $_POST['type']) { |
|
157 |
unset($config['gateways']['gateway_item'][$i]['defaultgw']); |
|
158 |
} else if ($config['gateways']['gateway_item'][$i]['type'] == $_POST['type']) { |
|
159 |
$config['gateways']['gateway_item'][$i]['defaultgw'] = true; |
|
160 |
} |
|
137 | 161 |
$i++; |
138 | 162 |
} |
139 |
$gateway['defaultgw'] = true; |
|
140 |
} else { |
|
141 |
unset($gateway['defaultgw']); |
|
142 | 163 |
} |
143 | 164 |
|
144 | 165 |
/* when saving the manual gateway we use the attribute which has the corresponding id */ |
... | ... | |
210 | 231 |
<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"> |
211 | 232 |
<br> <span class="vexpl">Gateway name</span></td> |
212 | 233 |
</tr> |
234 |
<tr> |
|
235 |
<td width="22%" valign="top" class="vncellreq">Type</td> |
|
236 |
<td width="78%" class="vtable"> |
|
237 |
<select name="type" class="formselect"> |
|
238 |
<?php |
|
239 |
if ($pconfig['type'] == 'IPv6') { |
|
240 |
$str = <<<EOD |
|
241 |
<option value="IPv4">IPv4</option> |
|
242 |
<option value="IPv6" selected>IPv6</option> |
|
243 |
EOD; |
|
244 |
} else { |
|
245 |
$str = <<<EOD |
|
246 |
<option value="IPv4" selected>IPv4</option> |
|
247 |
<option value="IPv6">IPv6</option> |
|
248 |
EOD; |
|
249 |
} |
|
250 |
|
|
251 |
echo $str; |
|
252 |
?> |
|
253 |
</select> |
|
254 |
</td> |
|
255 |
</tr> |
|
213 | 256 |
<tr> |
214 | 257 |
<td width="22%" valign="top" class="vncellreq">Gateway</td> |
215 | 258 |
<td width="78%" class="vtable"> |
216 | 259 |
<input name="gateway" type="text" class="formfld host" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>"> |
217 |
<br> <span class="vexpl">Gateway IP address</span></td> |
|
260 |
<br> <span class="vexpl">Gateway IPv4/IPv6 address</span></td>
|
|
218 | 261 |
</tr> |
219 | 262 |
<tr> |
220 | 263 |
<td width="22%" valign="top" class="vncell">Default Gateway</td> |
... | ... | |
229 | 272 |
<td width="78%" class="vtable"> |
230 | 273 |
<input name="monitor" type="text" id="monitor" value="<?php echo ($pconfig['monitor']) ; ?>" /> |
231 | 274 |
<strong>Alternative monitor IP</strong> <br /> |
232 |
Enter a alternative address here to be used to monitor the link. This is used for the |
|
275 |
Enter an alternative address here to be used to monitor the link. This is used for the
|
|
233 | 276 |
quality RRD graphs as well as the load balancer entries. Use this if the gateway does not respond |
234 | 277 |
to icmp requests.</strong> |
235 | 278 |
<br /> |
Also available in: Unified diff
Merge IPv6 changes