Project

General

Profile

Download (125 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

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

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

    
124
		if (isset($a_ppps[$pppid]['pppoe-reset-type'])) {
125
			$pconfig['pppoe-reset-type'] = $a_ppps[$pppid]['pppoe-reset-type'];
126
			$itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']);
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
				$resetTime_a = explode(" ", $resetTime);
136
				$pconfig['pppoe_pr_custom'] = true;
137
				$pconfig['pppoe_resetminute'] = $resetTime_a[0];
138
				$pconfig['pppoe_resethour'] = $resetTime_a[1];
139
				/*  just initialize $pconfig['pppoe_resetdate'] if the
140
				 *  coresponding item contains appropriate numeric values.
141
				 */
142
				if ($resetTime_a[2] <> "*" && $resetTime_a[3] <> "*")
143
					$pconfig['pppoe_resetdate'] = "{$resetTime_a[3]}/{$resetTime_a[2]}/" . date("Y");
144
			} else if ($a_ppps[$pppid]['pppoe-reset-type'] == "preset") {
145
				$pconfig['pppoe_pr_preset'] = true;
146
				switch ($resetTime) {
147
					case CRON_MONTHLY_PATTERN:
148
						$pconfig['pppoe_monthly'] = true;
149
						break;
150
					case CRON_WEEKLY_PATTERN:
151
						$pconfig['pppoe_weekly'] = true;
152
						break;
153
					case CRON_DAILY_PATTERN:
154
						$pconfig['pppoe_daily'] = true;
155
						break;
156
					case CRON_HOURLY_PATTERN:
157
						$pconfig['pppoe_hourly'] = true;
158
						break;
159
				}
160
			}
161
		}// End force pppoe reset at specific time
162
	}// End if type == pppoe
163
	else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp"){
164
		$pconfig['pptp_username'] = $a_ppps[$pppid]['username'];
165
		$pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']);
166
		$pconfig['pptp_local'] = explode(",",$a_ppps[$pppid]['localip']);
167
		$pconfig['pptp_subnet'] = explode(",",$a_ppps[$pppid]['subnet']);
168
		$pconfig['pptp_remote'] = explode(",",$a_ppps[$pppid]['gateway']);
169
		$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
170
		$pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout'];
171
	}
172
} else {
173
	$pconfig['ptpid'] = interfaces_ptpid_next();
174
	$pppid = count($a_ppps);
175
}
176
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
177
$pconfig['alias-address'] = $wancfg['alias-address'];
178
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
179
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
180
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
181
$pconfig['enable'] = isset($wancfg['enable']);
182

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

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

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

    
255
// print_r($pconfig);
256

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

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

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

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

    
357
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
358
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
359
			foreach ($toapplylist as $ifapply => $values) {
360
				if (isset($config['interfaces'][$ifapply]['enable'])) {
361
					/* check if any old addresses need purging */
362
					if(is_ipaddrv6($values['ipaddrv6'])) {
363
						$realif = get_real_interface("$ifapply");
364
						log_error("removing old v6 address {$values['ipaddrv6']} on {$realif}");
365
						mwexec("/sbin/ifconfig {$realif} inet6 {$values['ipaddrv6']} -alias");
366
					}
367
					interface_reconfigure($ifapply, true);
368
				} else {
369

    
370
					interface_bring_down($ifapply);
371
				}
372
			}
373
		}
374
		/* restart snmp so that it binds to correct address */
375
		services_snmpd_configure();
376

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

    
380
		clear_subsystem_dirty('staticroutes');
381

    
382
		filter_configure();
383

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

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

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

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

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

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

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

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

    
717
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
718
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
719

    
720
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
721
		switch($_POST['type']) {
722
			case "staticv4":
723
				$wancfg['ipaddr'] = $_POST['ipaddr'];
724
				$wancfg['subnet'] = $_POST['subnet'];
725
				if ($_POST['gateway'] != "none") {
726
					$wancfg['gateway'] = $_POST['gateway'];
727
				}
728
				break;
729
			case "dhcp":
730
				$wancfg['ipaddr'] = "dhcp";
731
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
732
				$wancfg['alias-address'] = $_POST['alias-address'];
733
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
734
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
735
				if($gateway_item) {
736
					$a_gateways[] = $gateway_item;
737
				}
738
				break;
739
			case "ppp":
740
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
741
				$a_ppps[$pppid]['type'] = $_POST['type'];
742
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
743
				$a_ppps[$pppid]['ports'] = $_POST['port'];
744
				$a_ppps[$pppid]['username'] = $_POST['username'];
745
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
746
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
747
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
748
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
749
				$wancfg['ipaddr'] = $_POST['type'];
750
				unset($a_ppps[$pppid]['ondemand']);
751
				unset($a_ppps[$pppid]['idletimeout']);
752
				break;
753

    
754
			case "pppoe":
755
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
756
				$a_ppps[$pppid]['type'] = $_POST['type'];
757
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
758
				if (isset($_POST['ppp_port']))
759
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
760
				else
761
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
762
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
763
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
764
				if (!empty($_POST['provider']))
765
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
766
				else
767
					$a_ppps[$pppid]['provider'] = true;
768
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
769
				if (!empty($_POST['idletimeout']))
770
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
771
				else
772
					unset($a_ppps[$pppid]['idletimeout']);
773

    
774
				if (!empty($_POST['pppoe-reset-type']))
775
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
776
				else
777
					unset($a_ppps[$pppid]['pppoe-reset-type']);
778
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
779
				$wancfg['ipaddr'] = $_POST['type'];
780
				if($gateway_item) {
781
					$a_gateways[] = $gateway_item;
782
				}
783

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

    
860
		if($_POST['blockpriv'] == "yes") {
861
			$wancfg['blockpriv'] = true;
862
		} else {
863
			unset($wancfg['blockpriv']);
864
		}
865
		if($_POST['blockbogons'] == "yes") {
866
			$wancfg['blockbogons'] = true;
867
		} else {
868
			unset($wancfg['blockbogons']);
869
		}
870
		$wancfg['spoofmac'] = $_POST['spoofmac'];
871
		if (empty($_POST['mtu'])) {
872
			unset($wancfg['mtu']);
873
		} else {
874
			$wancfg['mtu'] = $_POST['mtu'];
875
		}
876
		if (empty($_POST['mss'])) {
877
			unset($wancfg['mss']);
878
		} else {
879
			$wancfg['mss'] = $_POST['mss'];
880
		}
881
		if (empty($_POST['mediaopt'])) {
882
			unset($wancfg['media']);
883
			unset($wancfg['mediaopt']);
884
		} else {
885
			$mediaopts = explode(' ', $_POST['mediaopt']);	
886
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
887
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
888
			else { unset($wancfg['mediaopt']); }
889
		}
890
		if (isset($wancfg['wireless'])) {
891
			handle_wireless_post();
892
		}
893

    
894
		conf_mount_ro();
895
		write_config();
896

    
897
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
898
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
899
		} else {
900
			$toapplylist = array();
901
		}
