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
			break;
580
		case "6rd":
581
			foreach ($ifdescrs as $ifent => $ifdescr) {
582
				if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
583
					if ($config[interfaces][$ifent]['prefix-6rd'] == $_POST['prefix-6rd']) {
584
						$input_errors[] = gettext("You can only have one interface configured in 6rd with same prefix.");
585
						break;
586
					}
587
				}
588
			}
589
			if (in_array($wancfg['ipaddrv6'], array()))
590
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
591
			break;
592
		case "6to4":
593
			foreach ($ifdescrs as $ifent => $ifdescr) {
594
				if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
595
					$input_errors[] = sprintf(gettext("You can only have one interface configured as 6to4."),$_POST['type6']);
596
					break;
597
				}
598
			}
599
			if (in_array($wancfg['ipaddrv6'], array()))
600
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
601
			break;
602
		case "track6":
603
			/* needs to check if $track6-prefix-id is used on another interface */
604
			if (in_array($wancfg['ipaddrv6'], array()))
605
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
606

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

    
628

    
629
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
630
	$staticroutes = get_staticroutes(true);
631
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
632
	if ($_POST['ipaddr']) {
633
		if (!is_ipaddrv4($_POST['ipaddr']))
634
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
635
		else {
636
			if (is_ipaddr_configured($_POST['ipaddr'], $if, true))
637
				$input_errors[] = gettext("This IPv4 address is being used by another interface or VIP.");
638

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

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

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

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

    
736
		unset($min_mtu, $max_mtu);
737

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

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

    
756
				if ($parent_realhwif != $wancfg['if'])
757
					continue;
758

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

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

    
925
		unset($wancfg['adv_dhcp_pt_timeout']);
926
		unset($wancfg['adv_dhcp_pt_retry']);
927
		unset($wancfg['adv_dhcp_pt_select_timeout']);
928
		unset($wancfg['adv_dhcp_pt_reboot']);
929
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
930
		unset($wancfg['adv_dhcp_pt_initial_interval']);
931

    
932
		unset($wancfg['adv_dhcp_pt_values']);
933

    
934
		unset($wancfg['adv_dhcp_send_options']);
935
		unset($wancfg['adv_dhcp_request_options']);
936
		unset($wancfg['adv_dhcp_required_options']);
937
		unset($wancfg['adv_dhcp_option_modifiers']);
938

    
939
		unset($wancfg['adv_dhcp_config_advanced']);
940
		unset($wancfg['adv_dhcp_config_file_override']);
941
		unset($wancfg['adv_dhcp_config_file_override_path']);
942

    
943
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
944
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
945
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
946
		unset($wancfg['adv_dhcp6_interface_statement_script']);
947

    
948
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
949
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
950
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
951
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
952
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
953

    
954
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
955
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
956
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
957
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
958
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
959

    
960
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
961
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
962

    
963
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
964
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
965
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
966
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
967

    
968
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
969
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
970
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
971
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
972
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
973

    
974
		unset($wancfg['adv_dhcp6_config_advanced']);
975
		unset($wancfg['adv_dhcp6_config_file_override']);
976
		unset($wancfg['adv_dhcp6_config_file_override_path']);
977

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

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

    
1008
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
1009
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
1010

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

    
1027
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
1028
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
1029
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
1030
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
1031
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
1032
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
1033

    
1034
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
1035

    
1036
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
1037
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
1038
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
1039
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
1040

    
1041
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
1042
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
1043
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
1044

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

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

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

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

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

    
1153
				if (isset($_POST['adv_dhcp6_id_assoc_statement_address_enable']))
1154
					$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1155
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address']))
1156
					$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1157
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_id']))
1158
					$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1159
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_pltime']))
1160
					$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1161
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_vltime']))
1162
					$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1163

    
1164
				if (isset($_POST['adv_dhcp6_id_assoc_statement_prefix_enable']))
1165
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1166
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix']))
1167
					$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1168
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_id']))
1169
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1170
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_pltime']))
1171
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1172
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_vltime']))
1173
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1174

    
1175
				if (!empty($_POST['adv_dhcp6_prefix_interface_statement_sla_id']))
1176
					$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1177
				if (!empty($_POST['adv_dhcp6_prefix_interface_statement_sla_len']))
1178
					$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1179

    
1180
				if (!empty($_POST['adv_dhcp6_authentication_statement_authname']))
1181
					$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1182
				if (!empty($_POST['adv_dhcp6_authentication_statement_protocol']))
1183
					$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1184
				if (!empty($_POST['adv_dhcp6_authentication_statement_algorithm']))
1185
					$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1186
				if (!empty($_POST['adv_dhcp6_authentication_statement_rdm']))
1187
					$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1188

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

    
1200
				if (!empty($_POST['adv_dhcp6_config_advanced']))
1201
					$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1202
				if (!empty($_POST['adv_dhcp6_config_file_override']))
1203
					$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1204
				if (!empty($_POST['adv_dhcp6_config_file_override_path']))
1205
					$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1206

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

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

    
1272
		conf_mount_ro();
1273
		write_config();
1274

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

    
1284
		mark_subsystem_dirty('interfaces');
1285

    
1286
		/* regenerate cron settings/crontab file */
1287
		configure_cron();
1288

    
1289
		header("Location: interfaces.php?if={$if}");
1290
		exit;
1291
	}
1292

    
1293
} // end if($_POST)
1294

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

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

    
1436
function check_wireless_mode() {
1437
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1438

    
1439
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1440
		return;
1441

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

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

    
1479
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1480
$shortcut_section = "interfaces";
1481

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

    
1487
?>
1488

    
1489
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1490
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1491
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1492
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1493

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

    
1566
	function show_allcfg(obj) {
1567
		if (obj.checked)
1568
			jQuery('#allcfg').show();
1569
		else
1570
			jQuery('#allcfg').hide();
1571
	}
1572

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

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

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

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

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

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

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

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

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

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

    
2121
											<br />
2122
											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, '');" />
