Project

General

Profile

Download (169 KB) Statistics
| Branch: | Tag: | Revision:
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($config['ppps']['ppp']))
75
	$config['ppps']['ppp'] = array();
76

    
77
$a_ppps = &$config['ppps']['ppp'];
78

    
79
function remove_bad_chars($string) {
80
	return preg_replace('/[^a-z_0-9]/i','',$string);
81
}
82

    
83
if (!is_array($config['gateways']['gateway_item']))
84
	$config['gateways']['gateway_item'] = array();
85
$a_gateways = &$config['gateways']['gateway_item'];
86

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

    
97
foreach ($a_ppps as $pppid => $ppp) {
98
	if ($wancfg['if'] == $ppp['if'])
99
		break;
100
}
101

    
102
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
103
	$pconfig['pppid'] = $pppid;
104
	$pconfig['ptpid'] = $a_ppps[$pppid]['ptpid'];
105
	$pconfig['port'] = $a_ppps[$pppid]['ports'];
106
	if ($a_ppps[$pppid]['type'] == "ppp") {
107
		$pconfig['username'] = $a_ppps[$pppid]['username'];
108
		$pconfig['password'] = base64_decode($a_ppps[$pppid]['password']);
109

    
110
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
111
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
112
	}
113
	else if ($a_ppps[$pppid]['type'] == "pppoe") {
114
		$pconfig['pppoe_username'] = $a_ppps[$pppid]['username'];
115
		$pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']);
116
		$pconfig['provider'] = $a_ppps[$pppid]['provider'];
117
		$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
118
		$pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout'];
119

    
120
		/* ================================================ */
121
		/* = force a connection reset at a specific time? = */
122
		/* ================================================ */
123

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

    
180
$pconfig['adv_dhcp_pt_timeout'] = $wancfg['adv_dhcp_pt_timeout'];
181
$pconfig['adv_dhcp_pt_retry'] = $wancfg['adv_dhcp_pt_retry'];
182
$pconfig['adv_dhcp_pt_select_timeout'] = $wancfg['adv_dhcp_pt_select_timeout'];
183
$pconfig['adv_dhcp_pt_reboot'] = $wancfg['adv_dhcp_pt_reboot'];
184
$pconfig['adv_dhcp_pt_backoff_cutoff'] = $wancfg['adv_dhcp_pt_backoff_cutoff'];
185
$pconfig['adv_dhcp_pt_initial_interval'] = $wancfg['adv_dhcp_pt_initial_interval'];
186

    
187
$pconfig['adv_dhcp_pt_values'] = $wancfg['adv_dhcp_pt_values'];
188

    
189
$pconfig['adv_dhcp_send_options'] = $wancfg['adv_dhcp_send_options'];
190
$pconfig['adv_dhcp_request_options'] = $wancfg['adv_dhcp_request_options'];
191
$pconfig['adv_dhcp_required_options'] = $wancfg['adv_dhcp_required_options'];
192
$pconfig['adv_dhcp_option_modifiers'] = $wancfg['adv_dhcp_option_modifiers'];
193

    
194
$pconfig['adv_dhcp_config_advanced'] = $wancfg['adv_dhcp_config_advanced'];
195
$pconfig['adv_dhcp_config_file_override'] = $wancfg['adv_dhcp_config_file_override'];
196
$pconfig['adv_dhcp_config_file_override_path'] = $wancfg['adv_dhcp_config_file_override_path'];
197

    
198
$pconfig['adv_dhcp6_interface_statement_send_options'] = $wancfg['adv_dhcp6_interface_statement_send_options'];
199
$pconfig['adv_dhcp6_interface_statement_request_options'] = $wancfg['adv_dhcp6_interface_statement_request_options'];
200
$pconfig['adv_dhcp6_interface_statement_information_only_enable'] = $wancfg['adv_dhcp6_interface_statement_information_only_enable'];
201
$pconfig['adv_dhcp6_interface_statement_script'] = $wancfg['adv_dhcp6_interface_statement_script'];
202

    
203
$pconfig['adv_dhcp6_id_assoc_statement_address_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_address_enable'];
204
$pconfig['adv_dhcp6_id_assoc_statement_address'] = $wancfg['adv_dhcp6_id_assoc_statement_address'];
205
$pconfig['adv_dhcp6_id_assoc_statement_address_id'] = $wancfg['adv_dhcp6_id_assoc_statement_address_id'];
206
$pconfig['adv_dhcp6_id_assoc_statement_address_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_pltime'];
207
$pconfig['adv_dhcp6_id_assoc_statement_address_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_vltime'];
208

    
209
$pconfig['adv_dhcp6_id_assoc_statement_prefix_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'];
210
$pconfig['adv_dhcp6_id_assoc_statement_prefix'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix'];
211
$pconfig['adv_dhcp6_id_assoc_statement_prefix_id'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_id'];
212
$pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'];
213
$pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'];
214

    
215
$pconfig['adv_dhcp6_prefix_interface_statement_sla_id'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_id'];
216
$pconfig['adv_dhcp6_prefix_interface_statement_sla_len'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_len'];
217

    
218
$pconfig['adv_dhcp6_authentication_statement_authname'] = $wancfg['adv_dhcp6_authentication_statement_authname'];
219
$pconfig['adv_dhcp6_authentication_statement_protocol'] = $wancfg['adv_dhcp6_authentication_statement_protocol'];
220
$pconfig['adv_dhcp6_authentication_statement_algorithm'] = $wancfg['adv_dhcp6_authentication_statement_algorithm'];
221
$pconfig['adv_dhcp6_authentication_statement_rdm'] = $wancfg['adv_dhcp6_authentication_statement_rdm'];
222

    
223
$pconfig['adv_dhcp6_key_info_statement_keyname'] = $wancfg['adv_dhcp6_key_info_statement_keyname'];
224
$pconfig['adv_dhcp6_key_info_statement_realm'] = $wancfg['adv_dhcp6_key_info_statement_realm'];
225
$pconfig['adv_dhcp6_key_info_statement_keyid'] = $wancfg['adv_dhcp6_key_info_statement_keyid'];
226
$pconfig['adv_dhcp6_key_info_statement_secret'] = $wancfg['adv_dhcp6_key_info_statement_secret'];
227
$pconfig['adv_dhcp6_key_info_statement_expire'] = $wancfg['adv_dhcp6_key_info_statement_expire'];
228

    
229
$pconfig['adv_dhcp6_config_advanced'] = $wancfg['adv_dhcp6_config_advanced'];
230
$pconfig['adv_dhcp6_config_file_override'] = $wancfg['adv_dhcp6_config_file_override'];
231
$pconfig['adv_dhcp6_config_file_override_path'] = $wancfg['adv_dhcp6_config_file_override_path'];
232

    
233
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
234
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
235
$pconfig['enable'] = isset($wancfg['enable']);
236

    
237
if (is_array($config['aliases']['alias'])) {
238
	foreach($config['aliases']['alias'] as $alias) {
239
		if($alias['name'] == $wancfg['descr']) {
240
			$input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."),$wancfg['descr']);
241
		}
242
	}
243
}
244

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

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

    
309
// print_r($pconfig);
310

    
311
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
312
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
313
$pconfig['spoofmac'] = $wancfg['spoofmac'];
314
$pconfig['mtu'] = $wancfg['mtu'];
315
$pconfig['mss'] = $wancfg['mss'];
316

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

    
400
$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']);
401
$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
402

    
403
if ($_POST['apply']) {
404
	unset($input_errors);
405
	if (!is_subsystem_dirty('interfaces'))
406
		$intput_errors[] = gettext("You have already applied your settings!");
407
	else {
408
		unlink_if_exists("{$g['tmp_path']}/config.cache");
409
		clear_subsystem_dirty('interfaces');
410

    
411
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
412
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
413
			foreach ($toapplylist as $ifapply => $ifcfgo) {
414
				if (isset($config['interfaces'][$ifapply]['enable'])) {
415
					interface_bring_down($ifapply, false, $ifcfgo);
416
					interface_configure($ifapply, true);
417
				} else
418
					interface_bring_down($ifapply, true, $ifcfgo);
419
			}
420
		}
421
		/* restart snmp so that it binds to correct address */
422
		services_snmpd_configure();
423

    
424
		/* sync filter configuration */
425
		setup_gateways_monitor();
426

    
427
		clear_subsystem_dirty('interfaces');
428

    
429
		filter_configure();
430

    
431
		enable_rrd_graphing();
432

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

    
458
	unset($input_errors);
459
	$pconfig = $_POST;
460
	if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
461
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
462
	else
463
		$pconfig['track6-prefix-id'] = 0;
464
	conf_mount_rw();
465

    
466
	/* filter out spaces from descriptions  */
467
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
468

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

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

    
592
			if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
593
				$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
594
			} else {
595
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
596
				if ($track6_prefix_id < 0 || $track6_prefix_id >= $ipv6_num_prefix_ids) {
597
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.");
598
				}
599
			}
600
			break;
601
	}
602

    
603

    
604
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
605
	$staticroutes = get_staticroutes(true);
606
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
607
	if ($_POST['ipaddr']) {
608
		if (!is_ipaddrv4($_POST['ipaddr']))
609
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
610
		else {
611
			if (is_ipaddr_configured($_POST['ipaddr'], $if, true))
612
				$input_errors[] = gettext("This IPv4 address is being used by another interface or VIP.");
613

    
614
			foreach ($staticroutes as $route_subnet) {
615
				list($network, $subnet) = explode("/", $route_subnet);
616
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
617
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
618
					break;
619
				}
620
				unset($network, $subnet);
621
			}
622
		}
623
	}
624
	if ($_POST['ipaddrv6']) {
625
		if (!is_ipaddrv6($_POST['ipaddrv6']))
626
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
627
		else {
628
			if (is_ipaddr_configured($_POST['ipaddrv6'], $if, true))
629
				$input_errors[] = gettext("This IPv6 address is being used by another interface or VIP.");
630

    
631
			foreach ($staticroutes as $route_subnet) {
632
				list($network, $subnet) = explode("/", $route_subnet);
633
				if ($_POST['subnetv6'] == $subnet && $network == gen_subnetv6($_POST['ipaddrv6'], $_POST['subnetv6'])) {
634
					$input_errors[] = gettext("This IPv6 address conflicts with a Static Route.");
635
					break;
636
				}
637
				unset($network, $subnet);
638
			}
639
		}
640
	}
641
	if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
642
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
643
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6'])))
644
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
645
	if (($_POST['alias-address'] && !is_ipaddrv4($_POST['alias-address'])))
646
		$input_errors[] = gettext("A valid alias IP address must be specified.");
647
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
648
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
649
	if ($_POST['dhcprejectfrom'] && !is_ipaddrv4($_POST['dhcprejectfrom']))
650
		$input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from.");
651
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
652
		$match = false;
653
		foreach($a_gateways as $gateway) {
654
			if(in_array($_POST['gateway'], $gateway)) {
655
				$match = true;
656
			}
657
		}
658
		foreach($a_gateways as $gateway) {
659
			if(in_array($_POST['gatewayv6'], $gateway)) {
660
				$match = true;
661
			}
662
		}
663
		if(!$match) {
664
			$input_errors[] = gettext("A valid gateway must be specified.");
665
		}
666
	}
667
	if (($_POST['provider'] && !is_domain($_POST['provider'])))
668
		$input_errors[] = gettext("The service name contains invalid characters.");
669
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
670
		$input_errors[] = gettext("The idle timeout value must be an integer.");
671
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
672
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23)
673
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
674
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
675
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59)
676
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
677
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate'])))
678
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
679
	if (($_POST['pptp_local'] && !is_ipaddrv4($_POST['pptp_local'])))
