Project

General

Profile

Download (126 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces.php
5
	Copyright (C) 2004-2008 Scott Ullrich
6
	Copyright (C) 2006 Daniel S. Haischt.
7
	Copyright (C) 2008-2010 Ermal Lu?i
8
	All rights reserved.
9

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

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

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

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

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

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

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

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

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

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

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

    
74
if (!is_array($config['ppps']['ppp']))
75
	$config['ppps']['ppp'] = array();
76

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

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

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

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

    
95

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

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

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

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

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

    
181
if (is_array($config['aliases']['alias'])) {
182
	foreach($config['aliases']['alias'] as $alias) {
183
		if($alias['name'] == $wancfg['descr']) {
184
			$input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."),$wancfg['descr']);
185
		}
186
	}
187
}
188

    
189
switch($wancfg['ipaddr']) {
190
	case "dhcp":
191
		$pconfig['type'] = "dhcp";
192
		break;
193
	case "pppoe":
194
	case "pptp":
195
	case "l2tp":
196
	case "ppp":
197
		$pconfig['type'] = $wancfg['ipaddr'];
198
		break;
199
	default:
200
		if(is_ipaddrv4($wancfg['ipaddr'])) {
201
			$pconfig['type'] = "staticv4";
202
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
203
			$pconfig['subnet'] = $wancfg['subnet'];
204
			$pconfig['gateway'] = $wancfg['gateway'];
205
		} else
206
			$pconfig['type'] = "none";
207
		break;
208
}
209

    
210
switch($wancfg['ipaddrv6']) {
211
	case "slaac":
212
		$pconfig['type6'] = "slaac";
213
		break;
214
	case "dhcp6":
215
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
216
		if(!isset($wancfg['dhcp6-ia-pd-len']))
217
			$wancfg['dhcp6-ia-pd-len'] = "none";
218
		$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
219
		$pconfig['type6'] = "dhcp6";
220
		break;
221
	case "6to4":
222
		$pconfig['type6'] = "6to4";
223
		break;
224
	case "track6":
225
		$pconfig['type6'] = "track6";
226
		$pconfig['track6-interface'] = $wancfg['track6-interface'];
227
		$pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
228
		if ($wancfg['track6-prefix-id'] == "" || $wancfg['track6-prefix-id'] == "none") {
229
			$pconfig['track6-prefix-id--hex'] = "";
230
		} else {
231
			$pconfig['track6-prefix-id--hex'] = sprintf("%x", $wancfg['track6-prefix-id']);
232
		}
233
		break;
234
	case "6rd":
235
		$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
236
		if($wancfg['prefix-6rd-v4plen'] == "")
237
			$wancfg['prefix-6rd-v4plen'] = "0";
238
		$pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen'];
239
		$pconfig['type6'] = "6rd";
240
		$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
241
		break;
242
	default:
243
		if(is_ipaddrv6($wancfg['ipaddrv6'])) {
244
			$pconfig['type6'] = "staticv6";
245
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
246
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
247
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
248
		} else
249
			$pconfig['type6'] = "none";
250
		break;
251
}
252

    
253
// print_r($pconfig);
254

    
255
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
256
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
257
$pconfig['spoofmac'] = $wancfg['spoofmac'];
258
$pconfig['mtu'] = $wancfg['mtu'];
259
$pconfig['mss'] = $wancfg['mss'];
260

    
261
/* Wireless interface? */
262
if (isset($wancfg['wireless'])) {
263
	/* Sync first to be sure it displays the actual settings that will be used */
264
	interface_sync_wireless_clones($wancfg, false);
265
	/* Get wireless modes */
266
	$wlanif = get_real_interface($if);
267
	if (!does_interface_exist($wlanif))
268
		interface_wireless_clone($wlanif, $wancfg);
269
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
270
	preg_match("/^(.*?)([0-9]*)$/", $wlanbaseif, $wlanbaseif_split);
271
	$wl_modes = get_wireless_modes($if);
272
	$wl_chaninfo = get_wireless_channel_info($if);
273
	$wl_sysctl_prefix = 'dev.' . $wlanbaseif_split[1] . '.' . $wlanbaseif_split[2];
274
	$wl_sysctl = get_sysctl(array("{$wl_sysctl_prefix}.diversity", "{$wl_sysctl_prefix}.txantenna", "{$wl_sysctl_prefix}.rxantenna",
275
	                              "{$wl_sysctl_prefix}.slottime", "{$wl_sysctl_prefix}.acktimeout", "{$wl_sysctl_prefix}.ctstimeout"));
276
	$wl_regdomain_xml_attr = array();
277
	$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
278
	$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
279
	$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
280
	$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
281
	$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
282
	$pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]);
283
	$pconfig['standard'] = $wancfg['wireless']['standard'];
284
	$pconfig['mode'] = $wancfg['wireless']['mode'];
285
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
286
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
287
	$pconfig['channel'] = $wancfg['wireless']['channel'];
288
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
289
	$pconfig['diversity'] = $wancfg['wireless']['diversity'];
290
	$pconfig['txantenna'] = $wancfg['wireless']['txantenna'];
291
	$pconfig['rxantenna'] = $wancfg['wireless']['rxantenna'];
292
	$pconfig['distance'] = $wancfg['wireless']['distance'];
293
	$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
294
	$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
295
	$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
296
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
297
	if (isset($wancfg['wireless']['puren']['enable']))
298
		$pconfig['puremode'] = '11n';
299
	else if (isset($wancfg['wireless']['pureg']['enable']))
300
		$pconfig['puremode'] = '11g';
301
	else
302
		$pconfig['puremode'] = 'any';
303
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
304
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
305
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
306
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
307
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
308
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
309
	$pconfig['auth_server_addr2'] = $wancfg['wireless']['auth_server_addr2'];
310
	$pconfig['auth_server_port2'] = $wancfg['wireless']['auth_server_port2'];
311
	$pconfig['auth_server_shared_secret2'] = $wancfg['wireless']['auth_server_shared_secret2'];
312
	if (is_array($wancfg['wireless']['wpa'])) {
313
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
314
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
315
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
316
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
317
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
318
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
319
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
320
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
321
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
322
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
323
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
324
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
325
		$pconfig['rsn_preauth'] = isset($wancfg['wireless']['wpa']['rsn_preauth']);
326
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
327
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
328
	}
329
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
330
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
331
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
332
		$i = 1;
333
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
334
			$pconfig['key' . $i] = $wepkey['value'];
335
			if (isset($wepkey['txkey']))
336
				$pconfig['txkey'] = $i;
337
			$i++;
338
		}
339
		if (!isset($wepkey['txkey']))
340
			$pconfig['txkey'] = 1;
341
	}
342
}
343

    
344
$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']);
345
$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
346

    
347
if ($_POST['apply']) {
348
	unset($input_errors);
349
	if (!is_subsystem_dirty('interfaces'))
350
		$intput_errors[] = gettext("You have already applied your settings!");
351
	else {
352
		unlink_if_exists("{$g['tmp_path']}/config.cache");
353
		clear_subsystem_dirty('interfaces');
354

    
355
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
356
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
357
			foreach ($toapplylist as $ifapply => $ifcfgo) {
358
				if (isset($config['interfaces'][$ifapply]['enable'])) {
359
					interface_bring_down($ifapply, false, $ifcfgo);
360
					interface_configure($ifapply, true);
361
				} else
362
					interface_bring_down($ifapply, true, $ifcfgo);
363
			}
364
		}
365
		/* restart snmp so that it binds to correct address */
366
		services_snmpd_configure();
367

    
368
		/* sync filter configuration */
369
		setup_gateways_monitor();
370

    
371
		clear_subsystem_dirty('interfaces');
372

    
373
		filter_configure();
374

    
375
		enable_rrd_graphing();
376
	}
377
	@unlink("{$g['tmp_path']}/.interfaces.apply");
378
	header("Location: interfaces.php?if={$if}");
379
	exit;
380
} else if ($_POST && $_POST['enable'] != "yes") {
381
	unset($wancfg['enable']);
382
	if (isset($wancfg['wireless']))
383
		interface_sync_wireless_clones($wancfg, false);
384
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
385
	mark_subsystem_dirty('interfaces');
386
	if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
387
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
388
	} else {
389
		$toapplylist = array();
390
	}
391
	$toapplylist[$if] = $wancfg;
392
	/* we need to be able remove IP aliases for IPv6 */
393
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
394
	header("Location: interfaces.php?if={$if}");
395
	exit;
396
} else if ($_POST) {
397

    
398
	unset($input_errors);
399
	$pconfig = $_POST;
400
	if ($pconfig['track6-prefix-id--hex'] === "") {
401
		$pconfig['track6-prefix-id'] = "none";
402
	} else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
403
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
404
	} else {
405
		$pconfig['track6-prefix-id'] = "none";
406
	}
407
	conf_mount_rw();
408

    
409
	/* filter out spaces from descriptions  */
410
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
411

    
412
	/* okay first of all, cause we are just hiding the PPPoE HTML
413
	 * fields releated to PPPoE resets, we are going to unset $_POST
414
	 * vars, if the reset feature should not be used. Otherwise the
415
	 * data validation procedure below, may trigger a false error
416
	 * message.
417
	 */
418
	if (empty($_POST['pppoe-reset-type'])) {
419
		unset($_POST['pppoe_pr_type']);
420
		unset($_POST['pppoe_resethour']);
421
		unset($_POST['pppoe_resetminute']);
422
		unset($_POST['pppoe_resetdate']);
423
		unset($_POST['pppoe_pr_preset_val']);
424
	}
425
	/* description unique? */
426
	foreach ($ifdescrs as $ifent => $ifdescr) {
427
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
428
			$input_errors[] = gettext("An interface with the specified description already exists.");
429
			break;
430
		}
431
	}
432
	/* input validation */
433
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^staticv4/", $_POST['type'])))
434
		$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.");
435
	if (isset($config['dhcpdv6']) && isset($config['dhcpdv6'][$if]['enable']) && (! preg_match("/^staticv6/", $_POST['type6'])))
436
		$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.");
437

    
438
	switch(strtolower($_POST['type'])) {
439
		case "staticv4":
440
			$reqdfields = explode(" ", "ipaddr subnet gateway");
441
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
442
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
443
			break;
444
		case "none":
445
			if(is_array($config['virtualip']['vip'])) {
446
				foreach ($config['virtualip']['vip'] as $vip) {
447
					if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if)
448
						$input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration.");
449
				}
450
			}
451
		case "dhcp":
452
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp")))
453
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
454
			break;
455
		case "ppp":
456
			$reqdfields = explode(" ", "port phone");
457
			$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
458
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
459
			break;
460
		case "pppoe":
461
			if ($_POST['pppoe_dialondemand']) {
462
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
463
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
464
			} else {
465
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
466
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
467
			}
468
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
469
			break;
470
		case "pptp":
471
			if ($_POST['pptp_dialondemand']) {
472
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
473
				$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"));
474
			} else {
475
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
476
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
477
			}
478
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
479
			break;
480
		case "l2tp":
481
			if ($_POST['pptp_dialondemand']) {
482
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
483
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
484
			} else {
485
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
486
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"));
487
			}
488
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
489
			break;
490
	}
491
	switch(strtolower($_POST['type6'])) {
492
		case "staticv6":
493
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
494
			$reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
495
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
496
			break;
497
		case "none":
498
			if(is_array($config['virtualip']['vip'])) {
499
				foreach ($config['virtualip']['vip'] as $vip) {
500
					if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if)
501
						$input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration.");
502
				}
503
			}
504
		case "dhcp6":
505
			if (in_array($wancfg['ipaddrv6'], array()))
506
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
507
			break;
508
		case "6rd":
