Project

General

Profile

Download (104 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
// Populate page descr if it does not exist.
89
if ($if == "wan" && !$wancfg['descr'])
90
	$wancfg['descr'] = "WAN";
91
else if ($if == "lan" && !$wancfg['descr'])
92
	$wancfg['descr'] = "LAN";
93

    
94

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

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

    
108
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
109
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
110
	}
111

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

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

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

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

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

    
216
switch($wancfg['ipaddrv6']) {
217
	case "dhcpv6":
218
		$pconfig['type'] = "dhcpv6";
219
		break;
220
	default:
221
		/* if we have dual stack we need a combined type */
222
		if(is_ipaddr($wancfg['ipaddrv6'])) {
223
			$pconfig['type'] = "staticv6";
224
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
225
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
226
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
227
			if((is_ipaddr($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) {
333
				if (isset($config['interfaces'][$ifapply]['enable']))
334
					interface_configure($ifapply, true);
335
				else
336
					interface_bring_down($ifapply);
337
			}
338
		}
339
		/* restart snmp so that it binds to correct address */
340
		services_snmpd_configure();
341

    
342
		/* sync filter configuration */
343
		setup_gateways_monitor();
344

    
345
		clear_subsystem_dirty('staticroutes');
346

    
347
		filter_configure();
348

    
349
		enable_rrd_graphing();
350
	}
351
	@unlink("{$g['tmp_path']}/.interfaces.apply");
352
	header("Location: interfaces.php?if={$if}");
353
	exit;
354
} else if ($_POST && $_POST['enable'] != "yes") {
355
	unset($wancfg['enable']);
356
	if (isset($wancfg['wireless']))
357
		interface_sync_wireless_clones($wancfg, false);
358
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
359
	mark_subsystem_dirty('interfaces');
360
	if (file_exists("{$g['tmp_path']}/.interfaces.apply"))
361
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
362
	else
363
		$toapplylist = array();
364
	$toapplylist[$if] = $if; 
365
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
366
	header("Location: interfaces.php?if={$if}");
367
	exit;
368
} else if ($_POST) {
369

    
370
	unset($input_errors);
371
	$pconfig = $_POST;
372
	conf_mount_rw();
373

    
374
	/* filter out spaces from descriptions  */
375
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
376

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

    
401
	switch(strtolower($_POST['type'])) {
402
		case "staticv4":
403
			$reqdfields = explode(" ", "ipaddr subnet gateway");
404
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
405
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
406
			break;
407
		case "staticv6":
408
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
409
			$reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
410
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
411
			break;
412
		case "staticv4v6":
413
			$reqdfields = explode(" ", "ipaddr subnet gateway ipaddrv6 subnetv6 gatewayv6");
414
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"),gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
415
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
416
			break;
417
		case "none":
418
			if(is_array($config['virtualip']['vip'])) {
419
				foreach ($config['virtualip']['vip'] as $vip) {
420
					if ($vip['interface'] == $if)
421
						$input_errors[] = gettext("This interface is referenced by VIPs please delete those before setting the interface to 'none' configuration.");
422
				}
423
			}
424
		case "dhcp":
425
			break;
426
		case "dhcpv6":
427
			if (in_array($wancfg['ipaddrv6'], array("ppp", "pppoe", "pptp", "l2tp")))
428
				$input_errors[] = gettext("You have to reassign the interface to be able to configure as {$_POST['type']}.");
429
			break;
430
		case "ppp":
431
			$reqdfields = explode(" ", "port phone");
432
			$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
433
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
434
			break;
435
		case "pppoe":
436
			if ($_POST['pppoe_dialondemand']) {
437
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
438
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
439
			} else {
440
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
441
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
442
			}
443
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
444
			break;
445
		case "pptp":
446
			if ($_POST['pptp_dialondemand']) {
447
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
448
				$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"));
449
			} else {
450
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
451
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
452
			}
453
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
454
			break;
455
	}
456

    
457
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
458
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
459
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr'])))
460
		$input_errors[] = gettext("A valid IPv4 address must be specified.");
461
	if (($_POST['ipaddrv6'] && !is_ipaddr($_POST['ipaddrv6'])))
462
		$input_errors[] = gettext("A valid IPv6 address must be specified.");
463
	if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
464
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
465
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6'])))
466
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
467
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address'])))
468
		$input_errors[] = gettext("A valid alias IP address must be specified.");
469
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
470
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
471
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
472
		$match = false;
473
		foreach($a_gateways as $gateway) {
474
			if(in_array($_POST['gateway'], $gateway)) {
475
				$match = true;
476
			}
477
		}
478
		foreach($a_gateways as $gateway) {
479
			if(in_array($_POST['gatewayv6'], $gateway)) {
480
				$match = true;
481
			}
482
		}
483
		if(!$match) {
484
			$input_errors[] = gettext("A valid gateway must be specified.");
485
		}
486
	}
487
	if (($_POST['provider'] && !is_domain($_POST['provider'])))
488
		$input_errors[] = gettext("The service name contains invalid characters.");
489
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
490
		$input_errors[] = gettext("The idle timeout value must be an integer.");
491
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
492
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23)
493
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
494
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
495
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59)
496
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
497
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate'])))
498
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
499
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local'])))
500
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
501
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet'])))
502
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
503
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote'])))
504
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
505
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout']))
506
		$input_errors[] = gettext("The idle timeout value must be an integer.");
507
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])))
508
		$input_errors[] = gettext("A valid MAC address must be specified.");
509
	if ($_POST['mtu'] && ($_POST['mtu'] < 576))
510
		$input_errors[] = gettext("The MTU must be greater than 576 bytes.");
511
	if ($_POST['mss'] && ($_POST['mss'] < 576))
512
		$input_errors[] = gettext("The MSS must be greater than 576 bytes.");
513
	/* Wireless interface? */