902
		$toapplylist[$if] = array();
903
		/* we need to be able remove IP aliases for IPv6 */
904
		if(($old_wancfg['ipaddrv6'] != $wancfg['ipaddrv6']) && (is_ipaddrv6($old_wancfg['ipaddrv6']))) {
905
			$toapplylist[$if]['ipaddrv6'] = $old_wancfg['ipaddrv6'];
906
		}
907
		
908
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
909

    
910
		mark_subsystem_dirty('interfaces');
911

    
912
		/* regenerate cron settings/crontab file */
913
		configure_cron();
914

    
915
		header("Location: interfaces.php?if={$if}");
916
		exit;
917
	}
918

    
919
} // end if($_POST)
920

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

    
1058
function check_wireless_mode() {
1059
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1060

    
1061
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1062
		return;
1063

    
1064
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1065
		$clone_count = 1;
1066
	else
1067
		$clone_count = 0;
1068
	if (is_array($config['wireless']['clone'])) {
1069
		foreach ($config['wireless']['clone'] as $clone) {
1070
			if ($clone['if'] == $wlanbaseif)
1071
				$clone_count++;
1072
		}
1073
	}
1074
	if ($clone_count > 1) {
1075
		$old_wireless_mode = $wancfg['wireless']['mode'];
1076
		$wancfg['wireless']['mode'] = $_POST['mode'];
1077
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1078
			$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']]);
1079
		} else {
1080
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
1081
		}
1082
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1083
	}
1084
}
1085

    
1086
// Find all possible media options for the interface
1087
$mediaopts_list = array();
1088
$intrealname = $config['interfaces'][$if]['if'];
1089
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1090
foreach ($mediaopts as $mediaopt){
1091
	preg_match("/media (.*)/", $mediaopt, $matches);
1092
 	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1093
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1094
 		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1095
	}else{
1096
		// there is only media like "media 1000baseT"
1097
		array_push($mediaopts_list, $matches[1]);
1098
	}
1099
}
1100

    
1101
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1102
$statusurl = "status_interfaces.php";
1103

    
1104
$closehead = false;
1105
include("head.inc");
1106
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1107
$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"));
1108

    
1109
?>
1110

    
1111
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
1112
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1113
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1114
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1115
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1116

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

    
1186
	function show_allcfg(obj) {
1187
		if (obj.checked)
1188
			jQuery('#allcfg').show();
1189
		else
1190
			jQuery('#allcfg').hide();
1191
	}
1192

    
1193
	function show_reset_settings(reset_type) {
1194
		if (reset_type == 'preset') {
1195
			jQuery('#pppoepresetwrap').show();
1196
			jQuery('#pppoecustomwrap').hide();
1197
		}
1198
		else if (reset_type == 'custom') {
1199
			jQuery('#pppoecustomwrap').show();
1200
			jQuery('#pppoepresetwrap').hide();
1201
		} else {
1202
			jQuery('#pppoecustomwrap').hide();
1203
			jQuery('#pppoepresetwrap').hide();
1204
		}
1205
	}
1206
	function show_mon_config() {
1207
		jQuery("#showmonbox").html('');
1208
		jQuery('#showmon').css('display','block');
1209
	}
1210

    
1211
	function openwindow(url) {
1212
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1213
		if (oWin==null || typeof(oWin)=="undefined")
1214
			return false;
1215
		else
1216
			return true;
1217
	}
1218
	function country_list() {
1219
		jQuery('#country').children().remove();
1220
		jQuery('#provider').children().remove();
1221
		jQuery('#providerplan').children().remove();
1222
		jQuery.ajax("getserviceproviders.php",{
1223
			success: function(response) {
1224
				var responseTextArr = response.split("\n");
1225
				responseTextArr.sort();
1226
				responseTextArr.each( function(value) {
1227
					var option = new Element('option');
1228
					country = value.split(":");
1229
					option.text = country[0];
1230
					option.value = country[1];
1231
					jQuery('#country').append(option);
1232
				});
1233
			}
1234
		});
1235
		jQuery('#trcountry').css('display',"table-row");
1236
	}
