Project

General

Profile

Download (180 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
			if (is_ipaddr_configured($_POST['ipaddr'], $if, true))
640
				$input_errors[] = gettext("This IPv4 address is being used by another interface or VIP.");
641

    
642
			/* Do not accept network or broadcast address, except if subnet is 31 or 32 */
643
			if ($_POST['subnet'] < 31) {
644
				if ($_POST['ipaddr'] == gen_subnet($_POST['ipaddr'], $_POST['subnet']))
645
					$input_errors[] = gettext("This IPv4 address is the network address and cannot be used");
646
				else if ($_POST['ipaddr'] == gen_subnet_max($_POST['ipaddr'], $_POST['subnet']))
647
					$input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used");
648
			}
649

    
650
			foreach ($staticroutes as $route_subnet) {
651
				list($network, $subnet) = explode("/", $route_subnet);
652
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
653
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
654
					break;
655
				}
656
				unset($network, $subnet);
657
			}
658
		}
659
	}
660
	if ($_POST['ipaddrv6']) {
661
		if (!is_ipaddrv6($_POST['ipaddrv6']))
662
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
663
		else {
664
			if (is_ipaddr_configured($_POST['ipaddrv6'], $if, true))
665
				$input_errors[] = gettext("This IPv6 address is being used by another interface or VIP.");
666

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

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

    
739
		unset($min_mtu, $max_mtu);
740

    
741
		if (stristr($wancfg['if'], "_vlan")) {
742
			$realhwif_array = get_parent_interface($wancfg['if']);
743
			// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
744
			$parent_realhwif = $realhwif_array[0];
745
			$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
746
			if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) {
747
				if ($_POST['mtu'] > intval($config['interfaces'][$parent_if]['mtu']))
748
					$input_errors[] = gettext("The MTU of a VLAN cannot be greater than that of its parent interface.");
749
			}
750
		} else {
751
			foreach ($config['interfaces'] as $idx => $ifdata) {
752
				if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if']))
753
					continue;
754

    
755
				$realhwif_array = get_parent_interface($ifdata['if']);
756
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
757
				$parent_realhwif = $realhwif_array[0];
758

    
759
				if ($parent_realhwif != $wancfg['if'])
760
					continue;
761

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

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

    
928
		unset($wancfg['adv_dhcp_pt_timeout']);
929
		unset($wancfg['adv_dhcp_pt_retry']);
930
		unset($wancfg['adv_dhcp_pt_select_timeout']);
931
		unset($wancfg['adv_dhcp_pt_reboot']);
932
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
933
		unset($wancfg['adv_dhcp_pt_initial_interval']);
934

    
935
		unset($wancfg['adv_dhcp_pt_values']);
936

    
937
		unset($wancfg['adv_dhcp_send_options']);
938
		unset($wancfg['adv_dhcp_request_options']);
939
		unset($wancfg['adv_dhcp_required_options']);
940
		unset($wancfg['adv_dhcp_option_modifiers']);
941

    
942
		unset($wancfg['adv_dhcp_config_advanced']);
943
		unset($wancfg['adv_dhcp_config_file_override']);
944
		unset($wancfg['adv_dhcp_config_file_override_path']);
945

    
946
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
947
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
948
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
949
		unset($wancfg['adv_dhcp6_interface_statement_script']);
950

    
951
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
952
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
953
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
954
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
955
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
956

    
957
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
958
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
959
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
960
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
961
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
962

    
963
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
964
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
965

    
966
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
967
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
968
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
969
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
970

    
971
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
972
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
973
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
974
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
975
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
976

    
977
		unset($wancfg['adv_dhcp6_config_advanced']);
978
		unset($wancfg['adv_dhcp6_config_file_override']);
979
		unset($wancfg['adv_dhcp6_config_file_override_path']);
980

    
981
		unset($wancfg['pppoe_password']);
982
		unset($wancfg['pptp_username']);
983
		unset($wancfg['pptp_password']);
984
		unset($wancfg['provider']);
985
		unset($wancfg['ondemand']);
986
		unset($wancfg['timeout']);
987
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
988
			unset($wancfg['pppoe']['pppoe-reset-type']);
989
		unset($wancfg['local']);
990

    
991
		unset($wancfg['remote']);
992
		if (is_array($a_ppps[$pppid]) && in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
993
			if ($wancfg['ipaddr'] != 'ppp') {
994
				unset($a_ppps[$pppid]['apn']);
995
				unset($a_ppps[$pppid]['phone']);
996
				unset($a_ppps[$pppid]['provider']);
997
				unset($a_ppps[$pppid]['ondemand']);
998
			}
999
			if (in_array($wancfg['ipaddr'], array("pppoe", "pptp", "l2tp"))) {
1000
				unset($a_ppps[$pppid]['localip']);
1001
				unset($a_ppps[$pppid]['subnet']);
1002
				unset($a_ppps[$pppid]['gateway']);
1003
			}
1004
			if ($wancfg['ipaddr'] != 'pppoe')
1005
				unset($a_ppps[$pppid]['pppoe-reset-type']);
1006
			if ($wancfg['type'] != $_POST['type']) {
1007
				unset($a_ppps[$pppid]['idletimeout']);
1008
			}
1009
		}
1010

    
1011
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
1012
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
1013

    
1014
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
1015
		switch($_POST['type']) {
1016
			case "staticv4":
1017
				$wancfg['ipaddr'] = $_POST['ipaddr'];
1018
				$wancfg['subnet'] = $_POST['subnet'];
1019
				if ($_POST['gateway'] != "none") {
1020
					$wancfg['gateway'] = $_POST['gateway'];
1021
				}
1022
				break;
1023
			case "dhcp":
1024
				$wancfg['ipaddr'] = "dhcp";
1025
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
1026
				$wancfg['alias-address'] = $_POST['alias-address'];
1027
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
1028
				$wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom'];
1029

    
1030
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
1031
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
1032
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
1033
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
1034
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
1035
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
1036

    
1037
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
1038

    
1039
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
1040
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
1041
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
1042
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
1043

    
1044
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
1045
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
1046
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
1047

    
1048
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
1049
				if($gateway_item) {
1050
					$a_gateways[] = $gateway_item;
1051
				}
1052
				break;
1053
			case "ppp":
1054
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1055
				$a_ppps[$pppid]['type'] = $_POST['type'];
1056
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1057
				$a_ppps[$pppid]['ports'] = $_POST['port'];
1058
				$a_ppps[$pppid]['username'] = $_POST['ppp_username'];
1059
				$a_ppps[$pppid]['password'] = base64_encode($_POST['ppp_password']);
1060
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
1061
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
1062
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
1063
				$wancfg['ipaddr'] = $_POST['type'];
1064
				break;
1065

    
1066
			case "pppoe":
1067
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1068
				$a_ppps[$pppid]['type'] = $_POST['type'];
1069
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1070
				if (isset($_POST['ppp_port']))
1071
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
1072
				else
1073
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
1074
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
1075
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
1076
				if (!empty($_POST['provider']))
1077
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
1078
				else
1079
					$a_ppps[$pppid]['provider'] = true;
1080
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
1081
				if (!empty($_POST['pppoe_idletimeout']))
1082
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
1083
				else
1084
					unset($a_ppps[$pppid]['idletimeout']);
1085

    
1086
				if (!empty($_POST['pppoe-reset-type']))
1087
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
1088
				else
1089
					unset($a_ppps[$pppid]['pppoe-reset-type']);
1090
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1091
				$wancfg['ipaddr'] = $_POST['type'];
1092
				if($gateway_item) {
1093
					$a_gateways[] = $gateway_item;
1094
				}
1095

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

    
1147
				if (!empty($_POST['adv_dhcp6_interface_statement_send_options']))
1148
					$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1149
				if (!empty($_POST['adv_dhcp6_interface_statement_request_options']))
1150
					$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1151
				if (isset($_POST['adv_dhcp6_interface_statement_information_only_enable']))
1152
					$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1153
				if (!empty($_POST['adv_dhcp6_interface_statement_script']))
1154
					$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1155

    
1156
				if (isset($_POST['adv_dhcp6_id_assoc_statement_address_enable']))
1157
					$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1158
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address']))
1159
					$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1160
				if (is_numericint($_POST['adv_dhcp6_id_assoc_statement_address_id']))
1161
					$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1162
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_pltime']))
1163
					$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1164
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_vltime']))
1165
					$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1166

    
1167
				if (isset($_POST['adv_dhcp6_id_assoc_statement_prefix_enable']))
1168
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1169
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix']))
1170
					$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1171
				if (is_numericint($_POST['adv_dhcp6_id_assoc_statement_prefix_id']))
1172
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1173
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_pltime']))
1174
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1175
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_vltime']))
1176
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1177

    
1178
				if (is_numericint($_POST['adv_dhcp6_prefix_interface_statement_sla_id']))
1179
					$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1180
				if (is_numericint($_POST['adv_dhcp6_prefix_interface_statement_sla_len']))
1181
					$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1182

    
1183
				if (!empty($_POST['adv_dhcp6_authentication_statement_authname']))
1184
					$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1185
				if (!empty($_POST['adv_dhcp6_authentication_statement_protocol']))
1186
					$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1187
				if (!empty($_POST['adv_dhcp6_authentication_statement_algorithm']))
1188
					$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1189
				if (!empty($_POST['adv_dhcp6_authentication_statement_rdm']))
1190
					$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1191

    
1192
				if (!empty($_POST['adv_dhcp6_key_info_statement_keyname']))
1193
					$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1194
				if (!empty($_POST['adv_dhcp6_key_info_statement_realm']))
1195
					$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1196
				if (!empty($_POST['adv_dhcp6_key_info_statement_keyid']))
1197
					$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1198
				if (!empty($_POST['adv_dhcp6_key_info_statement_secret']))
1199
					$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1200
				if (!empty($_POST['adv_dhcp6_key_info_statement_expire']))
1201
					$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1202

    
1203
				if (!empty($_POST['adv_dhcp6_config_advanced']))
1204
					$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1205
				if (!empty($_POST['adv_dhcp6_config_file_override']))
1206
					$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1207
				if (!empty($_POST['adv_dhcp6_config_file_override_path']))
1208
					$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1209

    
1210
				if($gateway_item) {
1211
					$a_gateways[] = $gateway_item;
1212
				}
1213
				break;
1214
			case "6rd":
1215
				$wancfg['ipaddrv6'] = "6rd";
1216
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
1217
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
1218
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
1219
				if($gateway_item) {
1220
					$a_gateways[] = $gateway_item;
1221
				}
1222
				break;
1223
			case "6to4":
1224
				$wancfg['ipaddrv6'] = "6to4";
1225
				break;
1226
			case "track6":
1227
				$wancfg['ipaddrv6'] = "track6";
1228
				$wancfg['track6-interface'] = $_POST['track6-interface'];
1229
				if ($_POST['track6-prefix-id--hex'] === "")
1230
					$wancfg['track6-prefix-id'] = 0;
1231
				else if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
1232
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
1233
				else
1234
					$wancfg['track6-prefix-id'] = 0;
1235
				break;
1236
			case "none":
1237
				break;
1238
		}
1239
		handle_pppoe_reset($_POST);
1240

    
1241
		if($_POST['blockpriv'] == "yes") {
1242
			$wancfg['blockpriv'] = true;
1243
		} else {
1244
			unset($wancfg['blockpriv']);
1245
		}
1246
		if($_POST['blockbogons'] == "yes") {
1247
			$wancfg['blockbogons'] = true;
1248
		} else {
1249
			unset($wancfg['blockbogons']);
1250
		}
1251
		$wancfg['spoofmac'] = $_POST['spoofmac'];
1252
		if (empty($_POST['mtu'])) {
1253
			unset($wancfg['mtu']);
1254
		} else {
1255
			$wancfg['mtu'] = $_POST['mtu'];
1256
		}
1257
		if (empty($_POST['mss'])) {
1258
			unset($wancfg['mss']);
1259
		} else {
1260
			$wancfg['mss'] = $_POST['mss'];
1261
		}
1262
		if (empty($_POST['mediaopt'])) {
1263
			unset($wancfg['media']);
1264
			unset($wancfg['mediaopt']);
1265
		} else {
1266
			$mediaopts = explode(' ', $_POST['mediaopt']);
1267
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
1268
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
1269
			else { unset($wancfg['mediaopt']); }
1270
		}
1271
		if (isset($wancfg['wireless'])) {
1272
			handle_wireless_post();
1273
		}
1274

    
1275
		conf_mount_ro();
1276
		write_config();
1277

    
1278
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
1279
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
1280
		} else {
1281
			$toapplylist = array();
1282
		}
1283
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
1284
		$toapplylist[$if]['ppps'] = $old_ppps;
1285
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
1286

    
1287
		mark_subsystem_dirty('interfaces');
1288

    
1289
		/* regenerate cron settings/crontab file */
1290
		configure_cron();
1291

    
1292
		header("Location: interfaces.php?if={$if}");
1293
		exit;
1294
	}
1295

    
1296
} // end if($_POST)
1297

    
1298
function handle_wireless_post() {
1299
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
1300
	if (!is_array($wancfg['wireless']))
1301
		$wancfg['wireless'] = array();
1302
	$wancfg['wireless']['standard'] = $_POST['standard'];
1303
	$wancfg['wireless']['mode'] = $_POST['mode'];
1304
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
1305
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
1306
	$wancfg['wireless']['channel'] = $_POST['channel'];
1307
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
1308
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
1309
	$wancfg['wireless']['distance'] = $_POST['distance'];
1310
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
1311
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
1312
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
1313
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
1314
		foreach($wl_countries_attr as $wl_country) {
1315
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
1316
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
1317
				break;
1318
			}
1319
		}
