Project

General

Profile

Download (181 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces.php
5
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
6
	Copyright (C) 2004-2008 Scott Ullrich
7
	Copyright (C) 2006 Daniel S. Haischt.
8
	Copyright (C) 2008-2010 Ermal Luçi
9
	All rights reserved.
10

    
11
	originally part of m0n0wall (http://m0n0.ch/wall)
12
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
13
	All rights reserved.
14

    
15
	Redistribution and use in source and binary forms, with or without
16
	modification, are permitted provided that the following conditions are met:
17

    
18
	1. Redistributions of source code must retain the above copyright notice,
19
	   this list of conditions and the following disclaimer.
20

    
21
	2. Redistributions in binary form must reproduce the above copyright
22
	   notice, this list of conditions and the following disclaimer in the
23
	   documentation and/or other materials provided with the distribution.
24

    
25
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
26
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
29
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
	POSSIBILITY OF SUCH DAMAGE.
35
*/
36
/*
37
	pfSense_BUILDER_BINARIES:	/usr/sbin/arp
38
	pfSense_MODULE:	interfaces
39
*/
40

    
41
##|+PRIV
42
##|*IDENT=page-interfaces
43
##|*NAME=Interfaces: WAN page
44
##|*DESCR=Allow access to the 'Interfaces' page.
45
##|*MATCH=interfaces.php*
46
##|-PRIV
47

    
48
require_once("guiconfig.inc");
49
require_once("ipsec.inc");
50
require_once("functions.inc");
51
require_once("captiveportal.inc");
52
require_once("filter.inc");
53
require_once("shaper.inc");
54
require_once("rrd.inc");
55
require_once("vpn.inc");
56
require_once("xmlparse_attr.inc");
57

    
58
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces.php');
59

    
60
// Get configured interface list
61
$ifdescrs = get_configured_interface_with_descr(false, true);
62

    
63
$if = "wan";
64
if ($_REQUEST['if'])
65
	$if = $_REQUEST['if'];
66

    
67
if (empty($ifdescrs[$if])) {
68
	header("Location: interfaces.php");
69
	exit;
70
}
71

    
72
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
73
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
74
define("CRON_DAILY_PATTERN", "0 0 * * *");
75
define("CRON_HOURLY_PATTERN", "0 * * * *");
76

    
77
if (!is_array($pconfig))
78
	$pconfig = array();
79

    
80
if (!is_array($config['ppps']))
81
	$config['ppps'] = array();
82
if (!is_array($config['ppps']['ppp']))
83
	$config['ppps']['ppp'] = array();
84
$a_ppps = &$config['ppps']['ppp'];
85

    
86
function remove_bad_chars($string) {
87
	return preg_replace('/[^a-z_0-9]/i','',$string);
88
}
89

    
90
if (!is_array($config['gateways']['gateway_item']))
91
	$config['gateways']['gateway_item'] = array();
92
$a_gateways = &$config['gateways']['gateway_item'];
93

    
94
$wancfg = &$config['interfaces'][$if];
95
$old_wancfg = $wancfg;
96
$old_wancfg['realif'] = get_real_interface($if);
97
$old_ppps = $a_ppps;
98
// Populate page descr if it does not exist.
99
if ($if == "wan" && !$wancfg['descr'])
100
	$wancfg['descr'] = "WAN";
101
else if ($if == "lan" && !$wancfg['descr'])
102
	$wancfg['descr'] = "LAN";
103

    
104
/* NOTE: The code here is used to set the $pppid for the curious */
105
foreach ($a_ppps as $pppid => $ppp) {
106
	if ($wancfg['if'] == $ppp['if'])
107
		break;
108
}
109

    
110
$type_disabled = (substr($wancfg['if'], 0, 3) == 'gre') ? 'disabled="disabled"' : '';
111

    
112
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
113
	$pconfig['pppid'] = $pppid;
114
	$pconfig['ptpid'] = $a_ppps[$pppid]['ptpid'];
115
	$pconfig['port'] = $a_ppps[$pppid]['ports'];
116
	if ($a_ppps[$pppid]['type'] == "ppp") {
117
		$pconfig['ppp_username'] = $a_ppps[$pppid]['username'];
118
		$pconfig['ppp_password'] = base64_decode($a_ppps[$pppid]['password']);
119

    
120
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
121
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
122
	}
123
	else if ($a_ppps[$pppid]['type'] == "pppoe") {
124
		$pconfig['pppoe_username'] = $a_ppps[$pppid]['username'];
125
		$pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']);
126
		$pconfig['provider'] = $a_ppps[$pppid]['provider'];
127
		$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
128
		$pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout'];
129

    
130
		/* ================================================ */
131
		/* = force a connection reset at a specific time? = */
132
		/* ================================================ */
133

    
134
		if (isset($a_ppps[$pppid]['pppoe-reset-type'])) {
135
			$pconfig['pppoe-reset-type'] = $a_ppps[$pppid]['pppoe-reset-type'];
136
			$itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']);
137
			if ($itemhash)
138
				$cronitem = $itemhash['ITEM'];
139
			if (isset($cronitem)) {
140
				$resetTime = "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
141
			} else {
142
				$resetTime = NULL;
143
			}
144
			//log_error("ResetTime:".$resetTime);
145
			if ($a_ppps[$pppid]['pppoe-reset-type'] == "custom") {
146
				if ($cronitem) {
147
					$pconfig['pppoe_pr_custom'] = true;
148
					$pconfig['pppoe_resetminute'] = $cronitem['minute'];
149
					$pconfig['pppoe_resethour'] = $cronitem['hour'];
150
					if ($cronitem['mday'] <> "*" && $cronitem['month'] <> "*")
151
						$pconfig['pppoe_resetdate'] = "{$cronitem['month']}/{$cronitem['mday']}/" . date("Y");
152
				}
153
			} else if ($a_ppps[$pppid]['pppoe-reset-type'] == "preset") {
154
				$pconfig['pppoe_pr_preset'] = true;
155
				switch ($resetTime) {
156
					case CRON_MONTHLY_PATTERN:
157
						$pconfig['pppoe_monthly'] = true;
158
						break;
159
					case CRON_WEEKLY_PATTERN:
160
						$pconfig['pppoe_weekly'] = true;
161
						break;
162
					case CRON_DAILY_PATTERN:
163
						$pconfig['pppoe_daily'] = true;
164
						break;
165
					case CRON_HOURLY_PATTERN:
166
						$pconfig['pppoe_hourly'] = true;
167
						break;
168
				}
169
			}
170
		}// End force pppoe reset at specific time
171
	}// End if type == pppoe
172
	else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp"){
173
		$pconfig['pptp_username'] = $a_ppps[$pppid]['username'];
174
		$pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']);
175
		$pconfig['pptp_local'] = explode(",",$a_ppps[$pppid]['localip']);
176
		$pconfig['pptp_subnet'] = explode(",",$a_ppps[$pppid]['subnet']);
177
		$pconfig['pptp_remote'] = explode(",",$a_ppps[$pppid]['gateway']);
178
		$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
179
		$pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout'];
180
	}
181
} else {
182
	$pconfig['ptpid'] = interfaces_ptpid_next();
183
	$pppid = count($a_ppps);
184
}
185
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
186
$pconfig['alias-address'] = $wancfg['alias-address'];
187
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
188
$pconfig['dhcprejectfrom'] = $wancfg['dhcprejectfrom'];
189

    
190
$pconfig['adv_dhcp_pt_timeout'] = $wancfg['adv_dhcp_pt_timeout'];
191
$pconfig['adv_dhcp_pt_retry'] = $wancfg['adv_dhcp_pt_retry'];
192
$pconfig['adv_dhcp_pt_select_timeout'] = $wancfg['adv_dhcp_pt_select_timeout'];
193
$pconfig['adv_dhcp_pt_reboot'] = $wancfg['adv_dhcp_pt_reboot'];
194
$pconfig['adv_dhcp_pt_backoff_cutoff'] = $wancfg['adv_dhcp_pt_backoff_cutoff'];
195
$pconfig['adv_dhcp_pt_initial_interval'] = $wancfg['adv_dhcp_pt_initial_interval'];
196

    
197
$pconfig['adv_dhcp_pt_values'] = $wancfg['adv_dhcp_pt_values'];
198

    
199
$pconfig['adv_dhcp_send_options'] = $wancfg['adv_dhcp_send_options'];
200
$pconfig['adv_dhcp_request_options'] = $wancfg['adv_dhcp_request_options'];
201
$pconfig['adv_dhcp_required_options'] = $wancfg['adv_dhcp_required_options'];
202
$pconfig['adv_dhcp_option_modifiers'] = $wancfg['adv_dhcp_option_modifiers'];
203

    
204
$pconfig['adv_dhcp_config_advanced'] = $wancfg['adv_dhcp_config_advanced'];
205
$pconfig['adv_dhcp_config_file_override'] = $wancfg['adv_dhcp_config_file_override'];
206
$pconfig['adv_dhcp_config_file_override_path'] = $wancfg['adv_dhcp_config_file_override_path'];
207

    
208
$pconfig['adv_dhcp6_interface_statement_send_options'] = $wancfg['adv_dhcp6_interface_statement_send_options'];
209
$pconfig['adv_dhcp6_interface_statement_request_options'] = $wancfg['adv_dhcp6_interface_statement_request_options'];
210
$pconfig['adv_dhcp6_interface_statement_information_only_enable'] = $wancfg['adv_dhcp6_interface_statement_information_only_enable'];
211
$pconfig['adv_dhcp6_interface_statement_script'] = $wancfg['adv_dhcp6_interface_statement_script'];
212

    
213
$pconfig['adv_dhcp6_id_assoc_statement_address_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_address_enable'];
214
$pconfig['adv_dhcp6_id_assoc_statement_address'] = $wancfg['adv_dhcp6_id_assoc_statement_address'];
215
$pconfig['adv_dhcp6_id_assoc_statement_address_id'] = $wancfg['adv_dhcp6_id_assoc_statement_address_id'];
216
$pconfig['adv_dhcp6_id_assoc_statement_address_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_pltime'];
217
$pconfig['adv_dhcp6_id_assoc_statement_address_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_vltime'];
218

    
219
$pconfig['adv_dhcp6_id_assoc_statement_prefix_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'];
220
$pconfig['adv_dhcp6_id_assoc_statement_prefix'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix'];
221
$pconfig['adv_dhcp6_id_assoc_statement_prefix_id'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_id'];
222
$pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'];
223
$pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'];
224

    
225
$pconfig['adv_dhcp6_prefix_interface_statement_sla_id'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_id'];
226
$pconfig['adv_dhcp6_prefix_interface_statement_sla_len'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_len'];
227

    
228
$pconfig['adv_dhcp6_authentication_statement_authname'] = $wancfg['adv_dhcp6_authentication_statement_authname'];
229
$pconfig['adv_dhcp6_authentication_statement_protocol'] = $wancfg['adv_dhcp6_authentication_statement_protocol'];
230
$pconfig['adv_dhcp6_authentication_statement_algorithm'] = $wancfg['adv_dhcp6_authentication_statement_algorithm'];
231
$pconfig['adv_dhcp6_authentication_statement_rdm'] = $wancfg['adv_dhcp6_authentication_statement_rdm'];
232

    
233
$pconfig['adv_dhcp6_key_info_statement_keyname'] = $wancfg['adv_dhcp6_key_info_statement_keyname'];
234
$pconfig['adv_dhcp6_key_info_statement_realm'] = $wancfg['adv_dhcp6_key_info_statement_realm'];
235
$pconfig['adv_dhcp6_key_info_statement_keyid'] = $wancfg['adv_dhcp6_key_info_statement_keyid'];
236
$pconfig['adv_dhcp6_key_info_statement_secret'] = $wancfg['adv_dhcp6_key_info_statement_secret'];
237
$pconfig['adv_dhcp6_key_info_statement_expire'] = $wancfg['adv_dhcp6_key_info_statement_expire'];
238

    
239
$pconfig['adv_dhcp6_config_advanced'] = $wancfg['adv_dhcp6_config_advanced'];
240
$pconfig['adv_dhcp6_config_file_override'] = $wancfg['adv_dhcp6_config_file_override'];
241
$pconfig['adv_dhcp6_config_file_override_path'] = $wancfg['adv_dhcp6_config_file_override_path'];
242

    
243
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
244
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
245
$pconfig['enable'] = isset($wancfg['enable']);
246

    
247
if (is_array($config['aliases']['alias'])) {
248
	foreach($config['aliases']['alias'] as $alias) {
249
		if($alias['name'] == $wancfg['descr']) {
250
			$input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."),$wancfg['descr']);
251
		}
252
	}
253
}
254

    
255
switch($wancfg['ipaddr']) {
256
	case "dhcp":
257
		$pconfig['type'] = "dhcp";
258
		break;
259
	case "pppoe":
260
	case "pptp":
261
	case "l2tp":
262
	case "ppp":
263
		$pconfig['type'] = $wancfg['ipaddr'];
264
		break;
265
	default:
266
		if(is_ipaddrv4($wancfg['ipaddr'])) {
267
			$pconfig['type'] = "staticv4";
268
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
269
			$pconfig['subnet'] = $wancfg['subnet'];
270
			$pconfig['gateway'] = $wancfg['gateway'];
271
		} else
272
			$pconfig['type'] = "none";
273
		break;
274
}
275

    
276
switch($wancfg['ipaddrv6']) {
277
	case "slaac":
278
		$pconfig['type6'] = "slaac";
279
		break;
280
	case "dhcp6":
281
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
282
		if(!isset($wancfg['dhcp6-ia-pd-len']))
283
			$wancfg['dhcp6-ia-pd-len'] = "none";
284
		$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
285
		$pconfig['dhcp6-ia-pd-send-hint'] = isset($wancfg['dhcp6-ia-pd-send-hint']);
286
		$pconfig['type6'] = "dhcp6";
287
		$pconfig['dhcp6prefixonly'] = isset($wancfg['dhcp6prefixonly']);
288
		$pconfig['dhcp6usev4iface'] = isset($wancfg['dhcp6usev4iface']);
289
		break;
290
	case "6to4":
291
		$pconfig['type6'] = "6to4";
292
		break;
293
	case "track6":
294
		$pconfig['type6'] = "track6";
295
		$pconfig['track6-interface'] = $wancfg['track6-interface'];
296
		if ($wancfg['track6-prefix-id'] == "")
297
			$pconfig['track6-prefix-id'] = 0;
298
		else
299
			$pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
300
		$pconfig['track6-prefix-id--hex'] = sprintf("%x", $pconfig['track6-prefix-id']);
301
		break;
302
	case "6rd":
303
		$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
304
		if($wancfg['prefix-6rd-v4plen'] == "")
305
			$wancfg['prefix-6rd-v4plen'] = "0";
306
		$pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen'];
307
		$pconfig['type6'] = "6rd";
308
		$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
309
		break;
310
	default:
311
		if(is_ipaddrv6($wancfg['ipaddrv6'])) {
312
			$pconfig['type6'] = "staticv6";
313
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
314
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
315
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
316
		} else
317
			$pconfig['type6'] = "none";
318
		break;
319
}
320

    
321
// print_r($pconfig);
322

    
323
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
324
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
325
$pconfig['spoofmac'] = $wancfg['spoofmac'];
326
$pconfig['mtu'] = $wancfg['mtu'];
327
$pconfig['mss'] = $wancfg['mss'];
328

    
329
/* Wireless interface? */
330
if (isset($wancfg['wireless'])) {
331
	/* Sync first to be sure it displays the actual settings that will be used */
332
	interface_sync_wireless_clones($wancfg, false);
333
	/* Get wireless modes */
334
	$wlanif = get_real_interface($if);
335
	if (!does_interface_exist($wlanif))
336
		interface_wireless_clone($wlanif, $wancfg);
337
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
338
	preg_match("/^(.*?)([0-9]*)$/", $wlanbaseif, $wlanbaseif_split);
339
	$wl_modes = get_wireless_modes($if);
340
	$wl_chaninfo = get_wireless_channel_info($if);
341
	$wl_sysctl_prefix = 'dev.' . $wlanbaseif_split[1] . '.' . $wlanbaseif_split[2];
342
	$wl_sysctl = get_sysctl(array("{$wl_sysctl_prefix}.diversity", "{$wl_sysctl_prefix}.txantenna", "{$wl_sysctl_prefix}.rxantenna",
343
				      "{$wl_sysctl_prefix}.slottime", "{$wl_sysctl_prefix}.acktimeout", "{$wl_sysctl_prefix}.ctstimeout"));
344
	$wl_regdomain_xml_attr = array();
345
	$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
346
	$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
347
	$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
348
	$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
349
	$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
350
	$pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]);
351
	$pconfig['standard'] = $wancfg['wireless']['standard'];
352
	$pconfig['mode'] = $wancfg['wireless']['mode'];
353
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
354
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
355
	$pconfig['channel'] = $wancfg['wireless']['channel'];
356
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
357
	$pconfig['diversity'] = $wancfg['wireless']['diversity'];
358
	$pconfig['txantenna'] = $wancfg['wireless']['txantenna'];
359
	$pconfig['rxantenna'] = $wancfg['wireless']['rxantenna'];
360
	$pconfig['distance'] = $wancfg['wireless']['distance'];
361
	$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
362
	$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
363
	$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
364
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
365
	if (isset($wancfg['wireless']['puren']['enable']))
366
		$pconfig['puremode'] = '11n';
367
	else if (isset($wancfg['wireless']['pureg']['enable']))
368
		$pconfig['puremode'] = '11g';
369
	else
370
		$pconfig['puremode'] = 'any';
371
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
372
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
373
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
374
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
375
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
376
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
377
	$pconfig['auth_server_addr2'] = $wancfg['wireless']['auth_server_addr2'];
378
	$pconfig['auth_server_port2'] = $wancfg['wireless']['auth_server_port2'];
379
	$pconfig['auth_server_shared_secret2'] = $wancfg['wireless']['auth_server_shared_secret2'];
380
	if (is_array($wancfg['wireless']['wpa'])) {
381
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
382
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
383
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
384
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
385
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
386
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
387
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
388
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
389
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
390
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
391
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
392
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
393
		$pconfig['rsn_preauth'] = isset($wancfg['wireless']['wpa']['rsn_preauth']);
394
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
395
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
396
	}
397
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
398
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
399
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
400
		$i = 1;
401
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
402
			$pconfig['key' . $i] = $wepkey['value'];
403
			if (isset($wepkey['txkey']))
404
				$pconfig['txkey'] = $i;
405
			$i++;
406
		}
407
		if (!isset($wepkey['txkey']))
408
			$pconfig['txkey'] = 1;
409
	}
410
}
411

    
412
if ($_POST['apply']) {
413
	unset($input_errors);
414
	if (!is_subsystem_dirty('interfaces'))
415
		$input_errors[] = gettext("You have already applied your settings!");
416
	else {
417
		unlink_if_exists("{$g['tmp_path']}/config.cache");
418
		clear_subsystem_dirty('interfaces');
419

    
420
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
421
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
422
			foreach ($toapplylist as $ifapply => $ifcfgo) {
423
				if (isset($config['interfaces'][$ifapply]['enable'])) {
424
					interface_bring_down($ifapply, false, $ifcfgo);
425
					interface_configure($ifapply, true);
426
				} else {
427
					interface_bring_down($ifapply, true, $ifcfgo);
428
					if (isset($config['dhcpd'][$ifapply]['enable']) ||
429
					    isset($config['dhcpdv6'][$ifapply]['enable']))
430
						services_dhcpd_configure();
431
				}
432
			}
433
		}
434
		/* restart snmp so that it binds to correct address */
435
		services_snmpd_configure();
436

    
437
		/* sync filter configuration */
438
		setup_gateways_monitor();
439

    
440
		clear_subsystem_dirty('interfaces');
441

    
442
		filter_configure();
443

    
444
		enable_rrd_graphing();
445

    
446
		if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0))
