Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
97
$parent_vlan_if = "";
98
if (preg_match('/_vlan[0-9]/', $wancfg['if'])) {
99
	$realhwif_array = get_parent_interface($wancfg['if']);
100
	// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
101
	$realhwif = $realhwif_array[0];
102
	$parent_vlan_if = convert_real_interface_to_friendly_interface_name($realhwif);
103
	$wancfg['mtu'] = '';
104
}
105

    
106
foreach ($a_ppps as $pppid => $ppp) {
107
	if ($wancfg['if'] == $ppp['if'])
108
		break;
109
}
110

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

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

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

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

    
191
if (is_array($config['aliases']['alias'])) {
192
	foreach($config['aliases']['alias'] as $alias) {
193
		if($alias['name'] == $wancfg['descr']) {
194
			$input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."),$wancfg['descr']);
195
		}
196
	}
197
}
198

    
199
switch($wancfg['ipaddr']) {
200
	case "dhcp":
201
		$pconfig['type'] = "dhcp";
202
		break;
203
	case "pppoe":
204
	case "pptp":
205
	case "l2tp":
206
	case "ppp":
207
		$pconfig['type'] = $wancfg['ipaddr'];
208
		break;
209
	default:
210
		if(is_ipaddrv4($wancfg['ipaddr'])) {
211
			$pconfig['type'] = "staticv4";
212
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
213
			$pconfig['subnet'] = $wancfg['subnet'];
214
			$pconfig['gateway'] = $wancfg['gateway'];
215
		} else
216
			$pconfig['type'] = "none";
217
		break;
218
}
219

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

    
263
// print_r($pconfig);
264

    
265
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
266
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
267
$pconfig['spoofmac'] = $wancfg['spoofmac'];
268
$pconfig['mtu'] = $wancfg['mtu'];
269
$pconfig['mss'] = $wancfg['mss'];
270

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

    
354
$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']);
355
$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
356

    
357
if ($_POST['apply']) {
358
	unset($input_errors);
359
	if (!is_subsystem_dirty('interfaces'))
360
		$intput_errors[] = gettext("You have already applied your settings!");
361
	else {
362
		unlink_if_exists("{$g['tmp_path']}/config.cache");
363
		clear_subsystem_dirty('interfaces');
364

    
365
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
366
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
367
			foreach ($toapplylist as $ifapply => $ifcfgo) {
368
				if (isset($config['interfaces'][$ifapply]['enable'])) {
369
					interface_bring_down($ifapply, false, $ifcfgo);
370
					interface_configure($ifapply, true);
371
				} else
372
					interface_bring_down($ifapply, true, $ifcfgo);
373
			}
374
		}
375
		/* restart snmp so that it binds to correct address */
376
		services_snmpd_configure();
377

    
378
		/* sync filter configuration */
379
		setup_gateways_monitor();
380

    
381
		clear_subsystem_dirty('interfaces');
382

    
383
		filter_configure();
384

    
385
		enable_rrd_graphing();
386

    
387
		if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0))
388
			clear_subsystem_dirty('staticroutes');
389
	}
390
	@unlink("{$g['tmp_path']}/.interfaces.apply");
391
	header("Location: interfaces.php?if={$if}");
392
	exit;
393
} else if ($_POST && $_POST['enable'] != "yes") {
394
	unset($wancfg['enable']);
395
	if (isset($wancfg['wireless']))
396
		interface_sync_wireless_clones($wancfg, false);
397
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
398
	mark_subsystem_dirty('interfaces');
399
	if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
400
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
401
	} else {
402
		$toapplylist = array();
403
	}
404
	$toapplylist[$if]['ifcfg'] = $wancfg;
405
	$toapplylist[$if]['ppps'] = $a_ppps;
406
	/* we need to be able remove IP aliases for IPv6 */
407
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
408
	header("Location: interfaces.php?if={$if}");
409
	exit;
410
} else if ($_POST) {
411

    
412
	unset($input_errors);
413
	$pconfig = $_POST;
414
	if ($pconfig['track6-prefix-id--hex'] === "") {
415
		$pconfig['track6-prefix-id'] = "none";
416
	} else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
417
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
418
	} else {
419
		$pconfig['track6-prefix-id'] = "none";
420
	}
