Project

General

Profile

Download (132 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
$old_wancfg['realif'] = get_real_interface($if);
90
$old_ppps = $a_ppps;
91
// Populate page descr if it does not exist.
92
if ($if == "wan" && !$wancfg['descr'])
93
	$wancfg['descr'] = "WAN";
94
else if ($if == "lan" && !$wancfg['descr'])
95
	$wancfg['descr'] = "LAN";
96

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

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

    
110
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
111
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
112
	}
113
	else 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
			if ($itemhash)
128
				$cronitem = $itemhash['ITEM'];
129
			if (isset($cronitem)) {
130
				$resetTime = "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
131
			} else {
132
				$resetTime = NULL;
133
			}
134
			//log_error("ResetTime:".$resetTime);
135
			if ($a_ppps[$pppid]['pppoe-reset-type'] == "custom") {
136
				if ($cronitem) {
137
					$pconfig['pppoe_pr_custom'] = true;
138
					$pconfig['pppoe_resetminute'] = $cronitem['minute'];
139
					$pconfig['pppoe_resethour'] = $cronitem['hour'];
140
					if ($cronitem['mday'] <> "*" && $cronitem['month'] <> "*")
141
						$pconfig['pppoe_resetdate'] = "{$cronitem['month']}/{$cronitem['mday']}/" . date("Y");
142
				}
143
			} else if ($a_ppps[$pppid]['pppoe-reset-type'] == "preset") {
144
				$pconfig['pppoe_pr_preset'] = true;
145
				switch ($resetTime) {
146
					case CRON_MONTHLY_PATTERN:
147
						$pconfig['pppoe_monthly'] = true;
148
						break;
149
					case CRON_WEEKLY_PATTERN:
150
						$pconfig['pppoe_weekly'] = true;
151
						break;
152
					case CRON_DAILY_PATTERN:
153
						$pconfig['pppoe_daily'] = true;
154
						break;
155
					case CRON_HOURLY_PATTERN:
156
						$pconfig['pppoe_hourly'] = true;
157
						break;
158
				}
159
			}
160
		}// End force pppoe reset at specific time
161
	}// End if type == pppoe
162
	else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp"){
163
		$pconfig['pptp_username'] = $a_ppps[$pppid]['username'];
164
		$pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']);
165
		$pconfig['pptp_local'] = explode(",",$a_ppps[$pppid]['localip']);
166
		$pconfig['pptp_subnet'] = explode(",",$a_ppps[$pppid]['subnet']);
167
		$pconfig['pptp_remote'] = explode(",",$a_ppps[$pppid]['gateway']);
168
		$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
169
		$pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout'];
170
	}
171
} else {
172
	$pconfig['ptpid'] = interfaces_ptpid_next();
173
	$pppid = count($a_ppps);
174
}
175
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
176
$pconfig['alias-address'] = $wancfg['alias-address'];
177
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
178
$pconfig['dhcprejectfrom'] = $wancfg['dhcprejectfrom'];
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 "pppoe":
196
	case "pptp":
197
	case "l2tp":
198
	case "ppp":
199
		$pconfig['type'] = $wancfg['ipaddr'];
200
		break;
201
	default:
202
		if(is_ipaddrv4($wancfg['ipaddr'])) {
203
			$pconfig['type'] = "staticv4";
204
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
205
			$pconfig['subnet'] = $wancfg['subnet'];
206
			$pconfig['gateway'] = $wancfg['gateway'];
207
		} else
208
			$pconfig['type'] = "none";
209
		break;
210
}
211

    
212
switch($wancfg['ipaddrv6']) {
213
	case "slaac":
214
		$pconfig['type6'] = "slaac";
215
		break;
216
	case "dhcp6":
217
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
218
		if(!isset($wancfg['dhcp6-ia-pd-len']))
219
			$wancfg['dhcp6-ia-pd-len'] = "none";
220
		$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
221
		$pconfig['dhcp6-ia-pd-send-hint'] = isset($wancfg['dhcp6-ia-pd-send-hint']);
222
		$pconfig['type6'] = "dhcp6";
223
		$pconfig['dhcp6prefixonly'] = isset($wancfg['dhcp6prefixonly']);
224
		$pconfig['dhcp6usev4iface'] = isset($wancfg['dhcp6usev4iface']);
225
		break;
226
	case "6to4":
227
		$pconfig['type6'] = "6to4";
228
		break;
229
	case "track6":
230
		$pconfig['type6'] = "track6";
231
		$pconfig['track6-interface'] = $wancfg['track6-interface'];
232
		if ($wancfg['track6-prefix-id'] == "")
233
			$pconfig['track6-prefix-id'] = 0;
234
		else
235
			$pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
236
		$pconfig['track6-prefix-id--hex'] = sprintf("%x", $pconfig['track6-prefix-id']);
237
		break;
238
	case "6rd":
239
		$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
240
		if($wancfg['prefix-6rd-v4plen'] == "")
241
			$wancfg['prefix-6rd-v4plen'] = "0";
242
		$pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen'];
243
		$pconfig['type6'] = "6rd";
244
		$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
245
		break;
246
	default:
247
		if(is_ipaddrv6($wancfg['ipaddrv6'])) {
248
			$pconfig['type6'] = "staticv6";
249
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
250
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
251
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
252
		} else
253
			$pconfig['type6'] = "none";
254
		break;
255
}
256

    
257
// print_r($pconfig);
258

    
259
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
260
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
261
$pconfig['spoofmac'] = $wancfg['spoofmac'];
262
$pconfig['mtu'] = $wancfg['mtu'];
263
$pconfig['mss'] = $wancfg['mss'];
264

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

    
348
$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']);
349
$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
350

    
351
if ($_POST['apply']) {
352
	unset($input_errors);
353
	if (!is_subsystem_dirty('interfaces'))
354
		$intput_errors[] = gettext("You have already applied your settings!");
355
	else {
356
		unlink_if_exists("{$g['tmp_path']}/config.cache");
357
		clear_subsystem_dirty('interfaces');
358

    
359
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
360
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
361
			foreach ($toapplylist as $ifapply => $ifcfgo) {
362
				if (isset($config['interfaces'][$ifapply]['enable'])) {
363
					interface_bring_down($ifapply, false, $ifcfgo);
364
					interface_configure($ifapply, true);
365
				} else
366
					interface_bring_down($ifapply, true, $ifcfgo);
367
			}
368
		}
369
		/* restart snmp so that it binds to correct address */
370
		services_snmpd_configure();
371

    
372
		/* sync filter configuration */
373
		setup_gateways_monitor();
374

    
375
		clear_subsystem_dirty('interfaces');
376

    
377
		filter_configure();
378

    
379
		enable_rrd_graphing();
380

    
381
		if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0))
382
			clear_subsystem_dirty('staticroutes');
383
	}
384
	@unlink("{$g['tmp_path']}/.interfaces.apply");
385
	header("Location: interfaces.php?if={$if}");
386
	exit;
387
} else if ($_POST && $_POST['enable'] != "yes") {
388
	unset($wancfg['enable']);
389
	if (isset($wancfg['wireless']))
390
		interface_sync_wireless_clones($wancfg, false);
391
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
392
	mark_subsystem_dirty('interfaces');
393
	if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
394
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
395
	} else {
396
		$toapplylist = array();
397
	}
398
	$toapplylist[$if]['ifcfg'] = $wancfg;
399
	$toapplylist[$if]['ppps'] = $a_ppps;
400
	/* we need to be able remove IP aliases for IPv6 */
401
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
402
	header("Location: interfaces.php?if={$if}");
403
	exit;
404
} else if ($_POST) {
405

    
406
	unset($input_errors);
407
	$pconfig = $_POST;
408
	if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
409
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
410
	else
411
		$pconfig['track6-prefix-id'] = 0;
412
	conf_mount_rw();
413

    
414
	/* filter out spaces from descriptions  */
415
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
416

    
417
	/* okay first of all, cause we are just hiding the PPPoE HTML
418
	 * fields releated to PPPoE resets, we are going to unset $_POST
419
	 * vars, if the reset feature should not be used. Otherwise the
420
	 * data validation procedure below, may trigger a false error
421
	 * message.
422
	 */
423
	if (empty($_POST['pppoe-reset-type'])) {
424
		unset($_POST['pppoe_pr_type']);
425
		unset($_POST['pppoe_resethour']);
426
		unset($_POST['pppoe_resetminute']);
427
		unset($_POST['pppoe_resetdate']);
428
		unset($_POST['pppoe_pr_preset_val']);
429
	}
430
	/* description unique? */
431
	foreach ($ifdescrs as $ifent => $ifdescr) {
432
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
433
			$input_errors[] = gettext("An interface with the specified description already exists.");
434
			break;
435
		}
436
	}
437
	/* input validation */
438
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^staticv4/", $_POST['type'])))
439
		$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.");
440
	if (isset($config['dhcpdv6']) && isset($config['dhcpdv6'][$if]['enable']) && (! preg_match("/^staticv6/", $_POST['type6'])))
441
		$input_errors[] = gettext("The DHCP6 Server is active on this interface and it can be used only with a static IPv6 configuration. Please disable the DHCPv6 Server service on this interface first, then change the interface configuration.");
442

    
443
	switch(strtolower($_POST['type'])) {
444
		case "staticv4":
445
			$reqdfields = explode(" ", "ipaddr subnet gateway");
446
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
447
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
448
			break;
449
		case "none":
450
			if(is_array($config['virtualip']['vip'])) {
451
				foreach ($config['virtualip']['vip'] as $vip) {
452
					if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if)
453
						$input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration.");
454
				}
455
			}
456
		case "dhcp":
457
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp")))
458
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
459
			break;
460
		case "ppp":
461
			$reqdfields = explode(" ", "port phone");
462
			$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
463
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
464
			break;
465
		case "pppoe":
466
			if ($_POST['pppoe_dialondemand']) {
467
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
468
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
469
			} else {
470
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
471
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
472
			}
473
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
474
			break;
475
		case "pptp":
476
			if ($_POST['pptp_dialondemand']) {
477
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
478
				$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"));
479
			} else {
480
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
481
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
482
			}
483
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
484
			break;
485
		case "l2tp":
486
			if ($_POST['pptp_dialondemand']) {
487
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
488
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
489
			} else {
490
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
491
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"));
492
			}
493
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
494
			break;
495
	}
496
	switch(strtolower($_POST['type6'])) {
497
		case "staticv6":
498
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
499
			$reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
500
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
501
			break;
502
		case "none":
503
			if(is_array($config['virtualip']['vip'])) {
504
				foreach ($config['virtualip']['vip'] as $vip) {
505
					if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if)
506
						$input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration.");
507
				}
508
			}
509
		case "dhcp6":
510
			if (in_array($wancfg['ipaddrv6'], array()))
511
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
512
			break;
513
		case "6rd":
514
			foreach ($ifdescrs as $ifent => $ifdescr) {
515
				if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
516
					if ($config[interfaces][$ifent]['prefix-6rd'] == $_POST['prefix-6rd']) {
517
						$input_errors[] = gettext("You can only have one interface configured in 6rd with same prefix.");
518
						break;
519
					}
520
				}
521
			}
522
			if (in_array($wancfg['ipaddrv6'], array()))
523
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
524
			break;
525
		case "6to4":
526
			foreach ($ifdescrs as $ifent => $ifdescr) {
527
				if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
528
					$input_errors[] = sprintf(gettext("You can only have one interface configured as 6to4."),$_POST['type6']);
529
					break;
530
				}
531
			}
532
			if (in_array($wancfg['ipaddrv6'], array()))
533
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
534
			break;
535
		case "track6":
536
			/* needs to check if $track6-prefix-id is used on another interface */
537
			if (in_array($wancfg['ipaddrv6'], array()))
538
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
539

    
540
			if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
541
				$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
542
			} else {
543
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
544
				if ($track6_prefix_id < 0 || $track6_prefix_id >= $ipv6_num_prefix_ids) {
545
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.");
546
				}
547
			}
548
			break;
549
	}
550

    
551

    
552
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
553
	$staticroutes = get_staticroutes(true);
554
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
555
	if ($_POST['ipaddr']) {
556
		if (!is_ipaddrv4($_POST['ipaddr']))
557
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
558
		else {
559
			if (is_ipaddr_configured($_POST['ipaddr'], $if, true))
560
				$input_errors[] = gettext("This IPv4 address is being used by another interface or VIP.");
561

    
562
			/* Do not accept network or broadcast address, except if subnet is 31 or 32 */
563
			if ($_POST['subnet'] < 31) {
564
				if ($_POST['ipaddr'] == gen_subnet($_POST['ipaddr'], $_POST['subnet']))
565
					$input_errors[] = gettext("This IPv4 address is the network address and cannot be used");
566
				else if ($_POST['ipaddr'] == gen_subnet_max($_POST['ipaddr'], $_POST['subnet']))
567
					$input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used");
568
			}
569

    
570
			foreach ($staticroutes as $route_subnet) {
571
				list($network, $subnet) = explode("/", $route_subnet);
572
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
573
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
574
					break;
575
				}
576
				unset($network, $subnet);
577
			}
578
		}