680
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
681
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet'])))
682
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
683
	if (($_POST['pptp_remote'] && !is_ipaddrv4($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface])))
684
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
685
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout']))
686
		$input_errors[] = gettext("The idle timeout value must be an integer.");
687
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])))
688
		$input_errors[] = gettext("A valid MAC address must be specified.");
689
	if ($_POST['mtu']) {
690
		if ($_POST['mtu'] < 576 || $_POST['mtu'] > 9000)
691
			$input_errors[] = gettext("The MTU must be greater than 576 bytes.");
692

    
693
		if (stristr($wancfg['if'], "_vlan")) {
694
			$realhwif_array = get_parent_interface($wancfg['if']);
695
			// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
696
			$parent_realhwif = $realhwif_array[0];
697
			$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
698
			if (!empty($parent_if) && isset($config['interfaces'][$parent_if]['mtu'])) {
699
				$parent_mtu = $config['interfaces'][$parent_if]['mtu'];
700

    
701
				if ($_POST['mtu'] > $parent_mtu)
702
					$input_errors[] = gettext("MTU of a vlan should not be bigger than parent interface.");
703
			}
704
		} else {
705
			foreach ($config['interfaces'] as $idx => $ifdata) {
706
				if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if']))
707
					continue;
708

    
709
				$realhwif_array = get_parent_interface($ifdata['if']);
710
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
711
				$parent_realhwif = $realhwif_array[0];
712

    
713
				if ($parent_realhwif != $wancfg['if'])
714
					continue;
715

    
716
				if (isset($ifdata['mtu']) && $ifdata['mtu'] > $_POST['mtu'])
717
					$input_errors[] = sprintf(gettext("Interface %s (VLAN) has MTU set to a bigger value"), $ifdata['descr']);
718
			}
719
		}
720
	}
721
	if ($_POST['mss'] && ($_POST['mss'] < 576))
722
		$input_errors[] = gettext("The MSS must be greater than 576 bytes.");
723
	/* Wireless interface? */
724
	if (isset($wancfg['wireless'])) {
725
		$reqdfields = array("mode");
726
		$reqdfieldsn = array(gettext("Mode"));
727
		if ($_POST['mode'] == 'hostap') {
728
			$reqdfields[] = "ssid";
729
			$reqdfieldsn[] = gettext("SSID");
730
		}
731
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
732
		check_wireless_mode();
733
		/* loop through keys and enforce size */
734
		for ($i = 1; $i <= 4; $i++) {
735
			if ($_POST['key' . $i]) {
736
				/* 64 bit */
737
				if (strlen($_POST['key' . $i]) == 5)
738
					continue;
739
				if (strlen($_POST['key' . $i]) == 10) {
740
					/* hex key */
741
					if (stristr($_POST['key' . $i], "0x") == false) {
742
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
743
					}
744
					continue;
745
				}
746
				if (strlen($_POST['key' . $i]) == 12) {
747
					/* hex key */
748
					if(stristr($_POST['key' . $i], "0x") == false) {
749
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
750
					}
751
					continue;
752
				}
753
				/* 128 bit */
754
				if (strlen($_POST['key' . $i]) == 13)
755
					continue;
756
				if (strlen($_POST['key' . $i]) == 26) {
757
					/* hex key */
758
					if (stristr($_POST['key' . $i], "0x") == false)
759
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
760
					continue;
761
				}
762
				if(strlen($_POST['key' . $i]) == 28)
763
					continue;
764
				$input_errors[] =  gettext("Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.");
765
				break;
766
			}
767
		}
768

    
769
		if ($_POST['passphrase']) {
770
			$passlen = strlen($_POST['passphrase']);
771
			if ($passlen < 8 || $passlen > 63)
772
				$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
773
		}
774
	}
775
	if (!$input_errors) {
776
		if ($wancfg['ipaddr'] != $_POST['type']) {
777
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
778
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
779
				unset($a_ppps[$pppid]);
780
			} else if ($wancfg['ipaddrv6'] == "dhcp6") {
781
				$pid = find_dhcp6c_process($wancfg['if']);
782
				if($pid)
783
					posix_kill($pid, SIGTERM);
784
			} else if ($wancfg['ipaddr'] == "dhcp") {
785
				$pid = find_dhclient_process($wancfg['if']);
786
				if($pid)
787
					posix_kill($pid, SIGTERM);
788
			}
789

    
790
		}
791
		$ppp = array();
792
		if ($wancfg['ipaddr'] != "ppp")
793
			unset($wancfg['ipaddr']);
794
		if ($wancfg['ipaddrv6'] != "ppp")
795
			unset($wancfg['ipaddrv6']);
796
		unset($wancfg['subnet']);
797
		unset($wancfg['gateway']);
798
		unset($wancfg['subnetv6']);
799
		unset($wancfg['gatewayv6']);
800
		unset($wancfg['dhcphostname']);
801
		unset($wancfg['dhcprejectfrom']);
