Projet

Général

Profil

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

univnautes / usr / local / www / interfaces.php @ 6f3d2063

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
123
		/* ================================================ */
124
		/* = force a connection reset at a specific time? = */
125
		/* ================================================ */
126

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

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

    
190
$pconfig['adv_dhcp_pt_values'] = $wancfg['adv_dhcp_pt_values'];
191

    
192
$pconfig['adv_dhcp_send_options'] = $wancfg['adv_dhcp_send_options'];
193
$pconfig['adv_dhcp_request_options'] = $wancfg['adv_dhcp_request_options'];
194
$pconfig['adv_dhcp_required_options'] = $wancfg['adv_dhcp_required_options'];
195
$pconfig['adv_dhcp_option_modifiers'] = $wancfg['adv_dhcp_option_modifiers'];
196

    
197
$pconfig['adv_dhcp_config_advanced'] = $wancfg['adv_dhcp_config_advanced'];
198
$pconfig['adv_dhcp_config_file_override'] = $wancfg['adv_dhcp_config_file_override'];
199
$pconfig['adv_dhcp_config_file_override_path'] = $wancfg['adv_dhcp_config_file_override_path'];
200

    
201
$pconfig['adv_dhcp6_interface_statement_send_options'] = $wancfg['adv_dhcp6_interface_statement_send_options'];
202
$pconfig['adv_dhcp6_interface_statement_request_options'] = $wancfg['adv_dhcp6_interface_statement_request_options'];
203
$pconfig['adv_dhcp6_interface_statement_information_only_enable'] = $wancfg['adv_dhcp6_interface_statement_information_only_enable'];
204
$pconfig['adv_dhcp6_interface_statement_script'] = $wancfg['adv_dhcp6_interface_statement_script'];
205

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

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

    
218
$pconfig['adv_dhcp6_prefix_interface_statement_sla_id'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_id'];
219
$pconfig['adv_dhcp6_prefix_interface_statement_sla_len'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_len'];
220

    
221
$pconfig['adv_dhcp6_authentication_statement_authname'] = $wancfg['adv_dhcp6_authentication_statement_authname'];
222
$pconfig['adv_dhcp6_authentication_statement_protocol'] = $wancfg['adv_dhcp6_authentication_statement_protocol'];
223
$pconfig['adv_dhcp6_authentication_statement_algorithm'] = $wancfg['adv_dhcp6_authentication_statement_algorithm'];
224
$pconfig['adv_dhcp6_authentication_statement_rdm'] = $wancfg['adv_dhcp6_authentication_statement_rdm'];
225

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

    
232
$pconfig['adv_dhcp6_config_advanced'] = $wancfg['adv_dhcp6_config_advanced'];
233
$pconfig['adv_dhcp6_config_file_override'] = $wancfg['adv_dhcp6_config_file_override'];
234
$pconfig['adv_dhcp6_config_file_override_path'] = $wancfg['adv_dhcp6_config_file_override_path'];
235

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

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

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

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

    
314
// print_r($pconfig);
315

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

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

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

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

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

    
429
		/* sync filter configuration */
430
		setup_gateways_monitor();
431

    
432
		clear_subsystem_dirty('interfaces');
433

    
434
		filter_configure();
435

    
436
		enable_rrd_graphing();
437

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

    
463
	unset($input_errors);
464
	$pconfig = $_POST;
465
	if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
466
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
467
	else
468
		$pconfig['track6-prefix-id'] = 0;
469
	conf_mount_rw();
470

    
471
	/* filter out spaces from descriptions  */
472
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
473

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

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

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

    
608

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

    
619
			/* Do not accept network or broadcast address, except if subnet is 31 or 32 */
620
			if ($_POST['subnet'] < 31) {
621
				if ($_POST['ipaddr'] == gen_subnet($_POST['ipaddr'], $_POST['subnet']))
622
					$input_errors[] = gettext("This IPv4 address is the network address and cannot be used");
623
				else if ($_POST['ipaddr'] == gen_subnet_max($_POST['ipaddr'], $_POST['subnet']))
624
					$input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used");
625
			}
626

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

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

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

    
720
				$realhwif_array = get_parent_interface($ifdata['if']);
721
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
722
				$parent_realhwif = $realhwif_array[0];
723

    
724
				if ($parent_realhwif != $wancfg['if'])
725
					continue;
726

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

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

    
824
		unset($wancfg['adv_dhcp_pt_timeout']);
825
		unset($wancfg['adv_dhcp_pt_retry']);
826
		unset($wancfg['adv_dhcp_pt_select_timeout']);
827
		unset($wancfg['adv_dhcp_pt_reboot']);
828
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
829
		unset($wancfg['adv_dhcp_pt_initial_interval']);
830

    
831
		unset($wancfg['adv_dhcp_pt_values']);
832

    
833
		unset($wancfg['adv_dhcp_send_options']);
834
		unset($wancfg['adv_dhcp_request_options']);
835
		unset($wancfg['adv_dhcp_required_options']);
836
		unset($wancfg['adv_dhcp_option_modifiers']);
837

    
838
		unset($wancfg['adv_dhcp_config_advanced']);
839
		unset($wancfg['adv_dhcp_config_file_override']);
840
		unset($wancfg['adv_dhcp_config_file_override_path']);
841

    
842
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
843
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
844
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
845
		unset($wancfg['adv_dhcp6_interface_statement_script']);
846

    
847
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
848
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
849
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
850
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
851
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
852

    
853
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
854
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
855
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
856
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
857
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
858

    
859
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
860
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
861

    
862
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
863
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
864
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
865
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
866

    
867
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
868
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
869
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
870
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
871
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
872

    
873
		unset($wancfg['adv_dhcp6_config_advanced']);
874
		unset($wancfg['adv_dhcp6_config_file_override']);
875
		unset($wancfg['adv_dhcp6_config_file_override_path']);
876

    
877
		unset($wancfg['pppoe_password']);
878
		unset($wancfg['pptp_username']);
879
		unset($wancfg['pptp_password']);
880
		unset($wancfg['provider']);
881
		unset($wancfg['ondemand']);
882
		unset($wancfg['timeout']);
883
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
884
			unset($wancfg['pppoe']['pppoe-reset-type']);
885
		unset($wancfg['local']);
886

    
887
		unset($wancfg['remote']);
888
		unset($a_ppps[$pppid]['apn']);
889
		unset($a_ppps[$pppid]['phone']);
890
		unset($a_ppps[$pppid]['localip']);
891
		unset($a_ppps[$pppid]['subnet']);
892
		unset($a_ppps[$pppid]['gateway']);
893
		unset($a_ppps[$pppid]['pppoe-reset-type']);
894
		unset($a_ppps[$pppid]['provider']);
895

    
896
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
897
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
898

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

    
915
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
916
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
917
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
918
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
919
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
920
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
921

    
922
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
923

    
924
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
925
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
926
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
927
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
928

    
929
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
930
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
931
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
932

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

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

    
973
				if (!empty($_POST['pppoe-reset-type']))
974
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
975
				else
976
					unset($a_ppps[$pppid]['pppoe-reset-type']);
977
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
978
				$wancfg['ipaddr'] = $_POST['type'];
979
				if($gateway_item) {
980
					$a_gateways[] = $gateway_item;
981
				}
982

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

    
1034
				$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1035
				$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1036
				$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1037
				$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1038

    
1039
				$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1040
				$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1041
				$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1042
				$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1043
				$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1044

    
1045
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1046
				$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1047
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1048
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1049
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1050

    
1051
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1052
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1053

    
1054
				$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1055
				$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1056
				$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1057
				$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1058

    
1059
				$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1060
				$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1061
				$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1062
				$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1063
				$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1064

    
1065
				$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1066
				$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1067
				$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1068

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

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

    
1134
		conf_mount_ro();
1135
		write_config();
1136

    
1137
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
1138
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
1139
		} else {
1140
			$toapplylist = array();
1141
		}
1142
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
1143
		$toapplylist[$if]['ppps'] = $old_ppps;
1144
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
1145

    
1146
		mark_subsystem_dirty('interfaces');
1147

    
1148
		/* regenerate cron settings/crontab file */
1149
		configure_cron();
1150

    
1151
		header("Location: interfaces.php?if={$if}");
1152
		exit;
1153
	}
