Project

General

Profile

Download (172 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / interfaces.php @ a1b66bec

1
<?php
2
/* $Id$ */
3
/*
4
	interfaces.php
5
	Copyright (C) 2004-2008 Scott Ullrich
6
	Copyright (C) 2006 Daniel S. Haischt.
7
	Copyright (C) 2008-2010 Ermal Luçi
8
	All rights reserved.
9

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

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

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

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

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

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

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

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

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

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

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

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

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

    
79
if (!is_array($config['ppps']['ppp']))
80
	$config['ppps']['ppp'] = array();
81

    
82
$a_ppps = &$config['ppps']['ppp'];
83

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

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

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

    
102
foreach ($a_ppps as $pppid => $ppp) {
103
	if ($wancfg['if'] == $ppp['if'])
104
		break;
105
}
106

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

    
109
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
110
	$pconfig['pppid'] = $pppid;
111
	$pconfig['ptpid'] = $a_ppps[$pppid]['ptpid'];
112
	$pconfig['port'] = $a_ppps[$pppid]['ports'];
113
	if ($a_ppps[$pppid]['type'] == "ppp") {
114
		$pconfig['username'] = $a_ppps[$pppid]['username'];
115
		$pconfig['password'] = base64_decode($a_ppps[$pppid]['password']);
116

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

    
127
		/* ================================================ */
128
		/* = force a connection reset at a specific time? = */
129
		/* ================================================ */
130

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

    
187
$pconfig['adv_dhcp_pt_timeout'] = $wancfg['adv_dhcp_pt_timeout'];
188
$pconfig['adv_dhcp_pt_retry'] = $wancfg['adv_dhcp_pt_retry'];
189
$pconfig['adv_dhcp_pt_select_timeout'] = $wancfg['adv_dhcp_pt_select_timeout'];
190
$pconfig['adv_dhcp_pt_reboot'] = $wancfg['adv_dhcp_pt_reboot'];
191
$pconfig['adv_dhcp_pt_backoff_cutoff'] = $wancfg['adv_dhcp_pt_backoff_cutoff'];
192
$pconfig['adv_dhcp_pt_initial_interval'] = $wancfg['adv_dhcp_pt_initial_interval'];
193

    
194
$pconfig['adv_dhcp_pt_values'] = $wancfg['adv_dhcp_pt_values'];
195

    
196
$pconfig['adv_dhcp_send_options'] = $wancfg['adv_dhcp_send_options'];
197
$pconfig['adv_dhcp_request_options'] = $wancfg['adv_dhcp_request_options'];
198
$pconfig['adv_dhcp_required_options'] = $wancfg['adv_dhcp_required_options'];
199
$pconfig['adv_dhcp_option_modifiers'] = $wancfg['adv_dhcp_option_modifiers'];
200

    
201
$pconfig['adv_dhcp_config_advanced'] = $wancfg['adv_dhcp_config_advanced'];
202
$pconfig['adv_dhcp_config_file_override'] = $wancfg['adv_dhcp_config_file_override'];
203
$pconfig['adv_dhcp_config_file_override_path'] = $wancfg['adv_dhcp_config_file_override_path'];
204

    
205
$pconfig['adv_dhcp6_interface_statement_send_options'] = $wancfg['adv_dhcp6_interface_statement_send_options'];
206
$pconfig['adv_dhcp6_interface_statement_request_options'] = $wancfg['adv_dhcp6_interface_statement_request_options'];
207
$pconfig['adv_dhcp6_interface_statement_information_only_enable'] = $wancfg['adv_dhcp6_interface_statement_information_only_enable'];
208
$pconfig['adv_dhcp6_interface_statement_script'] = $wancfg['adv_dhcp6_interface_statement_script'];
209

    
210
$pconfig['adv_dhcp6_id_assoc_statement_address_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_address_enable'];
211
$pconfig['adv_dhcp6_id_assoc_statement_address'] = $wancfg['adv_dhcp6_id_assoc_statement_address'];
212
$pconfig['adv_dhcp6_id_assoc_statement_address_id'] = $wancfg['adv_dhcp6_id_assoc_statement_address_id'];
213
$pconfig['adv_dhcp6_id_assoc_statement_address_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_pltime'];
214
$pconfig['adv_dhcp6_id_assoc_statement_address_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_vltime'];
215

    
216
$pconfig['adv_dhcp6_id_assoc_statement_prefix_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'];
217
$pconfig['adv_dhcp6_id_assoc_statement_prefix'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix'];
218
$pconfig['adv_dhcp6_id_assoc_statement_prefix_id'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_id'];
219
$pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'];
220
$pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'];
221

    
222
$pconfig['adv_dhcp6_prefix_interface_statement_sla_id'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_id'];
223
$pconfig['adv_dhcp6_prefix_interface_statement_sla_len'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_len'];
224

    
225
$pconfig['adv_dhcp6_authentication_statement_authname'] = $wancfg['adv_dhcp6_authentication_statement_authname'];
226
$pconfig['adv_dhcp6_authentication_statement_protocol'] = $wancfg['adv_dhcp6_authentication_statement_protocol'];
227
$pconfig['adv_dhcp6_authentication_statement_algorithm'] = $wancfg['adv_dhcp6_authentication_statement_algorithm'];
228
$pconfig['adv_dhcp6_authentication_statement_rdm'] = $wancfg['adv_dhcp6_authentication_statement_rdm'];
229

    
230
$pconfig['adv_dhcp6_key_info_statement_keyname'] = $wancfg['adv_dhcp6_key_info_statement_keyname'];
231
$pconfig['adv_dhcp6_key_info_statement_realm'] = $wancfg['adv_dhcp6_key_info_statement_realm'];
232
$pconfig['adv_dhcp6_key_info_statement_keyid'] = $wancfg['adv_dhcp6_key_info_statement_keyid'];
233
$pconfig['adv_dhcp6_key_info_statement_secret'] = $wancfg['adv_dhcp6_key_info_statement_secret'];
234
$pconfig['adv_dhcp6_key_info_statement_expire'] = $wancfg['adv_dhcp6_key_info_statement_expire'];
235

    
236
$pconfig['adv_dhcp6_config_advanced'] = $wancfg['adv_dhcp6_config_advanced'];
237
$pconfig['adv_dhcp6_config_file_override'] = $wancfg['adv_dhcp6_config_file_override'];
238
$pconfig['adv_dhcp6_config_file_override_path'] = $wancfg['adv_dhcp6_config_file_override_path'];
239

    
240
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
241
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
242
$pconfig['enable'] = isset($wancfg['enable']);
243

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

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

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

    
318
// print_r($pconfig);
319

    
320
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
321
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
322
$pconfig['spoofmac'] = $wancfg['spoofmac'];
323
$pconfig['mtu'] = $wancfg['mtu'];
324
$pconfig['mss'] = $wancfg['mss'];
325

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

    
409
$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']);
410
$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
411

    
412
if ($_POST['apply']) {
413
	unset($input_errors);
414
	if (!is_subsystem_dirty('interfaces'))
415
		$intput_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
			}
429
		}
430
		/* restart snmp so that it binds to correct address */
431
		services_snmpd_configure();
432

    
433
		/* sync filter configuration */
434
		setup_gateways_monitor();
435

    
436
		clear_subsystem_dirty('interfaces');
437

    
438
		filter_configure();
439

    
440
		enable_rrd_graphing();
441

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

    
467
	unset($input_errors);
468
	$pconfig = $_POST;
469

    
470
	if (isset($_POST['track6-interface'])) {
471
		$ipv6_delegation_length = calculate_ipv6_delegation_length($_POST['track6-interface']);
472
		$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
473
	}
474

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

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

    
484
	/* okay first of all, cause we are just hiding the PPPoE HTML
485
	 * fields releated to PPPoE resets, we are going to unset $_POST
486
	 * vars, if the reset feature should not be used. Otherwise the
487
	 * data validation procedure below, may trigger a false error
488
	 * message.
489
	 */
490
	if (empty($_POST['pppoe-reset-type'])) {
491
		unset($_POST['pppoe_pr_type']);
492
		unset($_POST['pppoe_resethour']);
493
		unset($_POST['pppoe_resetminute']);
494
		unset($_POST['pppoe_resetdate']);
495
		unset($_POST['pppoe_pr_preset_val']);
496
	}
497
	/* description unique? */
498
	foreach ($ifdescrs as $ifent => $ifdescr) {
499
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
500
			$input_errors[] = gettext("An interface with the specified description already exists.");
501
			break;
502
		}
503
	}
504
	/* input validation */
505
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^staticv4/", $_POST['type'])))
506
		$input_errors[] = gettext("The DHCP Server is active on this interface and it can be used only with a static IP configuration. Please disable the DHCP Server service on this interface first, then change the interface configuration.");
507
	if (isset($config['dhcpdv6']) && isset($config['dhcpdv6'][$if]['enable']) && (! preg_match("/^staticv6/", $_POST['type6'])))
508
		$input_errors[] = gettext("The DHCP6 Server is active on this interface and it can be used only with a static IPv6 configuration. Please disable the DHCPv6 Server service on this interface first, then change the interface configuration.");
509

    
510
	switch(strtolower($_POST['type'])) {
511
		case "staticv4":
512
			$reqdfields = explode(" ", "ipaddr subnet gateway");
513
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
514
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
515
			break;
516
		case "none":
517
			if(is_array($config['virtualip']['vip'])) {
518
				foreach ($config['virtualip']['vip'] as $vip) {
519
					if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if)
520
						$input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration.");
521
				}
522
			}
523
		case "dhcp":
524
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp")))
525
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
526
			break;
527
		case "ppp":
528
			$reqdfields = explode(" ", "port phone");
529
			$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
530
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
531
			break;
532
		case "pppoe":
533
			if ($_POST['pppoe_dialondemand']) {
534
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
535
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
536
			} else {
537
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
538
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
539
			}
540
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
541
			break;
542
		case "pptp":
543
			if ($_POST['pptp_dialondemand']) {
544
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
545
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
546
			} else {
547
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
548
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
549
			}
550
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
551
			break;
552
		case "l2tp":
553
			if ($_POST['pptp_dialondemand']) {
554
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
555
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
556
			} else {
557
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
558
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"));
559
			}
560
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
561
			break;
562
	}
563
	switch(strtolower($_POST['type6'])) {
564
		case "staticv6":
565
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
566
			$reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
567
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
568
			break;
569
		case "none":
570
			if(is_array($config['virtualip']['vip'])) {
571
				foreach ($config['virtualip']['vip'] as $vip) {
572
					if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if)
573
						$input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration.");
574
				}
575
			}
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 >= $ipv6_num_prefix_ids) {
612
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.");
613
				}
614
			}
615
			break;
616
	}
617

    
618

    
619
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
620
	$staticroutes = get_staticroutes(true);