802
		unset($wancfg['dhcp6-duid']);
803
		unset($wancfg['dhcp6-ia-pd-len']);
804
		unset($wancfg['dhcp6prefixonly']);
805
		unset($wancfg['track6-interface']);
806
		unset($wancfg['track6-prefix-id']);
807
		unset($wancfg['prefix-6rd']);
808
		unset($wancfg['prefix-6rd-v4plen']);
809
		unset($wancfg['gateway-6rd']);
810

    
811
		unset($wancfg['adv_dhcp_pt_timeout']);
812
		unset($wancfg['adv_dhcp_pt_retry']);
813
		unset($wancfg['adv_dhcp_pt_select_timeout']);
814
		unset($wancfg['adv_dhcp_pt_reboot']);
815
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
816
		unset($wancfg['adv_dhcp_pt_initial_interval']);
817

    
818
		unset($wancfg['adv_dhcp_pt_values']);
819

    
820
		unset($wancfg['adv_dhcp_send_options']);
821
		unset($wancfg['adv_dhcp_request_options']);
822
		unset($wancfg['adv_dhcp_required_options']);
823
		unset($wancfg['adv_dhcp_option_modifiers']);
824

    
825
		unset($wancfg['adv_dhcp_config_advanced']);
826
		unset($wancfg['adv_dhcp_config_file_override']);
827
		unset($wancfg['adv_dhcp_config_file_override_path']);
828

    
829
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
830
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
831
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
832
		unset($wancfg['adv_dhcp6_interface_statement_script']);
833

    
834
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
835
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
836
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
837
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
838
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
839

    
840
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
841
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
842
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
843
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
844
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
845

    
846
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
847
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
848

    
849
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
850
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
851
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
852
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
853

    
854
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
855
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
856
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
857
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
858
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
859

    
860
		unset($wancfg['adv_dhcp6_config_advanced']);
861
		unset($wancfg['adv_dhcp6_config_file_override']);
862
		unset($wancfg['adv_dhcp6_config_file_override_path']);
863

    
864
		unset($wancfg['pppoe_password']);
865
		unset($wancfg['pptp_username']);
866
		unset($wancfg['pptp_password']);
867
		unset($wancfg['provider']);
868
		unset($wancfg['ondemand']);
869
		unset($wancfg['timeout']);
870
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
871
			unset($wancfg['pppoe']['pppoe-reset-type']);
872
		unset($wancfg['local']);
873

    
874
		unset($wancfg['remote']);
875
		unset($a_ppps[$pppid]['apn']);
876
		unset($a_ppps[$pppid]['phone']);
877
		unset($a_ppps[$pppid]['localip']);
878
		unset($a_ppps[$pppid]['subnet']);
879
		unset($a_ppps[$pppid]['gateway']);
880
		unset($a_ppps[$pppid]['pppoe-reset-type']);
881
		unset($a_ppps[$pppid]['provider']);
882

    
883
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
884
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
885

    
886
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
887
		switch($_POST['type']) {
888
			case "staticv4":
889
				$wancfg['ipaddr'] = $_POST['ipaddr'];
890
				$wancfg['subnet'] = $_POST['subnet'];
891
				if ($_POST['gateway'] != "none") {
892
					$wancfg['gateway'] = $_POST['gateway'];
893
				}
894
				break;
895
			case "dhcp":
896
				$wancfg['ipaddr'] = "dhcp";
897
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
898
				$wancfg['alias-address'] = $_POST['alias-address'];
899
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
900
				$wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom'];
901

    
902
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
903
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
904
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
905
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
906
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
907
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
908

    
909
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
910

    
911
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
912
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
913
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
914
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
915

    
916
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
917
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
918
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
919

    
920
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
921
				if($gateway_item) {
922
					$a_gateways[] = $gateway_item;
923
				}
924
				break;
925
			case "ppp":
926
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
927
				$a_ppps[$pppid]['type'] = $_POST['type'];
928
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
929
				$a_ppps[$pppid]['ports'] = $_POST['port'];
930
				$a_ppps[$pppid]['username'] = $_POST['username'];
931
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
932
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
933
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
934
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
935
				$wancfg['ipaddr'] = $_POST['type'];
936
				unset($a_ppps[$pppid]['ondemand']);
937
				unset($a_ppps[$pppid]['idletimeout']);
938
				break;
939

    
940
			case "pppoe":
941
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
942
				$a_ppps[$pppid]['type'] = $_POST['type'];
943
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
944
				if (isset($_POST['ppp_port']))
945
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
946
				else
947
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
948
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
949
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
950
				if (!empty($_POST['provider']))
951
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
952
				else
953
					$a_ppps[$pppid]['provider'] = true;
954
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
955
				if (!empty($_POST['pppoe_idletimeout']))
956
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
957
				else
958
					unset($a_ppps[$pppid]['idletimeout']);
959

    
960
				if (!empty($_POST['pppoe-reset-type']))
961
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
962
				else
963
					unset($a_ppps[$pppid]['pppoe-reset-type']);
964
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
965
				$wancfg['ipaddr'] = $_POST['type'];
966
				if($gateway_item) {
967
					$a_gateways[] = $gateway_item;
968
				}
969

    
970
				break;
971
			case "pptp":
972
			case "l2tp":
973
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
974
				$a_ppps[$pppid]['type'] = $_POST['type'];
975
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
976
				if (isset($_POST['ppp_port']))
977
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
978
				else
979
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
980
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
981
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
982
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
983
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
984
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
985
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
986
				if (!empty($_POST['pptp_idletimeout']))
987
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
988
				else
989
					unset($a_ppps[$pppid]['idletimeout']);
990
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
991
				$wancfg['ipaddr'] = $_POST['type'];
992
				if($gateway_item) {
993
					$a_gateways[] = $gateway_item;
994
				}
995
				break;
996
			case "none":
997
				break;
998
		}
999
		switch($_POST['type6']) {
1000
			case "staticv6":
1001
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
1002
				$wancfg['subnetv6'] = $_POST['subnetv6'];
1003
				if ($_POST['gatewayv6'] != "none") {
1004
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
1005
				}
1006
				break;
1007
			case "slaac":
1008
				$wancfg['ipaddrv6'] = "slaac";
1009
				break;
1010
			case "dhcp6":
1011
				$wancfg['ipaddrv6'] = "dhcp6";
1012
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
1013
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
1014
				if($_POST['dhcp6prefixonly'] == "yes")
1015
					$wancfg['dhcp6prefixonly'] = true;
1016

    
1017
				$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1018
				$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1019
				$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1020
				$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1021

    
1022
				$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1023
				$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1024
				$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1025
				$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1026
				$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1027

    
1028
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1029
				$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1030
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1031
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1032
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1033

    
1034
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1035
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1036

    
1037
				$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1038
				$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1039
				$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1040
				$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1041

    
1042
				$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1043
				$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1044
				$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1045
				$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1046
				$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1047

    
1048
				$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1049
				$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1050
				$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1051

    
1052
				if($gateway_item) {
1053
					$a_gateways[] = $gateway_item;
1054
				}
1055
				break;
1056
			case "6rd":
1057
				$wancfg['ipaddrv6'] = "6rd";
1058
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
1059
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
1060
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
1061
				if($gateway_item) {
1062
					$a_gateways[] = $gateway_item;
1063
				}
1064
				break;
1065
			case "6to4":
1066
				$wancfg['ipaddrv6'] = "6to4";
1067
				break;
1068
			case "track6":
1069
				$wancfg['ipaddrv6'] = "track6";
1070
				$wancfg['track6-interface'] = $_POST['track6-interface'];
1071
				if ($_POST['track6-prefix-id--hex'] === "")
1072
					$wancfg['track6-prefix-id'] = 0;
1073
				else if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
1074
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
1075
				else
1076
					$wancfg['track6-prefix-id'] = 0;
1077
				break;
1078
			case "none":
1079
				break;
1080
		}
1081
		handle_pppoe_reset($_POST);
1082

    
1083
		if($_POST['blockpriv'] == "yes") {
1084
			$wancfg['blockpriv'] = true;
1085
		} else {
1086
			unset($wancfg['blockpriv']);
1087
		}
1088
		if($_POST['blockbogons'] == "yes") {
1089
			$wancfg['blockbogons'] = true;
1090
		} else {
1091
			unset($wancfg['blockbogons']);
1092
		}
