Projet

Général

Profil

Télécharger (172 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / interfaces.php @ 62424bdb

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 ($_POST['mtu'] < 576 || $_POST['mtu'] > 9000)
714
			$input_errors[] = gettext("The MTU must be greater than 576 bytes and less than 9000.");
715

    
716
		if (stristr($wancfg['if'], "_vlan")) {
717
			$realhwif_array = get_parent_interface($wancfg['if']);
718
			// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
719
			$parent_realhwif = $realhwif_array[0];
720
			$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
721
			if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) {
722
				if ($_POST['mtu'] > intval($config['interfaces'][$parent_if]['mtu']))
723
					$input_errors[] = gettext("MTU of a vlan should not be bigger than parent interface.");
724
			}
725
		} else {
726
			foreach ($config['interfaces'] as $idx => $ifdata) {
727
				if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if']))
728
					continue;
729

    
730
				$realhwif_array = get_parent_interface($ifdata['if']);
731
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
732
				$parent_realhwif = $realhwif_array[0];
733

    
734
				if ($parent_realhwif != $wancfg['if'])
735
					continue;
736

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

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

    
832
		unset($wancfg['adv_dhcp_pt_timeout']);
833
		unset($wancfg['adv_dhcp_pt_retry']);
834
		unset($wancfg['adv_dhcp_pt_select_timeout']);
835
		unset($wancfg['adv_dhcp_pt_reboot']);
836
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
837
		unset($wancfg['adv_dhcp_pt_initial_interval']);
838

    
839
		unset($wancfg['adv_dhcp_pt_values']);
840

    
841
		unset($wancfg['adv_dhcp_send_options']);
842
		unset($wancfg['adv_dhcp_request_options']);
843
		unset($wancfg['adv_dhcp_required_options']);
844
		unset($wancfg['adv_dhcp_option_modifiers']);
845

    
846
		unset($wancfg['adv_dhcp_config_advanced']);
847
		unset($wancfg['adv_dhcp_config_file_override']);
848
		unset($wancfg['adv_dhcp_config_file_override_path']);
849

    
850
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
851
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
852
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
853
		unset($wancfg['adv_dhcp6_interface_statement_script']);
854

    
855
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
856
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
857
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
858
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
859
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
860

    
861
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
862
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
863
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
864
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
865
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
866

    
867
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
868
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
869

    
870
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
871
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
872
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
873
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
874

    
875
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
876
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
877
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
878
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
879
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
880

    
881
		unset($wancfg['adv_dhcp6_config_advanced']);
882
		unset($wancfg['adv_dhcp6_config_file_override']);
883
		unset($wancfg['adv_dhcp6_config_file_override_path']);
884

    
885
		unset($wancfg['pppoe_password']);
886
		unset($wancfg['pptp_username']);
887
		unset($wancfg['pptp_password']);
888
		unset($wancfg['provider']);
889
		unset($wancfg['ondemand']);
890
		unset($wancfg['timeout']);
891
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
892
			unset($wancfg['pppoe']['pppoe-reset-type']);
893
		unset($wancfg['local']);
894

    
895
		unset($wancfg['remote']);
896
		unset($a_ppps[$pppid]['apn']);
897
		unset($a_ppps[$pppid]['phone']);
898
		unset($a_ppps[$pppid]['localip']);
899
		unset($a_ppps[$pppid]['subnet']);
900
		unset($a_ppps[$pppid]['gateway']);
901
		unset($a_ppps[$pppid]['pppoe-reset-type']);
902
		unset($a_ppps[$pppid]['provider']);
903

    
904
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
905
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
906

    
907
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
908
		switch($_POST['type']) {
909
			case "staticv4":
910
				$wancfg['ipaddr'] = $_POST['ipaddr'];
911
				$wancfg['subnet'] = $_POST['subnet'];
912
				if ($_POST['gateway'] != "none") {
913
					$wancfg['gateway'] = $_POST['gateway'];
914
				}
915
				break;
916
			case "dhcp":
917
				$wancfg['ipaddr'] = "dhcp";
918
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
919
				$wancfg['alias-address'] = $_POST['alias-address'];
920
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
921
				$wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom'];
922

    
923
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
924
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
925
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
926
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
927
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
928
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
929

    
930
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
931

    
932
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
933
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
934
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
935
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
936

    
937
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
938
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
939
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
940

    
941
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
942
				if($gateway_item) {
943
					$a_gateways[] = $gateway_item;
944
				}
945
				break;
946
			case "ppp":
947
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
948
				$a_ppps[$pppid]['type'] = $_POST['type'];
949
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
950
				$a_ppps[$pppid]['ports'] = $_POST['port'];
951
				$a_ppps[$pppid]['username'] = $_POST['username'];
952
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
953
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
954
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
955
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
956
				$wancfg['ipaddr'] = $_POST['type'];
957
				unset($a_ppps[$pppid]['ondemand']);
958
				unset($a_ppps[$pppid]['idletimeout']);
959
				break;
960

    
961
			case "pppoe":
962
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
963
				$a_ppps[$pppid]['type'] = $_POST['type'];
964
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
965
				if (isset($_POST['ppp_port']))
966
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
967
				else
968
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
969
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
970
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
971
				if (!empty($_POST['provider']))
972
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
973
				else
974
					$a_ppps[$pppid]['provider'] = true;
975
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
976
				if (!empty($_POST['pppoe_idletimeout']))
977
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
978
				else
979
					unset($a_ppps[$pppid]['idletimeout']);
980

    
981
				if (!empty($_POST['pppoe-reset-type']))
982
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
983
				else
984
					unset($a_ppps[$pppid]['pppoe-reset-type']);
985
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
986
				$wancfg['ipaddr'] = $_POST['type'];
987
				if($gateway_item) {
988
					$a_gateways[] = $gateway_item;
989
				}
990

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

    
1042
				$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1043
				$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1044
				$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1045
				$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1046

    
1047
				$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1048
				$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1049
				$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1050
				$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1051
				$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1052

    
1053
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1054
				$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1055
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1056
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1057
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1058

    
1059
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1060
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1061

    
1062
				$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1063
				$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1064
				$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1065
				$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1066

    
1067
				$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1068
				$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1069
				$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1070
				$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1071
				$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1072

    
1073
				$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1074
				$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1075
				$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1076

    
1077
				if($gateway_item) {
1078
					$a_gateways[] = $gateway_item;
1079
				}
1080
				break;
1081
			case "6rd":
1082
				$wancfg['ipaddrv6'] = "6rd";
1083
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
1084
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
1085
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
1086
				if($gateway_item) {
1087
					$a_gateways[] = $gateway_item;
1088
				}
1089
				break;
1090
			case "6to4":
1091
				$wancfg['ipaddrv6'] = "6to4";
1092
				break;
1093
			case "track6":
1094
				$wancfg['ipaddrv6'] = "track6";
1095
				$wancfg['track6-interface'] = $_POST['track6-interface'];
1096
				if ($_POST['track6-prefix-id--hex'] === "")
1097
					$wancfg['track6-prefix-id'] = 0;
1098
				else if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
1099
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
1100
				else
1101
					$wancfg['track6-prefix-id'] = 0;
1102
				break;
1103
			case "none":
1104
				break;
1105
		}
1106
		handle_pppoe_reset($_POST);
1107

    
1108
		if($_POST['blockpriv'] == "yes") {
1109
			$wancfg['blockpriv'] = true;
1110
		} else {
1111
			unset($wancfg['blockpriv']);
1112
		}
1113
		if($_POST['blockbogons'] == "yes") {
1114
			$wancfg['blockbogons'] = true;
1115
		} else {
1116
			unset($wancfg['blockbogons']);
1117
		}
1118
		$wancfg['spoofmac'] = $_POST['spoofmac'];
1119
		if (empty($_POST['mtu'])) {
1120
			unset($wancfg['mtu']);
1121
		} else {
1122
			$wancfg['mtu'] = $_POST['mtu'];
1123
		}
1124
		if (empty($_POST['mss'])) {
1125
			unset($wancfg['mss']);
1126
		} else {
1127
			$wancfg['mss'] = $_POST['mss'];
1128
		}
1129
		if (empty($_POST['mediaopt'])) {
1130
			unset($wancfg['media']);
1131
			unset($wancfg['mediaopt']);
1132
		} else {
1133
			$mediaopts = explode(' ', $_POST['mediaopt']);
1134
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
1135
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
1136
			else { unset($wancfg['mediaopt']); }
1137
		}
1138
		if (isset($wancfg['wireless'])) {
1139
			handle_wireless_post();
1140
		}
1141

    
1142
		conf_mount_ro();
1143
		write_config();
1144

    
1145
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
1146
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
1147
		} else {
1148
			$toapplylist = array();
1149
		}
1150
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
1151
		$toapplylist[$if]['ppps'] = $old_ppps;
1152
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
1153

    
1154
		mark_subsystem_dirty('interfaces');
1155

    
1156
		/* regenerate cron settings/crontab file */
1157
		configure_cron();
1158

    
1159
		header("Location: interfaces.php?if={$if}");
1160
		exit;
1161
	}