514
	if (isset($wancfg['wireless'])) {
515
		$reqdfields = explode(" ", "mode ssid");
516
		$reqdfieldsn = array(gettext("Mode"),gettext("SSID"));
517
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
518
		check_wireless_mode();
519
		/* loop through keys and enforce size */
520
		for ($i = 1; $i <= 4; $i++) {
521
			if ($_POST['key' . $i]) {
522
				/* 64 bit */
523
				if (strlen($_POST['key' . $i]) == 5)
524
					continue;
525
				if (strlen($_POST['key' . $i]) == 10) {
526
					/* hex key */
527
					if (stristr($_POST['key' . $i], "0x") == false) {
528
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
529
					}
530
					continue;
531
				}
532
				if (strlen($_POST['key' . $i]) == 12) {
533
					/* hex key */
534
					if(stristr($_POST['key' . $i], "0x") == false) {
535
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
536
					}
537
					continue;
538
				}
539
				/* 128 bit */
540
				if (strlen($_POST['key' . $i]) == 13)
541
					continue;
542
				if (strlen($_POST['key' . $i]) == 26) {
543
					/* hex key */
544
					if (stristr($_POST['key' . $i], "0x") == false)
545
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
546
					continue;
547
				}
548
				if(strlen($_POST['key' . $i]) == 28)
549
					continue;
550
				$input_errors[] =  gettext("Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.");
551
				break;
552
			}
553
		}
554

    
555
		if ($_POST['passphrase']) {
556
                	$passlen = strlen($_POST['passphrase']);
557
                	if ($passlen < 8 || $passlen > 64)
558
                        	$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
559
		}
560
	}
561
	if (!$input_errors) {
562
		if ($wancfg['type'] != $_POST['type']) {
563
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
564
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
565
				unset($a_ppps[$pppid]);
566
			}
567
		}
568
		$ppp = array();
569
		if ($wancfg['ipaddr'] != "ppp")
570
			unset($wancfg['ipaddr']);
571
		if ($wancfg['ipaddrv6'] != "ppp")
572
			unset($wancfg['ipaddrv6']);
573
		unset($wancfg['subnet']);
574
		unset($wancfg['gateway']);
575
		unset($wancfg['subnetv6']);
576
		unset($wancfg['gatewayv6']);
577
		unset($wancfg['dhcphostname']);
578
		unset($wancfg['pppoe_username']);
579
		unset($wancfg['pppoe_password']);
580
		unset($wancfg['pptp_username']);
581
		unset($wancfg['pptp_password']);
582
		unset($wancfg['provider']);
583
		unset($wancfg['ondemand']);
584
		unset($wancfg['timeout']);
585
		if (isset($wancfg['pppoe']['pppoe-reset-type']))
586
			unset($wancfg['pppoe']['pppoe-reset-type']);
587
		unset($wancfg['local']);
588
		unset($wancfg['remote']);
589
		unset($a_ppps[$pppid]['apn']);
590
		unset($a_ppps[$pppid]['phone']);
591
		unset($a_ppps[$pppid]['localip']);
592
		unset($a_ppps[$pppid]['subnet']);
593
		unset($a_ppps[$pppid]['gateway']);
594
		unset($a_ppps[$pppid]['pppoe-reset-type']);
595
		unset($a_ppps[$pppid]['provider']);
596

    
597
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
598
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
599

    
600
		/* for dynamic interfaces we tack a gateway item onto the array to prevent system
601
		 * log messages from appearing. They can also manually add these items */
602
		/* 1st added gateway gets a default bit */
603
		if(!empty($a_gateways)) {
604
			$gateway_item = array();
605
			/* check for duplicates */
606
			$skip = false;
607
			foreach($a_gateways as $item) {
608
				if(($item['interface'] == "$if") && ($item['gateway'] == "dynamic")) {
609
					$skip = true;
610
				}
611
			}
612
			if($skip == false) {
613
				$gateway_item['gateway'] = "dynamic";
614
				$gateway_item['descr'] = gettext("Interface") . $if . gettext("dynamic gateway");
615
				$gateway_item['name'] = "GW_" . strtoupper($if);
616
				$gateway_item['interface'] = "{$if}";
617
			} else {
618
				unset($gateway_item);
619
			}
620
		}
621

    
622
		switch($_POST['type']) {
623
			case "staticv4":
624
				$wancfg['ipaddr'] = $_POST['ipaddr'];
625
				$wancfg['subnet'] = $_POST['subnet'];
626
				if ($_POST['gateway'] != "none") {
627
					$wancfg['gateway'] = $_POST['gateway'];
628
				}
629
				break;
630
			case "staticv6":
631
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
632
				$wancfg['subnetv6'] = $_POST['subnetv6'];
633
				if ($_POST['gatewayv6'] != "none") {
634
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
635
				}
636
				break;
637
			case "staticv4v6":
638
				$wancfg['ipaddr'] = $_POST['ipaddr'];
639
				$wancfg['subnet'] = $_POST['subnet'];
640
				if ($_POST['gateway'] != "none") {
641
					$wancfg['gateway'] = $_POST['gateway'];
642
				}
643
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
644
				$wancfg['subnetv6'] = $_POST['subnetv6'];
645
				if ($_POST['gatewayv6'] != "none") {
646
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
647
				}
648
				break;
649
			case "dhcp":
650
				$wancfg['ipaddr'] = "dhcp";
651
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
652
				$wancfg['alias-address'] = $_POST['alias-address'];
653
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
654
				if($gateway_item) {
655
					$a_gateways[] = $gateway_item;
656
				}
657
				break;
658
			case "dhcpv6":
659
				$wancfg['ipaddrv6'] = "dhcpv6";
660
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
661
				$wancfg['alias-address'] = $_POST['alias-address'];
662
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
663
				if($gateway_item) {
664
					$a_gateways[] = $gateway_item;
665
				}
666
				break;
667
			case "carpdev-dhcp":
668
				$wancfg['ipaddr'] = "carpdev-dhcp";
669
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
670
				$wancfg['alias-address'] = $_POST['alias-address'];
671
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
672
				if($gateway_item) {
673
					$a_gateways[] = $gateway_item;
674
				}
675
				break;
676
			case "ppp":
677
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
678
				$a_ppps[$pppid]['type'] = $_POST['type'];
679
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
680
				$a_ppps[$pppid]['ports'] = $_POST['port'];
681
				$a_ppps[$pppid]['username'] = $_POST['username'];
682
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
683
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
684
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
685
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
686
				$wancfg['ipaddr'] = $_POST['type'];
687
				unset($a_ppps[$pppid]['ondemand']);
688
				unset($a_ppps[$pppid]['idletimeout']);
689
				break;
690

    
691
			case "pppoe":
692
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
693
				$a_ppps[$pppid]['type'] = $_POST['type'];
694
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
695
				if (isset($_POST['ppp_port']))
696
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
697
				else
698
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
699
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
700
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
701
				if (!empty($_POST['provider']))
702
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
703
				else
704
					unset($a_ppps[$pppid]['provider']);
705
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
706
				if (!empty($_POST['idletimeout']))
707
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
708
				else
709
					unset($a_ppps[$pppid]['idletimeout']);
710

    
711
				if (!empty($_POST['pppoe-reset-type']))
712
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
713
				else
714
					unset($a_ppps[$pppid]['pppoe-reset-type']);
715
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
716
				$wancfg['ipaddr'] = $_POST['type'];
717
				if($gateway_item) {
718
					$a_gateways[] = $gateway_item;
719
				}
720

    
721
				break;
722
			case "pptp":
723
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
724
				$a_ppps[$pppid]['type'] = $_POST['type'];
725
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
726
				if (isset($_POST['ppp_port']))
727
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
728
				else
729
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
730
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
731
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
732
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
733
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
734
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
735
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
736
				if (!empty($_POST['idletimeout']))
737
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
738
				else
739
					unset($a_ppps[$pppid]['idletimeout']);
740
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
741
				$wancfg['ipaddr'] = $_POST['type'];
742
				if($gateway_item) {
743
					$a_gateways[] = $gateway_item;
744
				}
745
				break;
746
			case "none":
747
				break;
748
		}
