Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
95

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

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

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

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

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

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

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

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

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

    
237
// print_r($pconfig);
238

    
239
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
240
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
241
$pconfig['spoofmac'] = $wancfg['spoofmac'];
242
$pconfig['mtu'] = $wancfg['mtu'];
243
$pconfig['mss'] = $wancfg['mss'];
244

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

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

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

    
352
		/* sync filter configuration */
353
		setup_gateways_monitor();
354

    
355
		clear_subsystem_dirty('staticroutes');
356

    
357
		filter_configure();
358

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

    
385
	unset($input_errors);
386
	$pconfig = $_POST;
387
	conf_mount_rw();
388

    
389
	/* filter out spaces from descriptions  */
390
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
391

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

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

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

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

    
627
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
628
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
629

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

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

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

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

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

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

    
808
		conf_mount_ro();
809
		write_config();
810

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

    
824
		mark_subsystem_dirty('interfaces');
825

    
826
		/* regenerate cron settings/crontab file */
827
		configure_cron();
828

    
829
		header("Location: interfaces.php?if={$if}");
830
		exit;
831
	}
832

    
833
} // end if($_POST)
834

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

    
968
function check_wireless_mode() {
969
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
970

    
971
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
972
		return;
973

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

    
996
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
997
$statusurl = "status_interfaces.php";
998

    
999
$closehead = false;
1000
include("head.inc");
1001
$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"), "l2tp" => gettext("L2TP") /* , "carpdev-dhcp" => "CarpDev"*/);
1002

    
1003
?>
1004

    
1005
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1006
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1007
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1008
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1009

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

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

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

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

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

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

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

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

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

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

    
2300
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2301
						<tr>
2302
							<td width="22%" valign="top">
2303
								&nbsp;
2304
							</td>
2305
							<td width="78%">
2306
								<br/>
2307
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2308
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2309
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2310
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2311
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2312
								<?php endif; ?>
2313
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2314
							</td>
2315
						</tr>
2316
					</table>
2317
				</td>
2318
			</tr>
2319
		</table>
2320
		<!--
2321
		</div>
2322
		</td></tr>
2323
		</table>
2324
		-->
2325
	</form>
2326
	<script type="text/javascript">
2327
		var gatewayip;
2328
		var name;
2329
		function show_add_gateway() {
2330
			document.getElementById("addgateway").style.display = '';
2331
			document.getElementById("addgwbox").style.display = 'none';
2332
			document.getElementById("gateway").style.display = 'none';
2333
			document.getElementById("save").style.display = 'none';
2334
			document.getElementById("cancel").style.display = 'none';
2335
			document.getElementById("gwsave").style.display = '';
2336
			document.getElementById("gwcancel").style.display = '';
2337
			$('notebox').innerHTML="";
2338
		}
2339
		function hide_add_gateway() {
2340
			document.getElementById("addgateway").style.display = 'none';
2341
			document.getElementById("addgwbox").style.display = '';
2342
			document.getElementById("gateway").style.display = '';
2343
			document.getElementById("save").style.display = '';
2344
			document.getElementById("cancel").style.display = '';
2345
			document.getElementById("gwsave").style.display = '';
2346
			document.getElementById("gwcancel").style.display = '';
2347
		}
2348
		function hide_add_gatewaysave() {
2349
			document.getElementById("addgateway").style.display = 'none';
2350
			$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif"> One moment please...';
2351
			var iface = $F('if');
2352
			name = $('name').getValue();
2353
			var descr = $('gatewaydescr').getValue();
2354
			gatewayip = $('gatewayip').getValue();
2355
			addrtype = $('addrtype').getValue();
2356
			var defaultgw = $('defaultgw').getValue();
2357
			var url = "system_gateways_edit.php";
2358
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip) + '&type=' + escape(addrtype);
2359
			var myAjax = new Ajax.Request(
2360
				url,
2361
				{
2362
					method: 'post',
2363
					parameters: pars,
2364
					onFailure: report_failure,
2365
					onComplete: save_callback
2366
				});
2367
		}
2368
		function addOption(selectbox,text,value)
2369
		{
2370
			var optn = document.createElement("OPTION");
2371
			optn.text = text;
2372
			optn.value = value;
2373
			selectbox.options.add(optn);
2374
			selectbox.selectedIndex = (selectbox.options.length-1);
2375
			$('notebox').innerHTML="<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.";
2376
		}
2377
		function report_failure() {
2378
			alert("Sorry, we could not create your gateway at this time.");
2379
			hide_add_gateway();
2380
		}
2381
		function save_callback(transport) {
2382
			var response = transport.responseText;
2383
			if(response) {
2384
				document.getElementById("addgateway").style.display = 'none';
2385
				hide_add_gateway();
2386
				$('status').innerHTML = '';
2387
				addOption($('gateway'), name, name);
2388
				// Auto submit form?
2389
				//document.iform.submit();
2390
				//$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif">';
2391
			} else {
2392
				report_failure();
2393
			}
2394
		}
2395
		<?php
2396
		echo "show_allcfg(document.iform.enable);";
2397
		echo "updateType('{$pconfig['type']}');\n";
2398
		?>
2399
	</script>
2400
	<?php include("fend.inc"); ?>
2401
	</body>
2402
</html>
(87-87/231)