1162

    
1163
} // end if($_POST)
1164

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

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

    
1306
function check_wireless_mode() {
1307
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1308

    
1309
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1310
		return;
1311

    
1312
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1313
		$clone_count = 1;
1314
	else
1315
		$clone_count = 0;
1316
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1317
		foreach ($config['wireless']['clone'] as $clone) {
1318
			if ($clone['if'] == $wlanbaseif)
1319
				$clone_count++;
1320
		}
1321
	}
1322
	if ($clone_count > 1) {
1323
		$old_wireless_mode = $wancfg['wireless']['mode'];
1324
		$wancfg['wireless']['mode'] = $_POST['mode'];
1325
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1326
			$input_errors[] = sprintf(gettext("Unable to change mode to %s.  You may already have the maximum number of wireless clones supported in this mode."), $wlan_modes[$wancfg['wireless']['mode']]);
1327
		} else {
1328
			mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy");
1329
		}
1330
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1331
	}
1332
}
1333

    
1334
// Find all possible media options for the interface
1335
$mediaopts_list = array();
1336
$intrealname = $config['interfaces'][$if]['if'];
1337
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1338
foreach ($mediaopts as $mediaopt){
1339
	preg_match("/media (.*)/", $mediaopt, $matches);
1340
	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1341
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1342
		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1343
	}else{
1344
		// there is only media like "media 1000baseT"
1345
		array_push($mediaopts_list, $matches[1]);
1346
	}
1347
}
1348

    
1349
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1350
$shortcut_section = "interfaces";
1351

    
1352
$closehead = false;
1353
include("head.inc");
1354
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1355
$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCP6"), "slaac" => gettext("SLAAC"), "6rd" => gettext("6rd Tunnel"), "6to4" => gettext("6to4 Tunnel"), "track6" => gettext("Track Interface"));
1356

    
1357
?>
1358

    
1359
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1360
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1361
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1362
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1363

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

    
1435
	function show_allcfg(obj) {
1436
		if (obj.checked)
1437
			jQuery('#allcfg').show();
1438
		else
1439
			jQuery('#allcfg').hide();
1440
	}
1441

    
1442
	function show_reset_settings(reset_type) {
1443
		if (reset_type == 'preset') {
1444
			jQuery('#pppoepresetwrap').show();
1445
			jQuery('#pppoecustomwrap').hide();
1446
		}
1447
		else if (reset_type == 'custom') {
1448
			jQuery('#pppoecustomwrap').show();
1449
			jQuery('#pppoepresetwrap').hide();
1450
		} else {
1451
			jQuery('#pppoecustomwrap').hide();
1452
			jQuery('#pppoepresetwrap').hide();
1453
		}
1454
	}
1455
	function show_mon_config() {
1456
		jQuery("#showmonbox").html('');
1457
		jQuery('#showmon').css('display','block');
1458
	}
1459

    
1460
	function openwindow(url) {
1461
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1462
		if (oWin==null || typeof(oWin)=="undefined")
1463
			return false;
1464
		else
1465
			return true;
1466
	}
1467
	function country_list() {
1468
		jQuery('#country').children().remove();
1469
		jQuery('#provider_list').children().remove();
1470
		jQuery('#providerplan').children().remove();
1471
		jQuery.ajax("getserviceproviders.php",{
1472
			success: function(response) {
1473
				var responseTextArr = response.split("\n");
1474
				responseTextArr.sort();
1475
				responseTextArr.each( function(value) {
1476
					var option = new Element('option');
1477
					country = value.split(":");
1478
					option.text = country[0];
1479
					option.value = country[1];
1480
					jQuery('#country').append(option);
1481
				});
1482
			}
1483
		});
1484
		jQuery('#trcountry').css('display',"table-row");
1485
	}
1486

    
1487
	function providers_list() {
1488
		jQuery('#provider_list').children().remove();
1489
		jQuery('#providerplan').children().remove();
1490
		jQuery.ajax("getserviceproviders.php",{
1491
			type: 'post',
1492
			data: {country : jQuery('#country').val()},
1493
			success: function(response) {
1494
				var responseTextArr = response.split("\n");
1495
				responseTextArr.sort();
1496
				responseTextArr.each( function(value) {
1497
					var option = new Element('option');
1498
					option.text = value;
1499
					option.value = value;
1500
					jQuery('#provider_list').append(option);
1501
				});
1502
			}
1503
		});
1504
		jQuery('#trprovider').css("display","table-row");
1505
		jQuery('#trproviderplan').css("display","none");
1506
	}
1507

    
1508
	function providerplan_list() {
1509
		jQuery('#providerplan').children().remove();
1510
		jQuery('#providerplan').append( new Element('option') );
1511
		jQuery.ajax("getserviceproviders.php",{
1512
			type: 'post',
1513
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val()},
1514
			success: function(response) {
1515
				var responseTextArr = response.split("\n");
1516
				responseTextArr.sort();
1517
				responseTextArr.each( function(value) {
1518
					if(value != "") {
1519
						providerplan = value.split(":");
1520

    
1521
						var option = new Element('option');
1522
						option.text = providerplan[0] + " - " + providerplan[1];
1523
						option.value = providerplan[1];
1524
						jQuery('#providerplan').append(option);
1525
					}
1526
				});
1527
			}
1528
		});
1529
		jQuery('#trproviderplan').css("display","table-row");
1530
	}
1531

    
1532
	function prefill_provider() {
1533
		jQuery.ajax("getserviceproviders.php",{
1534
			type: 'post',
1535
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val(), plan : jQuery('#providerplan').val()},
1536
			success: function(data,textStatus,response) {
1537
				var xmldoc = response.responseXML;
1538
				var provider = xmldoc.getElementsByTagName('connection')[0];
1539
				jQuery('#username').val('');
1540
				jQuery('#password').val('');
1541
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1542
					jQuery('#phone').val('#777');
1543
					jQuery('#apn').val('');
1544
				} else {
1545
					jQuery('#phone').val('*99#');
1546
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1547
				}
1548
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1549
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1550
				jQuery('#username').val(username);
1551
				jQuery('#password').val(password);
1552
			}
1553
		});
1554
	}
1555

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

    
1973
									<tr style='display:none' id="show_adv_dhcp_protocol_timing">
1974
										<td width="22%" valign="top" class="vncell"><a target="_blank" href="http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#PROTOCOL_TIMING"><?=gettext("Protocol Timing"); ?></a></td>
1975
										<td width="48%" class="vtable">
1976
											Timeout: <input name="adv_dhcp_pt_timeout" type="text" class="formfld unknown" id="adv_dhcp_pt_timeout" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_timeout']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
1977
											Retry:   <input name="adv_dhcp_pt_retry"   type="text" class="formfld unknown" id="adv_dhcp_pt_retry"   size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_retry']);?>"   onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
1978
											Select Timeout: <input name="adv_dhcp_pt_select_timeout" type="text" class="formfld unknown" id="adv_dhcp_pt_select_timeout" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_select_timeout']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
1979

    
1980
											&nbsp; &nbsp; &nbsp; &nbsp; 
1981
											Presets: &nbsp;
1982
											<input name="adv_dhcp_pt_values" type="radio" value="DHCP"	id="customdhcpptdhcpdefaults"	onclick="customdhcpptsetvalues(this, iform);" />FreeBSD Default &nbsp; 
1983
											<input name="adv_dhcp_pt_values" type="radio" value="Clear"	id="customdhcpptclear"		onclick="customdhcpptsetvalues(this, iform);" />Clear
1984

    
1985
											<br />
1986
											Reboot: <input name="adv_dhcp_pt_reboot" type="text" class="formfld unknown" id="adv_dhcp_pt_reboot" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_reboot']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
1987
											Backoff Cutoff:   <input name="adv_dhcp_pt_backoff_cutoff"   type="text" class="formfld unknown" id="adv_dhcp_pt_backoff_cutoff"   size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_backoff_cutoff']);?>"   onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
1988
											Initial Interval: <input name="adv_dhcp_pt_initial_interval" type="text" class="formfld unknown" id="adv_dhcp_pt_initial_interval" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_initial_interval']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
1989

    
1990
											&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
1991
											<input name="adv_dhcp_pt_values" type="radio" value="pfSense"	id="customdhcpptpfsensedefaults"	onclick="customdhcpptsetvalues(this, iform);" />pfSense Default &nbsp; 
1992
											<input name="adv_dhcp_pt_values" type="radio" value="SavedCfg" checked="checked"	id="customdhcpptsavedcfg"		onclick="customdhcpptsetvalues(this, iform);" />Saved Cfg 