621
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
622
	if ($_POST['ipaddr']) {
623
		if (!is_ipaddrv4($_POST['ipaddr']))
624
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
625
		else {
626
			if (is_ipaddr_configured($_POST['ipaddr'], $if, true))
627
				$input_errors[] = gettext("This IPv4 address is being used by another interface or VIP.");
628

    
629
			/* Do not accept network or broadcast address, except if subnet is 31 or 32 */
630
			if ($_POST['subnet'] < 31) {
631
				if ($_POST['ipaddr'] == gen_subnet($_POST['ipaddr'], $_POST['subnet']))
632
					$input_errors[] = gettext("This IPv4 address is the network address and cannot be used");
633
				else if ($_POST['ipaddr'] == gen_subnet_max($_POST['ipaddr'], $_POST['subnet']))
634
					$input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used");
635
			}
636

    
637
			foreach ($staticroutes as $route_subnet) {
638
				list($network, $subnet) = explode("/", $route_subnet);
639
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
640
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
641
					break;
642
				}
643
				unset($network, $subnet);
644
			}
645
		}
646
	}
647
	if ($_POST['ipaddrv6']) {
648
		if (!is_ipaddrv6($_POST['ipaddrv6']))
649
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
650
		else {
651
			if (is_ipaddr_configured($_POST['ipaddrv6'], $if, true))
652
				$input_errors[] = gettext("This IPv6 address is being used by another interface or VIP.");
653

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

    
721
		if ($_POST['mtu'] < $min_mtu || $_POST['mtu'] > $max_mtu)
722
			$input_errors[] = sprintf(gettext("The MTU must be from %d to %d bytes."), $min_mtu, $max_mtu);
723

    
724
		unset($min_mtu, $max_mtu);
725

    
726
		if (stristr($wancfg['if'], "_vlan")) {
727
			$realhwif_array = get_parent_interface($wancfg['if']);
728
			// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
729
			$parent_realhwif = $realhwif_array[0];
730
			$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
731
			if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) {
732
				if ($_POST['mtu'] > intval($config['interfaces'][$parent_if]['mtu']))
733
					$input_errors[] = gettext("MTU of a vlan should not be bigger than parent interface.");
734
			}
735
		} else {
736
			foreach ($config['interfaces'] as $idx => $ifdata) {
737
				if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if']))
738
					continue;
739

    
740
				$realhwif_array = get_parent_interface($ifdata['if']);
741
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
742
				$parent_realhwif = $realhwif_array[0];
743

    
744
				if ($parent_realhwif != $wancfg['if'])
745
					continue;
746

    
747
				if (isset($ifdata['mtu']) && $ifdata['mtu'] > $_POST['mtu'])
748
					$input_errors[] = sprintf(gettext("Interface %s (VLAN) has MTU set to a bigger value"), $ifdata['descr']);
749
			}
750
		}
751
	}
752
	if ($_POST['mss'] && ($_POST['mss'] < 576))
753
		$input_errors[] = gettext("The MSS must be greater than 576 bytes.");
754
	/* Wireless interface? */
755
	if (isset($wancfg['wireless'])) {
756
		$reqdfields = array("mode");
757
		$reqdfieldsn = array(gettext("Mode"));
758
		if ($_POST['mode'] == 'hostap') {
759
			$reqdfields[] = "ssid";
760
			$reqdfieldsn[] = gettext("SSID");
761
		}
762
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
763
		check_wireless_mode();
764
		/* loop through keys and enforce size */
765
		for ($i = 1; $i <= 4; $i++) {
766
			if ($_POST['key' . $i]) {
767
				/* 64 bit */
768
				if (strlen($_POST['key' . $i]) == 5)
769
					continue;
770
				if (strlen($_POST['key' . $i]) == 10) {
771
					/* hex key */
772
					if (stristr($_POST['key' . $i], "0x") == false) {
773
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
774
					}
775
					continue;
776
				}
777
				if (strlen($_POST['key' . $i]) == 12) {
778
					/* hex key */
779
					if(stristr($_POST['key' . $i], "0x") == false) {
780
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
781
					}
782
					continue;
783
				}
784
				/* 128 bit */
785
				if (strlen($_POST['key' . $i]) == 13)
786
					continue;
787
				if (strlen($_POST['key' . $i]) == 26) {
788
					/* hex key */
789
					if (stristr($_POST['key' . $i], "0x") == false)
790
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
791
					continue;
792
				}
793
				if(strlen($_POST['key' . $i]) == 28)
794
					continue;
795
				$input_errors[] =  gettext("Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.");
796
				break;
797
			}
798
		}
799

    
800
		if ($_POST['passphrase']) {
801
			$passlen = strlen($_POST['passphrase']);
802
			if ($passlen < 8 || $passlen > 63)
803
				$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
804
		}
805
	}
806
	if (!$input_errors) {
807
		if ($wancfg['ipaddr'] != $_POST['type']) {
808
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
809
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
810
				unset($a_ppps[$pppid]);
811
			} else if ($wancfg['ipaddr'] == "dhcp") {
812
				kill_dhclient_process($wancfg['if']);
813
			}
814
			if ($wancfg['ipaddrv6'] == "dhcp6") {
815
				$pid = find_dhcp6c_process($wancfg['if']);
816
				if($pid)
817
					posix_kill($pid, SIGTERM);
818
			}
819
		}
820
		$ppp = array();
821
		if ($wancfg['ipaddr'] != "ppp")
822
			unset($wancfg['ipaddr']);
823
		if ($wancfg['ipaddrv6'] != "ppp")
824
			unset($wancfg['ipaddrv6']);
825
		unset($wancfg['subnet']);
826
		unset($wancfg['gateway']);
827
		unset($wancfg['subnetv6']);
828
		unset($wancfg['gatewayv6']);
829
		unset($wancfg['dhcphostname']);
830
		unset($wancfg['dhcprejectfrom']);
831
		unset($wancfg['dhcp6-duid']);
832
		unset($wancfg['dhcp6-ia-pd-len']);
833
		unset($wancfg['dhcp6-ia-pd-send-hint']);
834
		unset($wancfg['dhcp6prefixonly']);
835
		unset($wancfg['dhcp6usev4iface']);
836
		unset($wancfg['track6-interface']);
837
		unset($wancfg['track6-prefix-id']);
838
		unset($wancfg['prefix-6rd']);
839
		unset($wancfg['prefix-6rd-v4plen']);
840
		unset($wancfg['gateway-6rd']);
841

    
842
		unset($wancfg['adv_dhcp_pt_timeout']);
843
		unset($wancfg['adv_dhcp_pt_retry']);
844
		unset($wancfg['adv_dhcp_pt_select_timeout']);
845
		unset($wancfg['adv_dhcp_pt_reboot']);
846
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
847
		unset($wancfg['adv_dhcp_pt_initial_interval']);
848

    
849
		unset($wancfg['adv_dhcp_pt_values']);
850

    
851
		unset($wancfg['adv_dhcp_send_options']);
852
		unset($wancfg['adv_dhcp_request_options']);
853
		unset($wancfg['adv_dhcp_required_options']);
854
		unset($wancfg['adv_dhcp_option_modifiers']);
855

    
856
		unset($wancfg['adv_dhcp_config_advanced']);
857
		unset($wancfg['adv_dhcp_config_file_override']);
858
		unset($wancfg['adv_dhcp_config_file_override_path']);
859

    
860
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
861
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
862
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
863
		unset($wancfg['adv_dhcp6_interface_statement_script']);
864

    
865
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
866
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
867
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
868
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
869
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
870

    
871
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
872
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
873
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
874
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
875
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
876

    
877
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
878
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
879

    
880
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
881
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
882
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
883
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
884

    
885
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
886
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
887
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
888
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
889
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
890

    
891
		unset($wancfg['adv_dhcp6_config_advanced']);
892
		unset($wancfg['adv_dhcp6_config_file_override']);
893
		unset($wancfg['adv_dhcp6_config_file_override_path']);
894

    
895
		unset($wancfg['pppoe_password']);
896
		unset($wancfg['pptp_username']);
897
		unset($wancfg['pptp_password']);
898
		unset($wancfg['provider']);
899
		if ($wancfg['ipaddr'] != "ppp")
900
			unset($wancfg['ondemand']);
901
		unset($wancfg['timeout']);
902
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
903
			unset($wancfg['pppoe']['pppoe-reset-type']);
904
		unset($wancfg['local']);
905

    
906
		unset($wancfg['remote']);
907
		unset($a_ppps[$pppid]['apn']);
908
		unset($a_ppps[$pppid]['phone']);
909
		unset($a_ppps[$pppid]['localip']);
910
		unset($a_ppps[$pppid]['subnet']);
911
		unset($a_ppps[$pppid]['gateway']);
912
		unset($a_ppps[$pppid]['pppoe-reset-type']);
913
		unset($a_ppps[$pppid]['provider']);
914

    
915
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
916
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
917

    
918
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
919
		switch($_POST['type']) {
920
			case "staticv4":
921
				$wancfg['ipaddr'] = $_POST['ipaddr'];
922
				$wancfg['subnet'] = $_POST['subnet'];
923
				if ($_POST['gateway'] != "none") {
924
					$wancfg['gateway'] = $_POST['gateway'];
925
				}
926
				break;
927
			case "dhcp":
928
				$wancfg['ipaddr'] = "dhcp";
929
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
930
				$wancfg['alias-address'] = $_POST['alias-address'];
931
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
932
				$wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom'];
933

    
934
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
935
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
936
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
937
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
938
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
939
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
940

    
941
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
942

    
943
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
944
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
945
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
946
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
947

    
948
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
949
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
950
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
951

    
952
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
953
				if($gateway_item) {
954
					$a_gateways[] = $gateway_item;
955
				}
956
				break;
957
			case "ppp":
958
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
959
				$a_ppps[$pppid]['type'] = $_POST['type'];
960
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
961
				$a_ppps[$pppid]['ports'] = $_POST['port'];
962
				$a_ppps[$pppid]['username'] = $_POST['username'];
963
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
964
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
965
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
966
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
967
				$wancfg['ipaddr'] = $_POST['type'];
968
				unset($a_ppps[$pppid]['ondemand']);
969
				unset($a_ppps[$pppid]['idletimeout']);
970
				break;
971

    
972
			case "pppoe":
973
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
974
				$a_ppps[$pppid]['type'] = $_POST['type'];
975
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
976
				if (isset($_POST['ppp_port']))
977
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
978
				else
979
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
980
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
981
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
982
				if (!empty($_POST['provider']))
983
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
984
				else
985
					$a_ppps[$pppid]['provider'] = true;
986
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
987
				if (!empty($_POST['pppoe_idletimeout']))
988
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
989
				else
990
					unset($a_ppps[$pppid]['idletimeout']);
991

    
992
				if (!empty($_POST['pppoe-reset-type']))
993
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
994
				else
995
					unset($a_ppps[$pppid]['pppoe-reset-type']);
996
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
997
				$wancfg['ipaddr'] = $_POST['type'];
998
				if($gateway_item) {
999
					$a_gateways[] = $gateway_item;
1000
				}
1001

    
1002
				break;
1003
			case "pptp":
1004
			case "l2tp":
1005
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1006
				$a_ppps[$pppid]['type'] = $_POST['type'];
1007
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1008
				if (isset($_POST['ppp_port']))
1009
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
1010
				else
1011
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
1012
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
1013
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
1014
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
1015
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
1016
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
1017
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
1018
				if (!empty($_POST['pptp_idletimeout']))
1019
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
1020
				else
1021
					unset($a_ppps[$pppid]['idletimeout']);
1022
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1023
				$wancfg['ipaddr'] = $_POST['type'];
1024
				if($gateway_item) {
1025
					$a_gateways[] = $gateway_item;
1026
				}
1027
				break;
1028
			case "none":
1029
				break;
1030
		}