509
			foreach ($ifdescrs as $ifent => $ifdescr) {
510
				if ($if != $ifent && (($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6']) || ($config[interfaces][$ifent]['ipaddrv6'] == "6to4")) ) {
511
					$input_errors[] = sprintf(gettext("You can only have one interface configured as %s or 6to4."),$_POST['type6']);
512
					break;
513
				}
514
			}
515
			if (in_array($wancfg['ipaddrv6'], array()))
516
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
517
			break;
518
		case "6to4":
519
			foreach ($ifdescrs as $ifent => $ifdescr) {
520
				if ($if != $ifent && (($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6']) || ($config[interfaces][$ifent]['ipaddrv6'] == "6rd")) ) {
521
					$input_errors[] = sprintf(gettext("You can only have one interface configured as %s or 6rd."),$_POST['type6']);
522
					break;
523
				}
524
			}
525
			if (in_array($wancfg['ipaddrv6'], array()))
526
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
527
			break;
528
		case "track6":
529
			/* needs to check if $track6-prefix-id is used on another interface */
530
			if (in_array($wancfg['ipaddrv6'], array()))
531
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
532

    
533
			if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
534
				$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
535
			} else {
536
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
537
				if ($track6_prefix_id < 0 || $track6_prefix_id >= $ipv6_num_prefix_ids) {
538
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.");
539
				}
540
			}
541
			break;
542
	}
543

    
544
	
545
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
546
	$staticroutes = get_staticroutes(true);
547
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
548
	if ($_POST['ipaddr']) {
549
		if (!is_ipaddrv4($_POST['ipaddr']))
550
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
551
		else {
552
			if (is_ipaddr_configured($_POST['ipaddr'], $if, true))
553
				$input_errors[] = gettext("This IPv4 address is being used by another interface or VIP.");
554

    
555
			foreach ($staticroutes as $route_subnet) {
556
				if (ip_in_subnet($_POST['ipaddr'], $route_subnet)) {
557
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
558
					break;
559
				}
560
			}
561
		}
562
	}
563
	if ($_POST['ipaddrv6']) {
564
		if (!is_ipaddrv6($_POST['ipaddrv6']))
565
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
566
		else {
567
			if (is_ipaddr_configured($_POST['ipaddrv6'], $if, true))
568
				$input_errors[] = gettext("This IPv6 address is being used by another interface or VIP.");
569

    
570
			foreach ($staticroutes as $route_subnet) {
571
				if (ip_in_subnet($_POST['ipaddrv6'], $route_subnet)) {
572
					$input_errors[] = gettext("This IPv6 address conflicts with a Static Route.");
573
					break;
574
				}
575
			}
576
		}
577
	}
578
	if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
579
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
580
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6'])))
581
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
582
	if (($_POST['alias-address'] && !is_ipaddrv4($_POST['alias-address'])))
583
		$input_errors[] = gettext("A valid alias IP address must be specified.");
584
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
585
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
586
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
587
		$match = false;
588
		foreach($a_gateways as $gateway) {
589
			if(in_array($_POST['gateway'], $gateway)) {
590
				$match = true;
591
			}
592
		}
593
		foreach($a_gateways as $gateway) {
594
			if(in_array($_POST['gatewayv6'], $gateway)) {
595
				$match = true;
596
			}
597
		}
598
		if(!$match) {
599
			$input_errors[] = gettext("A valid gateway must be specified.");
600
		}
601
	}
602
	if (($_POST['provider'] && !is_domain($_POST['provider'])))
603
		$input_errors[] = gettext("The service name contains invalid characters.");
604
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
605
		$input_errors[] = gettext("The idle timeout value must be an integer.");
606
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
607
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23)
608
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
609
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
610
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59)
611
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
612
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate'])))
613
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
614
	if (($_POST['pptp_local'] && !is_ipaddrv4($_POST['pptp_local'])))
615
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
616
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet'])))
617
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
618
	if (($_POST['pptp_remote'] && !is_ipaddrv4($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface])))
619
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
620
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout']))
621
		$input_errors[] = gettext("The idle timeout value must be an integer.");
622
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])))
623
		$input_errors[] = gettext("A valid MAC address must be specified.");
624
	if ($_POST['mtu'] && ($_POST['mtu'] < 576))
625
		$input_errors[] = gettext("The MTU must be greater than 576 bytes.");
626
	if ($_POST['mss'] && ($_POST['mss'] < 576))
627
		$input_errors[] = gettext("The MSS must be greater than 576 bytes.");
628
	/* Wireless interface? */
629
	if (isset($wancfg['wireless'])) {
630
		$reqdfields = array("mode");
631
		$reqdfieldsn = array(gettext("Mode"));
632
		if ($_POST['mode'] == 'hostap') {
633
			$reqdfields[] = "ssid";
634
			$reqdfieldsn[] = gettext("SSID");
635
		}
636
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
637
		check_wireless_mode();
638
		/* loop through keys and enforce size */
639
		for ($i = 1; $i <= 4; $i++) {
640
			if ($_POST['key' . $i]) {
641
				/* 64 bit */
642
				if (strlen($_POST['key' . $i]) == 5)
643
					continue;
644
				if (strlen($_POST['key' . $i]) == 10) {
645
					/* hex key */
646
					if (stristr($_POST['key' . $i], "0x") == false) {
647
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
648
					}
649
					continue;
650
				}
651
				if (strlen($_POST['key' . $i]) == 12) {
652
					/* hex key */
653
					if(stristr($_POST['key' . $i], "0x") == false) {
654
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
655
					}
656
					continue;
657
				}
658
				/* 128 bit */
659
				if (strlen($_POST['key' . $i]) == 13)
660
					continue;
661
				if (strlen($_POST['key' . $i]) == 26) {
662
					/* hex key */
663
					if (stristr($_POST['key' . $i], "0x") == false)
664
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
665
					continue;
666
				}
667
				if(strlen($_POST['key' . $i]) == 28)
668
					continue;
669
				$input_errors[] =  gettext("Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.");
670
				break;
671
			}
672
		}
673

    
674
		if ($_POST['passphrase']) {
675
                	$passlen = strlen($_POST['passphrase']);
676
                	if ($passlen < 8 || $passlen > 64)
677
                        	$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
678
		}
679
	}
680
	if (!$input_errors) {
681
		if ($wancfg['ipaddr'] != $_POST['type']) {
682
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
683
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
684
				unset($a_ppps[$pppid]);
685
			} else if ($wancfg['ipaddrv6'] == "dhcp6") {
686
				$pid = find_dhcp6c_process($wancfg['if']);
687
				if($pid)
688
					posix_kill($pid, SIGTERM);
689
			} else if ($wancfg['ipaddr'] == "dhcp") {
690
				$pid = find_dhclient_process($wancfg['if']);
691
				if($pid)
692
					posix_kill($pid, SIGTERM);
693
			}
694
				
695
		}
696
		$ppp = array();
697
		if ($wancfg['ipaddr'] != "ppp")
698
			unset($wancfg['ipaddr']);
699
		if ($wancfg['ipaddrv6'] != "ppp")
700
			unset($wancfg['ipaddrv6']);
701
		unset($wancfg['subnet']);
702
		unset($wancfg['gateway']);
703
		unset($wancfg['subnetv6']);
704
		unset($wancfg['gatewayv6']);
705
		unset($wancfg['dhcphostname']);
706
		unset($wancfg['dhcp6-duid']);
707
		unset($wancfg['dhcp6-ia-pd-len']);
708
		unset($wancfg['track6-interface']);
709
		unset($wancfg['track6-prefix-id']);		
710
		unset($wancfg['prefix-6rd']);
711
		unset($wancfg['prefix-6rd-v4plen']);
712
		unset($wancfg['gateway-6rd']);
713
		unset($wancfg['pppoe_password']);
714
		unset($wancfg['pptp_username']);
715
		unset($wancfg['pptp_password']);
716
		unset($wancfg['provider']);
717
		unset($wancfg['ondemand']);
718
		unset($wancfg['timeout']);
719
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
720
			unset($wancfg['pppoe']['pppoe-reset-type']);
721
		unset($wancfg['local']);
722
		
723
		unset($wancfg['remote']);
724
		unset($a_ppps[$pppid]['apn']);
725
		unset($a_ppps[$pppid]['phone']);
726
		unset($a_ppps[$pppid]['localip']);
727
		unset($a_ppps[$pppid]['subnet']);
728
		unset($a_ppps[$pppid]['gateway']);
729
		unset($a_ppps[$pppid]['pppoe-reset-type']);
730
		unset($a_ppps[$pppid]['provider']);
731

    
732
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
733
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
734

    
735
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
736
		switch($_POST['type']) {
737
			case "staticv4":
738
				$wancfg['ipaddr'] = $_POST['ipaddr'];
739
				$wancfg['subnet'] = $_POST['subnet'];
740
				if ($_POST['gateway'] != "none") {
741
					$wancfg['gateway'] = $_POST['gateway'];
742
				}
743
				break;
744
			case "dhcp":
745
				$wancfg['ipaddr'] = "dhcp";
746
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
747
				$wancfg['alias-address'] = $_POST['alias-address'];
748
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
749
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
750
				if($gateway_item) {
751
					$a_gateways[] = $gateway_item;
752
				}
753
				break;
754
			case "ppp":
755
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
756
				$a_ppps[$pppid]['type'] = $_POST['type'];
757
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
758
				$a_ppps[$pppid]['ports'] = $_POST['port'];
759
				$a_ppps[$pppid]['username'] = $_POST['username'];
760
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
761
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
762
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
763
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
764
				$wancfg['ipaddr'] = $_POST['type'];
765
				unset($a_ppps[$pppid]['ondemand']);
766
				unset($a_ppps[$pppid]['idletimeout']);
767
				break;
768

    
769
			case "pppoe":
770
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
771
				$a_ppps[$pppid]['type'] = $_POST['type'];
772
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
773
				if (isset($_POST['ppp_port']))
774
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
775
				else
776
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
777
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
778
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
779
				if (!empty($_POST['provider']))
780
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
781
				else
782
					$a_ppps[$pppid]['provider'] = true;
783
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
784
				if (!empty($_POST['pppoe_idletimeout']))
785
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
786
				else
787
					unset($a_ppps[$pppid]['idletimeout']);
788

    
789
				if (!empty($_POST['pppoe-reset-type']))
790
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
791
				else
792
					unset($a_ppps[$pppid]['pppoe-reset-type']);
793
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
794
				$wancfg['ipaddr'] = $_POST['type'];
795
				if($gateway_item) {
796
					$a_gateways[] = $gateway_item;
797
				}
798

    
799
				break;
800
			case "pptp":
801
			case "l2tp":
802
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
803
				$a_ppps[$pppid]['type'] = $_POST['type'];
804
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
805
				if (isset($_POST['ppp_port']))
806
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
807
				else
808
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
809
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
810
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
811
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
812
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
813
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
814
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
815
				if (!empty($_POST['pptp_idletimeout']))
816
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
817
				else
818
					unset($a_ppps[$pppid]['idletimeout']);
819
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
820
				$wancfg['ipaddr'] = $_POST['type'];
821
				if($gateway_item) {
822
					$a_gateways[] = $gateway_item;
823
				}
824
				break;
825
			case "none":
826
				break;
827
		}
828
		switch($_POST['type6']) {
829
			case "staticv6":
830
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
831
				$wancfg['subnetv6'] = $_POST['subnetv6'];
832
				if ($_POST['gatewayv6'] != "none") {
833
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
834
				}
835
				break;
836
			case "slaac":
837
				$wancfg['ipaddrv6'] = "slaac";
838
				break;
839
			case "dhcp6":
840
				$wancfg['ipaddrv6'] = "dhcp6";
841
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
842
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
843
				if($gateway_item) {
844
					$a_gateways[] = $gateway_item;
845
				}
846
				break;
847
			case "6rd":
848
				$wancfg['ipaddrv6'] = "6rd";
849
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
850
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
851
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
852
				if($gateway_item) {
853
					$a_gateways[] = $gateway_item;
854
				}
855
				break;
856
			case "6to4":
857
				$wancfg['ipaddrv6'] = "6to4";
858
				break;
859
			case "track6":
860
				$wancfg['ipaddrv6'] = "track6";
861
				$wancfg['track6-interface'] = $_POST['track6-interface'];
862
				if ($_POST['track6-prefix-id--hex'] === "") {
863
					$wancfg['track6-prefix-id'] = "none";
864
				} else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
865
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
866
				} else {
867
					$wancfg['track6-prefix-id'] = "none";
868
				}