1993

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

    
1997
											<script type="text/javascript">
1998
											//<![CDATA[
1999
												function customdhcpptcheckradiobuton(T, BUTTON) {
2000
													for (var i = 0; i < T.length; i++) {
2001
														T[i].checked = false;
2002
														if (T[i].value == BUTTON) T[i].checked = true;
2003
													}
2004
													T.value = BUTTON;
2005
												}
2006

    
2007
												function customdhcpptsetvalues(T, FORM) {
2008
													// timeout, retry, select-timeout, reboot, backoff-cutoff, initial-interval
2009
													if (T.value == "DHCP")		customdhcpptsetvaluesnow(T, FORM, "60", "300", "0", "10", "120", "10");
2010
													if (T.value == "pfSense")	customdhcpptsetvaluesnow(T, FORM, "60", "15", "0", "", "", "1");
2011
													if (T.value == "SavedCfg")	customdhcpptsetvaluesnow(T, FORM, "<?=htmlspecialchars($pconfig['adv_dhcp_pt_timeout']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_retry']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_select_timeout']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_reboot']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_backoff_cutoff']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_initial_interval']);?>");
2012
													if (T.value == "Clear")		customdhcpptsetvaluesnow(T, FORM, "", "", "", "", "", "");
2013
												}
2014

    
2015
												function customdhcpptsetvaluesnow(T, FORM, timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
2016
													FORM.adv_dhcp_pt_timeout.value = timeout;
2017
													FORM.adv_dhcp_pt_retry.value = retry;
2018
													FORM.adv_dhcp_pt_select_timeout.value = selecttimeout;
2019
													FORM.adv_dhcp_pt_reboot.value = reboot;
2020
													FORM.adv_dhcp_pt_backoff_cutoff.value = backoffcutoff;
2021
													FORM.adv_dhcp_pt_initial_interval.value = initialinterval;
2022

    
2023
													FORM.adv_dhcp_pt_values.value = T.value;
2024
												}
2025

    
2026
												<!-- Set the adv_dhcp_pt_values radio button from saved config -->
2027
												var RADIOBUTTON_VALUE = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values']);?>";
2028
												if (RADIOBUTTON_VALUE == "") RADIOBUTTON_VALUE = "SavedCfg";
2029
												customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, RADIOBUTTON_VALUE);
2030
											//]]>
2031
											</script>
2032
										</td>
2033
									</tr>
2034

    
2035
									<tr style='display:none' id="show_adv_dhcp_lease_requirements_and_requests">
2036
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Lease Requirements and Requests</a>"); ?></td>
2037
										<td width="78%" class="vtable">
2038
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Send</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Options</a>"); ?><br />
2039
											<input name="adv_dhcp_send_options" type="text" class="formfld unknown" id="adv_dhcp_send_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_send_options']);?>" />
2040
											<br />
2041
											<?=gettext("The values in this field are DHCP options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2042
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2043
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2044
											"Some ISPs may require certain options be or not be sent. "); ?>
2045
											<hr/>
2046
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Request</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Options</a>"); ?><br />
2047
											<input name="adv_dhcp_request_options" type="text" class="formfld unknown" id="adv_dhcp_request_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_request_options']);?>" />
2048
											<br />
2049
											<?=gettext("The values in this field are DHCP option 55 to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2050
											"Some ISPs may require certain options be or not be requested. "); ?>
2051
											<hr/>
2052
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Require</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Options</a>"); ?><br />
2053
											<input name="adv_dhcp_required_options" type="text" class="formfld unknown" id="adv_dhcp_required_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_required_options']);?>" />
2054
											<br />
2055
											<?=gettext("The values in this field are DHCP options required by the client when requesting a DHCP lease.  [option [, ...]] "); ?>
2056
										</td>
2057
									</tr>
2058

    
2059
									<tr style='display:none' id="show_adv_dhcp_option_modifiers">
2060
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Option</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#OPTION_MODIFIERS\">Modifiers</a>"); ?></td>
2061
										<td width="78%" class="vtable">
2062
											<input name="adv_dhcp_option_modifiers" type="text" class="formfld unknown" id="adv_dhcp_option_modifiers" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_option_modifiers']);?>" />
2063
											<br />
2064
											<?=gettext("The values in this field are DHCP option modifiers applied to obtained DHCP lease.  [modifier option declaration [, ...]] <br /> " .
2065
											"modifiers: (default, supersede, prepend, append)"); ?>
2066
										</td>
2067
									</tr>
2068

    
2069
									<tr style='display:none' id="show_adv_dhcp_config_file_override">
2070
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5\">Configuration File</a> Override"); ?></td>
2071
										<td width="78%" class="vtable">
2072
 											<input name="adv_dhcp_config_file_override_path"   type="text" class="formfld unknown" id="adv_dhcp_config_file_override_path"  size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override_path']);?>" />
2073
											<br />
2074
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2075
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2076
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2077
											"Some ISPs may require certain options be or not be sent. "); ?>
2078
										</td>
2079
									</tr>
2080

    
2081
 									<tr>
2082
 										<td colspan="2" valign="top" height="16"></td>
2083
 									</tr>
2084

    
2085
								</table>
2086

    
2087
									<script type="text/javascript">
2088
									//<![CDATA[
2089
										function show_adv_dhcp_config(T) {
2090

    
2091
											if (T.checked) T.value = "Selected";
2092
											else T.value = "";
2093

    
2094
											     if (document.iform.adv_dhcp_config_file_override.checked)	show_hide_adv_dhcp('none', 'none', '');
2095
											else if (document.iform.adv_dhcp_config_advanced.checked)	show_hide_adv_dhcp('', '', 'none');
2096
											else 									show_hide_adv_dhcp('', 'none', 'none');
2097
										}
2098

    
2099
										function show_hide_adv_dhcp(basic, advanced, override) {
2100

    
2101
											document.getElementById("show_basic_dhcphostname").style.display = basic;
2102
											document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2103
											document.getElementById("show_basic_dhcprejectlease").style.display = basic;
2104

    
2105
											document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2106
											document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2107
											document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2108

    
2109
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2110
										}
2111

    
2112
										<!-- Set the adv_dhcp_config_advanced checkbox from saved config -->
2113
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_advanced']);?>" == "Selected") document.iform.adv_dhcp_config_advanced.checked = true;
2114
										show_adv_dhcp_config(document.iform.adv_dhcp_config_advanced);
2115

    
2116
										<!-- Set the adv_dhcp_config_file_override checkbox from saved config -->
2117
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override']);?>" == "Selected") document.iform.adv_dhcp_config_file_override.checked = true;
2118
										show_adv_dhcp_config(document.iform.adv_dhcp_config_file_override);
2119
									//]]>
2120
									</script>
2121

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

    
2191
									<tr style='display:none' id="show_adv_dhcp6_interface_statement">
2192
										<td width="22%" valign="top" class="vncell">
2193
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Interface_statement\">Interface Statement</a>"); ?>
2194
											<br /><br />
2195
											<input name="adv_dhcp6_interface_statement_information_only_enable" type="checkbox" id="adv_dhcp6_interface_statement_information_only_enable" value="" onclick="show_adv_dhcp6_config(this)" />
2196
											<?=gettext("Information Only"); ?>
2197
										</td>
2198
										<td width="78%" class="vtable">
2199
											<?=gettext("Send Options"); ?><br />
2200
											<input name="adv_dhcp6_interface_statement_send_options" type="text" class="formfld unknown" id="adv_dhcp6_interface_statement_send_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_send_options']);?>" />
2201
											<br />
2202
											<?=gettext("The values in this field are DHCP send options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2203
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2204
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2205
											"Some DHCP services may require certain options be or not be sent. "); ?>
2206
											<br />
2207
											<br />
2208
											<?=gettext("Request Options"); ?><br />
2209
											<input name="adv_dhcp6_interface_statement_request_options" type="text" class="formfld unknown" id="adv_dhcp6_interface_statement_request_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_request_options']);?>" />
2210
											<br />
2211
											<?=gettext("The values in this field are DHCP request options to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2212
											"Some DHCP services may require certain options be or not be requested. "); ?>
2213
											<br />
2214
											<br />
2215
											<?=gettext("Script"); ?><br />
2216
											<input name="adv_dhcp6_interface_statement_script" type="text" class="formfld unknown" id="adv_dhcp6_interface_statement_script" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_script']);?>" />
2217
											<br />
2218
											<?=gettext("The value in this field is the absolute path to a script invoked on certain conditions including when a reply message is received. <br />" .
2219
											"[/[dirname/[.../]]filename[.ext]] "); ?>
2220
										</td>
2221
									</tr>
2222

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

    
2229
											<input name="adv_dhcp6_id_assoc_statement_address_enable" type="checkbox" id="adv_dhcp6_id_assoc_statement_address_enable" value="" onclick="show_adv_dhcp6_config(this);" />
