Project

General

Profile

Download (172 KB) Statistics
| Branch: | Tag: | Revision:
1 8a9edda5 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4 b2bc44cd Scott Ullrich
	interfaces.php
5 78fcfb9c Scott Ullrich
	Copyright (C) 2004-2008 Scott Ullrich
6 744ea190 Scott Ullrich
	Copyright (C) 2006 Daniel S. Haischt.
7 63c704c3 N0YB
	Copyright (C) 2008-2010 Ermal Luçi
8 c3b3cd36 Scott Ullrich
	All rights reserved.
9 b1c525ee Scott Ullrich
10 c3b3cd36 Scott Ullrich
	originally part of m0n0wall (http://m0n0.ch/wall)
11 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
12
	All rights reserved.
13 e2cd32df Scott Ullrich
14 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16 e2cd32df Scott Ullrich
17 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19 e2cd32df Scott Ullrich
20 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
21
	   notice, this list of conditions and the following disclaimer in the
22
	   documentation and/or other materials provided with the distribution.
23 e2cd32df Scott Ullrich
24 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
	POSSIBILITY OF SUCH DAMAGE.
34
*/
35 7ac5a4cb Scott Ullrich
/*
36
	pfSense_BUILDER_BINARIES:	/usr/sbin/arp
37
	pfSense_MODULE:	interfaces
38
*/
39 5b237745 Scott Ullrich
40 6b07c15a Matthew Grooms
##|+PRIV
41 01eb687d Ermal Luçi
##|*IDENT=page-interfaces
42 6b07c15a Matthew Grooms
##|*NAME=Interfaces: WAN page
43 998552f8 Ermal Luçi
##|*DESCR=Allow access to the 'Interfaces' page.
44 01eb687d Ermal Luçi
##|*MATCH=interfaces.php*
45 6b07c15a Matthew Grooms
##|-PRIV
46
47 f81cfcc9 jim-p
require_once("guiconfig.inc");
48
require_once("ipsec.inc");
49
require_once("functions.inc");
50
require_once("captiveportal.inc");
51
require_once("filter.inc");
52
require_once("shaper.inc");
53
require_once("rrd.inc");
54
require_once("vpn.inc");
55 1fb064e8 Erik Fonnesbeck
require_once("xmlparse_attr.inc");
56 199d8121 Ermal Luçi
57 62424bdb Renato Botelho
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces.php');
58
59 94556105 Scott Ullrich
// Get configured interface list
60 dd18038e Ermal
$ifdescrs = get_configured_interface_with_descr(false, true);
61 94556105 Scott Ullrich
62 dd18038e Ermal
$if = "wan";
63
if ($_REQUEST['if'])
64 bd58d230 Scott Ullrich
	$if = $_REQUEST['if'];
65 dd18038e Ermal
66
if (empty($ifdescrs[$if])) {
67 6f3d2063 Renato Botelho
	header("Location: interfaces.php");
68 dd18038e Ermal
	exit;
69 9ff9a1c7 Seth Mos
}
70 6b07c15a Matthew Grooms
71 58af5941 Scott Ullrich
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
72
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
73
define("CRON_DAILY_PATTERN", "0 0 * * *");
74
define("CRON_HOURLY_PATTERN", "0 * * * *");
75 dc711694 Scott Ullrich
76 89c7a9c8 Ermal
if (!is_array($pconfig))
77
	$pconfig = array();
78
79 d85ba87f gnhb
if (!is_array($config['ppps']['ppp']))
80
	$config['ppps']['ppp'] = array();
81
82
$a_ppps = &$config['ppps']['ppp'];
83 58af5941 Scott Ullrich
84 f1f60c92 Ermal Luçi
function remove_bad_chars($string) {
85 e7346f05 Erik Fonnesbeck
	return preg_replace('/[^a-z_0-9]/i','',$string);
86 f1f60c92 Ermal Luçi
}
87
88 d173230c Seth Mos
if (!is_array($config['gateways']['gateway_item']))
89
	$config['gateways']['gateway_item'] = array();
90
$a_gateways = &$config['gateways']['gateway_item'];
91
92 f1f60c92 Ermal Luçi
$wancfg = &$config['interfaces'][$if];
93 ee5c01b5 Seth Mos
$old_wancfg = $wancfg;
94 e12ad49f Renato Botelho
$old_wancfg['realif'] = get_real_interface($if);
95
$old_ppps = $a_ppps;
96 dd18038e Ermal
// Populate page descr if it does not exist.
97
if ($if == "wan" && !$wancfg['descr'])
98
	$wancfg['descr'] = "WAN";
99
else if ($if == "lan" && !$wancfg['descr'])
100
	$wancfg['descr'] = "LAN";
101
102 8256f324 gnhb
foreach ($a_ppps as $pppid => $ppp) {
103 1d7e1d6c gnhb
	if ($wancfg['if'] == $ppp['if'])
104 8256f324 gnhb
		break;
105 30ade846 gnhb
}
106
107 f3d88511 Renato Botelho
$type_disabled = (substr($wancfg['if'], 0, 3) == 'gre') ? 'disabled="disabled"' : '';
108
109 1d7e1d6c gnhb
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
110 30ade846 gnhb
	$pconfig['pppid'] = $pppid;
111 1d7e1d6c gnhb
	$pconfig['ptpid'] = $a_ppps[$pppid]['ptpid'];
112
	$pconfig['port'] = $a_ppps[$pppid]['ports'];
113 70e46e62 Ermal
	if ($a_ppps[$pppid]['type'] == "ppp") {
114 3a906378 gnhb
		$pconfig['username'] = $a_ppps[$pppid]['username'];
115
		$pconfig['password'] = base64_decode($a_ppps[$pppid]['password']);
116 c0948c6c Renato Botelho
117 3a906378 gnhb
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
118
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
119
	}
120 70e46e62 Ermal
	else if ($a_ppps[$pppid]['type'] == "pppoe") {
121 d85ba87f gnhb
		$pconfig['pppoe_username'] = $a_ppps[$pppid]['username'];
122
		$pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']);
123
		$pconfig['provider'] = $a_ppps[$pppid]['provider'];
124
		$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
125
		$pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout'];
126 5b237745 Scott Ullrich
127 d85ba87f gnhb
		/* ================================================ */
128
		/* = force a connection reset at a specific time? = */
129
		/* ================================================ */
130 c0948c6c Renato Botelho
131 d85ba87f gnhb
		if (isset($a_ppps[$pppid]['pppoe-reset-type'])) {
132
			$pconfig['pppoe-reset-type'] = $a_ppps[$pppid]['pppoe-reset-type'];
133 1d7e1d6c gnhb
			$itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']);
134 70e46e62 Ermal
			if ($itemhash)
135
				$cronitem = $itemhash['ITEM'];
136 e40e6724 gnhb
			if (isset($cronitem)) {
137
				$resetTime = "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
138
			} else {
139
				$resetTime = NULL;
140
			}
141 70e46e62 Ermal
			//log_error("ResetTime:".$resetTime);
142 d85ba87f gnhb
			if ($a_ppps[$pppid]['pppoe-reset-type'] == "custom") {
143 70e46e62 Ermal
				if ($cronitem) {
144
					$pconfig['pppoe_pr_custom'] = true;
145
					$pconfig['pppoe_resetminute'] = $cronitem['minute'];
146
					$pconfig['pppoe_resethour'] = $cronitem['hour'];
147
					if ($cronitem['mday'] <> "*" && $cronitem['month'] <> "*")
148
						$pconfig['pppoe_resetdate'] = "{$cronitem['month']}/{$cronitem['mday']}/" . date("Y");
149 af13aad6 Ermal
				}
150 d85ba87f gnhb
			} else if ($a_ppps[$pppid]['pppoe-reset-type'] == "preset") {
151
				$pconfig['pppoe_pr_preset'] = true;
152
				switch ($resetTime) {
153
					case CRON_MONTHLY_PATTERN:
154
						$pconfig['pppoe_monthly'] = true;
155
						break;
156
					case CRON_WEEKLY_PATTERN:
157
						$pconfig['pppoe_weekly'] = true;
158
						break;
159
					case CRON_DAILY_PATTERN:
160
						$pconfig['pppoe_daily'] = true;
161
						break;
162
					case CRON_HOURLY_PATTERN:
163
						$pconfig['pppoe_hourly'] = true;
164
						break;
165
				}
166
			}
167
		}// End force pppoe reset at specific time
168 c0948c6c Renato Botelho
	}// End if type == pppoe
169 e4d40f41 gnhb
	else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp"){
170 d85ba87f gnhb
		$pconfig['pptp_username'] = $a_ppps[$pppid]['username'];
171
		$pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']);
172 4a1ee8ac gnhb
		$pconfig['pptp_local'] = explode(",",$a_ppps[$pppid]['localip']);
173
		$pconfig['pptp_subnet'] = explode(",",$a_ppps[$pppid]['subnet']);
174
		$pconfig['pptp_remote'] = explode(",",$a_ppps[$pppid]['gateway']);
175 d85ba87f gnhb
		$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
176
		$pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout'];
177
	}
178 8256f324 gnhb
} else {
179 1d7e1d6c gnhb
	$pconfig['ptpid'] = interfaces_ptpid_next();
180 8256f324 gnhb
	$pppid = count($a_ppps);
181 d85ba87f gnhb
}
182 5b237745 Scott Ullrich
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
183 bc40d758 Seth Mos
$pconfig['alias-address'] = $wancfg['alias-address'];
184
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
185 57c83fd6 jim-p
$pconfig['dhcprejectfrom'] = $wancfg['dhcprejectfrom'];
186 f4dd8b4c N0YB
187
$pconfig['adv_dhcp_pt_timeout'] = $wancfg['adv_dhcp_pt_timeout'];
188
$pconfig['adv_dhcp_pt_retry'] = $wancfg['adv_dhcp_pt_retry'];
189
$pconfig['adv_dhcp_pt_select_timeout'] = $wancfg['adv_dhcp_pt_select_timeout'];
190
$pconfig['adv_dhcp_pt_reboot'] = $wancfg['adv_dhcp_pt_reboot'];
191
$pconfig['adv_dhcp_pt_backoff_cutoff'] = $wancfg['adv_dhcp_pt_backoff_cutoff'];
192
$pconfig['adv_dhcp_pt_initial_interval'] = $wancfg['adv_dhcp_pt_initial_interval'];
193
194
$pconfig['adv_dhcp_pt_values'] = $wancfg['adv_dhcp_pt_values'];
195
196
$pconfig['adv_dhcp_send_options'] = $wancfg['adv_dhcp_send_options'];
197
$pconfig['adv_dhcp_request_options'] = $wancfg['adv_dhcp_request_options'];
198
$pconfig['adv_dhcp_required_options'] = $wancfg['adv_dhcp_required_options'];
199
$pconfig['adv_dhcp_option_modifiers'] = $wancfg['adv_dhcp_option_modifiers'];
200
201
$pconfig['adv_dhcp_config_advanced'] = $wancfg['adv_dhcp_config_advanced'];
202
$pconfig['adv_dhcp_config_file_override'] = $wancfg['adv_dhcp_config_file_override'];
203
$pconfig['adv_dhcp_config_file_override_path'] = $wancfg['adv_dhcp_config_file_override_path'];
204
205
$pconfig['adv_dhcp6_interface_statement_send_options'] = $wancfg['adv_dhcp6_interface_statement_send_options'];
206
$pconfig['adv_dhcp6_interface_statement_request_options'] = $wancfg['adv_dhcp6_interface_statement_request_options'];
207
$pconfig['adv_dhcp6_interface_statement_information_only_enable'] = $wancfg['adv_dhcp6_interface_statement_information_only_enable'];
208
$pconfig['adv_dhcp6_interface_statement_script'] = $wancfg['adv_dhcp6_interface_statement_script'];
209
210
$pconfig['adv_dhcp6_id_assoc_statement_address_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_address_enable'];
211
$pconfig['adv_dhcp6_id_assoc_statement_address'] = $wancfg['adv_dhcp6_id_assoc_statement_address'];
212
$pconfig['adv_dhcp6_id_assoc_statement_address_id'] = $wancfg['adv_dhcp6_id_assoc_statement_address_id'];
213
$pconfig['adv_dhcp6_id_assoc_statement_address_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_pltime'];
214
$pconfig['adv_dhcp6_id_assoc_statement_address_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_vltime'];
215
216
$pconfig['adv_dhcp6_id_assoc_statement_prefix_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'];
217
$pconfig['adv_dhcp6_id_assoc_statement_prefix'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix'];
218
$pconfig['adv_dhcp6_id_assoc_statement_prefix_id'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_id'];
219
$pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'];
220
$pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'];
221
222
$pconfig['adv_dhcp6_prefix_interface_statement_sla_id'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_id'];
223
$pconfig['adv_dhcp6_prefix_interface_statement_sla_len'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_len'];
224
225
$pconfig['adv_dhcp6_authentication_statement_authname'] = $wancfg['adv_dhcp6_authentication_statement_authname'];
226
$pconfig['adv_dhcp6_authentication_statement_protocol'] = $wancfg['adv_dhcp6_authentication_statement_protocol'];
227
$pconfig['adv_dhcp6_authentication_statement_algorithm'] = $wancfg['adv_dhcp6_authentication_statement_algorithm'];
228
$pconfig['adv_dhcp6_authentication_statement_rdm'] = $wancfg['adv_dhcp6_authentication_statement_rdm'];
229
230
$pconfig['adv_dhcp6_key_info_statement_keyname'] = $wancfg['adv_dhcp6_key_info_statement_keyname'];
231
$pconfig['adv_dhcp6_key_info_statement_realm'] = $wancfg['adv_dhcp6_key_info_statement_realm'];
232
$pconfig['adv_dhcp6_key_info_statement_keyid'] = $wancfg['adv_dhcp6_key_info_statement_keyid'];
233
$pconfig['adv_dhcp6_key_info_statement_secret'] = $wancfg['adv_dhcp6_key_info_statement_secret'];
234
$pconfig['adv_dhcp6_key_info_statement_expire'] = $wancfg['adv_dhcp6_key_info_statement_expire'];
235
236
$pconfig['adv_dhcp6_config_advanced'] = $wancfg['adv_dhcp6_config_advanced'];
237
$pconfig['adv_dhcp6_config_file_override'] = $wancfg['adv_dhcp6_config_file_override'];
238
$pconfig['adv_dhcp6_config_file_override_path'] = $wancfg['adv_dhcp6_config_file_override_path'];
239
240 e4d40f41 gnhb
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
241 f1f60c92 Ermal Luçi
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
242 6a688547 Ermal
$pconfig['enable'] = isset($wancfg['enable']);
243 f1f60c92 Ermal Luçi
244 9ff9a1c7 Seth Mos
if (is_array($config['aliases']['alias'])) {
245
	foreach($config['aliases']['alias'] as $alias) {
246
		if($alias['name'] == $wancfg['descr']) {
247 ea6be4a7 Erik Fonnesbeck
			$input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."),$wancfg['descr']);
248 9ff9a1c7 Seth Mos
		}
249
	}
250
}
251
252
switch($wancfg['ipaddr']) {
253
	case "dhcp":
254
		$pconfig['type'] = "dhcp";
255
		break;
256
	case "pppoe":
257
	case "pptp":
258 e4d40f41 gnhb
	case "l2tp":
259 611ae852 Ermal
	case "ppp":
260 d85ba87f gnhb
		$pconfig['type'] = $wancfg['ipaddr'];
261 611ae852 Ermal
		break;
262 9ff9a1c7 Seth Mos
	default:
263 85e9cfee Phil Davis
		if(is_ipaddrv4($wancfg['ipaddr'])) {
264 47593ac6 Seth Mos
			$pconfig['type'] = "staticv4";
265 9ff9a1c7 Seth Mos
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
266
			$pconfig['subnet'] = $wancfg['subnet'];
267
			$pconfig['gateway'] = $wancfg['gateway'];
268 dd18038e Ermal
		} else
269 9ff9a1c7 Seth Mos
			$pconfig['type'] = "none";
270
		break;
271
}
272 5b237745 Scott Ullrich
273 47593ac6 Seth Mos
switch($wancfg['ipaddrv6']) {
274 feb88a14 smos
	case "slaac":
275
		$pconfig['type6'] = "slaac";
276
		break;
277 e029943a Seth Mos
	case "dhcp6":
278
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
279 8839e3fb bcyrill
		if(!isset($wancfg['dhcp6-ia-pd-len']))
280 e029943a Seth Mos
			$wancfg['dhcp6-ia-pd-len'] = "none";
281
		$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
282 18f3c2fd Daniel Becker
		$pconfig['dhcp6-ia-pd-send-hint'] = isset($wancfg['dhcp6-ia-pd-send-hint']);
283 e029943a Seth Mos
		$pconfig['type6'] = "dhcp6";
284 a13acc0e smos
		$pconfig['dhcp6prefixonly'] = isset($wancfg['dhcp6prefixonly']);
285 dbb4e089 Ermal
		$pconfig['dhcp6usev4iface'] = isset($wancfg['dhcp6usev4iface']);
286 e029943a Seth Mos
		break;
287 31c43fd3 smos
	case "6to4":
288
		$pconfig['type6'] = "6to4";
289
		break;
290 20a7cb15 smos
	case "track6":
291
		$pconfig['type6'] = "track6";
292
		$pconfig['track6-interface'] = $wancfg['track6-interface'];
293 02203e6d Renato Botelho
		if ($wancfg['track6-prefix-id'] == "")
294
			$pconfig['track6-prefix-id'] = 0;
295
		else
296
			$pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
297
		$pconfig['track6-prefix-id--hex'] = sprintf("%x", $pconfig['track6-prefix-id']);
298 20a7cb15 smos
		break;
299 7d567088 smos
	case "6rd":
300
		$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
301 12215bfb smos
		if($wancfg['prefix-6rd-v4plen'] == "")
302
			$wancfg['prefix-6rd-v4plen'] = "0";
303
		$pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen'];
304 7d567088 smos
		$pconfig['type6'] = "6rd";
305
		$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
306
		break;
307 47593ac6 Seth Mos
	default:
308 85e9cfee Phil Davis
		if(is_ipaddrv6($wancfg['ipaddrv6'])) {
309 e029943a Seth Mos
			$pconfig['type6'] = "staticv6";
310 47593ac6 Seth Mos
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
311
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
312
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
313 e029943a Seth Mos
		} else
314
			$pconfig['type6'] = "none";
315 47593ac6 Seth Mos
		break;
316
}
317
318 0eb78676 smos
// print_r($pconfig);
319 47593ac6 Seth Mos
320 5b237745 Scott Ullrich
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
321 ff1955ee Bill Marquette
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
322 5b237745 Scott Ullrich
$pconfig['spoofmac'] = $wancfg['spoofmac'];
323
$pconfig['mtu'] = $wancfg['mtu'];
324 4cea5cf8 Ermal
$pconfig['mss'] = $wancfg['mss'];
325 5b237745 Scott Ullrich
326
/* Wireless interface? */
327 b7f01f59 Bill Marquette
if (isset($wancfg['wireless'])) {
328 ebf94efb Erik Fonnesbeck
	/* Sync first to be sure it displays the actual settings that will be used */
329
	interface_sync_wireless_clones($wancfg, false);
330 4634cb48 Ermal Luçi
	/* Get wireless modes */
331 10394059 Scott Ullrich
	$wlanif = get_real_interface($if);
332 3f23b74d Erik Fonnesbeck
	if (!does_interface_exist($wlanif))
333
		interface_wireless_clone($wlanif, $wancfg);
334 34808d4e Erik Fonnesbeck
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
335 6681fdd3 Erik Fonnesbeck
	preg_match("/^(.*?)([0-9]*)$/", $wlanbaseif, $wlanbaseif_split);
336 10394059 Scott Ullrich
	$wl_modes = get_wireless_modes($if);
337 f4094f0d Erik Fonnesbeck
	$wl_chaninfo = get_wireless_channel_info($if);
338 6681fdd3 Erik Fonnesbeck
	$wl_sysctl_prefix = 'dev.' . $wlanbaseif_split[1] . '.' . $wlanbaseif_split[2];
339 537bf7b3 Erik Fonnesbeck
	$wl_sysctl = get_sysctl(array("{$wl_sysctl_prefix}.diversity", "{$wl_sysctl_prefix}.txantenna", "{$wl_sysctl_prefix}.rxantenna",
340 6d529efd Renato Botelho
				      "{$wl_sysctl_prefix}.slottime", "{$wl_sysctl_prefix}.acktimeout", "{$wl_sysctl_prefix}.ctstimeout"));
341 071d63b9 Erik Fonnesbeck
	$wl_regdomain_xml_attr = array();
342
	$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
343
	$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
344
	$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
345
	$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
346
	$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
347 f62c44d8 Erik Fonnesbeck
	$pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]);
348 4634cb48 Ermal Luçi
	$pconfig['standard'] = $wancfg['wireless']['standard'];
349
	$pconfig['mode'] = $wancfg['wireless']['mode'];
350
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
351 ff2f4e43 Ermal Luçi
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
352 4634cb48 Ermal Luçi
	$pconfig['channel'] = $wancfg['wireless']['channel'];
353
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
354 537bf7b3 Erik Fonnesbeck
	$pconfig['diversity'] = $wancfg['wireless']['diversity'];
355
	$pconfig['txantenna'] = $wancfg['wireless']['txantenna'];
356
	$pconfig['rxantenna'] = $wancfg['wireless']['rxantenna'];
357 4634cb48 Ermal Luçi
	$pconfig['distance'] = $wancfg['wireless']['distance'];
358 20f09b3b Erik Fonnesbeck
	$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
359
	$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
360
	$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
361 4634cb48 Ermal Luçi
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
362 57bbd532 Erik Fonnesbeck
	if (isset($wancfg['wireless']['puren']['enable']))
363
		$pconfig['puremode'] = '11n';
364
	else if (isset($wancfg['wireless']['pureg']['enable']))
365
		$pconfig['puremode'] = '11g';
366
	else
367
		$pconfig['puremode'] = 'any';
368 4634cb48 Ermal Luçi
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
369
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
370
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
371 5949124c Scott Ullrich
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
372
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
373
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
374 32764288 Namezero
	$pconfig['auth_server_addr2'] = $wancfg['wireless']['auth_server_addr2'];
375
	$pconfig['auth_server_port2'] = $wancfg['wireless']['auth_server_port2'];
376
	$pconfig['auth_server_shared_secret2'] = $wancfg['wireless']['auth_server_shared_secret2'];
377 4634cb48 Ermal Luçi
	if (is_array($wancfg['wireless']['wpa'])) {
378
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
379
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
380
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
381
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
382
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
383
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
384
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
385
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
386
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
387
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
388
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
389 bfe1ef8c Ermal Luçi
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
390 ea62cd32 Scott Ullrich
		$pconfig['rsn_preauth'] = isset($wancfg['wireless']['wpa']['rsn_preauth']);
391 4634cb48 Ermal Luçi
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
392
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
393
	}
394
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
395
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
396 270c4607 Scott Ullrich
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
397 53c82ef9 Scott Ullrich
		$i = 1;
398
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
399
			$pconfig['key' . $i] = $wepkey['value'];
400
			if (isset($wepkey['txkey']))
401
				$pconfig['txkey'] = $i;
402
			$i++;
403
		}
404
		if (!isset($wepkey['txkey']))
405
			$pconfig['txkey'] = 1;
406 4634cb48 Ermal Luçi
	}
407 5b237745 Scott Ullrich
}
408
409 6b2d4b5a Darren Embry
$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']);
410
$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
411
412 43e255d2 Ermal Luçi
if ($_POST['apply']) {
413 7994c3f8 Ermal Luçi
	unset($input_errors);
414 a368a026 Ermal Lu?i
	if (!is_subsystem_dirty('interfaces'))
415 136c598d Carlos Eduardo Ramos
		$intput_errors[] = gettext("You have already applied your settings!");
416 c0948c6c Renato Botelho
	else {
417 270c4607 Scott Ullrich
		unlink_if_exists("{$g['tmp_path']}/config.cache");
418 a368a026 Ermal Lu?i
		clear_subsystem_dirty('interfaces');
419 c0948c6c Renato Botelho
420 dd18038e Ermal
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
421
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
422 18f338da Ermal Lu?i
			foreach ($toapplylist as $ifapply => $ifcfgo) {
423 d9797fd6 Renato Botelho
				if (isset($config['interfaces'][$ifapply]['enable'])) {
424
					interface_bring_down($ifapply, false, $ifcfgo);
425 613a3cc5 Renato Botelho
					interface_configure($ifapply, true);
426 d9797fd6 Renato Botelho
				} else
427
					interface_bring_down($ifapply, true, $ifcfgo);
428 dd18038e Ermal
			}
429
		}
430 c0948c6c Renato Botelho
		/* restart snmp so that it binds to correct address */
431
		services_snmpd_configure();
432 a5d6f60b Ermal Lu?i
433 270c4607 Scott Ullrich
		/* sync filter configuration */
434 61fc1160 Scott Ullrich
		setup_gateways_monitor();
435 a5d6f60b Ermal Lu?i
436 18f338da Ermal Lu?i
		clear_subsystem_dirty('interfaces');
437 c0948c6c Renato Botelho
438 b4d36392 Scott Ullrich
		filter_configure();
439 c0948c6c Renato Botelho
440 1ee5d4b3 sullrich
		enable_rrd_graphing();
441 244dee81 Renato Botelho
442
		if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0))