579
	}
580
	if ($_POST['ipaddrv6']) {
581
		if (!is_ipaddrv6($_POST['ipaddrv6']))
582
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
583
		else {
584
			if (is_ipaddr_configured($_POST['ipaddrv6'], $if, true))
585
				$input_errors[] = gettext("This IPv6 address is being used by another interface or VIP.");
586

    
587
			foreach ($staticroutes as $route_subnet) {
588
				list($network, $subnet) = explode("/", $route_subnet);
589
				if ($_POST['subnetv6'] == $subnet && $network == gen_subnetv6($_POST['ipaddrv6'], $_POST['subnetv6'])) {
590
					$input_errors[] = gettext("This IPv6 address conflicts with a Static Route.");
591
					break;
592
				}
593
				unset($network, $subnet);
594
			}
595
		}
596
	}
597
	if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
598
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
599
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6'])))
600
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
601
	if (($_POST['alias-address'] && !is_ipaddrv4($_POST['alias-address'])))
602
		$input_errors[] = gettext("A valid alias IP address must be specified.");
603
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
604
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
605
	if ($_POST['dhcprejectfrom'] && !is_ipaddrv4($_POST['dhcprejectfrom']))
606
		$input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from.");
607
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
608
		$match = false;
609
		foreach($a_gateways as $gateway) {
610
			if(in_array($_POST['gateway'], $gateway)) {
611
				$match = true;
612
			}
613
		}
614
		foreach($a_gateways as $gateway) {
615
			if(in_array($_POST['gatewayv6'], $gateway)) {
616
				$match = true;
617
			}
618
		}
619
		if(!$match) {
620
			$input_errors[] = gettext("A valid gateway must be specified.");
621
		}
622
	}
623
	if (($_POST['provider'] && !is_domain($_POST['provider'])))
624
		$input_errors[] = gettext("The service name contains invalid characters.");
625
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
626
		$input_errors[] = gettext("The idle timeout value must be an integer.");
627
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
628
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23)
629
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
630
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
631
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59)
632
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
633
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate'])))
634
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
635
	if (($_POST['pptp_local'] && !is_ipaddrv4($_POST['pptp_local'])))
636
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
637
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet'])))
638
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
639
	if (($_POST['pptp_remote'] && !is_ipaddrv4($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface])))
640
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
641
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout']))
642
		$input_errors[] = gettext("The idle timeout value must be an integer.");
643
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])))
644
		$input_errors[] = gettext("A valid MAC address must be specified.");
645
	if ($_POST['mtu']) {
646
		if ($_POST['mtu'] < 576 || $_POST['mtu'] > 9000)
647
			$input_errors[] = gettext("The MTU must be greater than 576 bytes and less than 9000.");
648

    
649
		if (stristr($wancfg['if'], "_vlan")) {
650
			$realhwif_array = get_parent_interface($wancfg['if']);
651
			// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
652
			$parent_realhwif = $realhwif_array[0];
653
			$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
654
			if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) {
655
				if ($_POST['mtu'] > intval($config['interfaces'][$parent_if]['mtu']))
656
					$input_errors[] = gettext("MTU of a vlan should not be bigger than parent interface.");
657
			}
658
		} else {
659
			foreach ($config['interfaces'] as $idx => $ifdata) {
660
				if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if']))
661
					continue;
662

    
663
				$realhwif_array = get_parent_interface($ifdata['if']);
664
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
665
				$parent_realhwif = $realhwif_array[0];
666

    
667
				if ($parent_realhwif != $wancfg['if'])
668
					continue;
669

    
670
				if (isset($ifdata['mtu']) && $ifdata['mtu'] > $_POST['mtu'])
671
					$input_errors[] = sprintf(gettext("Interface %s (VLAN) has MTU set to a bigger value"), $ifdata['descr']);
672
			}
673
		}
674
	}
675
	if ($_POST['mss'] && ($_POST['mss'] < 576))
676
		$input_errors[] = gettext("The MSS must be greater than 576 bytes.");
677
	/* Wireless interface? */
678
	if (isset($wancfg['wireless'])) {
679
		$reqdfields = array("mode");
680
		$reqdfieldsn = array(gettext("Mode"));
681
		if ($_POST['mode'] == 'hostap') {
682
			$reqdfields[] = "ssid";
683
			$reqdfieldsn[] = gettext("SSID");
684
		}
685
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
686
		check_wireless_mode();
687
		/* loop through keys and enforce size */
688
		for ($i = 1; $i <= 4; $i++) {
689
			if ($_POST['key' . $i]) {
690
				/* 64 bit */
691
				if (strlen($_POST['key' . $i]) == 5)
692
					continue;
693
				if (strlen($_POST['key' . $i]) == 10) {
694
					/* hex key */
695
					if (stristr($_POST['key' . $i], "0x") == false) {
696
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
697
					}
698
					continue;
699
				}
700
				if (strlen($_POST['key' . $i]) == 12) {
701
					/* hex key */
702
					if(stristr($_POST['key' . $i], "0x") == false) {
703
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
704
					}
705
					continue;
706
				}
707
				/* 128 bit */
708
				if (strlen($_POST['key' . $i]) == 13)
709
					continue;
710
				if (strlen($_POST['key' . $i]) == 26) {
711
					/* hex key */
712
					if (stristr($_POST['key' . $i], "0x") == false)
713
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
714
					continue;
715
				}
716
				if(strlen($_POST['key' . $i]) == 28)
717
					continue;
718
				$input_errors[] =  gettext("Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.");
719
				break;
720
			}
721
		}
722

    
723
		if ($_POST['passphrase']) {
724
			$passlen = strlen($_POST['passphrase']);
725
			if ($passlen < 8 || $passlen > 63)
726
				$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
727
		}
728
	}
729
	if (!$input_errors) {
730
		if ($wancfg['ipaddr'] != $_POST['type']) {
731
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
732
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
733
				unset($a_ppps[$pppid]);
734
			} else if ($wancfg['ipaddrv6'] == "dhcp6") {
735
				$pid = find_dhcp6c_process($wancfg['if']);
736
				if($pid)
737
					posix_kill($pid, SIGTERM);
738
			} else if ($wancfg['ipaddr'] == "dhcp") {
739
				$pid = find_dhclient_process($wancfg['if']);
740
				if($pid)
741
					posix_kill($pid, SIGTERM);
742
			}
743

    
744
		}
745
		$ppp = array();
746
		if ($wancfg['ipaddr'] != "ppp")
747
			unset($wancfg['ipaddr']);
748
		if ($wancfg['ipaddrv6'] != "ppp")
749
			unset($wancfg['ipaddrv6']);
750
		unset($wancfg['subnet']);
751
		unset($wancfg['gateway']);
752
		unset($wancfg['subnetv6']);
753
		unset($wancfg['gatewayv6']);
754
		unset($wancfg['dhcphostname']);
755
		unset($wancfg['dhcprejectfrom']);
756
		unset($wancfg['dhcp6-duid']);
757
		unset($wancfg['dhcp6-ia-pd-len']);
758
		unset($wancfg['dhcp6-ia-pd-send-hint']);
759
		unset($wancfg['dhcp6prefixonly']);
760
		unset($wancfg['dhcp6usev4iface']);
761
		unset($wancfg['track6-interface']);
762
		unset($wancfg['track6-prefix-id']);
763
		unset($wancfg['prefix-6rd']);
764
		unset($wancfg['prefix-6rd-v4plen']);
765
		unset($wancfg['gateway-6rd']);
766
		unset($wancfg['pppoe_password']);
767
		unset($wancfg['pptp_username']);
768
		unset($wancfg['pptp_password']);
769
		unset($wancfg['provider']);
770
		unset($wancfg['ondemand']);
771
		unset($wancfg['timeout']);
772
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
773
			unset($wancfg['pppoe']['pppoe-reset-type']);
774
		unset($wancfg['local']);
775

    
776
		unset($wancfg['remote']);
777
		unset($a_ppps[$pppid]['apn']);
778
		unset($a_ppps[$pppid]['phone']);
779
		unset($a_ppps[$pppid]['localip']);
780
		unset($a_ppps[$pppid]['subnet']);
781
		unset($a_ppps[$pppid]['gateway']);
782
		unset($a_ppps[$pppid]['pppoe-reset-type']);
783
		unset($a_ppps[$pppid]['provider']);
784

    
785
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
786
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
787

    
788
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
789
		switch($_POST['type']) {
790
			case "staticv4":
791
				$wancfg['ipaddr'] = $_POST['ipaddr'];
792
				$wancfg['subnet'] = $_POST['subnet'];
793
				if ($_POST['gateway'] != "none") {
794
					$wancfg['gateway'] = $_POST['gateway'];
795
				}
796
				break;
797
			case "dhcp":
798
				$wancfg['ipaddr'] = "dhcp";
799
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
800
				$wancfg['alias-address'] = $_POST['alias-address'];
801
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
802
				$wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom'];
803
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
804
				if($gateway_item) {
805
					$a_gateways[] = $gateway_item;
806
				}
807
				break;
808
			case "ppp":
809
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
810
				$a_ppps[$pppid]['type'] = $_POST['type'];
811
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
812
				$a_ppps[$pppid]['ports'] = $_POST['port'];
813
				$a_ppps[$pppid]['username'] = $_POST['username'];
814
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
815
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
816
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
817
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
818
				$wancfg['ipaddr'] = $_POST['type'];
819
				unset($a_ppps[$pppid]['ondemand']);
820
				unset($a_ppps[$pppid]['idletimeout']);
821
				break;
822

    
823
			case "pppoe":
824
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
825
				$a_ppps[$pppid]['type'] = $_POST['type'];
826
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
827
				if (isset($_POST['ppp_port']))
828
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
829
				else
830
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
831
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
832
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
833
				if (!empty($_POST['provider']))
834
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
835
				else
836
					$a_ppps[$pppid]['provider'] = true;
837
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
838
				if (!empty($_POST['pppoe_idletimeout']))
839
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
840
				else
841
					unset($a_ppps[$pppid]['idletimeout']);
842

    
843
				if (!empty($_POST['pppoe-reset-type']))
844
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
845
				else
846
					unset($a_ppps[$pppid]['pppoe-reset-type']);
847
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
848
				$wancfg['ipaddr'] = $_POST['type'];
849
				if($gateway_item) {
850
					$a_gateways[] = $gateway_item;
851
				}
852

    
853
				break;
854
			case "pptp":
855
			case "l2tp":
856
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
857
				$a_ppps[$pppid]['type'] = $_POST['type'];
858
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
859
				if (isset($_POST['ppp_port']))
860
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
861
				else
862
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
863
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
864
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
865
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
866
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
867
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
868
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
869
				if (!empty($_POST['pptp_idletimeout']))
870
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
871
				else
872
					unset($a_ppps[$pppid]['idletimeout']);
873
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
874
				$wancfg['ipaddr'] = $_POST['type'];
875
				if($gateway_item) {
876
					$a_gateways[] = $gateway_item;
877
				}
878
				break;
879
			case "none":
880
				break;
881
		}
882
		switch($_POST['type6']) {
883
			case "staticv6":
884
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
885
				$wancfg['subnetv6'] = $_POST['subnetv6'];
886
				if ($_POST['gatewayv6'] != "none") {
887
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
888
				}
889
				break;
890
			case "slaac":
891
				$wancfg['ipaddrv6'] = "slaac";
892
				break;
893
			case "dhcp6":
894
				$wancfg['ipaddrv6'] = "dhcp6";
895
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
896
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
897
				if($_POST['dhcp6-ia-pd-send-hint'] == "yes")
898
					$wancfg['dhcp6-ia-pd-send-hint'] = true;
899
				if($_POST['dhcp6prefixonly'] == "yes")
900
					$wancfg['dhcp6prefixonly'] = true;
901
				if($_POST['dhcp6usev4iface'] == "yes")
902
					$wancfg['dhcp6usev4iface'] = true;
903
				if($gateway_item) {
904
					$a_gateways[] = $gateway_item;
905
				}
906
				break;
907
			case "6rd":
908
				$wancfg['ipaddrv6'] = "6rd";
909
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
910
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
911
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
912
				if($gateway_item) {
913
					$a_gateways[] = $gateway_item;
914
				}
915
				break;
916
			case "6to4":
917
				$wancfg['ipaddrv6'] = "6to4";
918
				break;
919
			case "track6":
920
				$wancfg['ipaddrv6'] = "track6";
921
				$wancfg['track6-interface'] = $_POST['track6-interface'];
922
				if ($_POST['track6-prefix-id--hex'] === "")
923
					$wancfg['track6-prefix-id'] = 0;
924
				else if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
925
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
926
				else
927
					$wancfg['track6-prefix-id'] = 0;
928
				break;
929
			case "none":
930
				break;
931
		}