1031
		switch($_POST['type6']) {
1032
			case "staticv6":
1033
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
1034
				$wancfg['subnetv6'] = $_POST['subnetv6'];
1035
				if ($_POST['gatewayv6'] != "none") {
1036
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
1037
				}
1038
				break;
1039
			case "slaac":
1040
				$wancfg['ipaddrv6'] = "slaac";
1041
				break;
1042
			case "dhcp6":
1043
				$wancfg['ipaddrv6'] = "dhcp6";
1044
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
1045
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
1046
				if($_POST['dhcp6-ia-pd-send-hint'] == "yes")
1047
					$wancfg['dhcp6-ia-pd-send-hint'] = true;
1048
				if($_POST['dhcp6prefixonly'] == "yes")
1049
					$wancfg['dhcp6prefixonly'] = true;
1050
				if($_POST['dhcp6usev4iface'] == "yes")
1051
					$wancfg['dhcp6usev4iface'] = true;
1052

    
1053
				$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1054
				$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1055
				$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1056
				$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1057

    
1058
				$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1059
				$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1060
				$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1061
				$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1062
				$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1063

    
1064
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1065
				$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1066
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1067
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1068
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1069

    
1070
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1071
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1072

    
1073
				$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1074
				$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1075
				$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1076
				$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1077

    
1078
				$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1079
				$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1080
				$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1081
				$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1082
				$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1083

    
1084
				$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1085
				$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1086
				$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1087

    
1088
				if($gateway_item) {
1089
					$a_gateways[] = $gateway_item;
1090
				}
1091
				break;
1092
			case "6rd":
1093
				$wancfg['ipaddrv6'] = "6rd";
1094
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
1095
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
1096
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
1097
				if($gateway_item) {
1098
					$a_gateways[] = $gateway_item;
1099
				}
1100
				break;
1101
			case "6to4":
1102
				$wancfg['ipaddrv6'] = "6to4";
1103
				break;
1104
			case "track6":
1105
				$wancfg['ipaddrv6'] = "track6";
1106
				$wancfg['track6-interface'] = $_POST['track6-interface'];
1107
				if ($_POST['track6-prefix-id--hex'] === "")
1108
					$wancfg['track6-prefix-id'] = 0;
1109
				else if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
1110
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
1111
				else
1112
					$wancfg['track6-prefix-id'] = 0;
1113
				break;
1114
			case "none":
1115
				break;
1116
		}
1117
		handle_pppoe_reset($_POST);
1118

    
1119
		if($_POST['blockpriv'] == "yes") {
1120
			$wancfg['blockpriv'] = true;
1121
		} else {
1122
			unset($wancfg['blockpriv']);
1123
		}
1124
		if($_POST['blockbogons'] == "yes") {
1125
			$wancfg['blockbogons'] = true;
1126
		} else {
1127
			unset($wancfg['blockbogons']);
1128
		}
1129
		$wancfg['spoofmac'] = $_POST['spoofmac'];
1130
		if (empty($_POST['mtu'])) {
1131
			unset($wancfg['mtu']);
1132
		} else {
1133
			$wancfg['mtu'] = $_POST['mtu'];
1134
		}
1135
		if (empty($_POST['mss'])) {
1136
			unset($wancfg['mss']);
1137
		} else {
1138
			$wancfg['mss'] = $_POST['mss'];
1139
		}
1140
		if (empty($_POST['mediaopt'])) {
1141
			unset($wancfg['media']);
1142
			unset($wancfg['mediaopt']);
1143
		} else {
1144
			$mediaopts = explode(' ', $_POST['mediaopt']);
1145
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
1146
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
1147
			else { unset($wancfg['mediaopt']); }
1148
		}
1149
		if (isset($wancfg['wireless'])) {
1150
			handle_wireless_post();
1151
		}
1152

    
1153
		conf_mount_ro();
1154
		write_config();
1155

    
1156
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
1157
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
1158
		} else {
1159
			$toapplylist = array();
1160
		}
1161
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
1162
		$toapplylist[$if]['ppps'] = $old_ppps;
1163
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
1164

    
1165
		mark_subsystem_dirty('interfaces');
1166

    
1167
		/* regenerate cron settings/crontab file */
1168
		configure_cron();
1169

    
1170
		header("Location: interfaces.php?if={$if}");
1171
		exit;
1172
	}
1173

    
1174
} // end if($_POST)
1175

    
1176
function handle_wireless_post() {
1177
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
1178
	if (!is_array($wancfg['wireless']))
1179
		$wancfg['wireless'] = array();
1180
	$wancfg['wireless']['standard'] = $_POST['standard'];
1181
	$wancfg['wireless']['mode'] = $_POST['mode'];
1182
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
1183
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
1184
	$wancfg['wireless']['channel'] = $_POST['channel'];
1185
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
1186
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
1187
	$wancfg['wireless']['distance'] = $_POST['distance'];
1188
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
1189
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
1190
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
1191
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
1192
		foreach($wl_countries_attr as $wl_country) {
1193
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
1194
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
1195
				break;
1196
			}
1197
		}
1198
	}
1199
	if (!is_array($wancfg['wireless']['wpa']))
1200
		$wancfg['wireless']['wpa'] = array();
1201
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
1202
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
1203
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
1204
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
1205
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
1206
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
1207
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
1208
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
1209
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
1210
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
1211
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
1212
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
1213
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
1214
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
1215
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
1216

    
1217
	if ($_POST['persistcommonwireless'] == "yes") {
1218
		if (!is_array($config['wireless']))
1219
			$config['wireless'] = array();
1220
		if (!is_array($config['wireless']['interfaces']))
1221
			$config['wireless']['interfaces'] = array();
1222
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
1223
			$config['wireless']['interfaces'][$wlanbaseif] = array();
1224
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
1225
		unset($config['wireless']['interfaces'][$wlanbaseif]);
1226
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
1227
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
1228
	else if (isset($wancfg['wireless']['diversity']))
1229
		unset($wancfg['wireless']['diversity']);
1230
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
1231
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
1232
	else if (isset($wancfg['wireless']['txantenna']))
1233
		unset($wancfg['wireless']['txantenna']);
1234
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
1235
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
1236
	else if (isset($wancfg['wireless']['rxantenna']))
1237
		unset($wancfg['wireless']['rxantenna']);
1238
	if ($_POST['hidessid_enable'] == "yes")
1239
		$wancfg['wireless']['hidessid']['enable'] = true;
1240
	else if (isset($wancfg['wireless']['hidessid']['enable']))
1241
		unset($wancfg['wireless']['hidessid']['enable']);
1242
	if ($_POST['mac_acl_enable'] == "yes")
1243
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
1244
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
1245
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
1246
	if ($_POST['rsn_preauth'] == "yes")
1247
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
1248
	else
1249
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
1250
	if ($_POST['ieee8021x'] == "yes")
1251
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
1252
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
1253
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
1254
	if ($_POST['wpa_strict_rekey'] == "yes")
1255
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
1256
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
1257
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
1258
	if ($_POST['debug_mode'] == "yes")
1259
		$wancfg['wireless']['wpa']['debug_mode'] = true;
1260
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
1261
		sunset($wancfg['wireless']['wpa']['debug_mode']);
1262
	if ($_POST['wpa_enable'] == "yes")
1263
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
1264
	else if (isset($wancfg['wireless']['wpa']['enable']))
1265
		unset($wancfg['wireless']['wpa']['enable']);
1266
	if ($_POST['wep_enable'] == "yes") {
1267
		if (!is_array($wancfg['wireless']['wep']))
1268
			$wancfg['wireless']['wep'] = array();
1269
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
1270
	} else if (isset($wancfg['wireless']['wep']))
1271
		unset($wancfg['wireless']['wep']);
1272
	if ($_POST['wme_enable'] == "yes") {
1273
		if (!is_array($wancfg['wireless']['wme']))
1274
			$wancfg['wireless']['wme'] = array();
1275
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1276
	} else if (isset($wancfg['wireless']['wme']['enable']))
1277
		unset($wancfg['wireless']['wme']['enable']);
1278
	if ($_POST['puremode'] == "11g") {
1279
		if (!is_array($wancfg['wireless']['pureg']))
1280
			$wancfg['wireless']['pureg'] = array();
1281
		$wancfg['wireless']['pureg']['enable'] = true;
1282
	} else if ($_POST['puremode'] == "11n") {
1283
		if (!is_array($wancfg['wireless']['puren']))
1284
			$wancfg['wireless']['puren'] = array();
1285
		$wancfg['wireless']['puren']['enable'] = true;
1286
	} else {
1287
		if (isset($wancfg['wireless']['pureg']))
1288
			unset($wancfg['wireless']['pureg']);
1289
		if (isset($wancfg['wireless']['puren']))
1290
			unset($wancfg['wireless']['puren']);
1291
	}
1292
	if ($_POST['apbridge_enable'] == "yes") {
1293
		if (!is_array($wancfg['wireless']['apbridge']))
1294
			$wancfg['wireless']['apbridge'] = array();
1295
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1296
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
1297
		unset($wancfg['wireless']['apbridge']['enable']);
1298
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1299
		if (!is_array($wancfg['wireless']['turbo']))
1300
			$wancfg['wireless']['turbo'] = array();
1301
		$wancfg['wireless']['turbo']['enable'] = true;
1302
	} else if (isset($wancfg['wireless']['turbo']['enable']))
1303
		unset($wancfg['wireless']['turbo']['enable']);
1304
	$wancfg['wireless']['wep']['key'] = array();
1305
	for ($i = 1; $i <= 4; $i++) {
1306
		if ($_POST['key' . $i]) {
1307
			$newkey = array();
1308
			$newkey['value'] = $_POST['key' . $i];
1309
			if ($_POST['txkey'] == $i)
1310
				$newkey['txkey'] = true;
1311
			$wancfg['wireless']['wep']['key'][] = $newkey;
1312
		}
1313
	}
1314
	interface_sync_wireless_clones($wancfg, true);
1315
}
1316

    
1317
function check_wireless_mode() {
1318
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1319

    
1320
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1321
		return;
1322

    
1323
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1324
		$clone_count = 1;
1325
	else
1326
		$clone_count = 0;
1327
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1328
		foreach ($config['wireless']['clone'] as $clone) {
1329
			if ($clone['if'] == $wlanbaseif)
1330
				$clone_count++;
1331
		}
1332
	}