443
			clear_subsystem_dirty('staticroutes');
444 7994c3f8 Ermal Luçi
	}
445 dd18038e Ermal
	@unlink("{$g['tmp_path']}/.interfaces.apply");
446 7994c3f8 Ermal Luçi
	header("Location: interfaces.php?if={$if}");
447
	exit;
448 dd18038e Ermal
} else if ($_POST && $_POST['enable'] != "yes") {
449 270c4607 Scott Ullrich
	unset($wancfg['enable']);
450 dd18038e Ermal
	if (isset($wancfg['wireless']))
451 8f0289e7 Erik Fonnesbeck
		interface_sync_wireless_clones($wancfg, false);
452 270c4607 Scott Ullrich
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
453 a368a026 Ermal Lu?i
	mark_subsystem_dirty('interfaces');
454 ee5c01b5 Seth Mos
	if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
455 dd18038e Ermal
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
456 ee5c01b5 Seth Mos
	} else {
457 dd18038e Ermal
		$toapplylist = array();
458 ee5c01b5 Seth Mos
	}
459 e12ad49f Renato Botelho
	$toapplylist[$if]['ifcfg'] = $wancfg;
460
	$toapplylist[$if]['ppps'] = $a_ppps;
461 ee5c01b5 Seth Mos
	/* we need to be able remove IP aliases for IPv6 */
462 dd18038e Ermal
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
463 270c4607 Scott Ullrich
	header("Location: interfaces.php?if={$if}");
464
	exit;
465 dd18038e Ermal
} else if ($_POST) {
466 270c4607 Scott Ullrich
467 53c82ef9 Scott Ullrich
	unset($input_errors);
468
	$pconfig = $_POST;
469 aeb44799 Renato Botelho
470
	if (isset($_POST['track6-interface'])) {
471
		$ipv6_delegation_length = calculate_ipv6_delegation_length($_POST['track6-interface']);
472
		$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
473
	}
474
475 02203e6d Renato Botelho
	if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
476 6b2d4b5a Darren Embry
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
477 02203e6d Renato Botelho
	else
478
		$pconfig['track6-prefix-id'] = 0;
479 53c82ef9 Scott Ullrich
	conf_mount_rw();
480 fe24301f Ermal
481 53c82ef9 Scott Ullrich
	/* filter out spaces from descriptions  */
482
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
483 fe24301f Ermal
484 b4d36392 Scott Ullrich
	/* okay first of all, cause we are just hiding the PPPoE HTML
485 53c82ef9 Scott Ullrich
	 * fields releated to PPPoE resets, we are going to unset $_POST
486
	 * vars, if the reset feature should not be used. Otherwise the
487
	 * data validation procedure below, may trigger a false error
488
	 * message.
489
	 */
490 e40e6724 gnhb
	if (empty($_POST['pppoe-reset-type'])) {
491 c0948c6c Renato Botelho
		unset($_POST['pppoe_pr_type']);
492 53c82ef9 Scott Ullrich
		unset($_POST['pppoe_resethour']);
493
		unset($_POST['pppoe_resetminute']);
494
		unset($_POST['pppoe_resetdate']);
495
		unset($_POST['pppoe_pr_preset_val']);
496
	}
497
	/* description unique? */
498 dd18038e Ermal
	foreach ($ifdescrs as $ifent => $ifdescr) {
499 79851fc8 Ermal
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
500 136c598d Carlos Eduardo Ramos
			$input_errors[] = gettext("An interface with the specified description already exists.");
501 79851fc8 Ermal
			break;
502
		}
503 53c82ef9 Scott Ullrich
	}
504
	/* input validation */
505 e029943a Seth Mos
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^staticv4/", $_POST['type'])))
506 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("The DHCP Server is active on this interface and it can be used only with a static IP configuration. Please disable the DHCP Server service on this interface first, then change the interface configuration.");
507 1f56ce58 Renato Botelho
	if (isset($config['dhcpdv6']) && isset($config['dhcpdv6'][$if]['enable']) && (! preg_match("/^staticv6/", $_POST['type6'])))
508 e029943a Seth Mos
		$input_errors[] = gettext("The DHCP6 Server is active on this interface and it can be used only with a static IPv6 configuration. Please disable the DHCPv6 Server service on this interface first, then change the interface configuration.");
509 0c9da721 Ermal Lu?i
510 ef130e9f Ermal
	switch(strtolower($_POST['type'])) {
511 47593ac6 Seth Mos
		case "staticv4":
512 9ff9a1c7 Seth Mos
			$reqdfields = explode(" ", "ipaddr subnet gateway");
513 47593ac6 Seth Mos
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
514 1e9b4611 Renato Botelho
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
515 47593ac6 Seth Mos
			break;
516 88c00a65 Ermal
		case "none":
517 62a4abc9 Ermal
			if(is_array($config['virtualip']['vip'])) {
518
				foreach ($config['virtualip']['vip'] as $vip) {
519 2452cc37 Darren Embry
					if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if)
520
						$input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration.");
521 62a4abc9 Ermal
				}
522
			}
523 88c00a65 Ermal
		case "dhcp":
524 a9543eae Seth Mos
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp")))
525 d1d0a1ad Vinicius Coque
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
526 47593ac6 Seth Mos
			break;
527 513b762e gnhb
		case "ppp":
528
			$reqdfields = explode(" ", "port phone");
529 8cc6876f groo
			$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
530 1e9b4611 Renato Botelho
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
531 513b762e gnhb
			break;
532 ef130e9f Ermal
		case "pppoe":
533 9ff9a1c7 Seth Mos
			if ($_POST['pppoe_dialondemand']) {
534
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
535 8cc6876f groo
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
536 9ff9a1c7 Seth Mos
			} else {
537
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
538 8cc6876f groo
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
539 9ff9a1c7 Seth Mos
			}
540 1e9b4611 Renato Botelho
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
541 9ff9a1c7 Seth Mos
			break;
542 ef130e9f Ermal
		case "pptp":
543 9ff9a1c7 Seth Mos
			if ($_POST['pptp_dialondemand']) {
544
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
545 8cc6876f groo
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
546 9ff9a1c7 Seth Mos
			} else {
547
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
548 8cc6876f groo
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
549 9ff9a1c7 Seth Mos
			}
550 1e9b4611 Renato Botelho
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
551 9ff9a1c7 Seth Mos
			break;
552 e4d40f41 gnhb
		case "l2tp":
553
			if ($_POST['pptp_dialondemand']) {
554
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
555
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
556
			} else {
557
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
558
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"));
559
			}
560 1e9b4611 Renato Botelho
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
561 e4d40f41 gnhb
			break;
562 53c82ef9 Scott Ullrich
	}
563 e029943a Seth Mos
	switch(strtolower($_POST['type6'])) {
564
		case "staticv6":
565 20b49b17 Seth Mos
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
566 1e37f324 smos
			$reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
567 1e9b4611 Renato Botelho
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
568 e029943a Seth Mos
			break;
569
		case "none":
570
			if(is_array($config['virtualip']['vip'])) {
571
				foreach ($config['virtualip']['vip'] as $vip) {
572 2452cc37 Darren Embry
					if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if)
573
						$input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration.");
574 e029943a Seth Mos
				}
575
			}
576
		case "dhcp6":
577
			if (in_array($wancfg['ipaddrv6'], array()))
578 8b198c64 smos
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
579 e029943a Seth Mos
			break;
580 7d567088 smos
		case "6rd":
581 8b198c64 smos
			foreach ($ifdescrs as $ifent => $ifdescr) {
582 dcddb2fa Ermal
				if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
583
					if ($config[interfaces][$ifent]['prefix-6rd'] == $_POST['prefix-6rd']) {
584
						$input_errors[] = gettext("You can only have one interface configured in 6rd with same prefix.");
585
						break;
586
					}
587 8b198c64 smos
				}
588
			}
589 7d567088 smos
			if (in_array($wancfg['ipaddrv6'], array()))
590 8b198c64 smos
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
591 7d567088 smos
			break;
592 31c43fd3 smos
		case "6to4":
593 8b198c64 smos
			foreach ($ifdescrs as $ifent => $ifdescr) {
594 dcddb2fa Ermal
				if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
595
					$input_errors[] = sprintf(gettext("You can only have one interface configured as 6to4."),$_POST['type6']);
596 8b198c64 smos
					break;
597
				}
598
			}
599 31c43fd3 smos
			if (in_array($wancfg['ipaddrv6'], array()))
600 8b198c64 smos
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
601 31c43fd3 smos
			break;
602 20a7cb15 smos
		case "track6":
603
			/* needs to check if $track6-prefix-id is used on another interface */
604
			if (in_array($wancfg['ipaddrv6'], array()))
605 8b198c64 smos
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
606 6b2d4b5a Darren Embry
607
			if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
608
				$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
609
			} else {
610
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
611
				if ($track6_prefix_id < 0 || $track6_prefix_id >= $ipv6_num_prefix_ids) {
612
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.");
613
				}
614
			}
615 20a7cb15 smos
			break;
616 e029943a Seth Mos
	}
617 9ff9a1c7 Seth Mos
618 6d529efd Renato Botelho
619 53c82ef9 Scott Ullrich
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
620 42fa2c01 Renato Botelho
	$staticroutes = get_staticroutes(true);
621 53c82ef9 Scott Ullrich
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
622 e6c60013 Renato Botelho
	if ($_POST['ipaddr']) {
623
		if (!is_ipaddrv4($_POST['ipaddr']))
624
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
625 42fa2c01 Renato Botelho
		else {
626
			if (is_ipaddr_configured($_POST['ipaddr'], $if, true))
627
				$input_errors[] = gettext("This IPv4 address is being used by another interface or VIP.");
628
629 20dda766 Renato Botelho
			/* Do not accept network or broadcast address, except if subnet is 31 or 32 */
630
			if ($_POST['subnet'] < 31) {
631
				if ($_POST['ipaddr'] == gen_subnet($_POST['ipaddr'], $_POST['subnet']))
632
					$input_errors[] = gettext("This IPv4 address is the network address and cannot be used");
633
				else if ($_POST['ipaddr'] == gen_subnet_max($_POST['ipaddr'], $_POST['subnet']))
634
					$input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used");
635
			}
636
637 42fa2c01 Renato Botelho
			foreach ($staticroutes as $route_subnet) {
638 e480d64b Renato Botelho
				list($network, $subnet) = explode("/", $route_subnet);
639
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
640 42fa2c01 Renato Botelho
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
641
					break;
642
				}
643 e480d64b Renato Botelho
				unset($network, $subnet);
644 42fa2c01 Renato Botelho
			}
645
		}
646 e6c60013 Renato Botelho
	}
647 6e828f98 Renato Botelho
	if ($_POST['ipaddrv6']) {
648
		if (!is_ipaddrv6($_POST['ipaddrv6']))
649
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
650 42fa2c01 Renato Botelho
		else {
651
			if (is_ipaddr_configured($_POST['ipaddrv6'], $if, true))
652
				$input_errors[] = gettext("This IPv6 address is being used by another interface or VIP.");
653
654
			foreach ($staticroutes as $route_subnet) {
655 e480d64b Renato Botelho
				list($network, $subnet) = explode("/", $route_subnet);
656
				if ($_POST['subnetv6'] == $subnet && $network == gen_subnetv6($_POST['ipaddrv6'], $_POST['subnetv6'])) {
657 42fa2c01 Renato Botelho
					$input_errors[] = gettext("This IPv6 address conflicts with a Static Route.");
658
					break;
659
				}
660 e480d64b Renato Botelho
				unset($network, $subnet);
661 42fa2c01 Renato Botelho
			}
662
		}
663 6e828f98 Renato Botelho
	}
664 c0948c6c Renato Botelho
	if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
665 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
666 47593ac6 Seth Mos
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6'])))
667
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
668 85e9cfee Phil Davis
	if (($_POST['alias-address'] && !is_ipaddrv4($_POST['alias-address'])))
669 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid alias IP address must be specified.");
670 c0948c6c Renato Botelho
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
671 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
672 57c83fd6 jim-p
	if ($_POST['dhcprejectfrom'] && !is_ipaddrv4($_POST['dhcprejectfrom']))
673
		$input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from.");
674 47593ac6 Seth Mos
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
675 53c82ef9 Scott Ullrich
		$match = false;
676 9ff9a1c7 Seth Mos
		foreach($a_gateways as $gateway) {
677
			if(in_array($_POST['gateway'], $gateway)) {
678 53c82ef9 Scott Ullrich
				$match = true;
679 9ff9a1c7 Seth Mos
			}
680
		}
681 47593ac6 Seth Mos
		foreach($a_gateways as $gateway) {
682
			if(in_array($_POST['gatewayv6'], $gateway)) {
683
				$match = true;
684
			}
685
		}
686 9ff9a1c7 Seth Mos
		if(!$match) {
687 136c598d Carlos Eduardo Ramos
			$input_errors[] = gettext("A valid gateway must be specified.");
688 9ff9a1c7 Seth Mos
		}
689 53c82ef9 Scott Ullrich
	}
690 c0948c6c Renato Botelho
	if (($_POST['provider'] && !is_domain($_POST['provider'])))
691 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("The service name contains invalid characters.");
692 c0948c6c Renato Botelho
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
693 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("The idle timeout value must be an integer.");
694 c0948c6c Renato Botelho
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
695
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23)
696 53c82ef9 Scott Ullrich
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
697 c0948c6c Renato Botelho
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
698
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59)
699 53c82ef9 Scott Ullrich
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
700 c0948c6c Renato Botelho
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate'])))
701 53c82ef9 Scott Ullrich
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
702 85e9cfee Phil Davis
	if (($_POST['pptp_local'] && !is_ipaddrv4($_POST['pptp_local'])))
703 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
704 c0948c6c Renato Botelho
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet'])))
705 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
706 85e9cfee Phil Davis
	if (($_POST['pptp_remote'] && !is_ipaddrv4($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface])))
707 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
708 c0948c6c Renato Botelho
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout']))
709 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("The idle timeout value must be an integer.");
710 c0948c6c Renato Botelho
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])))
711 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid MAC address must be specified.");
712 0d0d4a27 Renato Botelho
	if ($_POST['mtu']) {
713 b783eaf2 Ermal
		if ($_POST['mtu'] < 576 || $_POST['mtu'] > 9000)
714 f6d89471 Ermal
			$input_errors[] = gettext("The MTU must be greater than 576 bytes and less than 9000.");
715 0d0d4a27 Renato Botelho
716 a58a9ece Ermal
		if (stristr($wancfg['if'], "_vlan")) {
717 0d0d4a27 Renato Botelho
			$realhwif_array = get_parent_interface($wancfg['if']);
718
			// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
719
			$parent_realhwif = $realhwif_array[0];
720
			$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
721 f6d89471 Ermal
			if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) {
722
				if ($_POST['mtu'] > intval($config['interfaces'][$parent_if]['mtu']))
723 0d0d4a27 Renato Botelho
					$input_errors[] = gettext("MTU of a vlan should not be bigger than parent interface.");
724
			}
725
		} else {
726
			foreach ($config['interfaces'] as $idx => $ifdata) {
727
				if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if']))
728
					continue;
729
730
				$realhwif_array = get_parent_interface($ifdata['if']);
731
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
732
				$parent_realhwif = $realhwif_array[0];
733
734
				if ($parent_realhwif != $wancfg['if'])
735
					continue;
736
737
				if (isset($ifdata['mtu']) && $ifdata['mtu'] > $_POST['mtu'])
738
					$input_errors[] = sprintf(gettext("Interface %s (VLAN) has MTU set to a bigger value"), $ifdata['descr']);
739
			}
740
		}
741
	}
742 c0948c6c Renato Botelho
	if ($_POST['mss'] && ($_POST['mss'] < 576))
743 4cea5cf8 Ermal
		$input_errors[] = gettext("The MSS must be greater than 576 bytes.");
744 53c82ef9 Scott Ullrich
	/* Wireless interface? */
745
	if (isset($wancfg['wireless'])) {
746 bb9d70d2 Erik Fonnesbeck
		$reqdfields = array("mode");
747
		$reqdfieldsn = array(gettext("Mode"));
748
		if ($_POST['mode'] == 'hostap') {
749
			$reqdfields[] = "ssid";
750
			$reqdfieldsn[] = gettext("SSID");
751
		}
752 1e9b4611 Renato Botelho
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
753 597330aa Erik Fonnesbeck
		check_wireless_mode();
754 53c82ef9 Scott Ullrich
		/* loop through keys and enforce size */
755
		for ($i = 1; $i <= 4; $i++) {
756
			if ($_POST['key' . $i]) {
757
				/* 64 bit */
758
				if (strlen($_POST['key' . $i]) == 5)
759
					continue;
760
				if (strlen($_POST['key' . $i]) == 10) {
761
					/* hex key */
762
					if (stristr($_POST['key' . $i], "0x") == false) {
763 4634cb48 Ermal Luçi
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
764
					}
765 53c82ef9 Scott Ullrich
					continue;
766
				}
767
				if (strlen($_POST['key' . $i]) == 12) {
768
					/* hex key */
769
					if(stristr($_POST['key' . $i], "0x") == false) {
770
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
771 4634cb48 Ermal Luçi
					}
772 53c82ef9 Scott Ullrich
					continue;
773
				}
774
				/* 128 bit */
775
				if (strlen($_POST['key' . $i]) == 13)
776
					continue;
777
				if (strlen($_POST['key' . $i]) == 26) {
778
					/* hex key */
779
					if (stristr($_POST['key' . $i], "0x") == false)
780
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
781
					continue;
782 4634cb48 Ermal Luçi
				}
783 53c82ef9 Scott Ullrich
				if(strlen($_POST['key' . $i]) == 28)
784
					continue;
785 136c598d Carlos Eduardo Ramos
				$input_errors[] =  gettext("Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.");
786 53c82ef9 Scott Ullrich
				break;
787 4634cb48 Ermal Luçi
			}
788 5b237745 Scott Ullrich
		}
789 08fae438 Ermal Lu?i
790
		if ($_POST['passphrase']) {
791 6d529efd Renato Botelho
			$passlen = strlen($_POST['passphrase']);
792 df78d8cc Renato Botelho
			if ($passlen < 8 || $passlen > 63)
793 6d529efd Renato Botelho
				$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
794 08fae438 Ermal Lu?i
		}
795 53c82ef9 Scott Ullrich
	}
796
	if (!$input_errors) {
797 8b1e7d04 Ermal
		if ($wancfg['ipaddr'] != $_POST['type']) {
798 ef130e9f Ermal
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
799
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
800
				unset($a_ppps[$pppid]);
801 8b1e7d04 Ermal
			} else if ($wancfg['ipaddr'] == "dhcp") {
802 d9d1bd20 Renato Botelho
				kill_dhclient_process($wancfg['if']);
803 ef130e9f Ermal
			}
804 89c7a9c8 Ermal
			if ($wancfg['ipaddrv6'] == "dhcp6") {
805
				$pid = find_dhcp6c_process($wancfg['if']);
806
				if($pid)
807
					posix_kill($pid, SIGTERM);
808
			}
809 ef130e9f Ermal
		}
810 d85ba87f gnhb
		$ppp = array();
811 da75413d Ermal
		if ($wancfg['ipaddr'] != "ppp")
812
			unset($wancfg['ipaddr']);
813 47593ac6 Seth Mos
		if ($wancfg['ipaddrv6'] != "ppp")
814
			unset($wancfg['ipaddrv6']);
815 53c82ef9 Scott Ullrich
		unset($wancfg['subnet']);
816
		unset($wancfg['gateway']);
817 47593ac6 Seth Mos
		unset($wancfg['subnetv6']);
818
		unset($wancfg['gatewayv6']);
819 53c82ef9 Scott Ullrich
		unset($wancfg['dhcphostname']);
820 57c83fd6 jim-p
		unset($wancfg['dhcprejectfrom']);
821 ed395640 Seth Mos
		unset($wancfg['dhcp6-duid']);
822
		unset($wancfg['dhcp6-ia-pd-len']);
823 18f3c2fd Daniel Becker
		unset($wancfg['dhcp6-ia-pd-send-hint']);
824 a13acc0e smos
		unset($wancfg['dhcp6prefixonly']);
825 dbb4e089 Ermal
		unset($wancfg['dhcp6usev4iface']);
826 20a7cb15 smos
		unset($wancfg['track6-interface']);
827 6d529efd Renato Botelho
		unset($wancfg['track6-prefix-id']);
828 7d567088 smos
		unset($wancfg['prefix-6rd']);
829 12215bfb smos
		unset($wancfg['prefix-6rd-v4plen']);
830 7d567088 smos
		unset($wancfg['gateway-6rd']);
831 f4dd8b4c N0YB
832
		unset($wancfg['adv_dhcp_pt_timeout']);
833
		unset($wancfg['adv_dhcp_pt_retry']);
834
		unset($wancfg['adv_dhcp_pt_select_timeout']);
835
		unset($wancfg['adv_dhcp_pt_reboot']);
836
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
837
		unset($wancfg['adv_dhcp_pt_initial_interval']);
838
839
		unset($wancfg['adv_dhcp_pt_values']);
840
841
		unset($wancfg['adv_dhcp_send_options']);
842
		unset($wancfg['adv_dhcp_request_options']);
843
		unset($wancfg['adv_dhcp_required_options']);
844
		unset($wancfg['adv_dhcp_option_modifiers']);
845
846
		unset($wancfg['adv_dhcp_config_advanced']);
847
		unset($wancfg['adv_dhcp_config_file_override']);
848
		unset($wancfg['adv_dhcp_config_file_override_path']);
849
850
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
851
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
852
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
853
		unset($wancfg['adv_dhcp6_interface_statement_script']);
854
855
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
856
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
857
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
858
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
859
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
860
861
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
862
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
863
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
864
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
865
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
866
867
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
868
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
869
870
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
871
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
872
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
873
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
874
875
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
876
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
877
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
878
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
879
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
880
881
		unset($wancfg['adv_dhcp6_config_advanced']);
882
		unset($wancfg['adv_dhcp6_config_file_override']);
883
		unset($wancfg['adv_dhcp6_config_file_override_path']);
884
885 53c82ef9 Scott Ullrich
		unset($wancfg['pppoe_password']);
886
		unset($wancfg['pptp_username']);
887
		unset($wancfg['pptp_password']);
888
		unset($wancfg['provider']);
889
		unset($wancfg['ondemand']);
890
		unset($wancfg['timeout']);
891 70e46e62 Ermal
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
892 8b7ae9a3 jim-p
			unset($wancfg['pppoe']['pppoe-reset-type']);
893 53c82ef9 Scott Ullrich
		unset($wancfg['local']);
894 6d529efd Renato Botelho
895 53c82ef9 Scott Ullrich
		unset($wancfg['remote']);
896 8256f324 gnhb
		unset($a_ppps[$pppid]['apn']);
897
		unset($a_ppps[$pppid]['phone']);
898
		unset($a_ppps[$pppid]['localip']);
899
		unset($a_ppps[$pppid]['subnet']);
900
		unset($a_ppps[$pppid]['gateway']);
901
		unset($a_ppps[$pppid]['pppoe-reset-type']);
902 1d7e1d6c gnhb
		unset($a_ppps[$pppid]['provider']);