1237

    
1238
	function providers_list() {
1239
		jQuery('#provider').children().remove();
1240
		jQuery('#providerplan').children().remove();
1241
		jQuery.ajax("getserviceproviders.php",{
1242
			type: 'post',
1243
			data: {country : jQuery('#country').val()},
1244
			success: function(response) {
1245
				var responseTextArr = response.split("\n");
1246
				responseTextArr.sort();
1247
				responseTextArr.each( function(value) {
1248
					var option = new Element('option');
1249
					option.text = value;
1250
					option.value = value;
1251
					jQuery('#provider').append(option);
1252
				});
1253
			}
1254
		});
1255
		jQuery('#trprovider').css("display","table-row");
1256
		jQuery('#trproviderplan').css("display","none");
1257
	}
1258

    
1259
	function providerplan_list() {
1260
		jQuery('#providerplan').children().remove();
1261
		jQuery('#providerplan').append( new Element('option') );
1262
		jQuery.ajax("getserviceproviders.php",{
1263
			type: 'post',
1264
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1265
			success: function(response) {
1266
				var responseTextArr = response.split("\n");
1267
				responseTextArr.sort();
1268
				responseTextArr.each( function(value) {
1269
					if(value != "") {
1270
						providerplan = value.split(":");
1271

    
1272
						var option = new Element('option');
1273
						option.text = providerplan[0] + " - " + providerplan[1];
1274
						option.value = providerplan[1];
1275
						jQuery('#providerplan').append(option);
1276
					}
1277
				});
1278
			}
1279
		});
1280
		jQuery('#trproviderplan').css("display","table-row");
1281
	}
1282

    
1283
	function prefill_provider() {
1284
		jQuery.ajax("getserviceproviders.php",{
1285
			type: 'post',
1286
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
1287
			success: function(data,textStatus,response) {
1288
				var xmldoc = response.responseXML;
1289
				var provider = xmldoc.getElementsByTagName('connection')[0];
1290
				jQuery('#username').val('');
1291
				jQuery('#password').val('');
1292
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1293
					jQuery('#phone').val('#777');
1294
					jQuery('#apn').val('');
1295
				} else {
1296
					jQuery('#phone').val('*99#');
1297
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1298
				}
1299
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1300
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1301
				jQuery('#username').val(username);
1302
				jQuery('#password').val(password);
1303
			}
1304
		});
1305
	}
1306

    
1307
</script>
1308
</head>
1309
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1310
	<?php include("fbegin.inc"); ?>
1311
	<form action="interfaces.php" method="post" name="iform" id="iform">
1312
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1313
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1314
		<?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 />
1315
		<?php endif; ?>
1316
		<?php if ($savemsg) print_info_box($savemsg); ?>
1317
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
1318
			<tr>
1319
				<td id="mainarea">
1320
					<div class="tabcont">
1321
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1322
						<tr>
1323
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1324
						</tr>
1325
						<tr>
1326
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1327
							<td width="78%" class="vtable">
1328
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked"; ?> onClick="show_allcfg(this);">
1329
							<strong><?=gettext("Enable Interface"); ?></strong>
1330
							</td>
1331
						</tr>
1332
					</table>
1333
					<div style="display:none;" name="allcfg" id="allcfg">
1334
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1335
						<tr>
1336
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1337
							<td width="78%" class="vtable">
1338
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
1339
								<br><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1340
							</td>
1341
						</tr>
1342
						<tr>
1343
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1344
							<td class="vtable">
1345
								<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
1346
								<?php
1347
									foreach ($types4 as $key => $opt) {
1348
										echo "<option onClick=\"updateType('{$key}');\"";
1349
										if ($key == $pconfig['type'])
1350
											echo " selected";
1351
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1352
										echo "</option>";
1353
									}
1354
								?>
1355
								</select>
1356
							</td>
1357
						</tr>
1358
						<tr>
1359
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1360
							<td class="vtable">
1361
								<select name="type6" onChange="updateTypeSix(this.value);" class="formselect" id="type6">
1362
								<?php
1363
									foreach ($types6 as $key => $opt) {
1364
										echo "<option onClick=\"updateTypeSix('{$key}');\"";
1365
										if ($key == $pconfig['type6'])
1366
											echo " selected";
1367
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1368
										echo "</option>";
1369
									}
1370
								?>
1371
								</select>
1372
							</td>
1373
						</tr>
1374
						<tr>
1375
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1376
							<td class="vtable">
1377
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
1378
								<?php
1379
									$ip = getenv('REMOTE_ADDR');
1380
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1381
									$mac = str_replace("\n","",$mac);
1382
									if($mac):
1383
								?>
1384
									<a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1385
								<?php endif; ?>
1386
								<br>
1387
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1388
								"address of this interface"); ?><br>
1389
								<?=gettext("(may be required with some cable connections)"); ?><br>
1390
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1391
								"or leave blank"); ?>
1392
							</td>
1393
						</tr>
1394
						<tr>
1395
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1396
							<td class="vtable">
1397
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
1398
								<br>
1399
								<?=gettext("If you leave this field blank, the adapter's default MTU will " .
1400
								"be used. This is typically 1500 bytes but can vary in some circumstances."); ?>
1401
							</td>
1402
						</tr>
1403
						<tr>
1404
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1405
							<td class="vtable">
1406
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>">
1407
								<br>