749
		handle_pppoe_reset($_POST);
750

    
751
		if($_POST['blockpriv'] == "yes") {
752
			$wancfg['blockpriv'] = true;
753
		} else {
754
			unset($wancfg['blockpriv']);
755
		}
756
		if($_POST['blockbogons'] == "yes") {
757
			$wancfg['blockbogons'] = true;
758
		} else {
759
			unset($wancfg['blockbogons']);
760
		}
761
		$wancfg['spoofmac'] = $_POST['spoofmac'];
762
		if (empty($_POST['mtu'])) {
763
			unset($wancfg['mtu']);
764
		} else {
765
			$wancfg['mtu'] = $_POST['mtu'];
766
		}
767
		if (empty($_POST['mss'])) {
768
			unset($wancfg['mss']);
769
		} else {
770
			$wancfg['mss'] = $_POST['mss'];
771
		}
772
		if (isset($wancfg['wireless'])) {
773
			handle_wireless_post();
774
		}
775

    
776
		conf_mount_ro();
777
		write_config();
778

    
779
		if (file_exists("{$g['tmp_path']}/.interfaces.apply"))
780
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
781
		else
782
			$toapplylist = array();
783
		$toapplylist[$if] = $if; 
784
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
785

    
786
		mark_subsystem_dirty('interfaces');
787

    
788
		/* regenerate cron settings/crontab file */
789
		configure_cron();
790

    
791
		header("Location: interfaces.php?if={$if}");
792
		exit;
793
	}
794

    
795
} // end if($_POST)
796

    
797
function handle_wireless_post() {
798
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
799
	if (!is_array($wancfg['wireless']))
800
		$wancfg['wireless'] = array();
801
	$wancfg['wireless']['standard'] = $_POST['standard'];
802
	$wancfg['wireless']['mode'] = $_POST['mode'];
803
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
804
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
805
	$wancfg['wireless']['channel'] = $_POST['channel'];
806
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
807
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
808
	$wancfg['wireless']['distance'] = $_POST['distance'];
809
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
810
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
811
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
812
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
813
		foreach($wl_countries_attr as $wl_country) {
814
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
815
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
816
				break;
817
			}
818
		}
819
	}
820
	if (!is_array($wancfg['wireless']['wpa']))
821
		$wancfg['wireless']['wpa'] = array();
