Projet

Général

Profil

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

univnautes / usr / local / www / interfaces.php @ 71f45fed

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
319
// print_r($pconfig);
320

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

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

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

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

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

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

    
437
		clear_subsystem_dirty('interfaces');
438

    
439
		filter_configure();
440

    
441
		enable_rrd_graphing();
442

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

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

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

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

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

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

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

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

    
622

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

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

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

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

    
725
		if ($_POST['mtu'] < $min_mtu || $_POST['mtu'] > $max_mtu)
726
			$input_errors[] = sprintf(gettext("The MTU must be from %d to %d bytes."), $min_mtu, $max_mtu);
727

    
728
		unset($min_mtu, $max_mtu);
729

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

    
744
				$realhwif_array = get_parent_interface($ifdata['if']);
745
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
746
				$parent_realhwif = $realhwif_array[0];
747

    
748
				if ($parent_realhwif != $wancfg['if'])
749
					continue;
750

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

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

    
846
		unset($wancfg['adv_dhcp_pt_timeout']);
847
		unset($wancfg['adv_dhcp_pt_retry']);
848
		unset($wancfg['adv_dhcp_pt_select_timeout']);
849
		unset($wancfg['adv_dhcp_pt_reboot']);
850
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
851
		unset($wancfg['adv_dhcp_pt_initial_interval']);
852

    
853
		unset($wancfg['adv_dhcp_pt_values']);
854

    
855
		unset($wancfg['adv_dhcp_send_options']);
856
		unset($wancfg['adv_dhcp_request_options']);
857
		unset($wancfg['adv_dhcp_required_options']);
858
		unset($wancfg['adv_dhcp_option_modifiers']);
859

    
860
		unset($wancfg['adv_dhcp_config_advanced']);
861
		unset($wancfg['adv_dhcp_config_file_override']);
862
		unset($wancfg['adv_dhcp_config_file_override_path']);
863

    
864
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
865
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
866
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
867
		unset($wancfg['adv_dhcp6_interface_statement_script']);
868

    
869
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
870
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
871
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
872
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
873
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
874

    
875
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
876
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
877
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
878
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
879
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
880

    
881
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
882
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
883

    
884
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
885
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
886
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
887
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
888

    
889
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
890
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
891
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
892
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
893
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
894

    
895
		unset($wancfg['adv_dhcp6_config_advanced']);
896
		unset($wancfg['adv_dhcp6_config_file_override']);
897
		unset($wancfg['adv_dhcp6_config_file_override_path']);
898

    
899
		unset($wancfg['pppoe_password']);
900
		unset($wancfg['pptp_username']);
901
		unset($wancfg['pptp_password']);
902
		unset($wancfg['provider']);
903
		if ($wancfg['ipaddr'] != "ppp")
904
			unset($wancfg['ondemand']);
905
		unset($wancfg['timeout']);
906
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
907
			unset($wancfg['pppoe']['pppoe-reset-type']);
908
		unset($wancfg['local']);
909

    
910
		unset($wancfg['remote']);
911
		unset($a_ppps[$pppid]['apn']);
912
		unset($a_ppps[$pppid]['phone']);
913
		unset($a_ppps[$pppid]['localip']);
914
		unset($a_ppps[$pppid]['subnet']);
915
		unset($a_ppps[$pppid]['gateway']);
916
		unset($a_ppps[$pppid]['pppoe-reset-type']);
917
		unset($a_ppps[$pppid]['provider']);
918

    
919
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
920
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
921

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

    
938
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
939
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
940
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
941
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
942
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
943
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
944

    
945
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
946

    
947
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
948
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
949
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
950
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
951

    
952
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
953
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
954
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
955

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

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

    
996
				if (!empty($_POST['pppoe-reset-type']))
997
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
998
				else
999
					unset($a_ppps[$pppid]['pppoe-reset-type']);
1000
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1001
				$wancfg['ipaddr'] = $_POST['type'];
