Project

General

Profile

Download (112 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 = split(" ", $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 "carpdev-dhcp":
196
		$pconfig['type'] = "carpdev-dhcp";
197
		$pconfig['ipaddr'] = "";
198
		break;
199
	case "pppoe":
200
	case "pptp":
201
	case "l2tp":
202
	case "ppp":
203
		$pconfig['type'] = $wancfg['ipaddr'];
204
		break;
205
	default:
206
		if(is_ipaddr($wancfg['ipaddr'])) {
207
			$pconfig['type'] = "staticv4";
208
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
209
			$pconfig['subnet'] = $wancfg['subnet'];
210
			$pconfig['gateway'] = $wancfg['gateway'];
211
			if((is_ipaddr($wancfg['ipaddrv6'])) && (is_ipaddr($wancfg['ipaddr']))) {
212
				$pconfig['type'] = "staticv4v6";
213
			}
214
		} else
215
			$pconfig['type'] = "none";
216
		break;
217
}
218

    
219
switch($wancfg['ipaddrv6']) {
220
	default:
221
		/* if we have dual stack we need a combined type */
222
		if(is_ipaddrv6($wancfg['ipaddrv6'])) {
223
			$pconfig['type'] = "staticv6";
224
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
225
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
226
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
227
			if((is_ipaddrv6($wancfg['ipaddrv6'])) && (is_ipaddr($wancfg['ipaddr']))) {
228
				$pconfig['type'] = "staticv4v6";
229
			}
230
		}
231
		break;
232
}
233

    
234
// print_r($pconfig);
235

    
236
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
237
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
238
$pconfig['spoofmac'] = $wancfg['spoofmac'];
239
$pconfig['mtu'] = $wancfg['mtu'];
240
$pconfig['mss'] = $wancfg['mss'];
241

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

    
322
if ($_POST['apply']) {
323
	unset($input_errors);
324
	if (!is_subsystem_dirty('interfaces'))
325
		$intput_errors[] = gettext("You have already applied your settings!");
326
	else {
327
		unlink_if_exists("{$g['tmp_path']}/config.cache");
328
		clear_subsystem_dirty('interfaces');
329

    
330
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
331
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
332
			foreach ($toapplylist as $ifapply => $values) {
333
				if (isset($config['interfaces'][$ifapply]['enable'])) {
334
					/* check if any old addresses need purging */
335
					if(is_ipaddrv6($values['ipaddrv6'])) {
336
						$realif = get_real_interface("$ifapply");
337
						log_error("removing old v6 address {$values['ipaddrv6']} on {$realif}");
338
						mwexec("/sbin/ifconfig {$realif} inet6 {$values['ipaddrv6']} -alias");
339
					}
340
					interface_configure($ifapply, true);
341
				} else {
342
					interface_bring_down($ifapply);
343
				}
344
			}
345
		}
346
		/* restart snmp so that it binds to correct address */
347
		services_snmpd_configure();
348

    
349
		/* sync filter configuration */
350
		setup_gateways_monitor();
351

    
352
		clear_subsystem_dirty('staticroutes');
353

    
354
		filter_configure();
355

    
356
		enable_rrd_graphing();
357
	}
358
	@unlink("{$g['tmp_path']}/.interfaces.apply");
359
	header("Location: interfaces.php?if={$if}");
360
	exit;
361
} else if ($_POST && $_POST['enable'] != "yes") {
362
	unset($wancfg['enable']);
363
	if (isset($wancfg['wireless']))
364
		interface_sync_wireless_clones($wancfg, false);
365
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
366
	mark_subsystem_dirty('interfaces');
367
	if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
368
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
369
	} else {
370
		$toapplylist = array();
371
	}
372
	$toapplylist[$if] = array();
373
	/* we need to be able remove IP aliases for IPv6 */
374
	if(($old_wancfg['ipaddrv6'] != $wancfg['ipaddrv6']) && (is_ipaddrv6($old_wancfg['ipaddrv6']))) {
375
		$toapplylist[$if]['ipaddrv6'] = "{$old_wancfg['ipaddrv6']}";
376
	}
377
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
378
	header("Location: interfaces.php?if={$if}");
379
	exit;
380
} else if ($_POST) {
381

    
382
	unset($input_errors);
383
	$pconfig = $_POST;
384
	conf_mount_rw();
385

    
386
	/* filter out spaces from descriptions  */
387
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
388

    
389
	/* okay first of all, cause we are just hiding the PPPoE HTML
390
	 * fields releated to PPPoE resets, we are going to unset $_POST
391
	 * vars, if the reset feature should not be used. Otherwise the
392
	 * data validation procedure below, may trigger a false error
393
	 * message.
394
	 */
395
	if (empty($_POST['pppoe-reset-type'])) {
396
		unset($_POST['pppoe_pr_type']);
397
		unset($_POST['pppoe_resethour']);
398
		unset($_POST['pppoe_resetminute']);
399
		unset($_POST['pppoe_resetdate']);
400
		unset($_POST['pppoe_pr_preset_val']);
401
	}
402
	/* description unique? */
403
	foreach ($ifdescrs as $ifent => $ifdescr) {
404
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
405
			$input_errors[] = gettext("An interface with the specified description already exists.");
406
			break;
407
		}
408
	}
409
	/* input validation */
410
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^static/", $_POST['type'])))
411
		$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.");
412

    
413
	switch(strtolower($_POST['type'])) {
414
		case "staticv4":
415
			$reqdfields = explode(" ", "ipaddr subnet gateway");
416
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
417
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
418
			break;
419
		case "staticv6":
420
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
421
			$reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
422
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
423
			break;
424
		case "staticv4v6":
425
			/* if the saved v6 address is empty we just lookup the link-local address */
426
			/* dhcp-pd will override the LAN address and we will setup a router advertisment in the background */
427
			if(empty($_POST['ipaddrv6'])) {
428
				exec("/sbin/ifconfig {$wancfg['if']} inet6 | awk '/fe80:/ {print $2}' | awk -F% '{print $1}'", $output);
429
				$_POST['ipaddrv6'] = trim($output[0]);
430
				$_POST['subnetv6'] = "64";
431
			}
432
			$reqdfields = explode(" ", "ipaddr subnet gateway ipaddrv6 subnetv6 gatewayv6");
433
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"),gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
434
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
435
			break;
436
		case "none":
437
			if(is_array($config['virtualip']['vip'])) {
438
				foreach ($config['virtualip']['vip'] as $vip) {
439
					if ($vip['interface'] == $if)
440
						$input_errors[] = gettext("This interface is referenced by VIPs please delete those before setting the interface to 'none' configuration.");
441
				}
442
			}
443
		case "dhcp":
444
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp")))
445
				$input_errors[] = gettext("You have to reassign the interface to be able to configure as {$_POST['type']}.");
446
			if (in_array($wancfg['ipaddrv6'], array("ppp", "pppoe", "pptp", "l2tp")))
447
				$input_errors[] = gettext("You have to reassign the interface to be able to configure as {$_POST['type']}.");
448
			break;
449
		case "ppp":
450
			$reqdfields = explode(" ", "port phone");
451
			$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
452
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
453
			break;
454
		case "pppoe":
455
			if ($_POST['pppoe_dialondemand']) {
456
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
457
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
458
			} else {
459
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
460
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
461
			}
462
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
463
			break;
464
		case "pptp":
465
			if ($_POST['pptp_dialondemand']) {
466
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
467
				$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"));
468
			} else {
469
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
470
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
471
			}
472
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
473
			break;
474
		case "l2tp":
475
			if ($_POST['pptp_dialondemand']) {
476
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
477
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
478
			} else {
479
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
480
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"));
481
			}
482
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
483
			break;
484
	}
485

    
486
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
487
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
488
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr'])))
489
		$input_errors[] = gettext("A valid IPv4 address must be specified.");
490
	if (($_POST['ipaddrv6'] && !is_ipaddr($_POST['ipaddrv6'])))
491
		$input_errors[] = gettext("A valid IPv6 address must be specified.");
492
	if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
493
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
494
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6'])))
495
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
496
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address'])))
497
		$input_errors[] = gettext("A valid alias IP address must be specified.");
498
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
499
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
500
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
501
		$match = false;
502
		foreach($a_gateways as $gateway) {
503
			if(in_array($_POST['gateway'], $gateway)) {
504
				$match = true;
505
			}
506
		}
507
		foreach($a_gateways as $gateway) {
508
			if(in_array($_POST['gatewayv6'], $gateway)) {
509
				$match = true;
510
			}
511
		}
512
		if(!$match) {
513
			$input_errors[] = gettext("A valid gateway must be specified.");
514
		}
515
	}
516
	if (($_POST['provider'] && !is_domain($_POST['provider'])))
517
		$input_errors[] = gettext("The service name contains invalid characters.");
518
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
519
		$input_errors[] = gettext("The idle timeout value must be an integer.");
520
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
521
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23)
522
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
523
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
524
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59)
525
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
526
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate'])))
527
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
528
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local'])))
529
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
530
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet'])))
531
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
532
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface])))
533
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
534
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout']))
535
		$input_errors[] = gettext("The idle timeout value must be an integer.");
536
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])))
537
		$input_errors[] = gettext("A valid MAC address must be specified.");
538
	if ($_POST['mtu'] && ($_POST['mtu'] < 576))
539
		$input_errors[] = gettext("The MTU must be greater than 576 bytes.");
540
	if ($_POST['mss'] && ($_POST['mss'] < 576))
541
		$input_errors[] = gettext("The MSS must be greater than 576 bytes.");
542
	/* Wireless interface? */
