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 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
if ($_REQUEST['if']) {
58
	$if = $_REQUEST['if'];
59
} else {
60
	$if = "wan";
61
}
62

    
63
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
64
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
65
define("CRON_DAILY_PATTERN", "0 0 * * *");
66
define("CRON_HOURLY_PATTERN", "0 * * * *");
67

    
68
if (!is_array($config['ppps']['ppp']))
69
	$config['ppps']['ppp'] = array();
70

    
71
$a_ppps = &$config['ppps']['ppp'];
72

    
73
function remove_bad_chars($string) {
74
	return preg_replace('/[^a-z_0-9]/i','',$string);
75
}
76

    
77
if (!is_array($config['gateways']['gateway_item']))
78
	$config['gateways']['gateway_item'] = array();
79

    
80
$a_gateways = &$config['gateways']['gateway_item'];
81

    
82
$wancfg = &$config['interfaces'][$if];
83

    
84
foreach ($a_ppps as $pppid => $ppp) {
85
	if ($wancfg['if'] == $ppp['if'])
86
		break;
87
}
88

    
89
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
90
	$pconfig['pppid'] = $pppid;
91
	$pconfig['ptpid'] = $a_ppps[$pppid]['ptpid'];
92
	$pconfig['port'] = $a_ppps[$pppid]['ports'];
93
	if ($a_ppps[$pppid]['type'] == "ppp"){
94
		$pconfig['username'] = $a_ppps[$pppid]['username'];
95
		$pconfig['password'] = base64_decode($a_ppps[$pppid]['password']);
96

    
97
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
98
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
99
	}
100

    
101
	if ($a_ppps[$pppid]['type'] == "pppoe"){
102
		$pconfig['pppoe_username'] = $a_ppps[$pppid]['username'];
103
		$pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']);
104
		$pconfig['provider'] = $a_ppps[$pppid]['provider'];
105
		$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
106
		$pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout'];
107

    
108
		/* ================================================ */
109
		/* = force a connection reset at a specific time? = */
110
		/* ================================================ */
111

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

    
168
// Populate page descr if it does not exist.
169
if($if == "wan" && !$wancfg['descr']) {
170
	$wancfg['descr'] = "WAN";
171
} else if ($if == "lan" && !$wancfg['descr']) {
172
	$wancfg['descr'] = "LAN";
173
}
174
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
175
$pconfig['enable'] = isset($wancfg['enable']);
176

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

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

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

    
231
// print_r($pconfig);
232

    
233
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
234
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
235
$pconfig['spoofmac'] = $wancfg['spoofmac'];
236
$pconfig['mtu'] = $wancfg['mtu'];
237
$pconfig['mss'] = $wancfg['mss'];
238

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

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

    
331
		/* restart snmp so that it binds to correct address */
332
		services_snmpd_configure();
333
		if ($if == "lan")
334
			$savemsg = gettext("The changes have been applied.  You may need to correct your web browser's IP address.");
335

    
336
		/* sync filter configuration */
337
		setup_gateways_monitor();
338

    
339
		clear_subsystem_dirty('staticroutes');
340

    
341
		filter_configure();
342

    
343
		enable_rrd_graphing();
344
	}
345
	header("Location: interfaces.php?if={$if}");
346
	exit;
347
} else
348

    
349
if ($_POST && $_POST['enable'] != "yes") {
350
	unset($wancfg['enable']);
351
	if (isset($wancfg['wireless'])) {
352
		interface_sync_wireless_clones($wancfg, false);
353
	}
354
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
355
	mark_subsystem_dirty('interfaces');
356
	header("Location: interfaces.php?if={$if}");
357
	exit;
358
} else
359

    
360
if ($_POST) {
361
	unset($input_errors);
362
	$pconfig = $_POST;
363
	conf_mount_rw();
364

    
365
	/* filter out spaces from descriptions  */
366
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
367

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

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

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

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

    
586
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
587
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
588

    
589
		/* for dynamic interfaces we tack a gateway item onto the array to prevent system
590
		 * log messages from appearing. They can also manually add these items */
591
		/* 1st added gateway gets a default bit */
592
		if(!empty($a_gateways)) {
593
			$gateway_item = array();
594
			/* check for duplicates */
595
			$skip = false;
596
			foreach($a_gateways as $item) {
597
				if(($item['interface'] == "$if") && ($item['gateway'] == "dynamic")) {
598
					$skip = true;
599
				}
600
			}
601
			if($skip == false) {
602
				$gateway_item['gateway'] = "dynamic";
603
				$gateway_item['descr'] = gettext("Interface") . $if . gettext("dynamic gateway");
604
				$gateway_item['name'] = "GW_" . strtoupper($if);
605
				$gateway_item['interface'] = "{$if}";
606
			} else {
607
				unset($gateway_item);
608
			}
609
		}
610

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

    
680
			case "pppoe":
681
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
682
				$a_ppps[$pppid]['type'] = $_POST['type'];
683
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
684
				if (isset($_POST['ppp_port']))
685
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
686
				else
687
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
688
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
689
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
690
				if (!empty($_POST['provider']))
691
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
692
				else
693
					unset($a_ppps[$pppid]['provider']);
694
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
695
				if (!empty($_POST['idletimeout']))
696
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
697
				else
698
					unset($a_ppps[$pppid]['idletimeout']);
699

    
700
				if (!empty($_POST['pppoe-reset-type']))
701
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
702
				else
703
					unset($a_ppps[$pppid]['pppoe-reset-type']);
704
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
705
				$wancfg['ipaddr'] = $_POST['type'];
706
				if($gateway_item) {
707
					$a_gateways[] = $gateway_item;
708
				}
709

    
710
				break;
711
			case "pptp":
712
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
713
				$a_ppps[$pppid]['type'] = $_POST['type'];
714
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
715
				if (isset($_POST['ppp_port']))
716
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
717
				else
718
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
719
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
720
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
721
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
722
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
723
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
724
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
725
				if (!empty($_POST['idletimeout']))
726
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
727
				else
728
					unset($a_ppps[$pppid]['idletimeout']);
729
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
730
				$wancfg['ipaddr'] = $_POST['type'];
731
				if($gateway_item) {
732
					$a_gateways[] = $gateway_item;
733
				}
734
				break;
735
			case "none":
736
				break;
737
		}