421
	conf_mount_rw();
422

    
423
	/* filter out spaces from descriptions  */
424
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
425

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

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

    
549
			if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
550
				$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
551
			} else {
552
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
553
				if ($track6_prefix_id < 0 || $track6_prefix_id >= $ipv6_num_prefix_ids) {
554
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.");
555
				}
556
			}
557
			break;
558
	}
559

    
560
	
561
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
562
	$staticroutes = get_staticroutes(true);
563
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
564
	if ($_POST['ipaddr']) {
565
		if (!is_ipaddrv4($_POST['ipaddr']))
566
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
567
		else {
568
			if (is_ipaddr_configured($_POST['ipaddr'], $if, true))
569
				$input_errors[] = gettext("This IPv4 address is being used by another interface or VIP.");
570

    
571
			foreach ($staticroutes as $route_subnet) {
572
				list($network, $subnet) = explode("/", $route_subnet);
573
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
574
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
575
					break;
576
				}
577
				unset($network, $subnet);
578
			}
579
		}
580
	}
581
	if ($_POST['ipaddrv6']) {
582
		if (!is_ipaddrv6($_POST['ipaddrv6']))
583
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
584
		else {
585
			if (is_ipaddr_configured($_POST['ipaddrv6'], $if, true))
586
				$input_errors[] = gettext("This IPv6 address is being used by another interface or VIP.");
587

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

    
694
		if ($_POST['passphrase']) {
695
                	$passlen = strlen($_POST['passphrase']);
696
                	if ($passlen < 8 || $passlen > 64)
697
                        	$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
698
		}
699
	}
700
	if (!$input_errors) {
701
		if ($wancfg['ipaddr'] != $_POST['type']) {
702
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
703
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
704
				unset($a_ppps[$pppid]);
705
			} else if ($wancfg['ipaddrv6'] == "dhcp6") {
706
				$pid = find_dhcp6c_process($wancfg['if']);
707
				if($pid)
708
					posix_kill($pid, SIGTERM);
709
			} else if ($wancfg['ipaddr'] == "dhcp") {
710
				$pid = find_dhclient_process($wancfg['if']);
711
				if($pid)
712
					posix_kill($pid, SIGTERM);
713
			}
714
				
715
		}
716
		$ppp = array();
717
		if ($wancfg['ipaddr'] != "ppp")
718
			unset($wancfg['ipaddr']);
719
		if ($wancfg['ipaddrv6'] != "ppp")
720
			unset($wancfg['ipaddrv6']);
721
		unset($wancfg['subnet']);
722
		unset($wancfg['gateway']);
723
		unset($wancfg['subnetv6']);
724
		unset($wancfg['gatewayv6']);
725
		unset($wancfg['dhcphostname']);
726
		unset($wancfg['dhcp6-duid']);
727
		unset($wancfg['dhcp6-ia-pd-len']);
728
		unset($wancfg['track6-interface']);
729
		unset($wancfg['track6-prefix-id']);		
730
		unset($wancfg['prefix-6rd']);
731
		unset($wancfg['prefix-6rd-v4plen']);
732
		unset($wancfg['gateway-6rd']);
733
		unset($wancfg['pppoe_password']);
734
		unset($wancfg['pptp_username']);
735
		unset($wancfg['pptp_password']);
736
		unset($wancfg['provider']);
737
		unset($wancfg['ondemand']);
738
		unset($wancfg['timeout']);
739
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
740
			unset($wancfg['pppoe']['pppoe-reset-type']);
741
		unset($wancfg['local']);
742
		
743
		unset($wancfg['remote']);
744
		unset($a_ppps[$pppid]['apn']);
745
		unset($a_ppps[$pppid]['phone']);
746
		unset($a_ppps[$pppid]['localip']);
747
		unset($a_ppps[$pppid]['subnet']);
748
		unset($a_ppps[$pppid]['gateway']);
749
		unset($a_ppps[$pppid]['pppoe-reset-type']);
750
		unset($a_ppps[$pppid]['provider']);
751

    
752
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
753
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
754

    
755
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
756
		switch($_POST['type']) {
757
			case "staticv4":
758
				$wancfg['ipaddr'] = $_POST['ipaddr'];
759
				$wancfg['subnet'] = $_POST['subnet'];
760
				if ($_POST['gateway'] != "none") {
761
					$wancfg['gateway'] = $_POST['gateway'];
762
				}
763
				break;
764
			case "dhcp":
765
				$wancfg['ipaddr'] = "dhcp";
766
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
767
				$wancfg['alias-address'] = $_POST['alias-address'];
768
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
769
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
770
				if($gateway_item) {
771
					$a_gateways[] = $gateway_item;
772
				}
773
				break;
774
			case "ppp":
775
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
776
				$a_ppps[$pppid]['type'] = $_POST['type'];
777
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
778
				$a_ppps[$pppid]['ports'] = $_POST['port'];
779
				$a_ppps[$pppid]['username'] = $_POST['username'];
780
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
781
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
782
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
783
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
784
				$wancfg['ipaddr'] = $_POST['type'];
785
				unset($a_ppps[$pppid]['ondemand']);
786
				unset($a_ppps[$pppid]['idletimeout']);
787
				break;
788

    
789
			case "pppoe":
790
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
791
				$a_ppps[$pppid]['type'] = $_POST['type'];
792
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
793
				if (isset($_POST['ppp_port']))
794
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
795
				else
796
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
797
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
798
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
799
				if (!empty($_POST['provider']))
800
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
801
				else
802
					$a_ppps[$pppid]['provider'] = true;
803
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
804
				if (!empty($_POST['pppoe_idletimeout']))
805
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
806
				else
807
					unset($a_ppps[$pppid]['idletimeout']);
808

    
809
				if (!empty($_POST['pppoe-reset-type']))
810
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
811
				else
812
					unset($a_ppps[$pppid]['pppoe-reset-type']);
813
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
814
				$wancfg['ipaddr'] = $_POST['type'];
815
				if($gateway_item) {
816
					$a_gateways[] = $gateway_item;
817
				}
818

    
819
				break;
820
			case "pptp":
821
			case "l2tp":
822
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
823
				$a_ppps[$pppid]['type'] = $_POST['type'];
824
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
825
				if (isset($_POST['ppp_port']))
826
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
827
				else
828
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
829
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
830
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
831
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
832
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
833
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
834
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
835
				if (!empty($_POST['pptp_idletimeout']))
836
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
837
				else
838
					unset($a_ppps[$pppid]['idletimeout']);
839
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
840
				$wancfg['ipaddr'] = $_POST['type'];
841
				if($gateway_item) {
842
					$a_gateways[] = $gateway_item;
843
				}
844
				break;
845
			case "none":
846
				break;
847
		}
848
		switch($_POST['type6']) {
849
			case "staticv6":
850
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
851
				$wancfg['subnetv6'] = $_POST['subnetv6'];
852
				if ($_POST['gatewayv6'] != "none") {
853
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
854
				}
855
				break;
856
			case "slaac":
857
				$wancfg['ipaddrv6'] = "slaac";
858
				break;
859
			case "dhcp6":
860
				$wancfg['ipaddrv6'] = "dhcp6";
861
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
862
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
863
				if($gateway_item) {
864
					$a_gateways[] = $gateway_item;
865
				}
866
				break;
867
			case "6rd":
868
				$wancfg['ipaddrv6'] = "6rd";
869
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
870
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
871
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
872
				if($gateway_item) {
873
					$a_gateways[] = $gateway_item;
874
				}
875
				break;
876
			case "6to4":
877
				$wancfg['ipaddrv6'] = "6to4";
878
				break;
879
			case "track6":
880
				$wancfg['ipaddrv6'] = "track6";
881
				$wancfg['track6-interface'] = $_POST['track6-interface'];
882
				if ($_POST['track6-prefix-id--hex'] === "") {
883
					$wancfg['track6-prefix-id'] = "none";
884
				} else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
885
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
886
				} else {
887
					$wancfg['track6-prefix-id'] = "none";
888
				}
889
				break;
890
			case "none":
891
				break;
892
		}