932
		handle_pppoe_reset($_POST);
933

    
934
		if($_POST['blockpriv'] == "yes") {
935
			$wancfg['blockpriv'] = true;
936
		} else {
937
			unset($wancfg['blockpriv']);
938
		}
939
		if($_POST['blockbogons'] == "yes") {
940
			$wancfg['blockbogons'] = true;
941
		} else {
942
			unset($wancfg['blockbogons']);
943
		}
944
		$wancfg['spoofmac'] = $_POST['spoofmac'];
945
		if (empty($_POST['mtu'])) {
946
			unset($wancfg['mtu']);
947
		} else {
948
			$wancfg['mtu'] = $_POST['mtu'];
949
		}
950
		if (empty($_POST['mss'])) {
951
			unset($wancfg['mss']);
952
		} else {
953
			$wancfg['mss'] = $_POST['mss'];
954
		}
955
		if (empty($_POST['mediaopt'])) {
956
			unset($wancfg['media']);
957
			unset($wancfg['mediaopt']);
958
		} else {
959
			$mediaopts = explode(' ', $_POST['mediaopt']);
960
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
961
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
962
			else { unset($wancfg['mediaopt']); }
963
		}
964
		if (isset($wancfg['wireless'])) {
965
			handle_wireless_post();
966
		}
967

    
968
		conf_mount_ro();
969
		write_config();
970

    
971
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
972
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
973
		} else {
974
			$toapplylist = array();
975
		}
976
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
977
		$toapplylist[$if]['ppps'] = $old_ppps;
978
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
979

    
980
		mark_subsystem_dirty('interfaces');
981

    
982
		/* regenerate cron settings/crontab file */
983
		configure_cron();
984

    
985
		header("Location: interfaces.php?if={$if}");
986
		exit;
987
	}
988

    
989
} // end if($_POST)
990

    
991
function handle_wireless_post() {
992
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
993
	if (!is_array($wancfg['wireless']))
994
		$wancfg['wireless'] = array();
995
	$wancfg['wireless']['standard'] = $_POST['standard'];
996
	$wancfg['wireless']['mode'] = $_POST['mode'];
997
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
998
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
999
	$wancfg['wireless']['channel'] = $_POST['channel'];
1000
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
1001
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
1002
	$wancfg['wireless']['distance'] = $_POST['distance'];
1003
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
1004
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
1005
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
1006
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
1007
		foreach($wl_countries_attr as $wl_country) {
1008
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
1009
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
1010
				break;
1011
			}
1012
		}
1013
	}
1014
	if (!is_array($wancfg['wireless']['wpa']))
1015
		$wancfg['wireless']['wpa'] = array();
1016
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
1017
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
1018
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
1019
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
1020
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
1021
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
1022
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
1023
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
1024
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
1025
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
1026
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
1027
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
1028
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
1029
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
1030
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
1031

    
1032
	if ($_POST['persistcommonwireless'] == "yes") {
1033
		if (!is_array($config['wireless']))
1034
			$config['wireless'] = array();
1035
		if (!is_array($config['wireless']['interfaces']))
1036
			$config['wireless']['interfaces'] = array();
1037
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
1038
			$config['wireless']['interfaces'][$wlanbaseif] = array();
1039
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
1040
		unset($config['wireless']['interfaces'][$wlanbaseif]);
1041
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
1042
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
1043
	else if (isset($wancfg['wireless']['diversity']))
1044
		unset($wancfg['wireless']['diversity']);
1045
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
1046
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
1047
	else if (isset($wancfg['wireless']['txantenna']))
1048
		unset($wancfg['wireless']['txantenna']);
1049
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
1050
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
1051
	else if (isset($wancfg['wireless']['rxantenna']))
1052
		unset($wancfg['wireless']['rxantenna']);
1053
	if ($_POST['hidessid_enable'] == "yes")
1054
		$wancfg['wireless']['hidessid']['enable'] = true;
1055
	else if (isset($wancfg['wireless']['hidessid']['enable']))
1056
		unset($wancfg['wireless']['hidessid']['enable']);
1057
	if ($_POST['mac_acl_enable'] == "yes")
1058
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
1059
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
1060
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
1061
	if ($_POST['rsn_preauth'] == "yes")
1062
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
1063
	else
1064
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
1065
	if ($_POST['ieee8021x'] == "yes")
1066
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
1067
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
1068
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
1069
	if ($_POST['wpa_strict_rekey'] == "yes")
1070
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
1071
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
1072
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
1073
	if ($_POST['debug_mode'] == "yes")
1074
		$wancfg['wireless']['wpa']['debug_mode'] = true;
1075
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
1076
		sunset($wancfg['wireless']['wpa']['debug_mode']);
1077
	if ($_POST['wpa_enable'] == "yes")
1078
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
1079
	else if (isset($wancfg['wireless']['wpa']['enable']))
1080
		unset($wancfg['wireless']['wpa']['enable']);
1081
	if ($_POST['wep_enable'] == "yes") {
1082
		if (!is_array($wancfg['wireless']['wep']))
1083
			$wancfg['wireless']['wep'] = array();
1084
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
1085
	} else if (isset($wancfg['wireless']['wep']))
1086
		unset($wancfg['wireless']['wep']);
1087
	if ($_POST['wme_enable'] == "yes") {
1088
		if (!is_array($wancfg['wireless']['wme']))
1089
			$wancfg['wireless']['wme'] = array();
1090
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1091
	} else if (isset($wancfg['wireless']['wme']['enable']))
1092
		unset($wancfg['wireless']['wme']['enable']);
1093
	if ($_POST['puremode'] == "11g") {
1094
		if (!is_array($wancfg['wireless']['pureg']))
1095
			$wancfg['wireless']['pureg'] = array();
1096
		$wancfg['wireless']['pureg']['enable'] = true;
1097
	} else if ($_POST['puremode'] == "11n") {
1098
		if (!is_array($wancfg['wireless']['puren']))
1099
			$wancfg['wireless']['puren'] = array();
1100
		$wancfg['wireless']['puren']['enable'] = true;
1101
	} else {
1102
		if (isset($wancfg['wireless']['pureg']))
1103
			unset($wancfg['wireless']['pureg']);
1104
		if (isset($wancfg['wireless']['puren']))
1105
			unset($wancfg['wireless']['puren']);
1106
	}
1107
	if ($_POST['apbridge_enable'] == "yes") {
1108
		if (!is_array($wancfg['wireless']['apbridge']))
1109
			$wancfg['wireless']['apbridge'] = array();
1110
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1111
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
1112
		unset($wancfg['wireless']['apbridge']['enable']);
1113
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1114
		if (!is_array($wancfg['wireless']['turbo']))
1115
			$wancfg['wireless']['turbo'] = array();
1116
		$wancfg['wireless']['turbo']['enable'] = true;
1117
	} else if (isset($wancfg['wireless']['turbo']['enable']))
1118
		unset($wancfg['wireless']['turbo']['enable']);
1119
	$wancfg['wireless']['wep']['key'] = array();
1120
	for ($i = 1; $i <= 4; $i++) {
1121
		if ($_POST['key' . $i]) {
1122
			$newkey = array();
1123
			$newkey['value'] = $_POST['key' . $i];
1124
			if ($_POST['txkey'] == $i)
1125
				$newkey['txkey'] = true;
1126
			$wancfg['wireless']['wep']['key'][] = $newkey;
1127
		}
1128
	}
1129
	interface_sync_wireless_clones($wancfg, true);
1130
}
1131

    
1132
function check_wireless_mode() {
1133
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1134

    
1135
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1136
		return;
1137

    
1138
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1139
		$clone_count = 1;
1140
	else
1141
		$clone_count = 0;
1142
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1143
		foreach ($config['wireless']['clone'] as $clone) {
1144
			if ($clone['if'] == $wlanbaseif)
1145
				$clone_count++;
1146
		}
1147
	}
1148
	if ($clone_count > 1) {
1149
		$old_wireless_mode = $wancfg['wireless']['mode'];
1150
		$wancfg['wireless']['mode'] = $_POST['mode'];
1151
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1152
			$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']]);
1153
		} else {
1154
			mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy");
1155
		}
1156
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1157
	}
1158
}
1159

    
1160
// Find all possible media options for the interface
1161
$mediaopts_list = array();
1162
$intrealname = $config['interfaces'][$if]['if'];
1163
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1164
foreach ($mediaopts as $mediaopt){
1165
	preg_match("/media (.*)/", $mediaopt, $matches);
1166
	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1167
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1168
		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1169
	}else{
1170
		// there is only media like "media 1000baseT"
1171
		array_push($mediaopts_list, $matches[1]);
1172
	}
1173
}
1174

    
1175
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1176
$shortcut_section = "interfaces";
1177

    
1178
$closehead = false;
1179
include("head.inc");
1180
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1181
$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCP6"), "slaac" => gettext("SLAAC"), "6rd" => gettext("6rd Tunnel"), "6to4" => gettext("6to4 Tunnel"), "track6" => gettext("Track Interface"));
1182

    
1183
?>
1184

    
1185
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1186
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1187
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1188
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1189

    
1190
<script type="text/javascript">
1191
	function updateType(t) {
1192
		switch(t) {
1193
			case "none": {
1194
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1195
				break;
1196
			}
1197
			case "staticv4": {
1198
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1199
				break;
1200
			}
1201
			case "dhcp": {
1202
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1203
				break;
1204
			}
1205
			case "ppp": {
1206
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1207
				country_list();
1208
				break;
1209
			}
1210
			case "pppoe": {
1211
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1212
				break;
1213
			}
1214
			case "l2tp":
1215
			case "pptp": {
1216
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1217
				jQuery('#pptp').show();
1218
				break;
1219
			}
1220
		}
1221
		if (t != "l2tp" && t != "pptp")
1222
			jQuery('#'+t).show();
1223
	}