543
	if (isset($wancfg['wireless'])) {
544
		$reqdfields = explode(" ", "mode ssid");
545
		$reqdfieldsn = array(gettext("Mode"),gettext("SSID"));
546
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
547
		check_wireless_mode();
548
		/* loop through keys and enforce size */
549
		for ($i = 1; $i <= 4; $i++) {
550
			if ($_POST['key' . $i]) {
551
				/* 64 bit */
552
				if (strlen($_POST['key' . $i]) == 5)
553
					continue;
554
				if (strlen($_POST['key' . $i]) == 10) {
555
					/* hex key */
556
					if (stristr($_POST['key' . $i], "0x") == false) {
557
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
558
					}
559
					continue;
560
				}
561
				if (strlen($_POST['key' . $i]) == 12) {
562
					/* hex key */
563
					if(stristr($_POST['key' . $i], "0x") == false) {
564
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
565
					}
566
					continue;
567
				}
568
				/* 128 bit */
569
				if (strlen($_POST['key' . $i]) == 13)
570
					continue;
571
				if (strlen($_POST['key' . $i]) == 26) {
572
					/* hex key */
573
					if (stristr($_POST['key' . $i], "0x") == false)
574
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
575
					continue;
576
				}
577
				if(strlen($_POST['key' . $i]) == 28)
578
					continue;
579
				$input_errors[] =  gettext("Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.");
580
				break;
581
			}
582
		}
583

    
584
		if ($_POST['passphrase']) {
585
                	$passlen = strlen($_POST['passphrase']);
586
                	if ($passlen < 8 || $passlen > 64)
587
                        	$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
588
		}
589
	}
590
	if (!$input_errors) {
591
		if ($wancfg['type'] != $_POST['type']) {
592
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
593
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
594
				unset($a_ppps[$pppid]);
595
			} else if ($wancfg['type'] == "dhcp") {
596
				$pid = find_dhclient_process($realif);
597
				if($pid)
598
					posix_kill($pid, SIGTERM);
599
			}
600
				
601
		}
602
		$ppp = array();
603
		if ($wancfg['ipaddr'] != "ppp")
604
			unset($wancfg['ipaddr']);
605
		if ($wancfg['ipaddrv6'] != "ppp")
606
			unset($wancfg['ipaddrv6']);
607
		unset($wancfg['subnet']);
608
		unset($wancfg['gateway']);
609
		unset($wancfg['subnetv6']);
610
		unset($wancfg['gatewayv6']);
611
		unset($wancfg['dhcphostname']);
612
		unset($wancfg['pppoe_username']);
613
		unset($wancfg['pppoe_password']);
614
		unset($wancfg['pptp_username']);
615
		unset($wancfg['pptp_password']);
616
		unset($wancfg['provider']);
617
		unset($wancfg['ondemand']);
618
		unset($wancfg['timeout']);
619
		if (isset($wancfg['pppoe']['pppoe-reset-type']))
620
			unset($wancfg['pppoe']['pppoe-reset-type']);
621
		unset($wancfg['local']);
622
		unset($wancfg['remote']);
623
		unset($a_ppps[$pppid]['apn']);
624
		unset($a_ppps[$pppid]['phone']);
625
		unset($a_ppps[$pppid]['localip']);
626
		unset($a_ppps[$pppid]['subnet']);
627
		unset($a_ppps[$pppid]['gateway']);
628
		unset($a_ppps[$pppid]['pppoe-reset-type']);
629
		unset($a_ppps[$pppid]['provider']);
630

    
631
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
632
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
633

    
634
		/* for dynamic interfaces we tack a gateway item onto the array to prevent system
635
		 * log messages from appearing. They can also manually add these items */
636
		/* 1st added gateway gets a default bit */
637
		if(!empty($a_gateways)) {
638
			$gateway_item = array();
639
			/* check for duplicates */
640
			$skip = false;
641
			foreach($a_gateways as $item) {
642
				if(($item['interface'] == "$if") && ($item['gateway'] == "dynamic")) {
643
					$skip = true;
644
				}
645
			}
646
			if($skip == false) {
647
				$gateway_item['gateway'] = "dynamic";
648
				$gateway_item['descr'] = gettext("Interface") . $if . gettext("dynamic gateway");
649
				$gateway_item['name'] = "GW_" . strtoupper($if);
650
				$gateway_item['interface'] = "{$if}";
651
			} else {
652
				unset($gateway_item);
653
			}
654
		}