893
		handle_pppoe_reset($_POST);
894

    
895
		if($_POST['blockpriv'] == "yes") {
896
			$wancfg['blockpriv'] = true;
897
		} else {
898
			unset($wancfg['blockpriv']);
899
		}
900
		if($_POST['blockbogons'] == "yes") {
901
			$wancfg['blockbogons'] = true;
902
		} else {
903
			unset($wancfg['blockbogons']);
904
		}
905
		$wancfg['spoofmac'] = $_POST['spoofmac'];
906
		if (empty($_POST['mtu'])) {
907
			unset($wancfg['mtu']);
908
		} else {
909
			$wancfg['mtu'] = $_POST['mtu'];
910
		}
911
		if (empty($_POST['mss'])) {
912
			unset($wancfg['mss']);
913
		} else {
914
			$wancfg['mss'] = $_POST['mss'];
915
		}
916
		if (empty($_POST['mediaopt'])) {
917
			unset($wancfg['media']);
918
			unset($wancfg['mediaopt']);
919
		} else {
920
			$mediaopts = explode(' ', $_POST['mediaopt']);	
921
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
922
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
923
			else { unset($wancfg['mediaopt']); }
924
		}
925
		if (isset($wancfg['wireless'])) {
926
			handle_wireless_post();
927
		}