1224
	function updateTypeSix(t) {
1225
		switch(t) {
1226
			case "none": {
1227
				jQuery('#staticv6, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1228
				break;
1229
			}
1230
			case "staticv6": {
1231
				jQuery('#none, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1232
				break;
1233
			}
1234
			case "slaac": {
1235
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #dhcp6').hide();
1236
				break;
1237
			}
1238
			case "dhcp6": {
1239
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #slaac').hide();
1240
				break;
1241
			}
1242
			case "6rd": {
1243
				jQuery('#none, #dhcp6, #staticv6, #6to4, #track6, #slaac').hide();
1244
				break;
1245
			}
1246
			case "6to4": {
1247
				jQuery('#none, #dhcp6, #staticv6, #6rd, #track6, #slaac').hide();
1248
				break;
1249
			}
1250
			case "track6": {
1251
				jQuery('#none, #dhcp6, #staticv6, #6rd, #6to4, #slaac').hide();
1252
				break;
1253
			}
1254
		}
1255
		if (t != "l2tp" && t != "pptp")
1256
			jQuery('#'+t).show();
1257
	}
1258

    
1259
	function show_allcfg(obj) {
1260
		if (obj.checked)
1261
			jQuery('#allcfg').show();
1262
		else
1263
			jQuery('#allcfg').hide();
1264
	}
1265

    
1266
	function show_reset_settings(reset_type) {
1267
		if (reset_type == 'preset') {
1268
			jQuery('#pppoepresetwrap').show();
1269
			jQuery('#pppoecustomwrap').hide();
1270
		}
1271
		else if (reset_type == 'custom') {
1272
			jQuery('#pppoecustomwrap').show();
1273
			jQuery('#pppoepresetwrap').hide();
1274
		} else {
1275
			jQuery('#pppoecustomwrap').hide();
1276
			jQuery('#pppoepresetwrap').hide();
1277
		}
1278
	}
1279
	function show_mon_config() {
1280
		jQuery("#showmonbox").html('');
1281
		jQuery('#showmon').css('display','block');
1282
	}
1283

    
1284
	function openwindow(url) {
1285
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1286
		if (oWin==null || typeof(oWin)=="undefined")
1287
			return false;
1288
		else
1289
			return true;
1290
	}
1291
	function country_list() {
1292
		jQuery('#country').children().remove();
1293
		jQuery('#provider').children().remove();
1294
		jQuery('#providerplan').children().remove();
1295
		jQuery.ajax("getserviceproviders.php",{
1296
			success: function(response) {
1297
				var responseTextArr = response.split("\n");
1298
				responseTextArr.sort();
1299
				responseTextArr.each( function(value) {
1300
					var option = new Element('option');
1301
					country = value.split(":");
1302
					option.text = country[0];
1303
					option.value = country[1];
1304
					jQuery('#country').append(option);
1305
				});
1306
			}
1307
		});
1308
		jQuery('#trcountry').css('display',"table-row");
1309
	}
1310

    
1311
	function providers_list() {
1312
		jQuery('#provider').children().remove();
1313
		jQuery('#providerplan').children().remove();
1314
		jQuery.ajax("getserviceproviders.php",{
1315
			type: 'post',
1316
			data: {country : jQuery('#country').val()},
1317
			success: function(response) {
1318
				var responseTextArr = response.split("\n");
1319
				responseTextArr.sort();
1320
				responseTextArr.each( function(value) {
1321
					var option = new Element('option');
1322
					option.text = value;
1323
					option.value = value;
1324
					jQuery('#provider').append(option);
1325
				});
1326
			}
1327
		});
1328
		jQuery('#trprovider').css("display","table-row");
1329
		jQuery('#trproviderplan').css("display","none");
1330
	}
1331

    
1332
	function providerplan_list() {
1333
		jQuery('#providerplan').children().remove();
1334
		jQuery('#providerplan').append( new Element('option') );
1335
		jQuery.ajax("getserviceproviders.php",{
1336
			type: 'post',
1337
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1338
			success: function(response) {
1339
				var responseTextArr = response.split("\n");
1340
				responseTextArr.sort();
1341
				responseTextArr.each( function(value) {
1342
					if(value != "") {
1343
						providerplan = value.split(":");
1344

    
1345
						var option = new Element('option');
1346
						option.text = providerplan[0] + " - " + providerplan[1];
1347
						option.value = providerplan[1];
1348
						jQuery('#providerplan').append(option);
1349
					}
1350
				});
1351
			}
1352
		});
1353
		jQuery('#trproviderplan').css("display","table-row");
1354
	}
1355

    
1356
	function prefill_provider() {
1357
		jQuery.ajax("getserviceproviders.php",{
1358
			type: 'post',
1359
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
1360
			success: function(data,textStatus,response) {
1361
				var xmldoc = response.responseXML;
1362
				var provider = xmldoc.getElementsByTagName('connection')[0];
1363
				jQuery('#username').val('');
1364
				jQuery('#password').val('');
1365
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1366
					jQuery('#phone').val('#777');
1367
					jQuery('#apn').val('');
1368
				} else {
1369
					jQuery('#phone').val('*99#');
1370
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1371
				}
1372
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1373
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1374
				jQuery('#username').val(username);
1375
				jQuery('#password').val(password);
1376
			}
1377
		});
1378
	}
1379

    
1380
</script>
1381
</head>
1382
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1383
	<?php include("fbegin.inc"); ?>
1384
	<form action="interfaces.php" method="post" name="iform" id="iform">
1385
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1386
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1387
		<?php print_info_box_np(sprintf(gettext("The %s configuration has been changed."),$wancfg['descr'])."</p><p>".gettext("You must apply the changes in order for them to take effect.")."</p><p>".gettext("Don't forget to adjust the DHCP Server range if needed after applying."));?></p><br />
1388
		<?php endif; ?>
1389
		<?php if ($savemsg) print_info_box($savemsg); ?>
1390
		<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces">
1391
			<tr>
1392
				<td id="mainarea">
1393
					<div class="tabcont">
1394
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="tabs">
1395
						<tr>
1396
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1397
						</tr>
1398
						<tr>
1399
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1400
							<td width="78%" class="vtable">
1401
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked=\"checked\""; ?> onclick="show_allcfg(this);" />
1402
							<strong><?=gettext("Enable Interface"); ?></strong>
1403
							</td>
1404
						</tr>
1405
					</table>
1406
					<div style="display:none;" name="allcfg" id="allcfg">
1407
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="allcfg">
1408
						<tr>
1409
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1410
							<td width="78%" class="vtable">
1411
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>" />
1412
								<br/><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1413
							</td>
1414
						</tr>
1415
						<tr>
1416
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1417
							<td class="vtable">
1418
								<select name="type" onchange="updateType(this.value);" class="formselect" id="type">
1419
								<?php
1420
									foreach ($types4 as $key => $opt) {
1421
										echo "<option onclick=\"updateType('{$key}');\"";
1422
										if ($key == $pconfig['type'])
1423
											echo " selected=\"selected\"";
1424
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1425
										echo "</option>";
1426
									}
1427
								?>
1428
								</select>
1429
							</td>
1430
						</tr>
1431
						<tr>
1432
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1433
							<td class="vtable">
1434
								<select name="type6" onchange="updateTypeSix(this.value);" class="formselect" id="type6">
1435
								<?php
1436
									foreach ($types6 as $key => $opt) {
1437
										echo "<option onclick=\"updateTypeSix('{$key}');\"";
1438
										if ($key == $pconfig['type6'])
1439
											echo " selected=\"selected\"";
1440
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1441
										echo "</option>";
1442
									}
1443
								?>
1444
								</select>
1445
							</td>
1446
						</tr>
1447
						<tr>
1448
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1449
							<td class="vtable">
1450
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>" />
1451
								<?php
1452
									$ip = getenv('REMOTE_ADDR');
1453
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1454
									$mac = str_replace("\n","",$mac);
1455
									if($mac):
1456
								?>
1457
									<a onclick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1458
								<?php endif; ?>
1459
								<br/>
1460
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1461
								"address of this interface"); ?><br/>
1462
								<?=gettext("(may be required with some cable connections)"); ?><br/>
1463
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1464
								"or leave blank"); ?>
1465
							</td>
1466
						</tr>
1467
						<tr>
1468
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1469
							<td class="vtable">
1470
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>" />
1471
								<br/>
1472
								<?php
1473
									print gettext("If you leave this field blank, the adapter's default MTU will " .
1474
									"be used. This is typically 1500 bytes but can vary in some circumstances.");
1475
								?>
1476
							</td>
1477
						</tr>
1478
						<tr>
1479
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1480
							<td class="vtable">
1481
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>" />
1482
								<br/>
1483
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1484
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1485
								"header size) will be in effect."); ?>
1486
							</td>
1487
						</tr>
1488
						<?php
1489
						if (count($mediaopts_list) > 0){
1490
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1491
						echo "<tr>";
1492
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1493
							echo '<td class="vtable">';
1494
							echo '<div id="showadvmediabox"';
1495
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1496
								else echo '>';
1497
								echo '<input type="button" onclick="show_advanced_media()" value="' . gettext("Advanced") . '" /> - ' . gettext("Show advanced option");
1498
							echo "</div>";
1499
							echo '<div id="showmediaadv" ';
1500
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1501
							else echo '>';
1502
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1503
								print "<option value=\"\">Default (no preference, typically autoselect)</option>";
1504
								print "<option value=\"\">------- Media Supported by this interface -------</option>";
1505
								foreach($mediaopts_list as $mediaopt){
1506
									if ($mediaopt != rtrim($mediaopt_from_config)){
1507
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1508
									} else {
1509
										print "<option value=\"$mediaopt\" selected=\"selected\">" . gettext("$mediaopt") . "</option>";
1510
									}
1511
								}
1512
								echo '</select><br/>';
1513
								echo gettext("Here you can explicitly set speed and duplex mode for this interface. WARNING: You MUST leave this set to autoselect (automatically negotiate speed) unless the port this interface connects to has its speed and duplex forced.");
1514
						echo '</div>';
1515
							echo '</td>';
1516
						echo '</tr>';
1517
						}
1518
						?>
1519
						<tr>
1520
							<td colspan="2" valign="top" height="16"></td>
1521
						</tr>
1522
						<tr style="display:none;" name="none" id="none"><td style="display:none;"></td></tr>
1523
						<tr style="display:none;" name="staticv4" id="staticv4">
1524
							<td colspan="2" style="padding:0px;">
1525
								<a name="gatewaysection"></a>
1526
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv4">
1527
									<tr>
1528
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1529
									</tr>
1530
									<tr>
1531
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1532
										<td width="78%" class="vtable">
1533
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" />
1534
											/
1535
											<select name="subnet" class="formselect" id="subnet">
1536
												<?php
1537
												for ($i = 32; $i > 0; $i--) {
1538
													if($i <> 31) {
1539
														echo "<option value=\"{$i}\" ";
1540
														if ($i == $pconfig['subnet']) echo "selected=\"selected\"";
1541
														echo ">" . $i . "</option>";
1542
													}
1543
												}
1544
												?>
1545
											</select>
1546
										</td>
1547
									</tr>
1548
									<tr>
1549
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway"); ?></td>
1550
										<td width="78%" class="vtable">
1551
											<select name="gateway" class="formselect" id="gateway">
1552
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1553
													<?php
1554
													if(count($a_gateways) > 0) {
1555
														foreach ($a_gateways as $gateway) {
1556
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1557
													?>
1558
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected=\"selected\""; ?>>
1559
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1560
															</option>
1561
													<?php
1562
															}
1563
														}
1564
													}
1565
													?>
1566
											</select>
1567
											- or  <strong><a onclick="show_add_gateway();" href="#gatewaysection"><?=gettext("add a new one."); ?></a></strong>
1568
											<br/>
1569
											<div id='addgwbox'>
1570
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add one using the link above"); ?>
1571
											</div>
1572
											<div id='notebox'>
1573
											</div>
1574
											<div id="status">
1575
											</div>
1576
											<div style="display:none" id="addgateway" name="addgateway">
1577
												<p>&nbsp;</p>
1578
												<table border="1" class="addgatewaybox" summary="addgateway">
1579
													<tr>
1580
														<td>
1581
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgateway">
1582
																<tr><td>&nbsp;</td></tr>
1583
																<tr>
1584
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1585
																</tr>
1586
																<tr><td>&nbsp;</td></tr>
1587
																<?php
1588
																if($if == "wan" || $if == "WAN")
1589
																	$checked = " checked=\"checked\"";
1590
																?>
1591
																<tr>
1592
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></font></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?> /></td>
1593
																</tr>
1594
																<tr>
1595
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></font></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>" /></td>
1596
																</tr>
1597
																<tr>
1598
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></font></td><td><input id="gatewayip" name="gatewayip" /></td>
1599
																</tr>
1600
																<tr>
1601
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescr" name="gatewaydescr" /></td>
1602
																</tr>
1603
																<tr><td>&nbsp;</td></tr>
1604
																<tr>
1605
																	<td colspan="2">
1606
																		<center>
1607
																			<div id='savebuttondiv'>
1608
																				<input id="gwsave" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave();' />
1609
																				<input id="gwcancel" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway();' />
1610
																			</div>
1611
																		</center>
1612
																	</td>
1613
																</tr>
1614
																<tr><td>&nbsp;</td></tr>
1615
															</table>
1616
														</td>
1617
													</tr>
1618
												</table>
1619
											</div>
1620
										</td>
1621
									</tr>
1622
									<tr>
1623
										<td colspan="2" valign="top" height="16"></td>
1624
									</tr>
1625
								</table>
1626
							</td>
1627
						</tr>
1628
						<tr style="display:none;" name="staticv6" id="staticv6">
1629
							<td colspan="2" style="padding:0px;">
1630
								<a name="gatewayv6section"></a>
1631
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv6">
1632
									<tr>
1633
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1634
									</tr>
1635
									<tr>
1636
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1637
										<td width="78%" class="vtable">
1638
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>" />
1639
											/
1640
											<select name="subnetv6" class="formselect" id="subnetv6">
1641
												<?php
1642
												for ($i = 128; $i > 0; $i--) {
1643
													if($i <> 127) {
1644
														echo "<option value=\"{$i}\" ";
1645
														if ($i == $pconfig['subnetv6']) echo "selected=\"selected\"";
1646
														echo ">" . $i . "</option>";
1647
													}
1648
												}
1649
												?>
1650
											</select>
1651
										</td>
1652
									</tr>
1653
									<tr>
1654
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway IPv6"); ?></td>
1655
										<td width="78%" class="vtable">
1656
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1657
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1658
													<?php
1659
													if(count($a_gateways) > 0) {
1660
														foreach ($a_gateways as $gateway) {
1661
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1662
													?>
1663
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected=\"selected\""; ?>>
1664
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1665
															</option>
1666
													<?php
1667
															}
1668
														}
1669
													}
1670
													?>