1408
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1409
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1410
								"header size) will be in effect."); ?>
1411
							</td>
1412
						</tr>
1413
						<?php 
1414
						if (count($mediaopts_list) > 0){
1415
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1416
						echo "<tr>";
1417
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1418
							echo '<td class="vtable">';
1419
                                			echo '<div id="showadvmediabox"';
1420
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1421
								else echo '>';
1422
								echo '<input type="button" onClick="show_advanced_media()" value="' . gettext("Advanced") . '"></input> - ' . gettext("Show advanced option");
1423
							echo "</div>";
1424
							echo '<div id="showmediaadv" ';
1425
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1426
							else echo '>';
1427
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1428
								print "<option value=\"\">Default (no preference, typically autoselect)</option>";
1429
								print "<option value=\"\">------- Media Supported by this interface -------</option>";
1430
								foreach($mediaopts_list as $mediaopt){
1431
									if ($mediaopt != rtrim($mediaopt_from_config)){
1432
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1433
									} else {
1434
										print "<option value=\"$mediaopt\" selected>" . gettext("$mediaopt") . "</option>";
1435
									}
1436
								}
1437
								echo '</select><br>';
1438
								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.");
1439
						echo '</div>';
1440
							echo '</td>';
1441
						echo '</tr>';
1442
						}
1443
						?>
1444
						<tr>
1445
							<td colspan="2" valign="top" height="16"></td>
1446
						</tr>
1447
						<tr style="display:none;" name="none" id="none">
1448
						</tr>
1449
						<tr style="display:none;" name="staticv4" id="staticv4">
1450
							<td colspan="2" style="padding:0px;">
1451
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1452
									<tr>
1453
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1454
									</tr>
1455
									<tr>
1456
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1457
										<td width="78%" class="vtable">
1458
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
1459
											/
1460
											<select name="subnet" class="formselect" id="subnet">
1461
												<?php
1462
												for ($i = 32; $i > 0; $i--) {
1463
													if($i <> 31) {
1464
														echo "<option value=\"{$i}\" ";
1465
														if ($i == $pconfig['subnet']) echo "selected";
1466
														echo ">" . $i . "</option>";
1467
													}
1468
												}
1469
												?>
1470
											</select>
1471
										</td>
1472
									</tr>
1473
									<tr>
1474
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway"); ?></td>
1475
										<td width="78%" class="vtable">
1476
											<select name="gateway" class="formselect" id="gateway">
1477
												<option value="none" selected><?=gettext("None"); ?></option>
1478
													<?php
1479
													if(count($a_gateways) > 0) {
1480
														foreach ($a_gateways as $gateway) {
1481
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1482
													?>
1483
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
1484
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1485
															</option>
1486
													<?php
1487
															}
1488
														}
1489
													}
1490
													?>
1491
											</select>
1492
											- or  <strong><a OnClick="show_add_gateway();" href="#"><?=gettext("add a new one."); ?></a></strong>
1493
											<br/>
1494
											<div id='addgwbox'>
1495
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add one using the link above"); ?>
1496
											</div>
1497
											<div id='notebox'>
1498
											</div>
1499
											<div id="status">
1500
											</div>
1501
											<div style="display:none" id="addgateway" name="addgateway">
1502
												<p>
1503
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1504
													<tr>
1505
														<td>
1506
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1507
																<tr><td>&nbsp;</td>
1508
																<tr>
1509
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1510
																</tr>
1511
																<tr><td>&nbsp;</td>
1512
																<?php
1513
																if($if == "wan" || $if == "WAN")
1514
																	$checked = " CHECKED";
1515
																?>
1516
																<tr>
1517
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
1518
																</tr>
1519
																<tr>
1520
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td>
1521
																</tr>
1522
																<tr>
1523
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></td><td><input id="gatewayip" name="gatewayip"></td>
1524
																</tr>
1525
																<tr>
1526
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1527
																</tr>
1528
																<tr><td>&nbsp;</td>
1529
																<tr>
1530
																	<td>&nbsp;</td>
1531
																	<td>
1532
																		<center>
1533
																			<div id='savebuttondiv'>
1534

    
1535

    
1536
																				<input id="gwsave" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave();'>
1537
																				<input id="gwcancel" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway();'>
1538
																			</div>
1539
																		</center>
1540
																	</td>
1541
																</tr>
1542
																<tr><td>&nbsp;</td></tr>
1543
															</table>
1544
														</td>
1545
													</tr>
1546
												</table>
1547
												<p/>
1548
											</div>
1549
										</td>
1550
									</tr>
1551
								</table>
1552
							</td>
1553
						</tr>
1554
						<tr style="display:none;" name="staticv6" id="staticv6">
1555
							<td colspan="2" style="padding:0px;">
1556
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1557
									<tr>
1558
										<td colspan="2" valign="top">&nbsp;</td>
1559
									</tr>
1560
									<tr>
1561
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1562
									</tr>
1563
									<tr>
1564
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1565
										<td width="78%" class="vtable">
1566
											<input name="ipaddrv6" type="text" class="formfld unknown ipv4v6" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>">
1567
											/
1568
											<select name="subnetv6" class="formselect ipv4v6" id="subnetv6">
1569
												<?php
1570
												for ($i = 128; $i > 0; $i--) {
1571
													if($i <> 127) {
1572
														echo "<option value=\"{$i}\" ";
1573
														if ($i == $pconfig['subnetv6']) echo "selected";
1574
														echo ">" . $i . "</option>";
1575
													}
1576
												}
