Projet

Général

Profil

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

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

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
// Get configured interface list
58
$ifdescrs = get_configured_interface_with_descr(false, true);
59

    
60
$if = "wan";
61
if ($_REQUEST['if'])
62
	$if = $_REQUEST['if'];
63

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

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

    
74
if (!is_array($pconfig))
75
	$pconfig = array();
76

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

    
80
$a_ppps = &$config['ppps']['ppp'];
81

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

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

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

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

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

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

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

    
125
		/* ================================================ */
126
		/* = force a connection reset at a specific time? = */
127
		/* ================================================ */
128

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

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

    
192
$pconfig['adv_dhcp_pt_values'] = $wancfg['adv_dhcp_pt_values'];
193

    
194
$pconfig['adv_dhcp_send_options'] = $wancfg['adv_dhcp_send_options'];
195
$pconfig['adv_dhcp_request_options'] = $wancfg['adv_dhcp_request_options'];
196
$pconfig['adv_dhcp_required_options'] = $wancfg['adv_dhcp_required_options'];
197
$pconfig['adv_dhcp_option_modifiers'] = $wancfg['adv_dhcp_option_modifiers'];
198

    
199
$pconfig['adv_dhcp_config_advanced'] = $wancfg['adv_dhcp_config_advanced'];
200
$pconfig['adv_dhcp_config_file_override'] = $wancfg['adv_dhcp_config_file_override'];
201
$pconfig['adv_dhcp_config_file_override_path'] = $wancfg['adv_dhcp_config_file_override_path'];
202

    
203
$pconfig['adv_dhcp6_interface_statement_send_options'] = $wancfg['adv_dhcp6_interface_statement_send_options'];
204
$pconfig['adv_dhcp6_interface_statement_request_options'] = $wancfg['adv_dhcp6_interface_statement_request_options'];
205
$pconfig['adv_dhcp6_interface_statement_information_only_enable'] = $wancfg['adv_dhcp6_interface_statement_information_only_enable'];
206
$pconfig['adv_dhcp6_interface_statement_script'] = $wancfg['adv_dhcp6_interface_statement_script'];
207

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

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

    
220
$pconfig['adv_dhcp6_prefix_interface_statement_sla_id'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_id'];
221
$pconfig['adv_dhcp6_prefix_interface_statement_sla_len'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_len'];
222

    
223
$pconfig['adv_dhcp6_authentication_statement_authname'] = $wancfg['adv_dhcp6_authentication_statement_authname'];
224
$pconfig['adv_dhcp6_authentication_statement_protocol'] = $wancfg['adv_dhcp6_authentication_statement_protocol'];
225
$pconfig['adv_dhcp6_authentication_statement_algorithm'] = $wancfg['adv_dhcp6_authentication_statement_algorithm'];
226
$pconfig['adv_dhcp6_authentication_statement_rdm'] = $wancfg['adv_dhcp6_authentication_statement_rdm'];
227

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

    
234
$pconfig['adv_dhcp6_config_advanced'] = $wancfg['adv_dhcp6_config_advanced'];
235
$pconfig['adv_dhcp6_config_file_override'] = $wancfg['adv_dhcp6_config_file_override'];
236
$pconfig['adv_dhcp6_config_file_override_path'] = $wancfg['adv_dhcp6_config_file_override_path'];
237

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

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

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

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

    
316
// print_r($pconfig);
317

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

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

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

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

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

    
431
		/* sync filter configuration */
432
		setup_gateways_monitor();
433

    
434
		clear_subsystem_dirty('interfaces');
435

    
436
		filter_configure();
437

    
438
		enable_rrd_graphing();
439

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

    
465
	unset($input_errors);
466
	$pconfig = $_POST;
467

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

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

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

    
482
	/* okay first of all, cause we are just hiding the PPPoE HTML
483
	 * fields releated to PPPoE resets, we are going to unset $_POST
484
	 * vars, if the reset feature should not be used. Otherwise the
485
	 * data validation procedure below, may trigger a false error
486
	 * message.
487
	 */
488
	if (empty($_POST['pppoe-reset-type'])) {
489
		unset($_POST['pppoe_pr_type']);
490
		unset($_POST['pppoe_resethour']);
491
		unset($_POST['pppoe_resetminute']);
492
		unset($_POST['pppoe_resetdate']);
493
		unset($_POST['pppoe_pr_preset_val']);
494
	}
495
	/* description unique? */
496
	foreach ($ifdescrs as $ifent => $ifdescr) {
497
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
498
			$input_errors[] = gettext("An interface with the specified description already exists.");
499
			break;
500
		}
501
	}
502
	/* input validation */
503
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^staticv4/", $_POST['type'])))
504
		$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.");
505
	if (isset($config['dhcpdv6']) && isset($config['dhcpdv6'][$if]['enable']) && (! preg_match("/^staticv6/", $_POST['type6'])))
506
		$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.");
507

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

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

    
616

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

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

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

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

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

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

    
732
				if ($parent_realhwif != $wancfg['if'])
733
					continue;
734

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

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

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

    
837
		unset($wancfg['adv_dhcp_pt_values']);
838

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

    
844
		unset($wancfg['adv_dhcp_config_advanced']);
845
		unset($wancfg['adv_dhcp_config_file_override']);
846
		unset($wancfg['adv_dhcp_config_file_override_path']);
847

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

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

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

    
865
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
866
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
867

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

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

    
879
		unset($wancfg['adv_dhcp6_config_advanced']);
880
		unset($wancfg['adv_dhcp6_config_file_override']);
881
		unset($wancfg['adv_dhcp6_config_file_override_path']);
882

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

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

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

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

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

    
928
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
929

    
930
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
931
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
932
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
933
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
934

    
935
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
936
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
937
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
938

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

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

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

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

    
1040
				$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1041
				$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1042
				$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1043
				$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1044

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

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

    
1057
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1058
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1059

    
1060
				$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1061
				$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1062
				$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1063
				$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1064

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

    
1071
				$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1072
				$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1073
				$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1074

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

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

    
1140
		conf_mount_ro();
1141
		write_config();
1142

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

    
1152
		mark_subsystem_dirty('interfaces');
1153

    
1154
		/* regenerate cron settings/crontab file */
1155
		configure_cron();
1156

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

    
1161
} // end if($_POST)
1162

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

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

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

    
1307
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1308
		return;