822
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
823
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
824
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
825
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
826
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
827
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
828
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
829
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
830
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
831
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
832
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
833
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
834
	if ($_POST['persistcommonwireless'] == "yes") {
835
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
836
			$config['wireless']['interfaces'][$wlanbaseif] = array();
837
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
838
		unset($config['wireless']['interfaces'][$wlanbaseif]);
839
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
840
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
841
	else if (isset($wancfg['wireless']['diversity']))
842
		unset($wancfg['wireless']['diversity']);
843
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
844
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
845
	else if (isset($wancfg['wireless']['txantenna']))
846
		unset($wancfg['wireless']['txantenna']);
847
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
848
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
849
	else if (isset($wancfg['wireless']['rxantenna']))
850
		unset($wancfg['wireless']['rxantenna']);
851
	if ($_POST['hidessid_enable'] == "yes")
852
		$wancfg['wireless']['hidessid']['enable'] = true;
853
	else if (isset($wancfg['wireless']['hidessid']['enable']))
854
		unset($wancfg['wireless']['hidessid']['enable']);
855
	if ($_POST['mac_acl_enable'] == "yes")
856
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
857
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
858
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
859
	if ($_POST['rsn_preauth'] == "yes")
860
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
861
	else
862
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
863
	if ($_POST['ieee8021x'] == "yes")
864
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
865
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
866
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
867
	if ($_POST['wpa_strict_rekey'] == "yes")
868
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
869
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
870
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
871
	if ($_POST['debug_mode'] == "yes")
872
		$wancfg['wireless']['wpa']['debug_mode'] = true;
873
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
874
		sunset($wancfg['wireless']['wpa']['debug_mode']);
875
	if ($_POST['wpa_enable'] == "yes")
876
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
877
	else if (isset($wancfg['wireless']['wpa']['enable']))
878
		unset($wancfg['wireless']['wpa']['enable']);
879
	if ($_POST['wep_enable'] == "yes") {
880
		if (!is_array($wancfg['wireless']['wep']))
881
			$wancfg['wireless']['wep'] = array();
882
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
883
	} else if (isset($wancfg['wireless']['wep']))
884
		unset($wancfg['wireless']['wep']);
885
	if ($_POST['wme_enable'] == "yes") {
886
		if (!is_array($wancfg['wireless']['wme']))
887
			$wancfg['wireless']['wme'] = array();
888
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
889
	} else if (isset($wancfg['wireless']['wme']['enable']))
890
		unset($wancfg['wireless']['wme']['enable']);
891
	if ($_POST['puremode'] == "11g") {
892
		if (!is_array($wancfg['wireless']['pureg']))
893
			$wancfg['wireless']['pureg'] = array();
894
		$wancfg['wireless']['pureg']['enable'] = true;
895
	} else if ($_POST['puremode'] == "11n") {
896
		if (!is_array($wancfg['wireless']['puren']))
897
			$wancfg['wireless']['puren'] = array();
898
		$wancfg['wireless']['puren']['enable'] = true;
899
	} else {
900
		if (isset($wancfg['wireless']['pureg']))
901
			unset($wancfg['wireless']['pureg']);
902
		if (isset($wancfg['wireless']['puren']))
903
			unset($wancfg['wireless']['puren']);
904
	}
905
	if ($_POST['apbridge_enable'] == "yes") {
906
		if (!is_array($wancfg['wireless']['apbridge']))
907
			$wancfg['wireless']['apbridge'] = array();
908
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
909
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
910
		unset($wancfg['wireless']['apbridge']['enable']);
911
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
912
		if (!is_array($wancfg['wireless']['turbo']))
913
			$wancfg['wireless']['turbo'] = array();
914
		$wancfg['wireless']['turbo']['enable'] = true;
915
	} else if (isset($wancfg['wireless']['turbo']['enable']))
916
		unset($wancfg['wireless']['turbo']['enable']);
917
	$wancfg['wireless']['wep']['key'] = array();
918
	for ($i = 1; $i <= 4; $i++) {
919
		if ($_POST['key' . $i]) {
920
			$newkey = array();
921
			$newkey['value'] = $_POST['key' . $i];
922
			if ($_POST['txkey'] == $i)
923
				$newkey['txkey'] = true;
924
			$wancfg['wireless']['wep']['key'][] = $newkey;
925
		}
926
	}
927
	interface_sync_wireless_clones($wancfg, true);
928
}
929

    
930
function check_wireless_mode() {
931
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
932

    
933
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
934
		return;
935

    
936
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
937
		$clone_count = 1;
938
	else
939
		$clone_count = 0;
940
	if (is_array($config['wireless']['clone'])) {
941
		foreach ($config['wireless']['clone'] as $clone) {
942
			if ($clone['if'] == $wlanbaseif)
943
				$clone_count++;
944
		}
945
	}
946
	if ($clone_count > 1) {
947
		$old_wireless_mode = $wancfg['wireless']['mode'];
948
		$wancfg['wireless']['mode'] = $_POST['mode'];
949
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
950
			$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']]);
951
		} else {
952
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
953
		}
954
		$wancfg['wireless']['mode'] = $old_wireless_mode;
955
	}