903 c0948c6c Renato Botelho
904 53c82ef9 Scott Ullrich
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
905 6a688547 Ermal
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
906 9ff9a1c7 Seth Mos
907 2fe06a32 smos
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
908 9ff9a1c7 Seth Mos
		switch($_POST['type']) {
909 47593ac6 Seth Mos
			case "staticv4":
910
				$wancfg['ipaddr'] = $_POST['ipaddr'];
911
				$wancfg['subnet'] = $_POST['subnet'];
912
				if ($_POST['gateway'] != "none") {
913
					$wancfg['gateway'] = $_POST['gateway'];
914
				}
915
				break;
916 9ff9a1c7 Seth Mos
			case "dhcp":
917
				$wancfg['ipaddr'] = "dhcp";
918
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
919
				$wancfg['alias-address'] = $_POST['alias-address'];
920
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
921 57c83fd6 jim-p
				$wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom'];
922 f4dd8b4c N0YB
923
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
924
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
925
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
926
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
927
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
928
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
929
930
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
931
932
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
933
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
934
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
935
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
936
937
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
938
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
939
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
940
941 e4d40f41 gnhb
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
942 9ff9a1c7 Seth Mos
				if($gateway_item) {
943
					$a_gateways[] = $gateway_item;
944
				}
945
				break;
946 3a906378 gnhb
			case "ppp":
947
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
948
				$a_ppps[$pppid]['type'] = $_POST['type'];
949 1d7e1d6c gnhb
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
950 3a906378 gnhb
				$a_ppps[$pppid]['ports'] = $_POST['port'];
951
				$a_ppps[$pppid]['username'] = $_POST['username'];
952
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
953 8256f324 gnhb
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
954 3a906378 gnhb
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
955 1d7e1d6c gnhb
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
956 8256f324 gnhb
				$wancfg['ipaddr'] = $_POST['type'];
957
				unset($a_ppps[$pppid]['ondemand']);
958
				unset($a_ppps[$pppid]['idletimeout']);
959 3a906378 gnhb
				break;
960
961 9ff9a1c7 Seth Mos
			case "pppoe":
962 6c05cfb0 gnhb
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
963
				$a_ppps[$pppid]['type'] = $_POST['type'];
964 1d7e1d6c gnhb
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
965 d85ba87f gnhb
				if (isset($_POST['ppp_port']))
966 6c05cfb0 gnhb
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
967 d85ba87f gnhb
				else
968 6c05cfb0 gnhb
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
969
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
970
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
971 d85ba87f gnhb
				if (!empty($_POST['provider']))
972 6c05cfb0 gnhb
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
973 d85ba87f gnhb
				else
974 233e2af1 jim-p
					$a_ppps[$pppid]['provider'] = true;
975 6c05cfb0 gnhb
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
976 0ff214f2 Renato Botelho
				if (!empty($_POST['pppoe_idletimeout']))
977 6c05cfb0 gnhb
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
978 d85ba87f gnhb
				else
979 6c05cfb0 gnhb
					unset($a_ppps[$pppid]['idletimeout']);
980 d85ba87f gnhb
981
				if (!empty($_POST['pppoe-reset-type']))
982 6c05cfb0 gnhb
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
983 d85ba87f gnhb
				else
984 6c05cfb0 gnhb
					unset($a_ppps[$pppid]['pppoe-reset-type']);
985 1d7e1d6c gnhb
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
986 d85ba87f gnhb
				$wancfg['ipaddr'] = $_POST['type'];
987 9ff9a1c7 Seth Mos
				if($gateway_item) {
988
					$a_gateways[] = $gateway_item;
989
				}
990 c0948c6c Renato Botelho
991 9ff9a1c7 Seth Mos
				break;
992
			case "pptp":
993 e4d40f41 gnhb
			case "l2tp":
994 6c05cfb0 gnhb
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
995
				$a_ppps[$pppid]['type'] = $_POST['type'];
996 1d7e1d6c gnhb
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
997 d85ba87f gnhb
				if (isset($_POST['ppp_port']))
998 6c05cfb0 gnhb
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
999 d85ba87f gnhb
				else
1000 6c05cfb0 gnhb
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
1001
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
1002
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
1003 ced4df74 gnhb
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
1004 6c05cfb0 gnhb
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
1005
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
1006
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
1007 0ff214f2 Renato Botelho
				if (!empty($_POST['pptp_idletimeout']))
1008 6c05cfb0 gnhb
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
1009 d85ba87f gnhb
				else
1010 6c05cfb0 gnhb
					unset($a_ppps[$pppid]['idletimeout']);
1011 1d7e1d6c gnhb
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1012 d85ba87f gnhb
				$wancfg['ipaddr'] = $_POST['type'];
1013 9ff9a1c7 Seth Mos
				if($gateway_item) {
1014
					$a_gateways[] = $gateway_item;
1015
				}
1016
				break;
1017 6c05cfb0 gnhb
			case "none":
1018
				break;
1019 4634cb48 Ermal Luçi
		}
1020 e029943a Seth Mos
		switch($_POST['type6']) {
1021
			case "staticv6":
1022
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
1023
				$wancfg['subnetv6'] = $_POST['subnetv6'];
1024
				if ($_POST['gatewayv6'] != "none") {
1025
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
1026
				}
1027
				break;
1028 feb88a14 smos
			case "slaac":
1029
				$wancfg['ipaddrv6'] = "slaac";
1030
				break;
1031 e029943a Seth Mos
			case "dhcp6":
1032
				$wancfg['ipaddrv6'] = "dhcp6";
1033
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
1034
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
1035 18f3c2fd Daniel Becker
				if($_POST['dhcp6-ia-pd-send-hint'] == "yes")
1036
					$wancfg['dhcp6-ia-pd-send-hint'] = true;
1037 a13acc0e smos
				if($_POST['dhcp6prefixonly'] == "yes")
1038
					$wancfg['dhcp6prefixonly'] = true;
1039 dbb4e089 Ermal
				if($_POST['dhcp6usev4iface'] == "yes")
1040
					$wancfg['dhcp6usev4iface'] = true;
1041 f4dd8b4c N0YB
1042
				$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1043
				$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1044
				$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1045
				$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1046
1047
				$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1048
				$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1049
				$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1050
				$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1051
				$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1052
1053
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1054
				$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1055
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1056
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1057
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1058
1059
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1060
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1061
1062
				$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1063
				$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1064
				$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1065
				$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1066
1067
				$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1068
				$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1069
				$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1070
				$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1071
				$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1072
1073
				$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1074
				$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1075
				$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1076
1077 e029943a Seth Mos
				if($gateway_item) {
1078
					$a_gateways[] = $gateway_item;
1079
				}
1080
				break;
1081 7d567088 smos
			case "6rd":
1082
				$wancfg['ipaddrv6'] = "6rd";
1083
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
1084 12215bfb smos
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
1085 7d567088 smos
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
1086
				if($gateway_item) {
1087
					$a_gateways[] = $gateway_item;
1088
				}
1089
				break;
1090 31c43fd3 smos
			case "6to4":
1091
				$wancfg['ipaddrv6'] = "6to4";
1092
				break;
1093 20a7cb15 smos
			case "track6":
1094
				$wancfg['ipaddrv6'] = "track6";
1095
				$wancfg['track6-interface'] = $_POST['track6-interface'];
1096 02203e6d Renato Botelho
				if ($_POST['track6-prefix-id--hex'] === "")
1097
					$wancfg['track6-prefix-id'] = 0;
1098
				else if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
1099 6b2d4b5a Darren Embry
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
1100 02203e6d Renato Botelho
				else
1101
					$wancfg['track6-prefix-id'] = 0;
1102 20a7cb15 smos
				break;
1103 e029943a Seth Mos
			case "none":
1104
				break;
1105
		}
1106 1d7e1d6c gnhb
		handle_pppoe_reset($_POST);
1107 c0948c6c Renato Botelho
1108 9ff9a1c7 Seth Mos
		if($_POST['blockpriv'] == "yes") {
1109 53c82ef9 Scott Ullrich
			$wancfg['blockpriv'] = true;
1110 9ff9a1c7 Seth Mos
		} else {
1111 53c82ef9 Scott Ullrich
			unset($wancfg['blockpriv']);
1112 9ff9a1c7 Seth Mos
		}
1113
		if($_POST['blockbogons'] == "yes") {
1114 53c82ef9 Scott Ullrich
			$wancfg['blockbogons'] = true;
1115 9ff9a1c7 Seth Mos
		} else {
1116 53c82ef9 Scott Ullrich
			unset($wancfg['blockbogons']);
1117 9ff9a1c7 Seth Mos
		}
1118 53c82ef9 Scott Ullrich
		$wancfg['spoofmac'] = $_POST['spoofmac'];
1119 9ff9a1c7 Seth Mos
		if (empty($_POST['mtu'])) {
1120 d6a891da Ermal Lu?i
			unset($wancfg['mtu']);
1121 9ff9a1c7 Seth Mos
		} else {
1122 d6a891da Ermal Lu?i
			$wancfg['mtu'] = $_POST['mtu'];
1123 9ff9a1c7 Seth Mos
		}
1124 4cea5cf8 Ermal
		if (empty($_POST['mss'])) {
1125
			unset($wancfg['mss']);
1126
		} else {
1127
			$wancfg['mss'] = $_POST['mss'];
1128
		}
1129 509ca889 Evgeny Yurchenko
		if (empty($_POST['mediaopt'])) {
1130
			unset($wancfg['media']);
1131
			unset($wancfg['mediaopt']);
1132
		} else {
1133 6d529efd Renato Botelho
			$mediaopts = explode(' ', $_POST['mediaopt']);
1134 509ca889 Evgeny Yurchenko
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
1135
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
1136
			else { unset($wancfg['mediaopt']); }
1137
		}
1138 9ff9a1c7 Seth Mos
		if (isset($wancfg['wireless'])) {
1139 25a6411a Scott Ullrich
			handle_wireless_post();
1140 9ff9a1c7 Seth Mos
		}
1141 c0948c6c Renato Botelho
1142 dd18038e Ermal
		conf_mount_ro();
1143 53c82ef9 Scott Ullrich
		write_config();
1144 dd18038e Ermal
1145 ee5c01b5 Seth Mos
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
1146 dd18038e Ermal
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
1147 ee5c01b5 Seth Mos
		} else {
1148 dd18038e Ermal
			$toapplylist = array();
1149 ee5c01b5 Seth Mos
		}
1150 e12ad49f Renato Botelho
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
1151
		$toapplylist[$if]['ppps'] = $old_ppps;
1152 dd18038e Ermal
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
1153
1154 a368a026 Ermal Lu?i
		mark_subsystem_dirty('interfaces');
1155 dd18038e Ermal
1156 53c82ef9 Scott Ullrich
		/* regenerate cron settings/crontab file */
1157
		configure_cron();
1158 dd18038e Ermal
1159 53c82ef9 Scott Ullrich
		header("Location: interfaces.php?if={$if}");
1160
		exit;
1161
	}
1162 c0948c6c Renato Botelho
1163
} // end if($_POST)
1164 270c4607 Scott Ullrich
1165 25a6411a Scott Ullrich
function handle_wireless_post() {
1166 f62c44d8 Erik Fonnesbeck
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
1167 270c4607 Scott Ullrich
	if (!is_array($wancfg['wireless']))
1168
		$wancfg['wireless'] = array();
1169
	$wancfg['wireless']['standard'] = $_POST['standard'];
1170
	$wancfg['wireless']['mode'] = $_POST['mode'];
1171
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
1172
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
1173
	$wancfg['wireless']['channel'] = $_POST['channel'];
1174
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
1175
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
1176
	$wancfg['wireless']['distance'] = $_POST['distance'];
1177 20f09b3b Erik Fonnesbeck
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
1178
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
1179
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
1180
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
1181 071d63b9 Erik Fonnesbeck
		foreach($wl_countries_attr as $wl_country) {
1182
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
1183
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
1184 20f09b3b Erik Fonnesbeck
				break;
1185
			}
1186
		}
1187
	}
1188 270c4607 Scott Ullrich
	if (!is_array($wancfg['wireless']['wpa']))
1189
		$wancfg['wireless']['wpa'] = array();
1190
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
1191
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
1192
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
1193
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
1194
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
1195
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
1196
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
1197
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
1198
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
1199 5949124c Scott Ullrich
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
1200
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
1201
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
1202 32764288 Namezero
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
1203
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
1204
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
1205 6d529efd Renato Botelho
1206 f62c44d8 Erik Fonnesbeck
	if ($_POST['persistcommonwireless'] == "yes") {
1207 6ef2297b Erik Fonnesbeck
		if (!is_array($config['wireless']))
1208
			$config['wireless'] = array();
1209
		if (!is_array($config['wireless']['interfaces']))
1210
			$config['wireless']['interfaces'] = array();
1211
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
1212 f62c44d8 Erik Fonnesbeck
			$config['wireless']['interfaces'][$wlanbaseif] = array();
1213
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
1214
		unset($config['wireless']['interfaces'][$wlanbaseif]);
1215 1930ccb6 Erik Fonnesbeck
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
1216 537bf7b3 Erik Fonnesbeck
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
1217
	else if (isset($wancfg['wireless']['diversity']))
1218
		unset($wancfg['wireless']['diversity']);
1219 1930ccb6 Erik Fonnesbeck
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
1220 537bf7b3 Erik Fonnesbeck
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
1221
	else if (isset($wancfg['wireless']['txantenna']))
1222
		unset($wancfg['wireless']['txantenna']);
1223 1930ccb6 Erik Fonnesbeck
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
1224 537bf7b3 Erik Fonnesbeck
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
1225
	else if (isset($wancfg['wireless']['rxantenna']))
1226
		unset($wancfg['wireless']['rxantenna']);
1227 270c4607 Scott Ullrich
	if ($_POST['hidessid_enable'] == "yes")
1228
		$wancfg['wireless']['hidessid']['enable'] = true;
1229
	else if (isset($wancfg['wireless']['hidessid']['enable']))
1230
		unset($wancfg['wireless']['hidessid']['enable']);
1231
	if ($_POST['mac_acl_enable'] == "yes")
1232
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
1233
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
1234
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
1235 c9e7d30d Scott Ullrich
	if ($_POST['rsn_preauth'] == "yes")
1236 ea62cd32 Scott Ullrich
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
1237 c0948c6c Renato Botelho
	else
1238 ea62cd32 Scott Ullrich
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
1239 270c4607 Scott Ullrich
	if ($_POST['ieee8021x'] == "yes")
1240
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
1241
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
1242
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
1243
	if ($_POST['wpa_strict_rekey'] == "yes")
1244
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
1245
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
1246
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
1247
	if ($_POST['debug_mode'] == "yes")
1248
		$wancfg['wireless']['wpa']['debug_mode'] = true;
1249
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
1250
		sunset($wancfg['wireless']['wpa']['debug_mode']);
1251
	if ($_POST['wpa_enable'] == "yes")
1252
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
1253
	else if (isset($wancfg['wireless']['wpa']['enable']))
1254
		unset($wancfg['wireless']['wpa']['enable']);
1255
	if ($_POST['wep_enable'] == "yes") {
1256
		if (!is_array($wancfg['wireless']['wep']))
1257
			$wancfg['wireless']['wep'] = array();
1258
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
1259
	} else if (isset($wancfg['wireless']['wep']))
1260
		unset($wancfg['wireless']['wep']);
1261
	if ($_POST['wme_enable'] == "yes") {
1262
		if (!is_array($wancfg['wireless']['wme']))
1263
			$wancfg['wireless']['wme'] = array();
1264
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1265
	} else if (isset($wancfg['wireless']['wme']['enable']))
1266
		unset($wancfg['wireless']['wme']['enable']);
1267 57bbd532 Erik Fonnesbeck
	if ($_POST['puremode'] == "11g") {
1268 270c4607 Scott Ullrich
		if (!is_array($wancfg['wireless']['pureg']))
1269
			$wancfg['wireless']['pureg'] = array();
1270 57bbd532 Erik Fonnesbeck
		$wancfg['wireless']['pureg']['enable'] = true;
1271
	} else if ($_POST['puremode'] == "11n") {
1272 ed459692 Erik Fonnesbeck
		if (!is_array($wancfg['wireless']['puren']))
1273
			$wancfg['wireless']['puren'] = array();
1274 57bbd532 Erik Fonnesbeck
		$wancfg['wireless']['puren']['enable'] = true;
1275
	} else {
1276
		if (isset($wancfg['wireless']['pureg']))
1277
			unset($wancfg['wireless']['pureg']);
1278
		if (isset($wancfg['wireless']['puren']))
1279
			unset($wancfg['wireless']['puren']);
1280
	}
1281 270c4607 Scott Ullrich
	if ($_POST['apbridge_enable'] == "yes") {
1282
		if (!is_array($wancfg['wireless']['apbridge']))
1283
			$wancfg['wireless']['apbridge'] = array();
1284
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1285
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
1286
		unset($wancfg['wireless']['apbridge']['enable']);
1287 9be20928 Erik Fonnesbeck
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1288 270c4607 Scott Ullrich
		if (!is_array($wancfg['wireless']['turbo']))
1289
			$wancfg['wireless']['turbo'] = array();
1290
		$wancfg['wireless']['turbo']['enable'] = true;
1291
	} else if (isset($wancfg['wireless']['turbo']['enable']))
1292
		unset($wancfg['wireless']['turbo']['enable']);
1293
	$wancfg['wireless']['wep']['key'] = array();
1294
	for ($i = 1; $i <= 4; $i++) {
1295
		if ($_POST['key' . $i]) {
1296
			$newkey = array();
1297
			$newkey['value'] = $_POST['key' . $i];
1298
			if ($_POST['txkey'] == $i)
1299
				$newkey['txkey'] = true;
1300
			$wancfg['wireless']['wep']['key'][] = $newkey;
1301
		}
1302 5b237745 Scott Ullrich
	}
1303 8f0289e7 Erik Fonnesbeck
	interface_sync_wireless_clones($wancfg, true);
1304 5b237745 Scott Ullrich
}
1305 7f43ca88 Scott Ullrich
1306 597330aa Erik Fonnesbeck
function check_wireless_mode() {
1307 651fff4f Erik Fonnesbeck
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1308 597330aa Erik Fonnesbeck
1309
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1310
		return;
1311
1312
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1313
		$clone_count = 1;
1314
	else
1315
		$clone_count = 0;
1316 6ef2297b Erik Fonnesbeck
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1317 597330aa Erik Fonnesbeck
		foreach ($config['wireless']['clone'] as $clone) {
1318
			if ($clone['if'] == $wlanbaseif)
1319
				$clone_count++;
1320
		}
1321
	}
1322
	if ($clone_count > 1) {
1323
		$old_wireless_mode = $wancfg['wireless']['mode'];
1324
		$wancfg['wireless']['mode'] = $_POST['mode'];
1325
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1326 4c807d76 Erik Fonnesbeck
			$input_errors[] = sprintf(gettext("Unable to change mode to %s.  You may already have the maximum number of wireless clones supported in this mode."), $wlan_modes[$wancfg['wireless']['mode']]);
1327 597330aa Erik Fonnesbeck
		} else {
1328 d31ca336 Renato Botelho
			mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy");
1329 597330aa Erik Fonnesbeck
		}
1330
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1331
	}
1332
}
1333
1334 509ca889 Evgeny Yurchenko
// Find all possible media options for the interface
1335
$mediaopts_list = array();
1336
$intrealname = $config['interfaces'][$if]['if'];
1337
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1338
foreach ($mediaopts as $mediaopt){
1339
	preg_match("/media (.*)/", $mediaopt, $matches);
1340 6d529efd Renato Botelho
	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1341 509ca889 Evgeny Yurchenko
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1342 6d529efd Renato Botelho
		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1343 509ca889 Evgeny Yurchenko
	}else{
1344
		// there is only media like "media 1000baseT"
1345
		array_push($mediaopts_list, $matches[1]);
1346
	}
1347
}
1348
1349 a6d9251e Scott Ullrich
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1350 b32dd0a6 jim-p
$shortcut_section = "interfaces";
1351 af1e2031 jim-p
1352 58af5941 Scott Ullrich
$closehead = false;
1353 7f43ca88 Scott Ullrich
include("head.inc");
1354 3e662cb0 Ermal
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1355 feb88a14 smos
$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCP6"), "slaac" => gettext("SLAAC"), "6rd" => gettext("6rd Tunnel"), "6to4" => gettext("6to4 Tunnel"), "track6" => gettext("Track Interface"));
1356 7f43ca88 Scott Ullrich
1357 5b237745 Scott Ullrich
?>
1358 7f43ca88 Scott Ullrich
1359 8098302a Scott Ullrich
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1360 58af5941 Scott Ullrich
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1361 8098302a Scott Ullrich
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1362
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1363 58af5941 Scott Ullrich
1364
<script type="text/javascript">
1365 6e31ca39 N0YB
//<![CDATA[
1366 9978e156 gnhb
	function updateType(t) {
1367 886f1f69 Scott Ullrich
		switch(t) {
1368 9978e156 gnhb
			case "none": {
1369 076b14b2 Vinicius Coque
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1370 47593ac6 Seth Mos
				break;
1371
			}
1372
			case "staticv4": {
1373 076b14b2 Vinicius Coque
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1374 9978e156 gnhb
				break;
1375
			}
1376
			case "dhcp": {
1377 076b14b2 Vinicius Coque
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1378 6c05cfb0 gnhb
				break;
1379
			}
1380
			case "ppp": {
1381 076b14b2 Vinicius Coque
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1382 3a906378 gnhb
				country_list();
1383 9978e156 gnhb
				break;
1384
			}
1385
			case "pppoe": {
1386 076b14b2 Vinicius Coque
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1387 9978e156 gnhb
				break;
1388
			}
1389 e4d40f41 gnhb
			case "l2tp":
1390 9978e156 gnhb
			case "pptp": {
1391 076b14b2 Vinicius Coque
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1392
				jQuery('#pptp').show();
1393 9978e156 gnhb
				break;
1394 09583657 Scott Ullrich
			}
1395 886f1f69 Scott Ullrich
		}
1396 e4d40f41 gnhb
		if (t != "l2tp" && t != "pptp")
1397 076b14b2 Vinicius Coque
			jQuery('#'+t).show();
1398 09583657 Scott Ullrich
	}
1399 e029943a Seth Mos
	function updateTypeSix(t) {
1400 ca4467bc N0YB
		if (!isNaN(t[0])) t = '_' + t;
1401 e029943a Seth Mos
		switch(t) {
1402
			case "none": {
1403 6e31ca39 N0YB
				jQuery('#staticv6, #dhcp6, #_6rd, #_6to4, #track6, #slaac').hide();
1404 e029943a Seth Mos
				break;
1405
			}
1406
			case "staticv6": {
1407 6e31ca39 N0YB
				jQuery('#none, #dhcp6, #_6rd, #_6to4, #track6, #slaac').hide();
1408 feb88a14 smos
				break;
1409
			}
1410
			case "slaac": {
1411 6e31ca39 N0YB
				jQuery('#none, #staticv6, #_6rd, #_6to4, #track6, #dhcp6').hide();
1412 e029943a Seth Mos
				break;
1413
			}
1414
			case "dhcp6": {
1415 6e31ca39 N0YB
				jQuery('#none, #staticv6, #_6rd, #_6to4, #track6, #slaac').hide();
1416 7d567088 smos
				break;
1417
			}
1418 6e31ca39 N0YB
			case "_6rd": {
1419
				jQuery('#none, #dhcp6, #staticv6, #_6to4, #track6, #slaac').hide();
1420 31c43fd3 smos
				break;
1421
			}
1422 6e31ca39 N0YB
			case "_6to4": {
1423
				jQuery('#none, #dhcp6, #staticv6, #_6rd, #track6, #slaac').hide();
1424 20a7cb15 smos
				break;
1425
			}
1426
			case "track6": {
1427 6e31ca39 N0YB
				jQuery('#none, #dhcp6, #staticv6, #_6rd, #_6to4, #slaac').hide();
1428 e029943a Seth Mos
				break;
1429
			}
1430
		}
1431
		if (t != "l2tp" && t != "pptp")
1432 076b14b2 Vinicius Coque
			jQuery('#'+t).show();
1433 e029943a Seth Mos
	}
1434 32764288 Namezero
1435 886f1f69 Scott Ullrich
	function show_allcfg(obj) {
1436
		if (obj.checked)
1437 076b14b2 Vinicius Coque
			jQuery('#allcfg').show();
1438 886f1f69 Scott Ullrich
		else
1439 076b14b2 Vinicius Coque
			jQuery('#allcfg').hide();
1440 886f1f69 Scott Ullrich
	}
