Projet

Général

Profil

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

univnautes / usr / local / www / interfaces.php @ 1c764a3a

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
318
// print_r($pconfig);
319

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

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

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

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

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

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

    
436
		clear_subsystem_dirty('interfaces');
437

    
438
		filter_configure();
439

    
440
		enable_rrd_graphing();
441

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

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

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

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

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

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

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

    
607
			if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
608
				$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
609
			} else {
610
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
611
				if ($track6_prefix_id < 0 || $track6_prefix_id >= $ipv6_num_prefix_ids) {
612
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.");
613
				}
614
			}
615
			break;
616
	}
617

    
618

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

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

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

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

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

    
724
		unset($min_mtu, $max_mtu);
725

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1152
		conf_mount_ro();
1153
		write_config();
1154

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

    
1164
		mark_subsystem_dirty('interfaces');
1165

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

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

    
1173
} // end if($_POST)
1174

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

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

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

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

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

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

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

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

    
1367
?>
1368

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2095
								</table>
2096

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

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

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

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

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

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

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

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

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

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

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

    
2233
									<tr style='display:none' id="show_adv_dhcp6_id_assoc_statement">
2234
										<td width="22%" valign="top" class="vncell">
2235
											<?=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>"); ?>
2236
										</td>
2237
										<td width="78%" class="vtable">
2238

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

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

    
2274
									<tr style='display:none' id="show_adv_dhcp6_prefix_interface_statement">
2275
										<td width="22%" valign="top" class="vncell">
2276
											<?=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>"); ?>
2277
										</td>
2278
										<td width="78%" class="vtable">
2279
											<?=gettext("Prefix Interface "); ?>
2280
											<?=gettext("<i>sla-id</i>"); ?>
2281
											<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']);?>" />
2282
											<?=gettext("<i>sla-len</i>"); ?>
2283
											<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']);?>" />
2284
										</td>
2285
									</tr>
2286

    
2287
									<tr style='display:none' id="show_adv_dhcp6_authentication_statement">
2288
										<td width="22%" valign="top" class="vncell">
2289
											<?=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>"); ?>
2290
										</td>
2291
										<td width="78%" class="vtable">
2292
											<?=gettext("<i>authname</i>"); ?>
2293
											<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']);?>" />
2294
											<?=gettext("<i>protocol</i>"); ?>
2295
											<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']);?>" />
2296
											<?=gettext("<i>algorithm</i>"); ?>
2297
											<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']);?>" />
2298
											<?=gettext("<i>rdm</i>"); ?>
2299
											<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']);?>" />
2300
										</td>
2301
									</tr>
2302

    
2303
									<tr style='display:none' id="show_adv_dhcp6_key_info_statement">
2304
										<td width="22%" valign="top" class="vncell">
2305
											<?=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>"); ?>
2306
										</td>
2307
										<td width="78%" class="vtable">
2308
											<?=gettext("<i>keyname</i>"); ?>
2309
											<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']);?>" />
2310
											<?=gettext("<i>realm</i>"); ?>
2311
											<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']);?>" />
2312
											<br />
2313
											<?=gettext("<i>keyid</i>"); ?>
2314
											<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']);?>" />
2315
											<?=gettext("<i>secret</i>"); ?>
2316
											<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']);?>" />
2317
											<?=gettext("<i>expire</i>"); ?>
2318
											<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']);?>" />
2319
										</td>
2320
									</tr>
2321

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

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

    
2340
								</table>
2341

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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