1002
				if($gateway_item) {
1003
					$a_gateways[] = $gateway_item;
1004
				}
1005

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

    
1057
				$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1058
				$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1059
				$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1060
				$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1061

    
1062
				$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1063
				$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1064
				$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1065
				$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1066
				$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1067

    
1068
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1069
				$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1070
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1071
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1072
				$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1073

    
1074
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1075
				$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1076

    
1077
				$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1078
				$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1079
				$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1080
				$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1081

    
1082
				$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1083
				$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1084
				$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1085
				$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1086
				$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1087

    
1088
				$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1089
				$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1090
				$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1091

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

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

    
1157
		conf_mount_ro();
1158
		write_config();
1159

    
1160
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
1161
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
1162
		} else {
1163
			$toapplylist = array();
1164
		}
1165
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
1166
		$toapplylist[$if]['ppps'] = $old_ppps;
1167
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
1168

    
1169
		mark_subsystem_dirty('interfaces');
1170

    
1171
		/* regenerate cron settings/crontab file */
1172
		configure_cron();
1173

    
1174
		header("Location: interfaces.php?if={$if}");
1175
		exit;
1176
	}
1177

    
1178
} // end if($_POST)
1179

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

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

    
1321
function check_wireless_mode() {
1322
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1323

    
1324
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1325
		return;
1326

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

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

    
1364
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1365
$shortcut_section = "interfaces";
1366

    
1367
$closehead = false;
1368
include("head.inc");
1369
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1370
$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"));
1371

    
1372
?>
1373

    
1374
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1375
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1376
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1377
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1378

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

    
1450
	function show_allcfg(obj) {
1451
		if (obj.checked)
1452
			jQuery('#allcfg').show();
1453
		else
1454
			jQuery('#allcfg').hide();
1455
	}
1456

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

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

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

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

    
1536
						var option = new Element('option');
1537
						option.text = providerplan[0] + " - " + providerplan[1];
1538
						option.value = providerplan[1];
1539
						jQuery('#providerplan').append(option);
1540
					}
1541
				});
1542
			}
1543
		});
1544
		jQuery('#trproviderplan').css("display","table-row");
1545
	}
1546

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

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

    
1988
									<tr style='display:none' id="show_adv_dhcp_protocol_timing">
1989
										<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>
1990
										<td width="48%" class="vtable">
1991
											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, '');" />
1992
											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, '');" />
1993
											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, '');" />
1994

    
1995
											&nbsp; &nbsp; &nbsp; &nbsp; 
1996
											Presets: &nbsp;
1997
											<input name="adv_dhcp_pt_values" type="radio" value="DHCP"	id="customdhcpptdhcpdefaults"	onclick="customdhcpptsetvalues(this, iform);" />FreeBSD Default &nbsp; 
1998
											<input name="adv_dhcp_pt_values" type="radio" value="Clear"	id="customdhcpptclear"		onclick="customdhcpptsetvalues(this, iform);" />Clear
1999

    
2000
											<br />
2001
											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, '');" />
2002
											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, '');" />
2003
											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, '');" />
2004

    
2005
											&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
2006
											<input name="adv_dhcp_pt_values" type="radio" value="pfSense"	id="customdhcpptpfsensedefaults"	onclick="customdhcpptsetvalues(this, iform);" />pfSense Default &nbsp; 
2007
											<input name="adv_dhcp_pt_values" type="radio" value="SavedCfg" checked="checked"	id="customdhcpptsavedcfg"		onclick="customdhcpptsetvalues(this, iform);" />Saved Cfg 