1577
												?>
1578
											</select>
1579
										</td>
1580
									</tr>
1581
									<tr>
1582
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway IPv6"); ?></td>
1583
										<td width="78%" class="vtable">
1584
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1585
												<option value="none" selected><?=gettext("None"); ?></option>
1586
													<?php
1587
													if(count($a_gateways) > 0) {
1588
														foreach ($a_gateways as $gateway) {
1589
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1590
													?>
1591
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected"; ?>>
1592
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1593
															</option>
1594
													<?php
1595
															}
1596
														}
1597
													}
1598
													?>
1599
											</select>
1600
											- or <strong><a OnClick="show_add_gateway_v6();" href="#"><?=gettext("add a new one."); ?></a></strong>
1601
											<br/>
1602
											<div id='addgwboxv6'>
1603
											<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above"); ?>
1604
											</div>
1605
											<div id='noteboxv6'>
1606
											</div>
1607
											<div id="statusv6">
1608
											</div>
1609
											<div style="display:none" id="addgatewayv6" name="addgatewayv6">
1610
												<p>
1611
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1612
													<tr>
1613
														<td>
1614
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1615
																<tr><td>&nbsp;</td>
1616
																<tr>
1617
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1618
																</tr>
1619
																<tr><td>&nbsp;</td>
1620
																<?php
1621
																if($if == "wan" || $if == "WAN")
1622
																	$checked = " CHECKED";
1623
																?>
1624
																<tr>
1625
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?>></td>
1626
																</tr>
1627
																<tr>
1628
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>"></td>
1629
																</tr>
1630
																<tr>
1631
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></td><td><input id="gatewayipv6" name="gatewayipv6"></td>
1632
																</tr>
1633
																<tr>
1634
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescrv6" name="gatewaydescrv6"></td>
1635
																</tr>
1636
																<tr><td>&nbsp;</td>
1637
																<tr>
1638
																	<td>&nbsp;</td>
1639
																	<td>
1640
																		<center>
1641
																			<div id='savebuttondivv6'>
1642
																				<input id="gwsavev6" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave_v6();'>
1643
																				<input id="gwcancelv6" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway_v6();'>
1644
																			</div>
1645
																		</center>
1646
																	</td>
1647
																</tr>
1648
																<tr><td>&nbsp;</td></tr>
1649
															</table>
1650
														</td>
1651
													</tr>
1652
												</table>
1653
												<p/>
1654
											</div>
1655
										</td>
1656
									</tr>
1657
								</table>
1658
							</td>
1659
						</tr>
1660
						<tr style="display:none;" name="dhcp" id="dhcp">
1661
							<td colspan="2" style="padding: 0px;">
1662
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1663
									<tr>
1664
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration"); ?></td>
1665
									</tr>
1666
									<!-- Uncomment to expose DHCP+ in GUI
1667
									<tr>
1668
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1669
										<td width="78%" class="vtable">
1670
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked"; ?> >
1671
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1672
										<br/>
1673
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
1674
										</td>
1675
									</tr>
1676
									-->
1677
									<tr>
1678
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1679
										<td width="78%" class="vtable">
1680
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1681
											<br>
1682
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1683
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1684
											"this (for client identification)."); ?>
1685
										</td>
1686
									</tr>
1687
									<tr>
1688
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
1689
										<td width="78%" class="vtable">
1690
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
1691
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1692
												<?php
1693
												for ($i = 32; $i > 0; $i--) {
1694
													if($i <> 31) {
1695
														echo "<option value=\"{$i}\" ";
1696
														if ($i == $pconfig['alias-subnet']) echo "selected";
1697
														echo ">" . $i . "</option>";
1698
													}
1699
												}
1700
												?>
1701
											</select>
1702
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
1703
											"DHCP client."); ?>
1704
										</td>
1705
									</tr>
1706
								</table>
1707
							</td>
1708
						</tr>
1709
						<tr style="display:none;" name="dhcp6" id="dhcp6">
1710
							<td colspan="2" style="padding: 0px;">
1711
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1712
									<tr>
1713
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration"); ?></td>
1714
									</tr>
1715
									<!--- Leave commented out for now
1716
									<tr>
1717
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
1718
										<td width="78%" class="vtable">
1719
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>">
1720
											<br>
1721
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
1722
											"when requesting a DHCPv6 lease."); ?><br />
1723
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
1724
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
1725
												}
1726
												printf(gettext("The current DUID is: '%s'"),$current_duid);
1727
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
1728
											?>
1729
										</td>
1730
									</tr>
1731
									-->
1732
									<tr>
1733
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
1734
										<td width="78%" class="vtable">
1735
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
1736
												<?php
1737
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
1738
												foreach($sizes as $bits => $length) {
1739
													echo "<option value=\"{$bits}\" ";
1740
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected";
1741
													echo ">" . $length . "</option>";
1742
												}
1743
												?>
1744
											</select>
1745
											<br>
1746
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
1747
										</td>
1748
									</tr>
1749
								</table>
1750
							</td>
1751
						</tr>
1752
						<tr style="display:none;" name="6rd" id="6rd">
1753
							<td colspan="2" style="padding: 0px;">
1754
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1755
									<tr>
1756
										<td colspan="2" valign="top" class="listtopic"><?=gettext("6RD Rapid Deployment"); ?></td>
1757
									</tr>
1758
									<tr>
1759
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD prefix"); ?></td>
1760
										<td width="78%" class="vtable">