869
				break;
870
			case "none":
871
				break;
872
		}
873
		handle_pppoe_reset($_POST);
874

    
875
		if($_POST['blockpriv'] == "yes") {
876
			$wancfg['blockpriv'] = true;
877
		} else {
878
			unset($wancfg['blockpriv']);
879
		}
880
		if($_POST['blockbogons'] == "yes") {
881
			$wancfg['blockbogons'] = true;
882
		} else {
883
			unset($wancfg['blockbogons']);
884
		}
885
		$wancfg['spoofmac'] = $_POST['spoofmac'];
886
		if (empty($_POST['mtu'])) {
887
			unset($wancfg['mtu']);
888
		} else {
889
			$wancfg['mtu'] = $_POST['mtu'];
890
		}
891
		if (empty($_POST['mss'])) {
892
			unset($wancfg['mss']);
893
		} else {
894
			$wancfg['mss'] = $_POST['mss'];
895
		}
896
		if (empty($_POST['mediaopt'])) {
897
			unset($wancfg['media']);
898
			unset($wancfg['mediaopt']);
899
		} else {
900
			$mediaopts = explode(' ', $_POST['mediaopt']);	
901
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
902
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
903
			else { unset($wancfg['mediaopt']); }
904
		}
905
		if (isset($wancfg['wireless'])) {
906
			handle_wireless_post();
907
		}
908

    
909
		conf_mount_ro();
910
		write_config();
911

    
912
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
913
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
914
		} else {
915
			$toapplylist = array();
916
		}
917
		$toapplylist[$if] = $old_wancfg;
918
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
919

    
920
		mark_subsystem_dirty('interfaces');
921

    
922
		/* regenerate cron settings/crontab file */
923
		configure_cron();
924

    
925
		header("Location: interfaces.php?if={$if}");
926
		exit;
927
	}
928

    
929
} // end if($_POST)
930

    
931
function handle_wireless_post() {
932
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
933
	if (!is_array($wancfg['wireless']))
934
		$wancfg['wireless'] = array();
935
	$wancfg['wireless']['standard'] = $_POST['standard'];
936
	$wancfg['wireless']['mode'] = $_POST['mode'];
937
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
938
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
939
	$wancfg['wireless']['channel'] = $_POST['channel'];
940
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
941
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
942
	$wancfg['wireless']['distance'] = $_POST['distance'];
943
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
944
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
945
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
946
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
947
		foreach($wl_countries_attr as $wl_country) {
948
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
949
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
950
				break;
951
			}
952
		}
953
	}
954
	if (!is_array($wancfg['wireless']['wpa']))
955
		$wancfg['wireless']['wpa'] = array();
956
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
957
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
958
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
959
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
960
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
961
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
962
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
963
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
964
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
965
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
966
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
967
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
968
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
969
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
970
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
971
	
972
	if ($_POST['persistcommonwireless'] == "yes") {
973
		if (!is_array($config['wireless']))
974
			$config['wireless'] = array();
975
		if (!is_array($config['wireless']['interfaces']))
976
			$config['wireless']['interfaces'] = array();
977
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
978
			$config['wireless']['interfaces'][$wlanbaseif] = array();
979
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
980
		unset($config['wireless']['interfaces'][$wlanbaseif]);
981
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
982
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
983
	else if (isset($wancfg['wireless']['diversity']))
984
		unset($wancfg['wireless']['diversity']);
985
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
986
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
987
	else if (isset($wancfg['wireless']['txantenna']))
988
		unset($wancfg['wireless']['txantenna']);
989
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
990
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
991
	else if (isset($wancfg['wireless']['rxantenna']))
992
		unset($wancfg['wireless']['rxantenna']);
993
	if ($_POST['hidessid_enable'] == "yes")
994
		$wancfg['wireless']['hidessid']['enable'] = true;
995
	else if (isset($wancfg['wireless']['hidessid']['enable']))
996
		unset($wancfg['wireless']['hidessid']['enable']);
997
	if ($_POST['mac_acl_enable'] == "yes")
998
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
999
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
1000
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
1001
	if ($_POST['rsn_preauth'] == "yes")
1002
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
1003
	else
1004
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
1005
	if ($_POST['ieee8021x'] == "yes")
1006
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
1007
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
1008
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
1009
	if ($_POST['wpa_strict_rekey'] == "yes")
1010
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
1011
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
1012
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
1013
	if ($_POST['debug_mode'] == "yes")
1014
		$wancfg['wireless']['wpa']['debug_mode'] = true;
1015
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
1016
		sunset($wancfg['wireless']['wpa']['debug_mode']);
1017
	if ($_POST['wpa_enable'] == "yes")
1018
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
1019
	else if (isset($wancfg['wireless']['wpa']['enable']))
1020
		unset($wancfg['wireless']['wpa']['enable']);
1021
	if ($_POST['wep_enable'] == "yes") {
1022
		if (!is_array($wancfg['wireless']['wep']))
1023
			$wancfg['wireless']['wep'] = array();
1024
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
1025
	} else if (isset($wancfg['wireless']['wep']))
1026
		unset($wancfg['wireless']['wep']);
1027
	if ($_POST['wme_enable'] == "yes") {
1028
		if (!is_array($wancfg['wireless']['wme']))
1029
			$wancfg['wireless']['wme'] = array();
1030
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1031
	} else if (isset($wancfg['wireless']['wme']['enable']))
1032
		unset($wancfg['wireless']['wme']['enable']);
1033
	if ($_POST['puremode'] == "11g") {
1034
		if (!is_array($wancfg['wireless']['pureg']))
1035
			$wancfg['wireless']['pureg'] = array();
1036
		$wancfg['wireless']['pureg']['enable'] = true;
1037
	} else if ($_POST['puremode'] == "11n") {
1038
		if (!is_array($wancfg['wireless']['puren']))
1039
			$wancfg['wireless']['puren'] = array();
1040
		$wancfg['wireless']['puren']['enable'] = true;
1041
	} else {
1042
		if (isset($wancfg['wireless']['pureg']))
1043
			unset($wancfg['wireless']['pureg']);
1044
		if (isset($wancfg['wireless']['puren']))
1045
			unset($wancfg['wireless']['puren']);
1046
	}
1047
	if ($_POST['apbridge_enable'] == "yes") {
1048
		if (!is_array($wancfg['wireless']['apbridge']))
1049
			$wancfg['wireless']['apbridge'] = array();
1050
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1051
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
1052
		unset($wancfg['wireless']['apbridge']['enable']);
1053
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1054
		if (!is_array($wancfg['wireless']['turbo']))
1055
			$wancfg['wireless']['turbo'] = array();
1056
		$wancfg['wireless']['turbo']['enable'] = true;
1057
	} else if (isset($wancfg['wireless']['turbo']['enable']))
1058
		unset($wancfg['wireless']['turbo']['enable']);
1059
	$wancfg['wireless']['wep']['key'] = array();
1060
	for ($i = 1; $i <= 4; $i++) {
1061
		if ($_POST['key' . $i]) {
1062
			$newkey = array();
1063
			$newkey['value'] = $_POST['key' . $i];
1064
			if ($_POST['txkey'] == $i)
1065
				$newkey['txkey'] = true;
1066
			$wancfg['wireless']['wep']['key'][] = $newkey;
1067
		}
1068
	}
1069
	interface_sync_wireless_clones($wancfg, true);
1070
}
1071

    
1072
function check_wireless_mode() {
1073
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1074

    
1075
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1076
		return;
1077

    
1078
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1079
		$clone_count = 1;
1080
	else
1081
		$clone_count = 0;
1082
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1083
		foreach ($config['wireless']['clone'] as $clone) {
1084
			if ($clone['if'] == $wlanbaseif)
1085
				$clone_count++;
1086
		}
1087
	}
1088
	if ($clone_count > 1) {
1089
		$old_wireless_mode = $wancfg['wireless']['mode'];
1090
		$wancfg['wireless']['mode'] = $_POST['mode'];
1091
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1092
			$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']]);
1093
		} else {
1094
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
1095
		}
1096
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1097
	}
1098
}
1099

    
1100
// Find all possible media options for the interface
1101
$mediaopts_list = array();
1102
$intrealname = $config['interfaces'][$if]['if'];
1103
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1104
foreach ($mediaopts as $mediaopt){
1105
	preg_match("/media (.*)/", $mediaopt, $matches);
1106
 	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1107
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1108
 		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1109
	}else{
1110
		// there is only media like "media 1000baseT"
1111
		array_push($mediaopts_list, $matches[1]);
1112
	}
1113
}
1114

    
1115
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1116
$shortcut_section = "interfaces";
1117

    
1118
$closehead = false;
1119
include("head.inc");
1120
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1121
$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"));
1122

    
1123
?>
1124

    
1125
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1126
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1127
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1128
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1129

    
1130
<script type="text/javascript">
1131
	function updateType(t) {
1132
		switch(t) {
1133
			case "none": {
1134
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1135
				break;
1136
			}
1137
			case "staticv4": {
1138
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1139
				break;
1140
			}
1141
			case "dhcp": {
1142
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1143
				break;
1144
			}
1145
			case "ppp": {
1146
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1147
				country_list();
1148
				break;
1149
			}
1150
			case "pppoe": {
1151
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1152
				break;
1153
			}
1154
			case "l2tp":
1155
			case "pptp": {
1156
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1157
				jQuery('#pptp').show();
1158
				break;
1159
			}
1160
		}
1161
		if (t != "l2tp" && t != "pptp")
1162
			jQuery('#'+t).show();
1163
	}