738
		handle_pppoe_reset($_POST);
739

    
740
		if($_POST['blockpriv'] == "yes") {
741
			$wancfg['blockpriv'] = true;
742
		} else {
743
			unset($wancfg['blockpriv']);
744
		}
745
		if($_POST['blockbogons'] == "yes") {
746
			$wancfg['blockbogons'] = true;
747
		} else {
748
			unset($wancfg['blockbogons']);
749
		}
750
		$wancfg['spoofmac'] = $_POST['spoofmac'];
751
		if (empty($_POST['mtu'])) {
752
			unset($wancfg['mtu']);
753
		} else {
754
			$wancfg['mtu'] = $_POST['mtu'];
755
		}
756
		if (empty($_POST['mss'])) {
757
			unset($wancfg['mss']);
758
		} else {
759
			$wancfg['mss'] = $_POST['mss'];
760
		}
761
		if (isset($wancfg['wireless'])) {
762
			handle_wireless_post();
763
		}
764

    
765
		write_config();
766
		mark_subsystem_dirty('interfaces');
767
		/* regenerate cron settings/crontab file */
768
		configure_cron();
769
		conf_mount_ro();
770
		header("Location: interfaces.php?if={$if}");
771
		exit;
772
	}
773

    
774

    
775

    
776
} // end if($_POST)
777

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

    
911
function check_wireless_mode() {
912
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
913

    
914
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
915
		return;
916

    
917
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
918
		$clone_count = 1;
919
	else
920
		$clone_count = 0;
921
	if (is_array($config['wireless']['clone'])) {
922
		foreach ($config['wireless']['clone'] as $clone) {
923
			if ($clone['if'] == $wlanbaseif)
924
				$clone_count++;
925
		}
926
	}
927
	if ($clone_count > 1) {
928
		$old_wireless_mode = $wancfg['wireless']['mode'];
929
		$wancfg['wireless']['mode'] = $_POST['mode'];
930
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
931
			$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']]);
932
		} else {
933
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
934
		}
935
		$wancfg['wireless']['mode'] = $old_wireless_mode;
936
	}
937
}
938

    
939
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
940
$statusurl = "status_interfaces.php";
941

    
942
$closehead = false;
943
include("head.inc");
944
$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"*/);
945

    
946
?>
947

    
948
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
949
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
950
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
951
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
952

    
953
<script type="text/javascript">
954
	function updateType(t) {
955
		switch(t) {
956
			case "none": {
957
				$('staticv4','staticv6','dhcp','dhcpv6','pppoe','pptp', 'ppp').invoke('hide');
958
				break;
959
			}
960
			case "staticv4": {
961
				$('none','staticv6','dhcp','dhcpv6','pppoe','pptp', 'ppp').invoke('hide');
962
				break;
963
			}
964
			case "staticv6": {
965
				$('none','staticv4','dhcp','dhcpv6','pppoe','pptp', 'ppp').invoke('hide');
966
				break;
967
			}
968
			case "staticv4v6": {
969
				$('none','dhcp','dhcpv6','pppoe','pptp', 'ppp').invoke('hide');
970
				$('staticv4').show();
971
				$('staticv6').show();
972
				break;
973
			}
974
			case "dhcp": {
975
				$('none','staticv4','staticv6','dhcpv6','pppoe','pptp', 'ppp').invoke('hide');
976
				break;
977
			}
978
			case "dhcpv6": {
979
				$('none','staticv4','staticv6','dhcp','pppoe','pptp', 'ppp').invoke('hide');
980
				break;
981
			}
982
			case "ppp": {
983
				$('none','staticv4','staticv6','dhcp','dhcpv6','pptp', 'pppoe').invoke('hide');
984
				country_list();
985
				break;
986
			}
987
			case "pppoe": {
988
				$('none','staticv4','staticv6','dhcp','dhcpv6','pptp', 'ppp').invoke('hide');
989
				break;
990
			}
991
			case "pptp": {
992
				$('none','staticv4','staticv6','dhcp','dhcpv6','pppoe', 'ppp').invoke('hide');
993
				break;
994
			}
995
		}
996
		$(t).show();
997
	}