1093
		$wancfg['spoofmac'] = $_POST['spoofmac'];
1094
		if (empty($_POST['mtu'])) {
1095
			unset($wancfg['mtu']);
1096
		} else {
1097
			$wancfg['mtu'] = $_POST['mtu'];
1098
		}
1099
		if (empty($_POST['mss'])) {
1100
			unset($wancfg['mss']);
1101
		} else {
1102
			$wancfg['mss'] = $_POST['mss'];
1103
		}
1104
		if (empty($_POST['mediaopt'])) {
1105
			unset($wancfg['media']);
1106
			unset($wancfg['mediaopt']);
1107
		} else {
1108
			$mediaopts = explode(' ', $_POST['mediaopt']);
1109
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
1110
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
1111
			else { unset($wancfg['mediaopt']); }
1112
		}
1113
		if (isset($wancfg['wireless'])) {
1114
			handle_wireless_post();
1115
		}
1116

    
1117
		conf_mount_ro();
1118
		write_config();
1119

    
1120
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
1121
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
1122
		} else {
1123
			$toapplylist = array();
1124
		}
1125
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
1126
		$toapplylist[$if]['ppps'] = $old_ppps;
1127
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
1128

    
1129
		mark_subsystem_dirty('interfaces');
1130

    
1131
		/* regenerate cron settings/crontab file */
1132
		configure_cron();
1133

    
1134
		header("Location: interfaces.php?if={$if}");
1135
		exit;
1136
	}
1137

    
1138
} // end if($_POST)
1139

    
1140
function handle_wireless_post() {
1141
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
1142
	if (!is_array($wancfg['wireless']))
1143
		$wancfg['wireless'] = array();
1144
	$wancfg['wireless']['standard'] = $_POST['standard'];
1145
	$wancfg['wireless']['mode'] = $_POST['mode'];
1146
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
1147
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
1148
	$wancfg['wireless']['channel'] = $_POST['channel'];
1149
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
1150
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
1151
	$wancfg['wireless']['distance'] = $_POST['distance'];
1152
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
1153
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
1154
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
1155
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
1156
		foreach($wl_countries_attr as $wl_country) {
1157
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
1158
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
1159
				break;
1160
			}
1161
		}
1162
	}
1163
	if (!is_array($wancfg['wireless']['wpa']))
1164
		$wancfg['wireless']['wpa'] = array();
1165
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
1166
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
1167
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
1168
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
1169
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
1170
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
1171
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
1172
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
1173
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
1174
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
1175
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
1176
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
1177
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
1178
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
1179
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
1180

    
1181
	if ($_POST['persistcommonwireless'] == "yes") {
1182
		if (!is_array($config['wireless']))
1183
			$config['wireless'] = array();
1184
		if (!is_array($config['wireless']['interfaces']))
1185
			$config['wireless']['interfaces'] = array();
1186
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
1187
			$config['wireless']['interfaces'][$wlanbaseif] = array();
1188
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
1189
		unset($config['wireless']['interfaces'][$wlanbaseif]);
1190
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
1191
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
1192
	else if (isset($wancfg['wireless']['diversity']))
1193
		unset($wancfg['wireless']['diversity']);
1194
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
1195
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
1196
	else if (isset($wancfg['wireless']['txantenna']))
1197
		unset($wancfg['wireless']['txantenna']);
1198
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
1199
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
1200
	else if (isset($wancfg['wireless']['rxantenna']))
1201
		unset($wancfg['wireless']['rxantenna']);
1202
	if ($_POST['hidessid_enable'] == "yes")
1203
		$wancfg['wireless']['hidessid']['enable'] = true;
1204
	else if (isset($wancfg['wireless']['hidessid']['enable']))
1205
		unset($wancfg['wireless']['hidessid']['enable']);
1206
	if ($_POST['mac_acl_enable'] == "yes")
1207
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
1208
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
1209
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
1210
	if ($_POST['rsn_preauth'] == "yes")
1211
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
1212
	else
1213
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
1214
	if ($_POST['ieee8021x'] == "yes")
1215
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
1216
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
1217
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
1218
	if ($_POST['wpa_strict_rekey'] == "yes")
1219
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
1220
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
1221
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
1222
	if ($_POST['debug_mode'] == "yes")
1223
		$wancfg['wireless']['wpa']['debug_mode'] = true;
1224
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
1225
		sunset($wancfg['wireless']['wpa']['debug_mode']);
1226
	if ($_POST['wpa_enable'] == "yes")
1227
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
1228
	else if (isset($wancfg['wireless']['wpa']['enable']))
1229
		unset($wancfg['wireless']['wpa']['enable']);
1230
	if ($_POST['wep_enable'] == "yes") {
1231
		if (!is_array($wancfg['wireless']['wep']))
1232
			$wancfg['wireless']['wep'] = array();
1233
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
1234
	} else if (isset($wancfg['wireless']['wep']))
1235
		unset($wancfg['wireless']['wep']);
1236
	if ($_POST['wme_enable'] == "yes") {
1237
		if (!is_array($wancfg['wireless']['wme']))
1238
			$wancfg['wireless']['wme'] = array();
1239
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1240
	} else if (isset($wancfg['wireless']['wme']['enable']))
1241
		unset($wancfg['wireless']['wme']['enable']);
1242
	if ($_POST['puremode'] == "11g") {
1243
		if (!is_array($wancfg['wireless']['pureg']))
1244
			$wancfg['wireless']['pureg'] = array();
1245
		$wancfg['wireless']['pureg']['enable'] = true;
1246
	} else if ($_POST['puremode'] == "11n") {
1247
		if (!is_array($wancfg['wireless']['puren']))
1248
			$wancfg['wireless']['puren'] = array();
1249
		$wancfg['wireless']['puren']['enable'] = true;
1250
	} else {
1251
		if (isset($wancfg['wireless']['pureg']))
1252
			unset($wancfg['wireless']['pureg']);
1253
		if (isset($wancfg['wireless']['puren']))
1254
			unset($wancfg['wireless']['puren']);
1255
	}
1256
	if ($_POST['apbridge_enable'] == "yes") {
1257
		if (!is_array($wancfg['wireless']['apbridge']))
1258
			$wancfg['wireless']['apbridge'] = array();
1259
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1260
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
1261
		unset($wancfg['wireless']['apbridge']['enable']);
1262
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1263
		if (!is_array($wancfg['wireless']['turbo']))
1264
			$wancfg['wireless']['turbo'] = array();
1265
		$wancfg['wireless']['turbo']['enable'] = true;
1266
	} else if (isset($wancfg['wireless']['turbo']['enable']))
1267
		unset($wancfg['wireless']['turbo']['enable']);
1268
	$wancfg['wireless']['wep']['key'] = array();
1269
	for ($i = 1; $i <= 4; $i++) {
1270
		if ($_POST['key' . $i]) {
1271
			$newkey = array();
1272
			$newkey['value'] = $_POST['key' . $i];
1273
			if ($_POST['txkey'] == $i)
1274
				$newkey['txkey'] = true;
1275
			$wancfg['wireless']['wep']['key'][] = $newkey;
1276
		}
1277
	}
1278
	interface_sync_wireless_clones($wancfg, true);
1279
}
1280

    
1281
function check_wireless_mode() {
1282
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1283

    
1284
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1285
		return;
1286

    
1287
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1288
		$clone_count = 1;
1289
	else
1290
		$clone_count = 0;
1291
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1292
		foreach ($config['wireless']['clone'] as $clone) {
1293
			if ($clone['if'] == $wlanbaseif)
1294
				$clone_count++;
1295
		}
1296
	}
1297
	if ($clone_count > 1) {
1298
		$old_wireless_mode = $wancfg['wireless']['mode'];
1299
		$wancfg['wireless']['mode'] = $_POST['mode'];
1300
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1301
			$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']]);
1302
		} else {
1303
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
1304
		}
1305
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1306
	}
1307
}
1308

    
1309
// Find all possible media options for the interface
1310
$mediaopts_list = array();
1311
$intrealname = $config['interfaces'][$if]['if'];
1312
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1313
foreach ($mediaopts as $mediaopt){
1314
	preg_match("/media (.*)/", $mediaopt, $matches);
1315
	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1316
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1317
		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1318
	}else{
1319
		// there is only media like "media 1000baseT"
1320
		array_push($mediaopts_list, $matches[1]);
1321
	}