1164
	function updateTypeSix(t) {
1165
		switch(t) {
1166
			case "none": {
1167
				jQuery('#staticv6, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1168
				break;
1169
			}
1170
			case "staticv6": {
1171
				jQuery('#none, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1172
				break;
1173
			}
1174
			case "slaac": {
1175
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #dhcp6').hide();
1176
				break;
1177
			}
1178
			case "dhcp6": {
1179
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #slaac').hide();
1180
				break;
1181
			}
1182
			case "6rd": {
1183
				jQuery('#none, #dhcp6, #staticv6, #6to4, #track6, #slaac').hide();
1184
				break;
1185
			}
1186
			case "6to4": {
1187
				jQuery('#none, #dhcp6, #staticv6, #6rd, #track6, #slaac').hide();
1188
				break;
1189
			}
1190
			case "track6": {
1191
				jQuery('#none, #dhcp6, #staticv6, #6rd, #6to4, #slaac').hide();
1192
				break;
1193
			}
1194
		}
1195
		if (t != "l2tp" && t != "pptp")
1196
			jQuery('#'+t).show();
1197
	}
1198

    
1199
	function show_allcfg(obj) {
1200
		if (obj.checked)
1201
			jQuery('#allcfg').show();
1202
		else
1203
			jQuery('#allcfg').hide();
1204
	}
1205

    
1206
	function show_reset_settings(reset_type) {
1207
		if (reset_type == 'preset') {
1208
			jQuery('#pppoepresetwrap').show();
1209
			jQuery('#pppoecustomwrap').hide();
1210
		}
1211
		else if (reset_type == 'custom') {
1212
			jQuery('#pppoecustomwrap').show();
1213
			jQuery('#pppoepresetwrap').hide();
1214
		} else {
1215
			jQuery('#pppoecustomwrap').hide();
1216
			jQuery('#pppoepresetwrap').hide();
1217
		}
1218
	}
1219
	function show_mon_config() {
1220
		jQuery("#showmonbox").html('');
1221
		jQuery('#showmon').css('display','block');
1222
	}
1223

    
1224
	function openwindow(url) {
1225
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1226
		if (oWin==null || typeof(oWin)=="undefined")
1227
			return false;
1228
		else
1229
			return true;
1230
	}
1231
	function country_list() {
1232
		jQuery('#country').children().remove();
1233
		jQuery('#provider').children().remove();
1234
		jQuery('#providerplan').children().remove();
1235
		jQuery.ajax("getserviceproviders.php",{
1236
			success: function(response) {
1237
				var responseTextArr = response.split("\n");
1238
				responseTextArr.sort();
1239
				responseTextArr.each( function(value) {
1240
					var option = new Element('option');
1241
					country = value.split(":");
1242
					option.text = country[0];
1243
					option.value = country[1];
1244
					jQuery('#country').append(option);
1245
				});
1246
			}
1247
		});
1248
		jQuery('#trcountry').css('display',"table-row");
1249
	}
1250

    
1251
	function providers_list() {
1252
		jQuery('#provider').children().remove();
1253
		jQuery('#providerplan').children().remove();
1254
		jQuery.ajax("getserviceproviders.php",{
1255
			type: 'post',
1256
			data: {country : jQuery('#country').val()},
1257
			success: function(response) {
1258
				var responseTextArr = response.split("\n");
1259
				responseTextArr.sort();
1260
				responseTextArr.each( function(value) {
1261
					var option = new Element('option');
1262
					option.text = value;
1263
					option.value = value;
1264
					jQuery('#provider').append(option);
1265
				});
1266
			}
1267
		});
1268
		jQuery('#trprovider').css("display","table-row");
1269
		jQuery('#trproviderplan').css("display","none");
1270
	}
1271

    
1272
	function providerplan_list() {
1273
		jQuery('#providerplan').children().remove();
1274
		jQuery('#providerplan').append( new Element('option') );
1275
		jQuery.ajax("getserviceproviders.php",{
1276
			type: 'post',
1277
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1278
			success: function(response) {
1279
				var responseTextArr = response.split("\n");
1280
				responseTextArr.sort();
1281
				responseTextArr.each( function(value) {
1282
					if(value != "") {
1283
						providerplan = value.split(":");
1284

    
1285
						var option = new Element('option');
1286
						option.text = providerplan[0] + " - " + providerplan[1];
1287
						option.value = providerplan[1];
1288
						jQuery('#providerplan').append(option);
1289
					}
1290
				});
1291
			}
1292
		});
1293
		jQuery('#trproviderplan').css("display","table-row");
1294
	}
1295

    
1296
	function prefill_provider() {
1297
		jQuery.ajax("getserviceproviders.php",{
1298
			type: 'post',
1299
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
1300
			success: function(data,textStatus,response) {
1301
				var xmldoc = response.responseXML;
1302
				var provider = xmldoc.getElementsByTagName('connection')[0];
1303
				jQuery('#username').val('');
1304
				jQuery('#password').val('');
1305
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1306
					jQuery('#phone').val('#777');
1307
					jQuery('#apn').val('');
1308
				} else {
1309
					jQuery('#phone').val('*99#');
1310
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1311
				}
1312
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1313
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1314
				jQuery('#username').val(username);
1315
				jQuery('#password').val(password);
1316
			}
1317
		});
1318
	}
1319

    
1320
</script>
1321
</head>
1322
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1323
	<?php include("fbegin.inc"); ?>
1324
	<form action="interfaces.php" method="post" name="iform" id="iform">
1325
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1326
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1327
		<?php print_info_box_np(sprintf(gettext("The %s configuration has been changed."),$wancfg['descr'])."<p>".gettext("You must apply the changes in order for them to take effect.")."<p>".gettext("Don't forget to adjust the DHCP Server range if needed after applying."));?><br />
1328
		<?php endif; ?>
1329
		<?php if ($savemsg) print_info_box($savemsg); ?>
1330
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
1331
			<tr>
1332
				<td id="mainarea">
1333
					<div class="tabcont">
1334
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1335
						<tr>
1336
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1337
						</tr>
1338
						<tr>
1339
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1340
							<td width="78%" class="vtable">
1341
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked"; ?> onClick="show_allcfg(this);">
1342
							<strong><?=gettext("Enable Interface"); ?></strong>
1343
							</td>
1344
						</tr>
1345
					</table>
1346
					<div style="display:none;" name="allcfg" id="allcfg">
1347
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1348
						<tr>
1349
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1350
							<td width="78%" class="vtable">
1351
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
1352
								<br><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1353
							</td>
1354
						</tr>
1355
						<tr>
1356
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1357
							<td class="vtable">
1358
								<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
1359
								<?php
1360
									foreach ($types4 as $key => $opt) {
1361
										echo "<option onClick=\"updateType('{$key}');\"";
1362
										if ($key == $pconfig['type'])
1363
											echo " selected";
1364
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1365
										echo "</option>";
1366
									}
1367
								?>
1368
								</select>
1369
							</td>
1370
						</tr>
1371
						<tr>
1372
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1373
							<td class="vtable">
1374
								<select name="type6" onChange="updateTypeSix(this.value);" class="formselect" id="type6">
1375
								<?php
1376
									foreach ($types6 as $key => $opt) {
1377
										echo "<option onClick=\"updateTypeSix('{$key}');\"";
1378
										if ($key == $pconfig['type6'])
1379
											echo " selected";
1380
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1381
										echo "</option>";
1382
									}
1383
								?>
1384
								</select>
1385
							</td>
1386
						</tr>
1387
						<tr>
1388
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1389
							<td class="vtable">
1390
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
1391
								<?php
1392
									$ip = getenv('REMOTE_ADDR');
1393
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1394
									$mac = str_replace("\n","",$mac);
1395
									if($mac):
1396
								?>
1397
									<a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1398
								<?php endif; ?>
1399
								<br>
1400
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1401
								"address of this interface"); ?><br>
1402
								<?=gettext("(may be required with some cable connections)"); ?><br>
1403
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1404
								"or leave blank"); ?>
1405
							</td>
1406
						</tr>
1407
						<tr>
1408
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1409
							<td class="vtable">
1410
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
1411
								<br>
1412
								<?=gettext("If you leave this field blank, the adapter's default MTU will " .
1413
								"be used. This is typically 1500 bytes but can vary in some circumstances."); ?>
1414
							</td>
1415
						</tr>
1416
						<tr>
1417
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1418
							<td class="vtable">
1419
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>">
1420
								<br>
1421
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1422
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1423
								"header size) will be in effect."); ?>
1424
							</td>
1425
						</tr>
1426
						<?php 
1427
						if (count($mediaopts_list) > 0){
1428
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1429
						echo "<tr>";
1430
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1431
							echo '<td class="vtable">';
1432
                                			echo '<div id="showadvmediabox"';
1433
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1434
								else echo '>';
1435
								echo '<input type="button" onClick="show_advanced_media()" value="' . gettext("Advanced") . '"></input> - ' . gettext("Show advanced option");
1436
							echo "</div>";
1437
							echo '<div id="showmediaadv" ';
1438
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1439
							else echo '>';
1440
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1441
								print "<option value=\"\">Default (no preference, typically autoselect)</option>";
1442
								print "<option value=\"\">------- Media Supported by this interface -------</option>";
1443
								foreach($mediaopts_list as $mediaopt){
1444
									if ($mediaopt != rtrim($mediaopt_from_config)){
1445
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1446
									} else {
1447
										print "<option value=\"$mediaopt\" selected>" . gettext("$mediaopt") . "</option>";
1448
									}
1449
								}
1450
								echo '</select><br>';
1451
								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.");
1452
						echo '</div>';
1453
							echo '</td>';
1454
						echo '</tr>';
1455
						}
1456
						?>
1457
						<tr>
1458
							<td colspan="2" valign="top" height="16"></td>
1459
						</tr>
1460
						<tr style="display:none;" name="none" id="none">
1461
						</tr>
1462
						<tr style="display:none;" name="staticv4" id="staticv4">
1463
							<td colspan="2" style="padding:0px;">
1464
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1465
									<tr>
1466
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1467
									</tr>
1468
									<tr>
1469
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1470
										<td width="78%" class="vtable">
1471
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
1472
											/
1473
											<select name="subnet" class="formselect" id="subnet">
1474
												<?php
1475
												for ($i = 32; $i > 0; $i--) {
1476
													if($i <> 31) {
1477
														echo "<option value=\"{$i}\" ";
1478
														if ($i == $pconfig['subnet']) echo "selected";
1479
														echo ">" . $i . "</option>";
1480
													}
1481
												}
1482
												?>
1483
											</select>
1484
										</td>
1485
									</tr>
1486
									<tr>
1487
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway"); ?></td>
1488
										<td width="78%" class="vtable">
1489
											<select name="gateway" class="formselect" id="gateway">
1490
												<option value="none" selected><?=gettext("None"); ?></option>
1491
													<?php
1492
													if(count($a_gateways) > 0) {
1493
														foreach ($a_gateways as $gateway) {
1494
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1495
													?>
1496
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
1497
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1498
															</option>
1499
													<?php
1500
															}
1501
														}
1502
													}
1503
													?>
1504
											</select>
1505
											- or  <strong><a OnClick="show_add_gateway();" href="#"><?=gettext("add a new one."); ?></a></strong>
1506
											<br/>
1507
											<div id='addgwbox'>
1508
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add one using the link above"); ?>
1509
											</div>
1510
											<div id='notebox'>
1511
											</div>
1512
											<div id="status">
1513
											</div>
1514
											<div style="display:none" id="addgateway" name="addgateway">
1515
												<p>
1516
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1517
													<tr>
1518
														<td>
1519
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1520
																<tr><td>&nbsp;</td></tr>
1521
																<tr>
1522
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1523
																</tr>
1524
																<tr><td>&nbsp;</td></tr>
1525
																<?php
1526
																if($if == "wan" || $if == "WAN")
1527
																	$checked = " CHECKED";
1528
																?>
1529
																<tr>
1530
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
1531
																</tr>
1532
																<tr>
1533
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td>
1534
																</tr>
1535
																<tr>
1536
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></td><td><input id="gatewayip" name="gatewayip"></td>
1537
																</tr>
1538
																<tr>
1539
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1540
																</tr>
1541
																<tr><td>&nbsp;</td></tr>
1542
																<tr>
1543
																	<td colspan="2">
1544
																		<center>
1545
																			<div id='savebuttondiv'>
1546
																				<input id="gwsave" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave();'>
1547
																				<input id="gwcancel" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway();'>
1548
																			</div>
1549
																		</center>
1550
																	</td>
1551
																</tr>
1552
																<tr><td>&nbsp;</td></tr>
1553
															</table>
1554
														</td>
1555
													</tr>
1556
												</table>
1557
												<p/>
1558
											</div>
1559
										</td>
1560
									</tr>
1561
									<tr>
1562
										<td colspan="2" valign="top" height="16"></td>
1563
									</tr>
1564
								</table>
1565
							</td>
1566
						</tr>
1567
						<tr style="display:none;" name="staticv6" id="staticv6">
1568
							<td colspan="2" style="padding:0px;">
1569
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1570
									<tr>
1571
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1572
									</tr>
1573
									<tr>
1574
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1575
										<td width="78%" class="vtable">
1576
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>">
1577
											/
1578
											<select name="subnetv6" class="formselect" id="subnetv6">
1579
												<?php