1333
	if ($clone_count > 1) {
1334
		$old_wireless_mode = $wancfg['wireless']['mode'];
1335
		$wancfg['wireless']['mode'] = $_POST['mode'];
1336
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1337
			$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']]);
1338
		} else {
1339
			mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy");
1340
		}
1341
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1342
	}
1343
}
1344

    
1345
// Find all possible media options for the interface
1346
$mediaopts_list = array();
1347
$intrealname = $config['interfaces'][$if]['if'];
1348
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1349
foreach ($mediaopts as $mediaopt){
1350
	preg_match("/media (.*)/", $mediaopt, $matches);
1351
	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1352
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1353
		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1354
	}else{
1355
		// there is only media like "media 1000baseT"
1356
		array_push($mediaopts_list, $matches[1]);
1357
	}
1358
}
1359

    
1360
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1361
$shortcut_section = "interfaces";
1362

    
1363
$closehead = false;
1364
include("head.inc");
1365
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1366
$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"));
1367

    
1368
?>
1369

    
1370
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1371
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1372
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1373
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1374

    
1375
<script type="text/javascript">
1376
//<![CDATA[
1377
	function updateType(t) {
1378
		switch(t) {
1379
			case "none": {
1380
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1381
				break;
1382
			}
1383
			case "staticv4": {
1384
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1385
				break;
1386
			}
1387
			case "dhcp": {
1388
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1389
				break;
1390
			}
1391
			case "ppp": {
1392
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1393
				country_list();
1394
				break;
1395
			}
1396
			case "pppoe": {
1397
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1398
				break;
1399
			}
1400
			case "l2tp":
1401
			case "pptp": {
1402
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1403
				jQuery('#pptp').show();
1404
				break;
1405
			}
1406
		}
1407
		if (t != "l2tp" && t != "pptp")
1408
			jQuery('#'+t).show();
1409
	}
1410
	function updateTypeSix(t) {
1411
		if (!isNaN(t[0])) t = '_' + t;
1412
		switch(t) {
1413
			case "none": {
1414
				jQuery('#staticv6, #dhcp6, #_6rd, #_6to4, #track6, #slaac').hide();
1415
				break;
1416
			}
1417
			case "staticv6": {
1418
				jQuery('#none, #dhcp6, #_6rd, #_6to4, #track6, #slaac').hide();
1419
				break;
1420
			}
1421
			case "slaac": {
1422
				jQuery('#none, #staticv6, #_6rd, #_6to4, #track6, #dhcp6').hide();
1423
				break;
1424
			}
1425
			case "dhcp6": {
1426
				jQuery('#none, #staticv6, #_6rd, #_6to4, #track6, #slaac').hide();
1427
				break;
1428
			}
1429
			case "_6rd": {
1430
				jQuery('#none, #dhcp6, #staticv6, #_6to4, #track6, #slaac').hide();
1431
				break;
1432
			}
1433
			case "_6to4": {
1434
				jQuery('#none, #dhcp6, #staticv6, #_6rd, #track6, #slaac').hide();
1435
				break;
1436
			}
1437
			case "track6": {
1438
				jQuery('#none, #dhcp6, #staticv6, #_6rd, #_6to4, #slaac').hide();
1439
				break;
1440
			}
1441
		}
1442
		if (t != "l2tp" && t != "pptp")
1443
			jQuery('#'+t).show();
1444
	}
1445

    
1446
	function show_allcfg(obj) {
1447
		if (obj.checked)
1448
			jQuery('#allcfg').show();
1449
		else
1450
			jQuery('#allcfg').hide();
1451
	}
1452

    
1453
	function show_reset_settings(reset_type) {
1454
		if (reset_type == 'preset') {
1455
			jQuery('#pppoepresetwrap').show();
1456
			jQuery('#pppoecustomwrap').hide();
1457
		}
1458
		else if (reset_type == 'custom') {
1459
			jQuery('#pppoecustomwrap').show();
1460
			jQuery('#pppoepresetwrap').hide();
1461
		} else {
1462
			jQuery('#pppoecustomwrap').hide();
1463
			jQuery('#pppoepresetwrap').hide();
1464
		}
1465
	}
1466
	function show_mon_config() {
1467
		jQuery("#showmonbox").html('');
1468
		jQuery('#showmon').css('display','block');
1469
	}
1470

    
1471
	function openwindow(url) {
1472
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1473
		if (oWin==null || typeof(oWin)=="undefined")
1474
			return false;
1475
		else
1476
			return true;
1477
	}
1478
	function country_list() {
1479
		jQuery('#country').children().remove();
1480
		jQuery('#provider_list').children().remove();
1481
		jQuery('#providerplan').children().remove();
1482
		jQuery.ajax("getserviceproviders.php",{
1483
			success: function(response) {
1484
				var responseTextArr = response.split("\n");
1485
				responseTextArr.sort();
1486
				responseTextArr.each( function(value) {
1487
					var option = new Element('option');
1488
					country = value.split(":");
1489
					option.text = country[0];
1490
					option.value = country[1];
1491
					jQuery('#country').append(option);
1492
				});
1493
			}
1494
		});
1495
		jQuery('#trcountry').css('display',"table-row");
1496
	}
1497

    
1498
	function providers_list() {
1499
		jQuery('#provider_list').children().remove();
1500
		jQuery('#providerplan').children().remove();
1501
		jQuery.ajax("getserviceproviders.php",{
1502
			type: 'post',
1503
			data: {country : jQuery('#country').val()},
1504
			success: function(response) {
1505
				var responseTextArr = response.split("\n");
1506
				responseTextArr.sort();
1507
				responseTextArr.each( function(value) {
1508
					var option = new Element('option');
1509
					option.text = value;
1510
					option.value = value;
1511
					jQuery('#provider_list').append(option);
1512
				});
1513
			}
1514
		});
1515
		jQuery('#trprovider').css("display","table-row");
1516
		jQuery('#trproviderplan').css("display","none");
1517
	}
1518

    
1519
	function providerplan_list() {
1520
		jQuery('#providerplan').children().remove();
1521
		jQuery('#providerplan').append( new Element('option') );
1522
		jQuery.ajax("getserviceproviders.php",{
1523
			type: 'post',
1524
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val()},
1525
			success: function(response) {
1526
				var responseTextArr = response.split("\n");
1527
				responseTextArr.sort();
1528
				responseTextArr.each( function(value) {
1529
					if(value != "") {
1530
						providerplan = value.split(":");
1531

    
1532
						var option = new Element('option');
1533
						option.text = providerplan[0] + " - " + providerplan[1];
1534
						option.value = providerplan[1];
1535
						jQuery('#providerplan').append(option);
1536
					}
1537
				});
1538
			}
1539
		});
1540
		jQuery('#trproviderplan').css("display","table-row");
1541
	}
1542

    
1543
	function prefill_provider() {
1544
		jQuery.ajax("getserviceproviders.php",{
1545
			type: 'post',
1546
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val(), plan : jQuery('#providerplan').val()},
1547
			success: function(data,textStatus,response) {
1548
				var xmldoc = response.responseXML;
1549
				var provider = xmldoc.getElementsByTagName('connection')[0];
1550
				jQuery('#username').val('');
1551
				jQuery('#password').val('');
1552
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1553
					jQuery('#phone').val('#777');
1554
					jQuery('#apn').val('');
1555
				} else {
1556
					jQuery('#phone').val('*99#');
1557
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1558
				}
1559
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1560
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1561
				jQuery('#username').val(username);
1562
				jQuery('#password').val(password);
1563
			}
1564
		});
1565
	}
1566

    
1567
//]]>
1568
</script>
1569
</head>
1570
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1571
	<?php include("fbegin.inc"); ?>
1572
	<form action="interfaces.php" method="post" name="iform" id="iform">
1573
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1574
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1575
		<?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 />
1576
		<?php endif; ?>
1577
		<?php if ($savemsg) print_info_box($savemsg); ?>
1578
		<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces">
1579
			<tr>
1580
				<td id="mainarea">
1581
					<div class="tabcont">
1582
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="tabs">
1583
						<tr>
1584
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1585
						</tr>
1586
						<tr>
1587
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1588
							<td width="78%" class="vtable">
1589
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked=\"checked\""; ?> onclick="show_allcfg(this);" />
1590
							<strong><?=gettext("Enable Interface"); ?></strong>
1591
							</td>
1592
						</tr>
1593
					</table>
1594
					<div style="display:none;" id="allcfg">
1595
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="allcfg">
1596
						<tr>
1597
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1598
							<td width="78%" class="vtable">
1599
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>" />
1600
								<br /><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1601
							</td>
1602
						</tr>
1603
						<tr>
1604
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1605
							<td class="vtable">
1606
							<select name="type" onchange="updateType(this.value);" <?php echo $type_disabled; ?> class="formselect" id="type">
1607
								<?php
1608
									foreach ($types4 as $key => $opt) {
1609
										echo "<option onclick=\"updateType('{$key}');\"";
1610
										if ($key == $pconfig['type'])
1611
											echo " selected=\"selected\"";
1612
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1613
										echo "</option>";
1614
									}
1615
								?>
1616
								</select>
1617
							</td>
1618
						</tr>
1619
						<tr>
1620
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1621
							<td class="vtable">
1622
							<select name="type6" onchange="updateTypeSix(this.value);" <?php echo $type_disabled; ?> class="formselect" id="type6">
1623
								<?php
1624
									foreach ($types6 as $key => $opt) {
1625
										echo "<option onclick=\"updateTypeSix('{$key}');\"";
1626
										if ($key == $pconfig['type6'])
1627
											echo " selected=\"selected\"";
1628
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1629
										echo "</option>";
1630
									}
1631
								?>
1632
								</select>
1633
							</td>
1634
						</tr>
1635
						<tr>
1636
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1637
							<td class="vtable">
1638
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>" />
1639
								<?php
1640
									$ip = getenv('REMOTE_ADDR');
1641
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1642
									$mac = str_replace("\n","",$mac);
1643
									if($mac):
1644
								?>
1645
									<a onclick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1646
								<?php endif; ?>
1647
								<br />
1648
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1649
								"address of this interface"); ?><br />
1650
								<?=gettext("(may be required with some cable connections)"); ?><br />
1651
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1652
								"or leave blank"); ?>
1653
							</td>
1654
						</tr>
1655
						<tr>
1656
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1657
							<td class="vtable">
1658
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>" />
1659
								<br />
1660
								<?php
1661
									print gettext("If you leave this field blank, the adapter's default MTU will " .
1662
									"be used. This is typically 1500 bytes but can vary in some circumstances.");
1663
								?>
1664
							</td>
1665
						</tr>
1666
						<tr>
1667
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1668
							<td class="vtable">
1669
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>" />
1670
								<br />
1671
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1672
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1673
								"header size) will be in effect."); ?>
1674
							</td>
1675
						</tr>
1676
						<?php