956
}
957

    
958
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
959
$statusurl = "status_interfaces.php";
960

    
961
$closehead = false;
962
include("head.inc");
963
$types = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "staticv6" => gettext("Static IPv6"), "staticv4v6" => gettext("Static IPv4 + IPv6"), "dhcp" => gettext("DHCP"), "dhcpv6" => gettext("DHCPv6"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP") /* , "carpdev-dhcp" => "CarpDev"*/);
964

    
965
?>
966

    
967
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
968
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
969
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
970
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
971

    
972
<script type="text/javascript">
973
	function updateType(t) {
974
		switch(t) {
975
			case "none": {
976
				$('staticv4','staticv6','dhcp','dhcpv6','pppoe','pptp', 'ppp').invoke('hide');
977
				break;
978
			}
979
			case "staticv4": {
980
				$('none','staticv6','dhcp','dhcpv6','pppoe','pptp', 'ppp').invoke('hide');
981
				break;
982
			}
983
			case "staticv6": {
984
				$('none','staticv4','dhcp','dhcpv6','pppoe','pptp', 'ppp').invoke('hide');
985
				break;
986
			}
987
			case "staticv4v6": {
988
				$('none','dhcp','dhcpv6','pppoe','pptp', 'ppp').invoke('hide');
989
				$('staticv4').show();
990
				$('staticv6').show();
991
				break;
992
			}
993
			case "dhcp": {
994
				$('none','staticv4','staticv6','dhcpv6','pppoe','pptp', 'ppp').invoke('hide');
995
				break;
996
			}
997
			case "dhcpv6": {
998
				$('none','staticv4','staticv6','dhcp','pppoe','pptp', 'ppp').invoke('hide');
999
				break;
1000
			}
1001
			case "ppp": {
1002
				$('none','staticv4','staticv6','dhcp','dhcpv6','pptp', 'pppoe').invoke('hide');
1003
				country_list();
1004
				break;
1005
			}
1006
			case "pppoe": {
1007
				$('none','staticv4','staticv6','dhcp','dhcpv6','pptp', 'ppp').invoke('hide');
1008
				break;
1009
			}
1010
			case "pptp": {
1011
				$('none','staticv4','staticv6','dhcp','dhcpv6','pppoe', 'ppp').invoke('hide');
1012
				break;
1013
			}
1014
		}
1015
		$(t).show();
1016
	}
1017

    
1018
	function show_allcfg(obj) {
1019
		if (obj.checked)
1020
			$('allcfg').show();
1021
		else
1022
			$('allcfg').hide();
1023
	}
1024

    
1025
	function show_reset_settings(reset_type) {
1026
		if (reset_type == 'preset') {
1027
			Effect.Appear('pppoepresetwrap', { duration: 0.0 });
1028
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
1029
		}
1030
		else if (reset_type == 'custom') {
1031
			Effect.Appear('pppoecustomwrap', { duration: 0.0 });
1032
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
1033
		} else {
1034
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
1035
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
1036
		}
1037
	}
1038
	function show_mon_config() {
1039
		document.getElementById("showmonbox").innerHTML='';
1040
		aodiv = document.getElementById('showmon');
1041
		aodiv.style.display = "block";
1042
	}
1043

    
1044
	function openwindow(url) {
1045
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1046
		if (oWin==null || typeof(oWin)=="undefined")
1047
			return false;
1048
		else
1049
			return true;
1050
	}
1051
	function country_list() {
1052
		$('country').childElements().each(function(node) { node.remove(); });
1053
		$('provider').childElements().each(function(node) { node.remove(); });
1054
		$('providerplan').childElements().each(function(node) { node.remove(); });
1055
		new Ajax.Request("getserviceproviders.php",{
1056
			onSuccess: function(response) {
1057
				var responseTextArr = response.responseText.split("\n");
1058
				responseTextArr.sort();
1059
				responseTextArr.each( function(value) {
1060
					var option = new Element('option');
1061
					country = value.split(":");
1062
					option.text = country[0];
1063
					option.value = country[1];
1064
					$('country').insert({ bottom : option });
1065
				});
1066
			}
1067
		});
1068
		$('trcountry').setStyle({display : "table-row"});
1069
	}
1070

    
1071
	function providers_list() {
1072
		$('provider').childElements().each(function(node) { node.remove(); });
1073
		$('providerplan').childElements().each(function(node) { node.remove(); });
1074
		new Ajax.Request("getserviceproviders.php",{
1075
			parameters: {country : $F('country')},
1076
			onSuccess: function(response) {
1077
				var responseTextArr = response.responseText.split("\n");
1078
				responseTextArr.sort();
1079
				responseTextArr.each( function(value) {
1080
					var option = new Element('option');
1081
					option.text = value;
1082
					option.value = value;
1083
					$('provider').insert({ bottom : option });
1084
				});
1085
			}
1086
		});
1087
		$('trprovider').setStyle({display : "table-row"});
1088
		$('trproviderplan').setStyle({display : "none"});
1089
	}
1090

    
1091
	function providerplan_list() {
1092
		$('providerplan').childElements().each(function(node) { node.remove(); });
1093
		$('providerplan').insert( new Element('option') );
1094
		new Ajax.Request("getserviceproviders.php",{
1095
			parameters: {country : $F('country'), provider : $F('provider')},
1096
			onSuccess: function(response) {
1097
				var responseTextArr = response.responseText.split("\n");
1098
				responseTextArr.sort();
1099
				responseTextArr.each( function(value) {
1100
					if(value != "") {
1101
						providerplan = value.split(":");
1102

    
1103
						var option = new Element('option');
1104
						option.text = providerplan[0] + " - " + providerplan[1];
1105
						option.value = providerplan[1];
1106
						$('providerplan').insert({ bottom : option });
1107
					}
1108
				});
1109
			}
1110
		});
1111
		$('trproviderplan').setStyle({display : "table-row"});
1112
	}
1113

    
1114
	function prefill_provider() {
1115
		new Ajax.Request("getserviceproviders.php",{
1116
			parameters: {country : $F('country'), provider : $F('provider'), plan : $F('providerplan')},
1117
			onSuccess: function(response) {
1118
				var xmldoc = response.responseXML;
1119
				var provider = xmldoc.getElementsByTagName('connection')[0];
1120
				$('username').setValue('');
1121
				$('password').setValue('');
1122
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1123
					$('phone').setValue('#777');
1124
					$('apn').setValue('');
1125
				} else {
1126
					$('phone').setValue('*99#');
1127
					$('apn').setValue(provider.getElementsByTagName('apn')[0].firstChild.data);
1128
				}
1129
				$('username').setValue(provider.getElementsByTagName('username')[0].firstChild.data);
1130
				$('password').setValue(provider.getElementsByTagName('password')[0].firstChild.data);
1131
			}
1132
		});
1133
	}
1134

    
1135
</script>
1136
</head>
1137
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1138
	<?php include("fbegin.inc"); ?>
1139
	<form action="interfaces.php" method="post" name="iform" id="iform">
1140
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1141
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1142
		<?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 />
1143
		<?php endif; ?>
1144
		<?php if ($savemsg) print_info_box($savemsg); ?>
1145
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
1146
			<tr>
1147
				<td id="mainarea">
1148
					<div class="tabcont">
1149
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1150
						<tr>
1151
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1152
						</tr>
1153
						<tr>
1154
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1155
							<td width="78%" class="vtable">
1156
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked"; ?> onClick="show_allcfg(this);">
1157
							<strong><?=gettext("Enable Interface"); ?></strong>
1158
							</td>
1159
						</tr>
1160
					</table>
1161
					<div style="display:none;" name="allcfg" id="allcfg">
1162
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1163
						<tr>
1164
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1165
							<td width="78%" class="vtable">
1166
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
1167
								<br><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1168
							</td>
1169
						</tr>
1170
						<tr>
1171
							<td valign="middle" class="vncell"><strong><?=gettext("Type"); ?></strong></td>
1172
							<td class="vtable">
1173
								<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
1174
								<?php
1175
									foreach ($types as $key => $opt) {
1176
										echo "<option onClick=\"updateType('{$key}');\"";
1177
										if ($key == $pconfig['type'])
1178
											echo " selected";
1179
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1180
										echo "</option>";
1181
									}
1182
								?>
1183
								</select>
1184
							</td>
1185
						</tr>
1186
						<tr>
1187
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1188
							<td class="vtable">
1189
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
1190
								<?php
1191
									$ip = getenv('REMOTE_ADDR');
1192
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1193
									$mac = str_replace("\n","",$mac);
1194
									if($mac):
1195
								?>
1196
									<a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1197
								<?php endif; ?>
1198
								<br>
1199
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1200
								"address of the WAN interface"); ?><br>