928

    
929
		conf_mount_ro();
930
		write_config();
931

    
932
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
933
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
934
		} else {
935
			$toapplylist = array();
936
		}
937
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
938
		$toapplylist[$if]['ppps'] = $old_ppps;
939
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
940

    
941
		mark_subsystem_dirty('interfaces');
942

    
943
		/* regenerate cron settings/crontab file */
944
		configure_cron();
945

    
946
		header("Location: interfaces.php?if={$if}");
947
		exit;
948
	}
949

    
950
} // end if($_POST)
951

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

    
1093
function check_wireless_mode() {
1094
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1095

    
1096
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1097
		return;
1098

    
1099
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1100
		$clone_count = 1;
1101
	else
1102
		$clone_count = 0;
1103
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1104
		foreach ($config['wireless']['clone'] as $clone) {
1105
			if ($clone['if'] == $wlanbaseif)
1106
				$clone_count++;
1107
		}
1108
	}
1109
	if ($clone_count > 1) {
1110
		$old_wireless_mode = $wancfg['wireless']['mode'];
1111
		$wancfg['wireless']['mode'] = $_POST['mode'];
1112
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1113
			$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']]);
1114
		} else {
1115
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
1116
		}
1117
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1118
	}
1119
}
1120

    
1121
// Find all possible media options for the interface
1122
$mediaopts_list = array();
1123
$intrealname = $config['interfaces'][$if]['if'];
1124
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1125
foreach ($mediaopts as $mediaopt){
1126
	preg_match("/media (.*)/", $mediaopt, $matches);
1127
 	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1128
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1129
 		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1130
	}else{
1131
		// there is only media like "media 1000baseT"
1132
		array_push($mediaopts_list, $matches[1]);
1133
	}
1134
}
1135

    
1136
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1137
$shortcut_section = "interfaces";
1138

    
1139
$closehead = false;
1140
include("head.inc");
1141
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1142
$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"));
1143

    
1144
?>
1145

    
1146
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1147
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1148
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1149
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1150

    
1151
<script type="text/javascript">
1152
	function updateType(t) {
1153
		switch(t) {
1154
			case "none": {
1155
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1156
				break;
1157
			}
1158
			case "staticv4": {
1159
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1160
				break;
1161
			}
1162
			case "dhcp": {
1163
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1164
				break;
1165
			}
1166
			case "ppp": {
1167
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1168
				country_list();
1169
				break;
1170
			}
1171
			case "pppoe": {
1172
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1173
				break;
1174
			}
1175
			case "l2tp":
1176
			case "pptp": {
1177
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1178
				jQuery('#pptp').show();
1179
				break;
1180
			}
1181
		}
1182
		if (t != "l2tp" && t != "pptp")
1183
			jQuery('#'+t).show();
1184
	}