1677
						if (count($mediaopts_list) > 0){
1678
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1679
						echo "<tr>";
1680
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1681
							echo '<td class="vtable">';
1682
							echo '<div id="showadvmediabox"';
1683
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1684
								else echo '>';
1685
								echo '<input type="button" onclick="show_advanced_media()" value="' . gettext("Advanced") . '" /> - ' . gettext("Show advanced option");
1686
							echo "</div>";
1687
							echo '<div id="showmediaadv" ';
1688
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1689
							else echo '>';
1690
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1691
								print "<option value=\"\">Default (no preference, typically autoselect)</option>";
1692
								print "<option value=\"\">------- Media Supported by this interface -------</option>";
1693
								foreach($mediaopts_list as $mediaopt){
1694
									if ($mediaopt != rtrim($mediaopt_from_config)){
1695
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1696
									} else {
1697
										print "<option value=\"$mediaopt\" selected=\"selected\">" . gettext("$mediaopt") . "</option>";
1698
									}
1699
								}
1700
								echo '</select><br />';
1701
								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.");
1702
						echo '</div>';
1703
							echo '</td>';
1704
						echo '</tr>';
1705
						}
1706
						?>
1707
						<tr>
1708
							<td colspan="2" valign="top" height="16"></td>
1709
						</tr>
1710
						<tr style="display:none;" id="none"><td style="display:none;"></td></tr>
1711
						<tr style="display:none;" id="staticv4">
1712
							<td colspan="2" style="padding:0px;">
1713
								<a name="gatewaysection"></a>
1714
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv4">
1715
									<tr>
1716
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1717
									</tr>
1718
									<tr>
1719
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1720
										<td width="78%" class="vtable">
1721
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" />
1722
											/
1723
											<select name="subnet" class="formselect" id="subnet">
1724
												<?php
1725
												for ($i = 32; $i > 0; $i--) {
1726
													if($i <> 31) {
1727
														echo "<option value=\"{$i}\" ";
1728
														if ($i == $pconfig['subnet']) echo "selected=\"selected\"";
1729
														echo ">" . $i . "</option>";
1730
													}
1731
												}
1732
												?>
1733
											</select>
1734
										</td>
1735
									</tr>
1736
									<tr>
1737
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Upstream Gateway"); ?></td>
1738
										<td width="78%" class="vtable">
1739
											<select name="gateway" class="formselect" id="gateway">
1740
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1741
													<?php
1742
													if(count($a_gateways) > 0) {
1743
														foreach ($a_gateways as $gateway) {
1744
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1745
													?>
1746
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected=\"selected\""; ?>>
1747
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1748
															</option>
1749
													<?php
1750
															}
1751
														}
1752
													}
1753
													?>
1754
											</select>
1755
											- or  <strong><a onclick="show_add_gateway();" href="#gatewaysection"><?=gettext("add a new one."); ?></a></strong>
1756
											<br />
1757
											<div id='addgwbox'>
1758
												<?=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 />
1759
												<?=gettext("On local LANs the upstream gateway should be \"none\"."); ?>
1760
											</div>
1761
											<div id='notebox'>
1762
											</div>
1763
											<div id="status">
1764
											</div>
1765
											<div style="display:none" id="addgateway">
1766
												<p>&nbsp;</p>
1767
												<table border="1" class="addgatewaybox" summary="addgateway">
1768
													<tr>
1769
														<td>
1770
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgateway">
1771
																<tr><td>&nbsp;</td></tr>
1772
																<tr>
1773
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1774
																</tr>
1775
																<tr><td>&nbsp;</td></tr>
1776
																<?php
1777
																if($if == "wan" || $if == "WAN")
1778
																	$checked = " checked=\"checked\"";
1779
																?>
1780
																<tr>
1781
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></font></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?> /></td>
1782
																</tr>
1783
																<tr>
1784
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></font></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>" /></td>
1785
																</tr>
1786
																<tr>
1787
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></font></td><td><input id="gatewayip" name="gatewayip" /></td>
1788
																</tr>
1789
																<tr>
1790
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescr" name="gatewaydescr" /></td>
1791
																</tr>
1792
																<tr><td>&nbsp;</td></tr>
1793
																<tr>
1794
																	<td colspan="2">
1795
																		<center>
1796
																			<div id='savebuttondiv'>
1797
																				<input id="gwsave" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave();' />
1798
																				<input id="gwcancel" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway();' />
1799
																			</div>
1800
																		</center>
1801
																	</td>
1802
																</tr>
1803
																<tr><td>&nbsp;</td></tr>
1804
															</table>
1805
														</td>
1806
													</tr>
1807
												</table>
1808
											</div>
1809
										</td>
1810
									</tr>
1811
									<tr>
1812
										<td colspan="2" valign="top" height="16"></td>
1813
									</tr>
1814
								</table>
1815
							</td>
1816
						</tr>
1817
						<tr style="display:none;" id="staticv6">
1818
							<td colspan="2" style="padding:0px;">
1819
								<a name="gatewayv6section"></a>
1820
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv6">
1821
									<tr>
1822
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1823
									</tr>
1824
									<tr>
1825
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1826
										<td width="78%" class="vtable">
1827
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>" />
1828
											/
1829
											<select name="subnetv6" class="formselect" id="subnetv6">
1830
												<?php
1831
												for ($i = 128; $i > 0; $i--) {
1832
													if($i <> 127) {
1833
														echo "<option value=\"{$i}\" ";
1834
														if ($i == $pconfig['subnetv6']) echo "selected=\"selected\"";
1835
														echo ">" . $i . "</option>";
1836
													}
1837
												}
1838
												?>
1839
											</select>
1840
										</td>
1841
									</tr>
1842
									<tr>
1843
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Upstream Gateway"); ?></td>
1844
										<td width="78%" class="vtable">
1845
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1846
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1847
													<?php
1848
													if(count($a_gateways) > 0) {
1849
														foreach ($a_gateways as $gateway) {
1850
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1851
													?>
1852
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected=\"selected\""; ?>>
1853
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1854
															</option>
1855
													<?php
1856
															}
1857
														}
1858
													}
1859
													?>
1860
											</select>
1861
											- or <strong><a onclick="show_add_gateway_v6();" href="#gatewayv6section"><?=gettext("add a new one."); ?></a></strong>
1862
											<br />
1863
											<div id='addgwboxv6'>
1864
												<?=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 />
1865
												<?=gettext("On local LANs the upstream gateway should be \"none\"."); ?>
1866
											</div>
1867
											<div id='noteboxv6'>
1868
											</div>
1869
											<div id="statusv6">
1870
											</div>
1871
											<div style="display:none" id="addgatewayv6">
1872
												<p>&nbsp;</p>
1873
												<table border="1" class="addgatewaybox" summary="addgatewayv6">
1874
													<tr>
1875
														<td>
1876
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgatewayv6">
1877
																<tr><td>&nbsp;</td></tr>
1878
																<tr>
1879
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1880
																</tr>
1881
																<tr><td>&nbsp;</td></tr>
1882
																<?php
1883
																if($if == "wan" || $if == "WAN")
1884
																	$checked = " checked=\"checked\"";
1885
																?>
1886
																<tr>
1887
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></font></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?> /></td>
1888
																</tr>
1889
																<tr>
1890
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></font></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>" /></td>
1891
																</tr>
1892
																<tr>
1893
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></font></td><td><input id="gatewayipv6" name="gatewayipv6" /></td>
1894
																</tr>
1895
																<tr>
1896
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescrv6" name="gatewaydescrv6" /></td>
1897
																</tr>
1898
																<tr><td>&nbsp;</td></tr>
1899
																<tr>
1900
																	<td colspan="2">
1901
																		<center>
1902
																			<div id='savebuttondivv6'>
1903
																				<input id="gwsavev6" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave_v6();' />
1904
																				<input id="gwcancelv6" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway_v6();' />
1905
																			</div>
1906
																		</center>
1907
																	</td>
1908
																</tr>
1909
																<tr><td>&nbsp;</td></tr>
1910
															</table>
1911
														</td>
1912
													</tr>
1913
												</table>
1914
											</div>
1915
										</td>
1916
									</tr>
1917
									<tr>
1918
										<td colspan="2" valign="top" height="16"></td>
1919
									</tr>
1920
								</table>
1921
							</td>
1922
						</tr>
1923
						<tr style="display:none;" id="dhcp">
1924
							<td colspan="2" style="padding: 0px;">
1925
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp">
1926
									<tr>
1927
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration &nbsp; &nbsp; " .
1928
										' <input name="adv_dhcp_config_advanced" type="checkbox" id="adv_dhcp_config_advanced" value="" onclick="show_adv_dhcp_config(this)" /> ' .
1929
										" Advanced &nbsp; &nbsp; " .
1930
										' <input name="adv_dhcp_config_file_override" type="checkbox" id="adv_dhcp_config_file_override" value="" onclick="show_adv_dhcp_config(this)" /> ' .
1931
										" Config File Override &nbsp; &nbsp; "); ?>
1932
										</td>
1933
									</tr>
1934
									<!-- Uncomment to expose DHCP+ in GUI
1935
									<tr>
1936
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1937
										<td width="78%" class="vtable">
1938
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked=\"checked\""; ?> />
1939
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1940
										<br />
1941
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
1942
										</td>
1943
									</tr>
1944
									-->
1945
									<tr style='display:none' id="show_basic_dhcphostname">
1946
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1947
										<td width="78%" class="vtable">
1948
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>" />
1949
											<br />
1950
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1951
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1952
											"this (for client identification)."); ?>
1953
										</td>
1954
									</tr>
1955
									<tr style='display:none' id="show_basic_dhcpalias-address">
1956
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
1957
										<td width="78%" class="vtable">
1958
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>" />
1959
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1960
												<?php
1961
												for ($i = 32; $i > 0; $i--) {
1962
													if($i <> 31) {
1963
														echo "<option value=\"{$i}\" ";
1964
														if ($i == $pconfig['alias-subnet']) echo "selected=\"selected\"";
1965
														echo ">" . $i . "</option>";
1966
													}
1967
												}
1968
												?>
1969
											</select>
1970
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
1971
											"DHCP client."); ?>
1972
										</td>
1973
									</tr>
1974
									<tr style='display:none' id="show_basic_dhcprejectlease">
1975
										<td width="22%" valign="top" class="vncell"><?=gettext("Reject Leases From"); ?></td>
1976
										<td width="78%" class="vtable">
1977
											<input name="dhcprejectfrom" type="text" class="formfld unknown" id="dhcprejectfrom" size="20" value="<?=htmlspecialchars($pconfig['dhcprejectfrom']);?>" />
1978
											<br />
1979
											<?=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."); ?>
1980
											<?=gettext("This is useful for rejecting leases from cable modems that offer private IPs when they lose upstream sync."); ?>
1981
										</td>
1982
									</tr>
1983

    
1984
									<tr style='display:none' id="show_adv_dhcp_protocol_timing">
1985
										<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>
1986
										<td width="48%" class="vtable">
1987
											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, '');" />
1988
											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, '');" />
1989
											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, '');" />
1990

    
1991
											&nbsp; &nbsp; &nbsp; &nbsp; 
1992
											Presets: &nbsp;