1441 9978e156 gnhb
1442 d85ba87f gnhb
	function show_reset_settings(reset_type) {
1443 c0948c6c Renato Botelho
		if (reset_type == 'preset') {
1444 076b14b2 Vinicius Coque
			jQuery('#pppoepresetwrap').show();
1445
			jQuery('#pppoecustomwrap').hide();
1446 c0948c6c Renato Botelho
		}
1447
		else if (reset_type == 'custom') {
1448 076b14b2 Vinicius Coque
			jQuery('#pppoecustomwrap').show();
1449
			jQuery('#pppoepresetwrap').hide();
1450 d85ba87f gnhb
		} else {
1451 076b14b2 Vinicius Coque
			jQuery('#pppoecustomwrap').hide();
1452
			jQuery('#pppoepresetwrap').hide();
1453 d85ba87f gnhb
		}
1454
	}
1455 886f1f69 Scott Ullrich
	function show_mon_config() {
1456 076b14b2 Vinicius Coque
		jQuery("#showmonbox").html('');
1457
		jQuery('#showmon').css('display','block');
1458 886f1f69 Scott Ullrich
	}
1459 4634cb48 Ermal Luçi
1460 886f1f69 Scott Ullrich
	function openwindow(url) {
1461
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1462 c0948c6c Renato Botelho
		if (oWin==null || typeof(oWin)=="undefined")
1463 886f1f69 Scott Ullrich
			return false;
1464 c0948c6c Renato Botelho
		else
1465 886f1f69 Scott Ullrich
			return true;
1466
	}
1467 3a906378 gnhb
	function country_list() {
1468 076b14b2 Vinicius Coque
		jQuery('#country').children().remove();
1469 cfd3676d N0YB
		jQuery('#provider_list').children().remove();
1470 076b14b2 Vinicius Coque
		jQuery('#providerplan').children().remove();
1471
		jQuery.ajax("getserviceproviders.php",{
1472
			success: function(response) {
1473
				var responseTextArr = response.split("\n");
1474 3a906378 gnhb
				responseTextArr.sort();
1475
				responseTextArr.each( function(value) {
1476
					var option = new Element('option');
1477
					country = value.split(":");
1478
					option.text = country[0];
1479
					option.value = country[1];
1480 076b14b2 Vinicius Coque
					jQuery('#country').append(option);
1481 3a906378 gnhb
				});
1482
			}
1483
		});
1484 076b14b2 Vinicius Coque
		jQuery('#trcountry').css('display',"table-row");
1485 3a906378 gnhb
	}
1486 c0948c6c Renato Botelho
1487 3a906378 gnhb
	function providers_list() {
1488 4a2c47fe N0YB
		jQuery('#provider_list').children().remove();
1489 076b14b2 Vinicius Coque
		jQuery('#providerplan').children().remove();
1490
		jQuery.ajax("getserviceproviders.php",{
1491
			type: 'post',
1492
			data: {country : jQuery('#country').val()},
1493
			success: function(response) {
1494
				var responseTextArr = response.split("\n");
1495 3a906378 gnhb
				responseTextArr.sort();
1496
				responseTextArr.each( function(value) {
1497
					var option = new Element('option');
1498
					option.text = value;
1499
					option.value = value;
1500 4a2c47fe N0YB
					jQuery('#provider_list').append(option);
1501 3a906378 gnhb
				});
1502
			}
1503
		});
1504 076b14b2 Vinicius Coque
		jQuery('#trprovider').css("display","table-row");
1505
		jQuery('#trproviderplan').css("display","none");
1506 3a906378 gnhb
	}
1507 c0948c6c Renato Botelho
1508 3a906378 gnhb
	function providerplan_list() {
1509 076b14b2 Vinicius Coque
		jQuery('#providerplan').children().remove();
1510
		jQuery('#providerplan').append( new Element('option') );
1511
		jQuery.ajax("getserviceproviders.php",{
1512
			type: 'post',
1513 4a2c47fe N0YB
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val()},
1514 076b14b2 Vinicius Coque
			success: function(response) {
1515
				var responseTextArr = response.split("\n");
1516 3a906378 gnhb
				responseTextArr.sort();
1517
				responseTextArr.each( function(value) {
1518
					if(value != "") {
1519
						providerplan = value.split(":");
1520 c0948c6c Renato Botelho
1521 3a906378 gnhb
						var option = new Element('option');
1522
						option.text = providerplan[0] + " - " + providerplan[1];
1523
						option.value = providerplan[1];
1524 076b14b2 Vinicius Coque
						jQuery('#providerplan').append(option);
1525 3a906378 gnhb
					}
1526
				});
1527
			}
1528
		});
1529 076b14b2 Vinicius Coque
		jQuery('#trproviderplan').css("display","table-row");
1530 3a906378 gnhb
	}
1531 c0948c6c Renato Botelho
1532 3a906378 gnhb
	function prefill_provider() {
1533 076b14b2 Vinicius Coque
		jQuery.ajax("getserviceproviders.php",{
1534
			type: 'post',
1535 4a2c47fe N0YB
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val(), plan : jQuery('#providerplan').val()},
1536 076b14b2 Vinicius Coque
			success: function(data,textStatus,response) {
1537 3a906378 gnhb
				var xmldoc = response.responseXML;
1538
				var provider = xmldoc.getElementsByTagName('connection')[0];
1539 076b14b2 Vinicius Coque
				jQuery('#username').val('');
1540
				jQuery('#password').val('');
1541 3a906378 gnhb
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1542 076b14b2 Vinicius Coque
					jQuery('#phone').val('#777');
1543
					jQuery('#apn').val('');
1544 3a906378 gnhb
				} else {
1545 076b14b2 Vinicius Coque
					jQuery('#phone').val('*99#');
1546
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1547 3a906378 gnhb
				}
1548 076b14b2 Vinicius Coque
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1549
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1550
				jQuery('#username').val(username);
1551
				jQuery('#password').val(password);
1552 3a906378 gnhb
			}
1553
		});
1554
	}
1555
1556 6e31ca39 N0YB
//]]>
1557 5b237745 Scott Ullrich
</script>
1558 58af5941 Scott Ullrich
</head>
1559 886f1f69 Scott Ullrich
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1560
	<?php include("fbegin.inc"); ?>
1561
	<form action="interfaces.php" method="post" name="iform" id="iform">
1562
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1563 a368a026 Ermal Lu?i
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1564 168549b9 Colin Fleming
		<?php print_info_box_np(sprintf(gettext("The %s configuration has been changed."),$wancfg['descr'])."</p><p>".gettext("You must apply the changes in order for them to take effect.")."</p><p>".gettext("Don't forget to adjust the DHCP Server range if needed after applying."));?></p><br />
1565 744ea190 Scott Ullrich
		<?php endif; ?>
1566
		<?php if ($savemsg) print_info_box($savemsg); ?>
1567 168549b9 Colin Fleming
		<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces">
1568 09583657 Scott Ullrich
			<tr>
1569 30ade846 gnhb
				<td id="mainarea">
1570
					<div class="tabcont">
1571 168549b9 Colin Fleming
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="tabs">
1572 09583657 Scott Ullrich
						<tr>
1573 136c598d Carlos Eduardo Ramos
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1574 09583657 Scott Ullrich
						</tr>
1575
						<tr>
1576 136c598d Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1577 30ade846 gnhb
							<td width="78%" class="vtable">
1578 339d2743 Colin Fleming
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked=\"checked\""; ?> onclick="show_allcfg(this);" />
1579 136c598d Carlos Eduardo Ramos
							<strong><?=gettext("Enable Interface"); ?></strong>
1580 09583657 Scott Ullrich
							</td>
1581
						</tr>
1582 30ade846 gnhb
					</table>
1583 6e31ca39 N0YB
					<div style="display:none;" id="allcfg">
1584 168549b9 Colin Fleming
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="allcfg">
1585 09583657 Scott Ullrich
						<tr>
1586 136c598d Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1587 09583657 Scott Ullrich
							<td width="78%" class="vtable">
1588 2cbe4b47 Colin Fleming
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>" />
1589 8cd558b6 ayvis
								<br /><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1590 30ade846 gnhb
							</td>
1591
						</tr>
1592
						<tr>
1593 e029943a Seth Mos
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1594 c0948c6c Renato Botelho
							<td class="vtable">
1595 f3d88511 Renato Botelho
							<select name="type" onchange="updateType(this.value);" <?php echo $type_disabled; ?> class="formselect" id="type">
1596 c0948c6c Renato Botelho
								<?php
1597 e029943a Seth Mos
									foreach ($types4 as $key => $opt) {
1598 32b91bcf Colin Fleming
										echo "<option onclick=\"updateType('{$key}');\"";
1599 c0948c6c Renato Botelho
										if ($key == $pconfig['type'])
1600 339d2743 Colin Fleming
											echo " selected=\"selected\"";
1601 3a13f094 gnhb
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1602
										echo "</option>";
1603 c0948c6c Renato Botelho
									}
1604 30ade846 gnhb
								?>
1605 667a3184 Scott Ullrich
								</select>
1606 30ade846 gnhb
							</td>
1607
						</tr>
1608 e029943a Seth Mos
						<tr>
1609
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1610
							<td class="vtable">
1611 f3d88511 Renato Botelho
							<select name="type6" onchange="updateTypeSix(this.value);" <?php echo $type_disabled; ?> class="formselect" id="type6">
1612 e029943a Seth Mos
								<?php
1613
									foreach ($types6 as $key => $opt) {
1614 32b91bcf Colin Fleming
										echo "<option onclick=\"updateTypeSix('{$key}');\"";
1615 e029943a Seth Mos
										if ($key == $pconfig['type6'])
1616 339d2743 Colin Fleming
											echo " selected=\"selected\"";
1617 e029943a Seth Mos
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1618
										echo "</option>";
1619
									}
1620
								?>
1621
								</select>
1622
							</td>
1623
						</tr>
1624 30ade846 gnhb
						<tr>
1625 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1626 30ade846 gnhb
							<td class="vtable">
1627 2cbe4b47 Colin Fleming
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>" />
1628 30ade846 gnhb
								<?php
1629
									$ip = getenv('REMOTE_ADDR');
1630
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1631
									$mac = str_replace("\n","",$mac);
1632
									if($mac):
1633
								?>
1634 32b91bcf Colin Fleming
									<a onclick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1635 30ade846 gnhb
								<?php endif; ?>
1636 8cd558b6 ayvis
								<br />
1637 136c598d Carlos Eduardo Ramos
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1638 8cd558b6 ayvis
								"address of this interface"); ?><br />
1639
								<?=gettext("(may be required with some cable connections)"); ?><br />
1640 136c598d Carlos Eduardo Ramos
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1641
								"or leave blank"); ?>
1642 30ade846 gnhb
							</td>
1643
						</tr>
1644
						<tr>
1645 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1646 c0948c6c Renato Botelho
							<td class="vtable">
1647 2cbe4b47 Colin Fleming
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>" />
1648 8cd558b6 ayvis
								<br />
1649 4a735210 Renato Botelho
								<?php
1650 0d0d4a27 Renato Botelho
									print gettext("If you leave this field blank, the adapter's default MTU will " .
1651
									"be used. This is typically 1500 bytes but can vary in some circumstances.");
1652 4a735210 Renato Botelho
								?>
1653 4cea5cf8 Ermal
							</td>
1654
						</tr>
1655
						<tr>
1656
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1657 c0948c6c Renato Botelho
							<td class="vtable">
1658 2cbe4b47 Colin Fleming
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>" />
1659 8cd558b6 ayvis
								<br />
1660 136c598d Carlos Eduardo Ramos
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1661 c0948c6c Renato Botelho
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1662
								"header size) will be in effect."); ?>
1663 30ade846 gnhb
							</td>
1664
						</tr>
1665 6d529efd Renato Botelho
						<?php
1666 509ca889 Evgeny Yurchenko
						if (count($mediaopts_list) > 0){
1667
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1668
						echo "<tr>";
1669
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1670
							echo '<td class="vtable">';
1671 6d529efd Renato Botelho
							echo '<div id="showadvmediabox"';
1672 6e2a15e6 Evgeny Yurchenko
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1673
								else echo '>';
1674 2cbe4b47 Colin Fleming
								echo '<input type="button" onclick="show_advanced_media()" value="' . gettext("Advanced") . '" /> - ' . gettext("Show advanced option");
1675 6e2a15e6 Evgeny Yurchenko
							echo "</div>";
1676
							echo '<div id="showmediaadv" ';
1677
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1678
							else echo '>';
1679 509ca889 Evgeny Yurchenko
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1680 433e9842 jim-p
								print "<option value=\"\">Default (no preference, typically autoselect)</option>";
1681
								print "<option value=\"\">------- Media Supported by this interface -------</option>";
1682 509ca889 Evgeny Yurchenko
								foreach($mediaopts_list as $mediaopt){
1683
									if ($mediaopt != rtrim($mediaopt_from_config)){
1684
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1685
									} else {
1686 339d2743 Colin Fleming
										print "<option value=\"$mediaopt\" selected=\"selected\">" . gettext("$mediaopt") . "</option>";
1687 509ca889 Evgeny Yurchenko
									}
1688
								}
1689 8cd558b6 ayvis
								echo '</select><br />';
1690 433e9842 jim-p
								echo gettext("Here you can explicitly set speed and duplex mode for this interface. WARNING: You MUST leave this set to autoselect (automatically negotiate speed) unless the port this interface connects to has its speed and duplex forced.");
1691 6e2a15e6 Evgeny Yurchenko
						echo '</div>';
1692 509ca889 Evgeny Yurchenko
							echo '</td>';
1693
						echo '</tr>';
1694
						}
1695
						?>
1696 30ade846 gnhb
						<tr>
1697
							<td colspan="2" valign="top" height="16"></td>
1698 c0948c6c Renato Botelho
						</tr>
1699 6e31ca39 N0YB
						<tr style="display:none;" id="none"><td style="display:none;"></td></tr>
1700
						<tr style="display:none;" id="staticv4">
1701 30ade846 gnhb
							<td colspan="2" style="padding:0px;">
1702 7a47e299 Renato Botelho
								<a name="gatewaysection"></a>
1703 168549b9 Colin Fleming
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv4">
1704 30ade846 gnhb
									<tr>
1705 47593ac6 Seth Mos
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1706 30ade846 gnhb
									</tr>
1707
									<tr>
1708 47593ac6 Seth Mos
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1709 c0948c6c Renato Botelho
										<td width="78%" class="vtable">
1710 2cbe4b47 Colin Fleming
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" />
1711 30ade846 gnhb
											/
1712
											<select name="subnet" class="formselect" id="subnet">
1713
												<?php
1714
												for ($i = 32; $i > 0; $i--) {
1715
													if($i <> 31) {
1716
														echo "<option value=\"{$i}\" ";
1717 339d2743 Colin Fleming
														if ($i == $pconfig['subnet']) echo "selected=\"selected\"";
1718 30ade846 gnhb
														echo ">" . $i . "</option>";
1719
													}
1720
												}
1721
												?>
1722
											</select>
1723
										</td>
1724
									</tr>
1725
									<tr>
1726 e2a6a6fb Phillip Davis
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Upstream Gateway"); ?></td>
1727 30ade846 gnhb
										<td width="78%" class="vtable">
1728
											<select name="gateway" class="formselect" id="gateway">
1729 339d2743 Colin Fleming
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1730 9978e156 gnhb
													<?php
1731 30ade846 gnhb
													if(count($a_gateways) > 0) {
1732
														foreach ($a_gateways as $gateway) {
1733 47593ac6 Seth Mos
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1734 9978e156 gnhb
													?>
1735 339d2743 Colin Fleming
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected=\"selected\""; ?>>
1736 30ade846 gnhb
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1737
															</option>
1738
													<?php
1739
															}
1740
														}
1741
													}
1742
													?>
1743
											</select>
1744 32b91bcf Colin Fleming
											- or  <strong><a onclick="show_add_gateway();" href="#gatewaysection"><?=gettext("add a new one."); ?></a></strong>
1745 8cd558b6 ayvis
											<br />
1746 30ade846 gnhb
											<div id='addgwbox'>
1747 8cd558b6 ayvis
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above."); ?><br />
1748 e2a6a6fb Phillip Davis
												<?=gettext("On local LANs the upstream gateway should be \"none\"."); ?>
1749 30ade846 gnhb
											</div>
1750
											<div id='notebox'>
1751
											</div>
1752
											<div id="status">
1753 c0948c6c Renato Botelho
											</div>
1754 6e31ca39 N0YB
											<div style="display:none" id="addgateway">
1755 168549b9 Colin Fleming
												<p>&nbsp;</p>
1756
												<table border="1" class="addgatewaybox" summary="addgateway">
1757 9978e156 gnhb
													<tr>
1758 30ade846 gnhb
														<td>
1759 168549b9 Colin Fleming
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgateway">
1760 bd10508a N0YB
																<tr><td>&nbsp;</td></tr>
1761 30ade846 gnhb
																<tr>
1762 933ea015 Carlos Eduardo Ramos
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1763 30ade846 gnhb
																</tr>
1764 bd10508a N0YB
																<tr><td>&nbsp;</td></tr>
1765 30ade846 gnhb
																<?php
1766
																if($if == "wan" || $if == "WAN")
1767 339d2743 Colin Fleming
																	$checked = " checked=\"checked\"";
1768 30ade846 gnhb
																?>
1769
																<tr>
1770 2cbe4b47 Colin Fleming
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></font></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?> /></td>
1771 c0948c6c Renato Botelho
																</tr>
1772 30ade846 gnhb
																<tr>
1773 2cbe4b47 Colin Fleming
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></font></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>" /></td>
1774 30ade846 gnhb
																</tr>
1775
																<tr>
1776 2cbe4b47 Colin Fleming
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></font></td><td><input id="gatewayip" name="gatewayip" /></td>
1777 30ade846 gnhb
																</tr>
1778
																<tr>
1779 168549b9 Colin Fleming
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescr" name="gatewaydescr" /></td>
1780 30ade846 gnhb
																</tr>
1781 bd10508a N0YB
																<tr><td>&nbsp;</td></tr>
1782 30ade846 gnhb
																<tr>
1783 bd10508a N0YB
																	<td colspan="2">
1784 30ade846 gnhb
																		<center>
1785
																			<div id='savebuttondiv'>
1786 168549b9 Colin Fleming
																				<input id="gwsave" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave();' />
1787
																				<input id="gwcancel" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway();' />
1788 30ade846 gnhb
																			</div>
1789
																		</center>
1790
																	</td>
1791
																</tr>
1792 93ee6323 gnhb
																<tr><td>&nbsp;</td></tr>
1793 30ade846 gnhb
															</table>
1794 9978e156 gnhb
														</td>
1795
													</tr>
1796
												</table>
1797 30ade846 gnhb
											</div>
1798
										</td>
1799
									</tr>
1800 a236affe N0YB
									<tr>
1801
										<td colspan="2" valign="top" height="16"></td>
1802
									</tr>
1803 30ade846 gnhb
								</table>
1804
							</td>
1805
						</tr>
1806 6e31ca39 N0YB
						<tr style="display:none;" id="staticv6">
1807 47593ac6 Seth Mos
							<td colspan="2" style="padding:0px;">
1808 7a47e299 Renato Botelho
								<a name="gatewayv6section"></a>
1809 168549b9 Colin Fleming
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv6">
1810 47593ac6 Seth Mos
									<tr>
1811
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1812
									</tr>
1813
									<tr>
1814
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1815
										<td width="78%" class="vtable">
1816 2cbe4b47 Colin Fleming
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>" />
1817 47593ac6 Seth Mos
											/
1818 85e9cfee Phil Davis
											<select name="subnetv6" class="formselect" id="subnetv6">
1819 47593ac6 Seth Mos
												<?php
1820
												for ($i = 128; $i > 0; $i--) {
1821
													if($i <> 127) {
1822
														echo "<option value=\"{$i}\" ";
1823 339d2743 Colin Fleming
														if ($i == $pconfig['subnetv6']) echo "selected=\"selected\"";
1824 47593ac6 Seth Mos
														echo ">" . $i . "</option>";
1825
													}
1826
												}
1827
												?>
1828
											</select>
1829
										</td>
1830
									</tr>
1831
									<tr>
1832 e2a6a6fb Phillip Davis
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Upstream Gateway"); ?></td>
1833 47593ac6 Seth Mos
										<td width="78%" class="vtable">
1834
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1835 339d2743 Colin Fleming
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1836 47593ac6 Seth Mos
													<?php
1837
													if(count($a_gateways) > 0) {
1838
														foreach ($a_gateways as $gateway) {
1839
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1840
													?>
1841 339d2743 Colin Fleming
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected=\"selected\""; ?>>
1842 47593ac6 Seth Mos
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1843
															</option>
1844
													<?php
1845
															}
1846
														}
1847
													}
1848
													?>
1849
											</select>
1850 32b91bcf Colin Fleming
											- or <strong><a onclick="show_add_gateway_v6();" href="#gatewayv6section"><?=gettext("add a new one."); ?></a></strong>
1851 8cd558b6 ayvis
											<br />
1852 cfd40454 Seth Mos
											<div id='addgwboxv6'>
1853 8cd558b6 ayvis
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above."); ?><br />
1854 e2a6a6fb Phillip Davis
												<?=gettext("On local LANs the upstream gateway should be \"none\"."); ?>
1855 47593ac6 Seth Mos
											</div>
1856 cfd40454 Seth Mos
											<div id='noteboxv6'>
1857 47593ac6 Seth Mos
											</div>
1858 cfd40454 Seth Mos
											<div id="statusv6">
1859 47593ac6 Seth Mos
											</div>
1860 6e31ca39 N0YB
											<div style="display:none" id="addgatewayv6">
1861 168549b9 Colin Fleming
												<p>&nbsp;</p>
1862
												<table border="1" class="addgatewaybox" summary="addgatewayv6">
1863 47593ac6 Seth Mos
													<tr>
1864
														<td>
1865 168549b9 Colin Fleming
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgatewayv6">
1866 bd10508a N0YB
																<tr><td>&nbsp;</td></tr>
1867 47593ac6 Seth Mos
																<tr>
1868
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1869
																</tr>
1870 bd10508a N0YB
																<tr><td>&nbsp;</td></tr>
1871 47593ac6 Seth Mos
																<?php
1872
																if($if == "wan" || $if == "WAN")
1873 339d2743 Colin Fleming
																	$checked = " checked=\"checked\"";
1874 47593ac6 Seth Mos
																?>
1875
																<tr>
1876 2cbe4b47 Colin Fleming
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></font></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?> /></td>
1877 47593ac6 Seth Mos
																</tr>
1878
																<tr>
1879 2cbe4b47 Colin Fleming
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></font></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>" /></td>
1880 47593ac6 Seth Mos
																</tr>
1881
																<tr>
1882 168549b9 Colin Fleming
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></font></td><td><input id="gatewayipv6" name="gatewayipv6" /></td>
1883 47593ac6 Seth Mos
																</tr>
1884
																<tr>
1885 2cbe4b47 Colin Fleming
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescrv6" name="gatewaydescrv6" /></td>
1886 47593ac6 Seth Mos
																</tr>
1887 bd10508a N0YB
																<tr><td>&nbsp;</td></tr>
1888 47593ac6 Seth Mos
																<tr>
1889 bd10508a N0YB
																	<td colspan="2">
1890 47593ac6 Seth Mos
																		<center>
1891 cfd40454 Seth Mos
																			<div id='savebuttondivv6'>
1892 168549b9 Colin Fleming
																				<input id="gwsavev6" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave_v6();' />
1893
																				<input id="gwcancelv6" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway_v6();' />
1894 47593ac6 Seth Mos
																			</div>
1895
																		</center>
1896
																	</td>
1897
																</tr>
1898
																<tr><td>&nbsp;</td></tr>
1899
															</table>
1900
														</td>
1901
													</tr>
1902
												</table>
1903
											</div>
1904
										</td>
1905
									</tr>
1906 a236affe N0YB
									<tr>
1907
										<td colspan="2" valign="top" height="16"></td>
1908
									</tr>
1909 47593ac6 Seth Mos
								</table>
1910
							</td>
1911
						</tr>
1912 6e31ca39 N0YB
						<tr style="display:none;" id="dhcp">
1913 30ade846 gnhb
							<td colspan="2" style="padding: 0px;">
1914 168549b9 Colin Fleming
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp">
1915 30ade846 gnhb
									<tr>