2230
											<?=gettext("Non-Temporary Address Allocation"); ?>
2231
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_address">
2232
											<?=gettext("id-assoc na"); ?>
2233
											<?=gettext("<i>ID</i>"); ?>
2234
											<input name="adv_dhcp6_id_assoc_statement_address_id" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address_id" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_id']);?>" />
2235
											<br />
2236
											<?=gettext("Address"); ?>
2237
											<?=gettext("<i>ipv6-address</i>"); ?>
2238
											<input name="adv_dhcp6_id_assoc_statement_address" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address" size="34" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address']);?>" />
2239
											<?=gettext("<i>pltime</i>"); ?>
2240
											<input name="adv_dhcp6_id_assoc_statement_address_pltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address_pltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_pltime']);?>" />
2241
											<?=gettext("<i>vltime</i>"); ?>
2242
											<input name="adv_dhcp6_id_assoc_statement_address_vltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address_vltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_vltime']);?>" />
2243
											</div>
2244
											<hr/>
2245

    
2246
											<input name="adv_dhcp6_id_assoc_statement_prefix_enable" type="checkbox" id="adv_dhcp6_id_assoc_statement_prefix_enable" value="" onclick="show_adv_dhcp6_config(this)" />
2247
											<?=gettext("Prefix Delegation"); ?>
2248
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_prefix">
2249
											<?=gettext("id-assoc pd"); ?>
2250
											<?=gettext("<i>ID</i>"); ?>
2251
											<input name="adv_dhcp6_id_assoc_statement_prefix_id" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix_id" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_id']);?>" />
2252
											<br />
2253
											<?=gettext("Prefix"); ?>
2254
											<?=gettext("<i>ipv6-prefix</i>"); ?>
2255
											<input name="adv_dhcp6_id_assoc_statement_prefix" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix" size="37" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix']);?>" />
2256
											<?=gettext("<i>pltime</i>"); ?>
2257
											<input name="adv_dhcp6_id_assoc_statement_prefix_pltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix_pltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime']);?>" />
2258
											<?=gettext("<i>vltime</i>"); ?>
2259
											<input name="adv_dhcp6_id_assoc_statement_prefix_vltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix_vltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime']);?>" />
2260
											</div>
2261
										</td>
2262
									</tr>
2263

    
2264
									<tr style='display:none' id="show_adv_dhcp6_prefix_interface_statement">
2265
										<td width="22%" valign="top" class="vncell">
2266
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Prefix_interface_statement\">Prefix Interface Statement</a>"); ?>
2267
										</td>
2268
										<td width="78%" class="vtable">
2269
											<?=gettext("Prefix Interface "); ?>
2270
											<?=gettext("<i>sla-id</i>"); ?>
2271
											<input name="adv_dhcp6_prefix_interface_statement_sla_id" type="text" class="formfld unknown" id="adv_dhcp6_prefix_interface_statement_sla_id" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_prefix_interface_statement_sla_id']);?>" />
2272
											<?=gettext("<i>sla-len</i>"); ?>
2273
											<input name="adv_dhcp6_prefix_interface_statement_sla_len" type="text" class="formfld unknown" id="adv_dhcp6_prefix_interface_statement_sla_len" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_prefix_interface_statement_sla_len']);?>" />
2274
										</td>
2275
									</tr>
2276

    
2277
									<tr style='display:none' id="show_adv_dhcp6_authentication_statement">
2278
										<td width="22%" valign="top" class="vncell">
2279
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Authentication_statement\">Authentication Statement</a>"); ?>
2280
										</td>
2281
										<td width="78%" class="vtable">
2282
											<?=gettext("<i>authname</i>"); ?>
2283
											<input name="adv_dhcp6_authentication_statement_authname" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_authname" size="10" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_authname']);?>" />
2284
											<?=gettext("<i>protocol</i>"); ?>
2285
											<input name="adv_dhcp6_authentication_statement_protocol" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_protocol" size="6" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_protocol']);?>" />
2286
											<?=gettext("<i>algorithm</i>"); ?>
2287
											<input name="adv_dhcp6_authentication_statement_algorithm" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_algorithm" size="8" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_algorithm']);?>" />
2288
											<?=gettext("<i>rdm</i>"); ?>
2289
											<input name="adv_dhcp6_authentication_statement_rdm" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_rdm" size="9" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_rdm']);?>" />
2290
										</td>
2291
									</tr>
2292

    
2293
									<tr style='display:none' id="show_adv_dhcp6_key_info_statement">
2294
										<td width="22%" valign="top" class="vncell">
2295
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Keyinfo_statement\">Keyinfo Statement</a>"); ?>
2296
										</td>
2297
										<td width="78%" class="vtable">
2298
											<?=gettext("<i>keyname</i>"); ?>
2299
											<input name="adv_dhcp6_key_info_statement_keyname" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_keyname" size="27" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_keyname']);?>" />
2300
											<?=gettext("<i>realm</i>"); ?>
2301
											<input name="adv_dhcp6_key_info_statement_realm" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_realm" size="37" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_realm']);?>" />
2302
											<br />
2303
											<?=gettext("<i>keyid</i>"); ?>
2304
											<input name="adv_dhcp6_key_info_statement_keyid" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_keyid" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_keyid']);?>" />
2305
											<?=gettext("<i>secret</i>"); ?>
2306
											<input name="adv_dhcp6_key_info_statement_secret" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_secret" size="36" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_secret']);?>" />
2307
											<?=gettext("<i>expire</i>"); ?>
2308
											<input name="adv_dhcp6_key_info_statement_expire" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_expire" size="15" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_expire']);?>" />
2309
										</td>
2310
									</tr>
2311

    
2312
									<tr style='display:none' id="show_adv_dhcp6_config_file_override">
2313
										<td width="22%" valign="top" class="vncell">
2314
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports\">Configuration File</a> Override"); ?>
2315
										</td>
2316
										<td width="78%" class="vtable">
2317
 											<input name="adv_dhcp6_config_file_override_path"   type="text" class="formfld unknown" id="adv_dhcp6_config_file_override_path"  size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override_path']);?>" />
2318
											<br />
2319
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2320
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2321
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2322
											"Some ISPs may require certain options be or not be sent. "); ?>
2323
										</td>
2324
									</tr>
2325

    
2326
 									<tr>
2327
 										<td colspan="2" valign="top" height="16"></td>
2328
 									</tr>
2329

    
2330
								</table>
2331

    
2332
									<script type="text/javascript">
2333
									//<![CDATA[
2334
										function show_adv_dhcp6_config(T) {
2335

    
2336
											if (T.checked) T.value = "Selected";
2337
											else T.value = "";
2338

    
2339
											     if (document.iform.adv_dhcp6_config_file_override.checked)	show_hide_adv_dhcp6('none', 'none', ''    );
2340
											else if (document.iform.adv_dhcp6_config_advanced.checked)		show_hide_adv_dhcp6('none', '',     'none');
2341
											else 															show_hide_adv_dhcp6('',     'none', 'none');
2342
										}
2343

    
2344
										function show_hide_adv_dhcp6(basic, advanced, override) {
2345

    
2346
											document.getElementById("basicdhcp6_use_pppoeinterface").style.display = basic;
2347
											document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2348
											document.getElementById("basicdhcp6_show_dhcp6_prefix_send_hint").style.display = basic;
2349
											document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
2350

    
2351
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2352
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2353

    
2354
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2355
											if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked)  {
2356
												document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2357
											}
2358

    
2359
											document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = 'none';
2360
											document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = 'none';
2361
											if (document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked)  {
2362
												document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = advanced;
2363
												document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = advanced;
2364
											}
2365

    
2366
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2367
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2368

    
2369
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2370
										}
2371

    
2372
										<!-- Set the adv_dhcp6_config_advanced checkbox from saved config -->
2373
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_advanced']);?>" == "Selected") document.iform.adv_dhcp6_config_advanced.checked = true;
2374
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_advanced);
2375

    
2376
										<!-- Set the adv_dhcp6_config_file_override checkbox from saved config -->
2377
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override']);?>" == "Selected") document.iform.adv_dhcp6_config_file_override.checked = true;
2378
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_file_override);
2379

    
2380
										<!-- Set the adv_dhcp6_interface_statement_information_only_enable checkbox from saved config -->
2381
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_information_only_enable']);?>" == "Selected") document.iform.adv_dhcp6_interface_statement_information_only_enable.checked = true;
2382
										show_adv_dhcp6_config(document.iform.adv_dhcp6_interface_statement_information_only_enable);
2383

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

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

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

    
2696
									<tr>
2697
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
2698
										<?php if (isset($pconfig['pppid'])): ?>
2699
											<td width="78%" class="vtable">
2700
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2701
											<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
2702
											</td>