1580
												for ($i = 128; $i > 0; $i--) {
1581
													if($i <> 127) {
1582
														echo "<option value=\"{$i}\" ";
1583
														if ($i == $pconfig['subnetv6']) echo "selected";
1584
														echo ">" . $i . "</option>";
1585
													}
1586
												}
1587
												?>
1588
											</select>
1589
										</td>
1590
									</tr>
1591
									<tr>
1592
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway IPv6"); ?></td>
1593
										<td width="78%" class="vtable">
1594
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1595
												<option value="none" selected><?=gettext("None"); ?></option>
1596
													<?php
1597
													if(count($a_gateways) > 0) {
1598
														foreach ($a_gateways as $gateway) {
1599
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1600
													?>
1601
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected"; ?>>
1602
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1603
															</option>
1604
													<?php
1605
															}
1606
														}
1607
													}
1608
													?>
1609
											</select>
1610
											- or <strong><a OnClick="show_add_gateway_v6();" href="#"><?=gettext("add a new one."); ?></a></strong>
1611
											<br/>
1612
											<div id='addgwboxv6'>
1613
											<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above"); ?>
1614
											</div>
1615
											<div id='noteboxv6'>
1616
											</div>
1617
											<div id="statusv6">
1618
											</div>
1619
											<div style="display:none" id="addgatewayv6" name="addgatewayv6">
1620
												<p>
1621
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1622
													<tr>
1623
														<td>
1624
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1625
																<tr><td>&nbsp;</td></tr>
1626
																<tr>
1627
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1628
																</tr>
1629
																<tr><td>&nbsp;</td></tr>
1630
																<?php
1631
																if($if == "wan" || $if == "WAN")
1632
																	$checked = " CHECKED";
1633
																?>
1634
																<tr>
1635
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?>></td>
1636
																</tr>
1637
																<tr>
1638
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>"></td>
1639
																</tr>
1640
																<tr>
1641
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></td><td><input id="gatewayipv6" name="gatewayipv6"></td>
1642
																</tr>
1643
																<tr>
1644
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescrv6" name="gatewaydescrv6"></td>
1645
																</tr>
1646
																<tr><td>&nbsp;</td></tr>
1647
																<tr>
1648
																	<td colspan="2">
1649
																		<center>
1650
																			<div id='savebuttondivv6'>
1651
																				<input id="gwsavev6" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave_v6();'>
1652
																				<input id="gwcancelv6" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway_v6();'>
1653
																			</div>
1654
																		</center>
1655
																	</td>
1656
																</tr>
1657
																<tr><td>&nbsp;</td></tr>
1658
															</table>
1659
														</td>
1660
													</tr>
1661
												</table>
1662
												<p/>
1663
											</div>
1664
										</td>
1665
									</tr>
1666
									<tr>
1667
										<td colspan="2" valign="top" height="16"></td>
1668
									</tr>
1669
								</table>
1670
							</td>
1671
						</tr>
1672
						<tr style="display:none;" name="dhcp" id="dhcp">
1673
							<td colspan="2" style="padding: 0px;">
1674
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1675
									<tr>
1676
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration"); ?></td>
1677
									</tr>
1678
									<!-- Uncomment to expose DHCP+ in GUI
1679
									<tr>
1680
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1681
										<td width="78%" class="vtable">
1682
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked"; ?> >
1683
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1684
										<br/>
1685
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
1686
										</td>
1687
									</tr>
1688
									-->
1689
									<tr>
1690
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1691
										<td width="78%" class="vtable">
1692
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1693
											<br>
1694
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1695
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1696
											"this (for client identification)."); ?>
1697
										</td>
1698
									</tr>
1699
									<tr>
1700
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
1701
										<td width="78%" class="vtable">
1702
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
1703
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1704
												<?php
1705
												for ($i = 32; $i > 0; $i--) {
1706
													if($i <> 31) {
1707
														echo "<option value=\"{$i}\" ";
1708
														if ($i == $pconfig['alias-subnet']) echo "selected";
1709
														echo ">" . $i . "</option>";
1710
													}
1711
												}
1712
												?>
1713
											</select>
1714
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
1715
											"DHCP client."); ?>
1716
										</td>
1717
									</tr>
1718
									<tr>
1719
										<td colspan="2" valign="top" height="16"></td>
1720
									</tr>
1721
								</table>
1722
							</td>
1723
						</tr>
1724
						<tr style="display:none;" name="dhcp6" id="dhcp6">
1725
							<td colspan="2" style="padding: 0px;">
1726
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1727
									<tr>
1728
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration"); ?></td>
1729
									</tr>
1730
									<!--- Leave commented out for now
1731
									<tr>
1732
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
1733
										<td width="78%" class="vtable">
1734
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>">
1735
											<br>
1736
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
1737
											"when requesting a DHCPv6 lease."); ?><br />
1738
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
1739
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
1740
												}
1741
												printf(gettext("The current DUID is: '%s'"),$current_duid);
1742
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
1743
											?>
1744
										</td>
1745
									</tr>
1746
									-->
1747
									<tr>
1748
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
1749
										<td width="78%" class="vtable">
1750
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
1751
												<?php
1752
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
1753
												foreach($sizes as $bits => $length) {
1754
													echo "<option value=\"{$bits}\" ";
1755
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected";
1756
													echo ">" . $length . "</option>";
1757
												}
1758
												?>
1759
											</select>
1760
											<br>
1761
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
1762
										</td>
1763
									</tr>
1764
									<tr>
1765
										<td colspan="2" valign="top" height="16"></td>
1766
									</tr>
1767
								</table>
1768
							</td>
1769
						</tr>
1770
						<tr style="display:none;" name="6rd" id="6rd">
1771
							<td colspan="2" style="padding: 0px;">
1772
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1773
									<tr>
1774
										<td colspan="2" valign="top" class="listtopic"><?=gettext("6RD Rapid Deployment"); ?></td>
1775
									</tr>
1776
									<tr>
1777
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD prefix"); ?></td>
1778
										<td width="78%" class="vtable">
1779
											<input name="prefix-6rd" type="text" class="formfld unknown" id="prefix-6rd" size="40" value="<?=htmlspecialchars($pconfig['prefix-6rd']);?>">
1780
											<br>
1781
											<?=gettext("The value in this field is the 6RD IPv6 prefix assigned by your ISP. e.g. '2001:db8::/32'") ?><br />
1782
										</td>
1783
									</tr>
1784
									<tr>
1785
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD Border Relay"); ?></td>
1786
										<td width="78%" class="vtable">
1787
											<input name="gateway-6rd" type="text" class="formfld unknown" id="gateway-6rd" size="40" value="<?=htmlspecialchars($pconfig['gateway-6rd']);?>">
1788
											<br>
1789
											<?=gettext("The value in this field is 6RD IPv4 gateway address assigned by your ISP") ?><br />
1790
										</td>
1791
									</tr>
1792
									<tr>
1793
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD IPv4 Prefix length"); ?></td>
1794
										<td width="78%" class="vtable">
1795
											<select name="prefix-6rd-v4plen" class="formselect" id="prefix-6rd-v4plen">
1796
												<?php
1797
												for ($i = 0; $i < 32; $i++) {
1798
													echo "<option value=\"{$i}\" ";
1799
													if (is_numeric($pconfig['prefix-6rd-v4plen']) && ($i == $pconfig['prefix-6rd-v4plen'])) echo "selected";
1800
													echo ">" . $i . " bits</option>";
1801
												}
1802
												?>
1803
											</select>
1804
											<br>
1805
											<?=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."); ?>
1806
										</td>
1807
									</tr>
1808
									<tr>
1809
										<td colspan="2" valign="top" height="16"></td>
1810
									</tr>
1811
								</table>
1812
							</td>
1813
						</tr>
1814
						<tr style="display:none;" name="track6" id="track6">
1815
							<td colspan="2" style="padding: 0px;">
1816
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1817
									<tr>
1818
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
1819
									</tr>
1820
									<tr>
1821
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
1822
										<td width="78%" class="vtable">
1823
										<select name='track6-interface' class='formselect' >
1824
										<?php 
1825
											$interfaces = get_configured_interface_with_descr(false, true);
1826
											$dynv6ifs = array();
1827
											foreach ($interfaces as $iface => $ifacename) {
1828
												switch($config['interfaces'][$iface]['ipaddrv6']) {
1829
													case "6to4":
1830
													case "6rd":
1831
													case "dhcp6":
1832
														$dynv6ifs[$iface] = $ifacename;
1833
														break;
1834
													default:
1835
														continue;
1836
												}
1837
											}
1838
											foreach($dynv6ifs as $iface => $ifacename) {
1839
												echo "<option value=\"{$iface}\"";
1840
												if ($iface == $pconfig['track6-interface'])
1841
													echo " selected";
1842
												echo ">" . htmlspecialchars($ifacename) . "</option>";
1843
											}
1844
										  ?>
1845
										</select> <br>
1846
											<br>
1847
											<?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
1848
										</td>
1849
									</tr>
1850
									<tr>
1851
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
1852
										<td width="78%" class="vtable">
1853
											<?php
1854
												if ($pconfig['track6-prefix-id'] == "none" || $pconfig['track6-prefix-id'] == "") {
1855
													$track6_prefix_id_hex = "";
1856
												} else {
1857
													$track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
1858
												}
1859
											?>
1860
											<input name="track6-prefix-id--hex" type="text" class="formfld unknown" id="track6-prefix-id--hex" size="8" value="<?= $track6_prefix_id_hex ?>" />
1861
											<br />
