Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
95

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

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

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

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

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

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

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

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

    
253
// print_r($pconfig);
254

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

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

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

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

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

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

    
371
		clear_subsystem_dirty('interfaces');
372

    
373
		filter_configure();
374

    
375
		enable_rrd_graphing();
376

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

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

    
412
	/* filter out spaces from descriptions  */
413
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
414

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

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

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

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

    
558
			foreach ($staticroutes as $route_subnet) {
559
				list($network, $subnet) = explode("/", $route_subnet);
560
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
561
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
562
					break;
563
				}
564
				unset($network, $subnet);
565
			}
566
		}
567
	}
568
	if ($_POST['ipaddrv6']) {
569
		if (!is_ipaddrv6($_POST['ipaddrv6']))
570
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
571
		else {
572
			if (is_ipaddr_configured($_POST['ipaddrv6'], $if, true))
573
				$input_errors[] = gettext("This IPv6 address is being used by another interface or VIP.");
574

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

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

    
739
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
740
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
741

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

    
776
			case "pppoe":
777
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
778
				$a_ppps[$pppid]['type'] = $_POST['type'];
779
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
780
				if (isset($_POST['ppp_port']))
781
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
782
				else
783
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
784
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
785
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
786
				if (!empty($_POST['provider']))
787
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
788
				else
789
					$a_ppps[$pppid]['provider'] = true;
790
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
791
				if (!empty($_POST['pppoe_idletimeout']))
792
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
793
				else
794
					unset($a_ppps[$pppid]['idletimeout']);
795

    
796
				if (!empty($_POST['pppoe-reset-type']))
797
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
798
				else
799
					unset($a_ppps[$pppid]['pppoe-reset-type']);
800
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
801
				$wancfg['ipaddr'] = $_POST['type'];
802
				if($gateway_item) {
803
					$a_gateways[] = $gateway_item;
804
				}
805

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

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

    
916
		conf_mount_ro();
917
		write_config();
918

    
919
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
920
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
921
		} else {
922
			$toapplylist = array();
923
		}
924
		$toapplylist[$if] = $old_wancfg;
925
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
926

    
927
		mark_subsystem_dirty('interfaces');
928

    
929
		/* regenerate cron settings/crontab file */
930
		configure_cron();
931

    
932
		header("Location: interfaces.php?if={$if}");
933
		exit;
934
	}
935

    
936
} // end if($_POST)
937

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

    
1079
function check_wireless_mode() {
1080
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1081

    
1082
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1083
		return;
1084

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

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

    
1122
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1123
$shortcut_section = "interfaces";
1124

    
1125
$closehead = false;
1126
include("head.inc");
1127
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1128
$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"));
1129

    
1130
?>
1131

    
1132
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1133
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1134
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1135
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1136

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

    
1206
	function show_allcfg(obj) {
1207
		if (obj.checked)
1208
			jQuery('#allcfg').show();
1209
		else
1210
			jQuery('#allcfg').hide();
1211
	}
1212

    
1213
	function show_reset_settings(reset_type) {
1214
		if (reset_type == 'preset') {
1215
			jQuery('#pppoepresetwrap').show();
1216
			jQuery('#pppoecustomwrap').hide();
1217
		}
1218
		else if (reset_type == 'custom') {
1219
			jQuery('#pppoecustomwrap').show();
1220
			jQuery('#pppoepresetwrap').hide();
1221
		} else {
1222
			jQuery('#pppoecustomwrap').hide();
1223
			jQuery('#pppoepresetwrap').hide();
1224
		}
1225
	}
1226
	function show_mon_config() {
1227
		jQuery("#showmonbox").html('');
1228
		jQuery('#showmon').css('display','block');
1229
	}
1230

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

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

    
1279
	function providerplan_list() {
1280
		jQuery('#providerplan').children().remove();
1281
		jQuery('#providerplan').append( new Element('option') );
1282
		jQuery.ajax("getserviceproviders.php",{
1283
			type: 'post',
1284
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1285
			success: function(response) {
1286
				var responseTextArr = response.split("\n");
1287
				responseTextArr.sort();
1288
				responseTextArr.each( function(value) {
1289
					if(value != "") {
1290
						providerplan = value.split(":");
1291

    
1292
						var option = new Element('option');
1293
						option.text = providerplan[0] + " - " + providerplan[1];
1294
						option.value = providerplan[1];
1295
						jQuery('#providerplan').append(option);
1296
					}
1297
				});
1298
			}
1299
		});
1300
		jQuery('#trproviderplan').css("display","table-row");
1301
	}
1302

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

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

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

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

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