1320
	}
1321
	if (!is_array($wancfg['wireless']['wpa']))
1322
		$wancfg['wireless']['wpa'] = array();
1323
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
1324
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
1325
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
1326
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
1327
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
1328
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
1329
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
1330
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
1331
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
1332
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
1333
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
1334
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
1335
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
1336
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
1337
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
1338

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

    
1439
function check_wireless_mode() {
1440
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1441

    
1442
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1443
		return;
1444

    
1445
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1446
		$clone_count = 1;
1447
	else
1448
		$clone_count = 0;
1449
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1450
		foreach ($config['wireless']['clone'] as $clone) {
1451
			if ($clone['if'] == $wlanbaseif)
1452
				$clone_count++;
1453
		}
1454
	}
1455
	if ($clone_count > 1) {
1456
		$old_wireless_mode = $wancfg['wireless']['mode'];
1457
		$wancfg['wireless']['mode'] = $_POST['mode'];
1458
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1459
			$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']]);
1460
		} else {
1461
			mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy");
1462
		}
1463
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1464
	}
1465
}
1466

    
1467
// Find all possible media options for the interface
1468
$mediaopts_list = array();
1469
$intrealname = $config['interfaces'][$if]['if'];
1470
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1471
foreach ($mediaopts as $mediaopt){
1472
	preg_match("/media (.*)/", $mediaopt, $matches);
1473
	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1474
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1475
		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1476
	}else{
1477
		// there is only media like "media 1000baseT"
1478
		array_push($mediaopts_list, $matches[1]);
1479
	}