1671
											</select>
1672
											- or <strong><a onclick="show_add_gateway_v6();" href="#gatewayv6section"><?=gettext("add a new one."); ?></a></strong>
1673
											<br/>
1674
											<div id='addgwboxv6'>
1675
											<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above"); ?>
1676
											</div>
1677
											<div id='noteboxv6'>
1678
											</div>
1679
											<div id="statusv6">
1680
											</div>
1681
											<div style="display:none" id="addgatewayv6" name="addgatewayv6">
1682
												<p>&nbsp;</p>
1683
												<table border="1" class="addgatewaybox" summary="addgatewayv6">
1684
													<tr>
1685
														<td>
1686
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgatewayv6">
1687
																<tr><td>&nbsp;</td></tr>
1688
																<tr>
1689
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1690
																</tr>
1691
																<tr><td>&nbsp;</td></tr>
1692
																<?php
1693
																if($if == "wan" || $if == "WAN")
1694
																	$checked = " checked=\"checked\"";
1695
																?>
1696
																<tr>
1697
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></font></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?> /></td>
1698
																</tr>
1699
																<tr>
1700
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></font></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>" /></td>
1701
																</tr>
1702
																<tr>
1703
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></font></td><td><input id="gatewayipv6" name="gatewayipv6" /></td>
1704
																</tr>
1705
																<tr>
1706
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescrv6" name="gatewaydescrv6" /></td>
1707
																</tr>
1708
																<tr><td>&nbsp;</td></tr>
1709
																<tr>
1710
																	<td colspan="2">
1711
																		<center>
1712
																			<div id='savebuttondivv6'>
1713
																				<input id="gwsavev6" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave_v6();' />
1714
																				<input id="gwcancelv6" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway_v6();' />
1715
																			</div>
1716
																		</center>
1717
																	</td>
1718
																</tr>
1719
																<tr><td>&nbsp;</td></tr>
1720
															</table>
1721
														</td>
1722
													</tr>
1723
												</table>
1724
											</div>
1725
										</td>
1726
									</tr>
1727
									<tr>
1728
										<td colspan="2" valign="top" height="16"></td>
1729
									</tr>
1730
								</table>
1731
							</td>
1732
						</tr>
1733
						<tr style="display:none;" name="dhcp" id="dhcp">
1734
							<td colspan="2" style="padding: 0px;">
1735
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp">
1736
									<tr>
1737
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration"); ?></td>
1738
									</tr>
1739
									<!-- Uncomment to expose DHCP+ in GUI
1740
									<tr>
1741
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1742
										<td width="78%" class="vtable">
1743
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked=\"checked\""; ?> />
1744
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1745
										<br/>
1746
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
1747
										</td>
1748
									</tr>
1749
									-->
1750
									<tr>
1751
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1752
										<td width="78%" class="vtable">
1753
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>" />
1754
											<br/>
1755
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1756
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1757
											"this (for client identification)."); ?>
1758
										</td>
1759
									</tr>
1760
									<tr>
1761
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
1762
										<td width="78%" class="vtable">
1763
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>" />
1764
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1765
												<?php
1766
												for ($i = 32; $i > 0; $i--) {
1767
													if($i <> 31) {
1768
														echo "<option value=\"{$i}\" ";
1769
														if ($i == $pconfig['alias-subnet']) echo "selected=\"selected\"";
1770
														echo ">" . $i . "</option>";
1771
													}
1772
												}
1773
												?>
1774
											</select>
1775
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
1776
											"DHCP client."); ?>
1777
										</td>
1778
									</tr>
1779
									<tr>
1780
										<td width="22%" valign="top" class="vncell"><?=gettext("Reject Leases From"); ?></td>
1781
										<td width="78%" class="vtable">
1782
											<input name="dhcprejectfrom" type="text" class="formfld unknown" id="dhcprejectfrom" size="20" value="<?=htmlspecialchars($pconfig['dhcprejectfrom']);?>" />
1783
											<br/>
1784
											<?=gettext("If there is a certain upstream DHCP server that should be ignored, place the IP address or subnet of the DHCP server to be ignored here."); ?>
1785
											<?=gettext("This is useful for rejecting leases from cable modems that offer private IPs when they lose upstream sync."); ?>
1786
										</td>
1787
									</tr>
1788
									<tr>
1789
										<td colspan="2" valign="top" height="16"></td>
1790
									</tr>
1791
								</table>
1792
							</td>
1793
						</tr>
1794
						<tr style="display:none;" name="dhcp6" id="dhcp6">
1795
							<td colspan="2" style="padding: 0px;">
1796
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp6">
1797
									<tr>
1798
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration"); ?></td>
1799
									</tr>
1800
									<!--- Leave commented out for now
1801
									<tr>
1802
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
1803
										<td width="78%" class="vtable">
1804
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>" />
1805
											<br/>
1806
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
1807
											"when requesting a DHCPv6 lease."); ?><br />
1808
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
1809
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
1810
												}
1811
												printf(gettext("The current DUID is: '%s'"),$current_duid);
1812
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
1813
											?>
1814
										</td>
1815
									</tr>
1816
									-->
1817
									<tr>
1818
										<td width="22%" valign="top" class="vncell"><?=gettext("Use IPv4 connectivity as parent interface"); ?></td>
1819
										<td width="78%" class="vtable">
1820
											<input name="dhcp6usev4iface" type="checkbox" id="dhcp6usev4iface" value="yes" <?php if ($pconfig['dhcp6usev4iface'] == true) echo "checked=\"checked\""; ?> />
1821
											<?=gettext("Request a IPv6 prefix/information through the IPv4 connectivity link"); ?>
1822
										</td>
1823
									</tr>
1824
									<tr>
1825
										<td width="22%" valign="top" class="vncell"><?=gettext("Request only a IPv6 prefix"); ?></td>
1826
										<td width="78%" class="vtable">
1827
											<input name="dhcp6prefixonly" type="checkbox" id="dhcp6prefixonly" value="yes" <?php if ($pconfig['dhcp6prefixonly'] == true) echo "checked=\"checked\""; ?> />
1828
											<?=gettext("Only request a IPv6 prefix, do not request a IPv6 address"); ?>
1829
										</td>
1830
									</tr>
1831
									<tr>
1832
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
1833
										<td width="78%" class="vtable">
1834
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
1835
												<?php
1836
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
1837
												foreach($sizes as $bits => $length) {
1838
													echo "<option value=\"{$bits}\" ";
1839
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected=\"selected\"";
1840
													echo ">" . $length . "</option>";
1841
												}
1842
												?>
1843
											</select>
1844
											<br/>
1845
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
1846
										</td>
1847
									</tr>
1848
									<tr>
1849
										<td width="22%" valign="top" class="vncell"><?=gettext("Send IPv6 prefix hint"); ?></td>
1850
										<td width="78%" class="vtable">
1851
											<input name="dhcp6-ia-pd-send-hint" type="checkbox" id="dhcp6-ia-pd-send-hint" value="yes" <?php if ($pconfig['dhcp6-ia-pd-send-hint'] == true) echo "checked=\"checked\""; ?> />
1852
											<?=gettext("Send an IPv6 prefix hint to indicate the desired prefix size for delegation"); ?>
1853
										</td>
1854
									</tr>
1855
									<tr>
1856
										<td colspan="2" valign="top" height="16"></td>
1857
									</tr>
1858
								</table>
1859
							</td>
1860
						</tr>
1861
						<tr style="display:none;" name="6rd" id="6rd">
1862
							<td colspan="2" style="padding: 0px;">
1863
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="6rd">
1864
									<tr>
1865
										<td colspan="2" valign="top" class="listtopic"><?=gettext("6RD Rapid Deployment"); ?></td>
1866
									</tr>
1867
									<tr>
1868
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD prefix"); ?></td>
1869
										<td width="78%" class="vtable">
1870
											<input name="prefix-6rd" type="text" class="formfld unknown" id="prefix-6rd" size="40" value="<?=htmlspecialchars($pconfig['prefix-6rd']);?>" />
1871
											<br/>
1872
											<?=gettext("The value in this field is the 6RD IPv6 prefix assigned by your ISP. e.g. '2001:db8::/32'") ?><br />
1873
										</td>
1874
									</tr>
1875
									<tr>
1876
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD Border Relay"); ?></td>
1877
										<td width="78%" class="vtable">
1878
											<input name="gateway-6rd" type="text" class="formfld unknown" id="gateway-6rd" size="40" value="<?=htmlspecialchars($pconfig['gateway-6rd']);?>" />
1879
											<br/>
1880
											<?=gettext("The value in this field is 6RD IPv4 gateway address assigned by your ISP") ?><br />
1881
										</td>
1882
									</tr>
1883
									<tr>
1884
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD IPv4 Prefix length"); ?></td>
1885
										<td width="78%" class="vtable">
1886
											<select name="prefix-6rd-v4plen" class="formselect" id="prefix-6rd-v4plen">
1887
												<?php
1888
												for ($i = 0; $i < 32; $i++) {
1889
													echo "<option value=\"{$i}\" ";
1890
													if (is_numeric($pconfig['prefix-6rd-v4plen']) && ($i == $pconfig['prefix-6rd-v4plen'])) echo "selected=\"selected\"";
1891
													echo ">" . $i . " bits</option>";
1892
												}
1893
												?>
1894
											</select>
1895
											<br/>
1896
											<?=gettext("The value in this field is the 6RD IPv4 prefix length. Normally specified by the ISP. A value of 0 means we embed the entire IPv4 address in the 6RD prefix."); ?>
1897
										</td>
1898
									</tr>
1899
									<tr>
1900
										<td colspan="2" valign="top" height="16"></td>
1901
									</tr>
1902
								</table>
1903
							</td>
1904
						</tr>
1905
						<tr style="display:none;" name="track6" id="track6">
1906
							<td colspan="2" style="padding: 0px;">
1907
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="track6">
1908
									<tr>
1909
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
1910
									</tr>
1911
									<tr>
1912
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
1913
										<td width="78%" class="vtable">
1914
										<select name='track6-interface' class='formselect' >
1915
										<?php
1916
											$interfaces = get_configured_interface_with_descr(false, true);
1917
											$dynv6ifs = array();
1918
											foreach ($interfaces as $iface => $ifacename) {
1919
												switch($config['interfaces'][$iface]['ipaddrv6']) {
1920
													case "6to4":
1921
													case "6rd":
1922
													case "dhcp6":
1923
														$dynv6ifs[$iface] = $ifacename;
1924
														break;
1925
													default:
1926
														continue;
1927
												}
1928
											}
1929
											foreach($dynv6ifs as $iface => $ifacename) {
1930
												echo "<option value=\"{$iface}\"";
1931
												if ($iface == $pconfig['track6-interface'])
1932
													echo " selected=\"selected\"";
1933
												echo ">" . htmlspecialchars($ifacename) . "</option>";
1934
											}
1935
										?>
1936
										</select> <br/>
1937
											<br/>
1938
											<?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
1939
										</td>
1940
									</tr>
1941
									<tr>
1942
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
1943
										<td width="78%" class="vtable">
1944
											<?php
1945
												if ($pconfig['track6-prefix-id'] == "")
1946
													$pconfig['track6-prefix-id'] = 0;
1947
												$track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
1948
											?>
1949
											<input name="track6-prefix-id--hex" type="text" class="formfld unknown" id="track6-prefix-id--hex" size="8" value="<?= $track6_prefix_id_hex ?>" />
1950
											<br />