2008

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

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

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

    
2030
												function customdhcpptsetvaluesnow(T, FORM, timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
2031
													FORM.adv_dhcp_pt_timeout.value = timeout;
2032
													FORM.adv_dhcp_pt_retry.value = retry;
2033
													FORM.adv_dhcp_pt_select_timeout.value = selecttimeout;
2034
													FORM.adv_dhcp_pt_reboot.value = reboot;
2035
													FORM.adv_dhcp_pt_backoff_cutoff.value = backoffcutoff;
2036
													FORM.adv_dhcp_pt_initial_interval.value = initialinterval;
2037

    
2038
													FORM.adv_dhcp_pt_values.value = T.value;
2039
												}
2040

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

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

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

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

    
2096
 									<tr>
2097
 										<td colspan="2" valign="top" height="16"></td>
2098
 									</tr>
2099

    
2100
								</table>
2101

    
2102
									<script type="text/javascript">
2103
									//<![CDATA[
2104
										function show_adv_dhcp_config(T) {
2105

    
2106
											if (T.checked) T.value = "Selected";
2107
											else T.value = "";
2108

    
2109
											     if (document.iform.adv_dhcp_config_file_override.checked)	show_hide_adv_dhcp('none', 'none', '');
2110
											else if (document.iform.adv_dhcp_config_advanced.checked)	show_hide_adv_dhcp('', '', 'none');
2111
											else 									show_hide_adv_dhcp('', 'none', 'none');
2112
										}
2113

    
2114
										function show_hide_adv_dhcp(basic, advanced, override) {
2115

    
2116
											document.getElementById("show_basic_dhcphostname").style.display = basic;
2117
											document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2118
											document.getElementById("show_basic_dhcprejectlease").style.display = basic;
2119

    
2120
											document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2121
											document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2122
											document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2123

    
2124
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2125
										}
2126

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

    
2131
										<!-- Set the adv_dhcp_config_file_override checkbox from saved config -->
2132
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override']);?>" == "Selected") document.iform.adv_dhcp_config_file_override.checked = true;
2133
										show_adv_dhcp_config(document.iform.adv_dhcp_config_file_override);
2134
									//]]>
2135
									</script>
2136

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

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

    
2238
									<tr style='display:none' id="show_adv_dhcp6_id_assoc_statement">
2239
										<td width="22%" valign="top" class="vncell">
2240
											<?=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>"); ?>
2241
										</td>
2242
										<td width="78%" class="vtable">
2243

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

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

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

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

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

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

    
2341
 									<tr>
2342
 										<td colspan="2" valign="top" height="16"></td>
2343
 									</tr>
2344

    
2345
								</table>
2346

    
2347
									<script type="text/javascript">
2348
									//<![CDATA[
2349
										function show_adv_dhcp6_config(T) {
2350

    
2351
											if (T.checked) T.value = "Selected";
2352
											else T.value = "";
2353

    
2354
											     if (document.iform.adv_dhcp6_config_file_override.checked)	show_hide_adv_dhcp6('none', 'none', ''    );
2355
											else if (document.iform.adv_dhcp6_config_advanced.checked)		show_hide_adv_dhcp6('none', '',     'none');
2356
											else 															show_hide_adv_dhcp6('',     'none', 'none');
2357
										}
2358

    
2359
										function show_hide_adv_dhcp6(basic, advanced, override) {
2360

    
2361
											document.getElementById("basicdhcp6_use_pppoeinterface").style.display = basic;
2362
											document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2363
											document.getElementById("basicdhcp6_show_dhcp6_prefix_send_hint").style.display = basic;
2364
											document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
2365

    
2366
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2367
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2368

    
2369
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2370
											if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked)  {
2371
												document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2372
											}
2373

    
2374
											document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = 'none';
2375
											document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = 'none';
2376
											if (document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked)  {
2377
												document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = advanced;
2378
												document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = advanced;
2379
											}
2380

    
2381
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2382
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2383

    
2384
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2385
										}
2386

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

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

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

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

    
2403
										<!-- Set the adv_dhcp6_id_assoc_statement_prefix_enable checkbox from saved config -->
2404
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked = true;
2405
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_prefix_enable);
2406
									//]]>
2407
									</script>
2408

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

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

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

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