1480
}
1481

    
1482
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1483
$shortcut_section = "interfaces";
1484

    
1485
$closehead = false;
1486
include("head.inc");
1487
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1488
$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"));
1489

    
1490
?>
1491

    
1492
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1493
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1494
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1495
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1496

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

    
1569
	function show_allcfg(obj) {
1570
		if (obj.checked)
1571
			jQuery('#allcfg').show();
1572
		else
1573
			jQuery('#allcfg').hide();
1574
	}
1575

    
1576
	function show_reset_settings(reset_type) {
1577
		if (reset_type == 'preset') {
1578
			jQuery('#pppoepresetwrap').show();
1579
			jQuery('#pppoecustomwrap').hide();
1580
		}
1581
		else if (reset_type == 'custom') {
1582
			jQuery('#pppoecustomwrap').show();
1583
			jQuery('#pppoepresetwrap').hide();
1584
		} else {
1585
			jQuery('#pppoecustomwrap').hide();
1586
			jQuery('#pppoepresetwrap').hide();
1587
		}
1588
	}
1589
	function show_mon_config() {
1590
		jQuery("#showmonbox").html('');
1591
		jQuery('#showmon').css('display','block');
1592
	}
1593

    
1594
	function openwindow(url) {
1595
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1596
		if (oWin==null || typeof(oWin)=="undefined")
1597
			return false;
1598
		else
1599
			return true;
1600
	}