2703
										<?php else: ?>
2704
											<td width="78%" class="vtable">
2705
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2706
											<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
2707
											</td>
2708
										<?php endif; ?>
2709
									</tr>
2710
									<tr>
2711
										<td colspan="2" valign="top" height="16"></td>
2712
									</tr>
2713
								</table>
2714
							</td>
2715
						</tr>
2716
						<tr style="display:none;" id="pptp">
2717
							<td colspan="2" style="padding:0px;">
2718
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pptp">
2719
									<tr>
2720
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP/L2TP configuration"); ?></td>
2721
									</tr>
2722
									<tr>
2723
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2724
										<td width="78%" class="vtable">
2725
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>" />
2726
										</td>
2727
									</tr>
2728
									<tr>
2729
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2730
										<td width="78%" class="vtable">
2731
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>" />
2732
										</td>
2733
									</tr>
2734
									<tr>
2735
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
2736
										<td width="78%" class="vtable">
2737
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>" />
2738
											/
2739
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
2740
												<?php for ($i = 31; $i > 0; $i--): ?>
2741
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected=\"selected\""; ?>>
2742
														<?=$i;?></option>
2743
												<?php endfor; ?>
2744
											</select>
2745
										</td>
2746
									</tr>
2747
									<tr>
2748
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
2749
										<td width="78%" class="vtable">
2750
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>" />
2751
										</td>
2752
									</tr>
2753
									<tr>
2754
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2755
										<td width="78%" class="vtable">
2756
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked=\"checked\""; ?> />
2757
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br />
2758
											<?=gettext("This option causes the interface to operate in dial-on-demand mode, allowing you to have a"); ?> <i><?=gettext("virtual full time"); ?></i> <?=gettext("connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected."); ?>
2759
										</td>
2760
									</tr>
2761
									<tr>
2762
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2763
										<td width="78%" class="vtable">
2764
											<input name="pptp_idletimeout" type="text" class="formfld unknown" id="pptp_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pptp_idletimeout']);?>" /> <?=gettext("seconds"); ?><br /><?=gettext("If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. An idle timeout of zero disables this feature."); ?>
2765
										</td>
2766
									</tr>
2767
									<tr>
2768
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
2769
										<?php if (isset($pconfig['pppid'])): ?>
2770
											<td width="78%" class="vtable">
2771
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
2772
											<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
2773
											</td>
2774
										<?php else: ?>
2775
											<td width="78%" class="vtable">
2776
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
2777
											<?=gettext("for advanced PPTP and L2TP configuration options");?>.
2778
											</td>
2779
										<?php endif; ?>
2780
									</tr>
2781
									<tr>
2782
										<td colspan="2" valign="top" height="16"></td>
2783
									</tr>
2784
								</table>
2785
							</td>
2786
						</tr>
2787
						<?php
2788
							/* Wireless interface? */
2789
							if (isset($wancfg['wireless'])):
2790
						?>
2791
						<tr>
2792
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
2793
						</tr>
2794
						<tr>
2795
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
2796
							<td class="vtable">
2797
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked=\"checked\"";?> />
2798
								<br /><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
2799
							</td>
2800
						</tr>
2801
						<tr>
2802
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
2803
							<td class="vtable">
2804
							<select name="standard" class="formselect" id="standard">
2805
								<?php
2806
								$rowIndex = 0;
2807
								foreach($wl_modes as $wl_standard => $wl_channels) {
2808
									$rowIndex++;
2809
									echo "<option ";
2810
									if ($pconfig['standard'] == "$wl_standard")
2811
										echo "selected=\"selected\" ";
2812
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
2813
								}
2814
								if ($rowIndex == 0)
2815
									echo "<option></option>";
2816
								?>
2817
							</select>
2818
							</td>
2819
						</tr>
2820
						<?php if (isset($wl_modes['11g'])): ?>
2821
						<tr>
2822
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
2823
							<td class="vtable">
2824
								<select name="protmode" class="formselect" id="protmode">
2825
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected=\"selected\"";?> value="off"><?=gettext("Protection mode off"); ?></option>
2826
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected=\"selected\"";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
2827
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected=\"selected\"";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
2828
								</select>
2829
								<br />
2830
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
2831
								<br />
2832
							</td>
2833
						</tr>
2834
						<?php else: ?>
2835
						<input name="protmode" type="hidden" id="protmode" value="off" />
2836
						<?php endif; ?>
2837
						<tr>
2838
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
2839
							<td class="vtable">
2840
								<select name="txpower" class="formselect" id="txpower">
2841
									<?
2842
									for($x = 99; $x > 0; $x--) {
2843
										if($pconfig["txpower"] == $x)
2844
											$SELECTED = " selected=\"selected\"";
2845
										else
2846
											$SELECTED = "";
2847
										echo "<option {$SELECTED}>{$x}</option>\n";
2848
									}
2849
									?>
2850
								</select><br />
2851
								<?=gettext("Note: Typically only a few discreet power settings are available and the driver will use the setting closest to the specified value.  Not all adapters support changing the transmit power setting."); ?>
2852
							</td>
2853
						</tr>
2854
						<tr>
2855
							<td valign="top" class="vncellreq"><?=gettext("Channel"); ?></td>
2856
							<td class="vtable">
2857
								<select name="channel" class="formselect" id="channel">
2858
									<option <?php if ($pconfig['channel'] == 0) echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2859
									<?php
2860
									foreach($wl_modes as $wl_standard => $wl_channels) {
2861
										if($wl_standard == "11g") { $wl_standard = "11b/g"; }
2862
										else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
2863
										else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
2864
										foreach($wl_channels as $wl_channel) {
2865
											echo "<option ";
2866
											if ($pconfig['channel'] == "$wl_channel") {
2867
												echo "selected=\"selected\" ";
2868
											}
2869
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
2870
											if(isset($wl_chaninfo[$wl_channel]))
2871
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
2872
											echo "</option>\n";
2873
										}
2874
									}
2875
									?>
2876
								</select>
2877
								<br />
2878
								<?=gettext("Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)"); ?>
2879
								<br />
2880
								<?=gettext("Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above."); ?>
2881
							</td>
2882
						</tr>
2883
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2884
						<tr>
2885
							<td valign="top" class="vncell"><?=gettext("Antenna settings"); ?></td>
2886
							<td class="vtable">
2887
								<table border="0" cellpadding="0" cellspacing="0" summary="antenna settings">
2888
									<tr>
2889
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])): ?>
2890
										<td>
2891
											<?=gettext("Diversity"); ?><br />
2892
											<select name="diversity" class="formselect" id="diversity">