447
			clear_subsystem_dirty('staticroutes');
448
	}
449
	@unlink("{$g['tmp_path']}/.interfaces.apply");
450
	header("Location: interfaces.php?if={$if}");
451
	exit;
452
} else if ($_POST && $_POST['enable'] != "yes") {
453
	unset($wancfg['enable']);
454
	if (isset($wancfg['wireless']))
455
		interface_sync_wireless_clones($wancfg, false);
456
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
457
	mark_subsystem_dirty('interfaces');
458
	if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
459
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
460
	} else {
461
		$toapplylist = array();
462
	}
463
	$toapplylist[$if]['ifcfg'] = $wancfg;
464
	$toapplylist[$if]['ppps'] = $a_ppps;
465
	/* we need to be able remove IP aliases for IPv6 */
466
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
467
	header("Location: interfaces.php?if={$if}");
468
	exit;
469
} else if ($_POST) {
470

    
471
	unset($input_errors);
472
	$pconfig = $_POST;
473

    
474
	if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
475
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
476
	else
477
		$pconfig['track6-prefix-id'] = 0;
478
	conf_mount_rw();
479

    
480
	/* filter out spaces from descriptions  */
481
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
482

    
483
	/* okay first of all, cause we are just hiding the PPPoE HTML
484
	 * fields releated to PPPoE resets, we are going to unset $_POST
485
	 * vars, if the reset feature should not be used. Otherwise the
486
	 * data validation procedure below, may trigger a false error
487
	 * message.
488
	 */
489
	if (empty($_POST['pppoe-reset-type'])) {
490
		unset($_POST['pppoe_pr_type']);
491
		unset($_POST['pppoe_resethour']);
492
		unset($_POST['pppoe_resetminute']);
493
		unset($_POST['pppoe_resetdate']);
494
		unset($_POST['pppoe_pr_preset_val']);
495
	}
496
	/* description unique? */
497
	foreach ($ifdescrs as $ifent => $ifdescr) {
498
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
499
			$input_errors[] = gettext("An interface with the specified description already exists.");
500
			break;
501
		}
502
	}
503
	if(is_numeric($_POST['descr'])) {
504
		$input_errors[] = gettext("The interface description cannot contain only numbers.");
505
	}
506
	/* input validation */
507
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^staticv4/", $_POST['type'])))
508
		$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.");
509
	if (isset($config['dhcpdv6']) && isset($config['dhcpdv6'][$if]['enable']) && (! preg_match("/^staticv6/", $_POST['type6'])))
510
		$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.");
511

    
512
	switch(strtolower($_POST['type'])) {
513
		case "staticv4":
514
			$reqdfields = explode(" ", "ipaddr subnet gateway");
515
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
516
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
517
			break;
518
		case "none":
519
			if(is_array($config['virtualip']['vip'])) {
520
				foreach ($config['virtualip']['vip'] as $vip) {
521
					if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if)
522
						$input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration.");
523
				}
524
			}
525
			break;
526
		case "ppp":
527
			$reqdfields = explode(" ", "port phone");
528
			$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
529
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
530
			break;
531
		case "pppoe":
532
			if ($_POST['pppoe_dialondemand']) {
533
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
534
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
535
			} else {
536
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
537
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
538
			}
539
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
540
			break;
541
		case "pptp":
542
			if ($_POST['pptp_dialondemand']) {
543
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
544
				$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"));
545
			} else {
546
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
547
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
548
			}
549
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
550
			break;
551
		case "l2tp":
552
			if ($_POST['pptp_dialondemand']) {
553
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
554
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
555
			} else {
556
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
557
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"));
558
			}
559
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
560
			break;
561
	}
562
	switch(strtolower($_POST['type6'])) {
563
		case "staticv6":
564
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
565
			$reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
566
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
567
			break;
568
		case "none":
569
			if(is_array($config['virtualip']['vip'])) {
570
				foreach ($config['virtualip']['vip'] as $vip) {
571
					if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if)
572
						$input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration.");
573
				}
574
			}
575
			break;
576
		case "dhcp6":
577
			if (in_array($wancfg['ipaddrv6'], array()))
578
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
579
			if ($_POST['dhcp6-ia-pd-send-hint'] && strtolower($_POST['dhcp6-ia-pd-len']) == 'none') {
580
				$input_errors[] = gettext('DHCPv6 Prefix Delegation size must be provided when Send IPv6 prefix hint flag is checked');
581
			}
582
			break;
583
		case "6rd":
584
			foreach ($ifdescrs as $ifent => $ifdescr) {
585
				if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
586
					if ($config[interfaces][$ifent]['prefix-6rd'] == $_POST['prefix-6rd']) {
587
						$input_errors[] = gettext("You can only have one interface configured in 6rd with same prefix.");
588
						break;
589
					}
590
				}
591
			}
592
			if (in_array($wancfg['ipaddrv6'], array()))
593
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
594
			break;
595
		case "6to4":
596
			foreach ($ifdescrs as $ifent => $ifdescr) {
597
				if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
598
					$input_errors[] = sprintf(gettext("You can only have one interface configured as 6to4."),$_POST['type6']);
599
					break;
600
				}
601
			}
602
			if (in_array($wancfg['ipaddrv6'], array()))
603
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
604
			break;
605
		case "track6":
606
			/* needs to check if $track6-prefix-id is used on another interface */
607
			if (in_array($wancfg['ipaddrv6'], array()))
608
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
609

    
610
			if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
611
				$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
612
			} else {
613
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
614
				if ($track6_prefix_id < 0 || $track6_prefix_id > $_POST['ipv6-num-prefix-ids-' . $_POST['track6-interface']]) {
615
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.") .
616
						" ({$_POST['track6-interface']}) - (0) - (" . sprintf('%x', $_POST['ipv6-num-prefix-ids-' . $_POST['track6-interface']]) . ")";
617
				} else {
618
					foreach ($ifdescrs as $ifent => $ifdescr) {
619
						if ($if == $ifent)
620
							continue;
621
						if ($config['interfaces'][$ifent]['ipaddrv6'] == 'track6' &&
622
						    $config['interfaces'][$ifent]['track6-interface'] == $_POST['track6-interface'] &&
623
						    $config['interfaces'][$ifent]['track6-prefix-id'] == $track6_prefix_id)
624
							$input_errors[] = sprintf(gettext("This track6 prefix ID is already being used in %s."), $ifdescr);
625
					}
626
				}
627
			}
628
			break;
629
	}
630

    
631

    
632
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
633
	$staticroutes = get_staticroutes(true);
634
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
635
	if ($_POST['ipaddr']) {
636
		if (!is_ipaddrv4($_POST['ipaddr']))
637
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
638
		else {
639
			$where_ipaddr_configured = where_is_ipaddr_configured($_POST['ipaddr'], $if, true, true, $_POST['subnet']);
640
			if (count($where_ipaddr_configured)) {
641
				$subnet_conflict_text = sprintf(gettext("IPv4 address %s is being used by or overlaps with:"), $_POST['ipaddr'] . "/" . $_POST['subnet']);
642
				foreach ($where_ipaddr_configured as $subnet_conflict) {
643
					$subnet_conflict_text .= " " . convert_friendly_interface_to_friendly_descr($subnet_conflict['if']) . " (" . $subnet_conflict['ip_or_subnet'] . ")";
644
				}
645
				$input_errors[] = $subnet_conflict_text;
646
			}
647

    
648
			/* Do not accept network or broadcast address, except if subnet is 31 or 32 */
649
			if ($_POST['subnet'] < 31) {
650
				if ($_POST['ipaddr'] == gen_subnet($_POST['ipaddr'], $_POST['subnet']))
651
					$input_errors[] = gettext("This IPv4 address is the network address and cannot be used");
652
				else if ($_POST['ipaddr'] == gen_subnet_max($_POST['ipaddr'], $_POST['subnet']))
653
					$input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used");
654
			}
655

    
656
			foreach ($staticroutes as $route_subnet) {
657
				list($network, $subnet) = explode("/", $route_subnet);
658
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
659
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
660
					break;
661
				}
662
				unset($network, $subnet);
663
			}
664
		}
665
	}
666
	if ($_POST['ipaddrv6']) {
667
		if (!is_ipaddrv6($_POST['ipaddrv6']))
668
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
669
		else {
670
			$where_ipaddr_configured = where_is_ipaddr_configured($_POST['ipaddrv6'], $if, true, true, $_POST['subnetv6']);
671
			if (count($where_ipaddr_configured)) {
672
				$subnet_conflict_text = sprintf(gettext("IPv6 address %s is being used by or overlaps with:"), $_POST['ipaddrv6'] . "/" . $_POST['subnetv6']);
673
				foreach ($where_ipaddr_configured as $subnet_conflict) {
674
					$subnet_conflict_text .= " " . convert_friendly_interface_to_friendly_descr($subnet_conflict['if']) . " (" . $subnet_conflict['ip_or_subnet'] . ")";
675
				}
676
				$input_errors[] = $subnet_conflict_text;
677
			}
678

    
679
			foreach ($staticroutes as $route_subnet) {
680
				list($network, $subnet) = explode("/", $route_subnet);
681
				if ($_POST['subnetv6'] == $subnet && $network == gen_subnetv6($_POST['ipaddrv6'], $_POST['subnetv6'])) {
682
					$input_errors[] = gettext("This IPv6 address conflicts with a Static Route.");
683
					break;
684
				}
685
				unset($network, $subnet);
686
			}
687
		}
688
	}
689
	if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
690
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
691
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6'])))
692
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
693
	if (($_POST['alias-address'] && !is_ipaddrv4($_POST['alias-address'])))
694
		$input_errors[] = gettext("A valid alias IP address must be specified.");
695
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
696
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
697
	if ($_POST['dhcprejectfrom'] && !is_ipaddrv4($_POST['dhcprejectfrom']))
698
		$input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from.");
699
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
700
		$match = false;
701
		foreach($a_gateways as $gateway) {
702
			if(in_array($_POST['gateway'], $gateway)) {
703
				$match = true;
704
			}
705
		}
706
		foreach($a_gateways as $gateway) {
707
			if(in_array($_POST['gatewayv6'], $gateway)) {
708
				$match = true;
709
			}
710
		}
711
		if(!$match) {
712
			$input_errors[] = gettext("A valid gateway must be specified.");
713
		}
714
	}
715
	if (($_POST['provider'] && !is_domain($_POST['provider'])))
716
		$input_errors[] = gettext("The service name contains invalid characters.");
717
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
718
		$input_errors[] = gettext("The idle timeout value must be an integer.");
719
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
720
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23)
721
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
722
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
723
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59)
724
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
725
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate'])))
726
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
727
	if (($_POST['pptp_local'] && !is_ipaddrv4($_POST['pptp_local'])))
728
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
729
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet'])))
730
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
731
	if (($_POST['pptp_remote'] && !is_ipaddrv4($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface])))
732
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
733
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout']))
734
		$input_errors[] = gettext("The idle timeout value must be an integer.");
735
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])))
736
		$input_errors[] = gettext("A valid MAC address must be specified.");
737
	if ($_POST['mtu']) {
738
		if (!is_numericint($_POST['mtu']))
739
			$input_errors[] = "MTU must be an integer.";
740
		if (substr($wancfg['if'], 0, 3) == 'gif') {
741
			$min_mtu = 1280;
742
			$max_mtu = 8192;
743
		} else {
744
			$min_mtu = 576;
745
			$max_mtu = 9000;
746
		}
747

    
748
		if ($_POST['mtu'] < $min_mtu || $_POST['mtu'] > $max_mtu)
749
			$input_errors[] = sprintf(gettext("The MTU must be between %d and %d bytes."), $min_mtu, $max_mtu);
750

    
751
		unset($min_mtu, $max_mtu);
752

    
753
		if (stristr($wancfg['if'], "_vlan")) {
754
			$realhwif_array = get_parent_interface($wancfg['if']);
755
			// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
756
			$parent_realhwif = $realhwif_array[0];
757
			$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
758
			if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) {
759
				if ($_POST['mtu'] > intval($config['interfaces'][$parent_if]['mtu']))
760
					$input_errors[] = gettext("The MTU of a VLAN cannot be greater than that of its parent interface.");
761
			}
762
		} else {
763
			foreach ($config['interfaces'] as $idx => $ifdata) {
764
				if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if']))
765
					continue;
766

    
767
				$realhwif_array = get_parent_interface($ifdata['if']);
768
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
769
				$parent_realhwif = $realhwif_array[0];
770

    
771
				if ($parent_realhwif != $wancfg['if'])
772
					continue;
773

    
774
				if (isset($ifdata['mtu']) && $ifdata['mtu'] > $_POST['mtu'])
775
					$input_errors[] = sprintf(gettext("Interface %s (VLAN) has MTU set to a larger value"), $ifdata['descr']);
776
			}
777
		}
778
	}
779
	if ($_POST['mss'] <> '')
780
		if (!is_numericint($_POST['mss']) || ($_POST['mss'] < 576 || $_POST['mss'] > 65535))
781
			$input_errors[] = gettext("The MSS must be an integer between 576 and 65535 bytes.");
782
	/* Wireless interface? */
783
	if (isset($wancfg['wireless'])) {
784
		$reqdfields = array("mode");
785
		$reqdfieldsn = array(gettext("Mode"));
786
		if ($_POST['mode'] == 'hostap') {
787
			$reqdfields[] = "ssid";
788
			$reqdfieldsn[] = gettext("SSID");
789
			if (isset($_POST['channel']) && $_POST['channel'] == "0") {
790
				// auto channel with hostap is broken, prevent this for now.
791
				$input_errors[] = gettext("A specific channel, not auto, must be selected for Access Point mode.");
792
			}
793
		}
794
		if (stristr($_POST['standard'], '11n')) {
795
			if (!($_POST['wme_enable'])) {
796
				$input_errors[] = gettext("802.11n standards require enabling WME.");
797
			}
798
		}
799
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
800
		check_wireless_mode();
801
		if (isset($_POST['wpa_group_rekey']) && (!is_numericint($_POST['wpa_group_rekey']) || $_POST['wpa_group_rekey'] < 1 || $_POST['wpa_group_rekey'] > 9999)) {
802
			$input_errors[] = gettext("Key Rotation must be an integer between 1 and 9999.");
803
		}
804
		if (isset($_POST['wpa_gmk_rekey']) && (!is_numericint($_POST['wpa_gmk_rekey']) || $_POST['wpa_gmk_rekey'] < 1 || $_POST['wpa_gmk_rekey'] > 9999)) {
805
			$input_errors[] = gettext("Master Key Regeneration must be an integer between 1 and 9999.");
806
		}
807
		if (isset($_POST['wpa_group_rekey']) && isset($_POST['wpa_gmk_rekey'])) {
808
			if ($_POST['wpa_group_rekey'] > $_POST['wpa_gmk_rekey']) {
809
				$input_errors[] = gettext("Master Key Regeneration must be greater than Key Rotation.");
810
			}
811
		}
812
		if (!empty($_POST['auth_server_addr'])) {
813
			if (!is_domain($_POST['auth_server_addr']) && !is_ipaddr($_POST['auth_server_addr'])) {
814
				$input_errors[] = gettext("802.1X Authentication Server must be an IP or hostname.");
815
			}
816
		}
817
		if (!empty($_POST['auth_server_addr2'])) {
818
			if (!is_domain($_POST['auth_server_addr2']) && !is_ipaddr($_POST['auth_server_addr2'])) {
819
				$input_errors[] = gettext("Secondary 802.1X Authentication Server must be an IP or hostname.");
820
			}
821
		}
822
		if (!empty($_POST['auth_server_port'])) {
823
			if (!is_port($_POST['auth_server_port'])) {
824
				$input_errors[] = gettext("802.1X Authentication Server Port must be a valid port number (1-65535).");
825
			}
826
		}
827
		if (!empty($_POST['auth_server_port2'])) {
828
			if (!is_port($_POST['auth_server_port2'])) {
829
				$input_errors[] = gettext("Secondary 802.1X Authentication Server Port must be a valid port number (1-65535).");
830
			}
831
		}
832
		if (isset($_POST['channel']) && !is_numericint($_POST['channel'])) {
833
			if (!is_numericint($_POST['channel'])) {
834
				$input_errors[] = gettext("Invalid channel specified.");
835
			} else {
836
				if ($_POST['channel'] > 255 || $_POST['channel'] < 0) {
837
					$input_errors[] = gettext("Channel must be between 0-255.");
838
				}
839
			}
840
		}
841
		if (!empty($_POST['distance']) && !is_numericint($_POST['distance'])) {
842
			$input_errors[] = gettext("Distance must be an integer.");
843
		}
844
		if (isset($_POST['standard']) && (stristr($_POST['standard'], '11na') || stristr($_POST['standard'], '11a'))) {
845
			if ($_POST['channel'] != 0 && $_POST['channel'] < 15) {
846
				$input_errors[] = gettext("Channel selected is not valid for 802.11a or 802.11na.");
847
			}
848
		}
849
		if (isset($_POST['standard']) && ($_POST['standard'] == "11b" || $_POST['standard'] == "11g")) {
850
			if ($_POST['channel'] > 14) {
851
				$input_errors[] = gettext("Channel selected is not valid for 802.11b or 802.11g.");
852
			}
853
		}
854
		if (!empty($_POST['protmode']) && !in_array($_POST['protmode'], array("off", "cts", "rtscts"))) {
855
			$input_errors[] = gettext("Invalid option chosen for OFDM Protection Mode");
856
		}
857
		/* loop through keys and enforce size */
858
		for ($i = 1; $i <= 4; $i++) {
859
			if ($_POST['key' . $i]) {
860
				/* 64 bit */
861
				if (strlen($_POST['key' . $i]) == 5)
862
					continue;
863
				if (strlen($_POST['key' . $i]) == 10) {
864
					/* hex key */
865
					if (stristr($_POST['key' . $i], "0x") == false) {
866
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
867
					}
868
					continue;
869
				}
870
				if (strlen($_POST['key' . $i]) == 12) {
871
					/* hex key */
872
					if(stristr($_POST['key' . $i], "0x") == false) {
873
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
874
					}
875
					continue;
876
				}
877
				/* 128 bit */
878
				if (strlen($_POST['key' . $i]) == 13)
879
					continue;
880
				if (strlen($_POST['key' . $i]) == 26) {
881
					/* hex key */
882
					if (stristr($_POST['key' . $i], "0x") == false)
883
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
884
					continue;
885
				}
886
				if(strlen($_POST['key' . $i]) == 28)
887
					continue;
888
				$input_errors[] =  gettext("Invalid WEP key. Enter a valid 40, 64, 104 or 128 bit WEP key.");
889
				break;
890
			}
891
		}
892

    
893
		if ($_POST['passphrase']) {
894
			$passlen = strlen($_POST['passphrase']);
895
			if ($passlen < 8 || $passlen > 63)
896
				$input_errors[] = gettext("The WPA passphrase must be between 8 and 63 characters long.");
897
		}
898
		if ($_POST['wpa_enable'] == "yes") {
899
			if (empty($_POST['passphrase']) && stristr($_POST['wpa_key_mgmt'], "WPA-PSK")) {
900
				$input_errors[] = gettext("A WPA Passphrase must be specified when WPA PSK is enabled.");
901
			}
902
		}
903
	}