1309

    
1310
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1311
		$clone_count = 1;
1312
	else
1313
		$clone_count = 0;
1314
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1315
		foreach ($config['wireless']['clone'] as $clone) {
1316
			if ($clone['if'] == $wlanbaseif)
1317
				$clone_count++;
1318
		}
1319
	}
1320
	if ($clone_count > 1) {
1321
		$old_wireless_mode = $wancfg['wireless']['mode'];
1322
		$wancfg['wireless']['mode'] = $_POST['mode'];
1323
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1324
			$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']]);
1325
		} else {
1326
			mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy");
1327
		}
1328
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1329
	}
1330
}
1331

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

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

    
1350
$closehead = false;
1351
include("head.inc");
1352
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1353
$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"));
1354

    
1355
?>
1356

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

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

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

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

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

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

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

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

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

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

    
1971
									<tr style='display:none' id="show_adv_dhcp_protocol_timing">
1972
										<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>
1973
										<td width="48%" class="vtable">
1974
											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, '');" />
1975
											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, '');" />
1976
											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, '');" />
1977

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

    
1983
											<br />
1984
											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, '');" />
1985
											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, '');" />
1986
											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, '');" />
1987

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

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

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

    
2005
												function customdhcpptsetvalues(T, FORM) {
2006
													// timeout, retry, select-timeout, reboot, backoff-cutoff, initial-interval
2007
													if (T.value == "DHCP")		customdhcpptsetvaluesnow(T, FORM, "60", "300", "0", "10", "120", "10");
2008
													if (T.value == "pfSense")	customdhcpptsetvaluesnow(T, FORM, "60", "15", "0", "", "", "1");
2009
													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']);?>");
2010
													if (T.value == "Clear")		customdhcpptsetvaluesnow(T, FORM, "", "", "", "", "", "");
2011
												}
2012

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

    
2021
													FORM.adv_dhcp_pt_values.value = T.value;
2022
												}
2023

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

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

    
2057
									<tr style='display:none' id="show_adv_dhcp_option_modifiers">
2058
										<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>
2059
										<td width="78%" class="vtable">
2060
											<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']);?>" />
2061
											<br />
2062
											<?=gettext("The values in this field are DHCP option modifiers applied to obtained DHCP lease.  [modifier option declaration [, ...]] <br /> " .
2063
											"modifiers: (default, supersede, prepend, append)"); ?>
2064
										</td>