1916 6e31ca39 N0YB
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration &nbsp; &nbsp; " .
1917
										' <input name="adv_dhcp_config_advanced" type="checkbox" id="adv_dhcp_config_advanced" value="" onclick="show_adv_dhcp_config(this)" /> ' .
1918
										" Advanced &nbsp; &nbsp; " .
1919
										' <input name="adv_dhcp_config_file_override" type="checkbox" id="adv_dhcp_config_file_override" value="" onclick="show_adv_dhcp_config(this)" /> ' .
1920
										" Config File Override &nbsp; &nbsp; "); ?>
1921 f4dd8b4c N0YB
										</td>
1922 30ade846 gnhb
									</tr>
1923 e4d40f41 gnhb
									<!-- Uncomment to expose DHCP+ in GUI
1924
									<tr>
1925
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1926
										<td width="78%" class="vtable">
1927 339d2743 Colin Fleming
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked=\"checked\""; ?> />
1928 e4d40f41 gnhb
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1929 8cd558b6 ayvis
										<br />
1930 e4d40f41 gnhb
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
1931
										</td>
1932
									</tr>
1933
									-->
1934 6e31ca39 N0YB
									<tr style='display:none' id="show_basic_dhcphostname">
1935 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1936 30ade846 gnhb
										<td width="78%" class="vtable">
1937 2cbe4b47 Colin Fleming
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>" />
1938 8cd558b6 ayvis
											<br />
1939 136c598d Carlos Eduardo Ramos
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1940
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1941 933ea015 Carlos Eduardo Ramos
											"this (for client identification)."); ?>
1942 30ade846 gnhb
										</td>
1943
									</tr>
1944 6e31ca39 N0YB
									<tr style='display:none' id="show_basic_dhcpalias-address">
1945 ed395640 Seth Mos
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
1946
										<td width="78%" class="vtable">
1947 2cbe4b47 Colin Fleming
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>" />
1948 ed395640 Seth Mos
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1949
												<?php
1950
												for ($i = 32; $i > 0; $i--) {
1951
													if($i <> 31) {
1952
														echo "<option value=\"{$i}\" ";
1953 339d2743 Colin Fleming
														if ($i == $pconfig['alias-subnet']) echo "selected=\"selected\"";
1954 ed395640 Seth Mos
														echo ">" . $i . "</option>";
1955
													}
1956
												}
1957
												?>
1958
											</select>
1959
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
1960
											"DHCP client."); ?>
1961
										</td>
1962 bfab2419 smos
									</tr>
1963 6e31ca39 N0YB
									<tr style='display:none' id="show_basic_dhcprejectlease">
1964 57c83fd6 jim-p
										<td width="22%" valign="top" class="vncell"><?=gettext("Reject Leases From"); ?></td>
1965
										<td width="78%" class="vtable">
1966
											<input name="dhcprejectfrom" type="text" class="formfld unknown" id="dhcprejectfrom" size="20" value="<?=htmlspecialchars($pconfig['dhcprejectfrom']);?>" />
1967 8cd558b6 ayvis
											<br />
1968 57c83fd6 jim-p
											<?=gettext("If there is a certain upstream DHCP server that should be ignored, place the IP address or subnet of the DHCP server to be ignored here."); ?>
1969 61ca05e2 N0YB
											<?=gettext("This is useful for rejecting leases from cable modems that offer private IPs when they lose upstream sync."); ?>
1970 57c83fd6 jim-p
										</td>
1971
									</tr>
1972 f4dd8b4c N0YB
1973 6e31ca39 N0YB
									<tr style='display:none' id="show_adv_dhcp_protocol_timing">
1974 ce668fcd Colin Fleming
										<td width="22%" valign="top" class="vncell"><a target="_blank" href="http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#PROTOCOL_TIMING"><?=gettext("Protocol Timing"); ?></a></td>
1975 f4dd8b4c N0YB
										<td width="48%" class="vtable">
1976 6e31ca39 N0YB
											Timeout: <input name="adv_dhcp_pt_timeout" type="text" class="formfld unknown" id="adv_dhcp_pt_timeout" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_timeout']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
1977
											Retry:   <input name="adv_dhcp_pt_retry"   type="text" class="formfld unknown" id="adv_dhcp_pt_retry"   size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_retry']);?>"   onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
1978
											Select Timeout: <input name="adv_dhcp_pt_select_timeout" type="text" class="formfld unknown" id="adv_dhcp_pt_select_timeout" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_select_timeout']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
1979 f4dd8b4c N0YB
1980 6e31ca39 N0YB
											&nbsp; &nbsp; &nbsp; &nbsp; 
1981
											Presets: &nbsp;
1982
											<input name="adv_dhcp_pt_values" type="radio" value="DHCP"	id="customdhcpptdhcpdefaults"	onclick="customdhcpptsetvalues(this, iform);" />FreeBSD Default &nbsp; 
1983
											<input name="adv_dhcp_pt_values" type="radio" value="Clear"	id="customdhcpptclear"		onclick="customdhcpptsetvalues(this, iform);" />Clear
1984 f4dd8b4c N0YB
1985 8cd558b6 ayvis
											<br />
1986 6e31ca39 N0YB
											Reboot: <input name="adv_dhcp_pt_reboot" type="text" class="formfld unknown" id="adv_dhcp_pt_reboot" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_reboot']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
1987
											Backoff Cutoff:   <input name="adv_dhcp_pt_backoff_cutoff"   type="text" class="formfld unknown" id="adv_dhcp_pt_backoff_cutoff"   size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_backoff_cutoff']);?>"   onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
1988
											Initial Interval: <input name="adv_dhcp_pt_initial_interval" type="text" class="formfld unknown" id="adv_dhcp_pt_initial_interval" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_initial_interval']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
1989 f4dd8b4c N0YB
1990 6e31ca39 N0YB
											&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
1991
											<input name="adv_dhcp_pt_values" type="radio" value="pfSense"	id="customdhcpptpfsensedefaults"	onclick="customdhcpptsetvalues(this, iform);" />pfSense Default &nbsp; 
1992
											<input name="adv_dhcp_pt_values" type="radio" value="SavedCfg" checked="checked"	id="customdhcpptsavedcfg"		onclick="customdhcpptsetvalues(this, iform);" />Saved Cfg 
1993 f4dd8b4c N0YB
1994 8cd558b6 ayvis
											<br />
1995
											<?=gettext("The values in these fields are DHCP protocol timings used when requesting a lease. <br /> " ); ?>
1996 f4dd8b4c N0YB
1997
											<script type="text/javascript">
1998 6e31ca39 N0YB
											//<![CDATA[
1999 f4dd8b4c N0YB
												function customdhcpptcheckradiobuton(T, BUTTON) {
2000
													for (var i = 0; i < T.length; i++) {
2001
														T[i].checked = false;
2002
														if (T[i].value == BUTTON) T[i].checked = true;
2003
													}
2004
													T.value = BUTTON;
2005
												}
2006
2007
												function customdhcpptsetvalues(T, FORM) {
2008
													// timeout, retry, select-timeout, reboot, backoff-cutoff, initial-interval
2009
													if (T.value == "DHCP")		customdhcpptsetvaluesnow(T, FORM, "60", "300", "0", "10", "120", "10");
2010
													if (T.value == "pfSense")	customdhcpptsetvaluesnow(T, FORM, "60", "15", "0", "", "", "1");
2011
													if (T.value == "SavedCfg")	customdhcpptsetvaluesnow(T, FORM, "<?=htmlspecialchars($pconfig['adv_dhcp_pt_timeout']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_retry']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_select_timeout']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_reboot']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_backoff_cutoff']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_initial_interval']);?>");
2012
													if (T.value == "Clear")		customdhcpptsetvaluesnow(T, FORM, "", "", "", "", "", "");
2013
												}
2014
2015
												function customdhcpptsetvaluesnow(T, FORM, timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
2016
													FORM.adv_dhcp_pt_timeout.value = timeout;
2017
													FORM.adv_dhcp_pt_retry.value = retry;
2018
													FORM.adv_dhcp_pt_select_timeout.value = selecttimeout;
2019
													FORM.adv_dhcp_pt_reboot.value = reboot;
2020
													FORM.adv_dhcp_pt_backoff_cutoff.value = backoffcutoff;
2021
													FORM.adv_dhcp_pt_initial_interval.value = initialinterval;
2022
2023
													FORM.adv_dhcp_pt_values.value = T.value;
2024
												}
2025
2026
												<!-- Set the adv_dhcp_pt_values radio button from saved config -->
2027
												var RADIOBUTTON_VALUE = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values']);?>";
2028
												if (RADIOBUTTON_VALUE == "") RADIOBUTTON_VALUE = "SavedCfg";
2029
												customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, RADIOBUTTON_VALUE);
2030 6e31ca39 N0YB
											//]]>
2031 f4dd8b4c N0YB
											</script>
2032
										</td>
2033 a236affe N0YB
									</tr>
2034 f4dd8b4c N0YB
2035 6e31ca39 N0YB
									<tr style='display:none' id="show_adv_dhcp_lease_requirements_and_requests">
2036
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Lease Requirements and Requests</a>"); ?></td>
2037 f4dd8b4c N0YB
										<td width="78%" class="vtable">
2038 8cd558b6 ayvis
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Send</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Options</a>"); ?><br />
2039 6e31ca39 N0YB
											<input name="adv_dhcp_send_options" type="text" class="formfld unknown" id="adv_dhcp_send_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_send_options']);?>" />
2040 8cd558b6 ayvis
											<br />
2041
											<?=gettext("The values in this field are DHCP options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2042
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2043
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2044 f4dd8b4c N0YB
											"Some ISPs may require certain options be or not be sent. "); ?>
2045 6e31ca39 N0YB
											<hr/>
2046 8cd558b6 ayvis
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Request</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Options</a>"); ?><br />
2047 6e31ca39 N0YB
											<input name="adv_dhcp_request_options" type="text" class="formfld unknown" id="adv_dhcp_request_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_request_options']);?>" />
2048 8cd558b6 ayvis
											<br />
2049
											<?=gettext("The values in this field are DHCP option 55 to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2050 f4dd8b4c N0YB
											"Some ISPs may require certain options be or not be requested. "); ?>
2051 6e31ca39 N0YB
											<hr/>
2052 8cd558b6 ayvis
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Require</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Options</a>"); ?><br />
2053 6e31ca39 N0YB
											<input name="adv_dhcp_required_options" type="text" class="formfld unknown" id="adv_dhcp_required_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_required_options']);?>" />
2054 8cd558b6 ayvis
											<br />
2055 c54b4586 Renato Botelho
											<?=gettext("The values in this field are DHCP options required by the client when requesting a DHCP lease.  [option [, ...]] "); ?>
2056 f4dd8b4c N0YB
										</td>
2057
									</tr>
2058
2059 6e31ca39 N0YB
									<tr style='display:none' id="show_adv_dhcp_option_modifiers">
2060
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Option</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#OPTION_MODIFIERS\">Modifiers</a>"); ?></td>
2061 f4dd8b4c N0YB
										<td width="78%" class="vtable">
2062 6e31ca39 N0YB
											<input name="adv_dhcp_option_modifiers" type="text" class="formfld unknown" id="adv_dhcp_option_modifiers" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_option_modifiers']);?>" />
2063 8cd558b6 ayvis
											<br />
2064
											<?=gettext("The values in this field are DHCP option modifiers applied to obtained DHCP lease.  [modifier option declaration [, ...]] <br /> " .
2065 f4dd8b4c N0YB
											"modifiers: (default, supersede, prepend, append)"); ?>
2066
										</td>
2067
									</tr>
2068
2069 6e31ca39 N0YB
									<tr style='display:none' id="show_adv_dhcp_config_file_override">
2070
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5\">Configuration File</a> Override"); ?></td>
2071 f4dd8b4c N0YB
										<td width="78%" class="vtable">
2072 6e31ca39 N0YB
 											<input name="adv_dhcp_config_file_override_path"   type="text" class="formfld unknown" id="adv_dhcp_config_file_override_path"  size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override_path']);?>" />
2073 8cd558b6 ayvis
											<br />
2074
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2075
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2076
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2077 f4dd8b4c N0YB
											"Some ISPs may require certain options be or not be sent. "); ?>
2078
										</td>
2079 a236affe N0YB
									</tr>
2080 f4dd8b4c N0YB
2081
 									<tr>
2082
 										<td colspan="2" valign="top" height="16"></td>
2083
 									</tr>
2084
2085 6e31ca39 N0YB
								</table>
2086
2087 f4dd8b4c N0YB
									<script type="text/javascript">
2088 6e31ca39 N0YB
									//<![CDATA[
2089 f4dd8b4c N0YB
										function show_adv_dhcp_config(T) {
2090
2091
											if (T.checked) T.value = "Selected";
2092
											else T.value = "";
2093
2094
											     if (document.iform.adv_dhcp_config_file_override.checked)	show_hide_adv_dhcp('none', 'none', '');
2095
											else if (document.iform.adv_dhcp_config_advanced.checked)	show_hide_adv_dhcp('', '', 'none');
2096
											else 									show_hide_adv_dhcp('', 'none', 'none');
2097
										}
2098
2099
										function show_hide_adv_dhcp(basic, advanced, override) {
2100
2101
											document.getElementById("show_basic_dhcphostname").style.display = basic;
2102
											document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2103 63c704c3 N0YB
											document.getElementById("show_basic_dhcprejectlease").style.display = basic;
2104 f4dd8b4c N0YB
2105 336d4f04 N0YB
											document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2106
											document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2107 f4dd8b4c N0YB
											document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2108
2109
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2110
										}
2111
2112
										<!-- Set the adv_dhcp_config_advanced checkbox from saved config -->
2113
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_advanced']);?>" == "Selected") document.iform.adv_dhcp_config_advanced.checked = true;
2114
										show_adv_dhcp_config(document.iform.adv_dhcp_config_advanced);
2115
2116
										<!-- Set the adv_dhcp_config_file_override checkbox from saved config -->
2117
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override']);?>" == "Selected") document.iform.adv_dhcp_config_file_override.checked = true;
2118
										show_adv_dhcp_config(document.iform.adv_dhcp_config_file_override);
2119 6e31ca39 N0YB
									//]]>
2120 f4dd8b4c N0YB
									</script>
2121
2122 e029943a Seth Mos
							</td>
2123
						</tr>
2124 6e31ca39 N0YB
						<tr style="display:none;" id="dhcp6">
2125 e029943a Seth Mos
							<td colspan="2" style="padding: 0px;">
2126 168549b9 Colin Fleming
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp6">
2127 e029943a Seth Mos
									<tr>
2128 6e31ca39 N0YB
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration &nbsp; &nbsp; " .
2129
										' <input name="adv_dhcp6_config_advanced" type="checkbox" id="adv_dhcp6_config_advanced" value="" onclick="show_adv_dhcp6_config(this)" /> ' .
2130
										" Advanced &nbsp; &nbsp; " .
2131
										' <input name="adv_dhcp6_config_file_override" type="checkbox" id="adv_dhcp6_config_file_override" value="" onclick="show_adv_dhcp6_config(this)" /> ' .
2132
										" Config File Override &nbsp; &nbsp; "); ?>
2133 f4dd8b4c N0YB
										</td>
2134 ed395640 Seth Mos
									</tr>
2135 20a7cb15 smos
									<!--- Leave commented out for now
2136 6e31ca39 N0YB
									<tr style='display:none' id="basicdhcp6_show_dhcp6_duid">
2137 a9543eae Seth Mos
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
2138
										<td width="78%" class="vtable">
2139 2cbe4b47 Colin Fleming
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>" />
2140 8cd558b6 ayvis
											<br />
2141 a9543eae Seth Mos
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
2142 7149c4e7 Seth Mos
											"when requesting a DHCPv6 lease."); ?><br />
2143
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
2144 ed395640 Seth Mos
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
2145 7149c4e7 Seth Mos
												}
2146 b1e4005f Vinicius Coque
												printf(gettext("The current DUID is: '%s'"),$current_duid);
2147 bfab2419 smos
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
2148 7149c4e7 Seth Mos
											?>
2149
										</td>
2150
									</tr>
2151 20a7cb15 smos
									-->
2152 6e31ca39 N0YB
									<tr style='display:none' id="basicdhcp6_use_pppoeinterface">
2153 dbb4e089 Ermal
										<td width="22%" valign="top" class="vncell"><?=gettext("Use IPv4 connectivity as parent interface"); ?></td>
2154
										<td width="78%" class="vtable">
2155
											<input name="dhcp6usev4iface" type="checkbox" id="dhcp6usev4iface" value="yes" <?php if ($pconfig['dhcp6usev4iface'] == true) echo "checked=\"checked\""; ?> />
2156
											<?=gettext("Request a IPv6 prefix/information through the IPv4 connectivity link"); ?>
2157
										</td>
2158
									</tr>
2159 6e31ca39 N0YB
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_only">
2160 a13acc0e smos
										<td width="22%" valign="top" class="vncell"><?=gettext("Request only a IPv6 prefix"); ?></td>
2161
										<td width="78%" class="vtable">
2162 3b648a09 Phil Davis
											<input name="dhcp6prefixonly" type="checkbox" id="dhcp6prefixonly" value="yes" <?php if ($pconfig['dhcp6prefixonly'] == true) echo "checked=\"checked\""; ?> />
2163 a13acc0e smos
											<?=gettext("Only request a IPv6 prefix, do not request a IPv6 address"); ?>
2164
										</td>
2165
									</tr>
2166 6e31ca39 N0YB
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_delegation_size">
2167 7149c4e7 Seth Mos
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
2168
										<td width="78%" class="vtable">
2169 ed395640 Seth Mos
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
2170 7149c4e7 Seth Mos
												<?php
2171 ed395640 Seth Mos
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
2172 7149c4e7 Seth Mos
												foreach($sizes as $bits => $length) {
2173
													echo "<option value=\"{$bits}\" ";
2174 339d2743 Colin Fleming
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected=\"selected\"";
2175 7149c4e7 Seth Mos
													echo ">" . $length . "</option>";
2176
												}
2177
												?>
2178
											</select>
2179 8cd558b6 ayvis
											<br />
2180 ed395640 Seth Mos
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
2181 30ade846 gnhb
										</td>
2182
									</tr>
2183 6e31ca39 N0YB
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_send_hint">
2184 18f3c2fd Daniel Becker
										<td width="22%" valign="top" class="vncell"><?=gettext("Send IPv6 prefix hint"); ?></td>
2185
										<td width="78%" class="vtable">
2186
											<input name="dhcp6-ia-pd-send-hint" type="checkbox" id="dhcp6-ia-pd-send-hint" value="yes" <?php if ($pconfig['dhcp6-ia-pd-send-hint'] == true) echo "checked=\"checked\""; ?> />
2187
											<?=gettext("Send an IPv6 prefix hint to indicate the desired prefix size for delegation"); ?>
2188
										</td>
2189
									</tr>
2190 f4dd8b4c N0YB
2191 6e31ca39 N0YB
									<tr style='display:none' id="show_adv_dhcp6_interface_statement">
2192 f4dd8b4c N0YB
										<td width="22%" valign="top" class="vncell">
2193 6e31ca39 N0YB
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Interface_statement\">Interface Statement</a>"); ?>
2194 8cd558b6 ayvis
											<br /><br />
2195 6e31ca39 N0YB
											<input name="adv_dhcp6_interface_statement_information_only_enable" type="checkbox" id="adv_dhcp6_interface_statement_information_only_enable" value="" onclick="show_adv_dhcp6_config(this)" />
2196 f4dd8b4c N0YB
											<?=gettext("Information Only"); ?>
2197
										</td>
2198
										<td width="78%" class="vtable">
2199 8cd558b6 ayvis
											<?=gettext("Send Options"); ?><br />
2200 6e31ca39 N0YB
											<input name="adv_dhcp6_interface_statement_send_options" type="text" class="formfld unknown" id="adv_dhcp6_interface_statement_send_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_send_options']);?>" />
2201 8cd558b6 ayvis
											<br />
2202
											<?=gettext("The values in this field are DHCP send options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2203
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2204
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2205 f4dd8b4c N0YB
											"Some DHCP services may require certain options be or not be sent. "); ?>
2206 8cd558b6 ayvis
											<br />
2207
											<br />
2208
											<?=gettext("Request Options"); ?><br />
2209 6e31ca39 N0YB
											<input name="adv_dhcp6_interface_statement_request_options" type="text" class="formfld unknown" id="adv_dhcp6_interface_statement_request_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_request_options']);?>" />
2210 8cd558b6 ayvis
											<br />
2211
											<?=gettext("The values in this field are DHCP request options to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2212 f4dd8b4c N0YB
											"Some DHCP services may require certain options be or not be requested. "); ?>
2213 8cd558b6 ayvis
											<br />
2214
											<br />
2215
											<?=gettext("Script"); ?><br />
2216 6e31ca39 N0YB
											<input name="adv_dhcp6_interface_statement_script" type="text" class="formfld unknown" id="adv_dhcp6_interface_statement_script" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_script']);?>" />
2217 8cd558b6 ayvis
											<br />
2218
											<?=gettext("The value in this field is the absolute path to a script invoked on certain conditions including when a reply message is received. <br />" .
2219 f4dd8b4c N0YB
											"[/[dirname/[.../]]filename[.ext]] "); ?>
2220
										</td>
2221
									</tr>
2222
2223 6e31ca39 N0YB
									<tr style='display:none' id="show_adv_dhcp6_id_assoc_statement">
2224 336d4f04 N0YB
										<td width="22%" valign="top" class="vncell">
2225 6e31ca39 N0YB
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Identity_association_statement\">Identity Association Statement</a>"); ?>
2226 336d4f04 N0YB
										</td>
2227 f4dd8b4c N0YB
										<td width="78%" class="vtable">
2228
2229 ce668fcd Colin Fleming
											<input name="adv_dhcp6_id_assoc_statement_address_enable" type="checkbox" id="adv_dhcp6_id_assoc_statement_address_enable" value="" onclick="show_adv_dhcp6_config(this);" />
2230 f4dd8b4c N0YB
											<?=gettext("Non-Temporary Address Allocation"); ?>
2231 6e31ca39 N0YB
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_address">
2232 f4dd8b4c N0YB
											<?=gettext("id-assoc na"); ?>
2233
											<?=gettext("<i>ID</i>"); ?>
2234 6e31ca39 N0YB
											<input name="adv_dhcp6_id_assoc_statement_address_id" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address_id" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_id']);?>" />
2235 8cd558b6 ayvis
											<br />
2236 f4dd8b4c N0YB
											<?=gettext("Address"); ?>
2237
											<?=gettext("<i>ipv6-address</i>"); ?>
2238 6e31ca39 N0YB
											<input name="adv_dhcp6_id_assoc_statement_address" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address" size="34" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address']);?>" />
2239 f4dd8b4c N0YB
											<?=gettext("<i>pltime</i>"); ?>
2240 6e31ca39 N0YB
											<input name="adv_dhcp6_id_assoc_statement_address_pltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address_pltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_pltime']);?>" />
2241 f4dd8b4c N0YB
											<?=gettext("<i>vltime</i>"); ?>
2242 6e31ca39 N0YB
											<input name="adv_dhcp6_id_assoc_statement_address_vltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address_vltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_vltime']);?>" />
2243 f4dd8b4c N0YB
											</div>
2244 6e31ca39 N0YB
											<hr/>
2245 f4dd8b4c N0YB
2246 6e31ca39 N0YB
											<input name="adv_dhcp6_id_assoc_statement_prefix_enable" type="checkbox" id="adv_dhcp6_id_assoc_statement_prefix_enable" value="" onclick="show_adv_dhcp6_config(this)" />
2247 f4dd8b4c N0YB
											<?=gettext("Prefix Delegation"); ?>
2248 6e31ca39 N0YB
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_prefix">
2249 f4dd8b4c N0YB
											<?=gettext("id-assoc pd"); ?>
2250
											<?=gettext("<i>ID</i>"); ?>
2251 6e31ca39 N0YB
											<input name="adv_dhcp6_id_assoc_statement_prefix_id" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix_id" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_id']);?>" />
2252 8cd558b6 ayvis
											<br />
2253 f4dd8b4c N0YB
											<?=gettext("Prefix"); ?>
2254
											<?=gettext("<i>ipv6-prefix</i>"); ?>
2255 6e31ca39 N0YB
											<input name="adv_dhcp6_id_assoc_statement_prefix" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix" size="37" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix']);?>" />
2256 f4dd8b4c N0YB
											<?=gettext("<i>pltime</i>"); ?>