904
	if (!$input_errors) {
905
		if ($wancfg['ipaddr'] != $_POST['type']) {
906
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
907
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
908
				unset($a_ppps[$pppid]);
909
			} else if ($wancfg['ipaddr'] == "dhcp") {
910
				kill_dhclient_process($wancfg['if']);
911
			}
912
			if ($wancfg['ipaddrv6'] == "dhcp6") {
913
				$pid = find_dhcp6c_process($wancfg['if']);
914
				if($pid)
915
					posix_kill($pid, SIGTERM);
916
			}
917
		}
918
		$ppp = array();
919
		if ($wancfg['ipaddr'] != "ppp")
920
			unset($wancfg['ipaddr']);
921
		if ($wancfg['ipaddrv6'] != "ppp")
922
			unset($wancfg['ipaddrv6']);
923
		unset($wancfg['subnet']);
924
		unset($wancfg['gateway']);
925
		unset($wancfg['subnetv6']);
926
		unset($wancfg['gatewayv6']);
927
		unset($wancfg['dhcphostname']);
928
		unset($wancfg['dhcprejectfrom']);
929
		unset($wancfg['dhcp6-duid']);
930
		unset($wancfg['dhcp6-ia-pd-len']);
931
		unset($wancfg['dhcp6-ia-pd-send-hint']);
932
		unset($wancfg['dhcp6prefixonly']);
933
		unset($wancfg['dhcp6usev4iface']);
934
		unset($wancfg['track6-interface']);
935
		unset($wancfg['track6-prefix-id']);
936
		unset($wancfg['prefix-6rd']);
937
		unset($wancfg['prefix-6rd-v4plen']);
938
		unset($wancfg['gateway-6rd']);
939

    
940
		unset($wancfg['adv_dhcp_pt_timeout']);
941
		unset($wancfg['adv_dhcp_pt_retry']);
942
		unset($wancfg['adv_dhcp_pt_select_timeout']);
943
		unset($wancfg['adv_dhcp_pt_reboot']);
944
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
945
		unset($wancfg['adv_dhcp_pt_initial_interval']);
946

    
947
		unset($wancfg['adv_dhcp_pt_values']);
948

    
949
		unset($wancfg['adv_dhcp_send_options']);
950
		unset($wancfg['adv_dhcp_request_options']);
951
		unset($wancfg['adv_dhcp_required_options']);
952
		unset($wancfg['adv_dhcp_option_modifiers']);
953

    
954
		unset($wancfg['adv_dhcp_config_advanced']);
955
		unset($wancfg['adv_dhcp_config_file_override']);
956
		unset($wancfg['adv_dhcp_config_file_override_path']);
957

    
958
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
959
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
960
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
961
		unset($wancfg['adv_dhcp6_interface_statement_script']);
962

    
963
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
964
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
965
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
966
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
967
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
968

    
969
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
970
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
971
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
972
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
973
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
974

    
975
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
976
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
977

    
978
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
979
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
980
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
981
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
982

    
983
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
984
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
985
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
986
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
987
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
988

    
989
		unset($wancfg['adv_dhcp6_config_advanced']);
990
		unset($wancfg['adv_dhcp6_config_file_override']);
991
		unset($wancfg['adv_dhcp6_config_file_override_path']);
992

    
993
		unset($wancfg['pppoe_password']);
994
		unset($wancfg['pptp_username']);
995
		unset($wancfg['pptp_password']);
996
		unset($wancfg['provider']);
997
		unset($wancfg['ondemand']);
998
		unset($wancfg['timeout']);
999
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
1000
			unset($wancfg['pppoe']['pppoe-reset-type']);
1001
		unset($wancfg['local']);
1002

    
1003
		unset($wancfg['remote']);
1004
		if (is_array($a_ppps[$pppid]) && in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
1005
			if ($wancfg['ipaddr'] != 'ppp') {
1006
				unset($a_ppps[$pppid]['apn']);
1007
				unset($a_ppps[$pppid]['phone']);
1008
				unset($a_ppps[$pppid]['provider']);
1009
				unset($a_ppps[$pppid]['ondemand']);
1010
			}
1011
			if (in_array($wancfg['ipaddr'], array("pppoe", "pptp", "l2tp"))) {
1012
				unset($a_ppps[$pppid]['localip']);
1013
				unset($a_ppps[$pppid]['subnet']);
1014
				unset($a_ppps[$pppid]['gateway']);
1015
			}
1016
			if ($wancfg['ipaddr'] != 'pppoe')
1017
				unset($a_ppps[$pppid]['pppoe-reset-type']);
1018
			if ($wancfg['type'] != $_POST['type']) {
1019
				unset($a_ppps[$pppid]['idletimeout']);
1020
			}
1021
		}
1022

    
1023
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
1024
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
1025

    
1026
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
1027
		switch($_POST['type']) {
1028
			case "staticv4":
1029
				$wancfg['ipaddr'] = $_POST['ipaddr'];
1030
				$wancfg['subnet'] = $_POST['subnet'];
1031
				if ($_POST['gateway'] != "none") {
1032
					$wancfg['gateway'] = $_POST['gateway'];
1033
				}
1034
				break;
1035
			case "dhcp":
1036
				$wancfg['ipaddr'] = "dhcp";
1037
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
1038
				$wancfg['alias-address'] = $_POST['alias-address'];
1039
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
1040
				$wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom'];
1041

    
1042
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
1043
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
1044
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
1045
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
1046
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
1047
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
1048

    
1049
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
1050

    
1051
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
1052
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
1053
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
1054
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
1055

    
1056
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
1057
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
1058
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
1059

    
1060
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
1061
				if($gateway_item) {
1062
					$a_gateways[] = $gateway_item;
1063
				}
1064
				break;
1065
			case "ppp":
1066
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1067
				$a_ppps[$pppid]['type'] = $_POST['type'];
1068
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1069
				$a_ppps[$pppid]['ports'] = $_POST['port'];
1070
				$a_ppps[$pppid]['username'] = $_POST['ppp_username'];
1071
				$a_ppps[$pppid]['password'] = base64_encode($_POST['ppp_password']);
1072
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
1073
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
1074
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
1075
				$wancfg['ipaddr'] = $_POST['type'];
1076
				break;
1077

    
1078
			case "pppoe":
1079
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1080
				$a_ppps[$pppid]['type'] = $_POST['type'];
1081
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1082
				if (isset($_POST['ppp_port']))
1083
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
1084
				else
1085
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
1086
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
1087
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
1088
				if (!empty($_POST['provider']))
1089
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
1090
				else
1091
					$a_ppps[$pppid]['provider'] = true;
1092
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
1093
				if (!empty($_POST['pppoe_idletimeout']))
1094
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
1095
				else
1096
					unset($a_ppps[$pppid]['idletimeout']);
1097

    
1098
				if (!empty($_POST['pppoe-reset-type']))
1099
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
1100
				else
1101
					unset($a_ppps[$pppid]['pppoe-reset-type']);
1102
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1103
				$wancfg['ipaddr'] = $_POST['type'];
1104
				if($gateway_item) {
1105
					$a_gateways[] = $gateway_item;
1106
				}
1107

    
1108
				break;
1109
			case "pptp":
1110
			case "l2tp":
1111
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1112
				$a_ppps[$pppid]['type'] = $_POST['type'];
1113
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1114
				if (isset($_POST['ppp_port']))
1115
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
1116
				else
1117
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
1118
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
1119
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
1120
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
1121
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
1122
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
1123
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
1124
				if (!empty($_POST['pptp_idletimeout']))
1125
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
1126
				else
1127
					unset($a_ppps[$pppid]['idletimeout']);
1128
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1129
				$wancfg['ipaddr'] = $_POST['type'];
1130
				if($gateway_item) {
1131
					$a_gateways[] = $gateway_item;
1132
				}
1133
				break;
1134
			case "none":
1135
				break;
1136
		}
1137
		switch($_POST['type6']) {
1138
			case "staticv6":
1139
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
1140
				$wancfg['subnetv6'] = $_POST['subnetv6'];
1141
				if ($_POST['gatewayv6'] != "none") {
1142
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
1143
				}
1144
				break;
1145
			case "slaac":
1146
				$wancfg['ipaddrv6'] = "slaac";
1147
				break;
1148
			case "dhcp6":
1149
				$wancfg['ipaddrv6'] = "dhcp6";
1150
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
1151
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
1152
				if($_POST['dhcp6-ia-pd-send-hint'] == "yes")
1153
					$wancfg['dhcp6-ia-pd-send-hint'] = true;
1154
				if($_POST['dhcp6prefixonly'] == "yes")
1155
					$wancfg['dhcp6prefixonly'] = true;
1156
				if($_POST['dhcp6usev4iface'] == "yes")
1157
					$wancfg['dhcp6usev4iface'] = true;
1158

    
1159
				if (!empty($_POST['adv_dhcp6_interface_statement_send_options']))
1160
					$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1161
				if (!empty($_POST['adv_dhcp6_interface_statement_request_options']))
1162
					$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1163
				if (isset($_POST['adv_dhcp6_interface_statement_information_only_enable']))
1164
					$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1165
				if (!empty($_POST['adv_dhcp6_interface_statement_script']))
1166
					$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1167

    
1168
				if (isset($_POST['adv_dhcp6_id_assoc_statement_address_enable']))
1169
					$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1170
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address']))
1171
					$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1172
				if (is_numericint($_POST['adv_dhcp6_id_assoc_statement_address_id']))
1173
					$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1174
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_pltime']))
1175
					$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1176
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_vltime']))
1177
					$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1178

    
1179
				if (isset($_POST['adv_dhcp6_id_assoc_statement_prefix_enable']))
1180
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1181
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix']))
1182
					$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1183
				if (is_numericint($_POST['adv_dhcp6_id_assoc_statement_prefix_id']))
1184
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1185
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_pltime']))
1186
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1187
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_vltime']))
1188
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1189

    
1190
				if (is_numericint($_POST['adv_dhcp6_prefix_interface_statement_sla_id']))
1191
					$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1192
				if (is_numericint($_POST['adv_dhcp6_prefix_interface_statement_sla_len']))
1193
					$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1194

    
1195
				if (!empty($_POST['adv_dhcp6_authentication_statement_authname']))
1196
					$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1197
				if (!empty($_POST['adv_dhcp6_authentication_statement_protocol']))
1198
					$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1199
				if (!empty($_POST['adv_dhcp6_authentication_statement_algorithm']))
1200
					$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1201
				if (!empty($_POST['adv_dhcp6_authentication_statement_rdm']))
1202
					$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1203

    
1204
				if (!empty($_POST['adv_dhcp6_key_info_statement_keyname']))
1205
					$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1206
				if (!empty($_POST['adv_dhcp6_key_info_statement_realm']))
1207
					$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1208
				if (!empty($_POST['adv_dhcp6_key_info_statement_keyid']))
1209
					$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1210
				if (!empty($_POST['adv_dhcp6_key_info_statement_secret']))
1211
					$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1212
				if (!empty($_POST['adv_dhcp6_key_info_statement_expire']))
1213
					$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1214

    
1215
				if (!empty($_POST['adv_dhcp6_config_advanced']))
1216
					$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1217
				if (!empty($_POST['adv_dhcp6_config_file_override']))
1218
					$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1219
				if (!empty($_POST['adv_dhcp6_config_file_override_path']))
1220
					$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1221

    
1222
				if($gateway_item) {
1223
					$a_gateways[] = $gateway_item;
1224
				}
1225
				break;
1226
			case "6rd":
1227
				$wancfg['ipaddrv6'] = "6rd";
1228
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
1229
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
1230
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
1231
				if($gateway_item) {
1232
					$a_gateways[] = $gateway_item;
1233
				}
1234
				break;
1235
			case "6to4":
1236
				$wancfg['ipaddrv6'] = "6to4";
1237
				break;
1238
			case "track6":
1239
				$wancfg['ipaddrv6'] = "track6";
1240
				$wancfg['track6-interface'] = $_POST['track6-interface'];
1241
				if ($_POST['track6-prefix-id--hex'] === "")
1242
					$wancfg['track6-prefix-id'] = 0;
1243
				else if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
1244
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
1245
				else
1246
					$wancfg['track6-prefix-id'] = 0;
1247
				break;
1248
			case "none":
1249
				break;
1250
		}
1251
		handle_pppoe_reset($_POST);
1252

    
1253
		if($_POST['blockpriv'] == "yes") {
1254
			$wancfg['blockpriv'] = true;
1255
		} else {
1256
			unset($wancfg['blockpriv']);
1257
		}
1258
		if($_POST['blockbogons'] == "yes") {
1259
			$wancfg['blockbogons'] = true;
1260
		} else {
1261
			unset($wancfg['blockbogons']);
1262
		}
1263
		$wancfg['spoofmac'] = $_POST['spoofmac'];
1264
		if (empty($_POST['mtu'])) {
1265
			unset($wancfg['mtu']);
1266
		} else {
1267
			$wancfg['mtu'] = $_POST['mtu'];
1268
		}
1269
		if (empty($_POST['mss'])) {
1270
			unset($wancfg['mss']);
1271
		} else {
1272
			$wancfg['mss'] = $_POST['mss'];
1273
		}
1274
		if (empty($_POST['mediaopt'])) {
1275
			unset($wancfg['media']);
1276
			unset($wancfg['mediaopt']);
1277
		} else {
1278
			$mediaopts = explode(' ', $_POST['mediaopt']);
1279
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
1280
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
1281
			else { unset($wancfg['mediaopt']); }
1282
		}
1283
		if (isset($wancfg['wireless'])) {
1284
			handle_wireless_post();
1285
		}
1286

    
1287
		conf_mount_ro();
1288
		write_config();
1289

    
1290
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
1291
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
1292
		} else {
1293
			$toapplylist = array();
1294
		}
1295
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
1296
		$toapplylist[$if]['ppps'] = $old_ppps;
1297
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
1298

    
1299
		mark_subsystem_dirty('interfaces');
1300

    
1301
		/* regenerate cron settings/crontab file */
1302
		configure_cron();
1303

    
1304
		header("Location: interfaces.php?if={$if}");
1305
		exit;
1306
	}
1307

    
1308
} // end if($_POST)
1309

    
1310
function handle_wireless_post() {
1311
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
1312
	if (!is_array($wancfg['wireless']))
1313
		$wancfg['wireless'] = array();
1314
	$wancfg['wireless']['standard'] = $_POST['standard'];
1315
	$wancfg['wireless']['mode'] = $_POST['mode'];
1316
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
1317
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
1318
	$wancfg['wireless']['channel'] = $_POST['channel'];
1319
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
1320
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
1321
	$wancfg['wireless']['distance'] = $_POST['distance'];
1322
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
1323
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
1324
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
1325
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
1326
		foreach($wl_countries_attr as $wl_country) {
1327
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
1328
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
1329
				break;
1330
			}
1331
		}
1332
	}
1333
	if (!is_array($wancfg['wireless']['wpa']))
1334
		$wancfg['wireless']['wpa'] = array();