1862
											<?= gettext("The value in this field is the (Delegated) IPv6 prefix id. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
1863
											<br />
1864
											<?= sprintf(gettext("Enter a <b>hexadecimal</b> value between %x and %x here, or leave blank."), 0, $ipv6_num_prefix_ids - 1); ?>
1865
										</td>
1866
									</tr>
1867
										</td>
1868
									</tr>
1869
									<tr>
1870
										<td colspan="2" valign="top" height="16"></td>
1871
									</tr>
1872
								</table>
1873
							</td>
1874
						</tr>
1875
						<tr style="display:none;" name="ppp" id="ppp">
1876
							<td colspan="2" style="padding: 0px;">
1877
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1878
									<tr>
1879
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
1880
									</tr>
1881
									<tr name="ppp_provider" id="ppp_provider">
1882
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
1883
										<td width="78%" class="vtable">
1884
											<table border="0" cellpadding="0" cellspacing="0">
1885
												<tr id="trcountry">
1886
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
1887
													<td>
1888
														<select class="formselect" name="country" id="country" onChange="providers_list()">
1889
															<option></option>
1890
														</select>
1891
													</td>
1892
												</tr>
1893
												<tr id="trprovider" style="display:none">
1894
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
1895
													<td>
1896
														<select class="formselect" name="provider" id="provider" onChange="providerplan_list()">
1897
															<option></option>
1898
														</select>
1899
													</td>
1900
												</tr>
1901
												<tr id="trproviderplan" style="display:none">
1902
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
1903
													<td>
1904
														<select class="formselect" name="providerplan" id="providerplan" onChange="prefill_provider()">
1905
															<option></option>
1906
														</select>
1907
													</td>
1908
												</tr>
1909
											</table>
1910
											<br/><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
1911
										</td>
1912
									</tr>
1913
									<tr>
1914
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
1915
										<td width="78%" class="vtable">
1916
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
1917
										</td>
1918
									</tr>
1919
									<tr>
1920
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
1921
										<td width="78%" class="vtable">
1922
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
1923
										</td>
1924
									</tr>
1925
									<tr name="phone_num" id="phone_num">
1926
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
1927
										<td width="78%" class="vtable">
1928
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>">
1929
										</td>
1930
									</tr>
1931
									<tr name="apn_" id="apn_">
1932
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
1933
										<td width="78%" class="vtable">
1934
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
1935
										</td>
1936
									</tr>
1937
									<tr name="interface" id="interface" >
1938
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
1939
										<td width="78%" class="vtable">
1940
											<select name="port" id="port" class="formselect">
1941
											<?php
1942
												$portlist = glob("/dev/cua*");
1943
												$modems = glob("/dev/modem*");
1944
												$portlist = array_merge($portlist, $modems);
1945
												foreach ($portlist as $port) {
1946
													if(preg_match("/\.(lock|init)$/", $port))
1947
														continue;
1948
													echo "<option value=\"".trim($port)."\"";
1949
													if ($pconfig['port'] == $port)
1950
														echo "selected";
1951
													echo ">{$port}</option>";
1952
												}?>
1953
											</select>
1954
										</td>
1955
									</tr>
1956
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
1957
										<?php if (isset($pconfig['pppid'])): ?>
1958
											<td width="78%" class="vtable">
1959
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
1960
											<?=gettext("to edit PPP configuration."); ?>
1961
											</td>
1962
										<?php else: ?>
1963
											<td width="78%" class="vtable">
1964
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
1965
											<?=gettext("to create a PPP configuration."); ?>
1966
											</td>
1967
										<?php endif; ?>
1968
									</tr>
1969
									<tr>
1970
										<td colspan="2" valign="top" height="16"></td>
1971
									</tr>
1972
								</table>
1973
							</td>
1974
						</tr>
1975
						<tr style="display:none;" name="pppoe" id="pppoe">
1976
							<td colspan="2" style="padding:0px;">
1977
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1978
									<tr>
1979
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
1980
									</tr>
1981
									<tr>
1982
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
1983
										<td width="78%" class="vtable">
1984
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
1985
										</td>
1986
									</tr>
1987
									<tr>
1988
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
1989
										<td width="78%" class="vtable">
1990
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
1991
										</td>
1992
									</tr>
1993
									<tr>
1994
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
1995
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
1996
											<br> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
1997
										</td>
1998
									</tr>
1999
									<tr>
2000
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2001
										<td width="78%" class="vtable">
2002
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>>
2003
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
2004
											<?=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."); ?>
2005
										</td>
2006
									</tr>
2007
									<tr>
2008
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2009
										<td width="78%" class="vtable">
2010
											<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."); ?>
2011
										</td>
2012
									</tr>
2013
									<tr>
2014
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
2015
										<td width="78%" class="vtable">
2016
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
2017
												<tr>
2018
													<td align="left" valign="top">
2019
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
2020
														<select valign="top" id="reset_type" name="pppoe-reset-type" class="formselect" onChange="show_reset_settings(this.value);">
2021
															<option value = ""><?=gettext("Disabled"); ?></option>
2022
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?=gettext("Custom"); ?></option>
2023
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?=gettext("Pre-Set"); ?></option>
2024
														</select> <?=gettext("Select a reset timing type"); ?>
2025
														</p>
2026
														<?php if ($pconfig['pppoe_pr_custom']): ?>
2027
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
2028
														<?php else: ?>
2029
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
2030
														<?php endif; ?>
2031
														<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" />
2032
														<?=gettext("hour (0-23)"); ?><br />
2033
														<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" />
2034
														<?=gettext("minute (0-59)"); ?><br />
2035
														<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']);?>" />
2036
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
2037
														<br />&nbsp;<br />
2038
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
2039
														<?=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."); ?>
2040
														</p>
2041
														<?php if ($pconfig['pppoe_pr_preset']): ?>
2042
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
2043
														<?php else: ?>
2044
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
2045
														<?php endif; ?>
2046
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
2047
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
2048
														<br />
2049
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
2050
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
2051
														<br />
2052
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
2053
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
2054
														<br />
2055
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
2056
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
2057
														</p>
2058
													</td>
2059
												</tr>
2060
											</table>
2061
										</td>
2062
									</tr>
2063

    
2064
									<tr>
2065
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
2066
										<?php if (isset($pconfig['pppid'])): ?>
2067
											<td width="78%" class="vtable">
2068
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2069
											<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
2070
											</td>
2071
										<?php else: ?>
2072
											<td width="78%" class="vtable">
2073
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2074
											<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
2075
											</td>
2076
										<?php endif; ?>
2077
									</tr>
2078
									<tr>
2079
										<td colspan="2" valign="top" height="16"></td>
2080
									</tr>
2081
								</table>
2082
							</td>
2083
						</tr>
2084
						<tr style="display:none;" name="pptp" id="pptp">
2085
							<td colspan="2" style="padding:0px;">
2086
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
2087
									<tr>
2088
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP/L2TP configuration"); ?></td>
2089
									</tr>
2090
									<tr>
2091
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2092
										<td width="78%" class="vtable">
2093
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
2094
										</td>
2095
									</tr>
2096
									<tr>
2097
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2098
										<td width="78%" class="vtable">
2099
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
2100
										</td>
2101
									</tr>
2102
									<tr>
2103
										<td width="22%" width="100" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
2104
										<td width="78%" class="vtable">
2105
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>">
2106
											/
2107
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
2108
												<?php for ($i = 31; $i > 0; $i--): ?>
2109
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected"; ?>>
2110
														<?=$i;?></option>
2111
												<?php endfor; ?>
2112
											</select>
2113
										</td>
2114
									</tr>
2115
									<tr>
2116
										<td width="22%" width="100" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
2117
										<td width="78%" class="vtable">
2118
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>">
2119
										</td>
2120
									</tr>
2121
									<tr>
2122
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2123
										<td width="78%" class="vtable">
2124
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?>>
2125
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
2126
											<?=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."); ?>
2127
										</td>
2128
									</tr>
2129
									<tr>
2130
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2131
										<td width="78%" class="vtable">
2132
											<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."); ?>
2133
										</td>
2134
									</tr>
2135
									<tr>
2136
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
2137
										<?php if (isset($pconfig['pppid'])): ?>
2138
											<td width="78%" class="vtable">
2139
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
2140
											<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
2141
											</td>
2142
										<?php else: ?>
2143
											<td width="78%" class="vtable">
2144
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
2145
											<?=gettext("for advanced PPTP and L2TP configuration options");?>.
2146
											</td>
2147
										<?php endif; ?>
2148
									</tr>
2149
									<tr>
2150
										<td colspan="2" valign="top" height="16"></td>
2151
									</tr>
2152
								</table>
2153
							</td>
2154
						</tr>
2155
						<?php
2156
							/* Wireless interface? */
2157
							if (isset($wancfg['wireless'])):
2158
						?>
2159
						<tr>
2160
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
2161
						</tr>
2162
						<tr>
2163
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
2164
							<td class="vtable">
2165
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked";?>>
2166
								<br/><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
2167
							</td>
2168
						</tr>
2169
						<tr>
2170
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
2171
							<td class="vtable">
2172
							<select name="standard" class="formselect" id="standard">
2173
								<?php
2174
								foreach($wl_modes as $wl_standard => $wl_channels) {
2175
									echo "<option ";
2176
									if ($pconfig['standard'] == "$wl_standard")
2177
										echo "selected ";
2178
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
2179
								}
2180
								?>
2181
							</select>
2182
							</td>
2183
						</tr>
2184
						<?php if (isset($wl_modes['11g'])): ?>
2185
						<tr>
2186
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
2187
							<td class="vtable">
2188
								<select name="protmode" class="formselect" id="protmode">
2189
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected";?> value="off"><?=gettext("Protection mode off"); ?></option>
2190
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
2191
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
2192
								</select>
2193
								<br/>
2194
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
2195
								<br/>
2196
							</td>
2197
						</tr>
2198
						<?php else: ?>
2199
						<input name="protmode" type="hidden" id="protmode" value="off">
2200
						<?php endif; ?>
2201
						<tr>
2202
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
2203
							<td class="vtable">
2204
								<select name="txpower" class="formselect" id="txpower">
2205
									<?
2206
									for($x = 99; $x > 0; $x--) {
2207
										if($pconfig["txpower"] == $x)
2208
											$SELECTED = " SELECTED";
2209
										else
2210
											$SELECTED = "";
2211
										echo "<option {$SELECTED}>{$x}</option>\n";
2212
									}
2213
									?>
2214
								</select><br/>
2215
								<?=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."); ?>
2216
							</td>
2217
						</tr>
2218
						<tr>
2219
							<td valign="top" class="vncellreq"><?=gettext("Channel"); ?></td>
2220
							<td class="vtable">
2221
								<select name="channel" class="formselect" id="channel">
2222
									<option <?php if ($pconfig['channel'] == 0) echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2223
									<?php
2224
									foreach($wl_modes as $wl_standard => $wl_channels) {
2225
										if($wl_standard == "11g") { $wl_standard = "11b/g"; }
2226
										else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
2227
										else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
2228
										foreach($wl_channels as $wl_channel) {
2229
											echo "<option ";
2230
											if ($pconfig['channel'] == "$wl_channel") {
2231
												echo "selected ";
2232
											}
2233
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
2234
											if(isset($wl_chaninfo[$wl_channel]))
2235
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
2236
											echo "</option>\n";
2237
										}
2238
									}
2239
									?>
2240
								</select>
2241
								<br/>
2242
								<?=gettext("Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)"); ?>
2243
								<br/>
2244
								<?=gettext("Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above."); ?>
2245
							</td>
2246
						</tr>
2247
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2248
						<tr>
2249
							<td valign="top" class="vncell"><?=gettext("Antenna settings"); ?></td>
2250
							<td class="vtable">
2251
								<table border="0" cellpadding="0" cellspacing="0">
2252
									<tr>
2253
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])): ?>
2254
										<td>
2255
											<?=gettext("Diversity"); ?><br/>
2256
											<select name="diversity" class="formselect" id="diversity">
2257
												<option <?php if (!isset($pconfig['diversity'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2258
												<option <?php if ($pconfig['diversity'] === '0') echo "selected"; ?> value="0"><?=gettext("Off"); ?></option>
2259
												<option <?php if ($pconfig['diversity'] === '1') echo "selected"; ?> value="1"><?=gettext("On"); ?></option>
2260
											</select>
2261
										</td>
2262
										<td>&nbsp;&nbsp</td>
2263
										<?php endif; ?>
2264
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])): ?>
2265
										<td>
2266
											<?=gettext("Transmit antenna"); ?><br/>
2267
											<select name="txantenna" class="formselect" id="txantenna">