2257 6e31ca39 N0YB
											<input name="adv_dhcp6_id_assoc_statement_prefix_pltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix_pltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime']);?>" />
2258 f4dd8b4c N0YB
											<?=gettext("<i>vltime</i>"); ?>
2259 6e31ca39 N0YB
											<input name="adv_dhcp6_id_assoc_statement_prefix_vltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix_vltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime']);?>" />
2260 f4dd8b4c N0YB
											</div>
2261
										</td>
2262
									</tr>
2263
2264 6e31ca39 N0YB
									<tr style='display:none' id="show_adv_dhcp6_prefix_interface_statement">
2265 336d4f04 N0YB
										<td width="22%" valign="top" class="vncell">
2266 6e31ca39 N0YB
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Prefix_interface_statement\">Prefix Interface Statement</a>"); ?>
2267 336d4f04 N0YB
										</td>
2268 f4dd8b4c N0YB
										<td width="78%" class="vtable">
2269
											<?=gettext("Prefix Interface "); ?>
2270
											<?=gettext("<i>sla-id</i>"); ?>
2271 6e31ca39 N0YB
											<input name="adv_dhcp6_prefix_interface_statement_sla_id" type="text" class="formfld unknown" id="adv_dhcp6_prefix_interface_statement_sla_id" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_prefix_interface_statement_sla_id']);?>" />
2272 f4dd8b4c N0YB
											<?=gettext("<i>sla-len</i>"); ?>
2273 6e31ca39 N0YB
											<input name="adv_dhcp6_prefix_interface_statement_sla_len" type="text" class="formfld unknown" id="adv_dhcp6_prefix_interface_statement_sla_len" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_prefix_interface_statement_sla_len']);?>" />
2274 f4dd8b4c N0YB
										</td>
2275 a236affe N0YB
									</tr>
2276 f4dd8b4c N0YB
2277 6e31ca39 N0YB
									<tr style='display:none' id="show_adv_dhcp6_authentication_statement">
2278 336d4f04 N0YB
										<td width="22%" valign="top" class="vncell">
2279 6e31ca39 N0YB
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Authentication_statement\">Authentication Statement</a>"); ?>
2280 336d4f04 N0YB
										</td>
2281 f4dd8b4c N0YB
										<td width="78%" class="vtable">
2282
											<?=gettext("<i>authname</i>"); ?>
2283 6e31ca39 N0YB
											<input name="adv_dhcp6_authentication_statement_authname" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_authname" size="10" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_authname']);?>" />
2284 f4dd8b4c N0YB
											<?=gettext("<i>protocol</i>"); ?>
2285 6e31ca39 N0YB
											<input name="adv_dhcp6_authentication_statement_protocol" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_protocol" size="6" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_protocol']);?>" />
2286 f4dd8b4c N0YB
											<?=gettext("<i>algorithm</i>"); ?>
2287 6e31ca39 N0YB
											<input name="adv_dhcp6_authentication_statement_algorithm" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_algorithm" size="8" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_algorithm']);?>" />
2288 f4dd8b4c N0YB
											<?=gettext("<i>rdm</i>"); ?>
2289 6e31ca39 N0YB
											<input name="adv_dhcp6_authentication_statement_rdm" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_rdm" size="9" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_rdm']);?>" />
2290 f4dd8b4c N0YB
										</td>
2291
									</tr>
2292
2293 6e31ca39 N0YB
									<tr style='display:none' id="show_adv_dhcp6_key_info_statement">
2294 336d4f04 N0YB
										<td width="22%" valign="top" class="vncell">
2295 6e31ca39 N0YB
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Keyinfo_statement\">Keyinfo Statement</a>"); ?>
2296 336d4f04 N0YB
										</td>
2297 f4dd8b4c N0YB
										<td width="78%" class="vtable">
2298
											<?=gettext("<i>keyname</i>"); ?>
2299 6e31ca39 N0YB
											<input name="adv_dhcp6_key_info_statement_keyname" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_keyname" size="27" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_keyname']);?>" />
2300 f4dd8b4c N0YB
											<?=gettext("<i>realm</i>"); ?>
2301 6e31ca39 N0YB
											<input name="adv_dhcp6_key_info_statement_realm" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_realm" size="37" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_realm']);?>" />
2302 8cd558b6 ayvis
											<br />
2303 f4dd8b4c N0YB
											<?=gettext("<i>keyid</i>"); ?>
2304 6e31ca39 N0YB
											<input name="adv_dhcp6_key_info_statement_keyid" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_keyid" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_keyid']);?>" />
2305 f4dd8b4c N0YB
											<?=gettext("<i>secret</i>"); ?>
2306 6e31ca39 N0YB
											<input name="adv_dhcp6_key_info_statement_secret" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_secret" size="36" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_secret']);?>" />
2307 f4dd8b4c N0YB
											<?=gettext("<i>expire</i>"); ?>
2308 6e31ca39 N0YB
											<input name="adv_dhcp6_key_info_statement_expire" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_expire" size="15" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_expire']);?>" />
2309 f4dd8b4c N0YB
										</td>
2310 a236affe N0YB
									</tr>
2311 f4dd8b4c N0YB
2312 6e31ca39 N0YB
									<tr style='display:none' id="show_adv_dhcp6_config_file_override">
2313 336d4f04 N0YB
										<td width="22%" valign="top" class="vncell">
2314 6e31ca39 N0YB
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports\">Configuration File</a> Override"); ?>
2315 336d4f04 N0YB
										</td>
2316 f4dd8b4c N0YB
										<td width="78%" class="vtable">
2317 6e31ca39 N0YB
 											<input name="adv_dhcp6_config_file_override_path"   type="text" class="formfld unknown" id="adv_dhcp6_config_file_override_path"  size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override_path']);?>" />
2318 8cd558b6 ayvis
											<br />
2319
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2320
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2321
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2322 f4dd8b4c N0YB
											"Some ISPs may require certain options be or not be sent. "); ?>
2323
										</td>
2324
									</tr>
2325
2326
 									<tr>
2327
 										<td colspan="2" valign="top" height="16"></td>
2328
 									</tr>
2329
2330 6e31ca39 N0YB
								</table>
2331
2332 f4dd8b4c N0YB
									<script type="text/javascript">
2333 6e31ca39 N0YB
									//<![CDATA[
2334 f4dd8b4c N0YB
										function show_adv_dhcp6_config(T) {
2335
2336
											if (T.checked) T.value = "Selected";
2337
											else T.value = "";
2338
2339
											     if (document.iform.adv_dhcp6_config_file_override.checked)	show_hide_adv_dhcp6('none', 'none', ''    );
2340
											else if (document.iform.adv_dhcp6_config_advanced.checked)		show_hide_adv_dhcp6('none', '',     'none');
2341
											else 															show_hide_adv_dhcp6('',     'none', 'none');
2342
										}
2343
2344
										function show_hide_adv_dhcp6(basic, advanced, override) {
2345
2346 dbb4e089 Ermal
											document.getElementById("basicdhcp6_use_pppoeinterface").style.display = basic;
2347 f4dd8b4c N0YB
											document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2348 18f3c2fd Daniel Becker
											document.getElementById("basicdhcp6_show_dhcp6_prefix_send_hint").style.display = basic;
2349 a13acc0e smos
											document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
2350 f4dd8b4c N0YB
2351
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2352
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2353
2354
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2355
											if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked)  {
2356
												document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2357
											}
2358
2359
											document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = 'none';
2360
											document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = 'none';
2361
											if (document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked)  {
2362
												document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = advanced;
2363
												document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = advanced;
2364
											}
2365
2366
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2367
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2368
2369
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2370
										}
2371
2372
										<!-- Set the adv_dhcp6_config_advanced checkbox from saved config -->
2373
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_advanced']);?>" == "Selected") document.iform.adv_dhcp6_config_advanced.checked = true;
2374
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_advanced);
2375
2376
										<!-- Set the adv_dhcp6_config_file_override checkbox from saved config -->
2377
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override']);?>" == "Selected") document.iform.adv_dhcp6_config_file_override.checked = true;
2378
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_file_override);
2379
2380
										<!-- Set the adv_dhcp6_interface_statement_information_only_enable checkbox from saved config -->
2381
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_information_only_enable']);?>" == "Selected") document.iform.adv_dhcp6_interface_statement_information_only_enable.checked = true;
2382
										show_adv_dhcp6_config(document.iform.adv_dhcp6_interface_statement_information_only_enable);
2383
2384
										<!-- Set the adv_dhcp6_id_assoc_statement_address_enable checkbox from saved config -->
2385
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked = true;
2386
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_address_enable);
2387
2388
										<!-- Set the adv_dhcp6_id_assoc_statement_prefix_enable checkbox from saved config -->
2389
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked = true;
2390
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_prefix_enable);
2391 6e31ca39 N0YB
									//]]>
2392 f4dd8b4c N0YB
									</script>
2393
2394 47593ac6 Seth Mos
							</td>
2395
						</tr>
2396 6e31ca39 N0YB
						<tr style="display:none;" id="_6rd">
2397 7d567088 smos
							<td colspan="2" style="padding: 0px;">
2398 168549b9 Colin Fleming
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="6rd">
2399 7d567088 smos
									<tr>
2400
										<td colspan="2" valign="top" class="listtopic"><?=gettext("6RD Rapid Deployment"); ?></td>
2401
									</tr>
2402
									<tr>
2403
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD prefix"); ?></td>
2404
										<td width="78%" class="vtable">
2405 2cbe4b47 Colin Fleming
											<input name="prefix-6rd" type="text" class="formfld unknown" id="prefix-6rd" size="40" value="<?=htmlspecialchars($pconfig['prefix-6rd']);?>" />
2406 8cd558b6 ayvis
											<br />
2407 32dc8109 smos
											<?=gettext("The value in this field is the 6RD IPv6 prefix assigned by your ISP. e.g. '2001:db8::/32'") ?><br />
2408 7d567088 smos
										</td>
2409
									</tr>
2410
									<tr>
2411 12215bfb smos
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD Border Relay"); ?></td>
2412 7d567088 smos
										<td width="78%" class="vtable">
2413 2cbe4b47 Colin Fleming
											<input name="gateway-6rd" type="text" class="formfld unknown" id="gateway-6rd" size="40" value="<?=htmlspecialchars($pconfig['gateway-6rd']);?>" />
2414 8cd558b6 ayvis
											<br />
2415 32dc8109 smos
											<?=gettext("The value in this field is 6RD IPv4 gateway address assigned by your ISP") ?><br />
2416 7d567088 smos
										</td>
2417
									</tr>
2418
									<tr>
2419 12215bfb smos
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD IPv4 Prefix length"); ?></td>
2420 7d567088 smos
										<td width="78%" class="vtable">
2421 12215bfb smos
											<select name="prefix-6rd-v4plen" class="formselect" id="prefix-6rd-v4plen">
2422 7d567088 smos
												<?php
2423 12215bfb smos
												for ($i = 0; $i < 32; $i++) {
2424
													echo "<option value=\"{$i}\" ";
2425 339d2743 Colin Fleming
													if (is_numeric($pconfig['prefix-6rd-v4plen']) && ($i == $pconfig['prefix-6rd-v4plen'])) echo "selected=\"selected\"";
2426 12215bfb smos
													echo ">" . $i . " bits</option>";
2427 7d567088 smos
												}
2428
												?>
2429
											</select>
2430 8cd558b6 ayvis
											<br />
2431 12215bfb smos
											<?=gettext("The value in this field is the 6RD IPv4 prefix length. Normally specified by the ISP. A value of 0 means we embed the entire IPv4 address in the 6RD prefix."); ?>
2432 7d567088 smos
										</td>
2433
									</tr>
2434 a236affe N0YB
									<tr>
2435
										<td colspan="2" valign="top" height="16"></td>
2436
									</tr>
2437 7d567088 smos
								</table>
2438
							</td>
2439
						</tr>
2440 6e31ca39 N0YB
						<tr style="display:none;" id="track6">
2441 20a7cb15 smos
							<td colspan="2" style="padding: 0px;">
2442 168549b9 Colin Fleming
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="track6">
2443 20a7cb15 smos
									<tr>
2444
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
2445
									</tr>
2446
									<tr>
2447
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
2448
										<td width="78%" class="vtable">
2449
										<select name='track6-interface' class='formselect' >
2450 6d529efd Renato Botelho
										<?php
2451 20a7cb15 smos
											$interfaces = get_configured_interface_with_descr(false, true);
2452
											$dynv6ifs = array();
2453
											foreach ($interfaces as $iface => $ifacename) {
2454
												switch($config['interfaces'][$iface]['ipaddrv6']) {
2455
													case "6to4":
2456
													case "6rd":
2457
													case "dhcp6":
2458
														$dynv6ifs[$iface] = $ifacename;
2459
														break;
2460
													default:
2461
														continue;
2462
												}
2463
											}
2464 6e31ca39 N0YB
											$rowIndex = 0;
2465 20a7cb15 smos
											foreach($dynv6ifs as $iface => $ifacename) {
2466 6e31ca39 N0YB
												$rowIndex++;
2467 20a7cb15 smos
												echo "<option value=\"{$iface}\"";
2468
												if ($iface == $pconfig['track6-interface'])
2469 339d2743 Colin Fleming
													echo " selected=\"selected\"";
2470 20a7cb15 smos
												echo ">" . htmlspecialchars($ifacename) . "</option>";
2471
											}
2472 6e31ca39 N0YB
											if ($rowIndex == 0)
2473
												echo "<option></option>";
2474 6d529efd Renato Botelho
										?>
2475 8cd558b6 ayvis
										</select> <br />
2476
											<br />
2477 20a7cb15 smos
											<?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
2478
										</td>
2479
									</tr>
2480
									<tr>
2481
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
2482
										<td width="78%" class="vtable">
2483 6b2d4b5a Darren Embry
											<?php
2484 02203e6d Renato Botelho
												if ($pconfig['track6-prefix-id'] == "")
2485
													$pconfig['track6-prefix-id'] = 0;
2486
												$track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
2487 6b2d4b5a Darren Embry
											?>
2488
											<input name="track6-prefix-id--hex" type="text" class="formfld unknown" id="track6-prefix-id--hex" size="8" value="<?= $track6_prefix_id_hex ?>" />
2489
											<br />
