Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
94

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

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

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

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

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

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

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

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

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

    
234
// print_r($pconfig);
235

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

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

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

    
330
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
331
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
332
			foreach ($toapplylist as $ifapply) {
333
				if (isset($config['interfaces'][$ifapply]['enable']))
334
					interface_configure($ifapply, true);
335
				else
336
					interface_bring_down($ifapply);
337
			}
338
		}
339
		/* restart snmp so that it binds to correct address */
340
		services_snmpd_configure();
341

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

    
345
		clear_subsystem_dirty('staticroutes');
346

    
347
		filter_configure();
348

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

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

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

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

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

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

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

    
602
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
603
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
604

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

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

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

    
716
				if (!empty($_POST['pppoe-reset-type']))
717
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
718
				else
719
					unset($a_ppps[$pppid]['pppoe-reset-type']);
720
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
721
				$wancfg['ipaddr'] = $_POST['type'];
722
				if($gateway_item) {
723
					$a_gateways[] = $gateway_item;
724
				}
725

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

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

    
781
		conf_mount_ro();
782
		write_config();
783

    
784
		if (file_exists("{$g['tmp_path']}/.interfaces.apply"))
785
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
786
		else
787
			$toapplylist = array();
788
		$toapplylist[$if] = $if; 
789
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
790

    
791
		mark_subsystem_dirty('interfaces');
792

    
793
		/* regenerate cron settings/crontab file */
794
		configure_cron();
795

    
796
		header("Location: interfaces.php?if={$if}");
797
		exit;
798
	}
799

    
800
} // end if($_POST)
801

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

    
935
function check_wireless_mode() {
936
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
937

    
938
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
939
		return;
940

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

    
963
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
964
$statusurl = "status_interfaces.php";
965

    
966
$closehead = false;
967
include("head.inc");
968
$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"*/);
969

    
970
?>
971

    
972
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
973
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
974
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
975
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
976

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

    
1023
	function show_allcfg(obj) {
1024
		if (obj.checked)
1025
			$('allcfg').show();
1026
		else
1027
			$('allcfg').hide();
1028
	}
1029

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

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

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

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

    
1108
						var option = new Element('option');
1109
						option.text = providerplan[0] + " - " + providerplan[1];
1110
						option.value = providerplan[1];
1111
						$('providerplan').insert({ bottom : option });
1112
					}
1113
				});
1114
			}
1115
		});
1116
		$('trproviderplan').setStyle({display : "table-row"});
1117
	}
1118

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

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

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

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