1601
	function country_list() {
1602
		jQuery('#country').children().remove();
1603
		jQuery('#provider_list').children().remove();
1604
		jQuery('#providerplan').children().remove();
1605
		jQuery.ajax("getserviceproviders.php",{
1606
			success: function(response) {
1607
				var responseTextArr = response.split("\n");
1608
				responseTextArr.sort();
1609
				responseTextArr.each( function(value) {
1610
					var option = new Element('option');
1611
					country = value.split(":");
1612
					option.text = country[0];
1613
					option.value = country[1];
1614
					jQuery('#country').append(option);
1615
				});
1616
			}
1617
		});
1618
		jQuery('#trcountry').css('display',"table-row");
1619
	}
1620

    
1621
	function providers_list() {
1622
		jQuery('#provider_list').children().remove();
1623
		jQuery('#providerplan').children().remove();
1624
		jQuery.ajax("getserviceproviders.php",{
1625
			type: 'post',
1626
			data: {country : jQuery('#country').val()},
1627
			success: function(response) {
1628
				var responseTextArr = response.split("\n");
1629
				responseTextArr.sort();
1630
				responseTextArr.each( function(value) {
1631
					var option = new Element('option');
1632
					option.text = value;
1633
					option.value = value;
1634
					jQuery('#provider_list').append(option);
1635
				});
1636
			}
1637
		});
1638
		jQuery('#trprovider').css("display","table-row");
1639
		jQuery('#trproviderplan').css("display","none");
1640
	}