1154

    
1155
} // end if($_POST)
1156

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

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

    
1298
function check_wireless_mode() {
1299
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1300

    
1301
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1302
		return;
1303

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

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

    
1341
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1342
$shortcut_section = "interfaces";
1343

    
1344
$closehead = false;
1345
include("head.inc");
1346
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1347
$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"));
1348

    
1349
?>
1350

    
1351
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1352
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1353
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1354
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1355

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

    
1427
	function show_allcfg(obj) {
1428
		if (obj.checked)
1429
			jQuery('#allcfg').show();
1430
		else
1431
			jQuery('#allcfg').hide();
1432
	}
1433

    
1434
	function show_reset_settings(reset_type) {
1435
		if (reset_type == 'preset') {
1436
			jQuery('#pppoepresetwrap').show();
1437
			jQuery('#pppoecustomwrap').hide();
1438
		}
1439
		else if (reset_type == 'custom') {
1440
			jQuery('#pppoecustomwrap').show();
1441
			jQuery('#pppoepresetwrap').hide();
1442
		} else {
1443
			jQuery('#pppoecustomwrap').hide();
1444
			jQuery('#pppoepresetwrap').hide();
1445
		}
1446
	}
1447
	function show_mon_config() {
1448
		jQuery("#showmonbox").html('');
1449
		jQuery('#showmon').css('display','block');
1450
	}
1451

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

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

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

    
1513
						var option = new Element('option');
1514
						option.text = providerplan[0] + " - " + providerplan[1];
1515
						option.value = providerplan[1];
1516
						jQuery('#providerplan').append(option);
1517
					}