2123
											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, '');" />
2124
											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, '');" />
2125

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

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

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

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

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

    
2159
													FORM.adv_dhcp_pt_values.value = T.value;
2160
												}
2161

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

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

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

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

    
2217
 									<tr>
2218
 										<td colspan="2" valign="top" height="16"></td>
2219
 									</tr>
2220

    
2221
								</table>
2222

    
2223
									<script type="text/javascript">
2224
									//<![CDATA[
2225
										function show_adv_dhcp_config(T) {
2226

    
2227
											if (T.checked) T.value = "Selected";
2228
											else T.value = "";
2229

    
2230
											     if (document.iform.adv_dhcp_config_file_override.checked)	show_hide_adv_dhcp('none', 'none', '');
2231
											else if (document.iform.adv_dhcp_config_advanced.checked)	show_hide_adv_dhcp('', '', 'none');
2232
											else 									show_hide_adv_dhcp('', 'none', 'none');
2233
										}
2234

    
2235
										function show_hide_adv_dhcp(basic, advanced, override) {
2236

    
2237
											document.getElementById("show_basic_dhcphostname").style.display = basic;
2238
											document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2239
											document.getElementById("show_basic_dhcprejectlease").style.display = basic;
2240

    
2241
											document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2242
											document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2243
											document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2244

    
2245
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2246
										}
2247

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

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

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

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

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

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

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

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

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

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

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

    
2462
 									<tr>
2463
 										<td colspan="2" valign="top" height="16"></td>
2464
 									</tr>
2465

    
2466
								</table>
2467

    
2468
									<script type="text/javascript">
2469
									//<![CDATA[
2470
										function show_adv_dhcp6_config(T) {
2471

    
2472
											if (T.checked) T.value = "Selected";
2473
											else T.value = "";
2474

    
2475
											     if (document.iform.adv_dhcp6_config_file_override.checked)	show_hide_adv_dhcp6('none', 'none', ''    );
2476
											else if (document.iform.adv_dhcp6_config_advanced.checked)		show_hide_adv_dhcp6('none', '',     'none');
2477
											else 															show_hide_adv_dhcp6('',     'none', 'none');
2478
										}
2479

    
2480
										function show_hide_adv_dhcp6(basic, advanced, override) {
2481

    
2482
											document.getElementById("basicdhcp6_use_pppoeinterface").style.display = basic;
2483
											document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2484
											document.getElementById("basicdhcp6_show_dhcp6_prefix_send_hint").style.display = basic;
2485
											document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
2486

    
2487
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2488
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2489

    
2490
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2491
											if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked)  {
2492
												document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2493
											}
2494

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

    
2502
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2503
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2504

    
2505
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2506
										}
2507

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

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

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

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

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

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

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

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

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