1201
								<?=gettext("(may be required with some cable connections)"); ?><br>
1202
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1203
								"or leave blank"); ?>
1204
							</td>
1205
						</tr>
1206
						<tr>
1207
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1208
							<td class="vtable">
1209
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
1210
								<br>
1211
								<?=gettext("If you leave this field blank, the adapter's default MTU will " .
1212
								"be used. This is typically 1500 bytes but can vary on some hardware."); ?>
1213
							</td>
1214
						</tr>
1215
						<tr>
1216
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1217
							<td class="vtable">
1218
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>">
1219
								<br>
1220
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1221
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1222
								"header size) will be in effect."); ?>
1223
							</td>
1224
						</tr>
1225
						<tr>
1226
							<td colspan="2" valign="top" height="16"></td>
1227
						</tr>
1228
						<tr style="display:none;" name="none" id="none">
1229
						</tr>
1230
						<tr style="display:none;" name="staticv4" id="staticv4">
1231
							<td colspan="2" style="padding:0px;">
1232
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1233
									<tr>
1234
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1235
									</tr>
1236
									<tr>
1237
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1238
										<td width="78%" class="vtable">
1239
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
1240
											/
1241
											<select name="subnet" class="formselect" id="subnet">
1242
												<?php
1243
												for ($i = 32; $i > 0; $i--) {
1244
													if($i <> 31) {
1245
														echo "<option value=\"{$i}\" ";
1246
														if ($i == $pconfig['subnet']) echo "selected";
1247
														echo ">" . $i . "</option>";
1248
													}
1249
												}
1250
												?>
1251
											</select>
1252
										</td>
1253
									</tr>
1254
									<tr>
1255
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Gateway"); ?></td>
1256
										<td width="78%" class="vtable">
1257
											<select name="gateway" class="formselect" id="gateway">
1258
												<option value="none" selected><?=gettext("None"); ?></option>
1259
													<?php
1260
													if(count($a_gateways) > 0) {
1261
														foreach ($a_gateways as $gateway) {
1262
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1263
													?>
1264
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
1265
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1266
															</option>
1267
													<?php
1268
															}
1269
														}
1270
													}
1271
													?>
1272
											</select>
1273
											<br/>
1274
											<div id='addgwbox'>
1275
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or"); ?> <a OnClick="show_add_gateway();" href="#"><?=gettext("add a new one."); ?></a>
1276
											</div>
1277
											<div id='notebox'>
1278
											</div>
1279
											<div id="status">
1280
											</div>
1281
											<div style="display:none" id="addgateway" name="addgateway">
1282
												<p>
1283
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1284
													<tr>
1285
														<td>
1286
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1287
																<tr><td>&nbsp;</td>
1288
																<tr>
1289
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1290
																</tr>
1291
																<tr><td>&nbsp;</td>
1292
																<?php
1293
																if($if == "wan" || $if == "WAN")
1294
																	$checked = " CHECKED";
1295
																?>
1296
																<tr>
1297
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
1298
																</tr>
1299
																<tr>
1300
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td>
1301
																</tr>
1302
																<tr>
1303
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></td><td><input id="gatewayip" name="gatewayip"></td>
1304
																</tr>
1305
																<tr>
1306
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1307
																</tr>
1308
																<tr><td>&nbsp;</td>
1309
																<tr>
1310
																	<td>&nbsp;</td>
1311
																	<td>
1312
																		<center>
1313
																			<div id='savebuttondiv'>
1314
																				<input type="hidden" name="addrtype" id="addrtype" value="IPv4" />
1315
																				<input id="gwsave" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave();'>
1316
																				<input id="gwcancel" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway();'>
1317
																			</div>
1318
																		</center>
1319
																	</td>
1320
																</tr>
1321
																<tr><td>&nbsp;</td></tr>
1322
															</table>
1323
														</td>
1324
													</tr>
1325
												</table>
1326
												<p/>
1327
											</div>
1328
										</td>
1329
									</tr>
1330
								</table>
1331
							</td>
1332
						</tr>
1333
						<tr style="display:none;" name="staticv6" id="staticv6">
1334
							<td colspan="2" style="padding:0px;">
1335
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1336
									<tr>
1337
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1338
									</tr>
1339
									<tr>
1340
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1341
										<td width="78%" class="vtable">
1342
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="20" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>">
1343
											/
1344
											<select name="subnetv6" class="formselect" id="subnetv6">
1345
												<?php
1346
												for ($i = 128; $i > 0; $i--) {
1347
													if($i <> 127) {
1348
														echo "<option value=\"{$i}\" ";
1349
														if ($i == $pconfig['subnetv6']) echo "selected";
1350
														echo ">" . $i . "</option>";
1351
													}
1352
												}
1353
												?>
1354
											</select>
1355
										</td>
1356
									</tr>
1357
									<tr>
1358
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Gateway"); ?></td>
1359
										<td width="78%" class="vtable">
1360
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1361
												<option value="none" selected><?=gettext("None"); ?></option>
1362
													<?php
1363
													if(count($a_gateways) > 0) {
1364
														foreach ($a_gateways as $gateway) {
1365
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1366
													?>
1367
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected"; ?>>
1368
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1369
															</option>
1370
													<?php
1371
															}
1372
														}
1373
													}
1374
													?>
1375
											</select>
1376
											<br/>
1377
											<div id='addgwbox'>
1378
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or"); ?> <a OnClick="show_add_gateway();" href="#"><?=gettext("add a new one."); ?></a>
1379
											</div>
1380
											<div id='notebox'>
1381
											</div>
1382
											<div id="status">
1383
											</div>
1384
											<div style="display:none" id="addgateway" name="addgateway">
1385
												<p>
1386
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1387
													<tr>
1388
														<td>
1389
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1390
																<tr><td>&nbsp;</td>
1391
																<tr>
1392
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1393
																</tr>
1394
																<tr><td>&nbsp;</td>
1395
																<?php
1396
																if($if == "wan" || $if == "WAN")
1397
																	$checked = " CHECKED";