655

    
656
		switch($_POST['type']) {
657
			case "staticv4":
658
				$wancfg['ipaddr'] = $_POST['ipaddr'];
659
				$wancfg['subnet'] = $_POST['subnet'];
660
				if ($_POST['gateway'] != "none") {
661
					$wancfg['gateway'] = $_POST['gateway'];
662
				}
663
				break;
664
			case "staticv6":
665
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
666
				$wancfg['subnetv6'] = $_POST['subnetv6'];
667
				if ($_POST['gatewayv6'] != "none") {
668
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
669
				}
670
				break;
671
			case "staticv4v6":
672
				$wancfg['ipaddr'] = $_POST['ipaddr'];
673
				$wancfg['subnet'] = $_POST['subnet'];
674
				if ($_POST['gateway'] != "none") {
675
					$wancfg['gateway'] = $_POST['gateway'];
676
				}
677
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
678
				$wancfg['subnetv6'] = $_POST['subnetv6'];
679
				if ($_POST['gatewayv6'] != "none") {
680
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
681
				}
682
				break;
683
			case "dhcp":
684
				$wancfg['ipaddr'] = "dhcp";
685
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
686
				$wancfg['alias-address'] = $_POST['alias-address'];
687
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
688
				$wancfg['duid'] = $_POST['duid'];
689
				$wancfg['dhcp-ia-pd-len'] = $_POST['dhcp-ia-pd-len'];
690
				unset($wancfg['pd-sla-id');
691
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
692
				if($gateway_item) {
693
					$a_gateways[] = $gateway_item;
694
				}
695
				break;
696
			case "carpdev-dhcp":
697
				$wancfg['ipaddr'] = "carpdev-dhcp";
698
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
699
				$wancfg['alias-address'] = $_POST['alias-address'];
700
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
701
				$wancfg['duid'] = $_POST['duid'];
702
				$wancfg['dhcp-ia-pd-len'] = $_POST['dhcp-ia-pd-len'];
703
				unset($wancfg['pd-sla-id');
704
				if($gateway_item) {
705
					$a_gateways[] = $gateway_item;
706
				}
707
				break;
708
			case "ppp":
709
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
710
				$a_ppps[$pppid]['type'] = $_POST['type'];
711
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
712
				$a_ppps[$pppid]['ports'] = $_POST['port'];
713
				$a_ppps[$pppid]['username'] = $_POST['username'];
714
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
715
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
716
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
717
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
718
				$wancfg['ipaddr'] = $_POST['type'];
719
				unset($wancfg['pd-sla-id');
720
				unset($a_ppps[$pppid]['ondemand']);
721
				unset($a_ppps[$pppid]['idletimeout']);
722
				break;
723

    
724
			case "pppoe":
725
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
726
				$a_ppps[$pppid]['type'] = $_POST['type'];
727
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
728
				if (isset($_POST['ppp_port']))
729
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
730
				else
731
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
732
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
733
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
734
				if (!empty($_POST['provider']))
735
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
736
				else
737
					unset($a_ppps[$pppid]['provider']);
738
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
739
				if (!empty($_POST['idletimeout']))
740
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
741
				else
742
					unset($a_ppps[$pppid]['idletimeout']);
743

    
744
				if (!empty($_POST['pppoe-reset-type']))
745
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
746
				else
747
					unset($a_ppps[$pppid]['pppoe-reset-type']);
748
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
749
				$wancfg['ipaddr'] = $_POST['type'];
750
				unset($wancfg['pd-sla-id');
751
				if($gateway_item) {
752
					$a_gateways[] = $gateway_item;
753
				}
754

    
755
				break;
756
			case "pptp":
757
			case "l2tp":
758
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
759
				$a_ppps[$pppid]['type'] = $_POST['type'];
760
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
761
				if (isset($_POST['ppp_port']))
762
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
763
				else
764
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
765
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
766
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
767
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
768
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
769
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
770
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
771
				if (!empty($_POST['idletimeout']))
772
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
773
				else
774
					unset($a_ppps[$pppid]['idletimeout']);
775
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
776
				$wancfg['ipaddr'] = $_POST['type'];
777
				unset($wancfg['pd-sla-id');
778
				if($gateway_item) {
779
					$a_gateways[] = $gateway_item;
780
				}
781
				break;
782
			case "none":
783
				break;
784
		}
785
		handle_pppoe_reset($_POST);
786

    
787
		if($_POST['blockpriv'] == "yes") {
788
			$wancfg['blockpriv'] = true;
789
		} else {
790
			unset($wancfg['blockpriv']);
791
		}
792
		if($_POST['blockbogons'] == "yes") {
793
			$wancfg['blockbogons'] = true;
794
		} else {
795
			unset($wancfg['blockbogons']);
796
		}
797
		$wancfg['spoofmac'] = $_POST['spoofmac'];
798
		if (empty($_POST['mtu'])) {
799
			unset($wancfg['mtu']);
800
		} else {
801
			$wancfg['mtu'] = $_POST['mtu'];
802
		}
803
		if (empty($_POST['mss'])) {
804
			unset($wancfg['mss']);
805
		} else {
806
			$wancfg['mss'] = $_POST['mss'];
807
		}
808
		if (isset($wancfg['wireless'])) {
809
			handle_wireless_post();
810
		}
811

    
812
		conf_mount_ro();
813
		write_config();
814

    
815
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
816
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
817
		} else {
818
			$toapplylist = array();
819
		}
820
		$toapplylist[$if] = array();
821
		/* we need to be able remove IP aliases for IPv6 */
822
		if(($old_wancfg['ipaddrv6'] != $wancfg['ipaddrv6']) && (is_ipaddrv6($old_wancfg['ipaddrv6']))) {
823
			$toapplylist[$if]['ipaddrv6'] = $old_wancfg['ipaddrv6'];
824
		}
825
		
826
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
827

    
828
		mark_subsystem_dirty('interfaces');
829

    
830
		/* regenerate cron settings/crontab file */
831
		configure_cron();
832

    
833
		header("Location: interfaces.php?if={$if}");
834
		exit;
835
	}
836

    
837
} // end if($_POST)
838

    
839
function handle_wireless_post() {
840
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
841
	if (!is_array($wancfg['wireless']))
842
		$wancfg['wireless'] = array();
843
	$wancfg['wireless']['standard'] = $_POST['standard'];
844
	$wancfg['wireless']['mode'] = $_POST['mode'];
845
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
846
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
847
	$wancfg['wireless']['channel'] = $_POST['channel'];
848
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
849
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
850
	$wancfg['wireless']['distance'] = $_POST['distance'];
851
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
852
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
853
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
854
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
855
		foreach($wl_countries_attr as $wl_country) {
856
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
857
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
858
				break;
859
			}
860
		}
861
	}
862
	if (!is_array($wancfg['wireless']['wpa']))
863
		$wancfg['wireless']['wpa'] = array();
864
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
865
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
866
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
867
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
868
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
869
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
870
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
871
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
872
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
873
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
874
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
875
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
876
	if ($_POST['persistcommonwireless'] == "yes") {
877
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
878
			$config['wireless']['interfaces'][$wlanbaseif] = array();
879
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
880
		unset($config['wireless']['interfaces'][$wlanbaseif]);
881
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
882
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
883
	else if (isset($wancfg['wireless']['diversity']))
884
		unset($wancfg['wireless']['diversity']);
885
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
886
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
887
	else if (isset($wancfg['wireless']['txantenna']))
888
		unset($wancfg['wireless']['txantenna']);
889
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
890
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
891
	else if (isset($wancfg['wireless']['rxantenna']))
892
		unset($wancfg['wireless']['rxantenna']);
893
	if ($_POST['hidessid_enable'] == "yes")
894
		$wancfg['wireless']['hidessid']['enable'] = true;
895
	else if (isset($wancfg['wireless']['hidessid']['enable']))
896
		unset($wancfg['wireless']['hidessid']['enable']);
897
	if ($_POST['mac_acl_enable'] == "yes")
898
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
899
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
900
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
901
	if ($_POST['rsn_preauth'] == "yes")
902
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
903
	else
904
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
905
	if ($_POST['ieee8021x'] == "yes")
906
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
907
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
908
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
909
	if ($_POST['wpa_strict_rekey'] == "yes")
910
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
911
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
912
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
913
	if ($_POST['debug_mode'] == "yes")
914
		$wancfg['wireless']['wpa']['debug_mode'] = true;
915
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
916
		sunset($wancfg['wireless']['wpa']['debug_mode']);
917
	if ($_POST['wpa_enable'] == "yes")
918
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
919
	else if (isset($wancfg['wireless']['wpa']['enable']))
920
		unset($wancfg['wireless']['wpa']['enable']);
921
	if ($_POST['wep_enable'] == "yes") {
922
		if (!is_array($wancfg['wireless']['wep']))
923
			$wancfg['wireless']['wep'] = array();
924
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
925
	} else if (isset($wancfg['wireless']['wep']))
926
		unset($wancfg['wireless']['wep']);
927
	if ($_POST['wme_enable'] == "yes") {
928
		if (!is_array($wancfg['wireless']['wme']))
929
			$wancfg['wireless']['wme'] = array();
930
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
931
	} else if (isset($wancfg['wireless']['wme']['enable']))
932
		unset($wancfg['wireless']['wme']['enable']);
933
	if ($_POST['puremode'] == "11g") {
934
		if (!is_array($wancfg['wireless']['pureg']))
935
			$wancfg['wireless']['pureg'] = array();
936
		$wancfg['wireless']['pureg']['enable'] = true;
937
	} else if ($_POST['puremode'] == "11n") {
938
		if (!is_array($wancfg['wireless']['puren']))
939
			$wancfg['wireless']['puren'] = array();
940
		$wancfg['wireless']['puren']['enable'] = true;
941
	} else {
942
		if (isset($wancfg['wireless']['pureg']))
943
			unset($wancfg['wireless']['pureg']);
944
		if (isset($wancfg['wireless']['puren']))
945
			unset($wancfg['wireless']['puren']);
946
	}
947
	if ($_POST['apbridge_enable'] == "yes") {
948
		if (!is_array($wancfg['wireless']['apbridge']))
949
			$wancfg['wireless']['apbridge'] = array();
950
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
951
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
952
		unset($wancfg['wireless']['apbridge']['enable']);
953
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
954
		if (!is_array($wancfg['wireless']['turbo']))
955
			$wancfg['wireless']['turbo'] = array();
956
		$wancfg['wireless']['turbo']['enable'] = true;
957
	} else if (isset($wancfg['wireless']['turbo']['enable']))
958
		unset($wancfg['wireless']['turbo']['enable']);
959
	$wancfg['wireless']['wep']['key'] = array();
960
	for ($i = 1; $i <= 4; $i++) {
961
		if ($_POST['key' . $i]) {
962
			$newkey = array();
963
			$newkey['value'] = $_POST['key' . $i];
964
			if ($_POST['txkey'] == $i)
965
				$newkey['txkey'] = true;
966
			$wancfg['wireless']['wep']['key'][] = $newkey;
967
		}
968
	}
969
	interface_sync_wireless_clones($wancfg, true);
970
}
971

    
972
function check_wireless_mode() {
973
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
974

    
975
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
976
		return;
977

    
978
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
979
		$clone_count = 1;
980
	else
981
		$clone_count = 0;
982
	if (is_array($config['wireless']['clone'])) {
983
		foreach ($config['wireless']['clone'] as $clone) {
984
			if ($clone['if'] == $wlanbaseif)
985
				$clone_count++;
986
		}
987
	}
988
	if ($clone_count > 1) {
989
		$old_wireless_mode = $wancfg['wireless']['mode'];
990
		$wancfg['wireless']['mode'] = $_POST['mode'];
991
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
992
			$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']]);
993
		} else {
994
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
995
		}
996
		$wancfg['wireless']['mode'] = $old_wireless_mode;
997
	}
998
}
999

    
1000
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1001
$statusurl = "status_interfaces.php";
1002

    
1003
$closehead = false;
1004
include("head.inc");
1005
$types = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "staticv6" => gettext("Static IPv6"), "staticv4v6" => gettext("Static IPv4 + IPv6"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP") /* , "carpdev-dhcp" => "CarpDev"*/);
1006

    
1007
?>
1008

    
1009
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1010
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1011
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1012
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1013

    
1014
<script type="text/javascript">
1015
	function updateType(t) {
1016
		switch(t) {
1017
			case "none": {
1018
				$('staticv4', 'staticv6', 'dhcp', 'pppoe','pptp', 'ppp').invoke('hide');
1019
				break;
1020
			}
1021
			case "staticv4": {
1022
				$('none', 'staticv6', 'dhcp', 'pppoe', 'pptp', 'ppp').invoke('hide');
1023
				break;
1024
			}
1025
			case "staticv6": {
1026
				$('none', 'staticv4', 'dhcp', 'pppoe','pptp', 'ppp').invoke('hide');
1027
				break;
1028
			}
1029
			case "staticv4v6": {
1030
				$('none', 'dhcp', 'pppoe', 'pptp', 'ppp').invoke('hide');
1031
				$('staticv4').show();
1032
				$('staticv6').show();
1033
				break;
1034
			}
1035
			case "dhcp": {
1036
				$('none', 'staticv4', 'staticv6', 'pppoe', 'pptp', 'ppp').invoke('hide');
1037
				break;
1038
			}
1039
			case "ppp": {
1040
				$('none', 'staticv4', 'staticv6', 'dhcp', 'pptp', 'pppoe').invoke('hide');
1041
				country_list();
1042
				break;
1043
			}
1044
			case "pppoe": {
1045
				$('none', 'staticv4', 'staticv6', 'dhcp', 'pptp', 'ppp').invoke('hide');
1046
				break;
1047
			}
1048
			case "l2tp":
1049
			case "pptp": {
1050
				$('none', 'staticv4', 'staticv6', 'dhcp', 'pppoe', 'ppp').invoke('hide');
1051
				$('pptp').show();
1052
				break;
1053
			}
1054
		}
1055
		if (t != "l2tp" && t != "pptp")
1056
			$(t).show();
1057
	}
1058

    
1059
	function show_allcfg(obj) {
1060
		if (obj.checked)
1061
			$('allcfg').show();
1062
		else
1063
			$('allcfg').hide();
1064
	}
1065

    
1066
	function show_reset_settings(reset_type) {
1067
		if (reset_type == 'preset') {
1068
			Effect.Appear('pppoepresetwrap', { duration: 0.0 });
1069
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
1070
		}
1071
		else if (reset_type == 'custom') {
1072
			Effect.Appear('pppoecustomwrap', { duration: 0.0 });
1073
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
1074
		} else {
1075
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
1076
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
1077
		}
1078
	}
1079
	function show_mon_config() {
1080
		document.getElementById("showmonbox").innerHTML='';
1081
		aodiv = document.getElementById('showmon');
1082
		aodiv.style.display = "block";
1083
	}
1084

    
1085
	function openwindow(url) {
1086
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1087
		if (oWin==null || typeof(oWin)=="undefined")
1088
			return false;
1089
		else
1090
			return true;
1091
	}
1092
	function country_list() {
1093
		$('country').childElements().each(function(node) { node.remove(); });
1094
		$('provider').childElements().each(function(node) { node.remove(); });
1095
		$('providerplan').childElements().each(function(node) { node.remove(); });
1096
		new Ajax.Request("getserviceproviders.php",{
1097
			onSuccess: function(response) {
1098
				var responseTextArr = response.responseText.split("\n");
1099
				responseTextArr.sort();
1100
				responseTextArr.each( function(value) {
1101
					var option = new Element('option');
1102
					country = value.split(":");
1103
					option.text = country[0];
1104
					option.value = country[1];
1105
					$('country').insert({ bottom : option });
1106
				});
1107
			}
1108
		});
1109
		$('trcountry').setStyle({display : "table-row"});
1110
	}
1111

    
1112
	function providers_list() {
1113
		$('provider').childElements().each(function(node) { node.remove(); });
1114
		$('providerplan').childElements().each(function(node) { node.remove(); });
1115
		new Ajax.Request("getserviceproviders.php",{
1116
			parameters: {country : $F('country')},
1117
			onSuccess: function(response) {
1118
				var responseTextArr = response.responseText.split("\n");
1119
				responseTextArr.sort();
1120
				responseTextArr.each( function(value) {
1121
					var option = new Element('option');
1122
					option.text = value;
1123
					option.value = value;
1124
					$('provider').insert({ bottom : option });
1125
				});
1126
			}
1127
		});
1128
		$('trprovider').setStyle({display : "table-row"});
1129
		$('trproviderplan').setStyle({display : "none"});
1130
	}
1131

    
1132
	function providerplan_list() {
1133
		$('providerplan').childElements().each(function(node) { node.remove(); });
1134
		$('providerplan').insert( new Element('option') );
1135
		new Ajax.Request("getserviceproviders.php",{
1136
			parameters: {country : $F('country'), provider : $F('provider')},
1137
			onSuccess: function(response) {
1138
				var responseTextArr = response.responseText.split("\n");
1139
				responseTextArr.sort();
1140
				responseTextArr.each( function(value) {
1141
					if(value != "") {
1142
						providerplan = value.split(":");
1143

    
1144
						var option = new Element('option');
1145
						option.text = providerplan[0] + " - " + providerplan[1];
1146
						option.value = providerplan[1];
1147
						$('providerplan').insert({ bottom : option });
1148
					}
1149
				});
1150
			}
1151
		});
1152
		$('trproviderplan').setStyle({display : "table-row"});
1153
	}
1154

    
1155
	function prefill_provider() {
1156
		new Ajax.Request("getserviceproviders.php",{
1157
			parameters: {country : $F('country'), provider : $F('provider'), plan : $F('providerplan')},
1158
			onSuccess: function(response) {
1159
				var xmldoc = response.responseXML;
1160
				var provider = xmldoc.getElementsByTagName('connection')[0];
1161
				$('username').setValue('');
1162
				$('password').setValue('');
1163
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1164
					$('phone').setValue('#777');
1165
					$('apn').setValue('');
1166
				} else {
1167
					$('phone').setValue('*99#');
1168
					$('apn').setValue(provider.getElementsByTagName('apn')[0].firstChild.data);
1169
				}
1170
				$('username').setValue(provider.getElementsByTagName('username')[0].firstChild.data);
1171
				$('password').setValue(provider.getElementsByTagName('password')[0].firstChild.data);
1172
			}
1173
		});
1174
	}