1335
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
1336
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
1337
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
1338
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
1339
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
1340
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
1341
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
1342
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
1343
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
1344
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
1345
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
1346
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
1347
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
1348
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
1349
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
1350

    
1351
	if ($_POST['persistcommonwireless'] == "yes") {
1352
		if (!is_array($config['wireless']))
1353
			$config['wireless'] = array();
1354
		if (!is_array($config['wireless']['interfaces']))
1355
			$config['wireless']['interfaces'] = array();
1356
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
1357
			$config['wireless']['interfaces'][$wlanbaseif] = array();
1358
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
1359
		unset($config['wireless']['interfaces'][$wlanbaseif]);
1360
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
1361
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
1362
	else if (isset($wancfg['wireless']['diversity']))
1363
		unset($wancfg['wireless']['diversity']);
1364
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
1365
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
1366
	else if (isset($wancfg['wireless']['txantenna']))
1367
		unset($wancfg['wireless']['txantenna']);
1368
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
1369
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
1370
	else if (isset($wancfg['wireless']['rxantenna']))
1371
		unset($wancfg['wireless']['rxantenna']);
1372
	if ($_POST['hidessid_enable'] == "yes")
1373
		$wancfg['wireless']['hidessid']['enable'] = true;
1374
	else if (isset($wancfg['wireless']['hidessid']['enable']))
1375
		unset($wancfg['wireless']['hidessid']['enable']);
1376
	if ($_POST['mac_acl_enable'] == "yes")
1377
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
1378
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
1379
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
1380
	if ($_POST['rsn_preauth'] == "yes")
1381
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
1382
	else
1383
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
1384
	if ($_POST['ieee8021x'] == "yes")
1385
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
1386
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
1387
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
1388
	if ($_POST['wpa_strict_rekey'] == "yes")
1389
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
1390
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
1391
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
1392
	if ($_POST['debug_mode'] == "yes")
1393
		$wancfg['wireless']['wpa']['debug_mode'] = true;
1394
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
1395
		sunset($wancfg['wireless']['wpa']['debug_mode']);
1396
	if ($_POST['wpa_enable'] == "yes")
1397
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
1398
	else if (isset($wancfg['wireless']['wpa']['enable']))
1399
		unset($wancfg['wireless']['wpa']['enable']);
1400
	if ($_POST['wep_enable'] == "yes") {
1401
		if (!is_array($wancfg['wireless']['wep']))
1402
			$wancfg['wireless']['wep'] = array();
1403
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
1404
	} else if (isset($wancfg['wireless']['wep']))
1405
		unset($wancfg['wireless']['wep']);
1406
	if ($_POST['wme_enable'] == "yes") {
1407
		if (!is_array($wancfg['wireless']['wme']))
1408
			$wancfg['wireless']['wme'] = array();
1409
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1410
	} else if (isset($wancfg['wireless']['wme']['enable']))
1411
		unset($wancfg['wireless']['wme']['enable']);
1412
	if ($_POST['puremode'] == "11g") {
1413
		if (!is_array($wancfg['wireless']['pureg']))
1414
			$wancfg['wireless']['pureg'] = array();
1415
		$wancfg['wireless']['pureg']['enable'] = true;
1416
	} else if ($_POST['puremode'] == "11n") {
1417
		if (!is_array($wancfg['wireless']['puren']))
1418
			$wancfg['wireless']['puren'] = array();
1419
		$wancfg['wireless']['puren']['enable'] = true;
1420
	} else {
1421
		if (isset($wancfg['wireless']['pureg']))
1422
			unset($wancfg['wireless']['pureg']);
1423
		if (isset($wancfg['wireless']['puren']))
1424
			unset($wancfg['wireless']['puren']);
1425
	}
1426
	if ($_POST['apbridge_enable'] == "yes") {
1427
		if (!is_array($wancfg['wireless']['apbridge']))
1428
			$wancfg['wireless']['apbridge'] = array();
1429
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1430
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
1431
		unset($wancfg['wireless']['apbridge']['enable']);
1432
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1433
		if (!is_array($wancfg['wireless']['turbo']))
1434
			$wancfg['wireless']['turbo'] = array();
1435
		$wancfg['wireless']['turbo']['enable'] = true;
1436
	} else if (isset($wancfg['wireless']['turbo']['enable']))
1437
		unset($wancfg['wireless']['turbo']['enable']);
1438
	$wancfg['wireless']['wep']['key'] = array();
1439
	for ($i = 1; $i <= 4; $i++) {
1440
		if ($_POST['key' . $i]) {
1441
			$newkey = array();
1442
			$newkey['value'] = $_POST['key' . $i];
1443
			if ($_POST['txkey'] == $i)
1444
				$newkey['txkey'] = true;
1445
			$wancfg['wireless']['wep']['key'][] = $newkey;
1446
		}
1447
	}
1448
	interface_sync_wireless_clones($wancfg, true);
1449
}
1450

    
1451
function check_wireless_mode() {
1452
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1453

    
1454
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1455
		return;
1456

    
1457
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1458
		$clone_count = 1;
1459
	else
1460
		$clone_count = 0;
1461
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1462
		foreach ($config['wireless']['clone'] as $clone) {
1463
			if ($clone['if'] == $wlanbaseif)
1464
				$clone_count++;
1465
		}
1466
	}
1467
	if ($clone_count > 1) {
1468
		$old_wireless_mode = $wancfg['wireless']['mode'];
1469
		$wancfg['wireless']['mode'] = $_POST['mode'];
1470
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1471
			$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']]);
1472
		} else {
1473
			mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy");
1474
		}
1475
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1476
	}
1477
}
1478

    
1479
// Find all possible media options for the interface
1480
$mediaopts_list = array();
1481
$intrealname = $config['interfaces'][$if]['if'];
1482
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1483
foreach ($mediaopts as $mediaopt){
1484
	preg_match("/media (.*)/", $mediaopt, $matches);
1485
	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1486
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1487
		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1488
	}else{
1489
		// there is only media like "media 1000baseT"
1490
		array_push($mediaopts_list, $matches[1]);
1491
	}
1492
}
1493

    
1494
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1495
$shortcut_section = "interfaces";
1496

    
1497
$closehead = false;
1498
include("head.inc");
1499
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1500
$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"));
1501

    
1502
?>
1503

    
1504
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1505
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1506
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1507
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1508

    
1509
<script type="text/javascript">
1510
//<![CDATA[
1511
	function updateType(t) {
1512
		switch(t) {
1513
			case "none": {
1514
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1515
				break;
1516
			}
1517
			case "staticv4": {
1518
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1519
				break;
1520
			}
1521
			case "dhcp": {
1522
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1523
				break;
1524
			}
1525
			case "ppp": {
1526
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1527
				country_list();
1528
				break;
1529
			}
1530
			case "pppoe": {
1531
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1532
				break;
1533
			}
1534
			case "l2tp":
1535
			case "pptp": {
1536
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1537
				jQuery('#pptp').show();
1538
				break;
1539
			}
1540
		}
1541
		if (t != "l2tp" && t != "pptp")
1542
			jQuery('#'+t).show();
1543
	}
1544
	function updateTypeSix(t) {
1545
		if (!isNaN(t[0])) t = '_' + t;
1546
		switch(t) {
1547
			case "none": {
1548
				jQuery('#staticv6, #dhcp6, #_6rd, #_6to4, #track6, #slaac').hide();
1549
				break;
1550
			}
1551
			case "staticv6": {
1552
				jQuery('#none, #dhcp6, #_6rd, #_6to4, #track6, #slaac').hide();
1553
				break;
1554
			}
1555
			case "slaac": {
1556
				jQuery('#none, #staticv6, #_6rd, #_6to4, #track6, #dhcp6').hide();
1557
				break;
1558
			}
1559
			case "dhcp6": {
1560
				jQuery('#none, #staticv6, #_6rd, #_6to4, #track6, #slaac').hide();
1561
				break;
1562
			}
1563
			case "_6rd": {
1564
				jQuery('#none, #dhcp6, #staticv6, #_6to4, #track6, #slaac').hide();
1565
				break;
1566
			}
1567
			case "_6to4": {
1568
				jQuery('#none, #dhcp6, #staticv6, #_6rd, #track6, #slaac').hide();
1569
				break;
1570
			}
1571
			case "track6": {
1572
				jQuery('#none, #dhcp6, #staticv6, #_6rd, #_6to4, #slaac').hide();
1573
				update_track6_prefix();
1574
				break;
1575
			}
1576
		}
1577
		if (t != "l2tp" && t != "pptp")
1578
			jQuery('#'+t).show();
1579
	}
1580

    
1581
	function show_allcfg(obj) {
1582
		if (obj.checked)
1583
			jQuery('#allcfg').show();
1584
		else
1585
			jQuery('#allcfg').hide();
1586
	}
1587

    
1588
	function show_reset_settings(reset_type) {
1589
		if (reset_type == 'preset') {
1590
			jQuery('#pppoepresetwrap').show();
1591
			jQuery('#pppoecustomwrap').hide();
1592
		}
1593
		else if (reset_type == 'custom') {
1594
			jQuery('#pppoecustomwrap').show();
1595
			jQuery('#pppoepresetwrap').hide();
1596
		} else {
1597
			jQuery('#pppoecustomwrap').hide();
1598
			jQuery('#pppoepresetwrap').hide();
1599
		}
1600
	}
1601
	function show_mon_config() {
1602
		jQuery("#showmonbox").html('');
1603
		jQuery('#showmon').css('display','block');
1604
	}
1605

    
1606
	function openwindow(url) {
1607
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1608
		if (oWin==null || typeof(oWin)=="undefined")
1609
			return false;
1610
		else
1611
			return true;
1612
	}
1613
	function country_list() {
1614
		jQuery('#country').children().remove();
1615
		jQuery('#provider_list').children().remove();
1616
		jQuery('#providerplan').children().remove();
1617
		jQuery.ajax("getserviceproviders.php",{
1618
			success: function(response) {
1619
				var responseTextArr = response.split("\n");
1620
				responseTextArr.sort();
1621
				responseTextArr.each( function(value) {
1622
					var option = new Element('option');
1623
					country = value.split(":");
1624
					option.text = country[0];
1625
					option.value = country[1];
1626
					jQuery('#country').append(option);
1627
				});
1628
			}
1629
		});
1630
		jQuery('#trcountry').css('display',"table-row");
1631
	}
1632

    
1633
	function providers_list() {
1634
		jQuery('#provider_list').children().remove();
1635
		jQuery('#providerplan').children().remove();
1636
		jQuery.ajax("getserviceproviders.php",{
1637
			type: 'post',
1638
			data: {country : jQuery('#country').val()},
1639
			success: function(response) {
1640
				var responseTextArr = response.split("\n");
1641
				responseTextArr.sort();
1642
				responseTextArr.each( function(value) {
1643
					var option = new Element('option');
1644
					option.text = value;
1645
					option.value = value;
1646
					jQuery('#provider_list').append(option);
1647
				});
1648
			}
1649
		});
1650
		jQuery('#trprovider').css("display","table-row");
1651
		jQuery('#trproviderplan').css("display","none");
1652
	}
1653

    
1654
	function providerplan_list() {
1655
		jQuery('#providerplan').children().remove();
1656
		jQuery('#providerplan').append( new Element('option') );
1657
		jQuery.ajax("getserviceproviders.php",{
1658
			type: 'post',
1659
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val()},
1660
			success: function(response) {
1661
				var responseTextArr = response.split("\n");
1662
				responseTextArr.sort();
1663
				responseTextArr.each( function(value) {
1664
					if(value != "") {
1665
						providerplan = value.split(":");
1666

    
1667
						var option = new Element('option');
1668
						option.text = providerplan[0] + " - " + providerplan[1];
1669
						option.value = providerplan[1];
1670
						jQuery('#providerplan').append(option);
1671
					}
1672
				});
1673
			}
1674
		});
1675
		jQuery('#trproviderplan').css("display","table-row");
1676
	}
1677

    
1678
	function prefill_provider() {
1679
		jQuery.ajax("getserviceproviders.php",{
1680
			type: 'post',
1681
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val(), plan : jQuery('#providerplan').val()},
1682
			success: function(data,textStatus,response) {
1683
				var xmldoc = response.responseXML;
1684
				var provider = xmldoc.getElementsByTagName('connection')[0];
1685
				jQuery('#ppp_username').val('');
1686
				jQuery('#ppp_password').val('');
1687
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1688
					jQuery('#phone').val('#777');
1689
					jQuery('#apn').val('');
1690
				} else {
1691
					jQuery('#phone').val('*99#');
1692
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1693
				}
1694
				ppp_username = provider.getElementsByTagName('ppp_username')[0].firstChild.data;
1695
				ppp_password = provider.getElementsByTagName('ppp_password')[0].firstChild.data;
1696
				jQuery('#ppp_username').val(ppp_username);
1697
				jQuery('#ppp_password').val(ppp_password);
1698
			}
1699
		});
1700
	}
1701

    
1702
	function update_track6_prefix() {
1703
		var iface = jQuery("#track6-interface").val();
1704
		if (iface == null)
1705
			return;
1706
		var track6_prefix_ids = jQuery('#ipv6-num-prefix-ids-' + iface).val();
1707
		if (track6_prefix_ids == null)
1708
			return;
1709
		track6_prefix_ids = parseInt(track6_prefix_ids).toString(16);
1710
		jQuery('#track6-prefix-id-range').html('(<b>hexadecimal</b> from 0 to ' + track6_prefix_ids + ')');
1711
	}
1712

    
1713
//]]>
1714
</script>
1715
</head>
1716
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1717
	<?php include("fbegin.inc"); ?>
1718
	<form action="interfaces.php" method="post" name="iform" id="iform">
1719
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1720
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1721
		<?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 />
1722
		<?php endif; ?>
1723
		<?php if ($savemsg) print_info_box($savemsg); ?>
1724
		<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces">
1725
			<tr>
1726
				<td id="mainarea">
1727
					<div class="tabcont">
1728
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="tabs">
1729
						<tr>
1730
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1731
						</tr>
1732
						<tr>
1733
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1734
							<td width="78%" class="vtable">
1735
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked=\"checked\""; ?> onclick="show_allcfg(this);" />
1736
							<strong><?=gettext("Enable Interface"); ?></strong>
1737
							</td>
1738
						</tr>
1739
					</table>
1740
					<div style="display:none;" id="allcfg">
1741
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="allcfg">
1742
						<tr>
1743
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1744
							<td width="78%" class="vtable">
1745
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>" />
1746
								<br /><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1747
							</td>
1748
						</tr>
1749
						<tr>
1750
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1751
							<td class="vtable">
1752
							<select name="type" onchange="updateType(this.value);" <?php echo $type_disabled; ?> class="formselect" id="type">
1753
								<?php
1754
									foreach ($types4 as $key => $opt) {
1755
										echo "<option onclick=\"updateType('{$key}');\"";
1756
										if ($key == $pconfig['type'])
1757
											echo " selected=\"selected\"";
1758
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1759
										echo "</option>";
1760
									}
1761
								?>
1762
								</select>
1763
							</td>
1764
						</tr>
1765
						<tr>
1766
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1767
							<td class="vtable">
1768
							<select name="type6" onchange="updateTypeSix(this.value);" <?php echo $type_disabled; ?> class="formselect" id="type6">
1769
								<?php
1770
									foreach ($types6 as $key => $opt) {
1771
										echo "<option onclick=\"updateTypeSix('{$key}');\"";
1772
										if ($key == $pconfig['type6'])
1773
											echo " selected=\"selected\"";
1774
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1775
										echo "</option>";
1776
									}
1777
								?>
1778
								</select>
1779
							</td>
1780
						</tr>
1781
						<tr>
1782
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1783
							<td class="vtable">
1784
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>" />
1785
								<?php
1786
									$ip = getenv('REMOTE_ADDR');
1787
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1788
									$mac = str_replace("\n","",$mac);
1789
									if($mac):
1790
								?>
1791
									<a onclick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1792
								<?php endif; ?>
1793
								<br />
1794
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1795
								"address of this interface"); ?><br />
1796
								<?=gettext("(may be required with some cable connections)"); ?><br />
1797
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1798
								"or leave blank"); ?>
1799
							</td>
1800
						</tr>
1801
						<tr>
1802
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1803
							<td class="vtable">
1804
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>" />
1805
								<br />
1806
								<?php
1807
									print gettext("If you leave this field blank, the adapter's default MTU will " .
1808
									"be used. This is typically 1500 bytes but can vary in some circumstances.");
1809
								?>
1810
							</td>
1811
						</tr>
1812
						<tr>
1813
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1814
							<td class="vtable">
1815
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>" />
1816
								<br />
1817
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1818
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1819
								"header size) will be in effect."); ?>
1820
							</td>
1821
						</tr>
1822
						<?php
1823
						if (count($mediaopts_list) > 0){
1824
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1825
						echo "<tr>";
1826
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1827
							echo '<td class="vtable">';
1828
							echo '<div id="showadvmediabox"';
1829
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1830
								else echo '>';
1831
								echo '<input type="button" onclick="show_advanced_media()" value="' . gettext("Advanced") . '" /> - ' . gettext("Show advanced option");
1832
							echo "</div>";
1833
							echo '<div id="showmediaadv" ';
1834
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1835
							else echo '>';
1836
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1837
								print "<option value=\"\">Default (no preference, typically autoselect)</option>";
1838
								print "<option value=\"\">------- Media Supported by this interface -------</option>";
1839
								foreach($mediaopts_list as $mediaopt){
1840
									if ($mediaopt != rtrim($mediaopt_from_config)){
1841
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1842
									} else {
1843
										print "<option value=\"$mediaopt\" selected=\"selected\">" . gettext("$mediaopt") . "</option>";
1844
									}
1845
								}
1846
								echo '</select><br />';
1847
								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.");
1848
						echo '</div>';
1849
							echo '</td>';
1850
						echo '</tr>';
1851
						}
1852
						?>
1853
						<tr>
1854
							<td colspan="2" valign="top" height="16"></td>
1855
						</tr>
1856
						<tr style="display:none;" id="none"><td style="display:none;"></td></tr>
1857
						<tr style="display:none;" id="staticv4">
1858
							<td colspan="2" style="padding:0px;">
1859
								<a name="gatewaysection"></a>
1860
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv4">
1861
									<tr>
1862
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1863
									</tr>
1864
									<tr>