1322
}
1323

    
1324
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1325
$shortcut_section = "interfaces";
1326

    
1327
$closehead = false;
1328
include("head.inc");
1329
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1330
$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"));
1331

    
1332
?>
1333

    
1334
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1335
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1336
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1337
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1338

    
1339
<script type="text/javascript">
1340
	function updateType(t) {
1341
		switch(t) {
1342
			case "none": {
1343
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1344
				break;
1345
			}
1346
			case "staticv4": {
1347
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1348
				break;
1349
			}
1350
			case "dhcp": {
1351
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1352
				break;
1353
			}
1354
			case "ppp": {
1355
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1356
				country_list();
1357
				break;
1358
			}
1359
			case "pppoe": {
1360
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1361
				break;
1362
			}
1363
			case "l2tp":
1364
			case "pptp": {
1365
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1366
				jQuery('#pptp').show();
1367
				break;
1368
			}
1369
		}
1370
		if (t != "l2tp" && t != "pptp")
1371
			jQuery('#'+t).show();
1372
	}
1373
	function updateTypeSix(t) {
1374
		switch(t) {
1375
			case "none": {
1376
				jQuery('#staticv6, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1377
				break;
1378
			}
1379
			case "staticv6": {
1380
				jQuery('#none, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1381
				break;
1382
			}
1383
			case "slaac": {
1384
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #dhcp6').hide();
1385
				break;
1386
			}
1387
			case "dhcp6": {
1388
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #slaac').hide();
1389
				break;
1390
			}
1391
			case "6rd": {
1392
				jQuery('#none, #dhcp6, #staticv6, #6to4, #track6, #slaac').hide();
1393
				break;
1394
			}
1395
			case "6to4": {
1396
				jQuery('#none, #dhcp6, #staticv6, #6rd, #track6, #slaac').hide();
1397
				break;
1398
			}
1399
			case "track6": {
1400
				jQuery('#none, #dhcp6, #staticv6, #6rd, #6to4, #slaac').hide();
1401
				break;
1402
			}
1403
		}
1404
		if (t != "l2tp" && t != "pptp")
1405
			jQuery('#'+t).show();
1406
	}
1407

    
1408
	function show_allcfg(obj) {
1409
		if (obj.checked)
1410
			jQuery('#allcfg').show();
1411
		else
1412
			jQuery('#allcfg').hide();
1413
	}
1414

    
1415
	function show_reset_settings(reset_type) {
1416
		if (reset_type == 'preset') {
1417
			jQuery('#pppoepresetwrap').show();
1418
			jQuery('#pppoecustomwrap').hide();
1419
		}
1420
		else if (reset_type == 'custom') {
1421
			jQuery('#pppoecustomwrap').show();
1422
			jQuery('#pppoepresetwrap').hide();
1423
		} else {
1424
			jQuery('#pppoecustomwrap').hide();
1425
			jQuery('#pppoepresetwrap').hide();
1426
		}
1427
	}
1428
	function show_mon_config() {
1429
		jQuery("#showmonbox").html('');
1430
		jQuery('#showmon').css('display','block');
1431
	}
1432

    
1433
	function openwindow(url) {
1434
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1435
		if (oWin==null || typeof(oWin)=="undefined")
1436
			return false;
1437
		else
1438
			return true;
1439
	}
1440
	function country_list() {
1441
		jQuery('#country').children().remove();
1442
		jQuery('#provider').children().remove();
1443
		jQuery('#providerplan').children().remove();
1444
		jQuery.ajax("getserviceproviders.php",{
1445
			success: function(response) {
1446
				var responseTextArr = response.split("\n");
1447
				responseTextArr.sort();
1448
				responseTextArr.each( function(value) {
1449
					var option = new Element('option');
1450
					country = value.split(":");
1451
					option.text = country[0];
1452
					option.value = country[1];
1453
					jQuery('#country').append(option);
1454
				});
1455
			}
1456
		});
1457
		jQuery('#trcountry').css('display',"table-row");
1458
	}
1459

    
1460
	function providers_list() {
1461
		jQuery('#provider').children().remove();
1462
		jQuery('#providerplan').children().remove();
1463
		jQuery.ajax("getserviceproviders.php",{
1464
			type: 'post',
1465
			data: {country : jQuery('#country').val()},
1466
			success: function(response) {
1467
				var responseTextArr = response.split("\n");
1468
				responseTextArr.sort();
1469
				responseTextArr.each( function(value) {
1470
					var option = new Element('option');
1471
					option.text = value;
1472
					option.value = value;
1473
					jQuery('#provider').append(option);
1474
				});
1475
			}
1476
		});
1477
		jQuery('#trprovider').css("display","table-row");
1478
		jQuery('#trproviderplan').css("display","none");
1479
	}
1480

    
1481
	function providerplan_list() {
1482
		jQuery('#providerplan').children().remove();
1483
		jQuery('#providerplan').append( new Element('option') );
1484
		jQuery.ajax("getserviceproviders.php",{
1485
			type: 'post',
1486
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1487
			success: function(response) {
1488
				var responseTextArr = response.split("\n");
1489
				responseTextArr.sort();
1490
				responseTextArr.each( function(value) {
1491
					if(value != "") {
1492
						providerplan = value.split(":");
1493

    
1494
						var option = new Element('option');
1495
						option.text = providerplan[0] + " - " + providerplan[1];
1496
						option.value = providerplan[1];
1497
						jQuery('#providerplan').append(option);
1498
					}
1499
				});
1500
			}
1501
		});
1502
		jQuery('#trproviderplan').css("display","table-row");
1503
	}
1504

    
1505
	function prefill_provider() {
1506
		jQuery.ajax("getserviceproviders.php",{
1507
			type: 'post',
1508
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
1509
			success: function(data,textStatus,response) {
1510
				var xmldoc = response.responseXML;
1511
				var provider = xmldoc.getElementsByTagName('connection')[0];
1512
				jQuery('#username').val('');
1513
				jQuery('#password').val('');
1514
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1515
					jQuery('#phone').val('#777');
1516
					jQuery('#apn').val('');
1517
				} else {
1518
					jQuery('#phone').val('*99#');
1519
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1520
				}
1521
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1522
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1523
				jQuery('#username').val(username);
1524
				jQuery('#password').val(password);
1525
			}
1526
		});
1527
	}
1528

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

    
1943
									<tr style='display:none' name="show_adv_dhcp_protocol_timing" id="show_adv_dhcp_protocol_timing">
1944
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#PROTOCOL_TIMING>Protocol Timing</a>"); ?></td>
1945
										<td width="48%" class="vtable">
1946
											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, '');">
1947
											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, '');">
1948
											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, '');">
1949

    
1950
											&nbsp &nbsp &nbsp &nbsp 
1951
											Presets: &nbsp
1952
											<input name="adv_dhcp_pt_values" type="radio" value="DHCP"	unchecked	enabled id="customdhcpptdhcpdefaults"	onClick="customdhcpptsetvalues(this, iform);">FreeBSD Default &nbsp 
1953
											<input name="adv_dhcp_pt_values" type="radio" value="Clear"	unchecked	enabled id="customdhcpptclear"		onClick="customdhcpptsetvalues(this, iform);">Clear
1954

    
1955
											<br>
1956
											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, '');">
1957
											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, '');">
1958
											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, '');">
1959

    
1960
											&nbsp &nbsp &nbsp &nbsp &nbsp 
1961
											<input name="adv_dhcp_pt_values" type="radio" value="pfSense"	unchecked	enabled id="customdhcpptpfsensedefaults"	onClick="customdhcpptsetvalues(this, iform);">pfSense Default &nbsp 
1962
											<input name="adv_dhcp_pt_values" type="radio" value="SavedCfg" checked	enabled id="customdhcpptsavedcfg"		onClick="customdhcpptsetvalues(this, iform);">Saved Cfg 
1963

    
1964
											<br>
1965
											<?=gettext("The values in these fields are DHCP protocol timings used when requesting a lease. <br> " ); ?>
1966

    
1967
											<script type="text/javascript">
1968
												function customdhcpptcheckradiobuton(T, BUTTON) {
1969
													for (var i = 0; i < T.length; i++) {
1970
														T[i].checked = false;
1971
														if (T[i].value == BUTTON) T[i].checked = true;
1972
													}
1973
													T.value = BUTTON;
1974
												}