1175

    
1176
</script>
1177
</head>
1178
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1179
	<?php include("fbegin.inc"); ?>
1180
	<form action="interfaces.php" method="post" name="iform" id="iform">
1181
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1182
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1183
		<?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 />
1184
		<?php endif; ?>
1185
		<?php if ($savemsg) print_info_box($savemsg); ?>
1186
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
1187
			<tr>
1188
				<td id="mainarea">
1189
					<div class="tabcont">
1190
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1191
						<tr>
1192
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1193
						</tr>
1194
						<tr>
1195
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1196
							<td width="78%" class="vtable">
1197
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked"; ?> onClick="show_allcfg(this);">
1198
							<strong><?=gettext("Enable Interface"); ?></strong>
1199
							</td>
1200
						</tr>
1201
					</table>
1202
					<div style="display:none;" name="allcfg" id="allcfg">
1203
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1204
						<tr>
1205
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1206
							<td width="78%" class="vtable">
1207
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
1208
								<br><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1209
							</td>
1210
						</tr>
1211
						<tr>
1212
							<td valign="middle" class="vncell"><strong><?=gettext("Type"); ?></strong></td>
1213
							<td class="vtable">
1214
								<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
1215
								<?php
1216
									foreach ($types as $key => $opt) {
1217
										echo "<option onClick=\"updateType('{$key}');\"";
1218
										if ($key == $pconfig['type'])
1219
											echo " selected";
1220
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1221
										echo "</option>";
1222
									}
1223
								?>
1224
								</select>
1225
							</td>
1226
						</tr>
1227
						<tr>
1228
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1229
							<td class="vtable">
1230
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
1231
								<?php
1232
									$ip = getenv('REMOTE_ADDR');
1233
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1234
									$mac = str_replace("\n","",$mac);
1235
									if($mac):
1236
								?>
1237
									<a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1238
								<?php endif; ?>
1239
								<br>
1240
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1241
								"address of the WAN interface"); ?><br>
1242
								<?=gettext("(may be required with some cable connections)"); ?><br>
1243
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1244
								"or leave blank"); ?>
1245
							</td>
1246
						</tr>
1247
						<tr>
1248
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1249
							<td class="vtable">
1250
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
1251
								<br>
1252
								<?=gettext("If you leave this field blank, the adapter's default MTU will " .
1253
								"be used. This is typically 1500 bytes but can vary on some hardware."); ?>
1254
							</td>
1255
						</tr>
1256
						<tr>
1257
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1258
							<td class="vtable">
1259
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>">
1260
								<br>
1261
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1262
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1263
								"header size) will be in effect."); ?>
1264
							</td>
1265
						</tr>
1266
						<tr>
1267
							<td colspan="2" valign="top" height="16"></td>
1268
						</tr>
1269
						<tr style="display:none;" name="none" id="none">
1270
						</tr>
1271
						<tr style="display:none;" name="staticv4" id="staticv4">
1272
							<td colspan="2" style="padding:0px;">
1273
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1274
									<tr>
1275
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1276
									</tr>
1277
									<tr>
1278
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1279
										<td width="78%" class="vtable">
1280
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
1281
											/
1282
											<select name="subnet" class="formselect" id="subnet">
1283
												<?php
1284
												for ($i = 32; $i > 0; $i--) {
1285
													if($i <> 31) {
1286
														echo "<option value=\"{$i}\" ";
1287
														if ($i == $pconfig['subnet']) echo "selected";
1288
														echo ">" . $i . "</option>";
1289
													}
1290
												}
1291
												?>
1292
											</select>
1293
										</td>
1294
									</tr>
1295
									<tr>
1296
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway"); ?></td>
1297
										<td width="78%" class="vtable">
1298
											<select name="gateway" class="formselect" id="gateway">
1299
												<option value="none" selected><?=gettext("None"); ?></option>
1300
													<?php
1301
													if(count($a_gateways) > 0) {
1302
														foreach ($a_gateways as $gateway) {
1303
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1304
													?>
1305
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
1306
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1307
															</option>
1308
													<?php
1309
															}
1310
														}
1311
													}
1312
													?>
1313
											</select>
1314
											- or  <strong><a OnClick="show_add_gateway();" href="#"><?=gettext("add a new one."); ?></a></strong>
1315
											<br/>
1316
											<div id='addgwbox'>
1317
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add one using the link above"); ?>
1318
											</div>
1319
											<div id='notebox'>
1320
											</div>
1321
											<div id="status">
1322
											</div>
1323
											<div style="display:none" id="addgateway" name="addgateway">
1324
												<p>
1325
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1326
													<tr>
1327
														<td>
1328
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1329
																<tr><td>&nbsp;</td>
1330
																<tr>
1331
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1332
																</tr>
1333
																<tr><td>&nbsp;</td>
1334
																<?php
1335
																if($if == "wan" || $if == "WAN")
1336
																	$checked = " CHECKED";
1337
																?>
1338
																<tr>
1339
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
1340
																</tr>
1341
																<tr>
1342
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td>
1343
																</tr>
1344
																<tr>
1345
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></td><td><input id="gatewayip" name="gatewayip"></td>
1346
																</tr>
1347
																<tr>
1348
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1349
																</tr>
1350
																<tr><td>&nbsp;</td>
1351
																<tr>
1352
																	<td>&nbsp;</td>
1353
																	<td>
1354
																		<center>
1355
																			<div id='savebuttondiv'>
1356
																				<input id="gwsave" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave();'>
1357
																				<input id="gwcancel" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway();'>
1358
																			</div>
1359
																		</center>
1360
																	</td>
1361
																</tr>
1362
																<tr><td>&nbsp;</td></tr>
1363
															</table>
1364
														</td>
1365
													</tr>
1366
												</table>
1367
												<p/>
1368
											</div>
1369
										</td>
1370
									</tr>
1371
								</table>
1372
							</td>
1373
						</tr>
1374
						<tr style="display:none;" name="staticv6" id="staticv6">
1375
							<td colspan="2" style="padding:0px;">
1376
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1377
									<tr>
1378
										<td colspan="2" valign="top">&nbsp;</td>
1379
									</tr>
1380
									<tr>
1381
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1382
									</tr>
1383
									<tr>
1384
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1385
										<td width="78%" class="vtable">
1386
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>">
1387
											/
1388
											<select name="subnetv6" class="formselect" id="subnetv6">
1389
												<?php
1390
												for ($i = 128; $i > 0; $i--) {
1391
													if($i <> 127) {
1392
														echo "<option value=\"{$i}\" ";
1393
														if ($i == $pconfig['subnetv6']) echo "selected";
1394
														echo ">" . $i . "</option>";
1395
													}
1396
												}
1397
												?>
1398
											</select>
1399
										</td>
1400
									</tr>
1401
									<tr>
1402
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway IPv6"); ?></td>
1403
										<td width="78%" class="vtable">
1404
											<select name="pd-sla-id" class="formselect" id="pd-sla-id">
1405
												<option value="none" selected><?=gettext("None"); ?></option>
1406
												<?php
1407
												// FIXME: Needs to calculate from prefix length from dhcp-pd
1408
												// Needs to check if the ID is not used on another interface
1409
												for ($i = 16; $i > 0; $i--) {
1410
													if($i <> 15) {
1411
														echo "<option value=\"{$i}\" ";
1412
														if ($i == $pconfig['pd-sla-id']) echo "selected";
1413
														echo ">" . $i . "</option>";
1414
													}
1415
												}
1416
												?>
1417

    
1418
										</td>
1419
									</tr>
1420
									<tr>
1421
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway IPv6"); ?></td>
1422
										<td width="78%" class="vtable">
1423
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1424
												<option value="none" selected><?=gettext("None"); ?></option>
1425
													<?php
1426
													if(count($a_gateways) > 0) {
1427
														foreach ($a_gateways as $gateway) {
1428
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1429
													?>
1430
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected"; ?>>
1431
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1432
															</option>
1433
													<?php
1434
															}
1435
														}
1436
													}
1437
													?>
1438
											</select>
1439
											- or <strong><a OnClick="show_add_gateway_v6();" href="#"><?=gettext("add a new one."); ?></a></strong>