2490
											<?= gettext("The value in this field is the (Delegated) IPv6 prefix id. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
2491
											<br />
2492 02203e6d Renato Botelho
											<?= sprintf(gettext("Enter a <b>hexadecimal</b> value between %x and %x here, default value is 0."), 0, $ipv6_num_prefix_ids - 1); ?>
2493 20a7cb15 smos
										</td>
2494
									</tr>
2495 a236affe N0YB
									<tr>
2496
										<td colspan="2" valign="top" height="16"></td>
2497
									</tr>
2498 20a7cb15 smos
								</table>
2499
							</td>
2500
						</tr>
2501 6e31ca39 N0YB
						<tr style="display:none;" id="ppp">
2502 6c05cfb0 gnhb
							<td colspan="2" style="padding: 0px;">
2503 168549b9 Colin Fleming
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="ppp">
2504 6c05cfb0 gnhb
									<tr>
2505 136c598d Carlos Eduardo Ramos
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
2506 6c05cfb0 gnhb
									</tr>
2507 6e31ca39 N0YB
									<tr id="ppp_provider">
2508 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
2509 3a906378 gnhb
										<td width="78%" class="vtable">
2510 168549b9 Colin Fleming
											<table border="0" cellpadding="0" cellspacing="0" summary="service provider">
2511 3a906378 gnhb
												<tr id="trcountry">
2512 933ea015 Carlos Eduardo Ramos
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
2513 3a906378 gnhb
													<td>
2514 32b91bcf Colin Fleming
														<select class="formselect" name="country" id="country" onchange="providers_list()">
2515 3a906378 gnhb
															<option></option>
2516
														</select>
2517
													</td>
2518
												</tr>
2519
												<tr id="trprovider" style="display:none">
2520 933ea015 Carlos Eduardo Ramos
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
2521 3a906378 gnhb
													<td>
2522 4a2c47fe N0YB
														<select class="formselect" name="provider_list" id="provider_list" onchange="providerplan_list()">
2523 3a906378 gnhb
															<option></option>
2524
														</select>
2525
													</td>
2526
												</tr>
2527
												<tr id="trproviderplan" style="display:none">
2528 933ea015 Carlos Eduardo Ramos
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
2529 3a906378 gnhb
													<td>
2530 32b91bcf Colin Fleming
														<select class="formselect" name="providerplan" id="providerplan" onchange="prefill_provider()">
2531 3a906378 gnhb
															<option></option>
2532
														</select>
2533
													</td>
2534
												</tr>
2535
											</table>
2536 8cd558b6 ayvis
											<br /><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
2537 3a906378 gnhb
										</td>
2538
									</tr>
2539 6c05cfb0 gnhb
									<tr>
2540 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
2541 3a906378 gnhb
										<td width="78%" class="vtable">
2542 2cbe4b47 Colin Fleming
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>" />
2543 3a906378 gnhb
										</td>
2544
									</tr>
2545
									<tr>
2546 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
2547 3a906378 gnhb
										<td width="78%" class="vtable">
2548 2cbe4b47 Colin Fleming
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>" />
2549 3a906378 gnhb
										</td>
2550
									</tr>
2551 6e31ca39 N0YB
									<tr id="phone_num">
2552 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
2553 3a906378 gnhb
										<td width="78%" class="vtable">
2554 2cbe4b47 Colin Fleming
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>" />
2555 3a906378 gnhb
										</td>
2556
									</tr>
2557 6e31ca39 N0YB
									<tr id="apn_">
2558 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
2559 3a906378 gnhb
										<td width="78%" class="vtable">
2560 2cbe4b47 Colin Fleming
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>" />
2561 3a906378 gnhb
										</td>
2562
									</tr>
2563 6e31ca39 N0YB
									<tr id="interface" >
2564 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
2565 3a906378 gnhb
										<td width="78%" class="vtable">
2566
											<select name="port" id="port" class="formselect">
2567
											<?php
2568
												$portlist = glob("/dev/cua*");
2569
												$modems = glob("/dev/modem*");
2570
												$portlist = array_merge($portlist, $modems);
2571 6e31ca39 N0YB
												$rowIndex = 0;
2572 3a906378 gnhb
												foreach ($portlist as $port) {
2573
													if(preg_match("/\.(lock|init)$/", $port))
2574
														continue;
2575 6e31ca39 N0YB
													$rowIndex++;
2576 3a906378 gnhb
													echo "<option value=\"".trim($port)."\"";
2577
													if ($pconfig['port'] == $port)
2578 339d2743 Colin Fleming
														echo " selected=\"selected\"";
2579 3a906378 gnhb
													echo ">{$port}</option>";
2580 6e31ca39 N0YB
												}
2581
												if ($rowIndex == 0)
2582
													echo "<option></option>";
2583
												?>
2584 3a906378 gnhb
											</select>
2585
										</td>
2586
									</tr>
2587 168549b9 Colin Fleming
									<tr>
2588 136c598d Carlos Eduardo Ramos
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
2589 6c05cfb0 gnhb
										<?php if (isset($pconfig['pppid'])): ?>
2590
											<td width="78%" class="vtable">
2591 933ea015 Carlos Eduardo Ramos
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2592
											<?=gettext("to edit PPP configuration."); ?>
2593 6c05cfb0 gnhb
											</td>
2594 ee9933b6 Renato Botelho
										<?php else: ?>
2595 6c05cfb0 gnhb
											<td width="78%" class="vtable">
2596 933ea015 Carlos Eduardo Ramos
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2597
											<?=gettext("to create a PPP configuration."); ?>
2598 6c05cfb0 gnhb
											</td>
2599 c0948c6c Renato Botelho
										<?php endif; ?>
2600 6c05cfb0 gnhb
									</tr>
2601 a236affe N0YB
									<tr>
2602
										<td colspan="2" valign="top" height="16"></td>
2603
									</tr>
2604 6c05cfb0 gnhb
								</table>
2605
							</td>
2606
						</tr>
2607 6e31ca39 N0YB
						<tr style="display:none;" id="pppoe">
2608 30ade846 gnhb
							<td colspan="2" style="padding:0px;">
2609 168549b9 Colin Fleming
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pppoe">
2610 30ade846 gnhb
									<tr>
2611 136c598d Carlos Eduardo Ramos
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
2612 30ade846 gnhb
									</tr>
2613
									<tr>
2614 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2615 30ade846 gnhb
										<td width="78%" class="vtable">
2616 2cbe4b47 Colin Fleming
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>" />
2617 30ade846 gnhb
										</td>
2618
									</tr>
2619
									<tr>
2620 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2621 30ade846 gnhb
										<td width="78%" class="vtable">
2622 2cbe4b47 Colin Fleming
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>" />
2623 30ade846 gnhb
										</td>
2624
									</tr>
2625
									<tr>
2626 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
2627 2cbe4b47 Colin Fleming
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>" />
2628 8cd558b6 ayvis
											<br /> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
2629 30ade846 gnhb
										</td>
2630
									</tr>
2631
									<tr>
2632 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2633 30ade846 gnhb
										<td width="78%" class="vtable">
2634 339d2743 Colin Fleming
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked=\"checked\""; ?> />
2635 8cd558b6 ayvis
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br />
2636 933ea015 Carlos Eduardo Ramos
											<?=gettext("This option causes the interface to operate in dial-on-demand mode, allowing you to have a "); ?><i><?=gettext("virtual full time"); ?></i> <?=gettext("connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected."); ?>
2637 30ade846 gnhb
										</td>
2638
									</tr>
2639
									<tr>
2640 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2641 30ade846 gnhb
										<td width="78%" class="vtable">
2642 8cd558b6 ayvis
											<input name="pppoe_idletimeout" type="text" class="formfld unknown" id="pppoe_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pppoe_idletimeout']);?>" /> <?=gettext("seconds"); ?><br /><?=gettext("If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. An idle timeout of zero disables this feature."); ?>
2643 30ade846 gnhb
										</td>
2644
									</tr>
2645
									<tr>
2646
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
2647
										<td width="78%" class="vtable">
2648 168549b9 Colin Fleming
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%" summary="periodic reset">
2649 30ade846 gnhb
												<tr>
2650
													<td align="left" valign="top">
2651
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
2652 168549b9 Colin Fleming
														<select style="vertical-align:top" id="reset_type" name="pppoe-reset-type" class="formselect" onchange="show_reset_settings(this.value);">
2653 339d2743 Colin Fleming
															<option value=""><?=gettext("Disabled"); ?></option>
2654
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected=\"selected\""; ?>><?=gettext("Custom"); ?></option>
2655
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected=\"selected\""; ?>><?=gettext("Pre-Set"); ?></option>
2656 136c598d Carlos Eduardo Ramos
														</select> <?=gettext("Select a reset timing type"); ?>
2657 30ade846 gnhb
														</p>
2658
														<?php if ($pconfig['pppoe_pr_custom']): ?>
2659
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
2660
														<?php else: ?>
2661
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
2662
														<?php endif; ?>
2663 c0948c6c Renato Botelho
														<input type="text" name="pppoe_resethour" class="fd_incremental_inp_range_0_23 fd_increment_1 fd_classname_dec_buttonDec fd_classname_inc_buttonInc" maxlength="2" id="pppoe_resethour" value="<?= $pconfig['pppoe_resethour']; ?>" size="3" />
2664 136c598d Carlos Eduardo Ramos
														<?=gettext("hour (0-23)"); ?><br />
2665 c0948c6c Renato Botelho
														<input type="text" name="pppoe_resetminute" class="fd_incremental_inp_range_0_59 fd_increment_1 fd_classname_dec_buttonDec fd_classname_inc_buttonInc" maxlength="2" id="pppoe_resetminute" value="<?= $pconfig['pppoe_resetminute']; ?>" size="3" />
2666 136c598d Carlos Eduardo Ramos
														<?=gettext("minute (0-59)"); ?><br />
2667 c0948c6c Renato Botelho
														<input name="pppoe_resetdate" type="text" class="w8em format-m-d-y highlight-days-67" id="pppoe_resetdate" maxlength="10" size="10" value="<?=htmlspecialchars($pconfig['pppoe_resetdate']);?>" />
2668 136c598d Carlos Eduardo Ramos
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
2669 30ade846 gnhb
														<br />&nbsp;<br />
2670 933ea015 Carlos Eduardo Ramos
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
2671 136c598d Carlos Eduardo Ramos
														<?=gettext("If you leave the date field empty, the reset will be executed each day at the time you did specify using the minutes and hour field."); ?>
2672 30ade846 gnhb
														</p>
2673
														<?php if ($pconfig['pppoe_pr_preset']): ?>
2674
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
2675
														<?php else: ?>
2676
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
2677
														<?php endif; ?>
2678 c0948c6c Renato Botelho
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
2679 136c598d Carlos Eduardo Ramos
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
2680 30ade846 gnhb
														<br />
2681 c0948c6c Renato Botelho
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
2682 136c598d Carlos Eduardo Ramos
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
2683 30ade846 gnhb
														<br />
2684 c0948c6c Renato Botelho
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
2685 136c598d Carlos Eduardo Ramos
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
2686 30ade846 gnhb
														<br />
2687 c0948c6c Renato Botelho
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
2688 136c598d Carlos Eduardo Ramos
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
2689 30ade846 gnhb
														</p>
2690
													</td>
2691
												</tr>
2692
											</table>
2693
										</td>
2694
									</tr>
2695 c0948c6c Renato Botelho
2696 30ade846 gnhb
									<tr>
2697 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
2698 30ade846 gnhb
										<?php if (isset($pconfig['pppid'])): ?>
2699 09637075 gnhb
											<td width="78%" class="vtable">
2700 c0948c6c Renato Botelho
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2701 933ea015 Carlos Eduardo Ramos
											<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
2702 9978e156 gnhb
											</td>
2703 ee9933b6 Renato Botelho
										<?php else: ?>
2704 09637075 gnhb
											<td width="78%" class="vtable">
2705 136c598d Carlos Eduardo Ramos
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2706 933ea015 Carlos Eduardo Ramos
											<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
2707 30ade846 gnhb
											</td>
2708 c0948c6c Renato Botelho
										<?php endif; ?>
2709 30ade846 gnhb
									</tr>
2710 a236affe N0YB
									<tr>
2711
										<td colspan="2" valign="top" height="16"></td>
2712
									</tr>
2713 30ade846 gnhb
								</table>
2714 87f0be87 Chris Buechler
							</td>
2715 667a3184 Scott Ullrich
						</tr>
2716 6e31ca39 N0YB
						<tr style="display:none;" id="pptp">
2717 30ade846 gnhb
							<td colspan="2" style="padding:0px;">
2718 168549b9 Colin Fleming
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pptp">
2719 30ade846 gnhb
									<tr>
2720 e4d40f41 gnhb
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP/L2TP configuration"); ?></td>
2721 30ade846 gnhb
									</tr>
2722
									<tr>
2723 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2724 30ade846 gnhb
										<td width="78%" class="vtable">
2725 2cbe4b47 Colin Fleming
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>" />
2726 30ade846 gnhb
										</td>
2727
									</tr>
2728
									<tr>
2729 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2730 30ade846 gnhb
										<td width="78%" class="vtable">
2731 2cbe4b47 Colin Fleming
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>" />
2732 30ade846 gnhb
										</td>
2733
									</tr>
2734
									<tr>
2735 168549b9 Colin Fleming
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
2736 c0948c6c Renato Botelho
										<td width="78%" class="vtable">
2737 2cbe4b47 Colin Fleming
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>" />
2738 30ade846 gnhb
											/
2739
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
2740
												<?php for ($i = 31; $i > 0; $i--): ?>
2741 339d2743 Colin Fleming
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected=\"selected\""; ?>>
2742 30ade846 gnhb
														<?=$i;?></option>
2743
												<?php endfor; ?>
2744
											</select>
2745
										</td>
2746
									</tr>
2747
									<tr>
2748 168549b9 Colin Fleming
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
2749 30ade846 gnhb
										<td width="78%" class="vtable">
2750 2cbe4b47 Colin Fleming
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>" />
2751 30ade846 gnhb
										</td>
2752
									</tr>
2753
									<tr>
2754 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2755 30ade846 gnhb
										<td width="78%" class="vtable">
2756 339d2743 Colin Fleming
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked=\"checked\""; ?> />
2757 8cd558b6 ayvis
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br />
2758 933ea015 Carlos Eduardo Ramos
											<?=gettext("This option causes the interface to operate in dial-on-demand mode, allowing you to have a"); ?> <i><?=gettext("virtual full time"); ?></i> <?=gettext("connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected."); ?>
2759 30ade846 gnhb
										</td>
2760
									</tr>
2761
									<tr>
2762 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2763 30ade846 gnhb
										<td width="78%" class="vtable">
2764 8cd558b6 ayvis
											<input name="pptp_idletimeout" type="text" class="formfld unknown" id="pptp_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pptp_idletimeout']);?>" /> <?=gettext("seconds"); ?><br /><?=gettext("If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. An idle timeout of zero disables this feature."); ?>
2765 30ade846 gnhb
										</td>
2766
									</tr>
2767 4a1ee8ac gnhb
									<tr>
2768 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
2769 4a1ee8ac gnhb
										<?php if (isset($pconfig['pppid'])): ?>
2770
											<td width="78%" class="vtable">
2771 c0948c6c Renato Botelho
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
2772 933ea015 Carlos Eduardo Ramos
											<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
2773 4a1ee8ac gnhb
											</td>
2774 ee9933b6 Renato Botelho
										<?php else: ?>
2775 4a1ee8ac gnhb
											<td width="78%" class="vtable">
2776 4256d115 Renato Botelho
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
2777
											<?=gettext("for advanced PPTP and L2TP configuration options");?>.
2778 4a1ee8ac gnhb
											</td>
2779 c0948c6c Renato Botelho
										<?php endif; ?>
2780 4a1ee8ac gnhb
									</tr>
2781 a236affe N0YB
									<tr>
2782
										<td colspan="2" valign="top" height="16"></td>
2783
									</tr>
2784 30ade846 gnhb
								</table>
2785
							</td>
2786
						</tr>
2787
						<?php
2788
							/* Wireless interface? */
2789
							if (isset($wancfg['wireless'])):
2790
						?>
2791 9978e156 gnhb
						<tr>
2792 136c598d Carlos Eduardo Ramos
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
2793 9978e156 gnhb
						</tr>
2794 f62c44d8 Erik Fonnesbeck
						<tr>
2795 4256d115 Renato Botelho
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
2796 f62c44d8 Erik Fonnesbeck
							<td class="vtable">
2797 339d2743 Colin Fleming
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked=\"checked\"";?> />
2798 8cd558b6 ayvis
								<br /><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
2799 f62c44d8 Erik Fonnesbeck
							</td>
2800
						</tr>
2801 9978e156 gnhb
						<tr>
2802 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
2803 30ade846 gnhb
							<td class="vtable">
2804 3a13f094 gnhb
							<select name="standard" class="formselect" id="standard">
2805
								<?php
2806 6e31ca39 N0YB
								$rowIndex = 0;
2807 3a13f094 gnhb
								foreach($wl_modes as $wl_standard => $wl_channels) {
2808 6e31ca39 N0YB
									$rowIndex++;
2809 3a13f094 gnhb
									echo "<option ";
2810
									if ($pconfig['standard'] == "$wl_standard")
2811 339d2743 Colin Fleming
										echo "selected=\"selected\" ";
2812 3a13f094 gnhb
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
2813
								}
2814 6e31ca39 N0YB
								if ($rowIndex == 0)
2815
									echo "<option></option>";
2816 3a13f094 gnhb
								?>
2817
							</select>
2818 30ade846 gnhb
							</td>
2819
						</tr>
2820
						<?php if (isset($wl_modes['11g'])): ?>
2821
						<tr>
2822 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
2823 30ade846 gnhb
							<td class="vtable">
2824
								<select name="protmode" class="formselect" id="protmode">
2825 339d2743 Colin Fleming
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected=\"selected\"";?> value="off"><?=gettext("Protection mode off"); ?></option>
2826
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected=\"selected\"";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
2827
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected=\"selected\"";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
2828 30ade846 gnhb
								</select>
2829 8cd558b6 ayvis
								<br />
2830 933ea015 Carlos Eduardo Ramos
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
2831 8cd558b6 ayvis
								<br />
2832 30ade846 gnhb
							</td>
2833
						</tr>
2834
						<?php else: ?>
2835 2cbe4b47 Colin Fleming
						<input name="protmode" type="hidden" id="protmode" value="off" />
2836 30ade846 gnhb
						<?php endif; ?>
2837
						<tr>
2838 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
2839 30ade846 gnhb
							<td class="vtable">
2840
								<select name="txpower" class="formselect" id="txpower">
2841
									<?
2842
									for($x = 99; $x > 0; $x--) {
2843
										if($pconfig["txpower"] == $x)
2844 339d2743 Colin Fleming
											$SELECTED = " selected=\"selected\"";
2845 30ade846 gnhb
										else
2846
											$SELECTED = "";
2847
										echo "<option {$SELECTED}>{$x}</option>\n";
2848
									}
2849
									?>
2850 8cd558b6 ayvis
								</select><br />
2851 3b7f0f53 Erik Fonnesbeck
								<?=gettext("Note: Typically only a few discreet power settings are available and the driver will use the setting closest to the specified value.  Not all adapters support changing the transmit power setting."); ?>
2852 9978e156 gnhb
							</td>
2853
						</tr>
2854
						<tr>
2855 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncellreq"><?=gettext("Channel"); ?></td>
2856 30ade846 gnhb
							<td class="vtable">
2857
								<select name="channel" class="formselect" id="channel">
2858 339d2743 Colin Fleming
									<option <?php if ($pconfig['channel'] == 0) echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2859 9978e156 gnhb
									<?php
2860 30ade846 gnhb
									foreach($wl_modes as $wl_standard => $wl_channels) {
2861
										if($wl_standard == "11g") { $wl_standard = "11b/g"; }
2862
										else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
2863
										else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
2864
										foreach($wl_channels as $wl_channel) {
2865
											echo "<option ";
2866
											if ($pconfig['channel'] == "$wl_channel") {
2867 339d2743 Colin Fleming
												echo "selected=\"selected\" ";
2868 30ade846 gnhb
											}
2869
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
2870
											if(isset($wl_chaninfo[$wl_channel]))
2871
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
2872
											echo "</option>\n";
2873 d85ba87f gnhb
										}
2874 9978e156 gnhb
									}
2875
									?>
2876
								</select>
2877 8cd558b6 ayvis
								<br />
2878 136c598d Carlos Eduardo Ramos
								<?=gettext("Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)"); ?>
2879 8cd558b6 ayvis
								<br />
2880 933ea015 Carlos Eduardo Ramos
								<?=gettext("Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above."); ?>
2881 9978e156 gnhb
							</td>
2882
						</tr>
2883 537bf7b3 Erik Fonnesbeck
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2884
						<tr>
2885
							<td valign="top" class="vncell"><?=gettext("Antenna settings"); ?></td>
2886
							<td class="vtable">
2887 168549b9 Colin Fleming
								<table border="0" cellpadding="0" cellspacing="0" summary="antenna settings">
2888 537bf7b3 Erik Fonnesbeck
									<tr>
2889
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])): ?>
2890
										<td>
2891 8cd558b6 ayvis
											<?=gettext("Diversity"); ?><br />
2892 537bf7b3 Erik Fonnesbeck
											<select name="diversity" class="formselect" id="diversity">