1398
																?>
1399
																<tr>
1400
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?>></td>
1401
																</tr>
1402
																<tr>
1403
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GWv6"?>"></td>
1404
																</tr>
1405
																<tr>
1406
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></td><td><input id="gatewayip" name="gatewayip"></td>
1407
																</tr>
1408
																<tr>
1409
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1410
																</tr>
1411
																<tr><td>&nbsp;</td>
1412
																<tr>
1413
																	<td>&nbsp;</td>
1414
																	<td>
1415
																		<center>
1416
																			<div id='savebuttondiv'>
1417
																				<input type="hidden" name="addrtype" id="addrtype" value="IPv6" />
1418
																				<input id="gwsave" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave();'>
1419
																				<input id="gwcancel" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway();'>
1420
																			</div>
1421
																		</center>
1422
																	</td>
1423
																</tr>
1424
																<tr><td>&nbsp;</td></tr>
1425
															</table>
1426
														</td>
1427
													</tr>
1428
												</table>
1429
												<p/>
1430
											</div>
1431
										</td>
1432
									</tr>
1433
								</table>
1434
							</td>
1435
						</tr>
1436
						<tr style="display:none;" name="dhcp" id="dhcp">
1437
							<td colspan="2" style="padding: 0px;">
1438
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1439
									<tr>
1440
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCPv4 client configuration"); ?></td>
1441
									</tr>
1442
									<tr>
1443
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1444
										<td width="78%" class="vtable">
1445
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1446
											<br>
1447
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1448
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1449
											"this (for client identification)."); ?>
1450
										</td>
1451
									</tr>
1452
									<tr>
1453
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IP address"); ?></td>
1454
										<td width="78%" class="vtable">
1455
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
1456
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1457
												<?php
1458
												for ($i = 32; $i > 0; $i--) {
1459
													if($i <> 31) {
1460
														echo "<option value=\"{$i}\" ";
1461
														if ($i == $pconfig['alias-subnet']) echo "selected";
1462
														echo ">" . $i . "</option>";
1463
													}
1464
												}
1465
												?>
1466
											</select>
1467
											<?=gettext("The value in this field is used as a fixed alias IP address by the " .
1468
											"DHCP client."); ?>
1469
										</td>
1470
									</tr>
1471
								</table>
1472
							</td>
1473
						</tr>
1474
						<tr style="display:none;" name="dhcpv6" id="dhcpv6">
1475
							<td colspan="2" style="padding: 0px;">
1476
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1477
									<tr>
1478
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCPv6 client configuration"); ?></td>
1479
									</tr>
1480
									<tr>
1481
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1482
										<td width="78%" class="vtable">
1483
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1484
											<br>
1485
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
1486
											"and hostname when requesting a DHCPv6 lease. Some ISPs may require " .
1487
											"this (for client identification)."); ?>
1488
										</td>
1489
									</tr>
1490
								</table>
1491
							</td>
1492
						</tr>
1493
						<tr style="display:none;" name="ppp" id="ppp">
1494
							<td colspan="2" style="padding: 0px;">
1495
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1496
									<tr>
1497
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
1498
									</tr>
1499
									<tr name="ppp_provider" id="ppp_provider">
1500
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
1501
										<td width="78%" class="vtable">
1502
											<table border="0" cellpadding="0" cellspacing="0">
1503
												<tr id="trcountry">
1504
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
1505
													<td>
1506
														<select class="formselect" name="country" id="country" onChange="providers_list()">
1507
															<option></option>
1508
														</select>
1509
													</td>
1510
												</tr>
1511
												<tr id="trprovider" style="display:none">
1512
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
1513
													<td>
1514
														<select class="formselect" name="provider" id="provider" onChange="providerplan_list()">
1515
															<option></option>
1516
														</select>
1517
													</td>
1518
												</tr>
1519
												<tr id="trproviderplan" style="display:none">
1520
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
1521
													<td>
1522
														<select class="formselect" name="providerplan" id="providerplan" onChange="prefill_provider()">
1523
															<option></option>
1524
														</select>
1525
													</td>
1526
												</tr>
1527
											</table>
1528
											<br/><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
1529
										</td>
1530
									</tr>
1531
									<tr>
1532
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
1533
										<td width="78%" class="vtable">
1534
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
1535
										</td>
1536
									</tr>
1537
									<tr>
1538
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
1539
										<td width="78%" class="vtable">
1540
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
1541
										</td>
1542
									</tr>
1543
									<tr name="phone_num" id="phone_num">
1544
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
1545
										<td width="78%" class="vtable">
1546
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>">
1547
										</td>
1548
									</tr>
1549
									<tr name="apn_" id="apn_">
1550
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
1551
										<td width="78%" class="vtable">
1552
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
1553
										</td>
1554
									</tr>
1555
									<tr name="interface" id="interface" >
1556
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
1557
										<td width="78%" class="vtable">
1558
											<select name="port" id="port" class="formselect">
1559
											<?php
1560
												$portlist = glob("/dev/cua*");
1561
												$modems = glob("/dev/modem*");
1562
												$portlist = array_merge($portlist, $modems);
1563
												foreach ($portlist as $port) {
1564
													if(preg_match("/\.(lock|init)$/", $port))
1565
														continue;
1566
													echo "<option value=\"".trim($port)."\"";
1567
													if ($pconfig['port'] == $port)
1568
														echo "selected";
1569
													echo ">{$port}</option>";
1570
												}?>
1571
											</select>
1572
										</td>
1573
									</tr>
1574
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
1575
										<?php if (isset($pconfig['pppid'])): ?>
1576
											<td width="78%" class="vtable">
1577
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
1578
											<?=gettext("to edit PPP configuration."); ?>
1579
											</td>
1580
										<?php else: ?>
1581
											<td width="78%" class="vtable">
1582
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
1583
											<?=gettext("to create a PPP configuration."); ?>
1584
											</td>
1585
										<?php endif; ?>
1586
									</tr>
1587
								</table>
1588
							</td>
1589
						</tr>
1590
						<tr style="display:none;" name="pppoe" id="pppoe">