1975

    
1976
												function customdhcpptsetvalues(T, FORM) {
1977
													// timeout, retry, select-timeout, reboot, backoff-cutoff, initial-interval
1978
													if (T.value == "DHCP")		customdhcpptsetvaluesnow(T, FORM, "60", "300", "0", "10", "120", "10");
1979
													if (T.value == "pfSense")	customdhcpptsetvaluesnow(T, FORM, "60", "15", "0", "", "", "1");
1980
													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']);?>");
1981
													if (T.value == "Clear")		customdhcpptsetvaluesnow(T, FORM, "", "", "", "", "", "");
1982
												}
1983

    
1984
												function customdhcpptsetvaluesnow(T, FORM, timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
1985
													FORM.adv_dhcp_pt_timeout.value = timeout;
1986
													FORM.adv_dhcp_pt_retry.value = retry;
1987
													FORM.adv_dhcp_pt_select_timeout.value = selecttimeout;
1988
													FORM.adv_dhcp_pt_reboot.value = reboot;
1989
													FORM.adv_dhcp_pt_backoff_cutoff.value = backoffcutoff;
1990
													FORM.adv_dhcp_pt_initial_interval.value = initialinterval;
1991

    
1992
													FORM.adv_dhcp_pt_values.value = T.value;
1993
												}
1994

    
1995
												<!-- Set the adv_dhcp_pt_values radio button from saved config -->
1996
												var RADIOBUTTON_VALUE = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values']);?>";
1997
												if (RADIOBUTTON_VALUE == "") RADIOBUTTON_VALUE = "SavedCfg";
1998
												customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, RADIOBUTTON_VALUE);
1999
											</script>
2000
										</td>
2001
									</tr>
2002

    
2003
									<tr style='display:none' name="show_adv_dhcp_lease_requirements_and_requests" id="show_adv_dhcp_lease_requirements_and_requests">
2004
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS>Lease Requirements and Requests</a>"); ?></td>
2005
										<td width="78%" class="vtable">
2006
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS>Send</a> <a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&sektion=5>Options</a>"); ?><br>
2007
											<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']);?>">
2008
											<br>
2009
											<?=gettext("The values in this field are DHCP options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br>" .
2010
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br>" .
2011
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br>" .
2012
											"Some ISPs may require certain options be or not be sent. "); ?>
2013
											<hr>
2014
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS>Request</a> <a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&sektion=5>Options</a>"); ?><br>
2015
											<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']);?>">
2016
											<br>
2017
											<?=gettext("The values in this field are DHCP option 55 to be sent when requesting a DHCP lease.  [option [, ...]] <br>" .
2018
											"Some ISPs may require certain options be or not be requested. "); ?>
2019
											<hr>
2020
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS>Require</a> <a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&sektion=5>Options</a>"); ?><br>
2021
											<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']);?>">
2022
											<br>
2023
											<?=gettext("The values in this field are DHCP options required by the client when requesting a DHCP lease.  [option [, ...]] "); ?>
2024
										</td>
2025
									</tr>
2026

    
2027
									<tr style='display:none' name="show_adv_dhcp_option_modifiers" id="show_adv_dhcp_option_modifiers">
2028
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&sektion=5>Option</a> <a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5#OPTION_MODIFIERS>Modifiers</a>"); ?></td>
2029
										<td width="78%" class="vtable">
2030
											<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']);?>">
2031
											<br>
2032
											<?=gettext("The values in this field are DHCP option modifiers applied to obtained DHCP lease.  [modifier option declaration [, ...]] <br> " .
2033
											"modifiers: (default, supersede, prepend, append)"); ?>
2034
										</td>
2035
									</tr>
2036

    
2037
									<tr style='display:none' name="show_adv_dhcp_config_file_override" id="show_adv_dhcp_config_file_override">
2038
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&sektion=5>Configuration File</a> Override"); ?></td>
2039
										<td width="78%" class="vtable">
2040
 											<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']);?>">
2041
											<br>
2042
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br> " .
2043
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br>" .
2044
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br>" .
2045
											"Some ISPs may require certain options be or not be sent. "); ?>
2046
										</td>
2047
									</tr>
2048

    
2049
 									<tr>
2050
 										<td colspan="2" valign="top" height="16"></td>
2051
 									</tr>
2052

    
2053
									<script type="text/javascript">
2054
										function show_adv_dhcp_config(T) {
2055

    
2056
											if (T.checked) T.value = "Selected";
2057
											else T.value = "";
2058

    
2059
											     if (document.iform.adv_dhcp_config_file_override.checked)	show_hide_adv_dhcp('none', 'none', '');
2060
											else if (document.iform.adv_dhcp_config_advanced.checked)	show_hide_adv_dhcp('', '', 'none');
2061
											else 									show_hide_adv_dhcp('', 'none', 'none');
2062
										}
2063

    
2064
										function show_hide_adv_dhcp(basic, advanced, override) {
2065

    
2066
											document.getElementById("show_basic_dhcphostname").style.display = basic;
2067
											document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2068
											document.getElementById("show_basic_dhcprejectlease").style.display = basic;
2069

    
2070
											document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2071
											document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2072
											document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2073

    
2074
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2075
										}
2076

    
2077
										<!-- Set the adv_dhcp_config_advanced checkbox from saved config -->
2078
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_advanced']);?>" == "Selected") document.iform.adv_dhcp_config_advanced.checked = true;
2079
										show_adv_dhcp_config(document.iform.adv_dhcp_config_advanced);
2080

    
2081
										<!-- Set the adv_dhcp_config_file_override checkbox from saved config -->
2082
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override']);?>" == "Selected") document.iform.adv_dhcp_config_file_override.checked = true;
2083
										show_adv_dhcp_config(document.iform.adv_dhcp_config_file_override);
2084
									</script>
2085

    
2086
								</table>
2087
							</td>
2088
						</tr>
2089
						<tr style="display:none;" name="dhcp6" id="dhcp6">
2090
							<td colspan="2" style="padding: 0px;">
2091
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp6">
2092
									<tr>
2093
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration &nbsp &nbsp " .
2094
										' <input name="adv_dhcp6_config_advanced" type="checkbox" id="adv_dhcp6_config_advanced" value="" onClick="show_adv_dhcp6_config(this)";> ' .
2095
										" Advanced &nbsp &nbsp " .
2096
										' <input name="adv_dhcp6_config_file_override" type="checkbox" id="adv_dhcp6_config_file_override" value="" onClick="show_adv_dhcp6_config(this)";> ' .
2097
										" Config File Override &nbsp &nbsp "); ?>
2098
										</td>
2099
									</tr>
2100
									<!--- Leave commented out for now
2101
									<tr style='display:none' name="basicdhcp6_show_dhcp6_duid" id="basicdhcp6_show_dhcp6_duid">
2102
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
2103
										<td width="78%" class="vtable">
2104
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>" />
2105
											<br/>
2106
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
2107
											"when requesting a DHCPv6 lease."); ?><br />
2108
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
2109
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
2110
												}
2111
												printf(gettext("The current DUID is: '%s'"),$current_duid);
2112
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
2113
											?>
2114
										</td>
2115
									</tr>
2116
									-->
2117
									<tr style='display:none' name="basicdhcp6_show_dhcp6_prefix_only" id="basicdhcp6_show_dhcp6_prefix_only">
2118
										<td width="22%" valign="top" class="vncell"><?=gettext("Request only a IPv6 prefix"); ?></td>
2119
										<td width="78%" class="vtable">
2120
											<input name="dhcp6prefixonly" type="checkbox" value="yes" <?php if ($pconfig['dhcp6prefixonly'] == true) echo "checked=\"checked\""; ?>" />
2121
											<?=gettext("Only request a IPv6 prefix, do not request a IPv6 address"); ?>
2122
										</td>
2123
									</tr>
2124
									<tr style='display:none' name="basicdhcp6_show_dhcp6_prefix_delegation_size" id="basicdhcp6_show_dhcp6_prefix_delegation_size">
2125
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
2126
										<td width="78%" class="vtable">
2127
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
2128
												<?php