998

    
999
	function show_allcfg(obj) {
1000
		if (obj.checked)
1001
			$('allcfg').show();
1002
		else
1003
			$('allcfg').hide();
1004
	}
1005

    
1006
	function show_reset_settings(reset_type) {
1007
		if (reset_type == 'preset') {
1008
			Effect.Appear('pppoepresetwrap', { duration: 0.0 });
1009
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
1010
		}
1011
		else if (reset_type == 'custom') {
1012
			Effect.Appear('pppoecustomwrap', { duration: 0.0 });
1013
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
1014
		} else {
1015
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
1016
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
1017
		}
1018
	}
1019
	function show_mon_config() {
1020
		document.getElementById("showmonbox").innerHTML='';
1021
		aodiv = document.getElementById('showmon');
1022
		aodiv.style.display = "block";
1023
	}
1024

    
1025
	function openwindow(url) {
1026
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1027
		if (oWin==null || typeof(oWin)=="undefined")
1028
			return false;
1029
		else
1030
			return true;
1031
	}
1032
	function country_list() {
1033
		$('country').childElements().each(function(node) { node.remove(); });
1034
		$('provider').childElements().each(function(node) { node.remove(); });
1035
		$('providerplan').childElements().each(function(node) { node.remove(); });
1036
		new Ajax.Request("getserviceproviders.php",{
1037
			onSuccess: function(response) {
1038
				var responseTextArr = response.responseText.split("\n");
1039
				responseTextArr.sort();
1040
				responseTextArr.each( function(value) {
1041
					var option = new Element('option');
1042
					country = value.split(":");
1043
					option.text = country[0];
1044
					option.value = country[1];
1045
					$('country').insert({ bottom : option });
1046
				});
1047
			}
1048
		});
1049
		$('trcountry').setStyle({display : "table-row"});
1050
	}
1051

    
1052
	function providers_list() {
1053
		$('provider').childElements().each(function(node) { node.remove(); });
1054
		$('providerplan').childElements().each(function(node) { node.remove(); });
1055
		new Ajax.Request("getserviceproviders.php",{
1056
			parameters: {country : $F('country')},
1057
			onSuccess: function(response) {
1058
				var responseTextArr = response.responseText.split("\n");
1059
				responseTextArr.sort();
1060
				responseTextArr.each( function(value) {
1061
					var option = new Element('option');
1062
					option.text = value;
1063
					option.value = value;
1064
					$('provider').insert({ bottom : option });
1065
				});
1066
			}
1067
		});
1068
		$('trprovider').setStyle({display : "table-row"});
1069
		$('trproviderplan').setStyle({display : "none"});
1070
	}
1071

    
1072
	function providerplan_list() {
1073
		$('providerplan').childElements().each(function(node) { node.remove(); });
1074
		$('providerplan').insert( new Element('option') );
1075
		new Ajax.Request("getserviceproviders.php",{
1076
			parameters: {country : $F('country'), provider : $F('provider')},
1077
			onSuccess: function(response) {
1078
				var responseTextArr = response.responseText.split("\n");
1079
				responseTextArr.sort();
1080
				responseTextArr.each( function(value) {
1081
					if(value != "") {
1082
						providerplan = value.split(":");
1083

    
1084
						var option = new Element('option');
1085
						option.text = providerplan[0] + " - " + providerplan[1];
1086
						option.value = providerplan[1];
1087
						$('providerplan').insert({ bottom : option });
1088
					}
1089
				});
1090
			}
1091
		});
1092
		$('trproviderplan').setStyle({display : "table-row"});
1093
	}
1094

    
1095
	function prefill_provider() {
1096
		new Ajax.Request("getserviceproviders.php",{
1097
			parameters: {country : $F('country'), provider : $F('provider'), plan : $F('providerplan')},
1098
			onSuccess: function(response) {
1099
				var xmldoc = response.responseXML;
1100
				var provider = xmldoc.getElementsByTagName('connection')[0];
1101
				$('username').setValue('');
1102
				$('password').setValue('');
1103
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1104
					$('phone').setValue('#777');
1105
					$('apn').setValue('');
1106
				} else {
1107
					$('phone').setValue('*99#');
1108
					$('apn').setValue(provider.getElementsByTagName('apn')[0].firstChild.data);
1109
				}
1110
				$('username').setValue(provider.getElementsByTagName('username')[0].firstChild.data);
1111
				$('password').setValue(provider.getElementsByTagName('password')[0].firstChild.data);
1112
			}
1113
		});
1114
	}
1115

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

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

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