1865
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1866
										<td width="78%" class="vtable">
1867
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" />
1868
											/
1869
											<select name="subnet" class="formselect" id="subnet">
1870
												<?php
1871
												for ($i = 32; $i > 0; $i--) {
1872
													echo "<option value=\"{$i}\" ";
1873
													if ($i == $pconfig['subnet']) echo "selected=\"selected\"";
1874
													echo ">" . $i . "</option>";
1875
												}
1876
												?>
1877
											</select>
1878
										</td>
1879
									</tr>
1880
									<tr>
1881
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Upstream Gateway"); ?></td>
1882
										<td width="78%" class="vtable">
1883
											<select name="gateway" class="formselect" id="gateway">
1884
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1885
													<?php
1886
													if(count($a_gateways) > 0) {
1887
														foreach ($a_gateways as $gateway) {
1888
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1889
													?>
1890
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected=\"selected\""; ?>>
1891
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1892
															</option>
1893
													<?php
1894
															}
1895
														}
1896
													}
1897
													?>
1898
											</select>
1899
											- or  <strong><a onclick="show_add_gateway();" href="#gatewaysection"><?=gettext("add a new one."); ?></a></strong>
1900
											<br />
1901
											<div id='addgwbox'>
1902
												<?=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 />
1903
												<?=gettext("On local LANs the upstream gateway should be \"none\"."); ?>
1904
											</div>
1905
											<div id='notebox'>
1906
											</div>
1907
											<div id="status">
1908
											</div>
1909
											<div style="display:none" id="addgateway">
1910
												<p>&nbsp;</p>
1911
												<table border="1" class="addgatewaybox" summary="addgateway">
1912
													<tr>
1913
														<td>
1914
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgateway">
1915
																<tr><td>&nbsp;</td></tr>
1916
																<tr>
1917
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1918
																</tr>
1919
																<tr><td>&nbsp;</td></tr>
1920
																<?php
1921
																if($if == "wan" || $if == "WAN")
1922
																	$checked = " checked=\"checked\"";
1923
																?>
1924
																<tr>
1925
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></font></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?> /></td>
1926
																</tr>
1927
																<tr>
1928
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></font></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>" /></td>
1929
																</tr>
1930
																<tr>
1931
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></font></td><td><input id="gatewayip" name="gatewayip" /></td>
1932
																</tr>
1933
																<tr>
1934
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescr" name="gatewaydescr" /></td>
1935
																</tr>
1936
																<tr><td>&nbsp;</td></tr>
1937
																<tr>
1938
																	<td colspan="2">
1939
																		<center>
1940
																			<div id='savebuttondiv'>
1941
																				<input id="gwsave" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave();' />
1942
																				<input id="gwcancel" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway();' />
1943
																			</div>
1944
																		</center>
1945
																	</td>
1946
																</tr>
1947
																<tr><td>&nbsp;</td></tr>
1948
															</table>
1949
														</td>
1950
													</tr>
1951
												</table>
1952
											</div>
1953
										</td>
1954
									</tr>
1955
									<tr>
1956
										<td colspan="2" valign="top" height="16"></td>
1957
									</tr>
1958
								</table>
1959
							</td>
1960
						</tr>
1961
						<tr style="display:none;" id="staticv6">
1962
							<td colspan="2" style="padding:0px;">
1963
								<a name="gatewayv6section"></a>
1964
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv6">
1965
									<tr>
1966
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1967
									</tr>
1968
									<tr>
1969
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1970
										<td width="78%" class="vtable">
1971
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>" />
1972
											/
1973
											<select name="subnetv6" class="formselect" id="subnetv6">
1974
												<?php
1975
												for ($i = 128; $i > 0; $i--) {
1976
													echo "<option value=\"{$i}\" ";
1977
													if ($i == $pconfig['subnetv6']) echo "selected=\"selected\"";
1978
													echo ">" . $i . "</option>";
1979
												}
1980
												?>
1981
											</select>
1982
										</td>
1983
									</tr>
1984
									<tr>
1985
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Upstream Gateway"); ?></td>
1986
										<td width="78%" class="vtable">
1987
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1988
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1989
													<?php
1990
													if(count($a_gateways) > 0) {
1991
														foreach ($a_gateways as $gateway) {
1992
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1993
													?>
1994
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected=\"selected\""; ?>>
1995
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1996
															</option>
1997
													<?php
1998
															}
1999
														}
2000
													}
2001
													?>
2002
											</select>
2003
											- or <strong><a onclick="show_add_gateway_v6();" href="#gatewayv6section"><?=gettext("add a new one."); ?></a></strong>
2004
											<br />
2005
											<div id='addgwboxv6'>
2006
												<?=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 />
2007
												<?=gettext("On local LANs the upstream gateway should be \"none\"."); ?>
2008
											</div>
2009
											<div id='noteboxv6'>
2010
											</div>
2011
											<div id="statusv6">
2012
											</div>
2013
											<div style="display:none" id="addgatewayv6">
2014
												<p>&nbsp;</p>
2015
												<table border="1" class="addgatewaybox" summary="addgatewayv6">
2016
													<tr>
2017
														<td>
2018
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgatewayv6">
2019
																<tr><td>&nbsp;</td></tr>
2020
																<tr>
2021
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
2022
																</tr>
2023
																<tr><td>&nbsp;</td></tr>
2024
																<?php
2025
																if($if == "wan" || $if == "WAN")
2026
																	$checked = " checked=\"checked\"";
2027
																?>
2028
																<tr>
2029
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></font></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?> /></td>
2030
																</tr>
2031
																<tr>
2032
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></font></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>" /></td>
2033
																</tr>
2034
																<tr>
2035
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></font></td><td><input id="gatewayipv6" name="gatewayipv6" /></td>
2036
																</tr>
2037
																<tr>
2038
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescrv6" name="gatewaydescrv6" /></td>
2039
																</tr>
2040
																<tr><td>&nbsp;</td></tr>
2041
																<tr>
2042
																	<td colspan="2">
2043
																		<center>
2044
																			<div id='savebuttondivv6'>
2045
																				<input id="gwsavev6" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave_v6();' />
2046
																				<input id="gwcancelv6" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway_v6();' />
2047
																			</div>
2048
																		</center>
2049
																	</td>
2050
																</tr>
2051
																<tr><td>&nbsp;</td></tr>
2052
															</table>
2053
														</td>
2054
													</tr>
2055
												</table>
2056
											</div>
2057
										</td>
2058
									</tr>
2059
									<tr>
2060
										<td colspan="2" valign="top" height="16"></td>
2061
									</tr>
2062
								</table>
2063
							</td>
2064
						</tr>
2065
						<tr style="display:none;" id="dhcp">
2066
							<td colspan="2" style="padding: 0px;">
2067
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp">
2068
									<tr>
2069
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration &nbsp; &nbsp; " .
2070
										' <input name="adv_dhcp_config_advanced" type="checkbox" id="adv_dhcp_config_advanced" value="" onclick="show_adv_dhcp_config(this)" /> ' .
2071
										" Advanced &nbsp; &nbsp; " .
2072
										' <input name="adv_dhcp_config_file_override" type="checkbox" id="adv_dhcp_config_file_override" value="" onclick="show_adv_dhcp_config(this)" /> ' .
2073
										" Config File Override &nbsp; &nbsp; "); ?>
2074
										</td>
2075
									</tr>
2076
									<!-- Uncomment to expose DHCP+ in GUI
2077
									<tr>
2078
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
2079
										<td width="78%" class="vtable">
2080
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked=\"checked\""; ?> />
2081
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
2082
										<br />
2083
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
2084
										</td>
2085
									</tr>
2086
									-->
2087
									<tr style='display:none' id="show_basic_dhcphostname">
2088
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
2089
										<td width="78%" class="vtable">
2090
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>" />
2091
											<br />
2092
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
2093
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
2094
											"this (for client identification)."); ?>
2095
										</td>
2096
									</tr>
2097
									<tr style='display:none' id="show_basic_dhcpalias-address">
2098
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
2099
										<td width="78%" class="vtable">
2100
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>" />
2101
											<select name="alias-subnet" class="formselect" id="alias-subnet">
2102
												<?php
2103
												for ($i = 32; $i > 0; $i--) {
2104
													echo "<option value=\"{$i}\" ";
2105
													if ($i == $pconfig['alias-subnet']) echo "selected=\"selected\"";
2106
													echo ">" . $i . "</option>";
2107
												}
2108
												?>
2109
											</select>
2110
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
2111
											"DHCP client."); ?>
2112
										</td>
2113
									</tr>
2114
									<tr style='display:none' id="show_basic_dhcprejectlease">
2115
										<td width="22%" valign="top" class="vncell"><?=gettext("Reject Leases From"); ?></td>
2116
										<td width="78%" class="vtable">
2117
											<input name="dhcprejectfrom" type="text" class="formfld unknown" id="dhcprejectfrom" size="20" value="<?=htmlspecialchars($pconfig['dhcprejectfrom']);?>" />
2118
											<br />
2119
											<?=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."); ?>
2120
											<?=gettext("This is useful for rejecting leases from cable modems that offer private IPs when they lose upstream sync."); ?>
2121
										</td>
2122
									</tr>
2123

    
2124
									<tr style='display:none' id="show_adv_dhcp_protocol_timing">
2125
										<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>
2126
										<td width="48%" class="vtable">
2127
											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, '');" />
2128
											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, '');" />
2129
											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, '');" />
2130

    
2131
											&nbsp; &nbsp; &nbsp; &nbsp; 
2132
											Presets: &nbsp;
2133
											<input name="adv_dhcp_pt_values" type="radio" value="DHCP"	id="customdhcpptdhcpdefaults"	onclick="customdhcpptsetvalues(this, iform);" />FreeBSD Default &nbsp; 
2134
											<input name="adv_dhcp_pt_values" type="radio" value="Clear"	id="customdhcpptclear"		onclick="customdhcpptsetvalues(this, iform);" />Clear
2135

    
2136
											<br />
2137
											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, '');" />
2138
											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, '');" />
2139
											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, '');" />
2140

    
2141
											&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
2142
											<input name="adv_dhcp_pt_values" type="radio" value="pfSense"	id="customdhcpptpfsensedefaults"	onclick="customdhcpptsetvalues(this, iform);" />pfSense Default &nbsp; 
2143
											<input name="adv_dhcp_pt_values" type="radio" value="SavedCfg" checked="checked"	id="customdhcpptsavedcfg"		onclick="customdhcpptsetvalues(this, iform);" />Saved Cfg 
2144

    
2145
											<br />
2146
											<?=gettext("The values in these fields are DHCP protocol timings used when requesting a lease. <br /> " ); ?>
2147

    
2148
											<script type="text/javascript">
2149
											//<![CDATA[
2150
												function customdhcpptcheckradiobuton(T, BUTTON) {
2151
													for (var i = 0; i < T.length; i++) {
2152
														T[i].checked = false;
2153
														if (T[i].value == BUTTON) T[i].checked = true;
2154
													}
2155
													T.value = BUTTON;
2156
												}
2157

    
2158
												function customdhcpptsetvalues(T, FORM) {
2159
													// timeout, retry, select-timeout, reboot, backoff-cutoff, initial-interval
2160
													if (T.value == "DHCP")		customdhcpptsetvaluesnow(T, FORM, "60", "300", "0", "10", "120", "10");
2161
													if (T.value == "pfSense")	customdhcpptsetvaluesnow(T, FORM, "60", "15", "0", "", "", "1");
2162
													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']);?>");
2163
													if (T.value == "Clear")		customdhcpptsetvaluesnow(T, FORM, "", "", "", "", "", "");
2164
												}
2165

    
2166
												function customdhcpptsetvaluesnow(T, FORM, timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
2167
													FORM.adv_dhcp_pt_timeout.value = timeout;
2168
													FORM.adv_dhcp_pt_retry.value = retry;
2169
													FORM.adv_dhcp_pt_select_timeout.value = selecttimeout;
2170
													FORM.adv_dhcp_pt_reboot.value = reboot;
2171
													FORM.adv_dhcp_pt_backoff_cutoff.value = backoffcutoff;
2172
													FORM.adv_dhcp_pt_initial_interval.value = initialinterval;
2173

    
2174
													FORM.adv_dhcp_pt_values.value = T.value;
2175
												}
2176

    
2177
												<!-- Set the adv_dhcp_pt_values radio button from saved config -->
2178
												var RADIOBUTTON_VALUE = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values']);?>";
2179
												if (RADIOBUTTON_VALUE == "") RADIOBUTTON_VALUE = "SavedCfg";
2180
												customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, RADIOBUTTON_VALUE);
2181
											//]]>
2182
											</script>
2183
										</td>
2184
									</tr>
2185

    
2186
									<tr style='display:none' id="show_adv_dhcp_lease_requirements_and_requests">
2187
										<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>
2188
										<td width="78%" class="vtable">
2189
											<?=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 />
2190
											<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']);?>" />
2191
											<br />
2192
											<?=gettext("The values in this field are DHCP options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2193
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2194
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2195
											"Some ISPs may require certain options be or not be sent. "); ?>
2196
											<hr/>
2197
											<?=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 />
2198
											<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']);?>" />
2199
											<br />
2200
											<?=gettext("The values in this field are DHCP option 55 to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2201
											"Some ISPs may require certain options be or not be requested. "); ?>
2202
											<hr/>
2203
											<?=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 />
2204
											<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']);?>" />
2205
											<br />
2206
											<?=gettext("The values in this field are DHCP options required by the client when requesting a DHCP lease.  [option [, ...]] "); ?>
2207
										</td>
2208
									</tr>
2209

    
2210
									<tr style='display:none' id="show_adv_dhcp_option_modifiers">
2211
										<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>
2212
										<td width="78%" class="vtable">
2213
											<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']);?>" />
2214
											<br />
2215
											<?=gettext("The values in this field are DHCP option modifiers applied to obtained DHCP lease.  [modifier option declaration [, ...]] <br /> " .
2216
											"modifiers: (default, supersede, prepend, append)"); ?>
2217
										</td>
2218
									</tr>
2219

    
2220
									<tr style='display:none' id="show_adv_dhcp_config_file_override">
2221
										<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>
2222
										<td width="78%" class="vtable">
2223
 											<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']);?>" />
2224
											<br />
2225
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2226
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2227
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2228
											"Some ISPs may require certain options be or not be sent. "); ?>
2229
										</td>
2230
									</tr>
2231

    
2232
 									<tr>
2233
 										<td colspan="2" valign="top" height="16"></td>
2234
 									</tr>
2235

    
2236
								</table>
2237

    
2238
									<script type="text/javascript">
2239
									//<![CDATA[
2240
										function show_adv_dhcp_config(T) {
2241

    
2242
											if (T.checked) T.value = "Selected";
2243
											else T.value = "";
2244

    
2245
											     if (document.iform.adv_dhcp_config_file_override.checked)	show_hide_adv_dhcp('none', 'none', '');
2246
											else if (document.iform.adv_dhcp_config_advanced.checked)	show_hide_adv_dhcp('', '', 'none');
2247
											else 									show_hide_adv_dhcp('', 'none', 'none');
2248
										}
2249

    
2250
										function show_hide_adv_dhcp(basic, advanced, override) {
2251

    
2252
											document.getElementById("show_basic_dhcphostname").style.display = basic;
2253
											document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2254
											document.getElementById("show_basic_dhcprejectlease").style.display = basic;
2255

    
2256
											document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2257
											document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2258
											document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2259

    
2260
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2261
										}
2262

    
2263
										<!-- Set the adv_dhcp_config_advanced checkbox from saved config -->
2264
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_advanced']);?>" == "Selected") document.iform.adv_dhcp_config_advanced.checked = true;
2265
										show_adv_dhcp_config(document.iform.adv_dhcp_config_advanced);
2266

    
2267
										<!-- Set the adv_dhcp_config_file_override checkbox from saved config -->
2268
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override']);?>" == "Selected") document.iform.adv_dhcp_config_file_override.checked = true;
2269
										show_adv_dhcp_config(document.iform.adv_dhcp_config_file_override);
2270
									//]]>
2271
									</script>
2272

    
2273
							</td>
2274
						</tr>
2275
						<tr style="display:none;" id="dhcp6">
2276
							<td colspan="2" style="padding: 0px;">
2277
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp6">
2278
									<tr>
2279
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration &nbsp; &nbsp; " .
2280
										' <input name="adv_dhcp6_config_advanced" type="checkbox" id="adv_dhcp6_config_advanced" value="" onclick="show_adv_dhcp6_config(this)" /> ' .
2281
										" Advanced &nbsp; &nbsp; " .
2282
										' <input name="adv_dhcp6_config_file_override" type="checkbox" id="adv_dhcp6_config_file_override" value="" onclick="show_adv_dhcp6_config(this)" /> ' .
2283
										" Config File Override &nbsp; &nbsp; "); ?>
2284
										</td>
2285
									</tr>
2286
									<!--- Leave commented out for now
2287
									<tr style='display:none' id="basicdhcp6_show_dhcp6_duid">
2288
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
2289
										<td width="78%" class="vtable">
2290
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>" />
2291
											<br />
2292
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
2293
											"when requesting a DHCPv6 lease."); ?><br />
2294
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
2295
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
2296
												}
2297
												printf(gettext("The current DUID is: '%s'"),$current_duid);
2298
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
2299
											?>
2300
										</td>
2301
									</tr>
2302
									-->
2303
									<tr style='display:none' id="basicdhcp6_use_pppoeinterface">
2304
										<td width="22%" valign="top" class="vncell"><?=gettext("Use IPv4 connectivity as parent interface"); ?></td>
2305
										<td width="78%" class="vtable">
2306
											<input name="dhcp6usev4iface" type="checkbox" id="dhcp6usev4iface" value="yes" <?php if ($pconfig['dhcp6usev4iface'] == true) echo "checked=\"checked\""; ?> />
2307
											<?=gettext("Request a IPv6 prefix/information through the IPv4 connectivity link"); ?>
2308
										</td>
2309
									</tr>
2310
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_only">
2311
										<td width="22%" valign="top" class="vncell"><?=gettext("Request only an IPv6 prefix"); ?></td>