2893
												<option <?php if (!isset($pconfig['diversity'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2894
												<option <?php if ($pconfig['diversity'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Off"); ?></option>
2895
												<option <?php if ($pconfig['diversity'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("On"); ?></option>
2896
											</select>
2897
										</td>
2898
										<td>&nbsp;&nbsp;</td>
2899
										<?php endif; ?>
2900
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])): ?>
2901
										<td>
2902
											<?=gettext("Transmit antenna"); ?><br />
2903
											<select name="txantenna" class="formselect" id="txantenna">
2904
												<option <?php if (!isset($pconfig['txantenna'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2905
												<option <?php if ($pconfig['txantenna'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2906
												<option <?php if ($pconfig['txantenna'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("#1"); ?></option>
2907
												<option <?php if ($pconfig['txantenna'] === '2') echo "selected=\"selected\""; ?> value="2"><?=gettext("#2"); ?></option>
2908
											</select>
2909
										</td>
2910
										<td>&nbsp;&nbsp;</td>
2911
										<?php endif; ?>
2912
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2913
										<td>
2914
											<?=gettext("Receive antenna"); ?><br />
2915
											<select name="rxantenna" class="formselect" id="rxantenna">
2916
												<option <?php if (!isset($pconfig['rxantenna'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2917
												<option <?php if ($pconfig['rxantenna'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2918
												<option <?php if ($pconfig['rxantenna'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("#1"); ?></option>
2919
												<option <?php if ($pconfig['rxantenna'] === '2') echo "selected=\"selected\""; ?> value="2"><?=gettext("#2"); ?></option>
2920
											</select>
2921
										</td>
2922
										<?php endif; ?>
2923
									</tr>
2924
								</table>
2925
								<br />
2926
								<?=gettext("Note: The antenna numbers do not always match up with the labels on the card."); ?>
2927
							</td>
2928
						</tr>
2929
						<?php endif; ?>
2930
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])): ?>
2931
						<tr>
2932
							<td valign="top" class="vncell"><?=gettext("Distance setting"); ?></td>
2933
							<td class="vtable">
2934
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>" />
2935
								<br />
2936
								<?=gettext("Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client"); ?><br />
2937
								<?=gettext("(measured in Meters and works only for Atheros based cards !)"); ?>
2938
							</td>
2939
						</tr>
2940
						<?php endif; ?>
2941
						<tr>
2942
							<td valign="top" class="vncell"><?=gettext("Regulatory settings"); ?></td>
2943
							<td class="vtable">
2944
								<?=gettext("Regulatory domain"); ?><br />
2945
								<select name="regdomain" class="formselect" id="regdomain">
2946
									<option <?php if (empty($pconfig['regdomain'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2947
									<?php
2948
									foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
2949
										echo "<option ";
2950
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
2951
											echo "selected=\"selected\" ";
2952
										}
2953
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
2954
									}
2955
									?>
2956
								</select>
2957
								<br />
2958
								<?=gettext("Note: Some cards have a default that is not recognized and require changing the regulatory domain to one in this list for the changes to other regulatory settings to work."); ?>
2959
								<br /><br />
2960
								<?=gettext("Country (listed with country code and regulatory domain)"); ?><br />
2961
								<select name="regcountry" class="formselect" id="regcountry">
2962
									<option <?php if (empty($pconfig['regcountry'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2963
									<?php
2964
									foreach($wl_countries as $wl_country_key => $wl_country) {
2965
										echo "<option ";
2966
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
2967
											echo "selected=\"selected\" ";
2968
										}
2969
										echo "value=\"{$wl_countries_attr[$wl_country_key]['ID']}\">{$wl_country['name']} -- ({$wl_countries_attr[$wl_country_key]['ID']}, " . strtoupper($wl_countries_attr[$wl_country_key]['rd'][0]['REF']) . ")</option>\n";
2970
									}
2971
									?>
2972
								</select>
2973
								<br />
2974
								<?=gettext("Note: Any country setting other than \"Default\" will override the regulatory domain setting"); ?>.
2975
								<br /><br />
2976
								<?=gettext("Location"); ?><br />
2977
								<select name="reglocation" class="formselect" id="reglocation">
2978
									<option <?php if (empty($pconfig['reglocation'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2979
									<option <?php if ($pconfig['reglocation'] == 'indoor') echo "selected=\"selected\""; ?> value="indoor"><?=gettext("Indoor"); ?></option>
2980
									<option <?php if ($pconfig['reglocation'] == 'outdoor') echo "selected=\"selected\""; ?> value="outdoor"><?=gettext("Outdoor"); ?></option>
2981
									<option <?php if ($pconfig['reglocation'] == 'anywhere') echo "selected=\"selected\""; ?> value="anywhere"><?=gettext("Anywhere"); ?></option>
2982
								</select>
2983
								<br /><br />
2984
								<?=gettext("These settings may affect which channels are available and the maximum transmit power allowed on those channels.  Using the correct settings to comply with local regulatory requirements is recommended."); ?>
2985
								<br />
2986
								<?=gettext("Note: All wireless networks on this interface will be temporarily brought down when changing regulatory settings.  Some of the regulatory domains or country codes may not be allowed by some cards.  These settings may not be able to add additional channels that are not already supported."); ?>
2987
							</td>
2988
						</tr>
2989
						<tr>
2990
							<td colspan="2" valign="top" height="16"></td>
2991
						</tr>
2992
						<tr>
2993
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Network-specific wireless configuration");?></td>
2994
						</tr>
2995
						<tr>
2996
							<td valign="top" class="vncellreq"><?=gettext("Mode"); ?></td>
2997
							<td class="vtable">
2998
								<select name="mode" class="formselect" id="mode">
2999
									<option <?php if ($pconfig['mode'] == 'bss') echo "selected=\"selected\"";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
3000
									<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected=\"selected\"";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
3001
									<option <?php if ($pconfig['mode'] == 'hostap') echo "selected=\"selected\"";?> value="hostap"><?=gettext("Access Point"); ?></option>
3002
								</select>
3003
							</td>
3004
						</tr>
3005
						<tr>
3006
							<td valign="top" class="vncellreq"><?=gettext("SSID"); ?></td>
3007
							<td class="vtable">
3008
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>" />
3009
								<br />
3010
								<?=gettext("Note: Only required in Access Point mode. If left blank in Ad-hoc or Infrastructure mode, this interface will connect to any available SSID"); ?>
3011
							</td>
3012
						</tr>
3013
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
3014
						<tr>
3015
							<td valign="top" class="vncell"><?=gettext("Minimum wireless standard"); ?></td>
3016
							<td class="vtable">
3017
								<select name="puremode" class="formselect" id="puremode">
3018
									<option <?php if ($pconfig['puremode'] == 'any') echo "selected=\"selected\"";?> value="any"><?=gettext("Any"); ?></option>
3019
									<?php if (isset($wl_modes['11g'])): ?>
3020
									<option <?php if ($pconfig['puremode'] == '11g') echo "selected=\"selected\"";?> value="11g"><?=gettext("802.11g"); ?></option>
3021
									<?php endif; ?>
3022
									<option <?php if ($pconfig['puremode'] == '11n') echo "selected=\"selected\"";?> value="11n"><?=gettext("802.11n"); ?></option>
3023
								</select>
3024
								<br />
3025
								<?=gettext("When operating as an access point, allow only stations capable of the selected wireless standard to associate (stations not capable are not permitted to associate)."); ?>
3026
							</td>
3027
						</tr>
3028
						<?php elseif (isset($wl_modes['11g'])): ?>
3029
						<tr>
3030
							<td valign="top" class="vncell"><?=gettext("802.11g only"); ?></td>
3031
							<td class="vtable">
3032
								<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <?php if ($pconfig['puremode'] == '11g') echo "checked=\"checked\"";?> />
3033
								<br /><?=gettext("When operating as an access point in 802.11g mode, allow only 11g-capable stations to associate (11b-only stations are not permitted to associate)."); ?>
3034
							</td>
3035
						</tr>
3036
						<?php endif; ?>
3037
						<tr>
3038
							<td valign="top" class="vncell"><?=gettext("Allow intra-BSS communication"); ?></td>
3039
							<td class="vtable">
3040
								<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <?php if ($pconfig['apbridge_enable']) echo "checked=\"checked\"";?> />
3041
								<br />
3042
								<?=gettext("When operating as an access point, enable this if you want to pass packets between wireless clients directly."); ?>
3043
								<br />
3044
								<?=gettext("Disabling the internal bridging is useful when traffic is to be processed with packet filtering."); ?>
3045
							</td>
3046
						</tr>
3047
						<tr>
3048
							<td valign="top" class="vncell"><?=gettext("Enable WME"); ?></td>
3049
							<td class="vtable">
3050
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <?php if ($pconfig['wme_enable']) echo "checked=\"checked\"";?> />
3051
								<br /><?=gettext("Setting this option will force the card to use WME (wireless QoS)."); ?>
3052
							</td>
3053
						</tr>
3054
						<tr>
3055
							<td valign="top" class="vncell"><?=gettext("Enable Hide SSID"); ?></td>
3056
							<td class="vtable">
3057
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <?php if ($pconfig['hidessid_enable']) echo "checked=\"checked\"";?> />
3058
								<br />
3059
								<?=gettext("Setting this option will force the card to NOT broadcast its SSID"); ?>
3060
								<br />
3061
								<?=gettext("(this might create problems for some clients)."); ?>
3062
							</td>
3063
						</tr>
3064
						<tr>
3065
							<td valign="top" class="vncell"><?=gettext("WEP"); ?></td>
3066
							<td class="vtable">
3067
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <?php if ($pconfig['wep_enable']) echo "checked=\"checked\""; ?> />
3068
								<strong><?=gettext("Enable WEP"); ?></strong>
3069
								<table border="0" cellspacing="0" cellpadding="0" summary="wep">
3070
									<tr>
3071
										<td>&nbsp;</td>
3072
										<td>&nbsp;</td>
3073
										<td>&nbsp;<?=gettext("TX key"); ?>&nbsp;</td>
3074
									</tr>
3075
									<tr>
3076
										<td><?=gettext("Key 1:"); ?>&nbsp;&nbsp;</td>
3077
										<td>
3078
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>" />
3079
										</td>
3080
										<td align="center">
3081
											<input name="txkey" type="radio" value="1" <?php if ($pconfig['txkey'] == 1) echo "checked=\"checked\"";?> />
3082
										</td>
3083
									</tr>
3084
									<tr>
3085
										<td><?=gettext("Key 2:"); ?>&nbsp;&nbsp;</td>
3086
										<td>
3087
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>" />
3088
										</td>
3089
										<td align="center">
3090
											<input name="txkey" type="radio" value="2" <?php if ($pconfig['txkey'] == 2) echo "checked=\"checked\"";?> />
3091
										</td>
3092
									</tr>
3093
									<tr>
3094
										<td><?=gettext("Key 3:"); ?>&nbsp;&nbsp;</td>
3095
										<td>
3096
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>" />
3097
										</td>
3098
										<td align="center">
3099
											<input name="txkey" type="radio" value="3" <?php if ($pconfig['txkey'] == 3) echo "checked=\"checked\"";?> />
3100
										</td>
3101
									</tr>
3102
									<tr>
3103
										<td><?=gettext("Key 4:"); ?>&nbsp;&nbsp;</td>
3104
										<td>
3105
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>" />
3106
										</td>
3107
										<td align="center">
3108
											<input name="txkey" type="radio" value="4" <?php if ($pconfig['txkey'] == 4) echo "checked=\"checked\"";?> />
3109
										</td>
3110
									</tr>
3111
								</table>
3112
								<br />
3113
								<?=gettext("40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'."); ?><br />
3114
								<?=gettext("104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'."); ?>
3115
							</td>
3116
						</tr>
3117
						<tr>
3118
							<td valign="top" class="vncell"><?=gettext("WPA"); ?></td>
3119
							<td class="vtable">
3120
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <?php if ($pconfig['wpa_enable']) echo "checked=\"checked\""; ?> />
3121
								<strong><?=gettext("Enable WPA"); ?></strong>
3122
								<br /><br />
3123
								<table border="0" cellspacing="0" cellpadding="0" summary="wpa">
3124
									<tr>
3125
										<td>&nbsp;</td>
3126
										<td>&nbsp;<?=gettext("WPA Pre-Shared Key"); ?>&nbsp;</td>
3127
									</tr>
3128
									<tr>
3129
										<td><?=gettext("PSK:"); ?>&nbsp;&nbsp;</td>
3130
										<td>
3131
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>" />
3132
										</td>
3133
									</tr>
3134
								</table>
3135
								<br /><?=gettext("Passphrase must be from 8 to 63 characters."); ?>
3136
							</td>
3137
						</tr>
3138
						<tr>
3139
							<td valign="top" class="vncell"><?=gettext("WPA Mode"); ?></td>
3140
							<td class="vtable">
3141
								<select name="wpa_mode" class="formselect" id="wpa_mode">
3142
									<option <?php if ($pconfig['wpa_mode'] == '1') echo "selected=\"selected\"";?> value="1"><?=gettext("WPA"); ?></option>
3143
									<option <?php if ($pconfig['wpa_mode'] == '2') echo "selected=\"selected\"";?> value="2"><?=gettext("WPA2"); ?></option>
3144
									<option <?php if ($pconfig['wpa_mode'] == '3') echo "selected=\"selected\"";?> value="3"><?=gettext("Both"); ?></option>
3145
								</select>
3146
							</td>
3147
						</tr>
3148
						<tr>
3149
							<td valign="top" class="vncell"><?=gettext("WPA Key Management Mode"); ?></td>
3150
							<td class="vtable">
3151
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
3152
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected=\"selected\"";?> value="WPA-PSK"><?=gettext("Pre-Shared Key"); ?></option>
3153
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected=\"selected\"";?> value="WPA-EAP"><?=gettext("Extensible Authentication Protocol"); ?></option>
3154
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected=\"selected\"";?> value="WPA-PSK WPA-EAP"><?=gettext("Both"); ?></option>
3155
								</select>
3156
							</td>
3157
						</tr>
3158
						<tr>
3159
							<td valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
3160
							<td class="vtable">
3161
								<select name="auth_algs" class="formselect" id="auth_algs">
3162
									<option <?php if ($pconfig['auth_algs'] == '1') echo "selected=\"selected\"";?> value="1"><?=gettext("Open System Authentication"); ?></option>
3163
									<option <?php if ($pconfig['auth_algs'] == '2') echo "selected=\"selected\"";?> value="2"><?=gettext("Shared Key Authentication"); ?></option>
3164
									<option <?php if ($pconfig['auth_algs'] == '3') echo "selected=\"selected\"";?> value="3"><?=gettext("Both"); ?></option>
3165
								</select>
3166
								<br /><?=gettext("Note: Shared Key Authentication requires WEP."); ?><br />
3167
							</td>
3168
						</tr>
3169
						<tr>
3170
							<td valign="top" class="vncell"><?=gettext("WPA Pairwise"); ?></td>
3171
							<td class="vtable">
3172
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
3173
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected=\"selected\"";?> value="CCMP TKIP"><?=gettext("Both"); ?></option>
3174
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected=\"selected\"";?> value="CCMP"><?=gettext("AES (recommended)"); ?></option>
3175
									<option <?php if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected=\"selected\"";?> value="TKIP"><?=gettext("TKIP"); ?></option>
3176
								</select>
3177
							</td>
3178
						</tr>
3179
						<tr>
3180
							<td valign="top" class="vncell"><?=gettext("Key Rotation"); ?></td>
3181
							<td class="vtable">
3182
								<input name="wpa_group_rekey" type="text" class="formfld unknown" id="wpa_group_rekey" size="30" value="<?php echo $pconfig['wpa_group_rekey'] ? $pconfig['wpa_group_rekey'] : "60";?>" />
3183
								<br /><?=gettext("Allowed values are 1-9999 but should not be longer than Master Key Regeneration time."); ?>
3184
							</td>
3185
						</tr>
3186
						<tr>
3187
							<td valign="top" class="vncell"><?=gettext("Master Key Regeneration"); ?></td>
3188
							<td class="vtable">
3189
								<input name="wpa_gmk_rekey" type="text" class="formfld" id="wpa_gmk_rekey" size="30" value="<?php echo $pconfig['wpa_gmk_rekey'] ? $pconfig['wpa_gmk_rekey'] : "3600";?>" />
3190
								<br /><?=gettext("Allowed values are 1-9999 but should not be shorter than Key Rotation time."); ?>
3191
							</td>
3192
						</tr>
3193
						<tr>
3194
							<td valign="top" class="vncell"><?=gettext("Strict Key Regeneration"); ?></td>
3195
							<td class="vtable">
3196
								<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <?php if ($pconfig['wpa_strict_rekey']) echo "checked=\"checked\""; ?> />
3197
								<br /><?=gettext("Setting this option will force the AP to rekey whenever a client disassociates."); ?>
3198
							</td>
3199
						</tr>
3200
						<tr>
3201
							<td valign="top" class="vncell"><?=gettext("Enable IEEE802.1X Authentication"); ?></td>
3202
							<td class="vtable">
3203
								<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <?php if ($pconfig['ieee8021x']) echo "checked=\"checked\"";?> />
3204
								<br /><?=gettext("Setting this option will enable 802.1x authentication."); ?>
3205
								<br /><span class="red"><strong><?=gettext("NOTE"); ?>:</strong></span> <?=gettext("this option requires checking the \"Enable WPA box\"."); ?>
3206
							</td>
3207
						</tr>
3208
						<tr>
3209
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server IP Address"); ?></td>
3210
							<td class="vtable">
3211
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>" />
3212
								<br /><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
3213
							</td>
3214
						</tr>
3215
						<tr>
3216
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Port"); ?></td>
3217
							<td class="vtable">
3218
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>" />
3219
								<br /><?=gettext("Leave blank for the default 1812 port."); ?>
3220
							</td>
3221
						</tr>
3222
						<tr>
3223
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Shared Secret"); ?></td>
3224
							<td class="vtable">
3225
								<input name="auth_server_shared_secret" id="auth_server_shared_secret" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_shared_secret']);?>" />
3226
								<br />
3227
							</td>
3228
						</tr>
3229
						<tr>
3230
					<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server IP Address"); ?></td>
3231
							<td class="vtable">
3232
								<input name="auth_server_addr2" id="auth_server_addr2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr2']);?>" />
3233
								<br /><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
3234
							</td>
3235
						</tr>
3236
						<tr>
3237
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Port"); ?></td>
3238
							<td class="vtable">
3239
								<input name="auth_server_port2" id="auth_server_port2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port2']);?>" />
3240
								<br /><?=gettext("Leave blank for the default 1812 port."); ?>
3241
							</td>
3242
						</tr>
3243
						<tr>
3244
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Shared Secret"); ?></td>
3245
							<td class="vtable">
3246
								<input name="auth_server_shared_secret2" id="auth_server_shared_secret2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_shared_secret2']);?>" />
3247
								<br />
3248
							</td>
3249
						</tr>
3250
						<tr>
3251
							<td valign="top" class="vncell">802.1X <?=gettext("Authentication Roaming Preauth"); ?></td>
3252
							<td class="vtable">
3253
								<input name="rsn_preauth" id="rsn_preauth" type="checkbox" class="formfld unknown" size="66" value="yes" <?php if ($pconfig['rsn_preauth']) echo "checked=\"checked\""; ?> />
3254
								<br />
3255
							</td>
3256
						</tr>
3257
						<tr>
3258
							<td colspan="2" valign="top" height="16"></td>
3259
						</tr>
3260
						<?php endif; ?>
3261
						<tr>
3262
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Private networks"); ?></td>
3263
						</tr>
3264
						<tr>
3265
							<td valign="middle" class="vncell">&nbsp;</td>
3266
							<td class="vtable">
3267
								<a name="rfc1918"></a>
3268
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked=\"checked\""; ?> />
3269
								<strong><?=gettext("Block private networks"); ?></strong><br />
3270
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
3271
								"for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as"); ?>
3272
								<?=gettext("well as loopback addresses (127/8)."); ?>&nbsp;&nbsp; <?=gettext("You should generally " .
3273
								"leave this option turned on, unless your WAN network lies in such " .
3274
								"a private address space, too."); ?>
3275
							</td>
3276
						</tr>
3277
						<tr>
3278
							<td valign="middle" class="vncell">&nbsp;</td>
3279
							<td class="vtable">
3280
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked=\"checked\""; ?> />
3281
								<strong><?=gettext("Block bogon networks"); ?></strong><br />
3282
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
3283
								"(but not RFC 1918) or not yet assigned by IANA."); ?>&nbsp;&nbsp;
3284
								<?=gettext("Bogons are prefixes that should never appear in the Internet routing table, " .
3285
								"and obviously should not appear as the source address in any packets you receive."); ?>
3286
								<br /><br />
3287
								<?=gettext("Note: The update frequency can be changed under System->Advanced Firewall/NAT settings.")?>
3288
							</td>
3289
						</tr>
3290
					</table> <!-- End "allcfg" table -->
3291
					</div> <!-- End "allcfg" div -->
3292

    
3293
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="buttons">
3294
						<tr>
3295
							<td width="22%" valign="top">
3296
								&nbsp;
3297
							</td>
3298
							<td width="78%">
3299
								<br />
3300
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
3301
								<input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
3302
								<input name="if" type="hidden" id="if" value="<?=htmlspecialchars($if);?>" />
3303
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
3304
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>" />
3305
								<?php endif; ?>
3306
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>" />
3307
							</td>
3308
						</tr>
3309
					</table>
3310
					</div>
3311
				</td>
3312
			</tr>
3313
		</table>
3314
	</form>
3315
	<script type="text/javascript">
3316
	//<![CDATA[
3317
		var gatewayip;
3318
		var name;
3319
		var gatewayipv6;
3320
		var namev6;
3321
		function show_add_gateway() {
3322
			document.getElementById("addgateway").style.display = '';
3323
			document.getElementById("addgwbox").style.display = 'none';
3324
			document.getElementById("gateway").style.display = 'none';
3325
			document.getElementById("save").style.display = 'none';
3326
			document.getElementById("cancel").style.display = 'none';
3327
			document.getElementById("gwsave").style.display = '';
3328
			document.getElementById("gwcancel").style.display = '';
3329
			jQuery('#notebox').html("");
3330
		}
3331
		function show_add_gateway_v6() {
3332
			document.getElementById("addgatewayv6").style.display = '';
3333
			document.getElementById("addgwboxv6").style.display = 'none';
3334
			document.getElementById("gatewayv6").style.display = 'none';
3335
			document.getElementById("save").style.display = 'none';
3336
			document.getElementById("cancel").style.display = 'none';
3337
			document.getElementById("gwsave").style.display = '';
3338
			document.getElementById("gwcancel").style.display = '';
3339
			jQuery('#noteboxv6').html("");
3340
		}
3341
		function hide_add_gateway() {
3342
			document.getElementById("addgateway").style.display = 'none';
3343
			document.getElementById("addgwbox").style.display = '';
3344
			document.getElementById("gateway").style.display = '';
3345
			document.getElementById("save").style.display = '';
3346
			document.getElementById("cancel").style.display = '';
3347
			document.getElementById("gwsave").style.display = '';
3348
			document.getElementById("gwcancel").style.display = '';
3349
			jQuery('#status').html('');
3350
		}
3351
		function hide_add_gateway_v6() {
3352
			document.getElementById("addgatewayv6").style.display = 'none';
3353
			document.getElementById("addgwboxv6").style.display = '';
3354
			document.getElementById("gatewayv6").style.display = '';
3355
			document.getElementById("save").style.display = '';
3356
			document.getElementById("cancel").style.display = '';
3357
			document.getElementById("gwsave").style.display = '';
3358
			document.getElementById("gwcancel").style.display = '';
3359
			jQuery('#statusv6').html('');
3360
		}
3361
		function hide_add_gatewaysave() {
3362
			document.getElementById("addgateway").style.display = 'none';
3363
			jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
3364
			var iface = jQuery('#if').val();
3365
			name = jQuery('#name').val();
3366
			var descr = jQuery('#gatewaydescr').val();
3367
			gatewayip = jQuery('#gatewayip').val();
3368

    
3369
			var defaultgw = '';
3370
			if (jQuery('#defaultgw').is(':checked'))
3371
				defaultgw = '&defaultgw=on';
3372
			var url = "system_gateways_edit.php";
3373
			var pars = 'isAjax=true&ipprotocol=inet' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3374
			jQuery.ajax(
3375
				url,
3376
				{
3377
					type: 'post',
3378
					data: pars,
3379
					error: report_failure,
3380
					success: save_callback
3381
				});
3382
		}
3383
		function hide_add_gatewaysave_v6() {
3384
			document.getElementById("addgatewayv6").style.display = 'none';
3385
			jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
3386
			var iface = jQuery('#if').val();
3387
			name = jQuery('#namev6').val();
3388
			var descr = jQuery('#gatewaydescrv6').val();
3389
			gatewayip = jQuery('#gatewayipv6').val();
3390
			var defaultgw = '';
3391
			if (jQuery('#defaultgwv6').is(':checked'))
3392
				defaultgw = '&defaultgw=on';
3393
			var url_v6 = "system_gateways_edit.php";
3394
			var pars_v6 = 'isAjax=true&ipprotocol=inet6' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3395
			jQuery.ajax(
3396
				url_v6,
3397
				{
3398
					type: 'post',
3399
					data: pars_v6,
3400
					error: report_failure_v6,
3401
					success: save_callback_v6
3402
				});
3403
		}
3404
		function addOption(selectbox,text,value)
3405
		{
3406
			var optn = document.createElement("OPTION");
3407
			optn.text = text;
3408
			optn.value = value;
3409
			selectbox.append(optn);
3410
			selectbox.prop('selectedIndex',selectbox.children().length-1);
3411
			jQuery('#notebox').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3412
		}
3413
		function addOption_v6(selectbox,text,value)
3414
		{
3415
			var optn = document.createElement("OPTION");
3416
			optn.text = text;
3417
			optn.value = value;
3418
			selectbox.append(optn);
3419
			selectbox.prop('selectedIndex',selectbox.children().length-1);
3420
			jQuery('#noteboxv6').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3421
		}
3422
		function report_failure(request, textStatus, errorThrown) {
3423
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3424
				alert(request.responseText);
3425
			} else {
3426
				alert("Sorry, we could not create your IPv4 gateway at this time.");
3427
			}
3428
			hide_add_gateway();
3429
		}
3430
		function report_failure_v6(request, textStatus, errorThrown) {
3431
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3432
				alert(request.responseText);
3433
			} else {
3434
				alert("Sorry, we could not create your IPv6 gateway at this time.");
3435
			}
3436
			hide_add_gateway_v6();
3437
		}
3438
		function save_callback(response) {
3439
			if(response) {
3440
				document.getElementById("addgateway").style.display = 'none';
3441
				hide_add_gateway();
3442
				var gwtext = escape(name) + " - " + gatewayip;
3443
				addOption(jQuery('#gateway'), gwtext, name);
3444
				// Auto submit form?
3445
				//document.iform.submit();
3446
				//jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader /">');
3447
			} else {
3448
				report_failure();
3449
			}
3450
		}
3451
		function show_advanced_media() {
3452
			document.getElementById("showadvmediabox").innerHTML='';
3453
			aodiv = document.getElementById('showmediaadv');
3454
			aodiv.style.display = "block";
3455
		}
3456
		function save_callback_v6(response_v6) {
3457
			if(response_v6) {
3458
				document.getElementById("addgatewayv6").style.display = 'none';
3459
				hide_add_gateway_v6();
3460
				var gwtext_v6 = escape(name) + " - " + gatewayip;
3461
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
3462
				// Auto submit form?
3463
				//document.iform.submit();
3464
				//jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" />');
3465
			} else {
3466
				report_failure_v6();
3467
			}
3468
		}
3469
		<?php
3470
		echo "show_allcfg(document.iform.enable);";
3471
		echo "updateType('{$pconfig['type']}');\n";
3472
		echo "updateTypeSix('{$pconfig['type6']}');\n";
3473
		?>
3474
	//]]>
3475
	</script>
3476
	<?php include("fend.inc"); ?>
3477
	</body>
3478
</html>
(95-95/256)