1761
											<input name="prefix-6rd" type="text" class="formfld unknown" id="prefix-6rd" size="40" value="<?=htmlspecialchars($pconfig['prefix-6rd']);?>">
1762
											<br>
1763
											<?=gettext("The value in this field is the 6RD IPv6 prefix assigned by your ISP. e.g. '2001:db8::/32'") ?><br />
1764
										</td>
1765
									</tr>
1766
									<tr>
1767
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD Border Relay"); ?></td>
1768
										<td width="78%" class="vtable">
1769
											<input name="gateway-6rd" type="text" class="formfld unknown" id="gateway-6rd" size="40" value="<?=htmlspecialchars($pconfig['gateway-6rd']);?>">
1770
											<br>
1771
											<?=gettext("The value in this field is 6RD IPv4 gateway address assigned by your ISP") ?><br />
1772
										</td>
1773
									</tr>
1774
									<tr>
1775
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD IPv4 Prefix length"); ?></td>
1776
										<td width="78%" class="vtable">
1777
											<select name="prefix-6rd-v4plen" class="formselect" id="prefix-6rd-v4plen">
1778
												<?php
1779
												for ($i = 0; $i < 32; $i++) {
1780
													echo "<option value=\"{$i}\" ";
1781
													if (is_numeric($pconfig['prefix-6rd-v4plen']) && ($i == $pconfig['prefix-6rd-v4plen'])) echo "selected";
1782
													echo ">" . $i . " bits</option>";
1783
												}
1784
												?>
1785
											</select>
1786
											<br>
1787
											<?=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."); ?>
1788
										</td>
1789
									</tr>
1790
								</table>
1791
							</td>
1792
						</tr>
1793
						<tr style="display:none;" name="track6" id="track6">
1794
							<td colspan="2" style="padding: 0px;">
1795
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1796
									<tr>
1797
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
1798
									</tr>
1799
									<tr>
1800
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
1801
										<td width="78%" class="vtable">
1802
										<select name='track6-interface' class='formselect' >
1803
										<?php 
1804
											$interfaces = get_configured_interface_with_descr(false, true);
1805
											$dynv6ifs = array();
1806
											foreach ($interfaces as $iface => $ifacename) {
1807
												switch($config['interfaces'][$iface]['ipaddrv6']) {
1808
													case "6to4":
1809
													case "6rd":
1810
													case "dhcp6":
1811
														$dynv6ifs[$iface] = $ifacename;
1812
														break;
1813
													default:
1814
														continue;
1815
												}
1816
											}
1817
											foreach($dynv6ifs as $iface => $ifacename) {
1818
												echo "<option value=\"{$iface}\"";
1819
												if ($iface == $pconfig['track6-interface'])
1820
													echo " selected";
1821
												echo ">" . htmlspecialchars($ifacename) . "</option>";
1822
											}
1823
										  ?>
1824
										</select> <br>
1825
											<br>
1826
											<?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
1827
										</td>
1828
									</tr>
1829
									<tr>
1830
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
1831
										<td width="78%" class="vtable">
1832
											<?php
1833
												if ($pconfig['track6-prefix-id'] == "none" || $pconfig['track6-prefix-id'] == "") {
1834
													$track6_prefix_id_hex = "";
1835
												} else {
1836
													$track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
1837
												}
1838
											?>
1839
											<input name="track6-prefix-id--hex" type="text" class="formfld unknown" id="track6-prefix-id--hex" size="8" value="<?= $track6_prefix_id_hex ?>" />
1840
											<br />