1641

    
1642
	function providerplan_list() {
1643
		jQuery('#providerplan').children().remove();
1644
		jQuery('#providerplan').append( new Element('option') );
1645
		jQuery.ajax("getserviceproviders.php",{
1646
			type: 'post',
1647
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val()},
1648
			success: function(response) {
1649
				var responseTextArr = response.split("\n");
1650
				responseTextArr.sort();
1651
				responseTextArr.each( function(value) {
1652
					if(value != "") {
1653
						providerplan = value.split(":");
1654

    
1655
						var option = new Element('option');
1656
						option.text = providerplan[0] + " - " + providerplan[1];
1657
						option.value = providerplan[1];
1658
						jQuery('#providerplan').append(option);
1659
					}
1660
				});
1661
			}
1662
		});
1663
		jQuery('#trproviderplan').css("display","table-row");
1664
	}
1665

    
1666
	function prefill_provider() {
1667
		jQuery.ajax("getserviceproviders.php",{
1668
			type: 'post',
1669
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val(), plan : jQuery('#providerplan').val()},
1670
			success: function(data,textStatus,response) {
1671
				var xmldoc = response.responseXML;
1672
				var provider = xmldoc.getElementsByTagName('connection')[0];
1673
				jQuery('#ppp_username').val('');
1674
				jQuery('#ppp_password').val('');
1675
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1676
					jQuery('#phone').val('#777');
1677
					jQuery('#apn').val('');
1678
				} else {
1679
					jQuery('#phone').val('*99#');
1680
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1681
				}
1682
				ppp_username = provider.getElementsByTagName('ppp_username')[0].firstChild.data;
1683
				ppp_password = provider.getElementsByTagName('ppp_password')[0].firstChild.data;
1684
				jQuery('#ppp_username').val(ppp_username);
1685
				jQuery('#ppp_password').val(ppp_password);
1686
			}
1687
		});
1688
	}
1689

    
1690
	function update_track6_prefix() {
1691
		var iface = jQuery("#track6-interface").val();
1692
		if (iface == null)
1693
			return;
1694
		var track6_prefix_ids = jQuery('#ipv6-num-prefix-ids-' + iface).val();
1695
		if (track6_prefix_ids == null)
1696
			return;
1697
		track6_prefix_ids = parseInt(track6_prefix_ids).toString(16);
1698
		jQuery('#track6-prefix-id-range').html('(<b>hexadecimal</b> from 0 to ' + track6_prefix_ids + ')');
1699
	}
1700

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

    
2112
									<tr style='display:none' id="show_adv_dhcp_protocol_timing">
2113
										<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>
2114
										<td width="48%" class="vtable">
2115
											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, '');" />
2116
											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, '');" />
2117
											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, '');" />
2118

    
2119
											&nbsp; &nbsp; &nbsp; &nbsp; 
2120
											Presets: &nbsp;
2121
											<input name="adv_dhcp_pt_values" type="radio" value="DHCP"	id="customdhcpptdhcpdefaults"	onclick="customdhcpptsetvalues(this, iform);" />FreeBSD Default &nbsp; 
2122
											<input name="adv_dhcp_pt_values" type="radio" value="Clear"	id="customdhcpptclear"		onclick="customdhcpptsetvalues(this, iform);" />Clear
2123

    
2124
											<br />
2125
											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, '');" />