1591
							<td colspan="2" style="padding:0px;">
1592
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1593
									<tr>
1594
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
1595
									</tr>
1596
									<tr>
1597
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
1598
										<td width="78%" class="vtable">
1599
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
1600
										</td>
1601
									</tr>
1602
									<tr>
1603
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
1604
										<td width="78%" class="vtable">
1605
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
1606
										</td>
1607
									</tr>
1608
									<tr>
1609
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
1610
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
1611
											<br> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
1612
										</td>
1613
									</tr>
1614
									<tr>
1615
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
1616
										<td width="78%" class="vtable">
1617
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>>
1618
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
1619
											<?=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."); ?>
1620
										</td>
1621
									</tr>
1622
									<tr>
1623
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
1624
										<td width="78%" class="vtable">
1625
											<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."); ?>
1626
										</td>
1627
									</tr>
1628
									<tr>
1629
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
1630
										<td width="78%" class="vtable">
1631
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
1632
												<tr>
1633
													<td align="left" valign="top">
1634
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
1635
														<select valign="top" id="reset_type" name="pppoe-reset-type" class="formselect" onChange="show_reset_settings(this.value);">
1636
															<option value = ""><?=gettext("Disabled"); ?></option>
1637
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?=gettext("Custom"); ?></option>
1638
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?=gettext("Pre-Set"); ?></option>
1639
														</select> <?=gettext("Select a reset timing type"); ?>
1640
														</p>
1641
														<?php if ($pconfig['pppoe_pr_custom']): ?>
1642
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
1643
														<?php else: ?>
1644
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
1645
														<?php endif; ?>
1646
														<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" />
1647
														<?=gettext("hour (0-23)"); ?><br />
1648
														<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" />
1649
														<?=gettext("minute (0-59)"); ?><br />
1650
														<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']);?>" />
1651
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
1652
														<br />&nbsp;<br />
1653
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
1654
														<?=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."); ?>
1655
														</p>
1656
														<?php if ($pconfig['pppoe_pr_preset']): ?>
1657
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
1658
														<?php else: ?>
1659
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
1660
														<?php endif; ?>
1661
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
1662
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
1663
														<br />
1664
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
1665
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
1666
														<br />
1667
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
1668
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
1669
														<br />
1670
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
1671
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
1672
														</p>
1673
													</td>
1674
												</tr>
1675
											</table>
1676
										</td>
1677
									</tr>
1678

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

    
2244
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2245
						<tr>
2246
							<td width="22%" valign="top">
2247
								&nbsp;
2248
							</td>
2249
							<td width="78%">
2250
								<br/>
2251
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2252
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2253
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2254
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2255
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2256
								<?php endif; ?>
2257
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2258
							</td>
2259
						</tr>
2260
					</table>
2261
				</td>
2262
			</tr>
2263
		</table>
2264
		<!--
2265
		</div>
2266
		</td></tr>
2267
		</table>
2268
		-->
2269
	</form>
2270
	<script type="text/javascript">
2271
		var gatewayip;
2272
		var name;
2273
		function show_add_gateway() {
2274
			document.getElementById("addgateway").style.display = '';
2275
			document.getElementById("addgwbox").style.display = 'none';
2276
			document.getElementById("gateway").style.display = 'none';
2277
			document.getElementById("save").style.display = 'none';
2278
			document.getElementById("cancel").style.display = 'none';
2279
			document.getElementById("gwsave").style.display = '';
2280
			document.getElementById("gwcancel").style.display = '';
2281
			$('notebox').innerHTML="";
2282
		}
2283
		function hide_add_gateway() {
2284
			document.getElementById("addgateway").style.display = 'none';
2285
			document.getElementById("addgwbox").style.display = '';
2286
			document.getElementById("gateway").style.display = '';
2287
			document.getElementById("save").style.display = '';
2288
			document.getElementById("cancel").style.display = '';
2289
			document.getElementById("gwsave").style.display = '';
2290
			document.getElementById("gwcancel").style.display = '';
2291
		}
2292
		function hide_add_gatewaysave() {
2293
			document.getElementById("addgateway").style.display = 'none';
2294
			$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif"> One moment please...';
2295
			var iface = $F('if');
2296
			name = $('name').getValue();
2297
			var descr = $('gatewaydescr').getValue();
2298
			gatewayip = $('gatewayip').getValue();
2299
			addrtype = $('addrtype').getValue();
2300
			var defaultgw = $('defaultgw').getValue();
2301
			var url = "system_gateways_edit.php";
2302
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip) + '&type=' + escape(addrtype);
2303
			var myAjax = new Ajax.Request(
2304
				url,
2305
				{
2306
					method: 'post',
2307
					parameters: pars,
2308
					onFailure: report_failure,
2309
					onComplete: save_callback
2310
				});
2311
		}
2312
		function addOption(selectbox,text,value)
2313
		{
2314
			var optn = document.createElement("OPTION");
2315
			optn.text = text;
2316
			optn.value = value;
2317
			selectbox.options.add(optn);
2318
			selectbox.selectedIndex = (selectbox.options.length-1);
2319
			$('notebox').innerHTML="<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.";
2320
		}
2321
		function report_failure() {
2322
			alert("Sorry, we could not create your gateway at this time.");
2323
			hide_add_gateway();
2324
		}
2325
		function save_callback(transport) {
2326
			var response = transport.responseText;
2327
			if(response) {
2328
				document.getElementById("addgateway").style.display = 'none';
2329
				hide_add_gateway();
2330
				$('status').innerHTML = '';
2331
				addOption($('gateway'), name, name);
2332
				// Auto submit form?
2333
				//document.iform.submit();
2334
				//$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif">';
2335
			} else {
2336
				report_failure();
2337
			}
2338
		}
2339
		<?php
2340
		echo "show_allcfg(document.iform.enable);";
2341
		echo "updateType('{$pconfig['type']}');\n";
2342
		?>
2343
	</script>
2344
	<?php include("fend.inc"); ?>
2345
	</body>
2346
</html>
(82-82/222)