2893 339d2743 Colin Fleming
												<option <?php if (!isset($pconfig['diversity'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2894
												<option <?php if ($pconfig['diversity'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Off"); ?></option>
2895
												<option <?php if ($pconfig['diversity'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("On"); ?></option>
2896 537bf7b3 Erik Fonnesbeck
											</select>
2897
										</td>
2898 6e31ca39 N0YB
										<td>&nbsp;&nbsp;</td>
2899 537bf7b3 Erik Fonnesbeck
										<?php endif; ?>
2900
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])): ?>
2901
										<td>
2902 8cd558b6 ayvis
											<?=gettext("Transmit antenna"); ?><br />
2903 537bf7b3 Erik Fonnesbeck
											<select name="txantenna" class="formselect" id="txantenna">
2904 339d2743 Colin Fleming
												<option <?php if (!isset($pconfig['txantenna'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2905
												<option <?php if ($pconfig['txantenna'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2906
												<option <?php if ($pconfig['txantenna'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("#1"); ?></option>
2907
												<option <?php if ($pconfig['txantenna'] === '2') echo "selected=\"selected\""; ?> value="2"><?=gettext("#2"); ?></option>
2908 537bf7b3 Erik Fonnesbeck
											</select>
2909
										</td>
2910 6e31ca39 N0YB
										<td>&nbsp;&nbsp;</td>
2911 537bf7b3 Erik Fonnesbeck
										<?php endif; ?>
2912
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2913
										<td>
2914 8cd558b6 ayvis
											<?=gettext("Receive antenna"); ?><br />
2915 537bf7b3 Erik Fonnesbeck
											<select name="rxantenna" class="formselect" id="rxantenna">
2916 339d2743 Colin Fleming
												<option <?php if (!isset($pconfig['rxantenna'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2917
												<option <?php if ($pconfig['rxantenna'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2918
												<option <?php if ($pconfig['rxantenna'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("#1"); ?></option>
2919
												<option <?php if ($pconfig['rxantenna'] === '2') echo "selected=\"selected\""; ?> value="2"><?=gettext("#2"); ?></option>
2920 537bf7b3 Erik Fonnesbeck
											</select>
2921
										</td>
2922
										<?php endif; ?>
2923
									</tr>
2924
								</table>
2925 8cd558b6 ayvis
								<br />
2926 537bf7b3 Erik Fonnesbeck
								<?=gettext("Note: The antenna numbers do not always match up with the labels on the card."); ?>
2927
							</td>
2928
						</tr>
2929
						<?php endif; ?>
2930 6681fdd3 Erik Fonnesbeck
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])): ?>
2931 9978e156 gnhb
						<tr>
2932 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Distance setting"); ?></td>
2933 30ade846 gnhb
							<td class="vtable">
2934 2cbe4b47 Colin Fleming
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>" />
2935 8cd558b6 ayvis
								<br />
2936
								<?=gettext("Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client"); ?><br />
2937 136c598d Carlos Eduardo Ramos
								<?=gettext("(measured in Meters and works only for Atheros based cards !)"); ?>
2938 30ade846 gnhb
							</td>
2939 9978e156 gnhb
						</tr>
2940 6681fdd3 Erik Fonnesbeck
						<?php endif; ?>
2941 9978e156 gnhb
						<tr>
2942 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Regulatory settings"); ?></td>
2943 30ade846 gnhb
							<td class="vtable">
2944 8cd558b6 ayvis
								<?=gettext("Regulatory domain"); ?><br />
2945 30ade846 gnhb
								<select name="regdomain" class="formselect" id="regdomain">
2946 339d2743 Colin Fleming
									<option <?php if (empty($pconfig['regdomain'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2947 30ade846 gnhb
									<?php
2948
									foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
2949
										echo "<option ";
2950
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
2951 339d2743 Colin Fleming
											echo "selected=\"selected\" ";
2952 30ade846 gnhb
										}
2953
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
2954
									}
2955
									?>
2956
								</select>
2957 8cd558b6 ayvis
								<br />
2958 933ea015 Carlos Eduardo Ramos
								<?=gettext("Note: Some cards have a default that is not recognized and require changing the regulatory domain to one in this list for the changes to other regulatory settings to work."); ?>
2959 8cd558b6 ayvis
								<br /><br />
2960
								<?=gettext("Country (listed with country code and regulatory domain)"); ?><br />
2961 30ade846 gnhb
								<select name="regcountry" class="formselect" id="regcountry">
2962 339d2743 Colin Fleming
									<option <?php if (empty($pconfig['regcountry'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2963 30ade846 gnhb
									<?php
2964
									foreach($wl_countries as $wl_country_key => $wl_country) {
2965
										echo "<option ";
2966
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
2967 339d2743 Colin Fleming
											echo "selected=\"selected\" ";
2968 30ade846 gnhb
										}
2969
										echo "value=\"{$wl_countries_attr[$wl_country_key]['ID']}\">{$wl_country['name']} -- ({$wl_countries_attr[$wl_country_key]['ID']}, " . strtoupper($wl_countries_attr[$wl_country_key]['rd'][0]['REF']) . ")</option>\n";
2970
									}
2971
									?>
2972
								</select>
2973 8cd558b6 ayvis
								<br />
2974 136c598d Carlos Eduardo Ramos
								<?=gettext("Note: Any country setting other than \"Default\" will override the regulatory domain setting"); ?>.
2975 8cd558b6 ayvis
								<br /><br />
2976
								<?=gettext("Location"); ?><br />
2977 30ade846 gnhb
								<select name="reglocation" class="formselect" id="reglocation">
2978 339d2743 Colin Fleming
									<option <?php if (empty($pconfig['reglocation'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2979
									<option <?php if ($pconfig['reglocation'] == 'indoor') echo "selected=\"selected\""; ?> value="indoor"><?=gettext("Indoor"); ?></option>
2980
									<option <?php if ($pconfig['reglocation'] == 'outdoor') echo "selected=\"selected\""; ?> value="outdoor"><?=gettext("Outdoor"); ?></option>
2981
									<option <?php if ($pconfig['reglocation'] == 'anywhere') echo "selected=\"selected\""; ?> value="anywhere"><?=gettext("Anywhere"); ?></option>
2982 30ade846 gnhb
								</select>
2983 8cd558b6 ayvis
								<br /><br />
2984 933ea015 Carlos Eduardo Ramos
								<?=gettext("These settings may affect which channels are available and the maximum transmit power allowed on those channels.  Using the correct settings to comply with local regulatory requirements is recommended."); ?>
2985 8cd558b6 ayvis
								<br />
2986 933ea015 Carlos Eduardo Ramos
								<?=gettext("Note: All wireless networks on this interface will be temporarily brought down when changing regulatory settings.  Some of the regulatory domains or country codes may not be allowed by some cards.  These settings may not be able to add additional channels that are not already supported."); ?>
2987 9978e156 gnhb
							</td>
2988
						</tr>
2989
						<tr>
2990 30ade846 gnhb
							<td colspan="2" valign="top" height="16"></td>
2991 c0948c6c Renato Botelho
						</tr>
2992 30ade846 gnhb
						<tr>
2993 4256d115 Renato Botelho
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Network-specific wireless configuration");?></td>
2994 30ade846 gnhb
						</tr>
2995
						<tr>
2996 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncellreq"><?=gettext("Mode"); ?></td>
2997 30ade846 gnhb
							<td class="vtable">
2998
								<select name="mode" class="formselect" id="mode">
2999 339d2743 Colin Fleming
									<option <?php if ($pconfig['mode'] == 'bss') echo "selected=\"selected\"";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
3000
									<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected=\"selected\"";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
3001
									<option <?php if ($pconfig['mode'] == 'hostap') echo "selected=\"selected\"";?> value="hostap"><?=gettext("Access Point"); ?></option>
3002 30ade846 gnhb
								</select>
3003 9978e156 gnhb
							</td>
3004
						</tr>
3005
						<tr>
3006 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncellreq"><?=gettext("SSID"); ?></td>
3007 30ade846 gnhb
							<td class="vtable">
3008 2cbe4b47 Colin Fleming
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>" />
3009 8cd558b6 ayvis
								<br />
3010 cb3c3fe4 Namezero
								<?=gettext("Note: Only required in Access Point mode. If left blank in Ad-hoc or Infrastructure mode, this interface will connect to any available SSID"); ?>
3011 9978e156 gnhb
							</td>
3012
						</tr>
3013 30ade846 gnhb
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
3014 9978e156 gnhb
						<tr>
3015 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Minimum wireless standard"); ?></td>
3016 30ade846 gnhb
							<td class="vtable">
3017
								<select name="puremode" class="formselect" id="puremode">
3018 339d2743 Colin Fleming
									<option <?php if ($pconfig['puremode'] == 'any') echo "selected=\"selected\"";?> value="any"><?=gettext("Any"); ?></option>
3019 30ade846 gnhb
									<?php if (isset($wl_modes['11g'])): ?>
3020 339d2743 Colin Fleming
									<option <?php if ($pconfig['puremode'] == '11g') echo "selected=\"selected\"";?> value="11g"><?=gettext("802.11g"); ?></option>
3021 30ade846 gnhb
									<?php endif; ?>
3022 339d2743 Colin Fleming
									<option <?php if ($pconfig['puremode'] == '11n') echo "selected=\"selected\"";?> value="11n"><?=gettext("802.11n"); ?></option>
3023 30ade846 gnhb
								</select>
3024 8cd558b6 ayvis
								<br />
3025 933ea015 Carlos Eduardo Ramos
								<?=gettext("When operating as an access point, allow only stations capable of the selected wireless standard to associate (stations not capable are not permitted to associate)."); ?>
3026 9978e156 gnhb
							</td>
3027
						</tr>
3028 30ade846 gnhb
						<?php elseif (isset($wl_modes['11g'])): ?>
3029 9978e156 gnhb
						<tr>
3030 933ea015 Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("802.11g only"); ?></td>
3031 30ade846 gnhb
							<td class="vtable">
3032 339d2743 Colin Fleming
								<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <?php if ($pconfig['puremode'] == '11g') echo "checked=\"checked\"";?> />
3033 8cd558b6 ayvis
								<br /><?=gettext("When operating as an access point in 802.11g mode, allow only 11g-capable stations to associate (11b-only stations are not permitted to associate)."); ?>
3034 9978e156 gnhb
							</td>
3035
						</tr>
3036 30ade846 gnhb
						<?php endif; ?>
3037 9978e156 gnhb
						<tr>
3038 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Allow intra-BSS communication"); ?></td>
3039 30ade846 gnhb
							<td class="vtable">
3040 339d2743 Colin Fleming
								<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <?php if ($pconfig['apbridge_enable']) echo "checked=\"checked\"";?> />
3041 8cd558b6 ayvis
								<br />
3042 933ea015 Carlos Eduardo Ramos
								<?=gettext("When operating as an access point, enable this if you want to pass packets between wireless clients directly."); ?>
3043 8cd558b6 ayvis
								<br />
3044 933ea015 Carlos Eduardo Ramos
								<?=gettext("Disabling the internal bridging is useful when traffic is to be processed with packet filtering."); ?>
3045 30ade846 gnhb
							</td>
3046
						</tr>
3047
						<tr>
3048 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Enable WME"); ?></td>
3049 30ade846 gnhb
							<td class="vtable">
3050 339d2743 Colin Fleming
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <?php if ($pconfig['wme_enable']) echo "checked=\"checked\"";?> />
3051 8cd558b6 ayvis
								<br /><?=gettext("Setting this option will force the card to use WME (wireless QoS)."); ?>
3052 30ade846 gnhb
							</td>
3053
						</tr>
3054
						<tr>
3055 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Enable Hide SSID"); ?></td>
3056 30ade846 gnhb
							<td class="vtable">
3057 339d2743 Colin Fleming
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <?php if ($pconfig['hidessid_enable']) echo "checked=\"checked\"";?> />
3058 8cd558b6 ayvis
								<br />
3059 136c598d Carlos Eduardo Ramos
								<?=gettext("Setting this option will force the card to NOT broadcast its SSID"); ?>
3060 8cd558b6 ayvis
								<br />
3061 933ea015 Carlos Eduardo Ramos
								<?=gettext("(this might create problems for some clients)."); ?>
3062 30ade846 gnhb
							</td>
3063
						</tr>
3064
						<tr>
3065 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("WEP"); ?></td>
3066 c0948c6c Renato Botelho
							<td class="vtable">
3067 339d2743 Colin Fleming
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <?php if ($pconfig['wep_enable']) echo "checked=\"checked\""; ?> />
3068 136c598d Carlos Eduardo Ramos
								<strong><?=gettext("Enable WEP"); ?></strong>
3069 168549b9 Colin Fleming
								<table border="0" cellspacing="0" cellpadding="0" summary="wep">
3070 9978e156 gnhb
									<tr>
3071 30ade846 gnhb
										<td>&nbsp;</td>
3072
										<td>&nbsp;</td>
3073 136c598d Carlos Eduardo Ramos
										<td>&nbsp;<?=gettext("TX key"); ?>&nbsp;</td>
3074 30ade846 gnhb
									</tr>
3075
									<tr>
3076 933ea015 Carlos Eduardo Ramos
										<td><?=gettext("Key 1:"); ?>&nbsp;&nbsp;</td>
3077 30ade846 gnhb
										<td>
3078 2cbe4b47 Colin Fleming
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>" />
3079 30ade846 gnhb
										</td>
3080
										<td align="center">
3081 6e31ca39 N0YB
											<input name="txkey" type="radio" value="1" <?php if ($pconfig['txkey'] == 1) echo "checked=\"checked\"";?> />
3082 30ade846 gnhb
										</td>
3083
									</tr>
3084
									<tr>
3085 933ea015 Carlos Eduardo Ramos
										<td><?=gettext("Key 2:"); ?>&nbsp;&nbsp;</td>
3086 30ade846 gnhb
										<td>
3087 2cbe4b47 Colin Fleming
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>" />
3088 30ade846 gnhb
										</td>
3089
										<td align="center">
3090 339d2743 Colin Fleming
											<input name="txkey" type="radio" value="2" <?php if ($pconfig['txkey'] == 2) echo "checked=\"checked\"";?> />
3091 30ade846 gnhb
										</td>
3092
									</tr>
3093
									<tr>
3094 933ea015 Carlos Eduardo Ramos
										<td><?=gettext("Key 3:"); ?>&nbsp;&nbsp;</td>
3095 30ade846 gnhb
										<td>
3096 2cbe4b47 Colin Fleming
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>" />
3097 30ade846 gnhb
										</td>
3098
										<td align="center">
3099 339d2743 Colin Fleming
											<input name="txkey" type="radio" value="3" <?php if ($pconfig['txkey'] == 3) echo "checked=\"checked\"";?> />
3100 30ade846 gnhb
										</td>
3101
									</tr>
3102
									<tr>
3103 933ea015 Carlos Eduardo Ramos
										<td><?=gettext("Key 4:"); ?>&nbsp;&nbsp;</td>
3104 30ade846 gnhb
										<td>
3105 2cbe4b47 Colin Fleming
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>" />
3106 30ade846 gnhb
										</td>
3107
										<td align="center">
3108 339d2743 Colin Fleming
											<input name="txkey" type="radio" value="4" <?php if ($pconfig['txkey'] == 4) echo "checked=\"checked\"";?> />
3109 9978e156 gnhb
										</td>
3110
									</tr>
3111
								</table>
3112 8cd558b6 ayvis
								<br />
3113
								<?=gettext("40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'."); ?><br />
3114 933ea015 Carlos Eduardo Ramos
								<?=gettext("104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'."); ?>
3115 9978e156 gnhb
							</td>
3116
						</tr>
3117
						<tr>
3118 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("WPA"); ?></td>
3119 30ade846 gnhb
							<td class="vtable">
3120 339d2743 Colin Fleming
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <?php if ($pconfig['wpa_enable']) echo "checked=\"checked\""; ?> />
3121 136c598d Carlos Eduardo Ramos
								<strong><?=gettext("Enable WPA"); ?></strong>
3122 8cd558b6 ayvis
								<br /><br />
3123 168549b9 Colin Fleming
								<table border="0" cellspacing="0" cellpadding="0" summary="wpa">
3124 30ade846 gnhb
									<tr>
3125
										<td>&nbsp;</td>
3126 2a2b247b jim-p
										<td>&nbsp;<?=gettext("WPA Pre-Shared Key"); ?>&nbsp;</td>
3127 30ade846 gnhb
									</tr>
3128
									<tr>
3129 933ea015 Carlos Eduardo Ramos
										<td><?=gettext("PSK:"); ?>&nbsp;&nbsp;</td>
3130 30ade846 gnhb
										<td>
3131 2cbe4b47 Colin Fleming
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>" />
3132 30ade846 gnhb
										</td>
3133
									</tr>
3134
								</table>
3135 8cd558b6 ayvis
								<br /><?=gettext("Passphrase must be from 8 to 63 characters."); ?>
3136 30ade846 gnhb
							</td>
3137 9978e156 gnhb
						</tr>
3138
						<tr>
3139 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("WPA Mode"); ?></td>
3140 30ade846 gnhb
							<td class="vtable">
3141
								<select name="wpa_mode" class="formselect" id="wpa_mode">
3142 339d2743 Colin Fleming
									<option <?php if ($pconfig['wpa_mode'] == '1') echo "selected=\"selected\"";?> value="1"><?=gettext("WPA"); ?></option>
3143
									<option <?php if ($pconfig['wpa_mode'] == '2') echo "selected=\"selected\"";?> value="2"><?=gettext("WPA2"); ?></option>
3144
									<option <?php if ($pconfig['wpa_mode'] == '3') echo "selected=\"selected\"";?> value="3"><?=gettext("Both"); ?></option>
3145 30ade846 gnhb
								</select>
3146 9978e156 gnhb
							</td>
3147
						</tr>
3148
						<tr>
3149 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("WPA Key Management Mode"); ?></td>
3150 c0948c6c Renato Botelho
							<td class="vtable">
3151 30ade846 gnhb
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
3152 339d2743 Colin Fleming
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected=\"selected\"";?> value="WPA-PSK"><?=gettext("Pre-Shared Key"); ?></option>
3153
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected=\"selected\"";?> value="WPA-EAP"><?=gettext("Extensible Authentication Protocol"); ?></option>
3154
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected=\"selected\"";?> value="WPA-PSK WPA-EAP"><?=gettext("Both"); ?></option>
3155 30ade846 gnhb
								</select>
3156 9978e156 gnhb
							</td>
3157
						</tr>
3158
						<tr>
3159 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
3160 30ade846 gnhb
							<td class="vtable">
3161
								<select name="auth_algs" class="formselect" id="auth_algs">
3162 339d2743 Colin Fleming
									<option <?php if ($pconfig['auth_algs'] == '1') echo "selected=\"selected\"";?> value="1"><?=gettext("Open System Authentication"); ?></option>
3163
									<option <?php if ($pconfig['auth_algs'] == '2') echo "selected=\"selected\"";?> value="2"><?=gettext("Shared Key Authentication"); ?></option>
3164
									<option <?php if ($pconfig['auth_algs'] == '3') echo "selected=\"selected\"";?> value="3"><?=gettext("Both"); ?></option>
3165 9978e156 gnhb
								</select>
3166 8cd558b6 ayvis
								<br /><?=gettext("Note: Shared Key Authentication requires WEP."); ?><br />
3167 9978e156 gnhb
							</td>
3168
						</tr>
3169
						<tr>
3170 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("WPA Pairwise"); ?></td>
3171 30ade846 gnhb
							<td class="vtable">
3172
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
3173 339d2743 Colin Fleming
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected=\"selected\"";?> value="CCMP TKIP"><?=gettext("Both"); ?></option>
3174
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected=\"selected\"";?> value="CCMP"><?=gettext("AES (recommended)"); ?></option>
3175
									<option <?php if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected=\"selected\"";?> value="TKIP"><?=gettext("TKIP"); ?></option>
3176 30ade846 gnhb
								</select>
3177 9978e156 gnhb
							</td>
3178
						</tr>
3179
						<tr>
3180 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Key Rotation"); ?></td>
3181 30ade846 gnhb
							<td class="vtable">
3182 2cbe4b47 Colin Fleming
								<input name="wpa_group_rekey" type="text" class="formfld unknown" id="wpa_group_rekey" size="30" value="<?php echo $pconfig['wpa_group_rekey'] ? $pconfig['wpa_group_rekey'] : "60";?>" />
3183 8cd558b6 ayvis
								<br /><?=gettext("Allowed values are 1-9999 but should not be longer than Master Key Regeneration time."); ?>
3184 9978e156 gnhb
							</td>
3185
						</tr>
3186
						<tr>
3187 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Master Key Regeneration"); ?></td>
3188 30ade846 gnhb
							<td class="vtable">
3189 2cbe4b47 Colin Fleming
								<input name="wpa_gmk_rekey" type="text" class="formfld" id="wpa_gmk_rekey" size="30" value="<?php echo $pconfig['wpa_gmk_rekey'] ? $pconfig['wpa_gmk_rekey'] : "3600";?>" />
3190 8cd558b6 ayvis
								<br /><?=gettext("Allowed values are 1-9999 but should not be shorter than Key Rotation time."); ?>
3191 9978e156 gnhb
							</td>
3192
						</tr>
3193
						<tr>
3194 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Strict Key Regeneration"); ?></td>
3195 30ade846 gnhb
							<td class="vtable">
3196 339d2743 Colin Fleming
								<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <?php if ($pconfig['wpa_strict_rekey']) echo "checked=\"checked\""; ?> />
3197 8cd558b6 ayvis
								<br /><?=gettext("Setting this option will force the AP to rekey whenever a client disassociates."); ?>
3198 30ade846 gnhb
							</td>
3199 9978e156 gnhb
						</tr>
3200
						<tr>
3201 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Enable IEEE802.1X Authentication"); ?></td>
3202 30ade846 gnhb
							<td class="vtable">
3203 339d2743 Colin Fleming
								<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <?php if ($pconfig['ieee8021x']) echo "checked=\"checked\"";?> />
3204 8cd558b6 ayvis
								<br /><?=gettext("Setting this option will enable 802.1x authentication."); ?>
3205
								<br /><span class="red"><strong><?=gettext("NOTE"); ?>:</strong></span> <?=gettext("this option requires checking the \"Enable WPA box\"."); ?>
3206 9978e156 gnhb
							</td>
3207
						</tr>
3208
						<tr>
3209 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server IP Address"); ?></td>
3210 30ade846 gnhb
							<td class="vtable">
3211 2cbe4b47 Colin Fleming
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>" />
3212 8cd558b6 ayvis
								<br /><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
3213 9978e156 gnhb
							</td>
3214
						</tr>
3215
						<tr>
3216 933ea015 Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Port"); ?></td>
3217 30ade846 gnhb
							<td class="vtable">
3218 2cbe4b47 Colin Fleming
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>" />
3219 8cd558b6 ayvis
								<br /><?=gettext("Leave blank for the default 1812 port."); ?>
3220 9978e156 gnhb
							</td>
3221
						</tr>
3222
						<tr>
3223 933ea015 Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Shared Secret"); ?></td>
3224 30ade846 gnhb
							<td class="vtable">
3225 2cbe4b47 Colin Fleming
								<input name="auth_server_shared_secret" id="auth_server_shared_secret" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_shared_secret']);?>" />
3226 8cd558b6 ayvis
								<br />
3227 9978e156 gnhb
							</td>
3228 30ade846 gnhb
						</tr>
3229 32764288 Namezero
						<tr>
3230
					<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server IP Address"); ?></td>
3231
							<td class="vtable">
3232 2cbe4b47 Colin Fleming
								<input name="auth_server_addr2" id="auth_server_addr2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr2']);?>" />
3233 8cd558b6 ayvis
								<br /><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
3234 32764288 Namezero
							</td>
3235
						</tr>
3236
						<tr>
3237
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Port"); ?></td>
3238
							<td class="vtable">
3239 2cbe4b47 Colin Fleming
								<input name="auth_server_port2" id="auth_server_port2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port2']);?>" />
3240 8cd558b6 ayvis
								<br /><?=gettext("Leave blank for the default 1812 port."); ?>
3241 32764288 Namezero
							</td>
3242
						</tr>
3243
						<tr>
3244
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Shared Secret"); ?></td>
3245
							<td class="vtable">
3246 2cbe4b47 Colin Fleming
								<input name="auth_server_shared_secret2" id="auth_server_shared_secret2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_shared_secret2']);?>" />
3247 8cd558b6 ayvis
								<br />
3248 32764288 Namezero
							</td>
3249
						</tr>
3250 c9e7d30d Scott Ullrich
						<tr>
3251
							<td valign="top" class="vncell">802.1X <?=gettext("Authentication Roaming Preauth"); ?></td>
3252
							<td class="vtable">
3253 339d2743 Colin Fleming
								<input name="rsn_preauth" id="rsn_preauth" type="checkbox" class="formfld unknown" size="66" value="yes" <?php if ($pconfig['rsn_preauth']) echo "checked=\"checked\""; ?> />
3254 8cd558b6 ayvis
								<br />
3255 c9e7d30d Scott Ullrich
							</td>
3256
						</tr>
3257 30ade846 gnhb
						<tr>
3258
							<td colspan="2" valign="top" height="16"></td>
3259
						</tr>
3260 a236affe N0YB
						<?php endif; ?>
3261 30ade846 gnhb
						<tr>
3262 136c598d Carlos Eduardo Ramos
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Private networks"); ?></td>
3263 30ade846 gnhb
						</tr>
3264
						<tr>
3265
							<td valign="middle" class="vncell">&nbsp;</td>
3266
							<td class="vtable">
3267 c0948c6c Renato Botelho
								<a name="rfc1918"></a>
3268 339d2743 Colin Fleming
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked=\"checked\""; ?> />
3269 8cd558b6 ayvis
								<strong><?=gettext("Block private networks"); ?></strong><br />
3270 136c598d Carlos Eduardo Ramos
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
3271
								"for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as"); ?>
3272 933ea015 Carlos Eduardo Ramos
								<?=gettext("well as loopback addresses (127/8)."); ?>&nbsp;&nbsp; <?=gettext("You should generally " .
3273 136c598d Carlos Eduardo Ramos
								"leave this option turned on, unless your WAN network lies in such " .
3274 c0948c6c Renato Botelho
								"a private address space, too."); ?>
3275 9978e156 gnhb
							</td>
3276
						</tr>
3277
						<tr>
3278 30ade846 gnhb
							<td valign="middle" class="vncell">&nbsp;</td>
3279 c0948c6c Renato Botelho
							<td class="vtable">
3280 339d2743 Colin Fleming
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked=\"checked\""; ?> />
3281 8cd558b6 ayvis
								<strong><?=gettext("Block bogon networks"); ?></strong><br />
3282 136c598d Carlos Eduardo Ramos
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
3283 933ea015 Carlos Eduardo Ramos
								"(but not RFC 1918) or not yet assigned by IANA."); ?>&nbsp;&nbsp;
3284 136c598d Carlos Eduardo Ramos
								<?=gettext("Bogons are prefixes that should never appear in the Internet routing table, " .
3285 933ea015 Carlos Eduardo Ramos
								"and obviously should not appear as the source address in any packets you receive."); ?>
3286 8cd558b6 ayvis
								<br /><br />
3287 6b4480dc bcyrill
								<?=gettext("Note: The update frequency can be changed under System->Advanced Firewall/NAT settings.")?>
3288 30ade846 gnhb
							</td>
3289 9978e156 gnhb
						</tr>
3290 1600b1af Scott Ullrich
					</table> <!-- End "allcfg" table -->
3291
					</div> <!-- End "allcfg" div -->
3292
3293 168549b9 Colin Fleming
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="buttons">
3294 9978e156 gnhb
						<tr>
3295 7b8db0c3 Erik Fonnesbeck
							<td width="22%" valign="top">
3296 30ade846 gnhb
								&nbsp;
3297
							</td>
3298 7b8db0c3 Erik Fonnesbeck
							<td width="78%">
3299 8cd558b6 ayvis
								<br />
3300 2cbe4b47 Colin Fleming
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
3301 c4372d3c Renato Botelho
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
3302 e41ec584 Renato Botelho
								<input name="if" type="hidden" id="if" value="<?=htmlspecialchars($if);?>" />
3303 1d7e1d6c gnhb
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
3304 2cbe4b47 Colin Fleming
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>" />
3305 30ade846 gnhb
								<?php endif; ?>
3306 2cbe4b47 Colin Fleming
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>" />
3307 9978e156 gnhb
							</td>
3308
						</tr>
3309 1600b1af Scott Ullrich
					</table>
3310 168549b9 Colin Fleming
					</div>
3311 9978e156 gnhb
				</td>
3312
			</tr>
3313
		</table>
3314
	</form>
3315 30ade846 gnhb
	<script type="text/javascript">
3316 32b91bcf Colin Fleming
	//<![CDATA[
3317 30ade846 gnhb
		var gatewayip;
3318
		var name;
3319 cfd40454 Seth Mos
		var gatewayipv6;
3320
		var namev6;
3321 30ade846 gnhb
		function show_add_gateway() {
3322
			document.getElementById("addgateway").style.display = '';
3323
			document.getElementById("addgwbox").style.display = 'none';
3324
			document.getElementById("gateway").style.display = 'none';
3325
			document.getElementById("save").style.display = 'none';
3326
			document.getElementById("cancel").style.display = 'none';
3327
			document.getElementById("gwsave").style.display = '';
3328
			document.getElementById("gwcancel").style.display = '';
3329 076b14b2 Vinicius Coque
			jQuery('#notebox').html("");
3330 30ade846 gnhb
		}
3331 cfd40454 Seth Mos
		function show_add_gateway_v6() {
3332
			document.getElementById("addgatewayv6").style.display = '';
3333
			document.getElementById("addgwboxv6").style.display = 'none';
3334
			document.getElementById("gatewayv6").style.display = 'none';
3335
			document.getElementById("save").style.display = 'none';
3336
			document.getElementById("cancel").style.display = 'none';
3337
			document.getElementById("gwsave").style.display = '';
3338
			document.getElementById("gwcancel").style.display = '';
3339 076b14b2 Vinicius Coque
			jQuery('#noteboxv6').html("");
3340 cfd40454 Seth Mos
		}
3341 30ade846 gnhb
		function hide_add_gateway() {
3342
			document.getElementById("addgateway").style.display = 'none';
3343 c0948c6c Renato Botelho
			document.getElementById("addgwbox").style.display = '';
3344 30ade846 gnhb
			document.getElementById("gateway").style.display = '';
3345
			document.getElementById("save").style.display = '';
3346
			document.getElementById("cancel").style.display = '';
3347
			document.getElementById("gwsave").style.display = '';
3348
			document.getElementById("gwcancel").style.display = '';
3349 56756d31 Renato Botelho
			jQuery('#status').html('');
3350 30ade846 gnhb
		}
3351 cfd40454 Seth Mos
		function hide_add_gateway_v6() {
3352
			document.getElementById("addgatewayv6").style.display = 'none';
3353
			document.getElementById("addgwboxv6").style.display = '';
3354
			document.getElementById("gatewayv6").style.display = '';
3355
			document.getElementById("save").style.display = '';
3356
			document.getElementById("cancel").style.display = '';
3357
			document.getElementById("gwsave").style.display = '';
3358
			document.getElementById("gwcancel").style.display = '';
3359 56756d31 Renato Botelho
			jQuery('#statusv6').html('');
3360 cfd40454 Seth Mos
		}
3361 30ade846 gnhb
		function hide_add_gatewaysave() {
3362
			document.getElementById("addgateway").style.display = 'none';
3363 7bc1b968 Renato Botelho
			jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
3364 076b14b2 Vinicius Coque
			var iface = jQuery('#if').val();
3365
			name = jQuery('#name').val();
3366
			var descr = jQuery('#gatewaydescr').val();
3367
			gatewayip = jQuery('#gatewayip').val();
3368 32764288 Namezero
3369 93ee6032 Renato Botelho
			var defaultgw = '';
3370
			if (jQuery('#defaultgw').is(':checked'))
3371
				defaultgw = '&defaultgw=on';
3372 30ade846 gnhb
			var url = "system_gateways_edit.php";
3373 93ee6032 Renato Botelho
			var pars = 'isAjax=true&ipprotocol=inet' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3374 076b14b2 Vinicius Coque
			jQuery.ajax(
3375 30ade846 gnhb
				url,
3376
				{
3377 076b14b2 Vinicius Coque
					type: 'post',
3378
					data: pars,
3379
					error: report_failure,
3380 56756d31 Renato Botelho
					success: save_callback
3381 c0948c6c Renato Botelho
				});
3382 30ade846 gnhb
		}
3383 cfd40454 Seth Mos
		function hide_add_gatewaysave_v6() {
3384
			document.getElementById("addgatewayv6").style.display = 'none';
3385 7bc1b968 Renato Botelho
			jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
3386 076b14b2 Vinicius Coque
			var iface = jQuery('#if').val();
3387
			name = jQuery('#namev6').val();
3388
			var descr = jQuery('#gatewaydescrv6').val();
3389
			gatewayip = jQuery('#gatewayipv6').val();
3390 93ee6032 Renato Botelho
			var defaultgw = '';
3391
			if (jQuery('#defaultgwv6').is(':checked'))
3392
				defaultgw = '&defaultgw=on';
3393 cfd40454 Seth Mos
			var url_v6 = "system_gateways_edit.php";
3394 93ee6032 Renato Botelho
			var pars_v6 = 'isAjax=true&ipprotocol=inet6' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3395 076b14b2 Vinicius Coque
			jQuery.ajax(
3396 cfd40454 Seth Mos
				url_v6,
3397
				{
3398 076b14b2 Vinicius Coque
					type: 'post',
3399
					data: pars_v6,
3400
					error: report_failure_v6,
3401 56756d31 Renato Botelho
					success: save_callback_v6
3402 cfd40454 Seth Mos
				});
3403
		}
3404 30ade846 gnhb
		function addOption(selectbox,text,value)
3405
		{
3406
			var optn = document.createElement("OPTION");
3407
			optn.text = text;
3408
			optn.value = value;
3409 076b14b2 Vinicius Coque
			selectbox.append(optn);
3410
			selectbox.prop('selectedIndex',selectbox.children().length-1);
3411 168549b9 Colin Fleming
			jQuery('#notebox').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3412 c0948c6c Renato Botelho
		}
3413 cfd40454 Seth Mos
		function addOption_v6(selectbox,text,value)
3414
		{
3415
			var optn = document.createElement("OPTION");
3416
			optn.text = text;
3417
			optn.value = value;
3418 076b14b2 Vinicius Coque
			selectbox.append(optn);
3419
			selectbox.prop('selectedIndex',selectbox.children().length-1);
3420 168549b9 Colin Fleming
			jQuery('#noteboxv6').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3421 cfd40454 Seth Mos
		}
3422 a0edece9 Darren Embry
		function report_failure(request, textStatus, errorThrown) {
3423
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3424
				alert(request.responseText);
3425
			} else {
3426
				alert("Sorry, we could not create your IPv4 gateway at this time.");
3427
			}
3428 30ade846 gnhb
			hide_add_gateway();
3429
		}
3430 a0edece9 Darren Embry
		function report_failure_v6(request, textStatus, errorThrown) {
3431
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3432
				alert(request.responseText);
3433
			} else {
3434
				alert("Sorry, we could not create your IPv6 gateway at this time.");
3435
			}
3436 cfd40454 Seth Mos
			hide_add_gateway_v6();
3437
		}
3438 6e704f19 Renato Botelho
		function save_callback(response) {
3439 30ade846 gnhb
			if(response) {
3440
				document.getElementById("addgateway").style.display = 'none';
3441
				hide_add_gateway();
3442 cfd40454 Seth Mos
				var gwtext = escape(name) + " - " + gatewayip;
3443 076b14b2 Vinicius Coque
				addOption(jQuery('#gateway'), gwtext, name);
3444 30ade846 gnhb
				// Auto submit form?
3445
				//document.iform.submit();
3446 7bc1b968 Renato Botelho
				//jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader /">');
3447 30ade846 gnhb
			} else {
3448
				report_failure();
3449
			}
3450
		}
3451 6e2a15e6 Evgeny Yurchenko
		function show_advanced_media() {
3452
			document.getElementById("showadvmediabox").innerHTML='';
3453
			aodiv = document.getElementById('showmediaadv');
3454
			aodiv.style.display = "block";
3455
		}
3456 6e704f19 Renato Botelho
		function save_callback_v6(response_v6) {
3457 cfd40454 Seth Mos
			if(response_v6) {
3458
				document.getElementById("addgatewayv6").style.display = 'none';
3459
				hide_add_gateway_v6();
3460
				var gwtext_v6 = escape(name) + " - " + gatewayip;
3461 076b14b2 Vinicius Coque
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
3462 cfd40454 Seth Mos
				// Auto submit form?
3463
				//document.iform.submit();
3464 7bc1b968 Renato Botelho
				//jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" />');
3465 cfd40454 Seth Mos
			} else {
3466
				report_failure_v6();
3467
			}
3468
		}
3469 30ade846 gnhb
		<?php
3470 8672329c Erik Fonnesbeck
		echo "show_allcfg(document.iform.enable);";
3471 30ade846 gnhb
		echo "updateType('{$pconfig['type']}');\n";
3472 e029943a Seth Mos
		echo "updateTypeSix('{$pconfig['type6']}');\n";
3473 6c05cfb0 gnhb
		?>
3474 32b91bcf Colin Fleming
	//]]>
3475 30ade846 gnhb
	</script>
3476
	<?php include("fend.inc"); ?>
3477
	</body>
3478 b09a92b7 Ermal Luçi
</html>