2126
											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, '');" />
2127
											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, '');" />
2128

    
2129
											&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
2130
											<input name="adv_dhcp_pt_values" type="radio" value="pfSense"	id="customdhcpptpfsensedefaults"	onclick="customdhcpptsetvalues(this, iform);" />pfSense Default &nbsp; 
2131
											<input name="adv_dhcp_pt_values" type="radio" value="SavedCfg" checked="checked"	id="customdhcpptsavedcfg"		onclick="customdhcpptsetvalues(this, iform);" />Saved Cfg 
2132

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

    
2136
											<script type="text/javascript">
2137
											//<![CDATA[
2138
												function customdhcpptcheckradiobuton(T, BUTTON) {
2139
													for (var i = 0; i < T.length; i++) {
2140
														T[i].checked = false;
2141
														if (T[i].value == BUTTON) T[i].checked = true;
2142
													}
2143
													T.value = BUTTON;
2144
												}
2145

    
2146
												function customdhcpptsetvalues(T, FORM) {
2147
													// timeout, retry, select-timeout, reboot, backoff-cutoff, initial-interval
2148
													if (T.value == "DHCP")		customdhcpptsetvaluesnow(T, FORM, "60", "300", "0", "10", "120", "10");
2149
													if (T.value == "pfSense")	customdhcpptsetvaluesnow(T, FORM, "60", "15", "0", "", "", "1");
2150
													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']);?>");
2151
													if (T.value == "Clear")		customdhcpptsetvaluesnow(T, FORM, "", "", "", "", "", "");
2152
												}
2153

    
2154
												function customdhcpptsetvaluesnow(T, FORM, timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
2155
													FORM.adv_dhcp_pt_timeout.value = timeout;
2156
													FORM.adv_dhcp_pt_retry.value = retry;
2157
													FORM.adv_dhcp_pt_select_timeout.value = selecttimeout;
2158
													FORM.adv_dhcp_pt_reboot.value = reboot;
2159
													FORM.adv_dhcp_pt_backoff_cutoff.value = backoffcutoff;
2160
													FORM.adv_dhcp_pt_initial_interval.value = initialinterval;
2161

    
2162
													FORM.adv_dhcp_pt_values.value = T.value;
2163
												}
2164

    
2165
												<!-- Set the adv_dhcp_pt_values radio button from saved config -->
2166
												var RADIOBUTTON_VALUE = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values']);?>";
2167
												if (RADIOBUTTON_VALUE == "") RADIOBUTTON_VALUE = "SavedCfg";
2168
												customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, RADIOBUTTON_VALUE);
2169
											//]]>
2170
											</script>
2171
										</td>
2172
									</tr>
2173

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

    
2198
									<tr style='display:none' id="show_adv_dhcp_option_modifiers">
2199
										<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>
2200
										<td width="78%" class="vtable">
2201
											<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']);?>" />
2202
											<br />
2203
											<?=gettext("The values in this field are DHCP option modifiers applied to obtained DHCP lease.  [modifier option declaration [, ...]] <br /> " .
2204
											"modifiers: (default, supersede, prepend, append)"); ?>
2205
										</td>
2206
									</tr>
2207

    
2208
									<tr style='display:none' id="show_adv_dhcp_config_file_override">
2209
										<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>
2210
										<td width="78%" class="vtable">
2211
 											<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']);?>" />
2212
											<br />
2213
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2214
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2215
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2216
											"Some ISPs may require certain options be or not be sent. "); ?>
2217
										</td>
2218
									</tr>
2219

    
2220
 									<tr>
2221
 										<td colspan="2" valign="top" height="16"></td>
2222
 									</tr>
2223

    
2224
								</table>
2225

    
2226
									<script type="text/javascript">
2227
									//<![CDATA[
2228
										function show_adv_dhcp_config(T) {
2229

    
2230
											if (T.checked) T.value = "Selected";
2231
											else T.value = "";
2232

    
2233
											     if (document.iform.adv_dhcp_config_file_override.checked)	show_hide_adv_dhcp('none', 'none', '');
2234
											else if (document.iform.adv_dhcp_config_advanced.checked)	show_hide_adv_dhcp('', '', 'none');
2235
											else 									show_hide_adv_dhcp('', 'none', 'none');
2236
										}