1518
				});
1519
			}
1520
		});
1521
		jQuery('#trproviderplan').css("display","table-row");
1522
	}
1523

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

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

    
1965
									<tr style='display:none' id="show_adv_dhcp_protocol_timing">
1966
										<td width="22%" valign="top" class="vncell"><a target="_blank" href="http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#PROTOCOL_TIMING"><?=gettext("Protocol Timing"); ?></a></td>
1967
										<td width="48%" class="vtable">
1968
											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, '');" />
1969
											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, '');" />
1970
											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, '');" />
1971

    
1972
											&nbsp; &nbsp; &nbsp; &nbsp; 
1973
											Presets: &nbsp;
1974
											<input name="adv_dhcp_pt_values" type="radio" value="DHCP"	id="customdhcpptdhcpdefaults"	onclick="customdhcpptsetvalues(this, iform);" />FreeBSD Default &nbsp; 
1975
											<input name="adv_dhcp_pt_values" type="radio" value="Clear"	id="customdhcpptclear"		onclick="customdhcpptsetvalues(this, iform);" />Clear
1976

    
1977
											<br />
1978
											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, '');" />
1979
											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, '');" />
1980
											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, '');" />
1981

    
1982
											&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
1983
											<input name="adv_dhcp_pt_values" type="radio" value="pfSense"	id="customdhcpptpfsensedefaults"	onclick="customdhcpptsetvalues(this, iform);" />pfSense Default &nbsp; 
1984
											<input name="adv_dhcp_pt_values" type="radio" value="SavedCfg" checked="checked"	id="customdhcpptsavedcfg"		onclick="customdhcpptsetvalues(this, iform);" />Saved Cfg 
1985

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

    
1989
											<script type="text/javascript">