2129
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
2130
												foreach($sizes as $bits => $length) {
2131
													echo "<option value=\"{$bits}\" ";
2132
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected=\"selected\"";
2133
													echo ">" . $length . "</option>";
2134
												}
2135
												?>
2136
											</select>
2137
											<br/>
2138
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
2139
										</td>
2140
									</tr>
2141

    
2142
									<tr style='display:none' name="show_adv_dhcp6_interface_statement" id="show_adv_dhcp6_interface_statement">
2143
										<td width="22%" valign="top" class="vncell">
2144
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&sektion=5&apropos=0&manpath=FreeBSD+Ports#Interface_statement>Interface Statement</a>"); ?>
2145
											<br><br>
2146
											<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)";>
2147
											<?=gettext("Information Only"); ?>
2148
										</td>
2149
										<td width="78%" class="vtable">
2150
											<?=gettext("Send Options"); ?><br>
2151
											<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']);?>">
2152
											<br>
2153
											<?=gettext("The values in this field are DHCP send options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br>" .
2154
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br>" .
2155
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br>" .
2156
											"Some DHCP services may require certain options be or not be sent. "); ?>
2157
											<br>
2158
											<br>
2159
											<?=gettext("Request Options"); ?><br>
2160
											<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']);?>">
2161
											<br>
2162
											<?=gettext("The values in this field are DHCP request options to be sent when requesting a DHCP lease.  [option [, ...]] <br>" .
2163
											"Some DHCP services may require certain options be or not be requested. "); ?>
2164
											<br>
2165
											<br>
2166
											<?=gettext("Script"); ?><br>
2167
											<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']);?>">
2168
											<br>
2169
											<?=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>" .
2170
											"[/[dirname/[.../]]filename[.ext]] "); ?>
2171
										</td>
2172
									</tr>
2173

    
2174
									<tr style='display:none' name="show_adv_dhcp6_id_assoc_statement" id="show_adv_dhcp6_id_assoc_statement">
2175
										<td width="22%" valign="top" class="vncell">
2176
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&sektion=5&apropos=0&manpath=FreeBSD+Ports#Identity_association_statement>Identity Association Statement</a>"); ?>
2177
										</td>
2178
										<td width="78%" class="vtable">
2179

    
2180
											<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)";>
2181
											<?=gettext("Non-Temporary Address Allocation"); ?>
2182
											<div style='display:none'  name="show_adv_dhcp6_id_assoc_statement_address" id="show_adv_dhcp6_id_assoc_statement_address">
2183
											<?=gettext("id-assoc na"); ?>
2184
											<?=gettext("<i>ID</i>"); ?>
2185
											<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']);?>">
2186
											<br>
2187
											<?=gettext("Address"); ?>
2188
											<?=gettext("<i>ipv6-address</i>"); ?>
2189
											<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']);?>">
2190
											<?=gettext("<i>pltime</i>"); ?>
2191
											<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']);?>">
2192
											<?=gettext("<i>vltime</i>"); ?>
2193
											<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']);?>">
2194
											</div>
2195
											<hr>
2196

    
2197
											<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)";>
2198
											<?=gettext("Prefix Delegation"); ?>
2199
											<div style='display:none'  name="show_adv_dhcp6_id_assoc_statement_prefix" id="show_adv_dhcp6_id_assoc_statement_prefix">
2200
											<?=gettext("id-assoc pd"); ?>
2201
											<?=gettext("<i>ID</i>"); ?>
2202
											<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']);?>">
2203
											<br>
2204
											<?=gettext("Prefix"); ?>
2205
											<?=gettext("<i>ipv6-prefix</i>"); ?>
2206
											<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']);?>">
2207
											<?=gettext("<i>pltime</i>"); ?>
2208
											<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']);?>">
2209
											<?=gettext("<i>vltime</i>"); ?>
2210
											<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']);?>">
2211
											</div>
2212
										</td>
2213
									</tr>
2214

    
2215
									<tr style='display:none' name="show_adv_dhcp6_prefix_interface_statement" id="show_adv_dhcp6_prefix_interface_statement">
2216
										<td width="22%" valign="top" class="vncell">
2217
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&sektion=5&apropos=0&manpath=FreeBSD+Ports#Prefix_interface_statement>Prefix Interface Statement</a>"); ?>
2218
										</td>
2219
										<td width="78%" class="vtable">
2220
											<?=gettext("Prefix Interface "); ?>
2221
											<?=gettext("<i>sla-id</i>"); ?>
2222
											<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']);?>">
2223
											<?=gettext("<i>sla-len</i>"); ?>
2224
											<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']);?>">
2225
										</td>
2226
									</tr>
2227

    
2228
									<tr style='display:none' name="show_adv_dhcp6_authentication_statement" id="show_adv_dhcp6_authentication_statement">
2229
										<td width="22%" valign="top" class="vncell">
2230
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&sektion=5&apropos=0&manpath=FreeBSD+Ports#Authentication_statement>Authentication Statement</a>"); ?>
2231
										</td>
2232
										<td width="78%" class="vtable">
2233
											<?=gettext("<i>authname</i>"); ?>
2234
											<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']);?>">
2235
											<?=gettext("<i>protocol</i>"); ?>
2236
											<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']);?>">
2237
											<?=gettext("<i>algorithm</i>"); ?>
2238
											<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']);?>">
2239
											<?=gettext("<i>rdm</i>"); ?>
2240
											<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']);?>">
2241
										</td>
2242
									</tr>
2243

    
2244
									<tr style='display:none' name="show_adv_dhcp6_key_info_statement" id="show_adv_dhcp6_key_info_statement">
2245
										<td width="22%" valign="top" class="vncell">
2246
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&sektion=5&apropos=0&manpath=FreeBSD+Ports#Keyinfo_statement>Keyinfo Statement</a>"); ?>
2247
										</td>
2248
										<td width="78%" class="vtable">
2249
											<?=gettext("<i>keyname</i>"); ?>
2250
											<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']);?>">
2251
											<?=gettext("<i>realm</i>"); ?>
2252
											<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']);?>">
2253
											<br>
2254
											<?=gettext("<i>keyid</i>"); ?>
2255
											<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']);?>">
2256
											<?=gettext("<i>secret</i>"); ?>
2257
											<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']);?>">
2258
											<?=gettext("<i>expire</i>"); ?>
2259
											<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']);?>">
2260
										</td>
2261
									</tr>
2262

    
2263
									<tr style='display:none' name="show_adv_dhcp6_config_file_override" id="show_adv_dhcp6_config_file_override">
2264
										<td width="22%" valign="top" class="vncell">
2265
											<?=gettext("<a target=FreeBSD DHCP href=http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&sektion=5&apropos=0&manpath=FreeBSD+Ports>Configuration File</a> Override"); ?>
2266
										</td>
2267
										<td width="78%" class="vtable">
2268
 											<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']);?>">
2269
											<br>
2270
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br> " .
2271
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br>" .
2272
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br>" .
2273
											"Some ISPs may require certain options be or not be sent. "); ?>
2274
										</td>
2275
									</tr>
2276

    
2277
 									<tr>
2278
 										<td colspan="2" valign="top" height="16"></td>
2279
 									</tr>
2280

    
2281
									<script type="text/javascript">
2282
										function show_adv_dhcp6_config(T) {
2283

    
2284
											if (T.checked) T.value = "Selected";
2285
											else T.value = "";
2286

    
2287
											     if (document.iform.adv_dhcp6_config_file_override.checked)	show_hide_adv_dhcp6('none', 'none', ''    );
2288
											else if (document.iform.adv_dhcp6_config_advanced.checked)		show_hide_adv_dhcp6('none', '',     'none');
2289
											else 															show_hide_adv_dhcp6('',     'none', 'none');
2290
										}
2291

    
2292
										function show_hide_adv_dhcp6(basic, advanced, override) {
2293

    
2294
											document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2295
											document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
2296

    
2297
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2298
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2299

    
2300
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2301
											if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked)  {
2302
												document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2303
											}
2304

    
2305
											document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = 'none';
2306
											document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = 'none';
2307
											if (document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked)  {
2308
												document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = advanced;
2309
												document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = advanced;
2310
											}
2311

    
2312
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2313
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2314

    
2315
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2316
										}
2317

    
2318
										<!-- Set the adv_dhcp6_config_advanced checkbox from saved config -->