2312
										<td width="78%" class="vtable">
2313
											<input name="dhcp6prefixonly" type="checkbox" id="dhcp6prefixonly" value="yes" <?php if ($pconfig['dhcp6prefixonly'] == true) echo "checked=\"checked\""; ?> />
2314
											<?=gettext("Only request an IPv6 prefix, do not request an IPv6 address"); ?>
2315
										</td>
2316
									</tr>
2317
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_delegation_size">
2318
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
2319
										<td width="78%" class="vtable">
2320
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
2321
												<?php
2322
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
2323
												foreach($sizes as $bits => $length) {
2324
													echo "<option value=\"{$bits}\" ";
2325
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected=\"selected\"";
2326
													echo ">" . $length . "</option>";
2327
												}
2328
												?>
2329
											</select>
2330
											<br />
2331
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
2332
										</td>
2333
									</tr>
2334
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_send_hint">
2335
										<td width="22%" valign="top" class="vncell"><?=gettext("Send IPv6 prefix hint"); ?></td>
2336
										<td width="78%" class="vtable">
2337
											<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\""; ?> />
2338
											<?=gettext("Send an IPv6 prefix hint to indicate the desired prefix size for delegation"); ?>
2339
										</td>
2340
									</tr>
2341

    
2342
									<tr style='display:none' id="show_adv_dhcp6_interface_statement">
2343
										<td width="22%" valign="top" class="vncell">
2344
											<?=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+10.1-RELEASE+and+Ports#Interface_statement\">Interface Statement</a>"); ?>
2345
											<br /><br />
2346
											<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)" />
2347
											<?=gettext("Information Only"); ?>
2348
										</td>
2349
										<td width="78%" class="vtable">
2350
											<?=gettext("Send Options"); ?><br />
2351
											<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']);?>" />
2352
											<br />
2353
											<?=gettext("The values in this field are DHCP send options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2354
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2355
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2356
											"Some DHCP services may require certain options be or not be sent. "); ?>
2357
											<br />
2358
											<br />
2359
											<?=gettext("Request Options"); ?><br />
2360
											<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']);?>" />
2361
											<br />
2362
											<?=gettext("The values in this field are DHCP request options to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2363
											"Some DHCP services may require certain options be or not be requested. "); ?>
2364
											<br />
2365
											<br />
2366
											<?=gettext("Script"); ?><br />
2367
											<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']);?>" />
2368
											<br />
2369
											<?=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 />" .
2370
											"[/[dirname/[.../]]filename[.ext]] "); ?>
2371
										</td>
2372
									</tr>
2373

    
2374
									<tr style='display:none' id="show_adv_dhcp6_id_assoc_statement">
2375
										<td width="22%" valign="top" class="vncell">
2376
											<?=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+10.1-RELEASE+and+Ports#Identity_association_statement\">Identity Association Statement</a>"); ?>
2377
										</td>
2378
										<td width="78%" class="vtable">
2379

    
2380
											<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);" />
2381
											<?=gettext("Non-Temporary Address Allocation"); ?>
2382
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_address">
2383
											<?=gettext("id-assoc na"); ?>
2384
											<?=gettext("<i>ID</i>"); ?>
2385
											<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']);?>" />
2386
											<br />
2387
											<?=gettext("Address"); ?>
2388
											<?=gettext("<i>ipv6-address</i>"); ?>
2389
											<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']);?>" />
2390
											<?=gettext("<i>pltime</i>"); ?>
2391
											<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']);?>" />
2392
											<?=gettext("<i>vltime</i>"); ?>
2393
											<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']);?>" />
2394
											</div>
2395
											<hr/>
2396

    
2397
											<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)" />
2398
											<?=gettext("Prefix Delegation"); ?>
2399
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_prefix">
2400
											<?=gettext("id-assoc pd"); ?>
2401
											<?=gettext("<i>ID</i>"); ?>
2402
											<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']);?>" />
2403
											<br />
2404
											<?=gettext("Prefix"); ?>
2405
											<?=gettext("<i>ipv6-prefix</i>"); ?>
2406
											<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']);?>" />
2407
											<?=gettext("<i>pltime</i>"); ?>
2408
											<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']);?>" />
2409
											<?=gettext("<i>vltime</i>"); ?>
2410
											<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']);?>" />
2411
											</div>
2412
										</td>
2413
									</tr>
2414

    
2415
									<tr style='display:none' id="show_adv_dhcp6_prefix_interface_statement">
2416
										<td width="22%" valign="top" class="vncell">
2417
											<?=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+10.1-RELEASE+and+Ports#Prefix_interface_statement\">Prefix Interface Statement</a>"); ?>
2418
										</td>
2419
										<td width="78%" class="vtable">
2420
											<?=gettext("Prefix Interface "); ?>
2421
											<?=gettext("<i>sla-id</i>"); ?>
2422
											<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']);?>" />
2423
											<?=gettext("<i>sla-len</i>"); ?>
2424
											<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']);?>" />
2425
										</td>
2426
									</tr>
2427

    
2428
									<tr style='display:none' id="show_adv_dhcp6_authentication_statement">
2429
										<td width="22%" valign="top" class="vncell">
2430
											<?=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+10.1-RELEASE+and+Ports#Authentication_statement\">Authentication Statement</a>"); ?>
2431
										</td>
2432
										<td width="78%" class="vtable">
2433
											<?=gettext("<i>authname</i>"); ?>
2434
											<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']);?>" />
2435
											<?=gettext("<i>protocol</i>"); ?>
2436
											<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']);?>" />
2437
											<?=gettext("<i>algorithm</i>"); ?>
2438
											<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']);?>" />
2439
											<?=gettext("<i>rdm</i>"); ?>
2440
											<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']);?>" />
2441
										</td>
2442
									</tr>
2443

    
2444
									<tr style='display:none' id="show_adv_dhcp6_key_info_statement">
2445
										<td width="22%" valign="top" class="vncell">
2446
											<?=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+10.1-RELEASE+and+Ports#Keyinfo_statement\">Keyinfo Statement</a>"); ?>
2447
										</td>
2448
										<td width="78%" class="vtable">
2449
											<?=gettext("<i>keyname</i>"); ?>
2450
											<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']);?>" />
2451
											<?=gettext("<i>realm</i>"); ?>
2452
											<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']);?>" />
2453
											<br />
2454
											<?=gettext("<i>keyid</i>"); ?>
2455
											<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']);?>" />
2456
											<?=gettext("<i>secret</i>"); ?>
2457
											<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']);?>" />
2458
											<?=gettext("<i>expire</i>"); ?>
2459
											<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']);?>" />
2460
										</td>
2461
									</tr>
2462

    
2463
									<tr style='display:none' id="show_adv_dhcp6_config_file_override">
2464
										<td width="22%" valign="top" class="vncell">
2465
											<?=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+10.1-RELEASE+and+Ports\">Configuration File</a> Override"); ?>
2466
										</td>
2467
										<td width="78%" class="vtable">
2468
 											<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']);?>" />
2469
											<br />
2470
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2471
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2472
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2473
											"Some ISPs may require certain options be or not be sent. "); ?>
2474
										</td>
2475
									</tr>
2476

    
2477
 									<tr>
2478
 										<td colspan="2" valign="top" height="16"></td>
2479
 									</tr>
2480

    
2481
								</table>
2482

    
2483
									<script type="text/javascript">
2484
									//<![CDATA[
2485
										function show_adv_dhcp6_config(T) {
2486

    
2487
											if (T.checked) T.value = "Selected";
2488
											else T.value = "";
2489

    
2490
											     if (document.iform.adv_dhcp6_config_file_override.checked)	show_hide_adv_dhcp6('none', 'none', ''    );
2491
											else if (document.iform.adv_dhcp6_config_advanced.checked)		show_hide_adv_dhcp6('none', '',     'none');
2492
											else 															show_hide_adv_dhcp6('',     'none', 'none');
2493
										}
2494

    
2495
										function show_hide_adv_dhcp6(basic, advanced, override) {
2496

    
2497
											document.getElementById("basicdhcp6_use_pppoeinterface").style.display = basic;
2498
											document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2499
											document.getElementById("basicdhcp6_show_dhcp6_prefix_send_hint").style.display = basic;
2500
											document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
2501

    
2502
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2503
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2504

    
2505
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2506
											if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked)  {
2507
												document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2508
											}
2509

    
2510
											document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = 'none';
2511
											document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = 'none';
2512
											if (document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked)  {
2513
												document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = advanced;
2514
												document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = advanced;
2515
											}
2516

    
2517
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2518
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2519

    
2520
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2521
										}
2522

    
2523
										<!-- Set the adv_dhcp6_config_advanced checkbox from saved config -->
2524
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_advanced']);?>" == "Selected") document.iform.adv_dhcp6_config_advanced.checked = true;
2525
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_advanced);
2526

    
2527
										<!-- Set the adv_dhcp6_config_file_override checkbox from saved config -->
2528
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override']);?>" == "Selected") document.iform.adv_dhcp6_config_file_override.checked = true;
2529
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_file_override);
2530

    
2531
										<!-- Set the adv_dhcp6_interface_statement_information_only_enable checkbox from saved config -->
2532
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_information_only_enable']);?>" == "Selected") document.iform.adv_dhcp6_interface_statement_information_only_enable.checked = true;
2533
										show_adv_dhcp6_config(document.iform.adv_dhcp6_interface_statement_information_only_enable);
2534

    
2535
										<!-- Set the adv_dhcp6_id_assoc_statement_address_enable checkbox from saved config -->
2536
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked = true;
2537
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_address_enable);
2538

    
2539
										<!-- Set the adv_dhcp6_id_assoc_statement_prefix_enable checkbox from saved config -->
2540
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked = true;
2541
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_prefix_enable);
2542
									//]]>
2543
									</script>
2544

    
2545
							</td>
2546
						</tr>
2547
						<tr style="display:none;" id="_6rd">
2548
							<td colspan="2" style="padding: 0px;">
2549
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="6rd">
2550
									<tr>
2551
										<td colspan="2" valign="top" class="listtopic"><?=gettext("6RD Configuration"); ?></td>
2552
									</tr>
2553
									<tr>
2554
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD prefix"); ?></td>
2555
										<td width="78%" class="vtable">
2556
											<input name="prefix-6rd" type="text" class="formfld unknown" id="prefix-6rd" size="40" value="<?=htmlspecialchars($pconfig['prefix-6rd']);?>" />
2557
											<br />
2558
											<?=gettext("The value in this field is the 6RD IPv6 prefix assigned by your ISP. e.g. '2001:db8::/32'") ?><br />
2559
										</td>
2560
									</tr>
2561
									<tr>
2562
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD Border Relay"); ?></td>
2563
										<td width="78%" class="vtable">
2564
											<input name="gateway-6rd" type="text" class="formfld unknown" id="gateway-6rd" size="40" value="<?=htmlspecialchars($pconfig['gateway-6rd']);?>" />
2565
											<br />
2566
											<?=gettext("The value in this field is 6RD IPv4 gateway address assigned by your ISP") ?><br />
2567
										</td>
2568
									</tr>
2569
									<tr>
2570
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD IPv4 Prefix length"); ?></td>
2571
										<td width="78%" class="vtable">
2572
											<select name="prefix-6rd-v4plen" class="formselect" id="prefix-6rd-v4plen">
2573
												<?php
2574
												for ($i = 0; $i < 32; $i++) {
2575
													echo "<option value=\"{$i}\" ";
2576
													if (is_numeric($pconfig['prefix-6rd-v4plen']) && ($i == $pconfig['prefix-6rd-v4plen'])) echo "selected=\"selected\"";
2577
													echo ">" . $i . " bits</option>";
2578
												}
2579
												?>
2580
											</select>
2581
											<br />
2582
											<?=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."); ?>
2583
										</td>
2584
									</tr>
2585
									<tr>
2586
										<td colspan="2" valign="top" height="16"></td>
2587
									</tr>
2588
								</table>
2589
							</td>
2590
						</tr>
2591
						<tr style="display:none;" id="track6">
2592
							<td colspan="2" style="padding: 0px;">
2593
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="track6">
2594
									<tr>
2595
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
2596
									</tr>
2597
									<tr>
2598
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
2599
										<td width="78%" class="vtable">
2600
										<select name="track6-interface" id='track6-interface' class='formselect' onchange="update_track6_prefix();">
2601
										<?php
2602
											$interfaces = get_configured_interface_with_descr(false, true);
2603
											$dynv6ifs = array();
2604
											foreach ($interfaces as $iface => $ifacename) {
2605
												switch($config['interfaces'][$iface]['ipaddrv6']) {
2606
													case "6to4":
2607
													case "6rd":
2608
													case "dhcp6":
2609
														$dynv6ifs[$iface] = array(
2610
															'name' => $ifacename,
2611
															'ipv6_num_prefix_ids' => pow(2, calculate_ipv6_delegation_length($iface)) - 1
2612
														);
2613
														break;
2614
													default:
2615
														continue;
2616
												}
2617
											}
2618
											$rowIndex = 0;
2619
											foreach($dynv6ifs as $iface => $ifacedata) {
2620
												$rowIndex++;
2621
												echo "<option value=\"{$iface}\"";
2622
												if ($iface == $pconfig['track6-interface'])
2623
													echo " selected=\"selected\"";
2624
												echo ">" . htmlspecialchars($ifacedata['name']) . "</option>";
2625
											}
2626
											if ($rowIndex == 0)
2627
												echo "<option></option>";
2628
										?>
2629
										</select> <br />
2630
										<?php
2631
											foreach($dynv6ifs as $iface => $ifacedata) {
2632
												echo "<input type=\"hidden\" name=\"ipv6-num-prefix-ids-{$iface}\" id=\"ipv6-num-prefix-ids-{$iface}\" value=\"{$ifacedata['ipv6_num_prefix_ids']}\">\n";
2633
											}
2634
										?>
2635
											<br />
2636
											<?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
2637
										</td>
2638
									</tr>
2639
									<tr>
2640
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
2641
										<td width="78%" class="vtable">
2642
											<?php
2643
												if ($pconfig['track6-prefix-id'] == "")
2644
													$pconfig['track6-prefix-id'] = 0;
2645
												$track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
2646
											?>
2647
											<input name="track6-prefix-id--hex" type="text" class="formfld unknown" id="track6-prefix-id--hex" size="8" value="<?= $track6_prefix_id_hex ?>" />
2648
											<span id="track6-prefix-id-range"></span>
2649
											<input type="hidden" id="track6-prefix-id-max" value="0"></input>
2650
											<br />