1993
											<input name="adv_dhcp_pt_values" type="radio" value="DHCP"	id="customdhcpptdhcpdefaults"	onclick="customdhcpptsetvalues(this, iform);" />FreeBSD Default &nbsp; 
1994
											<input name="adv_dhcp_pt_values" type="radio" value="Clear"	id="customdhcpptclear"		onclick="customdhcpptsetvalues(this, iform);" />Clear
1995

    
1996
											<br />
1997
											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, '');" />
1998
											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, '');" />
1999
											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, '');" />
2000

    
2001
											&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
2002
											<input name="adv_dhcp_pt_values" type="radio" value="pfSense"	id="customdhcpptpfsensedefaults"	onclick="customdhcpptsetvalues(this, iform);" />pfSense Default &nbsp; 
2003
											<input name="adv_dhcp_pt_values" type="radio" value="SavedCfg" checked="checked"	id="customdhcpptsavedcfg"		onclick="customdhcpptsetvalues(this, iform);" />Saved Cfg 
2004

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

    
2008
											<script type="text/javascript">
2009
											//<![CDATA[
2010
												function customdhcpptcheckradiobuton(T, BUTTON) {
2011
													for (var i = 0; i < T.length; i++) {
2012
														T[i].checked = false;
2013
														if (T[i].value == BUTTON) T[i].checked = true;
2014
													}
2015
													T.value = BUTTON;
2016
												}
2017

    
2018
												function customdhcpptsetvalues(T, FORM) {
2019
													// timeout, retry, select-timeout, reboot, backoff-cutoff, initial-interval
2020
													if (T.value == "DHCP")		customdhcpptsetvaluesnow(T, FORM, "60", "300", "0", "10", "120", "10");
2021
													if (T.value == "pfSense")	customdhcpptsetvaluesnow(T, FORM, "60", "15", "0", "", "", "1");
2022
													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']);?>");
2023
													if (T.value == "Clear")		customdhcpptsetvaluesnow(T, FORM, "", "", "", "", "", "");
2024
												}
2025

    
2026
												function customdhcpptsetvaluesnow(T, FORM, timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
2027
													FORM.adv_dhcp_pt_timeout.value = timeout;
2028
													FORM.adv_dhcp_pt_retry.value = retry;
2029
													FORM.adv_dhcp_pt_select_timeout.value = selecttimeout;
2030
													FORM.adv_dhcp_pt_reboot.value = reboot;
2031
													FORM.adv_dhcp_pt_backoff_cutoff.value = backoffcutoff;
2032
													FORM.adv_dhcp_pt_initial_interval.value = initialinterval;
2033

    
2034
													FORM.adv_dhcp_pt_values.value = T.value;
2035
												}
2036

    
2037
												<!-- Set the adv_dhcp_pt_values radio button from saved config -->
2038
												var RADIOBUTTON_VALUE = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values']);?>";
2039
												if (RADIOBUTTON_VALUE == "") RADIOBUTTON_VALUE = "SavedCfg";
2040
												customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, RADIOBUTTON_VALUE);
2041
											//]]>
2042
											</script>
2043
										</td>
2044
									</tr>
2045

    
2046
									<tr style='display:none' id="show_adv_dhcp_lease_requirements_and_requests">
2047
										<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>
2048
										<td width="78%" class="vtable">
2049
											<?=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 />
2050
											<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']);?>" />
2051
											<br />
2052
											<?=gettext("The values in this field are DHCP options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2053
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2054
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2055
											"Some ISPs may require certain options be or not be sent. "); ?>
2056
											<hr/>
2057
											<?=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 />
2058
											<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']);?>" />
2059
											<br />
2060
											<?=gettext("The values in this field are DHCP option 55 to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2061
											"Some ISPs may require certain options be or not be requested. "); ?>
2062
											<hr/>
2063
											<?=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 />
2064
											<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']);?>" />
2065
											<br />
2066
											<?=gettext("The values in this field are DHCP options required by the client when requesting a DHCP lease.  [option [, ...]] "); ?>
2067
										</td>
2068
									</tr>
2069

    
2070
									<tr style='display:none' id="show_adv_dhcp_option_modifiers">
2071
										<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>
2072
										<td width="78%" class="vtable">
2073
											<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']);?>" />
2074
											<br />
2075
											<?=gettext("The values in this field are DHCP option modifiers applied to obtained DHCP lease.  [modifier option declaration [, ...]] <br /> " .
2076
											"modifiers: (default, supersede, prepend, append)"); ?>
2077
										</td>
2078
									</tr>
2079

    
2080
									<tr style='display:none' id="show_adv_dhcp_config_file_override">
2081
										<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>
2082
										<td width="78%" class="vtable">
2083
 											<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']);?>" />
2084
											<br />
2085
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2086
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2087
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2088
											"Some ISPs may require certain options be or not be sent. "); ?>
2089
										</td>
2090
									</tr>
2091

    
2092
 									<tr>
2093
 										<td colspan="2" valign="top" height="16"></td>
2094
 									</tr>
2095

    
2096
								</table>
2097

    
2098
									<script type="text/javascript">
2099
									//<![CDATA[
2100
										function show_adv_dhcp_config(T) {
2101

    
2102
											if (T.checked) T.value = "Selected";
2103
											else T.value = "";
2104

    
2105
											     if (document.iform.adv_dhcp_config_file_override.checked)	show_hide_adv_dhcp('none', 'none', '');
2106
											else if (document.iform.adv_dhcp_config_advanced.checked)	show_hide_adv_dhcp('', '', 'none');
2107
											else 									show_hide_adv_dhcp('', 'none', 'none');
2108
										}
2109

    
2110
										function show_hide_adv_dhcp(basic, advanced, override) {
2111

    
2112
											document.getElementById("show_basic_dhcphostname").style.display = basic;
2113
											document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2114
											document.getElementById("show_basic_dhcprejectlease").style.display = basic;
2115

    
2116
											document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2117
											document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2118
											document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2119

    
2120
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2121
										}
2122

    
2123
										<!-- Set the adv_dhcp_config_advanced checkbox from saved config -->
2124
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_advanced']);?>" == "Selected") document.iform.adv_dhcp_config_advanced.checked = true;
2125
										show_adv_dhcp_config(document.iform.adv_dhcp_config_advanced);
2126

    
2127
										<!-- Set the adv_dhcp_config_file_override checkbox from saved config -->
2128
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override']);?>" == "Selected") document.iform.adv_dhcp_config_file_override.checked = true;
2129
										show_adv_dhcp_config(document.iform.adv_dhcp_config_file_override);
2130
									//]]>
2131
									</script>
2132

    
2133
							</td>
2134
						</tr>
2135
						<tr style="display:none;" id="dhcp6">
2136
							<td colspan="2" style="padding: 0px;">
2137
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp6">
2138
									<tr>
2139
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration &nbsp; &nbsp; " .
2140
										' <input name="adv_dhcp6_config_advanced" type="checkbox" id="adv_dhcp6_config_advanced" value="" onclick="show_adv_dhcp6_config(this)" /> ' .
2141
										" Advanced &nbsp; &nbsp; " .
2142
										' <input name="adv_dhcp6_config_file_override" type="checkbox" id="adv_dhcp6_config_file_override" value="" onclick="show_adv_dhcp6_config(this)" /> ' .
2143
										" Config File Override &nbsp; &nbsp; "); ?>
2144
										</td>
2145
									</tr>
2146
									<!--- Leave commented out for now
2147
									<tr style='display:none' id="basicdhcp6_show_dhcp6_duid">
2148
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
2149
										<td width="78%" class="vtable">
2150
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>" />
2151
											<br />
2152
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
2153
											"when requesting a DHCPv6 lease."); ?><br />
2154
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
2155
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
2156
												}
2157
												printf(gettext("The current DUID is: '%s'"),$current_duid);
2158
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
2159
											?>
2160
										</td>
2161
									</tr>
2162
									-->
2163
									<tr style='display:none' id="basicdhcp6_use_pppoeinterface">
2164
										<td width="22%" valign="top" class="vncell"><?=gettext("Use IPv4 connectivity as parent interface"); ?></td>
2165
										<td width="78%" class="vtable">
2166
											<input name="dhcp6usev4iface" type="checkbox" id="dhcp6usev4iface" value="yes" <?php if ($pconfig['dhcp6usev4iface'] == true) echo "checked=\"checked\""; ?> />
2167
											<?=gettext("Request a IPv6 prefix/information through the IPv4 connectivity link"); ?>
2168
										</td>
2169
									</tr>
2170
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_only">
2171
										<td width="22%" valign="top" class="vncell"><?=gettext("Request only a IPv6 prefix"); ?></td>
2172
										<td width="78%" class="vtable">
2173
											<input name="dhcp6prefixonly" type="checkbox" id="dhcp6prefixonly" value="yes" <?php if ($pconfig['dhcp6prefixonly'] == true) echo "checked=\"checked\""; ?> />
2174
											<?=gettext("Only request a IPv6 prefix, do not request a IPv6 address"); ?>
2175
										</td>
2176
									</tr>
2177
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_delegation_size">
2178
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
2179
										<td width="78%" class="vtable">
2180
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
2181
												<?php
2182
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
2183
												foreach($sizes as $bits => $length) {
2184
													echo "<option value=\"{$bits}\" ";
2185
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected=\"selected\"";
2186
													echo ">" . $length . "</option>";
2187
												}
2188
												?>
2189
											</select>
2190
											<br />
2191
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
2192
										</td>
2193
									</tr>
2194
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_send_hint">
2195
										<td width="22%" valign="top" class="vncell"><?=gettext("Send IPv6 prefix hint"); ?></td>
2196
										<td width="78%" class="vtable">
2197
											<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\""; ?> />
2198
											<?=gettext("Send an IPv6 prefix hint to indicate the desired prefix size for delegation"); ?>
2199
										</td>
2200
									</tr>
2201

    
2202
									<tr style='display:none' id="show_adv_dhcp6_interface_statement">
2203
										<td width="22%" valign="top" class="vncell">
2204
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Interface_statement\">Interface Statement</a>"); ?>
2205
											<br /><br />
2206
											<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)" />
2207
											<?=gettext("Information Only"); ?>
2208
										</td>
2209
										<td width="78%" class="vtable">
2210
											<?=gettext("Send Options"); ?><br />
2211
											<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']);?>" />
2212
											<br />
2213
											<?=gettext("The values in this field are DHCP send options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2214
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2215
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2216
											"Some DHCP services may require certain options be or not be sent. "); ?>
2217
											<br />
2218
											<br />
2219
											<?=gettext("Request Options"); ?><br />
2220
											<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']);?>" />
2221
											<br />
2222
											<?=gettext("The values in this field are DHCP request options to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2223
											"Some DHCP services may require certain options be or not be requested. "); ?>
2224
											<br />
2225
											<br />
2226
											<?=gettext("Script"); ?><br />
2227
											<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']);?>" />
2228
											<br />
2229
											<?=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 />" .
2230
											"[/[dirname/[.../]]filename[.ext]] "); ?>
2231
										</td>
2232
									</tr>