1185
	function updateTypeSix(t) {
1186
		switch(t) {
1187
			case "none": {
1188
				jQuery('#staticv6, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1189
				break;
1190
			}
1191
			case "staticv6": {
1192
				jQuery('#none, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1193
				break;
1194
			}
1195
			case "slaac": {
1196
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #dhcp6').hide();
1197
				break;
1198
			}
1199
			case "dhcp6": {
1200
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #slaac').hide();
1201
				break;
1202
			}
1203
			case "6rd": {
1204
				jQuery('#none, #dhcp6, #staticv6, #6to4, #track6, #slaac').hide();
1205
				break;
1206
			}
1207
			case "6to4": {
1208
				jQuery('#none, #dhcp6, #staticv6, #6rd, #track6, #slaac').hide();
1209
				break;
1210
			}
1211
			case "track6": {
1212
				jQuery('#none, #dhcp6, #staticv6, #6rd, #6to4, #slaac').hide();
1213
				break;
1214
			}
1215
		}
1216
		if (t != "l2tp" && t != "pptp")
1217
			jQuery('#'+t).show();
1218
	}
1219

    
1220
	function show_allcfg(obj) {
1221
		if (obj.checked)
1222
			jQuery('#allcfg').show();
1223
		else
1224
			jQuery('#allcfg').hide();
1225
	}
1226

    
1227
	function show_reset_settings(reset_type) {
1228
		if (reset_type == 'preset') {
1229
			jQuery('#pppoepresetwrap').show();
1230
			jQuery('#pppoecustomwrap').hide();
1231
		}
1232
		else if (reset_type == 'custom') {
1233
			jQuery('#pppoecustomwrap').show();
1234
			jQuery('#pppoepresetwrap').hide();
1235
		} else {
1236
			jQuery('#pppoecustomwrap').hide();
1237
			jQuery('#pppoepresetwrap').hide();
1238
		}
1239
	}
1240
	function show_mon_config() {
1241
		jQuery("#showmonbox").html('');
1242
		jQuery('#showmon').css('display','block');
1243
	}
1244

    
1245
	function openwindow(url) {
1246
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1247
		if (oWin==null || typeof(oWin)=="undefined")
1248
			return false;
1249
		else
1250
			return true;
1251
	}
1252
	function country_list() {
1253
		jQuery('#country').children().remove();
1254
		jQuery('#provider').children().remove();
1255
		jQuery('#providerplan').children().remove();
1256
		jQuery.ajax("getserviceproviders.php",{
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
					country = value.split(":");
1263
					option.text = country[0];
1264
					option.value = country[1];
1265
					jQuery('#country').append(option);
1266
				});
1267
			}
1268
		});
1269
		jQuery('#trcountry').css('display',"table-row");
1270
	}
1271

    
1272
	function providers_list() {
1273
		jQuery('#provider').children().remove();
1274
		jQuery('#providerplan').children().remove();
1275
		jQuery.ajax("getserviceproviders.php",{
1276
			type: 'post',
1277
			data: {country : jQuery('#country').val()},
1278
			success: function(response) {
1279
				var responseTextArr = response.split("\n");
1280
				responseTextArr.sort();
1281
				responseTextArr.each( function(value) {
1282
					var option = new Element('option');
1283
					option.text = value;
1284
					option.value = value;
1285
					jQuery('#provider').append(option);
1286
				});
1287
			}
1288
		});
1289
		jQuery('#trprovider').css("display","table-row");
1290
		jQuery('#trproviderplan').css("display","none");
1291
	}
1292

    
1293
	function providerplan_list() {
1294
		jQuery('#providerplan').children().remove();
1295
		jQuery('#providerplan').append( new Element('option') );
1296
		jQuery.ajax("getserviceproviders.php",{
1297
			type: 'post',
1298
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1299
			success: function(response) {
1300
				var responseTextArr = response.split("\n");
1301
				responseTextArr.sort();
1302
				responseTextArr.each( function(value) {
1303
					if(value != "") {
1304
						providerplan = value.split(":");
1305

    
1306
						var option = new Element('option');
1307
						option.text = providerplan[0] + " - " + providerplan[1];
1308
						option.value = providerplan[1];
1309
						jQuery('#providerplan').append(option);
1310
					}
1311
				});
1312
			}
1313
		});
1314
		jQuery('#trproviderplan').css("display","table-row");
1315
	}