2651
											<?= gettext("The value in this field is the (Delegated) IPv6 prefix ID. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
2652
											<br />
2653
											<?= gettext("default value is 0."); ?>
2654
										</td>
2655
									</tr>
2656
									<tr>
2657
										<td colspan="2" valign="top" height="16"></td>
2658
									</tr>
2659
								</table>
2660
							</td>
2661
						</tr>
2662
						<tr style="display:none;" id="ppp">
2663
							<td colspan="2" style="padding: 0px;">
2664
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="ppp">
2665
									<tr>
2666
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
2667
									</tr>
2668
									<tr id="ppp_provider">
2669
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
2670
										<td width="78%" class="vtable">
2671
											<table border="0" cellpadding="0" cellspacing="0" summary="service provider">
2672
												<tr id="trcountry">
2673
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
2674
													<td>
2675
														<select class="formselect" name="country" id="country" onchange="providers_list()">
2676
															<option></option>
2677
														</select>
2678
													</td>
2679
												</tr>
2680
												<tr id="trprovider" style="display:none">
2681
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
2682
													<td>
2683
														<select class="formselect" name="provider_list" id="provider_list" onchange="providerplan_list()">
2684
															<option></option>
2685
														</select>
2686
													</td>
2687
												</tr>
2688
												<tr id="trproviderplan" style="display:none">
2689
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
2690
													<td>
2691
														<select class="formselect" name="providerplan" id="providerplan" onchange="prefill_provider()">
2692
															<option></option>
2693
														</select>
2694
													</td>
2695
												</tr>
2696
											</table>
2697
											<br /><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
2698
										</td>
2699
									</tr>
2700
									<tr>
2701
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
2702
										<td width="78%" class="vtable">
2703
										<input name="ppp_username" type="text" class="formfld user" id="ppp_username" size="20" value="<?=htmlspecialchars($pconfig['ppp_username']);?>" />
2704
										</td>
2705
									</tr>
2706
									<tr>
2707
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
2708
										<td width="78%" class="vtable">
2709
										<input name="ppp_password" type="password" class="formfld pwd" id="ppp_password" size="20" value="<?=htmlspecialchars($pconfig['ppp_password']);?>" />
2710
										</td>
2711
									</tr>
2712
									<tr id="phone_num">
2713
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
2714
										<td width="78%" class="vtable">
2715
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>" />
2716
										</td>
2717
									</tr>
2718
									<tr id="apn_">
2719
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
2720
										<td width="78%" class="vtable">
2721
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>" />
2722
										</td>
2723
									</tr>
2724
									<tr id="interface" >
2725
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
2726
										<td width="78%" class="vtable">
2727
											<select name="port" id="port" class="formselect">
2728
											<?php
2729
												$portlist = glob("/dev/cua*");
2730
												$modems = glob("/dev/modem*");
2731
												$portlist = array_merge($portlist, $modems);
2732
												$rowIndex = 0;
2733
												foreach ($portlist as $port) {
2734
													if(preg_match("/\.(lock|init)$/", $port))
2735
														continue;
2736
													$rowIndex++;
2737
													echo "<option value=\"".trim($port)."\"";
2738
													if ($pconfig['port'] == $port)
2739
														echo " selected=\"selected\"";
2740
													echo ">{$port}</option>";
2741
												}
2742
												if ($rowIndex == 0)
2743
													echo "<option></option>";
2744
												?>
2745
											</select>
2746
										</td>
2747
									</tr>
2748
									<tr>
2749
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
2750
										<?php if (isset($pconfig['pppid'])): ?>
2751
											<td width="78%" class="vtable">
2752
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2753
											<?=gettext("to edit PPP configuration."); ?>
2754
											</td>
2755
										<?php else: ?>
2756
											<td width="78%" class="vtable">
2757
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2758
											<?=gettext("to create a PPP configuration."); ?>
2759
											</td>
2760
										<?php endif; ?>
2761
									</tr>
2762
									<tr>
2763
										<td colspan="2" valign="top" height="16"></td>
2764
									</tr>
2765
								</table>
2766
							</td>
2767
						</tr>
2768
						<tr style="display:none;" id="pppoe">
2769
							<td colspan="2" style="padding:0px;">
2770
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pppoe">
2771
									<tr>
2772
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
2773
									</tr>
2774
									<tr>
2775
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2776
										<td width="78%" class="vtable">
2777
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>" />
2778
										</td>
2779
									</tr>
2780
									<tr>
2781
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2782
										<td width="78%" class="vtable">
2783
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>" />
2784
										</td>
2785
									</tr>
2786
									<tr>
2787
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
2788
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>" />
2789
											<br /> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
2790
										</td>
2791
									</tr>
2792
									<tr>
2793
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2794
										<td width="78%" class="vtable">
2795
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked=\"checked\""; ?> />
2796
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br />
2797
											<?=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."); ?>
2798
										</td>
2799
									</tr>
2800
									<tr>
2801
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2802
										<td width="78%" class="vtable">
2803
											<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."); ?>
2804
										</td>
2805
									</tr>
2806
									<tr>
2807
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
2808
										<td width="78%" class="vtable">
2809
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%" summary="periodic reset">
2810
												<tr>
2811
													<td align="left" valign="top">
2812
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
2813
														<select style="vertical-align:top" id="reset_type" name="pppoe-reset-type" class="formselect" onchange="show_reset_settings(this.value);">
2814
															<option value=""><?=gettext("Disabled"); ?></option>
2815
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected=\"selected\""; ?>><?=gettext("Custom"); ?></option>
2816
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected=\"selected\""; ?>><?=gettext("Pre-Set"); ?></option>
2817
														</select> <?=gettext("Select a reset timing type"); ?>
2818
														</p>
2819
														<?php if ($pconfig['pppoe_pr_custom']): ?>
2820
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
2821
														<?php else: ?>
2822
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
2823
														<?php endif; ?>
2824
														<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" />
2825
														<?=gettext("hour (0-23)"); ?><br />
2826
														<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" />
2827
														<?=gettext("minute (0-59)"); ?><br />
2828
														<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']);?>" />
2829
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
2830
														<br />&nbsp;<br />
2831
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
2832
														<?=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."); ?>
2833
														</p>
2834
														<?php if ($pconfig['pppoe_pr_preset']): ?>
2835
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
2836
														<?php else: ?>
2837
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
2838
														<?php endif; ?>
2839
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
2840
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
2841
														<br />
2842
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
2843
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
2844
														<br />
2845
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
2846
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
2847
														<br />
2848
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
2849
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
2850
														</p>
2851
													</td>
2852
												</tr>
2853
											</table>
2854
										</td>
2855
									</tr>
2856

    
2857
									<tr>
2858
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
2859
										<?php if (isset($pconfig['pppid'])): ?>
2860
											<td width="78%" class="vtable">
2861
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2862
											<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
2863
											</td>
2864
										<?php else: ?>
2865
											<td width="78%" class="vtable">
2866
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2867
											<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
2868
											</td>
2869
										<?php endif; ?>
2870
									</tr>
2871
									<tr>
2872
										<td colspan="2" valign="top" height="16"></td>
2873
									</tr>
2874
								</table>
2875
							</td>
2876
						</tr>
2877
						<tr style="display:none;" id="pptp">
2878
							<td colspan="2" style="padding:0px;">
2879
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pptp">
2880
									<tr>
2881
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP/L2TP configuration"); ?></td>
2882
									</tr>
2883
									<tr>
2884
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2885
										<td width="78%" class="vtable">
2886
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>" />
2887
										</td>
2888
									</tr>
2889
									<tr>
2890
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2891
										<td width="78%" class="vtable">
2892
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>" />
2893
										</td>
2894
									</tr>
2895
									<tr>
2896
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
2897
										<td width="78%" class="vtable">
2898
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>" />
2899
											/
2900
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
2901
												<?php for ($i = 31; $i > 0; $i--): ?>
2902
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected=\"selected\""; ?>>
2903
														<?=$i;?></option>
2904
												<?php endfor; ?>
2905
											</select>
2906
										</td>
2907
									</tr>
2908
									<tr>
2909
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
2910
										<td width="78%" class="vtable">
2911
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>" />
2912
										</td>
2913
									</tr>
2914
									<tr>
2915
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2916
										<td width="78%" class="vtable">
2917
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked=\"checked\""; ?> />
2918
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br />
2919
											<?=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."); ?>
2920
										</td>
2921
									</tr>
2922
									<tr>
2923
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2924
										<td width="78%" class="vtable">
2925
											<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."); ?>
2926
										</td>
2927
									</tr>
2928
									<tr>
2929
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
2930
										<?php if (isset($pconfig['pppid'])): ?>
2931
											<td width="78%" class="vtable">
2932
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
2933
											<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
2934
											</td>
2935
										<?php else: ?>
2936
											<td width="78%" class="vtable">
2937
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
2938
											<?=gettext("for advanced PPTP and L2TP configuration options");?>.
2939
											</td>
2940
										<?php endif; ?>
2941
									</tr>
2942
									<tr>
2943
										<td colspan="2" valign="top" height="16"></td>
2944
									</tr>
2945
								</table>
2946
							</td>
2947
						</tr>
2948
						<?php
2949
							/* Wireless interface? */
2950
							if (isset($wancfg['wireless'])):
2951
						?>
2952
						<tr>
2953
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
2954
						</tr>
2955
						<tr>
2956
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
2957
							<td class="vtable">
2958
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked=\"checked\"";?> />
2959
								<br /><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
2960
							</td>
2961
						</tr>
2962
						<tr>
2963
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
2964
							<td class="vtable">
2965
							<select name="standard" class="formselect" id="standard">
2966
								<?php
2967
								$rowIndex = 0;
2968
								echo "<option ";
2969
								if ($pconfig['standard'] == "auto") {
2970
									echo "selected=\"selected\" ";
2971
								}
2972
								echo "value=\"auto\">auto</option>\n";
2973
								foreach($wl_modes as $wl_standard => $wl_channels) {
2974
									$rowIndex++;
2975
									echo "<option ";
2976
									if ($pconfig['standard'] == "$wl_standard") {
2977
										echo "selected=\"selected\" ";
2978
									}
2979
									if ($pconfig['standard'] == "") {
2980
										if ($wl_standard == "11ng") {
2981
											echo "selected=\"selected\" ";
2982
										}
2983
									}
2984
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
2985
								}
2986
								if ($rowIndex == 0)
2987
									echo "<option></option>";
2988
								?>
2989
							</select>
2990
							</td>
2991
						</tr>
2992
						<?php if (isset($wl_modes['11g'])): ?>
2993
						<tr>
2994
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
2995
							<td class="vtable">
2996
								<select name="protmode" class="formselect" id="protmode">
2997
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected=\"selected\"";?> value="off"><?=gettext("Protection mode off"); ?></option>
2998
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected=\"selected\"";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
2999
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected=\"selected\"";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
3000
								</select>
3001
								<br />
3002
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
3003
								<br />
3004
							</td>
3005
						</tr>
3006
						<?php else: ?>
3007
						<input name="protmode" type="hidden" id="protmode" value="off" />
3008
						<?php endif; ?>
3009
						<?php /* txpower is disabled because of issues with it.
3010
						<tr>
3011
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
3012
							<td class="vtable">
3013
								<select name="txpower" class="formselect" id="txpower">
3014
									<?
3015
									for($x = 99; $x > 0; $x--) {
3016
										if($pconfig["txpower"] == $x)
3017
											$SELECTED = " selected=\"selected\"";
3018
										else
3019
											$SELECTED = "";
3020
										echo "<option {$SELECTED}>{$x}</option>\n";
3021
									}
3022
									?>
3023
								</select><br />
3024
								<?=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."); ?>
3025
							</td>
3026
						</tr>*/
3027
						?>
3028
						<tr>
3029
							<td valign="top" class="vncellreq"><?=gettext("Channel"); ?></td>
3030
							<td class="vtable">
3031
								<select name="channel" class="formselect" id="channel">
3032
									<option <?php if ($pconfig['channel'] == 0) echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
3033
									<?php
3034
									foreach($wl_modes as $wl_standard => $wl_channels) {
3035
										if($wl_standard == "11g") { $wl_standard = "11b/g"; }
3036
										else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
3037
										else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
3038
										foreach($wl_channels as $wl_channel) {
3039
											echo "<option ";
3040
											if ($pconfig['channel'] == "$wl_channel") {
3041
												echo "selected=\"selected\" ";
3042
											}
3043
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
3044
											if(isset($wl_chaninfo[$wl_channel]))
3045
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
3046
											echo "</option>\n";
3047
										}
3048
									}
3049
									?>
3050
								</select>
3051
								<br />
3052
								<?=gettext("Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)"); ?>
3053
								<br />
3054
								<?=gettext("Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above."); ?>
3055
							</td>
3056
						</tr>
3057
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
3058
						<tr>
3059
							<td valign="top" class="vncell"><?=gettext("Antenna settings"); ?></td>
3060
							<td class="vtable">
3061
								<table border="0" cellpadding="0" cellspacing="0" summary="antenna settings">
3062
									<tr>
3063
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])): ?>
3064
										<td>
3065
											<?=gettext("Diversity"); ?><br />
3066
											<select name="diversity" class="formselect" id="diversity">