1951
											<?= gettext("The value in this field is the (Delegated) IPv6 prefix id. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
1952
											<br />
1953
											<?= sprintf(gettext("Enter a <b>hexadecimal</b> value between %x and %x here, default value is 0."), 0, $ipv6_num_prefix_ids - 1); ?>
1954
										</td>
1955
									</tr>
1956
									<tr>
1957
										<td colspan="2" valign="top" height="16"></td>
1958
									</tr>
1959
								</table>
1960
							</td>
1961
						</tr>
1962
						<tr style="display:none;" name="ppp" id="ppp">
1963
							<td colspan="2" style="padding: 0px;">
1964
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="ppp">
1965
									<tr>
1966
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
1967
									</tr>
1968
									<tr name="ppp_provider" id="ppp_provider">
1969
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
1970
										<td width="78%" class="vtable">
1971
											<table border="0" cellpadding="0" cellspacing="0" summary="service provider">
1972
												<tr id="trcountry">
1973
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
1974
													<td>
1975
														<select class="formselect" name="country" id="country" onchange="providers_list()">
1976
															<option></option>
1977
														</select>
1978
													</td>
1979
												</tr>
1980
												<tr id="trprovider" style="display:none">
1981
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
1982
													<td>
1983
														<select class="formselect" name="provider" id="provider" onchange="providerplan_list()">
1984
															<option></option>
1985
														</select>
1986
													</td>
1987
												</tr>
1988
												<tr id="trproviderplan" style="display:none">
1989
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
1990
													<td>
1991
														<select class="formselect" name="providerplan" id="providerplan" onchange="prefill_provider()">
1992
															<option></option>
1993
														</select>
1994
													</td>
1995
												</tr>
1996
											</table>
1997
											<br/><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
1998
										</td>
1999
									</tr>
2000
									<tr>
2001
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
2002
										<td width="78%" class="vtable">
2003
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>" />
2004
										</td>
2005
									</tr>
2006
									<tr>
2007
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
2008
										<td width="78%" class="vtable">
2009
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>" />
2010
										</td>
2011
									</tr>
2012
									<tr name="phone_num" id="phone_num">
2013
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
2014
										<td width="78%" class="vtable">
2015
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>" />
2016
										</td>
2017
									</tr>
2018
									<tr name="apn_" id="apn_">
2019
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
2020
										<td width="78%" class="vtable">
2021
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>" />
2022
										</td>
2023
									</tr>
2024
									<tr name="interface" id="interface" >
2025
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
2026
										<td width="78%" class="vtable">
2027
											<select name="port" id="port" class="formselect">
2028
											<?php
2029
												$portlist = glob("/dev/cua*");
2030
												$modems = glob("/dev/modem*");
2031
												$portlist = array_merge($portlist, $modems);
2032
												foreach ($portlist as $port) {
2033
													if(preg_match("/\.(lock|init)$/", $port))
2034
														continue;
2035
													echo "<option value=\"".trim($port)."\"";
2036
													if ($pconfig['port'] == $port)
2037
														echo " selected=\"selected\"";
2038
													echo ">{$port}</option>";
2039
												}?>
2040
											</select>
2041
										</td>
2042
									</tr>
2043
									<tr>
2044
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
2045
										<?php if (isset($pconfig['pppid'])): ?>
2046
											<td width="78%" class="vtable">
2047
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2048
											<?=gettext("to edit PPP configuration."); ?>
2049
											</td>
2050
										<?php else: ?>
2051
											<td width="78%" class="vtable">
2052
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2053
											<?=gettext("to create a PPP configuration."); ?>
2054
											</td>
2055
										<?php endif; ?>
2056
									</tr>
2057
									<tr>
2058
										<td colspan="2" valign="top" height="16"></td>
2059
									</tr>
2060
								</table>
2061
							</td>
2062
						</tr>
2063
						<tr style="display:none;" name="pppoe" id="pppoe">
2064
							<td colspan="2" style="padding:0px;">
2065
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pppoe">
2066
									<tr>
2067
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
2068
									</tr>
2069
									<tr>
2070
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2071
										<td width="78%" class="vtable">
2072
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>" />
2073
										</td>
2074
									</tr>
2075
									<tr>
2076
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2077
										<td width="78%" class="vtable">
2078
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>" />
2079
										</td>
2080
									</tr>
2081
									<tr>
2082
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
2083
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>" />
2084
											<br/> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
2085
										</td>
2086
									</tr>
2087
									<tr>
2088
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2089
										<td width="78%" class="vtable">
2090
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked=\"checked\""; ?> />
2091
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br/>
2092
											<?=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."); ?>
2093
										</td>
2094
									</tr>
2095
									<tr>
2096
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2097
										<td width="78%" class="vtable">
2098
											<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."); ?>
2099
										</td>
2100
									</tr>
2101
									<tr>
2102
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
2103
										<td width="78%" class="vtable">
2104
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%" summary="periodic reset">
2105
												<tr>
2106
													<td align="left" valign="top">
2107
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
2108
														<select style="vertical-align:top" id="reset_type" name="pppoe-reset-type" class="formselect" onchange="show_reset_settings(this.value);">
2109
															<option value=""><?=gettext("Disabled"); ?></option>
2110
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected=\"selected\""; ?>><?=gettext("Custom"); ?></option>
2111
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected=\"selected\""; ?>><?=gettext("Pre-Set"); ?></option>
2112
														</select> <?=gettext("Select a reset timing type"); ?>
2113
														</p>
2114
														<?php if ($pconfig['pppoe_pr_custom']): ?>
2115
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
2116
														<?php else: ?>
2117
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
2118
														<?php endif; ?>
2119
														<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" />
2120
														<?=gettext("hour (0-23)"); ?><br />
2121
														<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" />
2122
														<?=gettext("minute (0-59)"); ?><br />
2123
														<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']);?>" />
2124
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
2125
														<br />&nbsp;<br />
2126
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
2127
														<?=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."); ?>
2128
														</p>
2129
														<?php if ($pconfig['pppoe_pr_preset']): ?>
2130
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
2131
														<?php else: ?>
2132
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
2133
														<?php endif; ?>
2134
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
2135
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
2136
														<br />
2137
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
2138
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
2139
														<br />
2140
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
2141
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
2142
														<br />
2143
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
2144
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
2145
														</p>
2146
													</td>
2147
												</tr>
2148
											</table>
2149
										</td>
2150
									</tr>
2151

    
2152
									<tr>
2153
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
2154
										<?php if (isset($pconfig['pppid'])): ?>
2155
											<td width="78%" class="vtable">
2156
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2157
											<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
2158
											</td>
2159
										<?php else: ?>
2160
											<td width="78%" class="vtable">
2161
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2162
											<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
2163
											</td>
2164
										<?php endif; ?>
2165
									</tr>
2166
									<tr>
2167
										<td colspan="2" valign="top" height="16"></td>
2168
									</tr>
2169
								</table>
2170
							</td>
2171
						</tr>
2172
						<tr style="display:none;" name="pptp" id="pptp">
2173
							<td colspan="2" style="padding:0px;">
2174
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pptp">
2175
									<tr>
2176
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP/L2TP configuration"); ?></td>
2177
									</tr>
2178
									<tr>
2179
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2180
										<td width="78%" class="vtable">
2181
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>" />
2182
										</td>
2183
									</tr>
2184
									<tr>
2185
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2186
										<td width="78%" class="vtable">
2187
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>" />
2188
										</td>
2189
									</tr>
2190
									<tr>
2191
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
2192
										<td width="78%" class="vtable">
2193
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>" />
2194
											/
2195
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
2196
												<?php for ($i = 31; $i > 0; $i--): ?>
2197
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected=\"selected\""; ?>>
2198
														<?=$i;?></option>
2199
												<?php endfor; ?>
2200
											</select>
2201
										</td>
2202
									</tr>
2203
									<tr>
2204
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
2205
										<td width="78%" class="vtable">
2206
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>" />
2207
										</td>
2208
									</tr>
2209
									<tr>
2210
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2211
										<td width="78%" class="vtable">
2212
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked=\"checked\""; ?> />
2213
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br/>
2214
											<?=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."); ?>
2215
										</td>
2216
									</tr>
2217
									<tr>
2218
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2219
										<td width="78%" class="vtable">
2220
											<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."); ?>
2221
										</td>
2222
									</tr>
2223
									<tr>
2224
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
2225
										<?php if (isset($pconfig['pppid'])): ?>
2226
											<td width="78%" class="vtable">
2227
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
2228
											<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
2229
											</td>
2230
										<?php else: ?>
2231
											<td width="78%" class="vtable">
2232
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
2233
											<?=gettext("for advanced PPTP and L2TP configuration options");?>.
2234
											</td>
2235
										<?php endif; ?>
2236
									</tr>
2237
									<tr>
2238
										<td colspan="2" valign="top" height="16"></td>
2239
									</tr>
2240
								</table>
2241
							</td>
2242
						</tr>
2243
						<?php
2244
							/* Wireless interface? */
2245
							if (isset($wancfg['wireless'])):
2246
						?>
2247
						<tr>
2248
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
2249
						</tr>
2250
						<tr>
2251
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
2252
							<td class="vtable">
2253
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked=\"checked\"";?> />
2254
								<br/><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
2255
							</td>
2256
						</tr>
2257
						<tr>
2258
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
2259
							<td class="vtable">
2260
							<select name="standard" class="formselect" id="standard">
2261
								<?php
2262
								foreach($wl_modes as $wl_standard => $wl_channels) {
2263
									echo "<option ";
2264
									if ($pconfig['standard'] == "$wl_standard")
2265
										echo "selected=\"selected\" ";
2266
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
2267
								}
2268
								?>
2269
							</select>
2270
							</td>
2271
						</tr>
2272
						<?php if (isset($wl_modes['11g'])): ?>
2273
						<tr>
2274
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
2275
							<td class="vtable">
2276
								<select name="protmode" class="formselect" id="protmode">
2277
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected=\"selected\"";?> value="off"><?=gettext("Protection mode off"); ?></option>
2278
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected=\"selected\"";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
2279
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected=\"selected\"";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
2280
								</select>
2281
								<br/>
2282
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
2283
								<br/>
2284
							</td>
2285
						</tr>
2286
						<?php else: ?>
2287
						<input name="protmode" type="hidden" id="protmode" value="off" />
2288
						<?php endif; ?>
2289
						<tr>
2290
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
2291
							<td class="vtable">
2292
								<select name="txpower" class="formselect" id="txpower">
2293
									<?
2294
									for($x = 99; $x > 0; $x--) {
2295
										if($pconfig["txpower"] == $x)
2296
											$SELECTED = " selected=\"selected\"";
2297
										else
2298
											$SELECTED = "";
2299
										echo "<option {$SELECTED}>{$x}</option>\n";
2300
									}
2301
									?>
2302
								</select><br/>
2303
								<?=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."); ?>
2304
							</td>
2305
						</tr>
2306
						<tr>
2307
							<td valign="top" class="vncellreq"><?=gettext("Channel"); ?></td>
2308
							<td class="vtable">
2309
								<select name="channel" class="formselect" id="channel">
2310
									<option <?php if ($pconfig['channel'] == 0) echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2311
									<?php
2312
									foreach($wl_modes as $wl_standard => $wl_channels) {
2313
										if($wl_standard == "11g") { $wl_standard = "11b/g"; }
2314
										else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
2315
										else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
2316
										foreach($wl_channels as $wl_channel) {
2317
											echo "<option ";
2318
											if ($pconfig['channel'] == "$wl_channel") {
2319
												echo "selected=\"selected\" ";
2320
											}
2321
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
2322
											if(isset($wl_chaninfo[$wl_channel]))
2323
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
2324
											echo "</option>\n";
2325
										}
2326
									}
2327
									?>
2328
								</select>
2329
								<br/>
2330
								<?=gettext("Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)"); ?>
2331
								<br/>
2332
								<?=gettext("Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above."); ?>
2333
							</td>
2334
						</tr>
2335
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2336
						<tr>
2337
							<td valign="top" class="vncell"><?=gettext("Antenna settings"); ?></td>
2338
							<td class="vtable">
2339
								<table border="0" cellpadding="0" cellspacing="0" summary="antenna settings">
2340
									<tr>
2341
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])): ?>
2342
										<td>
2343
											<?=gettext("Diversity"); ?><br/>
2344
											<select name="diversity" class="formselect" id="diversity">