2237

    
2238
										function show_hide_adv_dhcp(basic, advanced, override) {
2239

    
2240
											document.getElementById("show_basic_dhcphostname").style.display = basic;
2241
											document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2242
											document.getElementById("show_basic_dhcprejectlease").style.display = basic;
2243

    
2244
											document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2245
											document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2246
											document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2247

    
2248
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2249
										}
2250

    
2251
										<!-- Set the adv_dhcp_config_advanced checkbox from saved config -->
2252
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_advanced']);?>" == "Selected") document.iform.adv_dhcp_config_advanced.checked = true;
2253
										show_adv_dhcp_config(document.iform.adv_dhcp_config_advanced);
2254

    
2255
										<!-- Set the adv_dhcp_config_file_override checkbox from saved config -->
2256
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override']);?>" == "Selected") document.iform.adv_dhcp_config_file_override.checked = true;
2257
										show_adv_dhcp_config(document.iform.adv_dhcp_config_file_override);
2258
									//]]>
2259
									</script>
2260

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

    
2330
									<tr style='display:none' id="show_adv_dhcp6_interface_statement">
2331
										<td width="22%" valign="top" class="vncell">
2332
											<?=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>"); ?>
2333
											<br /><br />
2334
											<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)" />
2335
											<?=gettext("Information Only"); ?>
2336
										</td>
2337
										<td width="78%" class="vtable">
2338
											<?=gettext("Send Options"); ?><br />
2339
											<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']);?>" />
2340
											<br />
2341
											<?=gettext("The values in this field are DHCP send options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2342
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2343
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2344
											"Some DHCP services may require certain options be or not be sent. "); ?>
2345
											<br />
2346
											<br />
2347
											<?=gettext("Request Options"); ?><br />
2348
											<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']);?>" />
2349
											<br />
2350
											<?=gettext("The values in this field are DHCP request options to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2351
											"Some DHCP services may require certain options be or not be requested. "); ?>
2352
											<br />
2353
											<br />
2354
											<?=gettext("Script"); ?><br />
2355
											<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']);?>" />
2356
											<br />
2357
											<?=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 />" .
2358
											"[/[dirname/[.../]]filename[.ext]] "); ?>
2359
										</td>
2360
									</tr>
2361

    
2362
									<tr style='display:none' id="show_adv_dhcp6_id_assoc_statement">
2363
										<td width="22%" valign="top" class="vncell">
2364
											<?=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>"); ?>
2365
										</td>
2366
										<td width="78%" class="vtable">
2367

    
2368
											<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);" />
2369
											<?=gettext("Non-Temporary Address Allocation"); ?>
2370
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_address">
2371
											<?=gettext("id-assoc na"); ?>
2372
											<?=gettext("<i>ID</i>"); ?>
2373
											<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']);?>" />
2374
											<br />
2375
											<?=gettext("Address"); ?>
2376
											<?=gettext("<i>ipv6-address</i>"); ?>
2377
											<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']);?>" />
2378
											<?=gettext("<i>pltime</i>"); ?>
2379
											<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']);?>" />
2380
											<?=gettext("<i>vltime</i>"); ?>
2381
											<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']);?>" />
2382
											</div>
2383
											<hr/>
2384

    
2385
											<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)" />
2386
											<?=gettext("Prefix Delegation"); ?>
2387
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_prefix">
2388
											<?=gettext("id-assoc pd"); ?>
2389
											<?=gettext("<i>ID</i>"); ?>
2390
											<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']);?>" />
2391
											<br />
2392
											<?=gettext("Prefix"); ?>
2393
											<?=gettext("<i>ipv6-prefix</i>"); ?>
2394
											<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']);?>" />
2395
											<?=gettext("<i>pltime</i>"); ?>
2396
											<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']);?>" />
2397
											<?=gettext("<i>vltime</i>"); ?>
2398
											<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']);?>" />
2399
											</div>
2400
										</td>
2401
									</tr>
2402

    
2403
									<tr style='display:none' id="show_adv_dhcp6_prefix_interface_statement">
2404
										<td width="22%" valign="top" class="vncell">
2405
											<?=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>"); ?>
2406
										</td>
2407
										<td width="78%" class="vtable">
2408
											<?=gettext("Prefix Interface "); ?>
2409
											<?=gettext("<i>sla-id</i>"); ?>
2410
											<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']);?>" />
2411
											<?=gettext("<i>sla-len</i>"); ?>
2412
											<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']);?>" />