3067
												<option <?php if (!isset($pconfig['diversity'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3068
												<option <?php if ($pconfig['diversity'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Off"); ?></option>
3069
												<option <?php if ($pconfig['diversity'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("On"); ?></option>
3070
											</select>
3071
										</td>
3072
										<td>&nbsp;&nbsp;</td>
3073
										<?php endif; ?>
3074
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])): ?>
3075
										<td>
3076
											<?=gettext("Transmit antenna"); ?><br />
3077
											<select name="txantenna" class="formselect" id="txantenna">
3078
												<option <?php if (!isset($pconfig['txantenna'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3079
												<option <?php if ($pconfig['txantenna'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
3080
												<option <?php if ($pconfig['txantenna'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("#1"); ?></option>
3081
												<option <?php if ($pconfig['txantenna'] === '2') echo "selected=\"selected\""; ?> value="2"><?=gettext("#2"); ?></option>
3082
											</select>
3083
										</td>
3084
										<td>&nbsp;&nbsp;</td>
3085
										<?php endif; ?>
3086
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
3087
										<td>
3088
											<?=gettext("Receive antenna"); ?><br />
3089
											<select name="rxantenna" class="formselect" id="rxantenna">
3090
												<option <?php if (!isset($pconfig['rxantenna'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3091
												<option <?php if ($pconfig['rxantenna'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
3092
												<option <?php if ($pconfig['rxantenna'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("#1"); ?></option>
3093
												<option <?php if ($pconfig['rxantenna'] === '2') echo "selected=\"selected\""; ?> value="2"><?=gettext("#2"); ?></option>
3094
											</select>
3095
										</td>
3096
										<?php endif; ?>
3097
									</tr>
3098
								</table>
3099
								<br />
3100
								<?=gettext("Note: The antenna numbers do not always match up with the labels on the card."); ?>
3101
							</td>
3102
						</tr>
3103
						<?php endif; ?>
3104
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])): ?>
3105
						<tr>
3106
							<td valign="top" class="vncell"><?=gettext("Distance setting"); ?></td>
3107
							<td class="vtable">
3108
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>" />
3109
								<br />
3110
								<?=gettext("Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client"); ?><br />
3111
								<?=gettext("(measured in meters)"); ?>
3112
							</td>
3113
						</tr>
3114
						<?php endif; ?>
3115
						<tr>
3116
							<td valign="top" class="vncell"><?=gettext("Regulatory settings"); ?></td>
3117
							<td class="vtable">
3118
								<?=gettext("Regulatory domain"); ?><br />
3119
								<select name="regdomain" class="formselect" id="regdomain">
3120
									<option <?php if (empty($pconfig['regdomain'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3121
									<?php
3122
									foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
3123
										echo "<option ";
3124
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
3125
											echo "selected=\"selected\" ";
3126
										}
3127
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
3128
									}
3129
									?>
3130
								</select>
3131
								<br />
3132
								<?=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."); ?>
3133
								<br /><br />
3134
								<?=gettext("Country (listed with country code and regulatory domain)"); ?><br />
3135
								<select name="regcountry" class="formselect" id="regcountry">
3136
									<option <?php if (empty($pconfig['regcountry'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3137
									<?php
3138
									foreach($wl_countries as $wl_country_key => $wl_country) {
3139
										echo "<option ";
3140
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
3141
											echo "selected=\"selected\" ";
3142
										}
3143
										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";
3144
									}
3145
									?>
3146
								</select>
3147
								<br />
3148
								<?=gettext("Note: Any country setting other than \"Default\" will override the regulatory domain setting"); ?>.
3149
								<br /><br />
3150
								<?=gettext("Location"); ?><br />
3151
								<select name="reglocation" class="formselect" id="reglocation">
3152
									<option <?php if (empty($pconfig['reglocation'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3153
									<option <?php if ($pconfig['reglocation'] == 'indoor') echo "selected=\"selected\""; ?> value="indoor"><?=gettext("Indoor"); ?></option>
3154
									<option <?php if ($pconfig['reglocation'] == 'outdoor') echo "selected=\"selected\""; ?> value="outdoor"><?=gettext("Outdoor"); ?></option>
3155
									<option <?php if ($pconfig['reglocation'] == 'anywhere') echo "selected=\"selected\""; ?> value="anywhere"><?=gettext("Anywhere"); ?></option>
3156
								</select>
3157
								<br /><br />
3158
								<?=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."); ?>
3159
								<br />
3160
								<?=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."); ?>
3161
							</td>
3162
						</tr>
3163
						<tr>
3164
							<td colspan="2" valign="top" height="16"></td>
3165
						</tr>
3166
						<tr>
3167
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Network-specific wireless configuration");?></td>
3168
						</tr>
3169
						<tr>
3170
							<td valign="top" class="vncellreq"><?=gettext("Mode"); ?></td>
3171
							<td class="vtable">
3172
								<select name="mode" class="formselect" id="mode">
3173
									<option <?php if ($pconfig['mode'] == 'bss') echo "selected=\"selected\"";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
3174
									<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected=\"selected\"";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
3175
									<option <?php if ($pconfig['mode'] == 'hostap') echo "selected=\"selected\"";?> value="hostap"><?=gettext("Access Point"); ?></option>
3176
								</select>
3177
							</td>
3178
						</tr>
3179
						<tr>
3180
							<td valign="top" class="vncellreq"><?=gettext("SSID"); ?></td>
3181
							<td class="vtable">
3182
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>" />
3183
								<br />
3184
								<?=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"); ?>
3185
							</td>
3186
						</tr>
3187
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
3188
						<tr>
3189
							<td valign="top" class="vncell"><?=gettext("Minimum wireless standard"); ?></td>
3190
							<td class="vtable">
3191
								<select name="puremode" class="formselect" id="puremode">
3192
									<option <?php if ($pconfig['puremode'] == 'any') echo "selected=\"selected\"";?> value="any"><?=gettext("Any"); ?></option>
3193
									<?php if (isset($wl_modes['11g'])): ?>
3194
									<option <?php if ($pconfig['puremode'] == '11g') echo "selected=\"selected\"";?> value="11g"><?=gettext("802.11g"); ?></option>
3195
									<?php endif; ?>
3196
									<option <?php if ($pconfig['puremode'] == '11n') echo "selected=\"selected\"";?> value="11n"><?=gettext("802.11n"); ?></option>
3197
								</select>
3198
								<br />
3199
								<?=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)."); ?>
3200
							</td>
3201
						</tr>
3202
						<?php elseif (isset($wl_modes['11g'])): ?>
3203
						<tr>
3204
							<td valign="top" class="vncell"><?=gettext("802.11g only"); ?></td>
3205
							<td class="vtable">
3206
								<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <?php if ($pconfig['puremode'] == '11g') echo "checked=\"checked\"";?> />
3207
								<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)."); ?>
3208
							</td>
3209
						</tr>
3210
						<?php endif; ?>
3211
						<tr>
3212
							<td valign="top" class="vncell"><?=gettext("Allow intra-BSS communication"); ?></td>
3213
							<td class="vtable">
3214
								<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <?php if ($pconfig['apbridge_enable']) echo "checked=\"checked\"";?> />
3215
								<br />
3216
								<?=gettext("When operating as an access point, enable this if you want to pass packets between wireless clients directly."); ?>
3217
								<br />
3218
								<?=gettext("Disabling the internal bridging is useful when traffic is to be processed with packet filtering."); ?>
3219
							</td>
3220
						</tr>
3221
						<tr>
3222
							<td valign="top" class="vncell"><?=gettext("Enable WME"); ?></td>
3223
							<td class="vtable">
3224
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <?php if ($pconfig['wme_enable']) echo "checked=\"checked\"";?> />
3225
								<br /><?=gettext("Setting this option will force the card to use WME (wireless QoS)."); ?>
3226
							</td>
3227
						</tr>
3228
						<tr>
3229
							<td valign="top" class="vncell"><?=gettext("Enable Hide SSID"); ?></td>
3230
							<td class="vtable">
3231
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <?php if ($pconfig['hidessid_enable']) echo "checked=\"checked\"";?> />
3232
								<br />
3233
								<?=gettext("Setting this option will force the card to NOT broadcast its SSID"); ?>
3234
								<br />
3235
								<?=gettext("(this might create problems for some clients)."); ?>
3236
							</td>
3237
						</tr>
3238
						<tr>
3239
							<td valign="top" class="vncell"><?=gettext("WEP"); ?></td>
3240
							<td class="vtable">
3241
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <?php if ($pconfig['wep_enable']) echo "checked=\"checked\""; ?> />
3242
								<strong><?=gettext("Enable WEP"); ?></strong>
3243
								<table border="0" cellspacing="0" cellpadding="0" summary="wep">
3244
									<tr>
3245
										<td>&nbsp;</td>
3246
										<td>&nbsp;</td>
3247
										<td>&nbsp;<?=gettext("TX key"); ?>&nbsp;</td>
3248
									</tr>
3249
									<tr>
3250
										<td><?=gettext("Key 1:"); ?>&nbsp;&nbsp;</td>
3251
										<td>
3252
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>" />
3253
										</td>
3254
										<td align="center">
3255
											<input name="txkey" type="radio" value="1" <?php if ($pconfig['txkey'] == 1) echo "checked=\"checked\"";?> />
3256
										</td>
3257
									</tr>
3258
									<tr>
3259
										<td><?=gettext("Key 2:"); ?>&nbsp;&nbsp;</td>
3260
										<td>
3261
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>" />
3262
										</td>
3263
										<td align="center">
3264
											<input name="txkey" type="radio" value="2" <?php if ($pconfig['txkey'] == 2) echo "checked=\"checked\"";?> />
3265
										</td>
3266
									</tr>
3267
									<tr>
3268
										<td><?=gettext("Key 3:"); ?>&nbsp;&nbsp;</td>
3269
										<td>
3270
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>" />
3271
										</td>
3272
										<td align="center">
3273
											<input name="txkey" type="radio" value="3" <?php if ($pconfig['txkey'] == 3) echo "checked=\"checked\"";?> />
3274
										</td>
3275
									</tr>
3276
									<tr>
3277
										<td><?=gettext("Key 4:"); ?>&nbsp;&nbsp;</td>
3278
										<td>
3279
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>" />
3280
										</td>
3281
										<td align="center">
3282
											<input name="txkey" type="radio" value="4" <?php if ($pconfig['txkey'] == 4) echo "checked=\"checked\"";?> />
3283
										</td>
3284
									</tr>
3285
								</table>
3286
								<br />
3287
								<?=gettext("40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'."); ?><br />
3288
								<?=gettext("104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'."); ?>
3289
							</td>
3290
						</tr>
3291
						<tr>
3292
							<td valign="top" class="vncell"><?=gettext("WPA"); ?></td>
3293
							<td class="vtable">
3294
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <?php if ($pconfig['wpa_enable']) echo "checked=\"checked\""; ?> />
3295
								<strong><?=gettext("Enable WPA"); ?></strong>
3296
								<br /><br />
3297
								<table border="0" cellspacing="0" cellpadding="0" summary="wpa">
3298
									<tr>
3299
										<td>&nbsp;</td>
3300
										<td>&nbsp;<?=gettext("WPA Pre-Shared Key"); ?>&nbsp;</td>
3301
									</tr>
3302
									<tr>
3303
										<td><?=gettext("PSK:"); ?>&nbsp;&nbsp;</td>
3304
										<td>
3305
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>" />
3306
										</td>
3307
									</tr>
3308
								</table>
3309
								<br /><?=gettext("WPA Passphrase must be between 8 and 63 characters long."); ?>
3310
							</td>
3311
						</tr>
3312
						<tr>
3313
							<td valign="top" class="vncell"><?=gettext("WPA Mode"); ?></td>
3314
							<td class="vtable">
3315
								<select name="wpa_mode" class="formselect" id="wpa_mode">
3316
									<option <?php if ($pconfig['wpa_mode'] == '1') echo "selected=\"selected\"";?> value="1"><?=gettext("WPA"); ?></option>
3317
									<option <?php if ($pconfig['wpa_mode'] == '2' || !isset($pconfig['wpa_mode'])) echo "selected=\"selected\"";?> value="2"><?=gettext("WPA2"); ?></option>
3318
									<option <?php if ($pconfig['wpa_mode'] == '3') echo "selected=\"selected\"";?> value="3"><?=gettext("Both"); ?></option>
3319
								</select>
3320
							</td>
3321
						</tr>
3322
						<tr>
3323
							<td valign="top" class="vncell"><?=gettext("WPA Key Management Mode"); ?></td>
3324
							<td class="vtable">
3325
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
3326
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected=\"selected\"";?> value="WPA-PSK"><?=gettext("Pre-Shared Key"); ?></option>
3327
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected=\"selected\"";?> value="WPA-EAP"><?=gettext("Extensible Authentication Protocol"); ?></option>
3328
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected=\"selected\"";?> value="WPA-PSK WPA-EAP"><?=gettext("Both"); ?></option>
3329
								</select>
3330
							</td>
3331
						</tr>
3332
						<tr>
3333
							<td valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
3334
							<td class="vtable">
3335
								<select name="auth_algs" class="formselect" id="auth_algs">
3336
									<option <?php if ($pconfig['auth_algs'] == '1') echo "selected=\"selected\"";?> value="1"><?=gettext("Open System Authentication"); ?></option>
3337
									<option <?php if ($pconfig['auth_algs'] == '2') echo "selected=\"selected\"";?> value="2"><?=gettext("Shared Key Authentication"); ?></option>
3338
									<option <?php if ($pconfig['auth_algs'] == '3') echo "selected=\"selected\"";?> value="3"><?=gettext("Both"); ?></option>
3339
								</select>
3340
								<br /><?=gettext("Note: Shared Key Authentication requires WEP."); ?><br />
3341
							</td>
3342
						</tr>
3343
						<tr>
3344
							<td valign="top" class="vncell"><?=gettext("WPA Pairwise"); ?></td>
3345
							<td class="vtable">
3346
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
3347
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected=\"selected\"";?> value="CCMP TKIP"><?=gettext("Both"); ?></option>
3348
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP' || !isset($pconfig['wpa_pairwise'])) echo "selected=\"selected\"";?> value="CCMP"><?=gettext("AES (recommended)"); ?></option>
3349
									<option <?php if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected=\"selected\"";?> value="TKIP"><?=gettext("TKIP"); ?></option>
3350
								</select>
3351
							</td>
3352
						</tr>
3353
						<tr>
3354
							<td valign="top" class="vncell"><?=gettext("Key Rotation"); ?></td>
3355
							<td class="vtable">
3356
								<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";?>" />
3357
								<br /><?=gettext("Allowed values are 1-9999. Must be longer than Master Key Regeneration time."); ?>
3358
							</td>
3359
						</tr>
3360
						<tr>
3361
							<td valign="top" class="vncell"><?=gettext("Master Key Regeneration"); ?></td>
3362
							<td class="vtable">
3363
								<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";?>" />
3364
								<br /><?=gettext("Allowed values are 1-9999. Must be shorter than Key Rotation time."); ?>
3365
							</td>
3366
						</tr>
3367
						<tr>
3368
							<td valign="top" class="vncell"><?=gettext("Strict Key Regeneration"); ?></td>
3369
							<td class="vtable">
3370
								<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <?php if ($pconfig['wpa_strict_rekey']) echo "checked=\"checked\""; ?> />
3371
								<br /><?=gettext("Setting this option will force the AP to rekey whenever a client disassociates."); ?>
3372
							</td>
3373
						</tr>
3374
						<tr>
3375
							<td valign="top" class="vncell"><?=gettext("Enable IEEE802.1X Authentication"); ?></td>
3376
							<td class="vtable">
3377
								<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <?php if ($pconfig['ieee8021x']) echo "checked=\"checked\"";?> />
3378
								<br /><?=gettext("Setting this option will enable 802.1X authentication."); ?>
3379
								<br /><span class="red"><strong><?=gettext("NOTE"); ?>:</strong></span> <?=gettext("this option requires checking the \"Enable WPA box\"."); ?>
3380
							</td>
3381
						</tr>
3382
						<tr>
3383
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server IP Address"); ?></td>
3384
							<td class="vtable">
3385
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>" />
3386
								<br /><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
3387
							</td>
3388
						</tr>
3389
						<tr>
3390
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Port"); ?></td>
3391
							<td class="vtable">
3392
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>" />
3393
								<br /><?=gettext("Leave blank for the default port 1812."); ?>
3394
							</td>
3395
						</tr>
3396
						<tr>
3397
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Shared Secret"); ?></td>
3398
							<td class="vtable">
3399
								<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']);?>" />
3400
								<br />
3401
							</td>
3402
						</tr>
3403
						<tr>
3404
					<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server IP Address"); ?></td>
3405
							<td class="vtable">
3406
								<input name="auth_server_addr2" id="auth_server_addr2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr2']);?>" />
3407
								<br /><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
3408
							</td>
3409
						</tr>
3410
						<tr>
3411
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Port"); ?></td>
3412
							<td class="vtable">
3413
								<input name="auth_server_port2" id="auth_server_port2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port2']);?>" />
3414
								<br /><?=gettext("Leave blank for the default port 1812."); ?>
3415
							</td>
3416
						</tr>
3417
						<tr>
3418
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Shared Secret"); ?></td>
3419
							<td class="vtable">
3420
								<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']);?>" />
3421
								<br />
3422
							</td>
3423
						</tr>
3424
						<tr>
3425
							<td valign="top" class="vncell">802.1X <?=gettext("Authentication Roaming Preauth"); ?></td>
3426
							<td class="vtable">
3427
								<input name="rsn_preauth" id="rsn_preauth" type="checkbox" class="formfld unknown" size="66" value="yes" <?php if ($pconfig['rsn_preauth']) echo "checked=\"checked\""; ?> />
3428
								<br />
3429
							</td>
3430
						</tr>
3431
						<tr>
3432
							<td colspan="2" valign="top" height="16"></td>
3433
						</tr>
3434
						<?php endif; ?>
3435
						<tr>
3436
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Private networks"); ?></td>
3437
						</tr>
3438
						<tr>
3439
							<td valign="middle" class="vncell">&nbsp;</td>
3440
							<td class="vtable">
3441
								<a name="rfc1918"></a>
3442
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked=\"checked\""; ?> />
3443
								<strong><?=gettext("Block private networks"); ?></strong><br />
3444
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
3445
								"for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as"); ?>
3446
								<?=gettext("well as loopback addresses (127/8)."); ?>&nbsp;&nbsp; <?=gettext("You should generally " .
3447
								"leave this option turned on, unless your WAN network lies in such " .
3448
								"a private address space, too."); ?>
3449
							</td>
3450
						</tr>
3451
						<tr>
3452
							<td valign="middle" class="vncell">&nbsp;</td>
3453
							<td class="vtable">
3454
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked=\"checked\""; ?> />
3455
								<strong><?=gettext("Block bogon networks"); ?></strong><br />
3456
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
3457
								"(but not RFC 1918) or not yet assigned by IANA."); ?>&nbsp;&nbsp;
3458
								<?=gettext("Bogons are prefixes that should never appear in the Internet routing table, " .
3459
								"and obviously should not appear as the source address in any packets you receive."); ?>
3460
								<br /><br />
3461
								<?=gettext("Note: The update frequency can be changed under System->Advanced Firewall/NAT settings.")?>
3462
							</td>
3463
						</tr>
3464
					</table> <!-- End "allcfg" table -->
3465
					</div> <!-- End "allcfg" div -->
3466

    
3467
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="buttons">
3468
						<tr>
3469
							<td width="22%" valign="top">
3470
								&nbsp;
3471
							</td>
3472
							<td width="78%">
3473
								<br />
3474
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
3475
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
3476
								<input name="if" type="hidden" id="if" value="<?=htmlspecialchars($if);?>" />
3477
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
3478
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>" />
3479
								<?php endif; ?>
3480
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>" />
3481
							</td>
3482
						</tr>
3483
					</table>
3484
					</div>
3485
				</td>
3486
			</tr>
3487
		</table>
3488
	</form>
3489
	<script type="text/javascript">
3490
	//<![CDATA[
3491
		var gatewayip;
3492
		var name;
3493
		var gatewayipv6;
3494
		var namev6;
3495
		function show_add_gateway() {
3496
			document.getElementById("addgateway").style.display = '';
3497
			document.getElementById("addgwbox").style.display = 'none';
3498
			document.getElementById("gateway").style.display = 'none';
3499
			document.getElementById("save").style.display = 'none';
3500
			document.getElementById("cancel").style.display = 'none';
3501
			document.getElementById("gwsave").style.display = '';
3502
			document.getElementById("gwcancel").style.display = '';
3503
			jQuery('#notebox').html("");
3504
		}
3505
		function show_add_gateway_v6() {
3506
			document.getElementById("addgatewayv6").style.display = '';
3507
			document.getElementById("addgwboxv6").style.display = 'none';
3508
			document.getElementById("gatewayv6").style.display = 'none';
3509
			document.getElementById("save").style.display = 'none';
3510
			document.getElementById("cancel").style.display = 'none';
3511
			document.getElementById("gwsave").style.display = '';
3512
			document.getElementById("gwcancel").style.display = '';
3513
			jQuery('#noteboxv6').html("");
3514
		}
3515
		function hide_add_gateway() {
3516
			document.getElementById("addgateway").style.display = 'none';
3517
			document.getElementById("addgwbox").style.display = '';
3518
			document.getElementById("gateway").style.display = '';
3519
			document.getElementById("save").style.display = '';
3520
			document.getElementById("cancel").style.display = '';
3521
			document.getElementById("gwsave").style.display = '';
3522
			document.getElementById("gwcancel").style.display = '';
3523
			jQuery('#status').html('');
3524
		}
3525
		function hide_add_gateway_v6() {
3526
			document.getElementById("addgatewayv6").style.display = 'none';
3527
			document.getElementById("addgwboxv6").style.display = '';
3528
			document.getElementById("gatewayv6").style.display = '';
3529
			document.getElementById("save").style.display = '';
3530
			document.getElementById("cancel").style.display = '';
3531
			document.getElementById("gwsave").style.display = '';
3532
			document.getElementById("gwcancel").style.display = '';
3533
			jQuery('#statusv6').html('');
3534
		}
3535
		function hide_add_gatewaysave() {
3536
			document.getElementById("addgateway").style.display = 'none';
3537
			jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
3538
			var iface = jQuery('#if').val();
3539
			name = jQuery('#name').val();
3540
			var descr = jQuery('#gatewaydescr').val();
3541
			gatewayip = jQuery('#gatewayip').val();
3542

    
3543
			var defaultgw = '';
3544
			if (jQuery('#defaultgw').is(':checked'))
3545
				defaultgw = '&defaultgw=on';
3546
			var url = "system_gateways_edit.php";
3547
			var pars = 'isAjax=true&ipprotocol=inet' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3548
			jQuery.ajax(
3549
				url,
3550
				{
3551
					type: 'post',
3552
					data: pars,
3553
					error: report_failure,
3554
					success: save_callback
3555
				});
3556
		}
3557
		function hide_add_gatewaysave_v6() {
3558
			document.getElementById("addgatewayv6").style.display = 'none';
3559
			jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
3560
			var iface = jQuery('#if').val();
3561
			name = jQuery('#namev6').val();
3562
			var descr = jQuery('#gatewaydescrv6').val();
3563
			gatewayip = jQuery('#gatewayipv6').val();
3564
			var defaultgw = '';
3565
			if (jQuery('#defaultgwv6').is(':checked'))
3566
				defaultgw = '&defaultgw=on';
3567
			var url_v6 = "system_gateways_edit.php";
3568
			var pars_v6 = 'isAjax=true&ipprotocol=inet6' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3569
			jQuery.ajax(
3570
				url_v6,
3571
				{
3572
					type: 'post',
3573
					data: pars_v6,
3574
					error: report_failure_v6,
3575
					success: save_callback_v6
3576
				});
3577
		}
3578
		function addOption(selectbox,text,value)
3579
		{
3580
			var optn = document.createElement("OPTION");
3581
			optn.text = text;
3582
			optn.value = value;
3583
			selectbox.append(optn);
3584
			selectbox.prop('selectedIndex',selectbox.children().length-1);
3585
			jQuery('#notebox').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3586
		}
3587
		function addOption_v6(selectbox,text,value)
3588
		{
3589
			var optn = document.createElement("OPTION");
3590
			optn.text = text;
3591
			optn.value = value;
3592
			selectbox.append(optn);
3593
			selectbox.prop('selectedIndex',selectbox.children().length-1);
3594
			jQuery('#noteboxv6').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3595
		}
3596
		function report_failure(request, textStatus, errorThrown) {
3597
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3598
				alert(request.responseText);
3599
			} else {
3600
				alert("Sorry, we could not create your IPv4 gateway at this time.");
3601
			}
3602
			hide_add_gateway();
3603
		}
3604
		function report_failure_v6(request, textStatus, errorThrown) {
3605
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3606
				alert(request.responseText);
3607
			} else {
3608
				alert("Sorry, we could not create your IPv6 gateway at this time.");
3609
			}
3610
			hide_add_gateway_v6();
3611
		}
3612
		function save_callback(response) {
3613
			if(response) {
3614
				document.getElementById("addgateway").style.display = 'none';
3615
				hide_add_gateway();
3616
				var gwtext = escape(name) + " - " + gatewayip;
3617
				addOption(jQuery('#gateway'), gwtext, name);
3618
				// Auto submit form?
3619
				//document.iform.submit();
3620
				//jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader /">');
3621
			} else {
3622
				report_failure();
3623
			}
3624
		}
3625
		function show_advanced_media() {
3626
			document.getElementById("showadvmediabox").innerHTML='';
3627
			aodiv = document.getElementById('showmediaadv');
3628
			aodiv.style.display = "block";
3629
		}
3630
		function save_callback_v6(response_v6) {
3631
			if(response_v6) {
3632
				document.getElementById("addgatewayv6").style.display = 'none';
3633
				hide_add_gateway_v6();
3634
				var gwtext_v6 = escape(name) + " - " + gatewayip;
3635
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
3636
				// Auto submit form?
3637
				//document.iform.submit();
3638
				//jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" />');
3639
			} else {
3640
				report_failure_v6();
3641
			}
3642
		}
3643
		<?php
3644
		echo "show_allcfg(document.iform.enable);";
3645
		echo "updateType('{$pconfig['type']}');\n";
3646
		echo "updateTypeSix('{$pconfig['type6']}');\n";
3647
		?>
3648
	//]]>
3649
	</script>
3650
	<?php include("fend.inc"); ?>
3651
	</body>
3652
</html>
(95-95/256)