2345
												<option <?php if (!isset($pconfig['diversity'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2346
												<option <?php if ($pconfig['diversity'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Off"); ?></option>
2347
												<option <?php if ($pconfig['diversity'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("On"); ?></option>
2348
											</select>
2349
										</td>
2350
										<td>&nbsp;&nbsp</td>
2351
										<?php endif; ?>
2352
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])): ?>
2353
										<td>
2354
											<?=gettext("Transmit antenna"); ?><br/>
2355
											<select name="txantenna" class="formselect" id="txantenna">
2356
												<option <?php if (!isset($pconfig['txantenna'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2357
												<option <?php if ($pconfig['txantenna'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2358
												<option <?php if ($pconfig['txantenna'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("#1"); ?></option>
2359
												<option <?php if ($pconfig['txantenna'] === '2') echo "selected=\"selected\""; ?> value="2"><?=gettext("#2"); ?></option>
2360
											</select>
2361
										</td>
2362
										<td>&nbsp;&nbsp</td>
2363
										<?php endif; ?>
2364
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2365
										<td>
2366
											<?=gettext("Receive antenna"); ?><br/>
2367
											<select name="rxantenna" class="formselect" id="rxantenna">
2368
												<option <?php if (!isset($pconfig['rxantenna'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2369
												<option <?php if ($pconfig['rxantenna'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2370
												<option <?php if ($pconfig['rxantenna'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("#1"); ?></option>
2371
												<option <?php if ($pconfig['rxantenna'] === '2') echo "selected=\"selected\""; ?> value="2"><?=gettext("#2"); ?></option>
2372
											</select>
2373
										</td>
2374
										<?php endif; ?>
2375
									</tr>
2376
								</table>
2377
								<br/>
2378
								<?=gettext("Note: The antenna numbers do not always match up with the labels on the card."); ?>
2379
							</td>
2380
						</tr>
2381
						<?php endif; ?>
2382
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])): ?>
2383
						<tr>
2384
							<td valign="top" class="vncell"><?=gettext("Distance setting"); ?></td>
2385
							<td class="vtable">
2386
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>" />
2387
								<br/>
2388
								<?=gettext("Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client"); ?><br/>
2389
								<?=gettext("(measured in Meters and works only for Atheros based cards !)"); ?>
2390
							</td>
2391
						</tr>
2392
						<?php endif; ?>
2393
						<tr>
2394
							<td valign="top" class="vncell"><?=gettext("Regulatory settings"); ?></td>
2395
							<td class="vtable">
2396
								<?=gettext("Regulatory domain"); ?><br/>
2397
								<select name="regdomain" class="formselect" id="regdomain">
2398
									<option <?php if (empty($pconfig['regdomain'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2399
									<?php
2400
									foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
2401
										echo "<option ";
2402
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
2403
											echo "selected=\"selected\" ";
2404
										}
2405
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
2406
									}
2407
									?>
2408
								</select>
2409
								<br/>
2410
								<?=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."); ?>
2411
								<br/><br/>
2412
								<?=gettext("Country (listed with country code and regulatory domain)"); ?><br/>
2413
								<select name="regcountry" class="formselect" id="regcountry">
2414
									<option <?php if (empty($pconfig['regcountry'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2415
									<?php
2416
									foreach($wl_countries as $wl_country_key => $wl_country) {
2417
										echo "<option ";
2418
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
2419
											echo "selected=\"selected\" ";
2420
										}
2421
										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";
2422
									}
2423
									?>
2424
								</select>
2425
								<br/>
2426
								<?=gettext("Note: Any country setting other than \"Default\" will override the regulatory domain setting"); ?>.
2427
								<br/><br/>
2428
								<?=gettext("Location"); ?><br/>
2429
								<select name="reglocation" class="formselect" id="reglocation">
2430
									<option <?php if (empty($pconfig['reglocation'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2431
									<option <?php if ($pconfig['reglocation'] == 'indoor') echo "selected=\"selected\""; ?> value="indoor"><?=gettext("Indoor"); ?></option>
2432
									<option <?php if ($pconfig['reglocation'] == 'outdoor') echo "selected=\"selected\""; ?> value="outdoor"><?=gettext("Outdoor"); ?></option>
2433
									<option <?php if ($pconfig['reglocation'] == 'anywhere') echo "selected=\"selected\""; ?> value="anywhere"><?=gettext("Anywhere"); ?></option>
2434
								</select>
2435
								<br/><br/>
2436
								<?=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."); ?>
2437
								<br/>
2438
								<?=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."); ?>
2439
							</td>
2440
						</tr>
2441
						<tr>
2442
							<td colspan="2" valign="top" height="16"></td>
2443
						</tr>
2444
						<tr>
2445
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Network-specific wireless configuration");?></td>
2446
						</tr>
2447
						<tr>
2448
							<td valign="top" class="vncellreq"><?=gettext("Mode"); ?></td>
2449
							<td class="vtable">
2450
								<select name="mode" class="formselect" id="mode">
2451
									<option <?php if ($pconfig['mode'] == 'bss') echo "selected=\"selected\"";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
2452
									<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected=\"selected\"";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
2453
									<option <?php if ($pconfig['mode'] == 'hostap') echo "selected=\"selected\"";?> value="hostap"><?=gettext("Access Point"); ?></option>
2454
								</select>
2455
							</td>
2456
						</tr>
2457
						<tr>
2458
							<td valign="top" class="vncellreq"><?=gettext("SSID"); ?></td>
2459
							<td class="vtable">
2460
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>" />
2461
								<br/>
2462
								<?=gettext("Note: Only required in Access Point mode. If left blank in Ad-hoc or Infrastructure mode, this interface will connect to any available SSID"); ?>
2463
							</td>
2464
						</tr>
2465
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
2466
						<tr>
2467
							<td valign="top" class="vncell"><?=gettext("Minimum wireless standard"); ?></td>
2468
							<td class="vtable">
2469
								<select name="puremode" class="formselect" id="puremode">
2470
									<option <?php if ($pconfig['puremode'] == 'any') echo "selected=\"selected\"";?> value="any"><?=gettext("Any"); ?></option>
2471
									<?php if (isset($wl_modes['11g'])): ?>
2472
									<option <?php if ($pconfig['puremode'] == '11g') echo "selected=\"selected\"";?> value="11g"><?=gettext("802.11g"); ?></option>
2473
									<?php endif; ?>
2474
									<option <?php if ($pconfig['puremode'] == '11n') echo "selected=\"selected\"";?> value="11n"><?=gettext("802.11n"); ?></option>
2475
								</select>
2476
								<br/>
2477
								<?=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)."); ?>
2478
							</td>
2479
						</tr>
2480
						<?php elseif (isset($wl_modes['11g'])): ?>
2481
						<tr>
2482
							<td valign="top" class="vncell"><?=gettext("802.11g only"); ?></td>
2483
							<td class="vtable">
2484
								<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <?php if ($pconfig['puremode'] == '11g') echo "checked=\"checked\"";?> />
2485
								<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)."); ?>
2486
							</td>
2487
						</tr>
2488
						<?php endif; ?>
2489
						<tr>
2490
							<td valign="top" class="vncell"><?=gettext("Allow intra-BSS communication"); ?></td>
2491
							<td class="vtable">
2492
								<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <?php if ($pconfig['apbridge_enable']) echo "checked=\"checked\"";?> />
2493
								<br/>
2494
								<?=gettext("When operating as an access point, enable this if you want to pass packets between wireless clients directly."); ?>
2495
								<br/>
2496
								<?=gettext("Disabling the internal bridging is useful when traffic is to be processed with packet filtering."); ?>
2497
							</td>
2498
						</tr>
2499
						<tr>
2500
							<td valign="top" class="vncell"><?=gettext("Enable WME"); ?></td>
2501
							<td class="vtable">
2502
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <?php if ($pconfig['wme_enable']) echo "checked=\"checked\"";?> />
2503
								<br/><?=gettext("Setting this option will force the card to use WME (wireless QoS)."); ?>
2504
							</td>
2505
						</tr>
2506
						<tr>
2507
							<td valign="top" class="vncell"><?=gettext("Enable Hide SSID"); ?></td>
2508
							<td class="vtable">
2509
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <?php if ($pconfig['hidessid_enable']) echo "checked=\"checked\"";?> />
2510
								<br/>
2511
								<?=gettext("Setting this option will force the card to NOT broadcast its SSID"); ?>
2512
								<br/>
2513
								<?=gettext("(this might create problems for some clients)."); ?>
2514
							</td>
2515
						</tr>
2516
						<tr>
2517
							<td valign="top" class="vncell"><?=gettext("WEP"); ?></td>
2518
							<td class="vtable">
2519
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <?php if ($pconfig['wep_enable']) echo "checked=\"checked\""; ?> />
2520
								<strong><?=gettext("Enable WEP"); ?></strong>
2521
								<table border="0" cellspacing="0" cellpadding="0" summary="wep">
2522
									<tr>
2523
										<td>&nbsp;</td>
2524
										<td>&nbsp;</td>
2525
										<td>&nbsp;<?=gettext("TX key"); ?>&nbsp;</td>
2526
									</tr>
2527
									<tr>
2528
										<td><?=gettext("Key 1:"); ?>&nbsp;&nbsp;</td>
2529
										<td>
2530
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>" />
2531
										</td>
2532
										<td align="center">
2533
											<input name="txkey" type="radio" value="1" <?php if ($pconfig['txkey'] == 1) echo "checked=\"checked\"";?>>
2534
										</td>
2535
									</tr>
2536
									<tr>
2537
										<td><?=gettext("Key 2:"); ?>&nbsp;&nbsp;</td>
2538
										<td>
2539
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>" />
2540
										</td>
2541
										<td align="center">
2542
											<input name="txkey" type="radio" value="2" <?php if ($pconfig['txkey'] == 2) echo "checked=\"checked\"";?> />
2543
										</td>
2544
									</tr>
2545
									<tr>
2546
										<td><?=gettext("Key 3:"); ?>&nbsp;&nbsp;</td>
2547
										<td>
2548
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>" />
2549
										</td>
2550
										<td align="center">
2551
											<input name="txkey" type="radio" value="3" <?php if ($pconfig['txkey'] == 3) echo "checked=\"checked\"";?> />
2552
										</td>
2553
									</tr>
2554
									<tr>
2555
										<td><?=gettext("Key 4:"); ?>&nbsp;&nbsp;</td>
2556
										<td>
2557
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>" />
2558
										</td>
2559
										<td align="center">
2560
											<input name="txkey" type="radio" value="4" <?php if ($pconfig['txkey'] == 4) echo "checked=\"checked\"";?> />
2561
										</td>
2562
									</tr>
2563
								</table>
2564
								<br/>
2565
								<?=gettext("40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'."); ?><br/>
2566
								<?=gettext("104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'."); ?>
2567
							</td>
2568
						</tr>
2569
						<tr>
2570
							<td valign="top" class="vncell"><?=gettext("WPA"); ?></td>
2571
							<td class="vtable">
2572
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <?php if ($pconfig['wpa_enable']) echo "checked=\"checked\""; ?> />
2573
								<strong><?=gettext("Enable WPA"); ?></strong>
2574
								<br/><br/>
2575
								<table border="0" cellspacing="0" cellpadding="0" summary="wpa">
2576
									<tr>
2577
										<td>&nbsp;</td>
2578
										<td>&nbsp;<?=gettext("WPA Pre-Shared Key"); ?>&nbsp;</td>
2579
									</tr>
2580
									<tr>
2581
										<td><?=gettext("PSK:"); ?>&nbsp;&nbsp;</td>
2582
										<td>
2583
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>" />
2584
										</td>
2585
									</tr>
2586
								</table>
2587
								<br/><?=gettext("Passphrase must be from 8 to 63 characters."); ?>
2588
							</td>
2589
						</tr>
2590
						<tr>
2591
							<td valign="top" class="vncell"><?=gettext("WPA Mode"); ?></td>
2592
							<td class="vtable">
2593
								<select name="wpa_mode" class="formselect" id="wpa_mode">
2594
									<option <?php if ($pconfig['wpa_mode'] == '1') echo "selected=\"selected\"";?> value="1"><?=gettext("WPA"); ?></option>
2595
									<option <?php if ($pconfig['wpa_mode'] == '2') echo "selected=\"selected\"";?> value="2"><?=gettext("WPA2"); ?></option>
2596
									<option <?php if ($pconfig['wpa_mode'] == '3') echo "selected=\"selected\"";?> value="3"><?=gettext("Both"); ?></option>
2597
								</select>
2598
							</td>
2599
						</tr>
2600
						<tr>
2601
							<td valign="top" class="vncell"><?=gettext("WPA Key Management Mode"); ?></td>
2602
							<td class="vtable">
2603
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
2604
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected=\"selected\"";?> value="WPA-PSK"><?=gettext("Pre-Shared Key"); ?></option>
2605
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected=\"selected\"";?> value="WPA-EAP"><?=gettext("Extensible Authentication Protocol"); ?></option>
2606
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected=\"selected\"";?> value="WPA-PSK WPA-EAP"><?=gettext("Both"); ?></option>
2607
								</select>
2608
							</td>
2609
						</tr>
2610
						<tr>
2611
							<td valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
2612
							<td class="vtable">
2613
								<select name="auth_algs" class="formselect" id="auth_algs">
2614
									<option <?php if ($pconfig['auth_algs'] == '1') echo "selected=\"selected\"";?> value="1"><?=gettext("Open System Authentication"); ?></option>
2615
									<option <?php if ($pconfig['auth_algs'] == '2') echo "selected=\"selected\"";?> value="2"><?=gettext("Shared Key Authentication"); ?></option>
2616
									<option <?php if ($pconfig['auth_algs'] == '3') echo "selected=\"selected\"";?> value="3"><?=gettext("Both"); ?></option>
2617
								</select>
2618
								<br/><?=gettext("Note: Shared Key Authentication requires WEP."); ?></br>
2619
							</td>
2620
						</tr>
2621
						<tr>
2622
							<td valign="top" class="vncell"><?=gettext("WPA Pairwise"); ?></td>
2623
							<td class="vtable">
2624
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
2625
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected=\"selected\"";?> value="CCMP TKIP"><?=gettext("Both"); ?></option>
2626
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected=\"selected\"";?> value="CCMP"><?=gettext("AES (recommended)"); ?></option>
2627
									<option <?php if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected=\"selected\"";?> value="TKIP"><?=gettext("TKIP"); ?></option>
2628
								</select>
2629
							</td>
2630
						</tr>
2631
						<tr>
2632
							<td valign="top" class="vncell"><?=gettext("Key Rotation"); ?></td>
2633
							<td class="vtable">
2634
								<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";?>" />
2635
								<br/><?=gettext("Allowed values are 1-9999 but should not be longer than Master Key Regeneration time."); ?>
2636
							</td>
2637
						</tr>
2638
						<tr>
2639
							<td valign="top" class="vncell"><?=gettext("Master Key Regeneration"); ?></td>
2640
							<td class="vtable">
2641
								<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";?>" />
2642
								<br/><?=gettext("Allowed values are 1-9999 but should not be shorter than Key Rotation time."); ?>
2643
							</td>
2644
						</tr>
2645
						<tr>
2646
							<td valign="top" class="vncell"><?=gettext("Strict Key Regeneration"); ?></td>
2647
							<td class="vtable">
2648
								<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <?php if ($pconfig['wpa_strict_rekey']) echo "checked=\"checked\""; ?> />
2649
								<br/><?=gettext("Setting this option will force the AP to rekey whenever a client disassociates."); ?>
2650
							</td>
2651
						</tr>
2652
						<tr>
2653
							<td valign="top" class="vncell"><?=gettext("Enable IEEE802.1X Authentication"); ?></td>
2654
							<td class="vtable">
2655
								<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <?php if ($pconfig['ieee8021x']) echo "checked=\"checked\"";?> />
2656
								<br/><?=gettext("Setting this option will enable 802.1x authentication."); ?>
2657
								<br/><span class="red"><strong><?=gettext("NOTE"); ?>:</strong></span> <?=gettext("this option requires checking the \"Enable WPA box\"."); ?>
2658
							</td>
2659
						</tr>
2660
						<tr>
2661
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server IP Address"); ?></td>
2662
							<td class="vtable">
2663
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>" />
2664
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
2665
							</td>
2666
						</tr>
2667
						<tr>
2668
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Port"); ?></td>
2669
							<td class="vtable">
2670
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>" />
2671
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
2672
							</td>
2673
						</tr>
2674
						<tr>
2675
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Shared Secret"); ?></td>
2676
							<td class="vtable">
2677
								<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']);?>" />
2678
								<br/>
2679
							</td>
2680
						</tr>
2681
						<tr>
2682
					<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server IP Address"); ?></td>
2683
							<td class="vtable">
2684
								<input name="auth_server_addr2" id="auth_server_addr2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr2']);?>" />
2685
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
2686
							</td>
2687
						</tr>
2688
						<tr>
2689
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Port"); ?></td>
2690
							<td class="vtable">
2691
								<input name="auth_server_port2" id="auth_server_port2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port2']);?>" />
2692
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
2693
							</td>
2694
						</tr>
2695
						<tr>
2696
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Shared Secret"); ?></td>
2697
							<td class="vtable">
2698
								<input name="auth_server_shared_secret2" id="auth_server_shared_secret2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_shared_secret2']);?>" />
2699
								<br/>
2700
							</td>
2701
						</tr>
2702
						<tr>
2703
							<td valign="top" class="vncell">802.1X <?=gettext("Authentication Roaming Preauth"); ?></td>
2704
							<td class="vtable">
2705
								<input name="rsn_preauth" id="rsn_preauth" type="checkbox" class="formfld unknown" size="66" value="yes" <?php if ($pconfig['rsn_preauth']) echo "checked=\"checked\""; ?> />
2706
								<br/>
2707
							</td>
2708
						</tr>
2709
						<tr>
2710
							<td colspan="2" valign="top" height="16"></td>
2711
						</tr>
2712
						<?php endif; ?>
2713
						<tr>
2714
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Private networks"); ?></td>
2715
						</tr>
2716
						<tr>
2717
							<td valign="middle" class="vncell">&nbsp;</td>
2718
							<td class="vtable">
2719
								<a name="rfc1918"></a>
2720
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked=\"checked\""; ?> />
2721
								<strong><?=gettext("Block private networks"); ?></strong><br/>
2722
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2723
								"for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as"); ?>
2724
								<?=gettext("well as loopback addresses (127/8)."); ?>&nbsp;&nbsp; <?=gettext("You should generally " .
2725
								"leave this option turned on, unless your WAN network lies in such " .
2726
								"a private address space, too."); ?>
2727
							</td>
2728
						</tr>
2729
						<tr>
2730
							<td valign="middle" class="vncell">&nbsp;</td>
2731
							<td class="vtable">
2732
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked=\"checked\""; ?> />
2733
								<strong><?=gettext("Block bogon networks"); ?></strong><br/>
2734
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2735
								"(but not RFC 1918) or not yet assigned by IANA."); ?>&nbsp;&nbsp;
2736
								<?=gettext("Bogons are prefixes that should never appear in the Internet routing table, " .
2737
								"and obviously should not appear as the source address in any packets you receive."); ?>
2738
								<br/><br/>
2739
								<?=gettext("Note: The update frequency can be changed under System->Advanced Firewall/NAT settings.")?>
2740
							</td>
2741
						</tr>
2742
					</table> <!-- End "allcfg" table -->
2743
					</div> <!-- End "allcfg" div -->
2744

    
2745
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="buttons">
2746
						<tr>
2747
							<td width="22%" valign="top">
2748
								&nbsp;
2749
							</td>
2750
							<td width="78%">
2751
								<br/>
2752
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
2753
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
2754
								<input name="if" type="hidden" id="if" value="<?=$if;?>" />
2755
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2756
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>" />
2757
								<?php endif; ?>
2758
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>" />
2759
							</td>
2760
						</tr>
2761
					</table>
2762
					</div>
2763
				</td>
2764
			</tr>
2765
		</table>
2766
	</form>
2767
	<script type="text/javascript">
2768
	//<![CDATA[
2769
		var gatewayip;
2770
		var name;
2771
		var gatewayipv6;
2772
		var namev6;
2773
		function show_add_gateway() {
2774
			document.getElementById("addgateway").style.display = '';
2775
			document.getElementById("addgwbox").style.display = 'none';
2776
			document.getElementById("gateway").style.display = 'none';
2777
			document.getElementById("save").style.display = 'none';
2778
			document.getElementById("cancel").style.display = 'none';
2779
			document.getElementById("gwsave").style.display = '';
2780
			document.getElementById("gwcancel").style.display = '';
2781
			jQuery('#notebox').html("");
2782
		}
2783
		function show_add_gateway_v6() {
2784
			document.getElementById("addgatewayv6").style.display = '';
2785
			document.getElementById("addgwboxv6").style.display = 'none';
2786
			document.getElementById("gatewayv6").style.display = 'none';
2787
			document.getElementById("save").style.display = 'none';
2788
			document.getElementById("cancel").style.display = 'none';
2789
			document.getElementById("gwsave").style.display = '';
2790
			document.getElementById("gwcancel").style.display = '';
2791
			jQuery('#noteboxv6').html("");
2792
		}
2793
		function hide_add_gateway() {
2794
			document.getElementById("addgateway").style.display = 'none';
2795
			document.getElementById("addgwbox").style.display = '';
2796
			document.getElementById("gateway").style.display = '';
2797
			document.getElementById("save").style.display = '';
2798
			document.getElementById("cancel").style.display = '';
2799
			document.getElementById("gwsave").style.display = '';
2800
			document.getElementById("gwcancel").style.display = '';
2801
			jQuery('#status').html('');
2802
		}
2803
		function hide_add_gateway_v6() {
2804
			document.getElementById("addgatewayv6").style.display = 'none';
2805
			document.getElementById("addgwboxv6").style.display = '';
2806
			document.getElementById("gatewayv6").style.display = '';
2807
			document.getElementById("save").style.display = '';
2808
			document.getElementById("cancel").style.display = '';
2809
			document.getElementById("gwsave").style.display = '';
2810
			document.getElementById("gwcancel").style.display = '';
2811
			jQuery('#statusv6').html('');
2812
		}
2813
		function hide_add_gatewaysave() {
2814
			document.getElementById("addgateway").style.display = 'none';
2815
			jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
2816
			var iface = jQuery('#if').val();
2817
			name = jQuery('#name').val();
2818
			var descr = jQuery('#gatewaydescr').val();
2819
			gatewayip = jQuery('#gatewayip').val();
2820

    
2821
			var defaultgw = '';
2822
			if (jQuery('#defaultgw').is(':checked'))
2823
				defaultgw = '&defaultgw=on';
2824
			var url = "system_gateways_edit.php";
2825
			var pars = 'isAjax=true&ipprotocol=inet' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2826
			jQuery.ajax(
2827
				url,
2828
				{
2829
					type: 'post',
2830
					data: pars,
2831
					error: report_failure,
2832
					success: save_callback
2833
				});
2834
		}
2835
		function hide_add_gatewaysave_v6() {
2836
			document.getElementById("addgatewayv6").style.display = 'none';
2837
			jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
2838
			var iface = jQuery('#if').val();
2839
			name = jQuery('#namev6').val();
2840
			var descr = jQuery('#gatewaydescrv6').val();
2841
			gatewayip = jQuery('#gatewayipv6').val();
2842
			var defaultgw = '';
2843
			if (jQuery('#defaultgwv6').is(':checked'))
2844
				defaultgw = '&defaultgw=on';
2845
			var url_v6 = "system_gateways_edit.php";
2846
			var pars_v6 = 'isAjax=true&ipprotocol=inet6' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2847
			jQuery.ajax(
2848
				url_v6,
2849
				{
2850
					type: 'post',
2851
					data: pars_v6,
2852
					error: report_failure_v6,
2853
					success: save_callback_v6
2854
				});
2855
		}
2856
		function addOption(selectbox,text,value)
2857
		{
2858
			var optn = document.createElement("OPTION");
2859
			optn.text = text;
2860
			optn.value = value;
2861
			selectbox.append(optn);
2862
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2863
			jQuery('#notebox').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
2864
		}
2865
		function addOption_v6(selectbox,text,value)
2866
		{
2867
			var optn = document.createElement("OPTION");
2868
			optn.text = text;
2869
			optn.value = value;
2870
			selectbox.append(optn);
2871
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2872
			jQuery('#noteboxv6').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
2873
		}
2874
		function report_failure(request, textStatus, errorThrown) {
2875
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
2876
				alert(request.responseText);
2877
			} else {
2878
				alert("Sorry, we could not create your IPv4 gateway at this time.");
2879
			}
2880
			hide_add_gateway();
2881
		}
2882
		function report_failure_v6(request, textStatus, errorThrown) {
2883
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
2884
				alert(request.responseText);
2885
			} else {
2886
				alert("Sorry, we could not create your IPv6 gateway at this time.");
2887
			}
2888
			hide_add_gateway_v6();
2889
		}
2890
		function save_callback(response) {
2891
			if(response) {
2892
				document.getElementById("addgateway").style.display = 'none';
2893
				hide_add_gateway();
2894
				var gwtext = escape(name) + " - " + gatewayip;
2895
				addOption(jQuery('#gateway'), gwtext, name);
2896
				// Auto submit form?
2897
				//document.iform.submit();
2898
				//jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader /">');
2899
			} else {
2900
				report_failure();
2901
			}
2902
		}
2903
		function show_advanced_media() {
2904
			document.getElementById("showadvmediabox").innerHTML='';
2905
			aodiv = document.getElementById('showmediaadv');
2906
			aodiv.style.display = "block";
2907
		}
2908
		function save_callback_v6(response_v6) {
2909
			if(response_v6) {
2910
				document.getElementById("addgatewayv6").style.display = 'none';
2911
				hide_add_gateway_v6();
2912
				var gwtext_v6 = escape(name) + " - " + gatewayip;
2913
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
2914
				// Auto submit form?
2915
				//document.iform.submit();
2916
				//jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" />');
2917
			} else {
2918
				report_failure_v6();
2919
			}
2920
		}
2921
		<?php
2922
		echo "show_allcfg(document.iform.enable);";
2923
		echo "updateType('{$pconfig['type']}');\n";
2924
		echo "updateTypeSix('{$pconfig['type6']}');\n";
2925
		?>
2926
	//]]>
2927
	</script>
2928
	<?php include("fend.inc"); ?>
2929
	</body>
2930
</html>
(93-93/246)