2319
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_advanced']);?>" == "Selected") document.iform.adv_dhcp6_config_advanced.checked = true;
2320
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_advanced);
2321

    
2322
										<!-- Set the adv_dhcp6_config_file_override checkbox from saved config -->
2323
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override']);?>" == "Selected") document.iform.adv_dhcp6_config_file_override.checked = true;
2324
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_file_override);
2325

    
2326
										<!-- Set the adv_dhcp6_interface_statement_information_only_enable checkbox from saved config -->
2327
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_information_only_enable']);?>" == "Selected") document.iform.adv_dhcp6_interface_statement_information_only_enable.checked = true;
2328
										show_adv_dhcp6_config(document.iform.adv_dhcp6_interface_statement_information_only_enable);
2329

    
2330
										<!-- Set the adv_dhcp6_id_assoc_statement_address_enable checkbox from saved config -->
2331
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked = true;
2332
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_address_enable);
2333

    
2334
										<!-- Set the adv_dhcp6_id_assoc_statement_prefix_enable checkbox from saved config -->
2335
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked = true;
2336
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_prefix_enable);
2337
									</script>
2338

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

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

    
3226
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="buttons">
3227
						<tr>
3228
							<td width="22%" valign="top">
3229
								&nbsp;
3230
							</td>
3231
							<td width="78%">
3232
								<br/>
3233
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
3234
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
3235
								<input name="if" type="hidden" id="if" value="<?=$if;?>" />
3236
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
3237
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>" />
3238
								<?php endif; ?>
3239
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>" />
3240
							</td>
3241
						</tr>
3242
					</table>
3243
					</div>
3244
				</td>
3245
			</tr>
3246
		</table>
3247
	</form>
3248
	<script type="text/javascript">
3249
	//<![CDATA[
3250
		var gatewayip;
3251
		var name;
3252
		var gatewayipv6;
3253
		var namev6;
3254
		function show_add_gateway() {
3255
			document.getElementById("addgateway").style.display = '';
3256
			document.getElementById("addgwbox").style.display = 'none';
3257
			document.getElementById("gateway").style.display = 'none';
3258
			document.getElementById("save").style.display = 'none';
3259
			document.getElementById("cancel").style.display = 'none';
3260
			document.getElementById("gwsave").style.display = '';
3261
			document.getElementById("gwcancel").style.display = '';
3262
			jQuery('#notebox').html("");
3263
		}
3264
		function show_add_gateway_v6() {
3265
			document.getElementById("addgatewayv6").style.display = '';
3266
			document.getElementById("addgwboxv6").style.display = 'none';
3267
			document.getElementById("gatewayv6").style.display = 'none';
3268
			document.getElementById("save").style.display = 'none';
3269
			document.getElementById("cancel").style.display = 'none';
3270
			document.getElementById("gwsave").style.display = '';
3271
			document.getElementById("gwcancel").style.display = '';
3272
			jQuery('#noteboxv6').html("");
3273
		}
3274
		function hide_add_gateway() {
3275
			document.getElementById("addgateway").style.display = 'none';
3276
			document.getElementById("addgwbox").style.display = '';
3277
			document.getElementById("gateway").style.display = '';
3278
			document.getElementById("save").style.display = '';
3279
			document.getElementById("cancel").style.display = '';
3280
			document.getElementById("gwsave").style.display = '';
3281
			document.getElementById("gwcancel").style.display = '';
3282
			jQuery('#status').html('');
3283
		}
3284
		function hide_add_gateway_v6() {
3285
			document.getElementById("addgatewayv6").style.display = 'none';
3286
			document.getElementById("addgwboxv6").style.display = '';
3287
			document.getElementById("gatewayv6").style.display = '';
3288
			document.getElementById("save").style.display = '';
3289
			document.getElementById("cancel").style.display = '';
3290
			document.getElementById("gwsave").style.display = '';
3291
			document.getElementById("gwcancel").style.display = '';
3292
			jQuery('#statusv6').html('');
3293
		}
3294
		function hide_add_gatewaysave() {
3295
			document.getElementById("addgateway").style.display = 'none';
3296
			jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif" alt="loader" /> One moment please...');
3297
			var iface = jQuery('#if').val();
3298
			name = jQuery('#name').val();
3299
			var descr = jQuery('#gatewaydescr').val();
3300
			gatewayip = jQuery('#gatewayip').val();
3301

    
3302
			var defaultgw = jQuery('#defaultgw').val();
3303
			var url = "system_gateways_edit.php";
3304
			var pars = 'isAjax=true&ipprotocol=inet&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3305
			jQuery.ajax(
3306
				url,
3307
				{
3308
					type: 'post',
3309
					data: pars,
3310
					error: report_failure,
3311
					success: save_callback
3312
				});
3313
		}
3314
		function hide_add_gatewaysave_v6() {
3315
			document.getElementById("addgatewayv6").style.display = 'none';
3316
			jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif" alt="loader" /> One moment please...');
3317
			var iface = jQuery('#if').val();
3318
			name = jQuery('#namev6').val();
3319
			var descr = jQuery('#gatewaydescrv6').val();
3320
			gatewayip = jQuery('#gatewayipv6').val();
3321
			var defaultgw = jQuery('#defaultgwv6').val();
3322
			var url_v6 = "system_gateways_edit.php";
3323
			var pars_v6 = 'isAjax=true&ipprotocol=inet6&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3324
			jQuery.ajax(
3325
				url_v6,
3326
				{
3327
					type: 'post',
3328
					data: pars_v6,
3329
					error: report_failure_v6,
3330
					success: save_callback_v6
3331
				});
3332
		}
3333
		function addOption(selectbox,text,value)
3334
		{
3335
			var optn = document.createElement("OPTION");
3336
			optn.text = text;
3337
			optn.value = value;
3338
			selectbox.append(optn);
3339
			selectbox.prop('selectedIndex',selectbox.children().length-1);
3340
			jQuery('#notebox').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3341
		}
3342
		function addOption_v6(selectbox,text,value)
3343
		{
3344
			var optn = document.createElement("OPTION");
3345
			optn.text = text;
3346
			optn.value = value;
3347
			selectbox.append(optn);
3348
			selectbox.prop('selectedIndex',selectbox.children().length-1);
3349
			jQuery('#noteboxv6').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3350
		}
3351
		function report_failure(request, textStatus, errorThrown) {
3352
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3353
				alert(request.responseText);
3354
			} else {
3355
				alert("Sorry, we could not create your IPv4 gateway at this time.");
3356
			}
3357
			hide_add_gateway();
3358
		}
3359
		function report_failure_v6(request, textStatus, errorThrown) {
3360
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3361
				alert(request.responseText);
3362
			} else {
3363
				alert("Sorry, we could not create your IPv6 gateway at this time.");
3364
			}
3365
			hide_add_gateway_v6();
3366
		}
3367
		function save_callback(response) {
3368
			if(response) {
3369
				document.getElementById("addgateway").style.display = 'none';
3370
				hide_add_gateway();
3371
				var gwtext = escape(name) + " - " + gatewayip;
3372
				addOption(jQuery('#gateway'), gwtext, name);
3373
				// Auto submit form?
3374
				//document.iform.submit();
3375
				//jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif" alt="loader /">');
3376
			} else {
3377
				report_failure();
3378
			}
3379
		}
3380
		function show_advanced_media() {
3381
			document.getElementById("showadvmediabox").innerHTML='';
3382
			aodiv = document.getElementById('showmediaadv');
3383
			aodiv.style.display = "block";
3384
		}
3385
		function save_callback_v6(response_v6) {
3386
			if(response_v6) {
3387
				document.getElementById("addgatewayv6").style.display = 'none';
3388
				hide_add_gateway_v6();
3389
				var gwtext_v6 = escape(name) + " - " + gatewayip;
3390
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
3391
				// Auto submit form?
3392
				//document.iform.submit();
3393
				//jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif" alt="loader" />');
3394
			} else {
3395
				report_failure_v6();
3396
			}
3397
		}
3398
		<?php
3399
		echo "show_allcfg(document.iform.enable);";
3400
		echo "updateType('{$pconfig['type']}');\n";
3401
		echo "updateTypeSix('{$pconfig['type6']}');\n";
3402
		?>
3403
	//]]>
3404
	</script>
3405
	<?php include("fend.inc"); ?>
3406
	</body>
3407
</html>
(93-93/246)