2233

    
2234
									<tr style='display:none' id="show_adv_dhcp6_id_assoc_statement">
2235
										<td width="22%" valign="top" class="vncell">
2236
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Identity_association_statement\">Identity Association Statement</a>"); ?>
2237
										</td>
2238
										<td width="78%" class="vtable">
2239

    
2240
											<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);" />
2241
											<?=gettext("Non-Temporary Address Allocation"); ?>
2242
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_address">
2243
											<?=gettext("id-assoc na"); ?>
2244
											<?=gettext("<i>ID</i>"); ?>
2245
											<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']);?>" />
2246
											<br />
2247
											<?=gettext("Address"); ?>
2248
											<?=gettext("<i>ipv6-address</i>"); ?>
2249
											<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']);?>" />
2250
											<?=gettext("<i>pltime</i>"); ?>
2251
											<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']);?>" />
2252
											<?=gettext("<i>vltime</i>"); ?>
2253
											<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']);?>" />
2254
											</div>
2255
											<hr/>
2256

    
2257
											<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)" />
2258
											<?=gettext("Prefix Delegation"); ?>
2259
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_prefix">
2260
											<?=gettext("id-assoc pd"); ?>
2261
											<?=gettext("<i>ID</i>"); ?>
2262
											<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']);?>" />
2263
											<br />
2264
											<?=gettext("Prefix"); ?>
2265
											<?=gettext("<i>ipv6-prefix</i>"); ?>
2266
											<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']);?>" />
2267
											<?=gettext("<i>pltime</i>"); ?>
2268
											<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']);?>" />
2269
											<?=gettext("<i>vltime</i>"); ?>
2270
											<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']);?>" />
2271
											</div>
2272
										</td>
2273
									</tr>
2274

    
2275
									<tr style='display:none' id="show_adv_dhcp6_prefix_interface_statement">
2276
										<td width="22%" valign="top" class="vncell">
2277
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Prefix_interface_statement\">Prefix Interface Statement</a>"); ?>
2278
										</td>
2279
										<td width="78%" class="vtable">
2280
											<?=gettext("Prefix Interface "); ?>
2281
											<?=gettext("<i>sla-id</i>"); ?>
2282
											<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']);?>" />
2283
											<?=gettext("<i>sla-len</i>"); ?>
2284
											<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']);?>" />
2285
										</td>
2286
									</tr>
2287

    
2288
									<tr style='display:none' id="show_adv_dhcp6_authentication_statement">
2289
										<td width="22%" valign="top" class="vncell">
2290
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Authentication_statement\">Authentication Statement</a>"); ?>
2291
										</td>
2292
										<td width="78%" class="vtable">
2293
											<?=gettext("<i>authname</i>"); ?>
2294
											<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']);?>" />
2295
											<?=gettext("<i>protocol</i>"); ?>
2296
											<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']);?>" />
2297
											<?=gettext("<i>algorithm</i>"); ?>
2298
											<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']);?>" />
2299
											<?=gettext("<i>rdm</i>"); ?>
2300
											<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']);?>" />
2301
										</td>
2302
									</tr>
2303

    
2304
									<tr style='display:none' id="show_adv_dhcp6_key_info_statement">
2305
										<td width="22%" valign="top" class="vncell">
2306
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Keyinfo_statement\">Keyinfo Statement</a>"); ?>
2307
										</td>
2308
										<td width="78%" class="vtable">
2309
											<?=gettext("<i>keyname</i>"); ?>
2310
											<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']);?>" />
2311
											<?=gettext("<i>realm</i>"); ?>
2312
											<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']);?>" />
2313
											<br />
2314
											<?=gettext("<i>keyid</i>"); ?>
2315
											<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']);?>" />
2316
											<?=gettext("<i>secret</i>"); ?>
2317
											<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']);?>" />
2318
											<?=gettext("<i>expire</i>"); ?>
2319
											<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']);?>" />
2320
										</td>
2321
									</tr>
2322

    
2323
									<tr style='display:none' id="show_adv_dhcp6_config_file_override">
2324
										<td width="22%" valign="top" class="vncell">
2325
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports\">Configuration File</a> Override"); ?>
2326
										</td>
2327
										<td width="78%" class="vtable">
2328
 											<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']);?>" />
2329
											<br />
2330
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2331
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2332
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2333
											"Some ISPs may require certain options be or not be sent. "); ?>
2334
										</td>
2335
									</tr>
2336

    
2337
 									<tr>
2338
 										<td colspan="2" valign="top" height="16"></td>
2339
 									</tr>
2340

    
2341
								</table>
2342

    
2343
									<script type="text/javascript">
2344
									//<![CDATA[
2345
										function show_adv_dhcp6_config(T) {
2346

    
2347
											if (T.checked) T.value = "Selected";
2348
											else T.value = "";
2349

    
2350
											     if (document.iform.adv_dhcp6_config_file_override.checked)	show_hide_adv_dhcp6('none', 'none', ''    );
2351
											else if (document.iform.adv_dhcp6_config_advanced.checked)		show_hide_adv_dhcp6('none', '',     'none');
2352
											else 															show_hide_adv_dhcp6('',     'none', 'none');
2353
										}
2354

    
2355
										function show_hide_adv_dhcp6(basic, advanced, override) {
2356

    
2357
											document.getElementById("basicdhcp6_use_pppoeinterface").style.display = basic;
2358
											document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2359
											document.getElementById("basicdhcp6_show_dhcp6_prefix_send_hint").style.display = basic;
2360
											document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
2361

    
2362
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2363
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2364

    
2365
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2366
											if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked)  {
2367
												document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2368
											}
2369

    
2370
											document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = 'none';
2371
											document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = 'none';
2372
											if (document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked)  {
2373
												document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = advanced;
2374
												document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = advanced;
2375
											}
2376

    
2377
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2378
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2379

    
2380
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2381
										}
2382

    
2383
										<!-- Set the adv_dhcp6_config_advanced checkbox from saved config -->
2384
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_advanced']);?>" == "Selected") document.iform.adv_dhcp6_config_advanced.checked = true;
2385
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_advanced);
2386

    
2387
										<!-- Set the adv_dhcp6_config_file_override checkbox from saved config -->
2388
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override']);?>" == "Selected") document.iform.adv_dhcp6_config_file_override.checked = true;
2389
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_file_override);
2390

    
2391
										<!-- Set the adv_dhcp6_interface_statement_information_only_enable checkbox from saved config -->
2392
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_information_only_enable']);?>" == "Selected") document.iform.adv_dhcp6_interface_statement_information_only_enable.checked = true;
2393
										show_adv_dhcp6_config(document.iform.adv_dhcp6_interface_statement_information_only_enable);
2394

    
2395
										<!-- Set the adv_dhcp6_id_assoc_statement_address_enable checkbox from saved config -->
2396
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked = true;
2397
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_address_enable);
2398

    
2399
										<!-- Set the adv_dhcp6_id_assoc_statement_prefix_enable checkbox from saved config -->
2400
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked = true;
2401
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_prefix_enable);
2402
									//]]>
2403
									</script>
2404

    
2405
							</td>
2406
						</tr>
2407
						<tr style="display:none;" id="_6rd">
2408
							<td colspan="2" style="padding: 0px;">
2409
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="6rd">
2410
									<tr>
2411
										<td colspan="2" valign="top" class="listtopic"><?=gettext("6RD Rapid Deployment"); ?></td>
2412
									</tr>
2413
									<tr>
2414
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD prefix"); ?></td>
2415
										<td width="78%" class="vtable">
2416
											<input name="prefix-6rd" type="text" class="formfld unknown" id="prefix-6rd" size="40" value="<?=htmlspecialchars($pconfig['prefix-6rd']);?>" />
2417
											<br />
2418
											<?=gettext("The value in this field is the 6RD IPv6 prefix assigned by your ISP. e.g. '2001:db8::/32'") ?><br />
2419
										</td>
2420
									</tr>
2421
									<tr>
2422
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD Border Relay"); ?></td>
2423
										<td width="78%" class="vtable">
2424
											<input name="gateway-6rd" type="text" class="formfld unknown" id="gateway-6rd" size="40" value="<?=htmlspecialchars($pconfig['gateway-6rd']);?>" />
2425
											<br />
2426
											<?=gettext("The value in this field is 6RD IPv4 gateway address assigned by your ISP") ?><br />
2427
										</td>
2428
									</tr>
2429
									<tr>
2430
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD IPv4 Prefix length"); ?></td>
2431
										<td width="78%" class="vtable">
2432
											<select name="prefix-6rd-v4plen" class="formselect" id="prefix-6rd-v4plen">
2433
												<?php
2434
												for ($i = 0; $i < 32; $i++) {
2435
													echo "<option value=\"{$i}\" ";
2436
													if (is_numeric($pconfig['prefix-6rd-v4plen']) && ($i == $pconfig['prefix-6rd-v4plen'])) echo "selected=\"selected\"";
2437
													echo ">" . $i . " bits</option>";
2438
												}
2439
												?>
2440
											</select>
2441
											<br />
2442
											<?=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."); ?>
2443
										</td>
2444
									</tr>
2445
									<tr>
2446
										<td colspan="2" valign="top" height="16"></td>
2447
									</tr>
2448
								</table>
2449
							</td>
2450
						</tr>
2451
						<tr style="display:none;" id="track6">
2452
							<td colspan="2" style="padding: 0px;">
2453
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="track6">
2454
									<tr>
2455
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
2456
									</tr>
2457
									<tr>
2458
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
2459
										<td width="78%" class="vtable">
2460
										<select name='track6-interface' class='formselect' >
2461
										<?php
2462
											$interfaces = get_configured_interface_with_descr(false, true);
2463
											$dynv6ifs = array();
2464
											foreach ($interfaces as $iface => $ifacename) {
2465
												switch($config['interfaces'][$iface]['ipaddrv6']) {
2466
													case "6to4":
2467
													case "6rd":
2468
													case "dhcp6":
2469
														$dynv6ifs[$iface] = $ifacename;
2470
														break;
2471
													default:
2472
														continue;
2473
												}
2474
											}
2475
											$rowIndex = 0;
2476
											foreach($dynv6ifs as $iface => $ifacename) {
2477
												$rowIndex++;
2478
												echo "<option value=\"{$iface}\"";
2479
												if ($iface == $pconfig['track6-interface'])
2480
													echo " selected=\"selected\"";
2481
												echo ">" . htmlspecialchars($ifacename) . "</option>";
2482
											}
2483
											if ($rowIndex == 0)
2484
												echo "<option></option>";
2485
										?>
2486
										</select> <br />
2487
											<br />
2488
											<?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
2489
										</td>
2490
									</tr>
2491
									<tr>
2492
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
2493
										<td width="78%" class="vtable">
2494
											<?php
2495
												if ($pconfig['track6-prefix-id'] == "")
2496
													$pconfig['track6-prefix-id'] = 0;
2497
												$track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
2498
											?>
2499
											<input name="track6-prefix-id--hex" type="text" class="formfld unknown" id="track6-prefix-id--hex" size="8" value="<?= $track6_prefix_id_hex ?>" />