1990
											//<![CDATA[
1991
												function customdhcpptcheckradiobuton(T, BUTTON) {
1992
													for (var i = 0; i < T.length; i++) {
1993
														T[i].checked = false;
1994
														if (T[i].value == BUTTON) T[i].checked = true;
1995
													}
1996
													T.value = BUTTON;
1997
												}
1998

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

    
2007
												function customdhcpptsetvaluesnow(T, FORM, timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
2008
													FORM.adv_dhcp_pt_timeout.value = timeout;
2009
													FORM.adv_dhcp_pt_retry.value = retry;
2010
													FORM.adv_dhcp_pt_select_timeout.value = selecttimeout;
2011
													FORM.adv_dhcp_pt_reboot.value = reboot;
2012
													FORM.adv_dhcp_pt_backoff_cutoff.value = backoffcutoff;
2013
													FORM.adv_dhcp_pt_initial_interval.value = initialinterval;
2014

    
2015
													FORM.adv_dhcp_pt_values.value = T.value;
2016
												}
2017

    
2018
												<!-- Set the adv_dhcp_pt_values radio button from saved config -->
2019
												var RADIOBUTTON_VALUE = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values']);?>";
2020
												if (RADIOBUTTON_VALUE == "") RADIOBUTTON_VALUE = "SavedCfg";
2021
												customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, RADIOBUTTON_VALUE);
2022
											//]]>
2023
											</script>
2024
										</td>
2025
									</tr>
2026

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

    
2051
									<tr style='display:none' id="show_adv_dhcp_option_modifiers">
2052
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Option</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#OPTION_MODIFIERS\">Modifiers</a>"); ?></td>
2053
										<td width="78%" class="vtable">
2054
											<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']);?>" />
2055
											<br />
2056
											<?=gettext("The values in this field are DHCP option modifiers applied to obtained DHCP lease.  [modifier option declaration [, ...]] <br /> " .
2057
											"modifiers: (default, supersede, prepend, append)"); ?>
2058
										</td>
2059
									</tr>
2060

    
2061
									<tr style='display:none' id="show_adv_dhcp_config_file_override">
2062
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5\">Configuration File</a> Override"); ?></td>
2063
										<td width="78%" class="vtable">
2064
 											<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']);?>" />
2065
											<br />
2066
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2067
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2068
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2069
											"Some ISPs may require certain options be or not be sent. "); ?>
2070
										</td>
2071
									</tr>
2072

    
2073
 									<tr>
2074
 										<td colspan="2" valign="top" height="16"></td>
2075
 									</tr>
2076

    
2077
								</table>
2078

    
2079
									<script type="text/javascript">
2080
									//<![CDATA[
2081
										function show_adv_dhcp_config(T) {
2082

    
2083
											if (T.checked) T.value = "Selected";
2084
											else T.value = "";
2085

    
2086
											     if (document.iform.adv_dhcp_config_file_override.checked)	show_hide_adv_dhcp('none', 'none', '');
2087
											else if (document.iform.adv_dhcp_config_advanced.checked)	show_hide_adv_dhcp('', '', 'none');
2088
											else 									show_hide_adv_dhcp('', 'none', 'none');
2089
										}
2090

    
2091
										function show_hide_adv_dhcp(basic, advanced, override) {
2092

    
2093
											document.getElementById("show_basic_dhcphostname").style.display = basic;
2094
											document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2095
											document.getElementById("show_basic_dhcprejectlease").style.display = basic;
2096

    
2097
											document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2098
											document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2099
											document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2100

    
2101
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2102
										}
2103

    
2104
										<!-- Set the adv_dhcp_config_advanced checkbox from saved config -->
2105
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_advanced']);?>" == "Selected") document.iform.adv_dhcp_config_advanced.checked = true;
2106
										show_adv_dhcp_config(document.iform.adv_dhcp_config_advanced);