1440
											<br/>
1441
											<div id='addgwboxv6'>
1442
											<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above"); ?>
1443
											</div>
1444
											<div id='noteboxv6'>
1445
											</div>
1446
											<div id="statusv6">
1447
											</div>
1448
											<div style="display:none" id="addgatewayv6" name="addgatewayv6">
1449
												<p>
1450
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1451
													<tr>
1452
														<td>
1453
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1454
																<tr><td>&nbsp;</td>
1455
																<tr>
1456
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1457
																</tr>
1458
																<tr><td>&nbsp;</td>
1459
																<?php
1460
																if($if == "wan" || $if == "WAN")
1461
																	$checked = " CHECKED";
1462
																?>
1463
																<tr>
1464
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?>></td>
1465
																</tr>
1466
																<tr>
1467
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>"></td>
1468
																</tr>
1469
																<tr>
1470
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></td><td><input id="gatewayipv6" name="gatewayipv6"></td>
1471
																</tr>
1472
																<tr>
1473
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescrv6" name="gatewaydescrv6"></td>
1474
																</tr>
1475
																<tr><td>&nbsp;</td>
1476
																<tr>
1477
																	<td>&nbsp;</td>
1478
																	<td>
1479
																		<center>
1480
																			<div id='savebuttondivv6'>
1481
																				<input id="gwsavev6" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave_v6();'>
1482
																				<input id="gwcancelv6" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway_v6();'>
1483
																			</div>
1484
																		</center>
1485
																	</td>
1486
																</tr>
1487
																<tr><td>&nbsp;</td></tr>
1488
															</table>
1489
														</td>
1490
													</tr>
1491
												</table>
1492
												<p/>
1493
											</div>
1494
										</td>
1495
									</tr>
1496
								</table>
1497
							</td>
1498
						</tr>
1499
						<tr style="display:none;" name="dhcp" id="dhcp">
1500
							<td colspan="2" style="padding: 0px;">
1501
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1502
									<tr>
1503
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration"); ?></td>
1504
									</tr>
1505
									<!-- Uncomment to expose DHCP+ in GUI
1506
									<tr>
1507
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1508
										<td width="78%" class="vtable">
1509
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked"; ?> >
1510
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1511
										<br/>
1512
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
1513
										</td>
1514
									</tr>
1515
									-->
1516
									<tr>
1517
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1518
										<td width="78%" class="vtable">
1519
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1520
											<br>
1521
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1522
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1523
											"this (for client identification)."); ?>
1524
										</td>
1525
									</tr>
1526
									<tr>
1527
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
1528
										<td width="78%" class="vtable">
1529
											<input name="duid" type="text" class="formfld unknown" id="duid" size="40" value="<?=htmlspecialchars($pconfig['duid']);?>">
1530
											<br>
1531
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
1532
											"when requesting a DHCPv6 lease."); ?><br />
1533
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
1534
													$current_duid = file_get_contents("/var/db/dhcp6c_duid");
1535
												}
1536
												echo gettext("The current DUID is: '") . $current_duid ."'";
1537
											?>
1538
											
1539
										</td>
1540
									</tr>
1541
									<tr>
1542
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
1543
										<td width="78%" class="vtable">
1544
											<select name="dhcp-ia-pd-len" class="formselect" id="dhcp-ia-pd-len">
1545
												<?php
1546
												$sizes = array(16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
1547
												foreach($sizes as $bits => $length) {
1548
													echo "<option value=\"{$bits}\" ";
1549
													if ($bits == $pconfig['dhcp-ia-pd-len']) echo "selected";
1550
													echo ">" . $length . "</option>";
1551
												}
1552
												?>
1553
											</select>
1554
											<br>
1555
											<?=gettext("The value in this field is the delegated prefix length provided by DHCPv6. Normally specified by the ISP."); ?>
1556
										</td>
1557
									</tr>
1558
									<tr>
1559
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IP address"); ?></td>
1560
										<td width="78%" class="vtable">
1561
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
1562
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1563
												<?php
1564
												for ($i = 32; $i > 0; $i--) {
1565
													if($i <> 31) {
1566
														echo "<option value=\"{$i}\" ";
1567
														if ($i == $pconfig['alias-subnet']) echo "selected";
1568
														echo ">" . $i . "</option>";
1569
													}
1570
												}
1571
												?>
1572
											</select>
1573
											<?=gettext("The value in this field is used as a fixed alias IP address by the " .
1574
											"DHCP client."); ?>
1575
										</td>
1576
									</tr>
1577
									
1578
								</table>
1579
							</td>
1580
						</tr>
1581
						<tr style="display:none;" name="ppp" id="ppp">
1582
							<td colspan="2" style="padding: 0px;">
1583
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1584
									<tr>
1585
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
1586
									</tr>
1587
									<tr name="ppp_provider" id="ppp_provider">
1588
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
1589
										<td width="78%" class="vtable">
1590
											<table border="0" cellpadding="0" cellspacing="0">
1591
												<tr id="trcountry">
1592
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
1593
													<td>
1594
														<select class="formselect" name="country" id="country" onChange="providers_list()">
1595
															<option></option>
1596
														</select>
1597
													</td>
1598
												</tr>
1599
												<tr id="trprovider" style="display:none">
1600
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
1601
													<td>
1602
														<select class="formselect" name="provider" id="provider" onChange="providerplan_list()">
1603
															<option></option>
1604
														</select>
1605
													</td>
1606
												</tr>
1607
												<tr id="trproviderplan" style="display:none">
1608
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
1609
													<td>
1610
														<select class="formselect" name="providerplan" id="providerplan" onChange="prefill_provider()">
1611
															<option></option>
1612
														</select>
1613
													</td>
1614
												</tr>
1615
											</table>
1616
											<br/><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
1617
										</td>
1618
									</tr>
1619
									<tr>
1620
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
1621
										<td width="78%" class="vtable">
1622
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
1623
										</td>
1624
									</tr>
1625
									<tr>
1626
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
1627
										<td width="78%" class="vtable">
1628
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
1629
										</td>
1630
									</tr>
1631
									<tr name="phone_num" id="phone_num">
1632
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
1633
										<td width="78%" class="vtable">
1634
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>">
1635
										</td>
1636
									</tr>
1637
									<tr name="apn_" id="apn_">
1638
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
1639
										<td width="78%" class="vtable">
1640
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
1641
										</td>
1642
									</tr>
1643
									<tr name="interface" id="interface" >
1644
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
1645
										<td width="78%" class="vtable">
1646
											<select name="port" id="port" class="formselect">
1647
											<?php
1648
												$portlist = glob("/dev/cua*");
1649
												$modems = glob("/dev/modem*");
1650
												$portlist = array_merge($portlist, $modems);
1651
												foreach ($portlist as $port) {
1652
													if(preg_match("/\.(lock|init)$/", $port))
1653
														continue;
1654
													echo "<option value=\"".trim($port)."\"";
1655
													if ($pconfig['port'] == $port)
1656
														echo "selected";
1657
													echo ">{$port}</option>";
1658
												}?>
1659
											</select>
1660
										</td>
1661
									</tr>
1662
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
1663
										<?php if (isset($pconfig['pppid'])): ?>
1664
											<td width="78%" class="vtable">
1665
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
1666
											<?=gettext("to edit PPP configuration."); ?>
1667
											</td>
1668
										<?php else: ?>
1669
											<td width="78%" class="vtable">
1670
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
1671
											<?=gettext("to create a PPP configuration."); ?>
1672
											</td>
1673
										<?php endif; ?>
1674
									</tr>
1675
								</table>
1676
							</td>
1677
						</tr>
1678
						<tr style="display:none;" name="pppoe" id="pppoe">
1679
							<td colspan="2" style="padding:0px;">
1680
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1681
									<tr>
1682
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
1683
									</tr>
1684
									<tr>
1685
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
1686
										<td width="78%" class="vtable">
1687
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
1688
										</td>
1689
									</tr>
1690
									<tr>
1691
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
1692
										<td width="78%" class="vtable">
1693
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
1694
										</td>
1695
									</tr>
1696
									<tr>
1697
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
1698
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
1699
											<br> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
1700
										</td>
1701
									</tr>
1702
									<tr>
1703
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
1704
										<td width="78%" class="vtable">
1705
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>>
1706
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
1707
											<?=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."); ?>
1708
										</td>
1709
									</tr>
1710
									<tr>
1711
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
1712
										<td width="78%" class="vtable">
1713
											<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."); ?>
1714
										</td>
1715
									</tr>
1716
									<tr>
1717
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
1718
										<td width="78%" class="vtable">
1719
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
1720
												<tr>
1721
													<td align="left" valign="top">
1722
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
1723
														<select valign="top" id="reset_type" name="pppoe-reset-type" class="formselect" onChange="show_reset_settings(this.value);">
1724
															<option value = ""><?=gettext("Disabled"); ?></option>
1725
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?=gettext("Custom"); ?></option>
1726
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?=gettext("Pre-Set"); ?></option>
1727
														</select> <?=gettext("Select a reset timing type"); ?>
1728
														</p>
1729
														<?php if ($pconfig['pppoe_pr_custom']): ?>
1730
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
1731
														<?php else: ?>
1732
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
1733
														<?php endif; ?>
1734
														<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" />
1735
														<?=gettext("hour (0-23)"); ?><br />
1736
														<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" />
1737
														<?=gettext("minute (0-59)"); ?><br />
1738
														<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']);?>" />
1739
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
1740
														<br />&nbsp;<br />
1741
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
1742
														<?=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."); ?>
1743
														</p>
1744
														<?php if ($pconfig['pppoe_pr_preset']): ?>
1745
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
1746
														<?php else: ?>
1747
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
1748
														<?php endif; ?>
1749
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
1750
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
1751
														<br />
1752
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
1753
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
1754
														<br />
1755
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
1756
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
1757
														<br />
1758
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
1759
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
1760
														</p>
1761
													</td>
1762
												</tr>
1763
											</table>
1764
										</td>
1765
									</tr>
1766

    
1767
									<tr>
1768
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
1769
										<?php if (isset($pconfig['pppid'])): ?>
1770
											<td width="78%" class="vtable">
1771
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
1772
											<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
1773
											</td>
1774
										<?php else: ?>
1775
											<td width="78%" class="vtable">
1776
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
1777
											<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
1778
											</td>
1779
										<?php endif; ?>
1780
									</tr>
1781
								</table>
1782
							</td>
1783
						</tr>
1784
						<tr style="display:none;" name="pptp" id="pptp">
1785
							<td colspan="2" style="padding:0px;">
1786
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1787
									<tr>
1788
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP/L2TP configuration"); ?></td>
1789
									</tr>
1790
									<tr>
1791
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
1792
										<td width="78%" class="vtable">
1793
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
1794
										</td>
1795
									</tr>
1796
									<tr>
1797
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
1798
										<td width="78%" class="vtable">
1799
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
1800
										</td>
1801
									</tr>
1802
									<tr>
1803
										<td width="22%" width="100" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
1804
										<td width="78%" class="vtable">
1805
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>">
1806
											/
1807
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
1808
												<?php for ($i = 31; $i > 0; $i--): ?>
1809
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected"; ?>>
1810
														<?=$i;?></option>
1811
												<?php endfor; ?>
1812
											</select>
1813
										</td>
1814
									</tr>
1815
									<tr>
1816
										<td width="22%" width="100" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
1817
										<td width="78%" class="vtable">
1818
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>">
1819
										</td>
1820
									</tr>
1821
									<tr>
1822
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
1823
										<td width="78%" class="vtable">
1824
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?>>
1825
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
1826
											<?=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."); ?>
1827
										</td>
1828
									</tr>
1829
									<tr>
1830
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
1831
										<td width="78%" class="vtable">
1832
											<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."); ?>
1833
										</td>
1834
									</tr>
1835
									<tr>
1836
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1837
										<?php if (isset($pconfig['pppid'])): ?>
1838
											<td width="78%" class="vtable">
1839
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
1840
											<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
1841
											</td>
1842
										<?php else: ?>
1843
											<td width="78%" class="vtable">
1844
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
1845
											<?=gettext("for advanced PPTP and L2TP configuration options");?>.
1846
											</td>
1847
										<?php endif; ?>
1848
									</tr>
1849
								</table>
1850
							</td>
1851
						</tr>
1852
						<?php
1853
							/* Wireless interface? */
1854
							if (isset($wancfg['wireless'])):
1855
						?>
1856
						<tr>
1857
							<td colspan="2" valign="top" height="16"></td>
1858
						</tr>
1859
						<tr>
1860
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
1861
						</tr>
1862
						<tr>
1863
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
1864
							<td class="vtable">
1865
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked";?>>
1866
								<br/><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
1867
							</td>
1868
						</tr>
1869
						<tr>
1870
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
1871
							<td class="vtable">
1872
							<select name="standard" class="formselect" id="standard">
1873
								<?php
1874
								foreach($wl_modes as $wl_standard => $wl_channels) {
1875
									echo "<option ";
1876
									if ($pconfig['standard'] == "$wl_standard")
1877
										echo "selected ";
1878
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
1879
								}
1880
								?>
1881
							</select>
1882
							</td>
1883
						</tr>
1884
						<?php if (isset($wl_modes['11g'])): ?>
1885
						<tr>
1886
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
1887
							<td class="vtable">
1888
								<select name="protmode" class="formselect" id="protmode">
1889
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected";?> value="off"><?=gettext("Protection mode off"); ?></option>
1890
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
1891
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
1892
								</select>
1893
								<br/>
1894
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
1895
								<br/>
1896
							</td>
1897
						</tr>
1898
						<?php else: ?>
1899
						<input name="protmode" type="hidden" id="protmode" value="off">
1900
						<?php endif; ?>
1901
						<tr>
1902
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
1903
							<td class="vtable">
1904
								<select name="txpower" class="formselect" id="txpower">
1905
									<?
1906
									for($x = 99; $x > 0; $x--) {
1907
										if($pconfig["txpower"] == $x)
1908
											$SELECTED = " SELECTED";
1909
										else
1910
											$SELECTED = "";
1911
										echo "<option {$SELECTED}>{$x}</option>\n";
1912
									}
1913
									?>
1914
								</select><br/>
1915
								<?=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."); ?>
1916
							</td>
1917
						</tr>
1918
						<tr>
1919
							<td valign="top" class="vncellreq"><?=gettext("Channel"); ?></td>
1920
							<td class="vtable">
1921
								<select name="channel" class="formselect" id="channel">
1922
									<option <?php if ($pconfig['channel'] == 0) echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
1923
									<?php
1924
									foreach($wl_modes as $wl_standard => $wl_channels) {
1925
										if($wl_standard == "11g") { $wl_standard = "11b/g"; }
1926
										else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
1927
										else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
1928
										foreach($wl_channels as $wl_channel) {
1929
											echo "<option ";
1930
											if ($pconfig['channel'] == "$wl_channel") {
1931
												echo "selected ";
1932
											}
1933
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
1934
											if(isset($wl_chaninfo[$wl_channel]))
1935
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
1936
											echo "</option>\n";
1937
										}
1938
									}
1939
									?>
1940
								</select>
1941
								<br/>
1942
								<?=gettext("Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)"); ?>
1943
								<br/>
1944
								<?=gettext("Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above."); ?>
1945
							</td>
1946
						</tr>
1947
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
1948
						<tr>
1949
							<td valign="top" class="vncell"><?=gettext("Antenna settings"); ?></td>
1950
							<td class="vtable">
1951
								<table border="0" cellpadding="0" cellspacing="0">
1952
									<tr>
1953
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])): ?>
1954
										<td>