2413
										</td>
2414
									</tr>
2415

    
2416
									<tr style='display:none' id="show_adv_dhcp6_authentication_statement">
2417
										<td width="22%" valign="top" class="vncell">
2418
											<?=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>"); ?>
2419
										</td>
2420
										<td width="78%" class="vtable">
2421
											<?=gettext("<i>authname</i>"); ?>
2422
											<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']);?>" />
2423
											<?=gettext("<i>protocol</i>"); ?>
2424
											<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']);?>" />
2425
											<?=gettext("<i>algorithm</i>"); ?>
2426
											<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']);?>" />
2427
											<?=gettext("<i>rdm</i>"); ?>
2428
											<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']);?>" />
2429
										</td>
2430
									</tr>
2431

    
2432
									<tr style='display:none' id="show_adv_dhcp6_key_info_statement">
2433
										<td width="22%" valign="top" class="vncell">
2434
											<?=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>"); ?>
2435
										</td>
2436
										<td width="78%" class="vtable">
2437
											<?=gettext("<i>keyname</i>"); ?>
2438
											<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']);?>" />
2439
											<?=gettext("<i>realm</i>"); ?>
2440
											<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']);?>" />
2441
											<br />
2442
											<?=gettext("<i>keyid</i>"); ?>
2443
											<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']);?>" />
2444
											<?=gettext("<i>secret</i>"); ?>
2445
											<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']);?>" />
2446
											<?=gettext("<i>expire</i>"); ?>
2447
											<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']);?>" />
2448
										</td>
2449
									</tr>
2450

    
2451
									<tr style='display:none' id="show_adv_dhcp6_config_file_override">
2452
										<td width="22%" valign="top" class="vncell">
2453
											<?=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"); ?>
2454
										</td>
2455
										<td width="78%" class="vtable">
2456
 											<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']);?>" />
2457
											<br />
2458
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2459
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2460
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2461
											"Some ISPs may require certain options be or not be sent. "); ?>
2462
										</td>
2463
									</tr>
2464

    
2465
 									<tr>
2466
 										<td colspan="2" valign="top" height="16"></td>
2467
 									</tr>
2468

    
2469
								</table>
2470

    
2471
									<script type="text/javascript">
2472
									//<![CDATA[
2473
										function show_adv_dhcp6_config(T) {
2474

    
2475
											if (T.checked) T.value = "Selected";
2476
											else T.value = "";
2477

    
2478
											     if (document.iform.adv_dhcp6_config_file_override.checked)	show_hide_adv_dhcp6('none', 'none', ''    );
2479
											else if (document.iform.adv_dhcp6_config_advanced.checked)		show_hide_adv_dhcp6('none', '',     'none');
2480
											else 															show_hide_adv_dhcp6('',     'none', 'none');
2481
										}
2482

    
2483
										function show_hide_adv_dhcp6(basic, advanced, override) {
2484

    
2485
											document.getElementById("basicdhcp6_use_pppoeinterface").style.display = basic;
2486
											document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2487
											document.getElementById("basicdhcp6_show_dhcp6_prefix_send_hint").style.display = basic;
2488
											document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
2489

    
2490
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2491
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2492

    
2493
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2494
											if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked)  {
2495
												document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2496
											}
2497

    
2498
											document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = 'none';
2499
											document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = 'none';
2500
											if (document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked)  {
2501
												document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = advanced;
2502
												document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = advanced;
2503
											}
2504

    
2505
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2506
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2507

    
2508
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2509
										}
2510

    
2511
										<!-- Set the adv_dhcp6_config_advanced checkbox from saved config -->
2512
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_advanced']);?>" == "Selected") document.iform.adv_dhcp6_config_advanced.checked = true;
2513
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_advanced);
2514

    
2515
										<!-- Set the adv_dhcp6_config_file_override checkbox from saved config -->
2516
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override']);?>" == "Selected") document.iform.adv_dhcp6_config_file_override.checked = true;
2517
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_file_override);
2518

    
2519
										<!-- Set the adv_dhcp6_interface_statement_information_only_enable checkbox from saved config -->
2520
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_information_only_enable']);?>" == "Selected") document.iform.adv_dhcp6_interface_statement_information_only_enable.checked = true;
2521
										show_adv_dhcp6_config(document.iform.adv_dhcp6_interface_statement_information_only_enable);
2522

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

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

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

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

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

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