2065
									</tr>
2066

    
2067
									<tr style='display:none' id="show_adv_dhcp_config_file_override">
2068
										<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>
2069
										<td width="78%" class="vtable">
2070
 											<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']);?>" />
2071
											<br />
2072
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2073
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2074
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2075
											"Some ISPs may require certain options be or not be sent. "); ?>
2076
										</td>
2077
									</tr>
2078

    
2079
 									<tr>
2080
 										<td colspan="2" valign="top" height="16"></td>
2081
 									</tr>
2082

    
2083
								</table>
2084

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

    
2089
											if (T.checked) T.value = "Selected";
2090
											else T.value = "";
2091

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

    
2097
										function show_hide_adv_dhcp(basic, advanced, override) {
2098

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

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

    
2107
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2108
										}
2109

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

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

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

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

    
2221
									<tr style='display:none' id="show_adv_dhcp6_id_assoc_statement">
2222
										<td width="22%" valign="top" class="vncell">
2223
											<?=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>"); ?>
2224
										</td>
2225
										<td width="78%" class="vtable">
2226

    
2227
											<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);" />
2228
											<?=gettext("Non-Temporary Address Allocation"); ?>
2229
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_address">
2230
											<?=gettext("id-assoc na"); ?>
2231
											<?=gettext("<i>ID</i>"); ?>
2232
											<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']);?>" />
2233
											<br />
2234
											<?=gettext("Address"); ?>
2235
											<?=gettext("<i>ipv6-address</i>"); ?>
2236
											<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']);?>" />
2237
											<?=gettext("<i>pltime</i>"); ?>
2238
											<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']);?>" />
2239
											<?=gettext("<i>vltime</i>"); ?>
2240
											<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']);?>" />
2241
											</div>
2242
											<hr/>
2243

    
2244
											<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)" />
2245
											<?=gettext("Prefix Delegation"); ?>
2246
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_prefix">
2247
											<?=gettext("id-assoc pd"); ?>
2248
											<?=gettext("<i>ID</i>"); ?>
2249
											<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']);?>" />
2250
											<br />
2251
											<?=gettext("Prefix"); ?>
2252
											<?=gettext("<i>ipv6-prefix</i>"); ?>
2253
											<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']);?>" />
2254
											<?=gettext("<i>pltime</i>"); ?>
2255
											<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']);?>" />
2256
											<?=gettext("<i>vltime</i>"); ?>
2257
											<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']);?>" />
2258
											</div>
2259
										</td>
2260
									</tr>
2261

    
2262
									<tr style='display:none' id="show_adv_dhcp6_prefix_interface_statement">
2263
										<td width="22%" valign="top" class="vncell">
2264
											<?=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>"); ?>
2265
										</td>
2266
										<td width="78%" class="vtable">
2267
											<?=gettext("Prefix Interface "); ?>
2268
											<?=gettext("<i>sla-id</i>"); ?>
2269
											<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']);?>" />
2270
											<?=gettext("<i>sla-len</i>"); ?>
2271
											<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']);?>" />
2272
										</td>
2273
									</tr>
2274

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

    
2291
									<tr style='display:none' id="show_adv_dhcp6_key_info_statement">
2292
										<td width="22%" valign="top" class="vncell">
2293
											<?=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>"); ?>
2294
										</td>
2295
										<td width="78%" class="vtable">
2296
											<?=gettext("<i>keyname</i>"); ?>
2297
											<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']);?>" />
2298
											<?=gettext("<i>realm</i>"); ?>
2299
											<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']);?>" />
2300
											<br />
2301
											<?=gettext("<i>keyid</i>"); ?>
2302
											<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']);?>" />
2303
											<?=gettext("<i>secret</i>"); ?>
2304
											<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']);?>" />
2305
											<?=gettext("<i>expire</i>"); ?>
2306
											<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']);?>" />
2307
										</td>
2308
									</tr>
2309

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

    
2324
 									<tr>
2325
 										<td colspan="2" valign="top" height="16"></td>
2326
 									</tr>
2327

    
2328
								</table>
2329

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

    
2334
											if (T.checked) T.value = "Selected";
2335
											else T.value = "";
2336

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

    
2342
										function show_hide_adv_dhcp6(basic, advanced, override) {
2343

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

    
2349
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2350
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2351

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

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

    
2364
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2365
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2366

    
2367
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2368
										}
2369

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

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

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

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

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

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

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

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

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