1316

    
1317
	function prefill_provider() {
1318
		jQuery.ajax("getserviceproviders.php",{
1319
			type: 'post',
1320
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
1321
			success: function(data,textStatus,response) {
1322
				var xmldoc = response.responseXML;
1323
				var provider = xmldoc.getElementsByTagName('connection')[0];
1324
				jQuery('#username').val('');
1325
				jQuery('#password').val('');
1326
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1327
					jQuery('#phone').val('#777');
1328
					jQuery('#apn').val('');
1329
				} else {
1330
					jQuery('#phone').val('*99#');
1331
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1332
				}
1333
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1334
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1335
				jQuery('#username').val(username);
1336
				jQuery('#password').val(password);
1337
			}
1338
		});
1339
	}
1340

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

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

    
2686
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2687
						<tr>
2688
							<td width="22%" valign="top">
2689
								&nbsp;
2690
							</td>
2691
							<td width="78%">
2692
								<br/>
2693
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2694
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2695
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2696
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2697
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2698
								<?php endif; ?>
2699
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2700
							</td>
2701
						</tr>
2702
					</table>
2703
				</td>
2704
			</tr>
2705
		</table>
2706
		<!--
2707
		</div>
2708
		</td></tr>
2709
		</table>
2710
		-->
2711
	</form>
2712
	<script type="text/javascript">
2713
		var gatewayip;
2714
		var name;
2715
		var gatewayipv6;
2716
		var namev6;
2717
		function show_add_gateway() {
2718
			document.getElementById("addgateway").style.display = '';
2719
			document.getElementById("addgwbox").style.display = 'none';
2720
			document.getElementById("gateway").style.display = 'none';
2721
			document.getElementById("save").style.display = 'none';
2722
			document.getElementById("cancel").style.display = 'none';
2723
			document.getElementById("gwsave").style.display = '';
2724
			document.getElementById("gwcancel").style.display = '';
2725
			jQuery('#notebox').html("");
2726
		}
2727
		function show_add_gateway_v6() {
2728
			document.getElementById("addgatewayv6").style.display = '';
2729
			document.getElementById("addgwboxv6").style.display = 'none';
2730
			document.getElementById("gatewayv6").style.display = 'none';
2731
			document.getElementById("save").style.display = 'none';
2732
			document.getElementById("cancel").style.display = 'none';
2733
			document.getElementById("gwsave").style.display = '';
2734
			document.getElementById("gwcancel").style.display = '';
2735
			jQuery('#noteboxv6').html("");
2736
		}
2737
		function hide_add_gateway() {
2738
			document.getElementById("addgateway").style.display = 'none';
2739
			document.getElementById("addgwbox").style.display = '';
2740
			document.getElementById("gateway").style.display = '';
2741
			document.getElementById("save").style.display = '';
2742
			document.getElementById("cancel").style.display = '';
2743
			document.getElementById("gwsave").style.display = '';
2744
			document.getElementById("gwcancel").style.display = '';
2745
			jQuery('#status').html('');
2746
		}
2747
		function hide_add_gateway_v6() {
2748
			document.getElementById("addgatewayv6").style.display = 'none';
2749
			document.getElementById("addgwboxv6").style.display = '';
2750
			document.getElementById("gatewayv6").style.display = '';
2751
			document.getElementById("save").style.display = '';
2752
			document.getElementById("cancel").style.display = '';
2753
			document.getElementById("gwsave").style.display = '';
2754
			document.getElementById("gwcancel").style.display = '';
2755
			jQuery('#statusv6').html('');
2756
		}
2757
		function hide_add_gatewaysave() {
2758
			document.getElementById("addgateway").style.display = 'none';
2759
			jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2760
			var iface = jQuery('#if').val();
2761
			name = jQuery('#name').val();
2762
			var descr = jQuery('#gatewaydescr').val();
2763
			gatewayip = jQuery('#gatewayip').val();
2764

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