1841
											<?= gettext("The value in this field is the (Delegated) IPv6 prefix id. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
1842
											<br />
1843
											<?= sprintf(gettext("Enter a <b>hexadecimal</b> value between %x and %x here, or leave blank."), 0, $ipv6_num_prefix_ids - 1); ?>
1844
										</td>
1845
									</tr>
1846
										</td>
1847
									</tr>
1848
								</table>
1849
							</td>
1850
						</tr>
1851
						<tr style="display:none;" name="ppp" id="ppp">
1852
							<td colspan="2" style="padding: 0px;">
1853
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1854
									<tr>
1855
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
1856
									</tr>
1857
									<tr name="ppp_provider" id="ppp_provider">
1858
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
1859
										<td width="78%" class="vtable">
1860
											<table border="0" cellpadding="0" cellspacing="0">
1861
												<tr id="trcountry">
1862
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
1863
													<td>
1864
														<select class="formselect" name="country" id="country" onChange="providers_list()">
1865
															<option></option>
1866
														</select>
1867
													</td>
1868
												</tr>
1869
												<tr id="trprovider" style="display:none">
1870
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
1871
													<td>
1872
														<select class="formselect" name="provider" id="provider" onChange="providerplan_list()">
1873
															<option></option>
1874
														</select>
1875
													</td>
1876
												</tr>
1877
												<tr id="trproviderplan" style="display:none">
1878
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
1879
													<td>
1880
														<select class="formselect" name="providerplan" id="providerplan" onChange="prefill_provider()">
1881
															<option></option>
1882
														</select>
1883
													</td>
1884
												</tr>
1885
											</table>
1886
											<br/><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
1887
										</td>
1888
									</tr>
1889
									<tr>
1890
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
1891
										<td width="78%" class="vtable">
1892
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
1893
										</td>
1894
									</tr>
1895
									<tr>
1896
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
1897
										<td width="78%" class="vtable">
1898
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
1899
										</td>
1900
									</tr>
1901
									<tr name="phone_num" id="phone_num">
1902
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
1903
										<td width="78%" class="vtable">
1904
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>">
1905
										</td>
1906
									</tr>
1907
									<tr name="apn_" id="apn_">
1908
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
1909
										<td width="78%" class="vtable">
1910
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
1911
										</td>
1912
									</tr>
1913
									<tr name="interface" id="interface" >
1914
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
1915
										<td width="78%" class="vtable">
1916
											<select name="port" id="port" class="formselect">
1917
											<?php
1918
												$portlist = glob("/dev/cua*");
1919
												$modems = glob("/dev/modem*");
1920
												$portlist = array_merge($portlist, $modems);
1921
												foreach ($portlist as $port) {
1922
													if(preg_match("/\.(lock|init)$/", $port))
1923
														continue;
1924
													echo "<option value=\"".trim($port)."\"";
1925
													if ($pconfig['port'] == $port)
1926
														echo "selected";
1927
													echo ">{$port}</option>";
1928
												}?>
1929
											</select>
1930
										</td>
1931
									</tr>
1932
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
1933
										<?php if (isset($pconfig['pppid'])): ?>
1934
											<td width="78%" class="vtable">
1935
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
1936
											<?=gettext("to edit PPP configuration."); ?>
1937
											</td>
1938
										<?php else: ?>
1939
											<td width="78%" class="vtable">
1940
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
1941
											<?=gettext("to create a PPP configuration."); ?>
1942
											</td>
1943
										<?php endif; ?>
1944
									</tr>
1945
								</table>
1946
							</td>
1947
						</tr>
1948
						<tr style="display:none;" name="pppoe" id="pppoe">
1949
							<td colspan="2" style="padding:0px;">
1950
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1951
									<tr>
1952
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
1953
									</tr>
1954
									<tr>
1955
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
1956
										<td width="78%" class="vtable">
1957
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
1958
										</td>
1959
									</tr>
1960
									<tr>
1961
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
1962
										<td width="78%" class="vtable">
1963
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
1964
										</td>
1965
									</tr>
1966
									<tr>
1967
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
1968
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
1969
											<br> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
1970
										</td>
1971
									</tr>
1972
									<tr>
1973
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
1974
										<td width="78%" class="vtable">
1975
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>>
1976
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
1977
											<?=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."); ?>
1978
										</td>
1979
									</tr>
1980
									<tr>
1981
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
1982
										<td width="78%" class="vtable">
1983
											<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."); ?>
1984
										</td>
1985
									</tr>
1986
									<tr>
1987
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
1988
										<td width="78%" class="vtable">
1989
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
1990
												<tr>
1991
													<td align="left" valign="top">
1992
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
1993
														<select valign="top" id="reset_type" name="pppoe-reset-type" class="formselect" onChange="show_reset_settings(this.value);">
1994
															<option value = ""><?=gettext("Disabled"); ?></option>
1995
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?=gettext("Custom"); ?></option>
1996
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?=gettext("Pre-Set"); ?></option>
1997
														</select> <?=gettext("Select a reset timing type"); ?>
1998
														</p>
1999
														<?php if ($pconfig['pppoe_pr_custom']): ?>
2000
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
2001
														<?php else: ?>
2002
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
2003
														<?php endif; ?>
2004
														<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" />
2005
														<?=gettext("hour (0-23)"); ?><br />
2006
														<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" />
2007
														<?=gettext("minute (0-59)"); ?><br />
2008
														<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']);?>" />
2009
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
2010
														<br />&nbsp;<br />
2011
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
2012
														<?=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."); ?>
2013
														</p>
2014
														<?php if ($pconfig['pppoe_pr_preset']): ?>
2015
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
2016
														<?php else: ?>
2017
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
2018
														<?php endif; ?>
2019
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
2020
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
2021
														<br />
2022
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
2023
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
2024
														<br />
2025
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
2026
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
2027
														<br />
2028
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
2029
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
2030
														</p>
2031
													</td>
2032
												</tr>
2033
											</table>
2034
										</td>
2035
									</tr>
2036

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

    
2625
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2626
						<tr>
2627
							<td width="22%" valign="top">
2628
								&nbsp;
2629
							</td>
2630
							<td width="78%">
2631
								<br/>
2632
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2633
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2634
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2635
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2636
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2637
								<?php endif; ?>
2638
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2639
							</td>
2640
						</tr>
2641
					</table>
2642
				</td>
2643
			</tr>
2644
		</table>
2645
		<!--
2646
		</div>
2647
		</td></tr>
2648
		</table>
2649
		-->
2650
	</form>
2651
	<script type="text/javascript">
2652
		var gatewayip;
2653
		var name;
2654
		var gatewayipv6;
2655
		var namev6;
2656
		function show_add_gateway() {
2657
			document.getElementById("addgateway").style.display = '';
2658
			document.getElementById("addgwbox").style.display = 'none';
2659
			document.getElementById("gateway").style.display = 'none';
2660
			document.getElementById("save").style.display = 'none';
2661
			document.getElementById("cancel").style.display = 'none';
2662
			document.getElementById("gwsave").style.display = '';
2663
			document.getElementById("gwcancel").style.display = '';
2664
			jQuery('#notebox').html("");
2665
		}
2666
		function show_add_gateway_v6() {
2667
			document.getElementById("addgatewayv6").style.display = '';
2668
			document.getElementById("addgwboxv6").style.display = 'none';
2669
			document.getElementById("gatewayv6").style.display = 'none';
2670
			document.getElementById("save").style.display = 'none';
2671
			document.getElementById("cancel").style.display = 'none';
2672
			document.getElementById("gwsave").style.display = '';
2673
			document.getElementById("gwcancel").style.display = '';
2674
			jQuery('#noteboxv6').html("");
2675
		}
2676
		function hide_add_gateway() {
2677
			document.getElementById("addgateway").style.display = 'none';
2678
			document.getElementById("addgwbox").style.display = '';
2679
			document.getElementById("gateway").style.display = '';
2680
			document.getElementById("save").style.display = '';
2681
			document.getElementById("cancel").style.display = '';
2682
			document.getElementById("gwsave").style.display = '';
2683
			document.getElementById("gwcancel").style.display = '';
2684
		}
2685
		function hide_add_gateway_v6() {
2686
			document.getElementById("addgatewayv6").style.display = 'none';
2687
			document.getElementById("addgwboxv6").style.display = '';
2688
			document.getElementById("gatewayv6").style.display = '';
2689
			document.getElementById("save").style.display = '';
2690
			document.getElementById("cancel").style.display = '';
2691
			document.getElementById("gwsave").style.display = '';
2692
			document.getElementById("gwcancel").style.display = '';
2693
		}
2694
		function hide_add_gatewaysave() {
2695
			document.getElementById("addgateway").style.display = 'none';
2696
			jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2697
			var iface = jQuery('#if').val();
2698
			name = jQuery('#name').val();
2699
			var descr = jQuery('#gatewaydescr').val();
2700
			gatewayip = jQuery('#gatewayip').val();
2701

    
2702
			var defaultgw = jQuery('#defaultgw').val();
2703
			var url = "system_gateways_edit.php";
2704
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2705
			jQuery.ajax(
2706
				url,
2707
				{
2708
					type: 'post',
2709
					data: pars,
2710
					error: report_failure,
2711
					complete: save_callback
2712
				});
2713
		}
2714
		function hide_add_gatewaysave_v6() {
2715
			document.getElementById("addgatewayv6").style.display = 'none';
2716
			jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2717
			var iface = jQuery('#if').val();
2718
			name = jQuery('#namev6').val();
2719
			var descr = jQuery('#gatewaydescrv6').val();
2720
			gatewayip = jQuery('#gatewayipv6').val();
2721
			var defaultgw = jQuery('#defaultgwv6').val();
2722
			var url_v6 = "system_gateways_edit.php";
2723
			var pars_v6 = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2724
			jQuery.ajax(
2725
				url_v6,
2726
				{
2727
					type: 'post',
2728
					data: pars_v6,
2729
					error: report_failure_v6,
2730
					complete: save_callback_v6
2731
				});
2732
		}
2733
		function addOption(selectbox,text,value)
2734
		{
2735
			var optn = document.createElement("OPTION");
2736
			optn.text = text;
2737
			optn.value = value;
2738
			selectbox.append(optn);
2739
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2740
			jQuery('#notebox').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2741
		}
2742
		function addOption_v6(selectbox,text,value)
2743
		{
2744
			var optn = document.createElement("OPTION");
2745
			optn.text = text;
2746
			optn.value = value;
2747
			selectbox.append(optn);
2748
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2749
			jQuery('#noteboxv6').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2750
		}
2751
		function report_failure(request, textStatus, errorThrown) {
2752
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
2753
				alert(request.responseText);
2754
			} else {
2755
				alert("Sorry, we could not create your IPv4 gateway at this time.");
2756
			}
2757
			hide_add_gateway();
2758
		}