1955
											<?=gettext("Diversity"); ?><br/>
1956
											<select name="diversity" class="formselect" id="diversity">
1957
												<option <?php if (!isset($pconfig['diversity'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
1958
												<option <?php if ($pconfig['diversity'] === '0') echo "selected"; ?> value="0"><?=gettext("Off"); ?></option>
1959
												<option <?php if ($pconfig['diversity'] === '1') echo "selected"; ?> value="1"><?=gettext("On"); ?></option>
1960
											</select>
1961
										</td>
1962
										<td>&nbsp;&nbsp</td>
1963
										<?php endif; ?>
1964
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])): ?>
1965
										<td>
1966
											<?=gettext("Transmit antenna"); ?><br/>
1967
											<select name="txantenna" class="formselect" id="txantenna">
1968
												<option <?php if (!isset($pconfig['txantenna'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
1969
												<option <?php if ($pconfig['txantenna'] === '0') echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
1970
												<option <?php if ($pconfig['txantenna'] === '1') echo "selected"; ?> value="1"><?=gettext("#1"); ?></option>
1971
												<option <?php if ($pconfig['txantenna'] === '2') echo "selected"; ?> value="2"><?=gettext("#2"); ?></option>
1972
											</select>
1973
										</td>
1974
										<td>&nbsp;&nbsp</td>
1975
										<?php endif; ?>
1976
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
1977
										<td>
1978
											<?=gettext("Receive antenna"); ?><br/>
1979
											<select name="rxantenna" class="formselect" id="rxantenna">
1980
												<option <?php if (!isset($pconfig['rxantenna'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
1981
												<option <?php if ($pconfig['rxantenna'] === '0') echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
1982
												<option <?php if ($pconfig['rxantenna'] === '1') echo "selected"; ?> value="1"><?=gettext("#1"); ?></option>
1983
												<option <?php if ($pconfig['rxantenna'] === '2') echo "selected"; ?> value="2"><?=gettext("#2"); ?></option>
1984
											</select>
1985
										</td>
1986
										<?php endif; ?>
1987
									</tr>
1988
								</table>
1989
								<br/>
1990
								<?=gettext("Note: The antenna numbers do not always match up with the labels on the card."); ?>
1991
							</td>
1992
						</tr>
1993
						<?php endif; ?>
1994
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])): ?>
1995
						<tr>
1996
							<td valign="top" class="vncell"><?=gettext("Distance setting"); ?></td>
1997
							<td class="vtable">
1998
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>">
1999
								<br/>
2000
								<?=gettext("Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client"); ?><br/>
2001
								<?=gettext("(measured in Meters and works only for Atheros based cards !)"); ?>
2002
							</td>
2003
						</tr>
2004
						<?php endif; ?>
2005
						<tr>
2006
							<td valign="top" class="vncell"><?=gettext("Regulatory settings"); ?></td>
2007
							<td class="vtable">
2008
								<?=gettext("Regulatory domain"); ?><br/>
2009
								<select name="regdomain" class="formselect" id="regdomain">
2010
									<option <?php if (empty($pconfig['regdomain'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2011
									<?php
2012
									foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
2013
										echo "<option ";
2014
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
2015
											echo "selected ";
2016
										}
2017
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
2018
									}
2019
									?>
2020
								</select>
2021
								<br/>
2022
								<?=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."); ?>
2023
								<br/><br/>
2024
								<?=gettext("Country (listed with country code and regulatory domain)"); ?><br/>
2025
								<select name="regcountry" class="formselect" id="regcountry">
2026
									<option <?php if (empty($pconfig['regcountry'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2027
									<?php
2028
									foreach($wl_countries as $wl_country_key => $wl_country) {
2029
										echo "<option ";
2030
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
2031
											echo "selected ";
2032
										}
2033
										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";
2034
									}
2035
									?>
2036
								</select>
2037
								<br/>
2038
								<?=gettext("Note: Any country setting other than \"Default\" will override the regulatory domain setting"); ?>.
2039
								<br/><br/>
2040
								<?=gettext("Location"); ?><br/>
2041
								<select name="reglocation" class="formselect" id="reglocation">
2042
									<option <?php if (empty($pconfig['reglocation'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2043
									<option <?php if ($pconfig['reglocation'] == 'indoor') echo "selected"; ?> value="indoor"><?=gettext("Indoor"); ?></option>
2044
									<option <?php if ($pconfig['reglocation'] == 'outdoor') echo "selected"; ?> value="outdoor"><?=gettext("Outdoor"); ?></option>
2045
									<option <?php if ($pconfig['reglocation'] == 'anywhere') echo "selected"; ?> value="anywhere"><?=gettext("Anywhere"); ?></option>
2046
								</select>
2047
								<br/><br/>
2048
								<?=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."); ?>
2049
								<br/>
2050
								<?=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."); ?>
2051
							</td>
2052
						</tr>
2053
						<tr>
2054
							<td colspan="2" valign="top" height="16"></td>
2055
						</tr>
2056
						<tr>
2057
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Network-specific wireless configuration");?></td>
2058
						</tr>
2059
						<tr>
2060
							<td valign="top" class="vncellreq"><?=gettext("Mode"); ?></td>
2061
							<td class="vtable">
2062
								<select name="mode" class="formselect" id="mode">
2063
									<option <?php if ($pconfig['mode'] == 'bss') echo "selected";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
2064
									<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
2065
									<option <?php if ($pconfig['mode'] == 'hostap') echo "selected";?> value="hostap"><?=gettext("Access Point"); ?></option>
2066
								</select>
2067
							</td>
2068
						</tr>
2069
						<tr>
2070
							<td valign="top" class="vncellreq"><?=gettext("SSID"); ?></td>
2071
							<td class="vtable">
2072
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>">
2073
							</td>
2074
						</tr>
2075
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
2076
						<tr>
2077
							<td valign="top" class="vncell"><?=gettext("Minimum wireless standard"); ?></td>
2078
							<td class="vtable">
2079
								<select name="puremode" class="formselect" id="puremode">
2080
									<option <?php if ($pconfig['puremode'] == 'any') echo "selected";?> value="any"><?=gettext("Any"); ?></option>
2081
									<?php if (isset($wl_modes['11g'])): ?>
2082
									<option <?php if ($pconfig['puremode'] == '11g') echo "selected";?> value="11g"><?=gettext("802.11g"); ?></option>
2083
									<?php endif; ?>
2084
									<option <?php if ($pconfig['puremode'] == '11n') echo "selected";?> value="11n"><?=gettext("802.11n"); ?></option>
2085
								</select>
2086
								<br/>
2087
								<?=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)."); ?>
2088
							</td>
2089
						</tr>
2090
						<?php elseif (isset($wl_modes['11g'])): ?>
2091
						<tr>
2092
							<td valign="top" class="vncell"><?=gettext("802.11g only"); ?></td>
2093
							<td class="vtable">
2094
								<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <?php if ($pconfig['puremode'] == '11g') echo "checked";?>>
2095
								<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)."); ?>
2096
							</td>
2097
						</tr>
2098
						<?php endif; ?>
2099
						<tr>
2100
							<td valign="top" class="vncell"><?=gettext("Allow intra-BSS communication"); ?></td>
2101
							<td class="vtable">
2102
								<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <?php if ($pconfig['apbridge_enable']) echo "checked";?>>
2103
								<br/>
2104
								<?=gettext("When operating as an access point, enable this if you want to pass packets between wireless clients directly."); ?>
2105
								<br/>
2106
								<?=gettext("Disabling the internal bridging is useful when traffic is to be processed with packet filtering."); ?>
2107
							</td>
2108
						</tr>
2109
						<tr>
2110
							<td valign="top" class="vncell"><?=gettext("Enable WME"); ?></td>
2111
							<td class="vtable">
2112
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <?php if ($pconfig['wme_enable']) echo "checked";?>>
2113
								<br/><?=gettext("Setting this option will force the card to use WME (wireless QoS)."); ?>
2114
							</td>
2115
						</tr>
2116
						<tr>
2117
							<td valign="top" class="vncell"><?=gettext("Enable Hide SSID"); ?></td>
2118
							<td class="vtable">
2119
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <?php if ($pconfig['hidessid_enable']) echo "checked";?>>
2120
								<br/>
2121
								<?=gettext("Setting this option will force the card to NOT broadcast its SSID"); ?>
2122
								<br/>
2123
								<?=gettext("(this might create problems for some clients)."); ?>
2124
							</td>
2125
						</tr>
2126
						<tr>
2127
							<td valign="top" class="vncell"><?=gettext("WEP"); ?></td>
2128
							<td class="vtable">
2129
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <?php if ($pconfig['wep_enable']) echo "checked"; ?>>
2130
								<strong><?=gettext("Enable WEP"); ?></strong>
2131
								<table border="0" cellspacing="0" cellpadding="0">
2132
									<tr>
2133
										<td>&nbsp;</td>
2134
										<td>&nbsp;</td>
2135
										<td>&nbsp;<?=gettext("TX key"); ?>&nbsp;</td>
2136
									</tr>
2137
									<tr>
2138
										<td><?=gettext("Key 1:"); ?>&nbsp;&nbsp;</td>
2139
										<td>
2140
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>">
2141
										</td>
2142
										<td align="center">
2143
											<input name="txkey" type="radio" value="1" <?php if ($pconfig['txkey'] == 1) echo "checked";?>>
2144
										</td>
2145
									</tr>
2146
									<tr>
2147
										<td><?=gettext("Key 2:"); ?>&nbsp;&nbsp;</td>
2148
										<td>
2149
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>">
2150
										</td>
2151
										<td align="center">
2152
											<input name="txkey" type="radio" value="2" <?php if ($pconfig['txkey'] == 2) echo "checked";?>>
2153
										</td>
2154
									</tr>
2155
									<tr>
2156
										<td><?=gettext("Key 3:"); ?>&nbsp;&nbsp;</td>
2157
										<td>
2158
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>">
2159
										</td>
2160
										<td align="center">
2161
											<input name="txkey" type="radio" value="3" <?php if ($pconfig['txkey'] == 3) echo "checked";?>>
2162
										</td>
2163
									</tr>
2164
									<tr>
2165
										<td><?=gettext("Key 4:"); ?>&nbsp;&nbsp;</td>
2166
										<td>
2167
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>">
2168
										</td>
2169
										<td align="center">
2170
											<input name="txkey" type="radio" value="4" <?php if ($pconfig['txkey'] == 4) echo "checked";?>>
2171
										</td>
2172
									</tr>
2173
								</table>
2174
								<br/>
2175
								<?=gettext("40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'."); ?><br/>
2176
								<?=gettext("104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'."); ?>
2177
							</td>
2178
						</tr>
2179
						<tr>
2180
							<td valign="top" class="vncell"><?=gettext("WPA"); ?></td>
2181
							<td class="vtable">
2182
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <?php if ($pconfig['wpa_enable']) echo "checked"; ?>>
2183
								<strong><?=gettext("Enable WPA"); ?></strong>
2184
								<br/><br/>
2185
								<table border="0" cellspacing="0" cellpadding="0">
2186
									<tr>
2187
										<td>&nbsp;</td>
2188
										<td>&nbsp;<?=gettext("WPA Pre Shared Key"); ?>&nbsp;</td>
2189
									</tr>
2190
									<tr>
2191
										<td><?=gettext("PSK:"); ?>&nbsp;&nbsp;</td>
2192
										<td>
2193
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>">
2194
										</td>
2195
									</tr>
2196
								</table>
2197
								<br/><?=gettext("Passphrase must be from 8 to 63 characters."); ?>
2198
							</td>
2199
						</tr>
2200
						<tr>
2201
							<td valign="top" class="vncell"><?=gettext("WPA Mode"); ?></td>
2202
							<td class="vtable">
2203
								<select name="wpa_mode" class="formselect" id="wpa_mode">
2204
									<option <?php if ($pconfig['wpa_mode'] == '1') echo "selected";?> value="1"><?=gettext("WPA"); ?></option>
2205
									<option <?php if ($pconfig['wpa_mode'] == '2') echo "selected";?> value="2"><?=gettext("WPA2"); ?></option>
2206
									<option <?php if ($pconfig['wpa_mode'] == '3') echo "selected";?> value="3"><?=gettext("Both"); ?></option>
2207
								</select>
2208
							</td>
2209
						</tr>
2210
						<tr>
2211
							<td valign="top" class="vncell"><?=gettext("WPA Key Management Mode"); ?></td>
2212
							<td class="vtable">
2213
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
2214
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected";?> value="WPA-PSK"><?=gettext("Pre Shared Key"); ?></option>
2215
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected";?> value="WPA-EAP"><?=gettext("Extensible Authentication Protocol"); ?></option>
2216
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected";?> value="WPA-PSK WPA-EAP"><?=gettext("Both"); ?></option>
2217
								</select>
2218
							</td>
2219
						</tr>
2220
						<tr>
2221
							<td valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
2222
							<td class="vtable">
2223
								<select name="auth_algs" class="formselect" id="auth_algs">
2224
									<option <?php if ($pconfig['auth_algs'] == '1') echo "selected";?> value="1"><?=gettext("Open System Authentication"); ?></option>
2225
									<option <?php if ($pconfig['auth_algs'] == '2') echo "selected";?> value="2"><?=gettext("Shared Key Authentication"); ?></option>
2226
									<option <?php if ($pconfig['auth_algs'] == '3') echo "selected";?> value="3"><?=gettext("Both"); ?></option>
2227
								</select>
2228
								<br/><?=gettext("Note: Shared Key Authentication requires WEP."); ?></br>
2229
							</td>
2230
						</tr>
2231
						<tr>
2232
							<td valign="top" class="vncell"><?=gettext("WPA Pairwise"); ?></td>
2233
							<td class="vtable">
2234
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
2235
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected";?> value="CCMP TKIP"><?=gettext("Both"); ?></option>
2236
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected";?> value="CCMP"><?=gettext("AES (recommended)"); ?></option>
2237
									<option <?php if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected";?> value="TKIP"><?=gettext("TKIP"); ?></option>
2238
								</select>
2239
							</td>
2240
						</tr>
2241
						<tr>
2242
							<td valign="top" class="vncell"><?=gettext("Key Rotation"); ?></td>
2243
							<td class="vtable">
2244
								<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";?>">
2245
								<br/><?=gettext("Allowed values are 1-9999 but should not be longer than Master Key Regeneration time."); ?>
2246
							</td>
2247
						</tr>
2248
						<tr>
2249
							<td valign="top" class="vncell"><?=gettext("Master Key Regeneration"); ?></td>
2250
							<td class="vtable">
2251
								<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";?>">
2252
								<br/><?=gettext("Allowed values are 1-9999 but should not be shorter than Key Rotation time."); ?>
2253
							</td>
2254
						</tr>
2255
						<tr>
2256
							<td valign="top" class="vncell"><?=gettext("Strict Key Regeneration"); ?></td>
2257
							<td class="vtable">
2258
								<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <?php if ($pconfig['wpa_strict_rekey']) echo "checked"; ?>>
2259
								<br/><?=gettext("Setting this option will force the AP to rekey whenever a client disassociates."); ?>
2260
							</td>
2261
						</tr>
2262
						<tr>
2263
							<td valign="top" class="vncell"><?=gettext("Enable IEEE802.1X Authentication"); ?></td>
2264
							<td class="vtable">
2265
								<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <?php if ($pconfig['ieee8021x']) echo "checked";?>>
2266
								<br/><?=gettext("Setting this option will enable 802.1x authentication."); ?>
2267
								<br/><span class="red"><strong><?=gettext("NOTE"); ?>:</strong></span> <?=gettext("this option requires checking the \"Enable WPA box\"."); ?>
2268
							</td>
2269
						</tr>
2270
						<tr>
2271
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server IP Address"); ?></td>
2272
							<td class="vtable">
2273
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>">
2274
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
2275
							</td>
2276
						</tr>
2277
						<tr>
2278
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Port"); ?></td>
2279
							<td class="vtable">
2280
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>">
2281
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
2282
							</td>
2283
						</tr>
2284
						<tr>
2285
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Shared Secret"); ?></td>
2286
							<td class="vtable">
2287
								<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']);?>">
2288
								<br/>
2289
							</td>
2290
						</tr>
2291
						<tr>
2292
							<td valign="top" class="vncell">802.1X <?=gettext("Authentication Roaming Preauth"); ?></td>
2293
							<td class="vtable">
2294
								<input name="rsn_preauth" id="rsn_preauth" type="checkbox" class="formfld unknown" size="66" value="yes" <? if ($pconfig['rsn_preauth']) echo "checked"; ?>>
2295
								<br/>
2296
							</td>
2297
						</tr>
2298
						<?php endif; ?>
2299
						<tr>
2300
							<td colspan="2" valign="top" height="16"></td>
2301
						</tr>
2302
						<tr>
2303
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Private networks"); ?></td>
2304
						</tr>
2305
						<tr>
2306
							<td valign="middle" class="vncell">&nbsp;</td>
2307
							<td class="vtable">
2308
								<a name="rfc1918"></a>
2309
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
2310
								<strong><?=gettext("Block private networks"); ?></strong><br>
2311
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2312
								"for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as"); ?>
2313
								<?=gettext("well as loopback addresses (127/8)."); ?>&nbsp;&nbsp; <?=gettext("You should generally " .
2314
								"leave this option turned on, unless your WAN network lies in such " .
2315
								"a private address space, too."); ?>
2316
							</td>
2317
						</tr>
2318
						<tr>
2319
							<td valign="middle" class="vncell">&nbsp;</td>
2320
							<td class="vtable">
2321
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
2322
								<strong><?=gettext("Block bogon networks"); ?></strong><br>
2323
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2324
								"(but not RFC 1918) or not yet assigned by IANA."); ?>&nbsp;&nbsp;
2325
								<?=gettext("Bogons are prefixes that should never appear in the Internet routing table, " .
2326
								"and obviously should not appear as the source address in any packets you receive."); ?>
2327
							</td>
2328
						</tr>
2329
					</table> <!-- End "allcfg" table -->
2330
					</div> <!-- End "allcfg" div -->
2331

    
2332
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2333
						<tr>
2334
							<td width="22%" valign="top">
2335
								&nbsp;
2336
							</td>
2337
							<td width="78%">
2338
								<br/>
2339
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2340
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2341
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2342
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2343
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2344
								<?php endif; ?>
2345
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2346
							</td>
2347
						</tr>
2348
					</table>
2349
				</td>
2350
			</tr>
2351
		</table>
2352
		<!--
2353
		</div>
2354
		</td></tr>
2355
		</table>
2356
		-->
2357
	</form>
2358
	<script type="text/javascript">
2359
		var gatewayip;
2360
		var name;
2361
		var gatewayipv6;
2362
		var namev6;
2363
		function show_add_gateway() {
2364
			document.getElementById("addgateway").style.display = '';
2365
			document.getElementById("addgwbox").style.display = 'none';
2366
			document.getElementById("gateway").style.display = 'none';
2367
			document.getElementById("save").style.display = 'none';
2368
			document.getElementById("cancel").style.display = 'none';
2369
			document.getElementById("gwsave").style.display = '';
2370
			document.getElementById("gwcancel").style.display = '';
2371
			$('notebox').innerHTML="";
2372
		}
2373
		function show_add_gateway_v6() {
2374
			document.getElementById("addgatewayv6").style.display = '';
2375
			document.getElementById("addgwboxv6").style.display = 'none';
2376
			document.getElementById("gatewayv6").style.display = 'none';
2377
			document.getElementById("save").style.display = 'none';
2378
			document.getElementById("cancel").style.display = 'none';
2379
			document.getElementById("gwsave").style.display = '';
2380
			document.getElementById("gwcancel").style.display = '';
2381
			$('noteboxv6').innerHTML="";
2382
		}
2383
		function hide_add_gateway() {
2384
			document.getElementById("addgateway").style.display = 'none';
2385
			document.getElementById("addgwbox").style.display = '';
2386
			document.getElementById("gateway").style.display = '';
2387
			document.getElementById("save").style.display = '';
2388
			document.getElementById("cancel").style.display = '';
2389
			document.getElementById("gwsave").style.display = '';
2390
			document.getElementById("gwcancel").style.display = '';
2391
		}
2392
		function hide_add_gateway_v6() {
2393
			document.getElementById("addgatewayv6").style.display = 'none';
2394
			document.getElementById("addgwboxv6").style.display = '';
2395
			document.getElementById("gatewayv6").style.display = '';
2396
			document.getElementById("save").style.display = '';
2397
			document.getElementById("cancel").style.display = '';
2398
			document.getElementById("gwsave").style.display = '';
2399
			document.getElementById("gwcancel").style.display = '';
2400
		}
2401
		function hide_add_gatewaysave() {
2402
			document.getElementById("addgateway").style.display = 'none';
2403
			$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif"> One moment please...';
2404
			var iface = $F('if');
2405
			name = $('name').getValue();
2406
			var descr = $('gatewaydescr').getValue();
2407
			gatewayip = $('gatewayip').getValue();
2408
			var defaultgw = $('defaultgw').getValue();
2409
			var url = "system_gateways_edit.php";
2410
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2411
			var myAjax = new Ajax.Request(
2412
				url,
2413
				{
2414
					method: 'post',
2415
					parameters: pars,
2416
					onFailure: report_failure,
2417
					onComplete: save_callback
2418
				});
2419
		}
2420
		function hide_add_gatewaysave_v6() {
2421
			document.getElementById("addgatewayv6").style.display = 'none';
2422
			$('statusv6').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif"> One moment please...';
2423
			var iface = $F('if');
2424
			name = $('namev6').getValue();
2425
			var descr = $('gatewaydescrv6').getValue();
2426
			gatewayip = $('gatewayipv6').getValue();
2427
			var defaultgw = $('defaultgwv6').getValue();
2428
			var url_v6 = "system_gateways_edit.php";
2429
			var pars_v6 = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2430
			var myAjax_v6 = new Ajax.Request(
2431
				url_v6,
2432
				{
2433
					method: 'post',
2434
					parameters: pars_v6,
2435
					onFailure: report_failure_v6,
2436
					onComplete: save_callback_v6
2437
				});
2438
		}
2439
		function addOption(selectbox,text,value)
2440
		{
2441
			var optn = document.createElement("OPTION");
2442
			optn.text = text;
2443
			optn.value = value;
2444
			selectbox.options.add(optn);
2445
			selectbox.selectedIndex = (selectbox.options.length-1);
2446
			$('notebox').innerHTML="<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.";
2447
		}
2448
		function addOption_v6(selectbox,text,value)
2449
		{
2450
			var optn = document.createElement("OPTION");
2451
			optn.text = text;
2452
			optn.value = value;
2453
			selectbox.options.add(optn);
2454
			selectbox.selectedIndex = (selectbox.options.length-1);
2455
			$('noteboxv6').innerHTML="<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.";
2456
		}
2457
		function report_failure() {
2458
			alert("Sorry, we could not create your IPv4 gateway at this time.");
2459
			hide_add_gateway();
2460
		}
2461
		function report_failure_v6() {
2462
			alert("Sorry, we could not create your IPv6 gateway at this time.");
2463
			hide_add_gateway_v6();
2464
		}
2465
		function save_callback(transport) {
2466
			var response = transport.responseText;
2467
			if(response) {
2468
				document.getElementById("addgateway").style.display = 'none';
2469
				hide_add_gateway();
2470
				$('status').innerHTML = '';
2471
				var gwtext = escape(name) + " - " + gatewayip;
2472
				addOption($('gateway'), gwtext, name);
2473
				// Auto submit form?
2474
				//document.iform.submit();
2475
				//$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif">';
2476
			} else {
2477
				report_failure();
2478
			}
2479
		}
2480
		function save_callback_v6(transport) {
2481
			var response_v6 = transport.responseText;
2482
			if(response_v6) {
2483
				document.getElementById("addgatewayv6").style.display = 'none';
2484
				hide_add_gateway_v6();
2485
				$('statusv6').innerHTML = '';
2486
				var gwtext_v6 = escape(name) + " - " + gatewayip;
2487
				addOption_v6($('gatewayv6'), gwtext_v6, name);
2488
				// Auto submit form?
2489
				//document.iform.submit();
2490
				//$('statusv6').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif">';
2491
			} else {
2492
				report_failure_v6();
2493
			}
2494
		}
2495
		<?php
2496
		echo "show_allcfg(document.iform.enable);";
2497
		echo "updateType('{$pconfig['type']}');\n";
2498
		?>
2499
	</script>
2500
	<?php include("fend.inc"); ?>
2501
	</body>
2502
</html>
(87-87/231)