2268
												<option <?php if (!isset($pconfig['txantenna'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2269
												<option <?php if ($pconfig['txantenna'] === '0') echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2270
												<option <?php if ($pconfig['txantenna'] === '1') echo "selected"; ?> value="1"><?=gettext("#1"); ?></option>
2271
												<option <?php if ($pconfig['txantenna'] === '2') echo "selected"; ?> value="2"><?=gettext("#2"); ?></option>
2272
											</select>
2273
										</td>
2274
										<td>&nbsp;&nbsp</td>
2275
										<?php endif; ?>
2276
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2277
										<td>
2278
											<?=gettext("Receive antenna"); ?><br/>
2279
											<select name="rxantenna" class="formselect" id="rxantenna">
2280
												<option <?php if (!isset($pconfig['rxantenna'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2281
												<option <?php if ($pconfig['rxantenna'] === '0') echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2282
												<option <?php if ($pconfig['rxantenna'] === '1') echo "selected"; ?> value="1"><?=gettext("#1"); ?></option>
2283
												<option <?php if ($pconfig['rxantenna'] === '2') echo "selected"; ?> value="2"><?=gettext("#2"); ?></option>
2284
											</select>
2285
										</td>
2286
										<?php endif; ?>
2287
									</tr>
2288
								</table>
2289
								<br/>
2290
								<?=gettext("Note: The antenna numbers do not always match up with the labels on the card."); ?>
2291
							</td>
2292
						</tr>
2293
						<?php endif; ?>
2294
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])): ?>
2295
						<tr>
2296
							<td valign="top" class="vncell"><?=gettext("Distance setting"); ?></td>
2297
							<td class="vtable">
2298
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>">
2299
								<br/>
2300
								<?=gettext("Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client"); ?><br/>
2301
								<?=gettext("(measured in Meters and works only for Atheros based cards !)"); ?>
2302
							</td>
2303
						</tr>
2304
						<?php endif; ?>
2305
						<tr>
2306
							<td valign="top" class="vncell"><?=gettext("Regulatory settings"); ?></td>
2307
							<td class="vtable">
2308
								<?=gettext("Regulatory domain"); ?><br/>
2309
								<select name="regdomain" class="formselect" id="regdomain">
2310
									<option <?php if (empty($pconfig['regdomain'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2311
									<?php
2312
									foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
2313
										echo "<option ";
2314
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
2315
											echo "selected ";
2316
										}
2317
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
2318
									}
2319
									?>
2320
								</select>
2321
								<br/>
2322
								<?=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."); ?>
2323
								<br/><br/>
2324
								<?=gettext("Country (listed with country code and regulatory domain)"); ?><br/>
2325
								<select name="regcountry" class="formselect" id="regcountry">
2326
									<option <?php if (empty($pconfig['regcountry'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2327
									<?php
2328
									foreach($wl_countries as $wl_country_key => $wl_country) {
2329
										echo "<option ";
2330
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
2331
											echo "selected ";
2332
										}
2333
										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";
2334
									}
2335
									?>
2336
								</select>
2337
								<br/>
2338
								<?=gettext("Note: Any country setting other than \"Default\" will override the regulatory domain setting"); ?>.
2339
								<br/><br/>
2340
								<?=gettext("Location"); ?><br/>
2341
								<select name="reglocation" class="formselect" id="reglocation">
2342
									<option <?php if (empty($pconfig['reglocation'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2343
									<option <?php if ($pconfig['reglocation'] == 'indoor') echo "selected"; ?> value="indoor"><?=gettext("Indoor"); ?></option>
2344
									<option <?php if ($pconfig['reglocation'] == 'outdoor') echo "selected"; ?> value="outdoor"><?=gettext("Outdoor"); ?></option>
2345
									<option <?php if ($pconfig['reglocation'] == 'anywhere') echo "selected"; ?> value="anywhere"><?=gettext("Anywhere"); ?></option>
2346
								</select>
2347
								<br/><br/>
2348
								<?=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."); ?>
2349
								<br/>
2350
								<?=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."); ?>
2351
							</td>
2352
						</tr>
2353
						<tr>
2354
							<td colspan="2" valign="top" height="16"></td>
2355
						</tr>
2356
						<tr>
2357
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Network-specific wireless configuration");?></td>
2358
						</tr>
2359
						<tr>
2360
							<td valign="top" class="vncellreq"><?=gettext("Mode"); ?></td>
2361
							<td class="vtable">
2362
								<select name="mode" class="formselect" id="mode">
2363
									<option <?php if ($pconfig['mode'] == 'bss') echo "selected";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
2364
									<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
2365
									<option <?php if ($pconfig['mode'] == 'hostap') echo "selected";?> value="hostap"><?=gettext("Access Point"); ?></option>
2366
								</select>
2367
							</td>
2368
						</tr>
2369
						<tr>
2370
							<td valign="top" class="vncellreq"><?=gettext("SSID"); ?></td>
2371
							<td class="vtable">
2372
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>">
2373
								<br/>
2374
								<?=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"); ?>
2375
							</td>
2376
						</tr>
2377
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
2378
						<tr>
2379
							<td valign="top" class="vncell"><?=gettext("Minimum wireless standard"); ?></td>
2380
							<td class="vtable">
2381
								<select name="puremode" class="formselect" id="puremode">
2382
									<option <?php if ($pconfig['puremode'] == 'any') echo "selected";?> value="any"><?=gettext("Any"); ?></option>
2383
									<?php if (isset($wl_modes['11g'])): ?>
2384
									<option <?php if ($pconfig['puremode'] == '11g') echo "selected";?> value="11g"><?=gettext("802.11g"); ?></option>
2385
									<?php endif; ?>
2386
									<option <?php if ($pconfig['puremode'] == '11n') echo "selected";?> value="11n"><?=gettext("802.11n"); ?></option>
2387
								</select>
2388
								<br/>
2389
								<?=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)."); ?>
2390
							</td>
2391
						</tr>
2392
						<?php elseif (isset($wl_modes['11g'])): ?>
2393
						<tr>
2394
							<td valign="top" class="vncell"><?=gettext("802.11g only"); ?></td>
2395
							<td class="vtable">
2396
								<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <?php if ($pconfig['puremode'] == '11g') echo "checked";?>>
2397
								<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)."); ?>
2398
							</td>
2399
						</tr>
2400
						<?php endif; ?>
2401
						<tr>
2402
							<td valign="top" class="vncell"><?=gettext("Allow intra-BSS communication"); ?></td>
2403
							<td class="vtable">
2404
								<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <?php if ($pconfig['apbridge_enable']) echo "checked";?>>
2405
								<br/>
2406
								<?=gettext("When operating as an access point, enable this if you want to pass packets between wireless clients directly."); ?>
2407
								<br/>
2408
								<?=gettext("Disabling the internal bridging is useful when traffic is to be processed with packet filtering."); ?>
2409
							</td>
2410
						</tr>
2411
						<tr>
2412
							<td valign="top" class="vncell"><?=gettext("Enable WME"); ?></td>
2413
							<td class="vtable">
2414
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <?php if ($pconfig['wme_enable']) echo "checked";?>>
2415
								<br/><?=gettext("Setting this option will force the card to use WME (wireless QoS)."); ?>
2416
							</td>
2417
						</tr>
2418
						<tr>
2419
							<td valign="top" class="vncell"><?=gettext("Enable Hide SSID"); ?></td>
2420
							<td class="vtable">
2421
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <?php if ($pconfig['hidessid_enable']) echo "checked";?>>
2422
								<br/>
2423
								<?=gettext("Setting this option will force the card to NOT broadcast its SSID"); ?>
2424
								<br/>
2425
								<?=gettext("(this might create problems for some clients)."); ?>
2426
							</td>
2427
						</tr>
2428
						<tr>
2429
							<td valign="top" class="vncell"><?=gettext("WEP"); ?></td>
2430
							<td class="vtable">
2431
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <?php if ($pconfig['wep_enable']) echo "checked"; ?>>
2432
								<strong><?=gettext("Enable WEP"); ?></strong>
2433
								<table border="0" cellspacing="0" cellpadding="0">
2434
									<tr>
2435
										<td>&nbsp;</td>
2436
										<td>&nbsp;</td>
2437
										<td>&nbsp;<?=gettext("TX key"); ?>&nbsp;</td>
2438
									</tr>
2439
									<tr>
2440
										<td><?=gettext("Key 1:"); ?>&nbsp;&nbsp;</td>
2441
										<td>
2442
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>">
2443
										</td>
2444
										<td align="center">
2445
											<input name="txkey" type="radio" value="1" <?php if ($pconfig['txkey'] == 1) echo "checked";?>>
2446
										</td>
2447
									</tr>
2448
									<tr>
2449
										<td><?=gettext("Key 2:"); ?>&nbsp;&nbsp;</td>
2450
										<td>
2451
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>">
2452
										</td>
2453
										<td align="center">
2454
											<input name="txkey" type="radio" value="2" <?php if ($pconfig['txkey'] == 2) echo "checked";?>>
2455
										</td>
2456
									</tr>
2457
									<tr>
2458
										<td><?=gettext("Key 3:"); ?>&nbsp;&nbsp;</td>
2459
										<td>
2460
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>">
2461
										</td>
2462
										<td align="center">
2463
											<input name="txkey" type="radio" value="3" <?php if ($pconfig['txkey'] == 3) echo "checked";?>>
2464
										</td>
2465
									</tr>
2466
									<tr>
2467
										<td><?=gettext("Key 4:"); ?>&nbsp;&nbsp;</td>
2468
										<td>
2469
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>">
2470
										</td>
2471
										<td align="center">
2472
											<input name="txkey" type="radio" value="4" <?php if ($pconfig['txkey'] == 4) echo "checked";?>>
2473
										</td>
2474
									</tr>
2475
								</table>
2476
								<br/>
2477
								<?=gettext("40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'."); ?><br/>
2478
								<?=gettext("104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'."); ?>
2479
							</td>
2480
						</tr>
2481
						<tr>
2482
							<td valign="top" class="vncell"><?=gettext("WPA"); ?></td>
2483
							<td class="vtable">
2484
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <?php if ($pconfig['wpa_enable']) echo "checked"; ?>>
2485
								<strong><?=gettext("Enable WPA"); ?></strong>
2486
								<br/><br/>
2487
								<table border="0" cellspacing="0" cellpadding="0">
2488
									<tr>
2489
										<td>&nbsp;</td>
2490
										<td>&nbsp;<?=gettext("WPA Pre-Shared Key"); ?>&nbsp;</td>
2491
									</tr>
2492
									<tr>
2493
										<td><?=gettext("PSK:"); ?>&nbsp;&nbsp;</td>
2494
										<td>
2495
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>">
2496
										</td>
2497
									</tr>
2498
								</table>
2499
								<br/><?=gettext("Passphrase must be from 8 to 63 characters."); ?>
2500
							</td>
2501
						</tr>
2502
						<tr>
2503
							<td valign="top" class="vncell"><?=gettext("WPA Mode"); ?></td>
2504
							<td class="vtable">
2505
								<select name="wpa_mode" class="formselect" id="wpa_mode">
2506
									<option <?php if ($pconfig['wpa_mode'] == '1') echo "selected";?> value="1"><?=gettext("WPA"); ?></option>
2507
									<option <?php if ($pconfig['wpa_mode'] == '2') echo "selected";?> value="2"><?=gettext("WPA2"); ?></option>
2508
									<option <?php if ($pconfig['wpa_mode'] == '3') echo "selected";?> value="3"><?=gettext("Both"); ?></option>
2509
								</select>
2510
							</td>
2511
						</tr>
2512
						<tr>
2513
							<td valign="top" class="vncell"><?=gettext("WPA Key Management Mode"); ?></td>
2514
							<td class="vtable">
2515
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
2516
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected";?> value="WPA-PSK"><?=gettext("Pre-Shared Key"); ?></option>
2517
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected";?> value="WPA-EAP"><?=gettext("Extensible Authentication Protocol"); ?></option>
2518
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected";?> value="WPA-PSK WPA-EAP"><?=gettext("Both"); ?></option>
2519
								</select>
2520
							</td>
2521
						</tr>
2522
						<tr>
2523
							<td valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
2524
							<td class="vtable">
2525
								<select name="auth_algs" class="formselect" id="auth_algs">
2526
									<option <?php if ($pconfig['auth_algs'] == '1') echo "selected";?> value="1"><?=gettext("Open System Authentication"); ?></option>
2527
									<option <?php if ($pconfig['auth_algs'] == '2') echo "selected";?> value="2"><?=gettext("Shared Key Authentication"); ?></option>
2528
									<option <?php if ($pconfig['auth_algs'] == '3') echo "selected";?> value="3"><?=gettext("Both"); ?></option>
2529
								</select>
2530
								<br/><?=gettext("Note: Shared Key Authentication requires WEP."); ?></br>
2531
							</td>
2532
						</tr>
2533
						<tr>
2534
							<td valign="top" class="vncell"><?=gettext("WPA Pairwise"); ?></td>
2535
							<td class="vtable">
2536
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
2537
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected";?> value="CCMP TKIP"><?=gettext("Both"); ?></option>
2538
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected";?> value="CCMP"><?=gettext("AES (recommended)"); ?></option>
2539
									<option <?php if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected";?> value="TKIP"><?=gettext("TKIP"); ?></option>
2540
								</select>
2541
							</td>
2542
						</tr>
2543
						<tr>
2544
							<td valign="top" class="vncell"><?=gettext("Key Rotation"); ?></td>
2545
							<td class="vtable">
2546
								<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";?>">
2547
								<br/><?=gettext("Allowed values are 1-9999 but should not be longer than Master Key Regeneration time."); ?>
2548
							</td>
2549
						</tr>
2550
						<tr>
2551
							<td valign="top" class="vncell"><?=gettext("Master Key Regeneration"); ?></td>
2552
							<td class="vtable">
2553
								<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";?>">
2554
								<br/><?=gettext("Allowed values are 1-9999 but should not be shorter than Key Rotation time."); ?>
2555
							</td>
2556
						</tr>
2557
						<tr>
2558
							<td valign="top" class="vncell"><?=gettext("Strict Key Regeneration"); ?></td>
2559
							<td class="vtable">
2560
								<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <?php if ($pconfig['wpa_strict_rekey']) echo "checked"; ?>>
2561
								<br/><?=gettext("Setting this option will force the AP to rekey whenever a client disassociates."); ?>
2562
							</td>
2563
						</tr>
2564
						<tr>
2565
							<td valign="top" class="vncell"><?=gettext("Enable IEEE802.1X Authentication"); ?></td>
2566
							<td class="vtable">
2567
								<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <?php if ($pconfig['ieee8021x']) echo "checked";?>>
2568
								<br/><?=gettext("Setting this option will enable 802.1x authentication."); ?>
2569
								<br/><span class="red"><strong><?=gettext("NOTE"); ?>:</strong></span> <?=gettext("this option requires checking the \"Enable WPA box\"."); ?>
2570
							</td>
2571
						</tr>
2572
						<tr>
2573
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server IP Address"); ?></td>
2574
							<td class="vtable">
2575
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>">
2576
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
2577
							</td>
2578
						</tr>
2579
						<tr>
2580
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Port"); ?></td>
2581
							<td class="vtable">
2582
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>">
2583
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
2584
							</td>
2585
						</tr>
2586
						<tr>
2587
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Shared Secret"); ?></td>
2588
							<td class="vtable">
2589
								<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']);?>">
2590
								<br/>
2591
							</td>
2592
						</tr>
2593
						<tr>
2594
					<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server IP Address"); ?></td>
2595
							<td class="vtable">
2596
								<input name="auth_server_addr2" id="auth_server_addr2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr2']);?>">
2597
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
2598
							</td>
2599
						</tr>
2600
						<tr>
2601
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Port"); ?></td>
2602
							<td class="vtable">
2603
								<input name="auth_server_port2" id="auth_server_port2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port2']);?>">
2604
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
2605
							</td>
2606
						</tr>
2607
						<tr>
2608
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Shared Secret"); ?></td>
2609
							<td class="vtable">
2610
								<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']);?>">
2611
								<br/>
2612
							</td>
2613
						</tr>
2614
						<tr>
2615
							<td valign="top" class="vncell">802.1X <?=gettext("Authentication Roaming Preauth"); ?></td>
2616
							<td class="vtable">
2617
								<input name="rsn_preauth" id="rsn_preauth" type="checkbox" class="formfld unknown" size="66" value="yes" <?php if ($pconfig['rsn_preauth']) echo "checked"; ?>>
2618
								<br/>
2619
							</td>
2620
						</tr>
2621
						<tr>
2622
							<td colspan="2" valign="top" height="16"></td>
2623
						</tr>
2624
						<?php endif; ?>
2625
						<tr>
2626
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Private networks"); ?></td>
2627
						</tr>
2628
						<tr>
2629
							<td valign="middle" class="vncell">&nbsp;</td>
2630
							<td class="vtable">
2631
								<a name="rfc1918"></a>
2632
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
2633
								<strong><?=gettext("Block private networks"); ?></strong><br>
2634
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2635
								"for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as"); ?>
2636
								<?=gettext("well as loopback addresses (127/8)."); ?>&nbsp;&nbsp; <?=gettext("You should generally " .
2637
								"leave this option turned on, unless your WAN network lies in such " .
2638
								"a private address space, too."); ?>
2639
							</td>
2640
						</tr>
2641
						<tr>
2642
							<td valign="middle" class="vncell">&nbsp;</td>
2643
							<td class="vtable">
2644
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
2645
								<strong><?=gettext("Block bogon networks"); ?></strong><br>
2646
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2647
								"(but not RFC 1918) or not yet assigned by IANA."); ?>&nbsp;&nbsp;
2648
								<?=gettext("Bogons are prefixes that should never appear in the Internet routing table, " .
2649
								"and obviously should not appear as the source address in any packets you receive."); ?>
2650
								<br/><br/>
2651
								<?=gettext("Note: The update frequency can be changed under System->Advanced Firewall/NAT settings.")?>
2652
							</td>
2653
						</tr>
2654
					</table> <!-- End "allcfg" table -->
2655
					</div> <!-- End "allcfg" div -->
2656

    
2657
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2658
						<tr>
2659
							<td width="22%" valign="top">
2660
								&nbsp;
2661
							</td>
2662
							<td width="78%">
2663
								<br/>
2664
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2665
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2666
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2667
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2668
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2669
								<?php endif; ?>
2670
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2671
							</td>
2672
						</tr>
2673
					</table>
2674
				</td>
2675
			</tr>
2676
		</table>
2677
		<!--
2678
		</div>
2679
		</td></tr>
2680
		</table>
2681
		-->
2682
	</form>
2683
	<script type="text/javascript">
2684
		var gatewayip;
2685
		var name;
2686
		var gatewayipv6;
2687
		var namev6;
2688
		function show_add_gateway() {
2689
			document.getElementById("addgateway").style.display = '';
2690
			document.getElementById("addgwbox").style.display = 'none';
2691
			document.getElementById("gateway").style.display = 'none';
2692
			document.getElementById("save").style.display = 'none';
2693
			document.getElementById("cancel").style.display = 'none';
2694
			document.getElementById("gwsave").style.display = '';
2695
			document.getElementById("gwcancel").style.display = '';
2696
			jQuery('#notebox').html("");
2697
		}
2698
		function show_add_gateway_v6() {
2699
			document.getElementById("addgatewayv6").style.display = '';
2700
			document.getElementById("addgwboxv6").style.display = 'none';
2701
			document.getElementById("gatewayv6").style.display = 'none';
2702
			document.getElementById("save").style.display = 'none';
2703
			document.getElementById("cancel").style.display = 'none';
2704
			document.getElementById("gwsave").style.display = '';
2705
			document.getElementById("gwcancel").style.display = '';
2706
			jQuery('#noteboxv6').html("");
2707
		}
2708
		function hide_add_gateway() {
2709
			document.getElementById("addgateway").style.display = 'none';
2710
			document.getElementById("addgwbox").style.display = '';
2711
			document.getElementById("gateway").style.display = '';
2712
			document.getElementById("save").style.display = '';
2713
			document.getElementById("cancel").style.display = '';
2714
			document.getElementById("gwsave").style.display = '';
2715
			document.getElementById("gwcancel").style.display = '';
2716
			jQuery('#status').html('');
2717
		}
2718
		function hide_add_gateway_v6() {
2719
			document.getElementById("addgatewayv6").style.display = 'none';
2720
			document.getElementById("addgwboxv6").style.display = '';
2721
			document.getElementById("gatewayv6").style.display = '';
2722
			document.getElementById("save").style.display = '';
2723
			document.getElementById("cancel").style.display = '';
2724
			document.getElementById("gwsave").style.display = '';
2725
			document.getElementById("gwcancel").style.display = '';
2726
			jQuery('#statusv6').html('');
2727
		}
2728
		function hide_add_gatewaysave() {
2729
			document.getElementById("addgateway").style.display = 'none';
2730
			jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2731
			var iface = jQuery('#if').val();
2732
			name = jQuery('#name').val();
2733
			var descr = jQuery('#gatewaydescr').val();
2734
			gatewayip = jQuery('#gatewayip').val();
2735

    
2736
			var defaultgw = jQuery('#defaultgw').val();
2737
			var url = "system_gateways_edit.php";
2738
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2739
			jQuery.ajax(
2740
				url,
2741
				{
2742
					type: 'post',
2743
					data: pars,
2744
					error: report_failure,
2745
					success: save_callback
2746
				});
2747
		}
2748
		function hide_add_gatewaysave_v6() {
2749
			document.getElementById("addgatewayv6").style.display = 'none';
2750
			jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2751
			var iface = jQuery('#if').val();
2752
			name = jQuery('#namev6').val();
2753
			var descr = jQuery('#gatewaydescrv6').val();
2754
			gatewayip = jQuery('#gatewayipv6').val();
2755
			var defaultgw = jQuery('#defaultgwv6').val();
2756
			var url_v6 = "system_gateways_edit.php";
2757
			var pars_v6 = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2758
			jQuery.ajax(
2759
				url_v6,
2760
				{
2761
					type: 'post',
2762
					data: pars_v6,
2763
					error: report_failure_v6,
2764
					success: save_callback_v6
2765
				});
2766
		}
2767
		function addOption(selectbox,text,value)
2768
		{
2769
			var optn = document.createElement("OPTION");
2770
			optn.text = text;
2771
			optn.value = value;
2772
			selectbox.append(optn);
2773
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2774
			jQuery('#notebox').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2775
		}
2776
		function addOption_v6(selectbox,text,value)
2777
		{
2778
			var optn = document.createElement("OPTION");
2779
			optn.text = text;
2780
			optn.value = value;
2781
			selectbox.append(optn);
2782
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2783
			jQuery('#noteboxv6').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2784
		}
2785
		function report_failure(request, textStatus, errorThrown) {
2786
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
2787
				alert(request.responseText);
2788
			} else {
2789
				alert("Sorry, we could not create your IPv4 gateway at this time.");
2790
			}
2791
			hide_add_gateway();
2792
		}
2793
		function report_failure_v6(request, textStatus, errorThrown) {
2794
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
2795
				alert(request.responseText);
2796
			} else {
2797
				alert("Sorry, we could not create your IPv6 gateway at this time.");
2798
			}
2799
			hide_add_gateway_v6();
2800
		}
2801
		function save_callback(transport) {
2802
			var response = transport.responseText;
2803
			if(response) {
2804
				document.getElementById("addgateway").style.display = 'none';
2805
				hide_add_gateway();
2806
				var gwtext = escape(name) + " - " + gatewayip;
2807
				addOption(jQuery('#gateway'), gwtext, name);
2808
				// Auto submit form?
2809
				//document.iform.submit();
2810
				//jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif">');
2811
			} else {
2812
				report_failure();
2813
			}
2814
		}
2815
		function show_advanced_media() {
2816
			document.getElementById("showadvmediabox").innerHTML='';
2817
			aodiv = document.getElementById('showmediaadv');
2818
			aodiv.style.display = "block";
2819
		}
2820
		function save_callback_v6(transport) {
2821
			var response_v6 = transport.responseText;
2822
			if(response_v6) {
2823
				document.getElementById("addgatewayv6").style.display = 'none';
2824
				hide_add_gateway_v6();
2825
				var gwtext_v6 = escape(name) + " - " + gatewayip;
2826
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
2827
				// Auto submit form?
2828
				//document.iform.submit();
2829
				//jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif">');
2830
			} else {
2831
				report_failure_v6();
2832
			}
2833
		}
2834
		<?php
2835
		echo "show_allcfg(document.iform.enable);";
2836
		echo "updateType('{$pconfig['type']}');\n";
2837
		echo "updateTypeSix('{$pconfig['type6']}');\n";
2838
		?>
2839
	</script>
2840
	<?php include("fend.inc"); ?>
2841
	</body>
2842
</html>
(93-93/246)