2759
		function report_failure_v6(request, textStatus, errorThrown) {
2760
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
2761
				alert(request.responseText);
2762
			} else {
2763
				alert("Sorry, we could not create your IPv6 gateway at this time.");
2764
			}
2765
			hide_add_gateway_v6();
2766
		}
2767
		function save_callback(transport) {
2768
			var response = transport.responseText;
2769
			if(response) {
2770
				document.getElementById("addgateway").style.display = 'none';
2771
				hide_add_gateway();
2772
				jQuery('#status').html('');
2773
				var gwtext = escape(name) + " - " + gatewayip;
2774
				addOption(jQuery('#gateway'), gwtext, name);
2775
				// Auto submit form?
2776
				//document.iform.submit();
2777
				//jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif">');
2778
			} else {
2779
				report_failure();
2780
			}
2781
		}
2782
		function show_advanced_media() {
2783
			document.getElementById("showadvmediabox").innerHTML='';
2784
			aodiv = document.getElementById('showmediaadv');
2785
			aodiv.style.display = "block";
2786
		}
2787
		function save_callback_v6(transport) {
2788
			var response_v6 = transport.responseText;
2789
			if(response_v6) {
2790
				document.getElementById("addgatewayv6").style.display = 'none';
2791
				hide_add_gateway_v6();
2792
				jQuery('#statusv6').html('');
2793
				var gwtext_v6 = escape(name) + " - " + gatewayip;
2794
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
2795
				// Auto submit form?
2796
				//document.iform.submit();
2797
				//jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif">');
2798
			} else {
2799
				report_failure_v6();
2800
			}
2801
		}
2802
		<?php
2803
		echo "show_allcfg(document.iform.enable);";
2804
		echo "updateType('{$pconfig['type']}');\n";
2805
		echo "updateTypeSix('{$pconfig['type6']}');\n";
2806
		?>
2807
	</script>
2808
	<?php include("fend.inc"); ?>
2809
	</body>
2810
</html>
(92-92/249)