2500
											<br />
2501
											<?= gettext("The value in this field is the (Delegated) IPv6 prefix id. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
2502
											<br />
2503
											<?= sprintf(gettext("Enter a <b>hexadecimal</b> value between %x and %x here, default value is 0."), 0, $ipv6_num_prefix_ids - 1); ?>
2504
										</td>
2505
									</tr>
2506
									<tr>
2507
										<td colspan="2" valign="top" height="16"></td>
2508
									</tr>
2509
								</table>
2510
							</td>
2511
						</tr>
2512
						<tr style="display:none;" id="ppp">
2513
							<td colspan="2" style="padding: 0px;">
2514
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="ppp">
2515
									<tr>
2516
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
2517
									</tr>
2518
									<tr id="ppp_provider">
2519
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
2520
										<td width="78%" class="vtable">
2521
											<table border="0" cellpadding="0" cellspacing="0" summary="service provider">
2522
												<tr id="trcountry">
2523
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
2524
													<td>
2525
														<select class="formselect" name="country" id="country" onchange="providers_list()">
2526
															<option></option>
2527
														</select>
2528
													</td>
2529
												</tr>
2530
												<tr id="trprovider" style="display:none">
2531
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
2532
													<td>
2533
														<select class="formselect" name="provider_list" id="provider_list" onchange="providerplan_list()">
2534
															<option></option>
2535
														</select>
2536
													</td>
2537
												</tr>
2538
												<tr id="trproviderplan" style="display:none">
2539
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
2540
													<td>
2541
														<select class="formselect" name="providerplan" id="providerplan" onchange="prefill_provider()">
2542
															<option></option>
2543
														</select>
2544
													</td>
2545
												</tr>
2546
											</table>
2547
											<br /><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
2548
										</td>
2549
									</tr>
2550
									<tr>
2551
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
2552
										<td width="78%" class="vtable">
2553
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>" />
2554
										</td>
2555
									</tr>
2556
									<tr>
2557
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
2558
										<td width="78%" class="vtable">
2559
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>" />
2560
										</td>
2561
									</tr>
2562
									<tr id="phone_num">
2563
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
2564
										<td width="78%" class="vtable">
2565
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>" />
2566
										</td>
2567
									</tr>
2568
									<tr id="apn_">
2569
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
2570
										<td width="78%" class="vtable">
2571
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>" />
2572
										</td>
2573
									</tr>
2574
									<tr id="interface" >
2575
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
2576
										<td width="78%" class="vtable">
2577
											<select name="port" id="port" class="formselect">
2578
											<?php
2579
												$portlist = glob("/dev/cua*");
2580
												$modems = glob("/dev/modem*");
2581
												$portlist = array_merge($portlist, $modems);
2582
												$rowIndex = 0;
2583
												foreach ($portlist as $port) {
2584
													if(preg_match("/\.(lock|init)$/", $port))
2585
														continue;
2586
													$rowIndex++;
2587
													echo "<option value=\"".trim($port)."\"";
2588
													if ($pconfig['port'] == $port)
2589
														echo " selected=\"selected\"";
2590
													echo ">{$port}</option>";
2591
												}
2592
												if ($rowIndex == 0)
2593
													echo "<option></option>";
2594
												?>
2595
											</select>
2596
										</td>
2597
									</tr>
2598
									<tr>
2599
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
2600
										<?php if (isset($pconfig['pppid'])): ?>
2601
											<td width="78%" class="vtable">
2602
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2603
											<?=gettext("to edit PPP configuration."); ?>
2604
											</td>
2605
										<?php else: ?>
2606
											<td width="78%" class="vtable">
2607
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2608
											<?=gettext("to create a PPP configuration."); ?>
2609
											</td>
2610
										<?php endif; ?>
2611
									</tr>
2612
									<tr>
2613
										<td colspan="2" valign="top" height="16"></td>
2614
									</tr>
2615
								</table>
2616
							</td>
2617
						</tr>
2618
						<tr style="display:none;" id="pppoe">
2619
							<td colspan="2" style="padding:0px;">
2620
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pppoe">
2621
									<tr>
2622
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
2623
									</tr>
2624
									<tr>
2625
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2626
										<td width="78%" class="vtable">
2627
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>" />
2628
										</td>
2629
									</tr>
2630
									<tr>
2631
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2632
										<td width="78%" class="vtable">
2633
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>" />
2634
										</td>
2635
									</tr>
2636
									<tr>
2637
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
2638
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>" />
2639
											<br /> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
2640
										</td>
2641
									</tr>
2642
									<tr>
2643
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2644
										<td width="78%" class="vtable">
2645
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked=\"checked\""; ?> />
2646
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br />
2647
											<?=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."); ?>
2648
										</td>
2649
									</tr>
2650
									<tr>
2651
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2652
										<td width="78%" class="vtable">
2653
											<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."); ?>
2654
										</td>
2655
									</tr>
2656
									<tr>
2657
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
2658
										<td width="78%" class="vtable">
2659
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%" summary="periodic reset">
2660
												<tr>
2661
													<td align="left" valign="top">
2662
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
2663
														<select style="vertical-align:top" id="reset_type" name="pppoe-reset-type" class="formselect" onchange="show_reset_settings(this.value);">
2664
															<option value=""><?=gettext("Disabled"); ?></option>
2665
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected=\"selected\""; ?>><?=gettext("Custom"); ?></option>
2666
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected=\"selected\""; ?>><?=gettext("Pre-Set"); ?></option>
2667
														</select> <?=gettext("Select a reset timing type"); ?>
2668
														</p>
2669
														<?php if ($pconfig['pppoe_pr_custom']): ?>
2670
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
2671
														<?php else: ?>
2672
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
2673
														<?php endif; ?>
2674
														<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" />
2675
														<?=gettext("hour (0-23)"); ?><br />
2676
														<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" />
2677
														<?=gettext("minute (0-59)"); ?><br />
2678
														<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']);?>" />
2679
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
2680
														<br />&nbsp;<br />
2681
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
2682
														<?=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."); ?>
2683
														</p>
2684
														<?php if ($pconfig['pppoe_pr_preset']): ?>
2685
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
2686
														<?php else: ?>
2687
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
2688
														<?php endif; ?>
2689
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
2690
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
2691
														<br />
2692
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
2693
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
2694
														<br />
2695
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
2696
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
2697
														<br />
2698
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
2699
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
2700
														</p>
2701
													</td>
2702
												</tr>
2703
											</table>
2704
										</td>
2705
									</tr>
2706

    
2707
									<tr>
2708
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
2709
										<?php if (isset($pconfig['pppid'])): ?>
2710
											<td width="78%" class="vtable">
2711
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2712
											<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
2713
											</td>
2714
										<?php else: ?>
2715
											<td width="78%" class="vtable">
2716
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2717
											<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
2718
											</td>
2719
										<?php endif; ?>
2720
									</tr>
2721
									<tr>
2722
										<td colspan="2" valign="top" height="16"></td>
2723
									</tr>
2724
								</table>
2725
							</td>
2726
						</tr>
2727
						<tr style="display:none;" id="pptp">
2728
							<td colspan="2" style="padding:0px;">
2729
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pptp">
2730
									<tr>
2731
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP/L2TP configuration"); ?></td>
2732
									</tr>
2733
									<tr>
2734
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2735
										<td width="78%" class="vtable">
2736
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>" />
2737
										</td>
2738
									</tr>
2739
									<tr>
2740
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2741
										<td width="78%" class="vtable">
2742
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>" />
2743
										</td>
2744
									</tr>
2745
									<tr>
2746
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
2747
										<td width="78%" class="vtable">
2748
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>" />
2749
											/
2750
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
2751
												<?php for ($i = 31; $i > 0; $i--): ?>
2752
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected=\"selected\""; ?>>
2753
														<?=$i;?></option>
2754
												<?php endfor; ?>
2755
											</select>
2756
										</td>
2757
									</tr>
2758
									<tr>
2759
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
2760
										<td width="78%" class="vtable">
2761
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>" />
2762
										</td>
2763
									</tr>
2764
									<tr>
2765
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2766
										<td width="78%" class="vtable">
2767
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked=\"checked\""; ?> />
2768
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br />
2769
											<?=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."); ?>
2770
										</td>
2771
									</tr>
2772
									<tr>
2773
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2774
										<td width="78%" class="vtable">
2775
											<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."); ?>
2776
										</td>
2777
									</tr>
2778
									<tr>
2779
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
2780
										<?php if (isset($pconfig['pppid'])): ?>
2781
											<td width="78%" class="vtable">
2782
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
2783
											<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
2784
											</td>
2785
										<?php else: ?>
2786
											<td width="78%" class="vtable">
2787
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
2788
											<?=gettext("for advanced PPTP and L2TP configuration options");?>.
2789
											</td>
2790
										<?php endif; ?>
2791
									</tr>
2792
									<tr>
2793
										<td colspan="2" valign="top" height="16"></td>
2794
									</tr>
2795
								</table>
2796
							</td>
2797
						</tr>
2798
						<?php
2799
							/* Wireless interface? */
2800
							if (isset($wancfg['wireless'])):
2801
						?>
2802
						<tr>
2803
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
2804
						</tr>
2805
						<tr>
2806
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
2807
							<td class="vtable">
2808
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked=\"checked\"";?> />
2809
								<br /><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
2810
							</td>
2811
						</tr>
2812
						<tr>
2813
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
2814
							<td class="vtable">
2815
							<select name="standard" class="formselect" id="standard">
2816
								<?php
2817
								$rowIndex = 0;
2818
								foreach($wl_modes as $wl_standard => $wl_channels) {
2819
									$rowIndex++;
2820
									echo "<option ";
2821
									if ($pconfig['standard'] == "$wl_standard")
2822
										echo "selected=\"selected\" ";
2823
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
2824
								}
2825
								if ($rowIndex == 0)
2826
									echo "<option></option>";
2827
								?>
2828
							</select>
2829
							</td>
2830
						</tr>
2831
						<?php if (isset($wl_modes['11g'])): ?>
2832
						<tr>
2833
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
2834
							<td class="vtable">
2835
								<select name="protmode" class="formselect" id="protmode">
2836
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected=\"selected\"";?> value="off"><?=gettext("Protection mode off"); ?></option>
2837
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected=\"selected\"";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
2838
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected=\"selected\"";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
2839
								</select>
2840
								<br />
2841
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
2842
								<br />
2843
							</td>
2844
						</tr>
2845
						<?php else: ?>
2846
						<input name="protmode" type="hidden" id="protmode" value="off" />
2847
						<?php endif; ?>
2848
						<tr>
2849
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
2850
							<td class="vtable">
2851
								<select name="txpower" class="formselect" id="txpower">
2852
									<?
2853
									for($x = 99; $x > 0; $x--) {
2854
										if($pconfig["txpower"] == $x)
2855
											$SELECTED = " selected=\"selected\"";
2856
										else
2857
											$SELECTED = "";
2858