2107

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

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

    
2183
									<tr style='display:none' id="show_adv_dhcp6_interface_statement">
2184
										<td width="22%" valign="top" class="vncell">
2185
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Interface_statement\">Interface Statement</a>"); ?>
2186
											<br /><br />
2187
											<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)" />
2188
											<?=gettext("Information Only"); ?>
2189
										</td>
2190
										<td width="78%" class="vtable">
2191
											<?=gettext("Send Options"); ?><br />
2192
											<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']);?>" />
2193
											<br />
2194
											<?=gettext("The values in this field are DHCP send options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2195
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2196
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2197
											"Some DHCP services may require certain options be or not be sent. "); ?>
2198
											<br />
2199
											<br />
2200
											<?=gettext("Request Options"); ?><br />
2201
											<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']);?>" />
2202
											<br />
2203
											<?=gettext("The values in this field are DHCP request options to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2204
											"Some DHCP services may require certain options be or not be requested. "); ?>
2205
											<br />
2206
											<br />
2207
											<?=gettext("Script"); ?><br />
2208
											<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']);?>" />
2209
											<br />
2210
											<?=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 />" .
2211
											"[/[dirname/[.../]]filename[.ext]] "); ?>
2212
										</td>
2213
									</tr>
2214

    
2215
									<tr style='display:none' id="show_adv_dhcp6_id_assoc_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&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Identity_association_statement\">Identity Association Statement</a>"); ?>
2218
										</td>
2219
										<td width="78%" class="vtable">
2220

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

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

    
2256
									<tr style='display:none' id="show_adv_dhcp6_prefix_interface_statement">
2257
										<td width="22%" valign="top" class="vncell">
2258
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Prefix_interface_statement\">Prefix Interface Statement</a>"); ?>
2259
										</td>
2260
										<td width="78%" class="vtable">
2261
											<?=gettext("Prefix Interface "); ?>
2262
											<?=gettext("<i>sla-id</i>"); ?>
2263
											<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']);?>" />
2264
											<?=gettext("<i>sla-len</i>"); ?>
2265
											<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']);?>" />
2266
										</td>
2267
									</tr>
2268

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

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

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

    
2318
 									<tr>
2319
 										<td colspan="2" valign="top" height="16"></td>
2320
 									</tr>
2321

    
2322
								</table>
2323

    
2324
									<script type="text/javascript">
2325
									//<![CDATA[
2326
										function show_adv_dhcp6_config(T) {
2327

    
2328
											if (T.checked) T.value = "Selected";
2329
											else T.value = "";
2330

    
2331
											     if (document.iform.adv_dhcp6_config_file_override.checked)	show_hide_adv_dhcp6('none', 'none', ''    );
2332
											else if (document.iform.adv_dhcp6_config_advanced.checked)		show_hide_adv_dhcp6('none', '',     'none');
2333
											else 															show_hide_adv_dhcp6('',     'none', 'none');
2334
										}
2335

    
2336
										function show_hide_adv_dhcp6(basic, advanced, override) {
2337

    
2338
											document.getElementById("basicdhcp6_use_pppoeinterface").style.display = basic;
2339
											document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2340
											document.getElementById("basicdhcp6_show_dhcp6_prefix_send_hint").style.display = basic;
2341
											document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
2342

    
2343
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2344
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2345

    
2346
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2347
											if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked)  {
2348
												document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2349
											}
2350

    
2351
											document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = 'none';
2352
											document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = 'none';
2353
											if (document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked)  {
2354
												document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = advanced;
2355
												document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = advanced;
2356
											}
2357

    
2358
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2359
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2360

    
2361
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2362
										}
2363

    
2364
										<!-- Set the adv_dhcp6_config_advanced checkbox from saved config -->
2365
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_advanced']);?>" == "Selected") document.iform.adv_dhcp6_config_advanced.checked = true;
2366
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_advanced);
2367

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

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

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

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

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

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

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

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