Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
95

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

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

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

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

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

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

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

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

    
253
// print_r($pconfig);
254

    
255
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
256
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
257
$pconfig['spoofmac'] = $wancfg['spoofmac'];
258
$pconfig['mtu'] = $wancfg['mtu'];
259
$pconfig['mss'] = $wancfg['mss'];
260

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

    
344
$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']);
345
$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
346

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

    
355
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
356
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
357
			foreach ($toapplylist as $ifapply => $ifcfgo) {
358
				interface_bring_down($ifapply, false, $ifcfgo);
359
				interface_configure($ifapply);
360
			}
361
		}
362
		/* restart snmp so that it binds to correct address */
363
		services_snmpd_configure();
364

    
365
		/* sync filter configuration */
366
		setup_gateways_monitor();
367

    
368
		clear_subsystem_dirty('interfaces');
369

    
370
		filter_configure();
371

    
372
		enable_rrd_graphing();
373
	}
374
	@unlink("{$g['tmp_path']}/.interfaces.apply");
375
	header("Location: interfaces.php?if={$if}");
376
	exit;
377
} else if ($_POST && $_POST['enable'] != "yes") {
378
	unset($wancfg['enable']);
379
	if (isset($wancfg['wireless']))
380
		interface_sync_wireless_clones($wancfg, false);
381
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
382
	mark_subsystem_dirty('interfaces');
383
	if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
384
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
385
	} else {
386
		$toapplylist = array();
387
	}
388
	$toapplylist[$if] = $wancfg;
389
	/* we need to be able remove IP aliases for IPv6 */
390
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
391
	header("Location: interfaces.php?if={$if}");
392
	exit;
393
} else if ($_POST) {
394

    
395
	unset($input_errors);
396
	$pconfig = $_POST;
397
	if ($pconfig['track6-prefix-id--hex'] === "") {
398
		$pconfig['track6-prefix-id'] = "none";
399
	} else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
400
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
401
	} else {
402
		$pconfig['track6-prefix-id'] = "none";
403
	}
404
	conf_mount_rw();
405

    
406
	/* filter out spaces from descriptions  */
407
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
408

    
409
	/* okay first of all, cause we are just hiding the PPPoE HTML
410
	 * fields releated to PPPoE resets, we are going to unset $_POST
411
	 * vars, if the reset feature should not be used. Otherwise the
412
	 * data validation procedure below, may trigger a false error
413
	 * message.
414
	 */
415
	if (empty($_POST['pppoe-reset-type'])) {
416
		unset($_POST['pppoe_pr_type']);
417
		unset($_POST['pppoe_resethour']);
418
		unset($_POST['pppoe_resetminute']);
419
		unset($_POST['pppoe_resetdate']);
420
		unset($_POST['pppoe_pr_preset_val']);
421
	}
422
	/* description unique? */
423
	foreach ($ifdescrs as $ifent => $ifdescr) {
424
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
425
			$input_errors[] = gettext("An interface with the specified description already exists.");
426
			break;
427
		}
428
	}
429
	/* input validation */
430
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^staticv4/", $_POST['type'])))
431
		$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.");
432
	if (isset($config['dhcpd6']) && isset($config['dhcpd6'][$if]['enable']) && (! preg_match("/^staticv6/", $_POST['type6'])))
433
		$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.");
434

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

    
530
			if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
531
				$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
532
			} else {
533
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
534
				if ($track6_prefix_id < 0 || $track6_prefix_id >= $ipv6_num_prefix_ids) {
535
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.");
536
				}
537
			}
538
			break;
539
	}
540

    
541
	
542
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
543
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
544
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr'])))
545
		$input_errors[] = gettext("A valid IPv4 address must be specified.");
546
	if (($_POST['ipaddrv6'] && !is_ipaddr($_POST['ipaddrv6'])))
547
		$input_errors[] = gettext("A valid IPv6 address must be specified.");
548
	if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
549
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
550
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6'])))
551
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
552
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address'])))
553
		$input_errors[] = gettext("A valid alias IP address must be specified.");
554
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
555
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
556
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
557
		$match = false;
558
		foreach($a_gateways as $gateway) {
559
			if(in_array($_POST['gateway'], $gateway)) {
560
				$match = true;
561
			}
562
		}
563
		foreach($a_gateways as $gateway) {
564
			if(in_array($_POST['gatewayv6'], $gateway)) {
565
				$match = true;
566
			}
567
		}
568
		if(!$match) {
569
			$input_errors[] = gettext("A valid gateway must be specified.");
570
		}
571
	}
572
	if (($_POST['provider'] && !is_domain($_POST['provider'])))
573
		$input_errors[] = gettext("The service name contains invalid characters.");
574
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
575
		$input_errors[] = gettext("The idle timeout value must be an integer.");
576
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
577
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23)
578
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
579
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
580
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59)
581
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
582
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate'])))
583
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
584
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local'])))
585
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
586
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet'])))
587
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
588
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface])))
589
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
590
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout']))
591
		$input_errors[] = gettext("The idle timeout value must be an integer.");
592
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])))
593
		$input_errors[] = gettext("A valid MAC address must be specified.");
594
	if ($_POST['mtu'] && ($_POST['mtu'] < 576))
595
		$input_errors[] = gettext("The MTU must be greater than 576 bytes.");
596
	if ($_POST['mss'] && ($_POST['mss'] < 576))
597
		$input_errors[] = gettext("The MSS must be greater than 576 bytes.");
598
	/* Wireless interface? */
599
	if (isset($wancfg['wireless'])) {
600
		$reqdfields = array("mode");
601
		$reqdfieldsn = array(gettext("Mode"));
602
		if ($_POST['mode'] == 'hostap') {
603
			$reqdfields[] = "ssid";
604
			$reqdfieldsn[] = gettext("SSID");
605
		}
606
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
607
		check_wireless_mode();
608
		/* loop through keys and enforce size */
609
		for ($i = 1; $i <= 4; $i++) {
610
			if ($_POST['key' . $i]) {
611
				/* 64 bit */
612
				if (strlen($_POST['key' . $i]) == 5)
613
					continue;
614
				if (strlen($_POST['key' . $i]) == 10) {
615
					/* hex key */
616
					if (stristr($_POST['key' . $i], "0x") == false) {
617
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
618
					}
619
					continue;
620
				}
621
				if (strlen($_POST['key' . $i]) == 12) {
622
					/* hex key */
623
					if(stristr($_POST['key' . $i], "0x") == false) {
624
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
625
					}
626
					continue;
627
				}
628
				/* 128 bit */
629
				if (strlen($_POST['key' . $i]) == 13)
630
					continue;
631
				if (strlen($_POST['key' . $i]) == 26) {
632
					/* hex key */
633
					if (stristr($_POST['key' . $i], "0x") == false)
634
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
635
					continue;
636
				}
637
				if(strlen($_POST['key' . $i]) == 28)
638
					continue;
639
				$input_errors[] =  gettext("Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.");
640
				break;
641
			}
642
		}
643

    
644
		if ($_POST['passphrase']) {
645
                	$passlen = strlen($_POST['passphrase']);
646
                	if ($passlen < 8 || $passlen > 64)
647
                        	$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
648
		}
649
	}
650
	if (!$input_errors) {
651
		if ($wancfg['ipaddr'] != $_POST['type']) {
652
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
653
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
654
				unset($a_ppps[$pppid]);
655
			} else if ($wancfg['ipaddrv6'] == "dhcp6") {
656
				$pid = find_dhcp6c_process($wancfg['if']);
657
				if($pid)
658
					posix_kill($pid, SIGTERM);
659
			} else if ($wancfg['ipaddr'] == "dhcp") {
660
				$pid = find_dhclient_process($wancfg['if']);
661
				if($pid)
662
					posix_kill($pid, SIGTERM);
663
			}
664
				
665
		}
666
		$ppp = array();
667
		if ($wancfg['ipaddr'] != "ppp")
668
			unset($wancfg['ipaddr']);
669
		if ($wancfg['ipaddrv6'] != "ppp")
670
			unset($wancfg['ipaddrv6']);
671
		unset($wancfg['subnet']);
672
		unset($wancfg['gateway']);
673
		unset($wancfg['subnetv6']);
674
		unset($wancfg['gatewayv6']);
675
		unset($wancfg['dhcphostname']);
676
		unset($wancfg['dhcp6-duid']);
677
		unset($wancfg['dhcp6-ia-pd-len']);
678
		unset($wancfg['track6-interface']);
679
		unset($wancfg['track6-prefix-id']);		
680
		unset($wancfg['prefix-6rd']);
681
		unset($wancfg['prefix-6rd-v4plen']);
682
		unset($wancfg['gateway-6rd']);
683
		unset($wancfg['pppoe_password']);
684
		unset($wancfg['pptp_username']);
685
		unset($wancfg['pptp_password']);
686
		unset($wancfg['provider']);
687
		unset($wancfg['ondemand']);
688
		unset($wancfg['timeout']);
689
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
690
			unset($wancfg['pppoe']['pppoe-reset-type']);
691
		unset($wancfg['local']);
692
		
693
		unset($wancfg['remote']);
694
		unset($a_ppps[$pppid]['apn']);
695
		unset($a_ppps[$pppid]['phone']);
696
		unset($a_ppps[$pppid]['localip']);
697
		unset($a_ppps[$pppid]['subnet']);
698
		unset($a_ppps[$pppid]['gateway']);
699
		unset($a_ppps[$pppid]['pppoe-reset-type']);
700
		unset($a_ppps[$pppid]['provider']);
701

    
702
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
703
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
704

    
705
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
706
		switch($_POST['type']) {
707
			case "staticv4":
708
				$wancfg['ipaddr'] = $_POST['ipaddr'];
709
				$wancfg['subnet'] = $_POST['subnet'];
710
				if ($_POST['gateway'] != "none") {
711
					$wancfg['gateway'] = $_POST['gateway'];
712
				}
713
				break;
714
			case "dhcp":
715
				$wancfg['ipaddr'] = "dhcp";
716
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
717
				$wancfg['alias-address'] = $_POST['alias-address'];
718
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
719
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
720
				if($gateway_item) {
721
					$a_gateways[] = $gateway_item;
722
				}
723
				break;
724
			case "ppp":
725
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
726
				$a_ppps[$pppid]['type'] = $_POST['type'];
727
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
728
				$a_ppps[$pppid]['ports'] = $_POST['port'];
729
				$a_ppps[$pppid]['username'] = $_POST['username'];
730
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
731
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
732
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
733
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
734
				$wancfg['ipaddr'] = $_POST['type'];
735
				unset($a_ppps[$pppid]['ondemand']);
736
				unset($a_ppps[$pppid]['idletimeout']);
737
				break;
738

    
739
			case "pppoe":
740
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
741
				$a_ppps[$pppid]['type'] = $_POST['type'];
742
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
743
				if (isset($_POST['ppp_port']))
744
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
745
				else
746
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
747
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
748
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
749
				if (!empty($_POST['provider']))
750
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
751
				else
752
					$a_ppps[$pppid]['provider'] = true;
753
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
754
				if (!empty($_POST['pppoe_idletimeout']))
755
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
756
				else
757
					unset($a_ppps[$pppid]['idletimeout']);
758

    
759
				if (!empty($_POST['pppoe-reset-type']))
760
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
761
				else
762
					unset($a_ppps[$pppid]['pppoe-reset-type']);
763
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
764
				$wancfg['ipaddr'] = $_POST['type'];
765
				if($gateway_item) {
766
					$a_gateways[] = $gateway_item;
767
				}
768

    
769
				break;
770
			case "pptp":
771
			case "l2tp":
772
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
773
				$a_ppps[$pppid]['type'] = $_POST['type'];
774
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
775
				if (isset($_POST['ppp_port']))
776
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
777
				else
778
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
779
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
780
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
781
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
782
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
783
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
784
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
785
				if (!empty($_POST['pptp_idletimeout']))
786
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
787
				else
788
					unset($a_ppps[$pppid]['idletimeout']);
789
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
790
				$wancfg['ipaddr'] = $_POST['type'];
791
				if($gateway_item) {
792
					$a_gateways[] = $gateway_item;
793
				}
794
				break;
795
			case "none":
796
				break;
797
		}
798
		switch($_POST['type6']) {
799
			case "staticv6":
800
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
801
				$wancfg['subnetv6'] = $_POST['subnetv6'];
802
				if ($_POST['gatewayv6'] != "none") {
803
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
804
				}
805
				break;
806
			case "slaac":
807
				$wancfg['ipaddrv6'] = "slaac";
808
				break;
809
			case "dhcp6":
810
				$wancfg['ipaddrv6'] = "dhcp6";
811
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
812
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
813
				if($gateway_item) {
814
					$a_gateways[] = $gateway_item;
815
				}
816
				break;
817
			case "6rd":
818
				$wancfg['ipaddrv6'] = "6rd";
819
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
820
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
821
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
822
				if($gateway_item) {
823
					$a_gateways[] = $gateway_item;
824
				}
825
				break;
826
			case "6to4":
827
				$wancfg['ipaddrv6'] = "6to4";
828
				break;
829
			case "track6":
830
				$wancfg['ipaddrv6'] = "track6";
831
				$wancfg['track6-interface'] = $_POST['track6-interface'];
832
				if ($_POST['track6-prefix-id--hex'] === "") {
833
					$wancfg['track6-prefix-id'] = "none";
834
				} else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
835
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
836
				} else {
837
					$wancfg['track6-prefix-id'] = "none";
838
				}
839
				break;
840
			case "none":
841
				break;
842
		}
843
		handle_pppoe_reset($_POST);
844

    
845
		if($_POST['blockpriv'] == "yes") {
846
			$wancfg['blockpriv'] = true;
847
		} else {
848
			unset($wancfg['blockpriv']);
849
		}
850
		if($_POST['blockbogons'] == "yes") {
851
			$wancfg['blockbogons'] = true;
852
		} else {
853
			unset($wancfg['blockbogons']);
854
		}
855
		$wancfg['spoofmac'] = $_POST['spoofmac'];
856
		if (empty($_POST['mtu'])) {
857
			unset($wancfg['mtu']);
858
		} else {
859
			$wancfg['mtu'] = $_POST['mtu'];
860
		}
861
		if (empty($_POST['mss'])) {
862
			unset($wancfg['mss']);
863
		} else {
864
			$wancfg['mss'] = $_POST['mss'];
865
		}
866
		if (empty($_POST['mediaopt'])) {
867
			unset($wancfg['media']);
868
			unset($wancfg['mediaopt']);
869
		} else {
870
			$mediaopts = explode(' ', $_POST['mediaopt']);	
871
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
872
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
873
			else { unset($wancfg['mediaopt']); }
874
		}
875
		if (isset($wancfg['wireless'])) {
876
			handle_wireless_post();
877
		}
878

    
879
		conf_mount_ro();
880
		write_config();
881

    
882
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
883
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
884
		} else {
885
			$toapplylist = array();
886
		}
887
		$toapplylist[$if] = $old_wancfg;
888
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
889

    
890
		mark_subsystem_dirty('interfaces');
891

    
892
		/* regenerate cron settings/crontab file */
893
		configure_cron();
894

    
895
		header("Location: interfaces.php?if={$if}");
896
		exit;
897
	}
898

    
899
} // end if($_POST)
900

    
901
function handle_wireless_post() {
902
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
903
	if (!is_array($wancfg['wireless']))
904
		$wancfg['wireless'] = array();
905
	$wancfg['wireless']['standard'] = $_POST['standard'];
906
	$wancfg['wireless']['mode'] = $_POST['mode'];
907
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
908
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
909
	$wancfg['wireless']['channel'] = $_POST['channel'];
910
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
911
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
912
	$wancfg['wireless']['distance'] = $_POST['distance'];
913
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
914
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
915
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
916
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
917
		foreach($wl_countries_attr as $wl_country) {
918
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
919
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
920
				break;
921
			}
922
		}
923
	}
924
	if (!is_array($wancfg['wireless']['wpa']))
925
		$wancfg['wireless']['wpa'] = array();
926
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
927
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
928
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
929
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
930
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
931
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
932
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
933
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
934
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
935
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
936
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
937
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
938
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
939
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
940
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
941
	
942
	if ($_POST['persistcommonwireless'] == "yes") {
943
		if (!is_array($config['wireless']))
944
			$config['wireless'] = array();
945
		if (!is_array($config['wireless']['interfaces']))
946
			$config['wireless']['interfaces'] = array();
947
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
948
			$config['wireless']['interfaces'][$wlanbaseif] = array();
949
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
950
		unset($config['wireless']['interfaces'][$wlanbaseif]);
951
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
952
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
953
	else if (isset($wancfg['wireless']['diversity']))
954
		unset($wancfg['wireless']['diversity']);
955
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
956
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
957
	else if (isset($wancfg['wireless']['txantenna']))
958
		unset($wancfg['wireless']['txantenna']);
959
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
960
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
961
	else if (isset($wancfg['wireless']['rxantenna']))
962
		unset($wancfg['wireless']['rxantenna']);
963
	if ($_POST['hidessid_enable'] == "yes")
964
		$wancfg['wireless']['hidessid']['enable'] = true;
965
	else if (isset($wancfg['wireless']['hidessid']['enable']))
966
		unset($wancfg['wireless']['hidessid']['enable']);
967
	if ($_POST['mac_acl_enable'] == "yes")
968
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
969
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
970
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
971
	if ($_POST['rsn_preauth'] == "yes")
972
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
973
	else
974
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
975
	if ($_POST['ieee8021x'] == "yes")
976
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
977
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
978
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
979
	if ($_POST['wpa_strict_rekey'] == "yes")
980
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
981
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
982
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
983
	if ($_POST['debug_mode'] == "yes")
984
		$wancfg['wireless']['wpa']['debug_mode'] = true;
985
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
986
		sunset($wancfg['wireless']['wpa']['debug_mode']);
987
	if ($_POST['wpa_enable'] == "yes")
988
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
989
	else if (isset($wancfg['wireless']['wpa']['enable']))
990
		unset($wancfg['wireless']['wpa']['enable']);
991
	if ($_POST['wep_enable'] == "yes") {
992
		if (!is_array($wancfg['wireless']['wep']))
993
			$wancfg['wireless']['wep'] = array();
994
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
995
	} else if (isset($wancfg['wireless']['wep']))
996
		unset($wancfg['wireless']['wep']);
997
	if ($_POST['wme_enable'] == "yes") {
998
		if (!is_array($wancfg['wireless']['wme']))
999
			$wancfg['wireless']['wme'] = array();
1000
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1001
	} else if (isset($wancfg['wireless']['wme']['enable']))
1002
		unset($wancfg['wireless']['wme']['enable']);
1003
	if ($_POST['puremode'] == "11g") {
1004
		if (!is_array($wancfg['wireless']['pureg']))
1005
			$wancfg['wireless']['pureg'] = array();
1006
		$wancfg['wireless']['pureg']['enable'] = true;
1007
	} else if ($_POST['puremode'] == "11n") {
1008
		if (!is_array($wancfg['wireless']['puren']))
1009
			$wancfg['wireless']['puren'] = array();
1010
		$wancfg['wireless']['puren']['enable'] = true;
1011
	} else {
1012
		if (isset($wancfg['wireless']['pureg']))
1013
			unset($wancfg['wireless']['pureg']);
1014
		if (isset($wancfg['wireless']['puren']))
1015
			unset($wancfg['wireless']['puren']);
1016
	}
1017
	if ($_POST['apbridge_enable'] == "yes") {
1018
		if (!is_array($wancfg['wireless']['apbridge']))
1019
			$wancfg['wireless']['apbridge'] = array();
1020
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1021
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
1022
		unset($wancfg['wireless']['apbridge']['enable']);
1023
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1024
		if (!is_array($wancfg['wireless']['turbo']))
1025
			$wancfg['wireless']['turbo'] = array();
1026
		$wancfg['wireless']['turbo']['enable'] = true;
1027
	} else if (isset($wancfg['wireless']['turbo']['enable']))
1028
		unset($wancfg['wireless']['turbo']['enable']);
1029
	$wancfg['wireless']['wep']['key'] = array();
1030
	for ($i = 1; $i <= 4; $i++) {
1031
		if ($_POST['key' . $i]) {
1032
			$newkey = array();
1033
			$newkey['value'] = $_POST['key' . $i];
1034
			if ($_POST['txkey'] == $i)
1035
				$newkey['txkey'] = true;
1036
			$wancfg['wireless']['wep']['key'][] = $newkey;
1037
		}
1038
	}
1039
	interface_sync_wireless_clones($wancfg, true);
1040
}
1041

    
1042
function check_wireless_mode() {
1043
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1044

    
1045
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1046
		return;
1047

    
1048
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1049
		$clone_count = 1;
1050
	else
1051
		$clone_count = 0;
1052
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1053
		foreach ($config['wireless']['clone'] as $clone) {
1054
			if ($clone['if'] == $wlanbaseif)
1055
				$clone_count++;
1056
		}
1057
	}
1058
	if ($clone_count > 1) {
1059
		$old_wireless_mode = $wancfg['wireless']['mode'];
1060
		$wancfg['wireless']['mode'] = $_POST['mode'];
1061
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1062
			$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']]);
1063
		} else {
1064
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
1065
		}
1066
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1067
	}
1068
}
1069

    
1070
// Find all possible media options for the interface
1071
$mediaopts_list = array();
1072
$intrealname = $config['interfaces'][$if]['if'];
1073
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1074
foreach ($mediaopts as $mediaopt){
1075
	preg_match("/media (.*)/", $mediaopt, $matches);
1076
 	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1077
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1078
 		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1079
	}else{
1080
		// there is only media like "media 1000baseT"
1081
		array_push($mediaopts_list, $matches[1]);
1082
	}
1083
}
1084

    
1085
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1086
$shortcut_section = "interfaces";
1087

    
1088
$closehead = false;
1089
include("head.inc");
1090
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1091
$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"));
1092

    
1093
?>
1094

    
1095
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
1096
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1097
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1098
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1099
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1100

    
1101
<script type="text/javascript">
1102
	function updateType(t) {
1103
		switch(t) {
1104
			case "none": {
1105
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1106
				break;
1107
			}
1108
			case "staticv4": {
1109
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1110
				break;
1111
			}
1112
			case "dhcp": {
1113
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1114
				break;
1115
			}
1116
			case "ppp": {
1117
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1118
				country_list();
1119
				break;
1120
			}
1121
			case "pppoe": {
1122
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1123
				break;
1124
			}
1125
			case "l2tp":
1126
			case "pptp": {
1127
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1128
				jQuery('#pptp').show();
1129
				break;
1130
			}
1131
		}
1132
		if (t != "l2tp" && t != "pptp")
1133
			jQuery('#'+t).show();
1134
	}
1135
	function updateTypeSix(t) {
1136
		switch(t) {
1137
			case "none": {
1138
				jQuery('#staticv6, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1139
				break;
1140
			}
1141
			case "staticv6": {
1142
				jQuery('#none, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1143
				break;
1144
			}
1145
			case "slaac": {
1146
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #dhcp6').hide();
1147
				break;
1148
			}
1149
			case "dhcp6": {
1150
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #slaac').hide();
1151
				break;
1152
			}
1153
			case "6rd": {
1154
				jQuery('#none, #dhcp6, #staticv6, #6to4, #track6, #slaac').hide();
1155
				break;
1156
			}
1157
			case "6to4": {
1158
				jQuery('#none, #dhcp6, #staticv6, #6rd, #track6, #slaac').hide();
1159
				break;
1160
			}
1161
			case "track6": {
1162
				jQuery('#none, #dhcp6, #staticv6, #6rd, #6to4, #slaac').hide();
1163
				break;
1164
			}
1165
		}
1166
		if (t != "l2tp" && t != "pptp")
1167
			jQuery('#'+t).show();
1168
	}
1169

    
1170
	function show_allcfg(obj) {
1171
		if (obj.checked)
1172
			jQuery('#allcfg').show();
1173
		else
1174
			jQuery('#allcfg').hide();
1175
	}
1176

    
1177
	function show_reset_settings(reset_type) {
1178
		if (reset_type == 'preset') {
1179
			jQuery('#pppoepresetwrap').show();
1180
			jQuery('#pppoecustomwrap').hide();
1181
		}
1182
		else if (reset_type == 'custom') {
1183
			jQuery('#pppoecustomwrap').show();
1184
			jQuery('#pppoepresetwrap').hide();
1185
		} else {
1186
			jQuery('#pppoecustomwrap').hide();
1187
			jQuery('#pppoepresetwrap').hide();
1188
		}
1189
	}
1190
	function show_mon_config() {
1191
		jQuery("#showmonbox").html('');
1192
		jQuery('#showmon').css('display','block');
1193
	}
1194

    
1195
	function openwindow(url) {
1196
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1197
		if (oWin==null || typeof(oWin)=="undefined")
1198
			return false;
1199
		else
1200
			return true;
1201
	}
1202
	function country_list() {
1203
		jQuery('#country').children().remove();
1204
		jQuery('#provider').children().remove();
1205
		jQuery('#providerplan').children().remove();
1206
		jQuery.ajax("getserviceproviders.php",{
1207
			success: function(response) {
1208
				var responseTextArr = response.split("\n");
1209
				responseTextArr.sort();
1210
				responseTextArr.each( function(value) {
1211
					var option = new Element('option');
1212
					country = value.split(":");
1213
					option.text = country[0];
1214
					option.value = country[1];
1215
					jQuery('#country').append(option);
1216
				});
1217
			}
1218
		});
1219
		jQuery('#trcountry').css('display',"table-row");
1220
	}
1221

    
1222
	function providers_list() {
1223
		jQuery('#provider').children().remove();
1224
		jQuery('#providerplan').children().remove();
1225
		jQuery.ajax("getserviceproviders.php",{
1226
			type: 'post',
1227
			data: {country : jQuery('#country').val()},
1228
			success: function(response) {
1229
				var responseTextArr = response.split("\n");
1230
				responseTextArr.sort();
1231
				responseTextArr.each( function(value) {
1232
					var option = new Element('option');
1233
					option.text = value;
1234
					option.value = value;
1235
					jQuery('#provider').append(option);
1236
				});
1237
			}
1238
		});
1239
		jQuery('#trprovider').css("display","table-row");
1240
		jQuery('#trproviderplan').css("display","none");
1241
	}
1242

    
1243
	function providerplan_list() {
1244
		jQuery('#providerplan').children().remove();
1245
		jQuery('#providerplan').append( new Element('option') );
1246
		jQuery.ajax("getserviceproviders.php",{
1247
			type: 'post',
1248
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1249
			success: function(response) {
1250
				var responseTextArr = response.split("\n");
1251
				responseTextArr.sort();
1252
				responseTextArr.each( function(value) {
1253
					if(value != "") {
1254
						providerplan = value.split(":");
1255

    
1256
						var option = new Element('option');
1257
						option.text = providerplan[0] + " - " + providerplan[1];
1258
						option.value = providerplan[1];
1259
						jQuery('#providerplan').append(option);
1260
					}
1261
				});
1262
			}
1263
		});
1264
		jQuery('#trproviderplan').css("display","table-row");
1265
	}
1266

    
1267
	function prefill_provider() {
1268
		jQuery.ajax("getserviceproviders.php",{
1269
			type: 'post',
1270
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
1271
			success: function(data,textStatus,response) {
1272
				var xmldoc = response.responseXML;
1273
				var provider = xmldoc.getElementsByTagName('connection')[0];
1274
				jQuery('#username').val('');
1275
				jQuery('#password').val('');
1276
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1277
					jQuery('#phone').val('#777');
1278
					jQuery('#apn').val('');
1279
				} else {
1280
					jQuery('#phone').val('*99#');
1281
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1282
				}
1283
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1284
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1285
				jQuery('#username').val(username);
1286
				jQuery('#password').val(password);
1287
			}
1288
		});
1289
	}
1290

    
1291
</script>
1292
</head>
1293
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1294
	<?php include("fbegin.inc"); ?>
1295
	<form action="interfaces.php" method="post" name="iform" id="iform">
1296
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1297
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1298
		<?php print_info_box_np(sprintf(gettext("The %s configuration has been changed."),$wancfg['descr'])."<p>".gettext("You must apply the changes in order for them to take effect.")."<p>".gettext("Don't forget to adjust the DHCP Server range if needed after applying."));?><br />
1299
		<?php endif; ?>
1300
		<?php if ($savemsg) print_info_box($savemsg); ?>
1301
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
1302
			<tr>
1303
				<td id="mainarea">
1304
					<div class="tabcont">
1305
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1306
						<tr>
1307
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1308
						</tr>
1309
						<tr>
1310
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1311
							<td width="78%" class="vtable">
1312
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked"; ?> onClick="show_allcfg(this);">
1313
							<strong><?=gettext("Enable Interface"); ?></strong>
1314
							</td>
1315
						</tr>
1316
					</table>
1317
					<div style="display:none;" name="allcfg" id="allcfg">
1318
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1319
						<tr>
1320
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1321
							<td width="78%" class="vtable">
1322
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
1323
								<br><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1324
							</td>
1325
						</tr>
1326
						<tr>
1327
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1328
							<td class="vtable">
1329
								<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
1330
								<?php
1331
									foreach ($types4 as $key => $opt) {
1332
										echo "<option onClick=\"updateType('{$key}');\"";
1333
										if ($key == $pconfig['type'])
1334
											echo " selected";
1335
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1336
										echo "</option>";
1337
									}
1338
								?>
1339
								</select>
1340
							</td>
1341
						</tr>
1342
						<tr>
1343
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1344
							<td class="vtable">
1345
								<select name="type6" onChange="updateTypeSix(this.value);" class="formselect" id="type6">
1346
								<?php
1347
									foreach ($types6 as $key => $opt) {
1348
										echo "<option onClick=\"updateTypeSix('{$key}');\"";
1349
										if ($key == $pconfig['type6'])
1350
											echo " selected";
1351
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1352
										echo "</option>";
1353
									}
1354
								?>
1355
								</select>
1356
							</td>
1357
						</tr>
1358
						<tr>
1359
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1360
							<td class="vtable">
1361
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
1362
								<?php
1363
									$ip = getenv('REMOTE_ADDR');
1364
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1365
									$mac = str_replace("\n","",$mac);
1366
									if($mac):
1367
								?>
1368
									<a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1369
								<?php endif; ?>
1370
								<br>
1371
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1372
								"address of this interface"); ?><br>
1373
								<?=gettext("(may be required with some cable connections)"); ?><br>
1374
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1375
								"or leave blank"); ?>
1376
							</td>
1377
						</tr>
1378
						<tr>
1379
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1380
							<td class="vtable">
1381
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
1382
								<br>
1383
								<?=gettext("If you leave this field blank, the adapter's default MTU will " .
1384
								"be used. This is typically 1500 bytes but can vary in some circumstances."); ?>
1385
							</td>
1386
						</tr>
1387
						<tr>
1388
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1389
							<td class="vtable">
1390
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>">
1391
								<br>
1392
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1393
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1394
								"header size) will be in effect."); ?>
1395
							</td>
1396
						</tr>
1397
						<?php 
1398
						if (count($mediaopts_list) > 0){
1399
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1400
						echo "<tr>";
1401
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1402
							echo '<td class="vtable">';
1403
                                			echo '<div id="showadvmediabox"';
1404
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1405
								else echo '>';
1406
								echo '<input type="button" onClick="show_advanced_media()" value="' . gettext("Advanced") . '"></input> - ' . gettext("Show advanced option");
1407
							echo "</div>";
1408
							echo '<div id="showmediaadv" ';
1409
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1410
							else echo '>';
1411
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1412
								print "<option value=\"\">Default (no preference, typically autoselect)</option>";
1413
								print "<option value=\"\">------- Media Supported by this interface -------</option>";
1414
								foreach($mediaopts_list as $mediaopt){
1415
									if ($mediaopt != rtrim($mediaopt_from_config)){
1416
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1417
									} else {
1418
										print "<option value=\"$mediaopt\" selected>" . gettext("$mediaopt") . "</option>";
1419
									}
1420
								}
1421
								echo '</select><br>';
1422
								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.");
1423
						echo '</div>';
1424
							echo '</td>';
1425
						echo '</tr>';
1426
						}
1427
						?>
1428
						<tr>
1429
							<td colspan="2" valign="top" height="16"></td>
1430
						</tr>
1431
						<tr style="display:none;" name="none" id="none">
1432
						</tr>
1433
						<tr style="display:none;" name="staticv4" id="staticv4">
1434
							<td colspan="2" style="padding:0px;">
1435
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1436
									<tr>
1437
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1438
									</tr>
1439
									<tr>
1440
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1441
										<td width="78%" class="vtable">
1442
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
1443
											/
1444
											<select name="subnet" class="formselect" id="subnet">
1445
												<?php
1446
												for ($i = 32; $i > 0; $i--) {
1447
													if($i <> 31) {
1448
														echo "<option value=\"{$i}\" ";
1449
														if ($i == $pconfig['subnet']) echo "selected";
1450
														echo ">" . $i . "</option>";
1451
													}
1452
												}
1453
												?>
1454
											</select>
1455
										</td>
1456
									</tr>
1457
									<tr>
1458
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway"); ?></td>
1459
										<td width="78%" class="vtable">
1460
											<select name="gateway" class="formselect" id="gateway">
1461
												<option value="none" selected><?=gettext("None"); ?></option>
1462
													<?php
1463
													if(count($a_gateways) > 0) {
1464
														foreach ($a_gateways as $gateway) {
1465
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1466
													?>
1467
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
1468
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1469
															</option>
1470
													<?php
1471
															}
1472
														}
1473
													}
1474
													?>
1475
											</select>
1476
											- or  <strong><a OnClick="show_add_gateway();" href="#"><?=gettext("add a new one."); ?></a></strong>
1477
											<br/>
1478
											<div id='addgwbox'>
1479
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add one using the link above"); ?>
1480
											</div>
1481
											<div id='notebox'>
1482
											</div>
1483
											<div id="status">
1484
											</div>
1485
											<div style="display:none" id="addgateway" name="addgateway">
1486
												<p>
1487
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1488
													<tr>
1489
														<td>
1490
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1491
																<tr><td>&nbsp;</td>
1492
																<tr>
1493
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1494
																</tr>
1495
																<tr><td>&nbsp;</td>
1496
																<?php
1497
																if($if == "wan" || $if == "WAN")
1498
																	$checked = " CHECKED";
1499
																?>
1500
																<tr>
1501
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
1502
																</tr>
1503
																<tr>
1504
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td>
1505
																</tr>
1506
																<tr>
1507
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></td><td><input id="gatewayip" name="gatewayip"></td>
1508
																</tr>
1509
																<tr>
1510
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1511
																</tr>
1512
																<tr><td>&nbsp;</td>
1513
																<tr>
1514
																	<td>&nbsp;</td>
1515
																	<td>
1516
																		<center>
1517
																			<div id='savebuttondiv'>
1518

    
1519

    
1520
																				<input id="gwsave" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave();'>
1521
																				<input id="gwcancel" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway();'>
1522
																			</div>
1523
																		</center>
1524
																	</td>
1525
																</tr>
1526
																<tr><td>&nbsp;</td></tr>
1527
															</table>
1528
														</td>
1529
													</tr>
1530
												</table>
1531
												<p/>
1532
											</div>
1533
										</td>
1534
									</tr>
1535
								</table>
1536
							</td>
1537
						</tr>
1538
						<tr style="display:none;" name="staticv6" id="staticv6">
1539
							<td colspan="2" style="padding:0px;">
1540
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1541
									<tr>
1542
										<td colspan="2" valign="top">&nbsp;</td>
1543
									</tr>
1544
									<tr>
1545
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1546
									</tr>
1547
									<tr>
1548
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1549
										<td width="78%" class="vtable">
1550
											<input name="ipaddrv6" type="text" class="formfld unknown ipv4v6" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>">
1551
											/
1552
											<select name="subnetv6" class="formselect ipv4v6" id="subnetv6">
1553
												<?php
1554
												for ($i = 128; $i > 0; $i--) {
1555
													if($i <> 127) {
1556
														echo "<option value=\"{$i}\" ";
1557
														if ($i == $pconfig['subnetv6']) echo "selected";
1558
														echo ">" . $i . "</option>";
1559
													}
1560
												}
1561
												?>
1562
											</select>
1563
										</td>
1564
									</tr>
1565
									<tr>
1566
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway IPv6"); ?></td>
1567
										<td width="78%" class="vtable">
1568
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1569
												<option value="none" selected><?=gettext("None"); ?></option>
1570
													<?php
1571
													if(count($a_gateways) > 0) {
1572
														foreach ($a_gateways as $gateway) {
1573
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1574
													?>
1575
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected"; ?>>
1576
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1577
															</option>
1578
													<?php
1579
															}
1580
														}
1581
													}
1582
													?>
1583
											</select>
1584
											- or <strong><a OnClick="show_add_gateway_v6();" href="#"><?=gettext("add a new one."); ?></a></strong>
1585
											<br/>
1586
											<div id='addgwboxv6'>
1587
											<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above"); ?>
1588
											</div>
1589
											<div id='noteboxv6'>
1590
											</div>
1591
											<div id="statusv6">
1592
											</div>
1593
											<div style="display:none" id="addgatewayv6" name="addgatewayv6">
1594
												<p>
1595
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1596
													<tr>
1597
														<td>
1598
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1599
																<tr><td>&nbsp;</td>
1600
																<tr>
1601
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1602
																</tr>
1603
																<tr><td>&nbsp;</td>
1604
																<?php
1605
																if($if == "wan" || $if == "WAN")
1606
																	$checked = " CHECKED";
1607
																?>
1608
																<tr>
1609
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?>></td>
1610
																</tr>
1611
																<tr>
1612
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>"></td>
1613
																</tr>
1614
																<tr>
1615
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></td><td><input id="gatewayipv6" name="gatewayipv6"></td>
1616
																</tr>
1617
																<tr>
1618
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescrv6" name="gatewaydescrv6"></td>
1619
																</tr>
1620
																<tr><td>&nbsp;</td>
1621
																<tr>
1622
																	<td>&nbsp;</td>
1623
																	<td>
1624
																		<center>
1625
																			<div id='savebuttondivv6'>
1626
																				<input id="gwsavev6" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave_v6();'>
1627
																				<input id="gwcancelv6" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway_v6();'>
1628
																			</div>
1629
																		</center>
1630
																	</td>
1631
																</tr>
1632
																<tr><td>&nbsp;</td></tr>
1633
															</table>
1634
														</td>
1635
													</tr>
1636
												</table>
1637
												<p/>
1638
											</div>
1639
										</td>
1640
									</tr>
1641
								</table>
1642
							</td>
1643
						</tr>
1644
						<tr style="display:none;" name="dhcp" id="dhcp">
1645
							<td colspan="2" style="padding: 0px;">
1646
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1647
									<tr>
1648
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration"); ?></td>
1649
									</tr>
1650
									<!-- Uncomment to expose DHCP+ in GUI
1651
									<tr>
1652
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1653
										<td width="78%" class="vtable">
1654
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked"; ?> >
1655
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1656
										<br/>
1657
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
1658
										</td>
1659
									</tr>
1660
									-->
1661
									<tr>
1662
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1663
										<td width="78%" class="vtable">
1664
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1665
											<br>
1666
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1667
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1668
											"this (for client identification)."); ?>
1669
										</td>
1670
									</tr>
1671
									<tr>
1672
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
1673
										<td width="78%" class="vtable">
1674
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
1675
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1676
												<?php
1677
												for ($i = 32; $i > 0; $i--) {
1678
													if($i <> 31) {
1679
														echo "<option value=\"{$i}\" ";
1680
														if ($i == $pconfig['alias-subnet']) echo "selected";
1681
														echo ">" . $i . "</option>";
1682
													}
1683
												}
1684
												?>
1685
											</select>
1686
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
1687
											"DHCP client."); ?>
1688
										</td>
1689
									</tr>
1690
								</table>
1691
							</td>
1692
						</tr>
1693
						<tr style="display:none;" name="dhcp6" id="dhcp6">
1694
							<td colspan="2" style="padding: 0px;">
1695
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1696
									<tr>
1697
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration"); ?></td>
1698
									</tr>
1699
									<!--- Leave commented out for now
1700
									<tr>
1701
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
1702
										<td width="78%" class="vtable">
1703
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>">
1704
											<br>
1705
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
1706
											"when requesting a DHCPv6 lease."); ?><br />
1707
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
1708
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
1709
												}
1710
												printf(gettext("The current DUID is: '%s'"),$current_duid);
1711
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
1712
											?>
1713
										</td>
1714
									</tr>
1715
									-->
1716
									<tr>
1717
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
1718
										<td width="78%" class="vtable">
1719
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
1720
												<?php
1721
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
1722
												foreach($sizes as $bits => $length) {
1723
													echo "<option value=\"{$bits}\" ";
1724
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected";
1725
													echo ">" . $length . "</option>";
1726
												}
1727
												?>
1728
											</select>
1729
											<br>
1730
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
1731
										</td>
1732
									</tr>
1733
								</table>
1734
							</td>
1735
						</tr>
1736
						<tr style="display:none;" name="6rd" id="6rd">
1737
							<td colspan="2" style="padding: 0px;">
1738
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1739
									<tr>
1740
										<td colspan="2" valign="top" class="listtopic"><?=gettext("6RD Rapid Deployment"); ?></td>
1741
									</tr>
1742
									<tr>
1743
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD prefix"); ?></td>
1744
										<td width="78%" class="vtable">
1745
											<input name="prefix-6rd" type="text" class="formfld unknown" id="prefix-6rd" size="40" value="<?=htmlspecialchars($pconfig['prefix-6rd']);?>">
1746
											<br>
1747
											<?=gettext("The value in this field is the 6RD IPv6 prefix assigned by your ISP. e.g. '2001:db8::/32'") ?><br />
1748
										</td>
1749
									</tr>
1750
									<tr>
1751
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD Border Relay"); ?></td>
1752
										<td width="78%" class="vtable">
1753
											<input name="gateway-6rd" type="text" class="formfld unknown" id="gateway-6rd" size="40" value="<?=htmlspecialchars($pconfig['gateway-6rd']);?>">
1754
											<br>
1755
											<?=gettext("The value in this field is 6RD IPv4 gateway address assigned by your ISP") ?><br />
1756
										</td>
1757
									</tr>
1758
									<tr>
1759
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD IPv4 Prefix length"); ?></td>
1760
										<td width="78%" class="vtable">
1761
											<select name="prefix-6rd-v4plen" class="formselect" id="prefix-6rd-v4plen">
1762
												<?php
1763
												for ($i = 0; $i < 32; $i++) {
1764
													echo "<option value=\"{$i}\" ";
1765
													if (is_numeric($pconfig['prefix-6rd-v4plen']) && ($i == $pconfig['prefix-6rd-v4plen'])) echo "selected";
1766
													echo ">" . $i . " bits</option>";
1767
												}
1768
												?>
1769
											</select>
1770
											<br>
1771
											<?=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."); ?>
1772
										</td>
1773
									</tr>
1774
								</table>
1775
							</td>
1776
						</tr>
1777
						<tr style="display:none;" name="track6" id="track6">
1778
							<td colspan="2" style="padding: 0px;">
1779
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1780
									<tr>
1781
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
1782
									</tr>
1783
									<tr>
1784
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
1785
										<td width="78%" class="vtable">
1786
										<select name='track6-interface' class='formselect' >
1787
										<?php 
1788
											$interfaces = get_configured_interface_with_descr(false, true);
1789
											$dynv6ifs = array();
1790
											foreach ($interfaces as $iface => $ifacename) {
1791
												switch($config['interfaces'][$iface]['ipaddrv6']) {
1792
													case "6to4":
1793
													case "6rd":
1794
													case "dhcp6":
1795
														$dynv6ifs[$iface] = $ifacename;
1796
														break;
1797
													default:
1798
														continue;
1799
												}
1800
											}
1801
											foreach($dynv6ifs as $iface => $ifacename) {
1802
												echo "<option value=\"{$iface}\"";
1803
												if ($iface == $pconfig['track6-interface'])
1804
													echo " selected";
1805
												echo ">" . htmlspecialchars($ifacename) . "</option>";
1806
											}
1807
										  ?>
1808
										</select> <br>
1809
											<br>
1810
											<?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
1811
										</td>
1812
									</tr>
1813
									<tr>
1814
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
1815
										<td width="78%" class="vtable">
1816
											<?php
1817
												if ($pconfig['track6-prefix-id'] == "none" || $pconfig['track6-prefix-id'] == "") {
1818
													$track6_prefix_id_hex = "";
1819
												} else {
1820
													$track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
1821
												}
1822
											?>
1823
											<input name="track6-prefix-id--hex" type="text" class="formfld unknown" id="track6-prefix-id--hex" size="8" value="<?= $track6_prefix_id_hex ?>" />
1824
											<br />
1825
											<?= gettext("The value in this field is the (Delegated) IPv6 prefix id. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
1826
											<br />
1827
											<?= sprintf(gettext("Enter a <b>hexadecimal</b> value between %x and %x here, or leave blank."), 0, $ipv6_num_prefix_ids - 1); ?>
1828
										</td>
1829
									</tr>
1830
										</td>
1831
									</tr>
1832
								</table>
1833
							</td>
1834
						</tr>
1835
						<tr style="display:none;" name="ppp" id="ppp">
1836
							<td colspan="2" style="padding: 0px;">
1837
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1838
									<tr>
1839
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
1840
									</tr>
1841
									<tr name="ppp_provider" id="ppp_provider">
1842
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
1843
										<td width="78%" class="vtable">
1844
											<table border="0" cellpadding="0" cellspacing="0">
1845
												<tr id="trcountry">
1846
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
1847
													<td>
1848
														<select class="formselect" name="country" id="country" onChange="providers_list()">
1849
															<option></option>
1850
														</select>
1851
													</td>
1852
												</tr>
1853
												<tr id="trprovider" style="display:none">
1854
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
1855
													<td>
1856
														<select class="formselect" name="provider" id="provider" onChange="providerplan_list()">
1857
															<option></option>
1858
														</select>
1859
													</td>
1860
												</tr>
1861
												<tr id="trproviderplan" style="display:none">
1862
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
1863
													<td>
1864
														<select class="formselect" name="providerplan" id="providerplan" onChange="prefill_provider()">
1865
															<option></option>
1866
														</select>
1867
													</td>
1868
												</tr>
1869
											</table>
1870
											<br/><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
1871
										</td>
1872
									</tr>
1873
									<tr>
1874
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
1875
										<td width="78%" class="vtable">
1876
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
1877
										</td>
1878
									</tr>
1879
									<tr>
1880
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
1881
										<td width="78%" class="vtable">
1882
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
1883
										</td>
1884
									</tr>
1885
									<tr name="phone_num" id="phone_num">
1886
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
1887
										<td width="78%" class="vtable">
1888
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>">
1889
										</td>
1890
									</tr>
1891
									<tr name="apn_" id="apn_">
1892
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
1893
										<td width="78%" class="vtable">
1894
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
1895
										</td>
1896
									</tr>
1897
									<tr name="interface" id="interface" >
1898
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
1899
										<td width="78%" class="vtable">
1900
											<select name="port" id="port" class="formselect">
1901
											<?php
1902
												$portlist = glob("/dev/cua*");
1903
												$modems = glob("/dev/modem*");
1904
												$portlist = array_merge($portlist, $modems);
1905
												foreach ($portlist as $port) {
1906
													if(preg_match("/\.(lock|init)$/", $port))
1907
														continue;
1908
													echo "<option value=\"".trim($port)."\"";
1909
													if ($pconfig['port'] == $port)
1910
														echo "selected";
1911
													echo ">{$port}</option>";
1912
												}?>
1913
											</select>
1914
										</td>
1915
									</tr>
1916
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
1917
										<?php if (isset($pconfig['pppid'])): ?>
1918
											<td width="78%" class="vtable">
1919
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
1920
											<?=gettext("to edit PPP configuration."); ?>
1921
											</td>
1922
										<?php else: ?>
1923
											<td width="78%" class="vtable">
1924
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
1925
											<?=gettext("to create a PPP configuration."); ?>
1926
											</td>
1927
										<?php endif; ?>
1928
									</tr>
1929
								</table>
1930
							</td>
1931
						</tr>
1932
						<tr style="display:none;" name="pppoe" id="pppoe">
1933
							<td colspan="2" style="padding:0px;">
1934
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1935
									<tr>
1936
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
1937
									</tr>
1938
									<tr>
1939
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
1940
										<td width="78%" class="vtable">
1941
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
1942
										</td>
1943
									</tr>
1944
									<tr>
1945
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
1946
										<td width="78%" class="vtable">
1947
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
1948
										</td>
1949
									</tr>
1950
									<tr>
1951
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
1952
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
1953
											<br> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
1954
										</td>
1955
									</tr>
1956
									<tr>
1957
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
1958
										<td width="78%" class="vtable">
1959
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>>
1960
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
1961
											<?=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."); ?>
1962
										</td>
1963
									</tr>
1964
									<tr>
1965
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
1966
										<td width="78%" class="vtable">
1967
											<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."); ?>
1968
										</td>
1969
									</tr>
1970
									<tr>
1971
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
1972
										<td width="78%" class="vtable">
1973
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
1974
												<tr>
1975
													<td align="left" valign="top">
1976
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
1977
														<select valign="top" id="reset_type" name="pppoe-reset-type" class="formselect" onChange="show_reset_settings(this.value);">
1978
															<option value = ""><?=gettext("Disabled"); ?></option>
1979
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?=gettext("Custom"); ?></option>
1980
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?=gettext("Pre-Set"); ?></option>
1981
														</select> <?=gettext("Select a reset timing type"); ?>
1982
														</p>
1983
														<?php if ($pconfig['pppoe_pr_custom']): ?>
1984
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
1985
														<?php else: ?>
1986
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
1987
														<?php endif; ?>
1988
														<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" />
1989
														<?=gettext("hour (0-23)"); ?><br />
1990
														<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" />
1991
														<?=gettext("minute (0-59)"); ?><br />
1992
														<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']);?>" />
1993
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
1994
														<br />&nbsp;<br />
1995
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
1996
														<?=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."); ?>
1997
														</p>
1998
														<?php if ($pconfig['pppoe_pr_preset']): ?>
1999
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
2000
														<?php else: ?>
2001
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
2002
														<?php endif; ?>
2003
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
2004
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
2005
														<br />
2006
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
2007
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
2008
														<br />
2009
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
2010
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
2011
														<br />
2012
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
2013
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
2014
														</p>
2015
													</td>
2016
												</tr>
2017
											</table>
2018
										</td>
2019
									</tr>
2020

    
2021
									<tr>
2022
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
2023
										<?php if (isset($pconfig['pppid'])): ?>
2024
											<td width="78%" class="vtable">
2025
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2026
											<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
2027
											</td>
2028
										<?php else: ?>
2029
											<td width="78%" class="vtable">
2030
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2031
											<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
2032
											</td>
2033
										<?php endif; ?>
2034
									</tr>
2035
								</table>
2036
							</td>
2037
						</tr>
2038
						<tr style="display:none;" name="pptp" id="pptp">
2039
							<td colspan="2" style="padding:0px;">
2040
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
2041
									<tr>
2042
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP/L2TP configuration"); ?></td>
2043
									</tr>
2044
									<tr>
2045
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2046
										<td width="78%" class="vtable">
2047
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
2048
										</td>
2049
									</tr>
2050
									<tr>
2051
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2052
										<td width="78%" class="vtable">
2053
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
2054
										</td>
2055
									</tr>
2056
									<tr>
2057
										<td width="22%" width="100" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
2058
										<td width="78%" class="vtable">
2059
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>">
2060
											/
2061
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
2062
												<?php for ($i = 31; $i > 0; $i--): ?>
2063
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected"; ?>>
2064
														<?=$i;?></option>
2065
												<?php endfor; ?>
2066
											</select>
2067
										</td>
2068
									</tr>
2069
									<tr>
2070
										<td width="22%" width="100" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
2071
										<td width="78%" class="vtable">
2072
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>">
2073
										</td>
2074
									</tr>
2075
									<tr>
2076
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2077
										<td width="78%" class="vtable">
2078
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?>>
2079
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
2080
											<?=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."); ?>
2081
										</td>
2082
									</tr>
2083
									<tr>
2084
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2085
										<td width="78%" class="vtable">
2086
											<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."); ?>
2087
										</td>
2088
									</tr>
2089
									<tr>
2090
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
2091
										<?php if (isset($pconfig['pppid'])): ?>
2092
											<td width="78%" class="vtable">
2093
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
2094
											<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
2095
											</td>
2096
										<?php else: ?>
2097
											<td width="78%" class="vtable">
2098
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
2099
											<?=gettext("for advanced PPTP and L2TP configuration options");?>.
2100
											</td>
2101
										<?php endif; ?>
2102
									</tr>
2103
								</table>
2104
							</td>
2105
						</tr>
2106
						<?php
2107
							/* Wireless interface? */
2108
							if (isset($wancfg['wireless'])):
2109
						?>
2110
						<tr>
2111
							<td colspan="2" valign="top" height="16"></td>
2112
						</tr>
2113
						<tr>
2114
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
2115
						</tr>
2116
						<tr>
2117
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
2118
							<td class="vtable">
2119
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked";?>>
2120
								<br/><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
2121
							</td>
2122
						</tr>
2123
						<tr>
2124
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
2125
							<td class="vtable">
2126
							<select name="standard" class="formselect" id="standard">
2127
								<?php
2128
								foreach($wl_modes as $wl_standard => $wl_channels) {
2129
									echo "<option ";
2130
									if ($pconfig['standard'] == "$wl_standard")
2131
										echo "selected ";
2132
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
2133
								}
2134
								?>
2135
							</select>
2136
							</td>
2137
						</tr>
2138
						<?php if (isset($wl_modes['11g'])): ?>
2139
						<tr>
2140
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
2141
							<td class="vtable">
2142
								<select name="protmode" class="formselect" id="protmode">
2143
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected";?> value="off"><?=gettext("Protection mode off"); ?></option>
2144
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
2145
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
2146
								</select>
2147
								<br/>
2148
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
2149
								<br/>
2150
							</td>
2151
						</tr>
2152
						<?php else: ?>
2153
						<input name="protmode" type="hidden" id="protmode" value="off">
2154
						<?php endif; ?>
2155
						<tr>
2156
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
2157
							<td class="vtable">
2158
								<select name="txpower" class="formselect" id="txpower">
2159
									<?
2160
									for($x = 99; $x > 0; $x--) {
2161
										if($pconfig["txpower"] == $x)
2162
											$SELECTED = " SELECTED";
2163
										else
2164
											$SELECTED = "";
2165
										echo "<option {$SELECTED}>{$x}</option>\n";
2166
									}
2167
									?>
2168
								</select><br/>
2169
								<?=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."); ?>
2170
							</td>
2171
						</tr>
2172
						<tr>
2173
							<td valign="top" class="vncellreq"><?=gettext("Channel"); ?></td>
2174
							<td class="vtable">
2175
								<select name="channel" class="formselect" id="channel">
2176
									<option <?php if ($pconfig['channel'] == 0) echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2177
									<?php
2178
									foreach($wl_modes as $wl_standard => $wl_channels) {
2179
										if($wl_standard == "11g") { $wl_standard = "11b/g"; }
2180
										else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
2181
										else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
2182
										foreach($wl_channels as $wl_channel) {
2183
											echo "<option ";
2184
											if ($pconfig['channel'] == "$wl_channel") {
2185
												echo "selected ";
2186
											}
2187
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
2188
											if(isset($wl_chaninfo[$wl_channel]))
2189
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
2190
											echo "</option>\n";
2191
										}
2192
									}
2193
									?>
2194
								</select>
2195
								<br/>
2196
								<?=gettext("Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)"); ?>
2197
								<br/>
2198
								<?=gettext("Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above."); ?>
2199
							</td>
2200
						</tr>
2201
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2202
						<tr>
2203
							<td valign="top" class="vncell"><?=gettext("Antenna settings"); ?></td>
2204
							<td class="vtable">
2205
								<table border="0" cellpadding="0" cellspacing="0">
2206
									<tr>
2207
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])): ?>
2208
										<td>
2209
											<?=gettext("Diversity"); ?><br/>
2210
											<select name="diversity" class="formselect" id="diversity">
2211
												<option <?php if (!isset($pconfig['diversity'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2212
												<option <?php if ($pconfig['diversity'] === '0') echo "selected"; ?> value="0"><?=gettext("Off"); ?></option>
2213
												<option <?php if ($pconfig['diversity'] === '1') echo "selected"; ?> value="1"><?=gettext("On"); ?></option>
2214
											</select>
2215
										</td>
2216
										<td>&nbsp;&nbsp</td>
2217
										<?php endif; ?>
2218
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])): ?>
2219
										<td>
2220
											<?=gettext("Transmit antenna"); ?><br/>
2221
											<select name="txantenna" class="formselect" id="txantenna">
2222
												<option <?php if (!isset($pconfig['txantenna'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2223
												<option <?php if ($pconfig['txantenna'] === '0') echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2224
												<option <?php if ($pconfig['txantenna'] === '1') echo "selected"; ?> value="1"><?=gettext("#1"); ?></option>
2225
												<option <?php if ($pconfig['txantenna'] === '2') echo "selected"; ?> value="2"><?=gettext("#2"); ?></option>
2226
											</select>
2227
										</td>
2228
										<td>&nbsp;&nbsp</td>
2229
										<?php endif; ?>
2230
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2231
										<td>
2232
											<?=gettext("Receive antenna"); ?><br/>
2233
											<select name="rxantenna" class="formselect" id="rxantenna">
2234
												<option <?php if (!isset($pconfig['rxantenna'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2235
												<option <?php if ($pconfig['rxantenna'] === '0') echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2236
												<option <?php if ($pconfig['rxantenna'] === '1') echo "selected"; ?> value="1"><?=gettext("#1"); ?></option>
2237
												<option <?php if ($pconfig['rxantenna'] === '2') echo "selected"; ?> value="2"><?=gettext("#2"); ?></option>
2238
											</select>
2239
										</td>
2240
										<?php endif; ?>
2241
									</tr>
2242
								</table>
2243
								<br/>
2244
								<?=gettext("Note: The antenna numbers do not always match up with the labels on the card."); ?>
2245
							</td>
2246
						</tr>
2247
						<?php endif; ?>
2248
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])): ?>
2249
						<tr>
2250
							<td valign="top" class="vncell"><?=gettext("Distance setting"); ?></td>
2251
							<td class="vtable">
2252
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>">
2253
								<br/>
2254
								<?=gettext("Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client"); ?><br/>
2255
								<?=gettext("(measured in Meters and works only for Atheros based cards !)"); ?>
2256
							</td>
2257
						</tr>
2258
						<?php endif; ?>
2259
						<tr>
2260
							<td valign="top" class="vncell"><?=gettext("Regulatory settings"); ?></td>
2261
							<td class="vtable">
2262
								<?=gettext("Regulatory domain"); ?><br/>
2263
								<select name="regdomain" class="formselect" id="regdomain">
2264
									<option <?php if (empty($pconfig['regdomain'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2265
									<?php
2266
									foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
2267
										echo "<option ";
2268
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
2269
											echo "selected ";
2270
										}
2271
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
2272
									}
2273
									?>
2274
								</select>
2275
								<br/>
2276
								<?=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."); ?>
2277
								<br/><br/>
2278
								<?=gettext("Country (listed with country code and regulatory domain)"); ?><br/>
2279
								<select name="regcountry" class="formselect" id="regcountry">
2280
									<option <?php if (empty($pconfig['regcountry'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2281
									<?php
2282
									foreach($wl_countries as $wl_country_key => $wl_country) {
2283
										echo "<option ";
2284
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
2285
											echo "selected ";
2286
										}
2287
										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";
2288
									}
2289
									?>
2290
								</select>
2291
								<br/>
2292
								<?=gettext("Note: Any country setting other than \"Default\" will override the regulatory domain setting"); ?>.
2293
								<br/><br/>
2294
								<?=gettext("Location"); ?><br/>
2295
								<select name="reglocation" class="formselect" id="reglocation">
2296
									<option <?php if (empty($pconfig['reglocation'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2297
									<option <?php if ($pconfig['reglocation'] == 'indoor') echo "selected"; ?> value="indoor"><?=gettext("Indoor"); ?></option>
2298
									<option <?php if ($pconfig['reglocation'] == 'outdoor') echo "selected"; ?> value="outdoor"><?=gettext("Outdoor"); ?></option>
2299
									<option <?php if ($pconfig['reglocation'] == 'anywhere') echo "selected"; ?> value="anywhere"><?=gettext("Anywhere"); ?></option>
2300
								</select>
2301
								<br/><br/>
2302
								<?=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."); ?>
2303
								<br/>
2304
								<?=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."); ?>
2305
							</td>
2306
						</tr>
2307
						<tr>
2308
							<td colspan="2" valign="top" height="16"></td>
2309
						</tr>
2310
						<tr>
2311
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Network-specific wireless configuration");?></td>
2312
						</tr>
2313
						<tr>
2314
							<td valign="top" class="vncellreq"><?=gettext("Mode"); ?></td>
2315
							<td class="vtable">
2316
								<select name="mode" class="formselect" id="mode">
2317
									<option <?php if ($pconfig['mode'] == 'bss') echo "selected";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
2318
									<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
2319
									<option <?php if ($pconfig['mode'] == 'hostap') echo "selected";?> value="hostap"><?=gettext("Access Point"); ?></option>
2320
								</select>
2321
							</td>
2322
						</tr>
2323
						<tr>
2324
							<td valign="top" class="vncellreq"><?=gettext("SSID"); ?></td>
2325
							<td class="vtable">
2326
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>">
2327
								<br/>
2328
								<?=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"); ?>
2329
							</td>
2330
						</tr>
2331
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
2332
						<tr>
2333
							<td valign="top" class="vncell"><?=gettext("Minimum wireless standard"); ?></td>
2334
							<td class="vtable">
2335
								<select name="puremode" class="formselect" id="puremode">
2336
									<option <?php if ($pconfig['puremode'] == 'any') echo "selected";?> value="any"><?=gettext("Any"); ?></option>
2337
									<?php if (isset($wl_modes['11g'])): ?>
2338
									<option <?php if ($pconfig['puremode'] == '11g') echo "selected";?> value="11g"><?=gettext("802.11g"); ?></option>
2339
									<?php endif; ?>
2340
									<option <?php if ($pconfig['puremode'] == '11n') echo "selected";?> value="11n"><?=gettext("802.11n"); ?></option>
2341
								</select>
2342
								<br/>
2343
								<?=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)."); ?>
2344
							</td>
2345
						</tr>
2346
						<?php elseif (isset($wl_modes['11g'])): ?>
2347
						<tr>
2348
							<td valign="top" class="vncell"><?=gettext("802.11g only"); ?></td>
2349
							<td class="vtable">
2350
								<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <?php if ($pconfig['puremode'] == '11g') echo "checked";?>>
2351
								<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)."); ?>
2352
							</td>
2353
						</tr>
2354
						<?php endif; ?>
2355
						<tr>
2356
							<td valign="top" class="vncell"><?=gettext("Allow intra-BSS communication"); ?></td>
2357
							<td class="vtable">
2358
								<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <?php if ($pconfig['apbridge_enable']) echo "checked";?>>
2359
								<br/>
2360
								<?=gettext("When operating as an access point, enable this if you want to pass packets between wireless clients directly."); ?>
2361
								<br/>
2362
								<?=gettext("Disabling the internal bridging is useful when traffic is to be processed with packet filtering."); ?>
2363
							</td>
2364
						</tr>
2365
						<tr>
2366
							<td valign="top" class="vncell"><?=gettext("Enable WME"); ?></td>
2367
							<td class="vtable">
2368
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <?php if ($pconfig['wme_enable']) echo "checked";?>>
2369
								<br/><?=gettext("Setting this option will force the card to use WME (wireless QoS)."); ?>
2370
							</td>
2371
						</tr>
2372
						<tr>
2373
							<td valign="top" class="vncell"><?=gettext("Enable Hide SSID"); ?></td>
2374
							<td class="vtable">
2375
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <?php if ($pconfig['hidessid_enable']) echo "checked";?>>
2376
								<br/>
2377
								<?=gettext("Setting this option will force the card to NOT broadcast its SSID"); ?>
2378
								<br/>
2379
								<?=gettext("(this might create problems for some clients)."); ?>
2380
							</td>
2381
						</tr>
2382
						<tr>
2383
							<td valign="top" class="vncell"><?=gettext("WEP"); ?></td>
2384
							<td class="vtable">
2385
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <?php if ($pconfig['wep_enable']) echo "checked"; ?>>
2386
								<strong><?=gettext("Enable WEP"); ?></strong>
2387
								<table border="0" cellspacing="0" cellpadding="0">
2388
									<tr>
2389
										<td>&nbsp;</td>
2390
										<td>&nbsp;</td>
2391
										<td>&nbsp;<?=gettext("TX key"); ?>&nbsp;</td>
2392
									</tr>
2393
									<tr>
2394
										<td><?=gettext("Key 1:"); ?>&nbsp;&nbsp;</td>
2395
										<td>
2396
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>">
2397
										</td>
2398
										<td align="center">
2399
											<input name="txkey" type="radio" value="1" <?php if ($pconfig['txkey'] == 1) echo "checked";?>>
2400
										</td>
2401
									</tr>
2402
									<tr>
2403
										<td><?=gettext("Key 2:"); ?>&nbsp;&nbsp;</td>
2404
										<td>
2405
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>">
2406
										</td>
2407
										<td align="center">
2408
											<input name="txkey" type="radio" value="2" <?php if ($pconfig['txkey'] == 2) echo "checked";?>>
2409
										</td>
2410
									</tr>
2411
									<tr>
2412
										<td><?=gettext("Key 3:"); ?>&nbsp;&nbsp;</td>
2413
										<td>
2414
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>">
2415
										</td>
2416
										<td align="center">
2417
											<input name="txkey" type="radio" value="3" <?php if ($pconfig['txkey'] == 3) echo "checked";?>>
2418
										</td>
2419
									</tr>
2420
									<tr>
2421
										<td><?=gettext("Key 4:"); ?>&nbsp;&nbsp;</td>
2422
										<td>
2423
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>">
2424
										</td>
2425
										<td align="center">
2426
											<input name="txkey" type="radio" value="4" <?php if ($pconfig['txkey'] == 4) echo "checked";?>>
2427
										</td>
2428
									</tr>
2429
								</table>
2430
								<br/>
2431
								<?=gettext("40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'."); ?><br/>
2432
								<?=gettext("104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'."); ?>
2433
							</td>
2434
						</tr>
2435
						<tr>
2436
							<td valign="top" class="vncell"><?=gettext("WPA"); ?></td>
2437
							<td class="vtable">
2438
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <?php if ($pconfig['wpa_enable']) echo "checked"; ?>>
2439
								<strong><?=gettext("Enable WPA"); ?></strong>
2440
								<br/><br/>
2441
								<table border="0" cellspacing="0" cellpadding="0">
2442
									<tr>
2443
										<td>&nbsp;</td>
2444
										<td>&nbsp;<?=gettext("WPA Pre-Shared Key"); ?>&nbsp;</td>
2445
									</tr>
2446
									<tr>
2447
										<td><?=gettext("PSK:"); ?>&nbsp;&nbsp;</td>
2448
										<td>
2449
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>">
2450
										</td>
2451
									</tr>
2452
								</table>
2453
								<br/><?=gettext("Passphrase must be from 8 to 63 characters."); ?>
2454
							</td>
2455
						</tr>
2456
						<tr>
2457
							<td valign="top" class="vncell"><?=gettext("WPA Mode"); ?></td>
2458
							<td class="vtable">
2459
								<select name="wpa_mode" class="formselect" id="wpa_mode">
2460
									<option <?php if ($pconfig['wpa_mode'] == '1') echo "selected";?> value="1"><?=gettext("WPA"); ?></option>
2461
									<option <?php if ($pconfig['wpa_mode'] == '2') echo "selected";?> value="2"><?=gettext("WPA2"); ?></option>
2462
									<option <?php if ($pconfig['wpa_mode'] == '3') echo "selected";?> value="3"><?=gettext("Both"); ?></option>
2463
								</select>
2464
							</td>
2465
						</tr>
2466
						<tr>
2467
							<td valign="top" class="vncell"><?=gettext("WPA Key Management Mode"); ?></td>
2468
							<td class="vtable">
2469
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
2470
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected";?> value="WPA-PSK"><?=gettext("Pre-Shared Key"); ?></option>
2471
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected";?> value="WPA-EAP"><?=gettext("Extensible Authentication Protocol"); ?></option>
2472
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected";?> value="WPA-PSK WPA-EAP"><?=gettext("Both"); ?></option>
2473
								</select>
2474
							</td>
2475
						</tr>
2476
						<tr>
2477
							<td valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
2478
							<td class="vtable">
2479
								<select name="auth_algs" class="formselect" id="auth_algs">
2480
									<option <?php if ($pconfig['auth_algs'] == '1') echo "selected";?> value="1"><?=gettext("Open System Authentication"); ?></option>
2481
									<option <?php if ($pconfig['auth_algs'] == '2') echo "selected";?> value="2"><?=gettext("Shared Key Authentication"); ?></option>
2482
									<option <?php if ($pconfig['auth_algs'] == '3') echo "selected";?> value="3"><?=gettext("Both"); ?></option>
2483
								</select>
2484
								<br/><?=gettext("Note: Shared Key Authentication requires WEP."); ?></br>
2485
							</td>
2486
						</tr>
2487
						<tr>
2488
							<td valign="top" class="vncell"><?=gettext("WPA Pairwise"); ?></td>
2489
							<td class="vtable">
2490
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
2491
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected";?> value="CCMP TKIP"><?=gettext("Both"); ?></option>
2492
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected";?> value="CCMP"><?=gettext("AES (recommended)"); ?></option>
2493
									<option <?php if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected";?> value="TKIP"><?=gettext("TKIP"); ?></option>
2494
								</select>
2495
							</td>
2496
						</tr>
2497
						<tr>
2498
							<td valign="top" class="vncell"><?=gettext("Key Rotation"); ?></td>
2499
							<td class="vtable">
2500
								<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";?>">
2501
								<br/><?=gettext("Allowed values are 1-9999 but should not be longer than Master Key Regeneration time."); ?>
2502
							</td>
2503
						</tr>
2504
						<tr>
2505
							<td valign="top" class="vncell"><?=gettext("Master Key Regeneration"); ?></td>
2506
							<td class="vtable">
2507
								<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";?>">
2508
								<br/><?=gettext("Allowed values are 1-9999 but should not be shorter than Key Rotation time."); ?>
2509
							</td>
2510
						</tr>
2511
						<tr>
2512
							<td valign="top" class="vncell"><?=gettext("Strict Key Regeneration"); ?></td>
2513
							<td class="vtable">
2514
								<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <?php if ($pconfig['wpa_strict_rekey']) echo "checked"; ?>>
2515
								<br/><?=gettext("Setting this option will force the AP to rekey whenever a client disassociates."); ?>
2516
							</td>
2517
						</tr>
2518
						<tr>
2519
							<td valign="top" class="vncell"><?=gettext("Enable IEEE802.1X Authentication"); ?></td>
2520
							<td class="vtable">
2521
								<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <?php if ($pconfig['ieee8021x']) echo "checked";?>>
2522
								<br/><?=gettext("Setting this option will enable 802.1x authentication."); ?>
2523
								<br/><span class="red"><strong><?=gettext("NOTE"); ?>:</strong></span> <?=gettext("this option requires checking the \"Enable WPA box\"."); ?>
2524
							</td>
2525
						</tr>
2526
						<tr>
2527
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server IP Address"); ?></td>
2528
							<td class="vtable">
2529
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>">
2530
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
2531
							</td>
2532
						</tr>
2533
						<tr>
2534
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Port"); ?></td>
2535
							<td class="vtable">
2536
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>">
2537
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
2538
							</td>
2539
						</tr>
2540
						<tr>
2541
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Shared Secret"); ?></td>
2542
							<td class="vtable">
2543
								<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']);?>">
2544
								<br/>
2545
							</td>
2546
						</tr>
2547
						<tr>
2548
					<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server IP Address"); ?></td>
2549
							<td class="vtable">
2550
								<input name="auth_server_addr2" id="auth_server_addr2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr2']);?>">
2551
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
2552
							</td>
2553
						</tr>
2554
						<tr>
2555
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Port"); ?></td>
2556
							<td class="vtable">
2557
								<input name="auth_server_port2" id="auth_server_port2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port2']);?>">
2558
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
2559
							</td>
2560
						</tr>
2561
						<tr>
2562
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Shared Secret"); ?></td>
2563
							<td class="vtable">
2564
								<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']);?>">
2565
								<br/>
2566
							</td>
2567
						</tr>
2568
						<tr>
2569
							<td valign="top" class="vncell">802.1X <?=gettext("Authentication Roaming Preauth"); ?></td>
2570
							<td class="vtable">
2571
								<input name="rsn_preauth" id="rsn_preauth" type="checkbox" class="formfld unknown" size="66" value="yes" <?php if ($pconfig['rsn_preauth']) echo "checked"; ?>>
2572
								<br/>
2573
							</td>
2574
						</tr>
2575
						<?php endif; ?>
2576
						<tr>
2577
							<td colspan="2" valign="top" height="16"></td>
2578
						</tr>
2579
						<tr>
2580
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Private networks"); ?></td>
2581
						</tr>
2582
						<tr>
2583
							<td valign="middle" class="vncell">&nbsp;</td>
2584
							<td class="vtable">
2585
								<a name="rfc1918"></a>
2586
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
2587
								<strong><?=gettext("Block private networks"); ?></strong><br>
2588
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2589
								"for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as"); ?>
2590
								<?=gettext("well as loopback addresses (127/8)."); ?>&nbsp;&nbsp; <?=gettext("You should generally " .
2591
								"leave this option turned on, unless your WAN network lies in such " .
2592
								"a private address space, too."); ?>
2593
							</td>
2594
						</tr>
2595
						<tr>
2596
							<td valign="middle" class="vncell">&nbsp;</td>
2597
							<td class="vtable">
2598
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
2599
								<strong><?=gettext("Block bogon networks"); ?></strong><br>
2600
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2601
								"(but not RFC 1918) or not yet assigned by IANA."); ?>&nbsp;&nbsp;
2602
								<?=gettext("Bogons are prefixes that should never appear in the Internet routing table, " .
2603
								"and obviously should not appear as the source address in any packets you receive."); ?>
2604
								<br/><br/>
2605
								<?=gettext("Note: The update frequency can be changed under System->Advanced Firewall/NAT settings.")?>
2606
							</td>
2607
						</tr>
2608
					</table> <!-- End "allcfg" table -->
2609
					</div> <!-- End "allcfg" div -->
2610

    
2611
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2612
						<tr>
2613
							<td width="22%" valign="top">
2614
								&nbsp;
2615
							</td>
2616
							<td width="78%">
2617
								<br/>
2618
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2619
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2620
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2621
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2622
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2623
								<?php endif; ?>
2624
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2625
							</td>
2626
						</tr>
2627
					</table>
2628
				</td>
2629
			</tr>
2630
		</table>
2631
		<!--
2632
		</div>
2633
		</td></tr>
2634
		</table>
2635
		-->
2636
	</form>
2637
	<script type="text/javascript">
2638
		var gatewayip;
2639
		var name;
2640
		var gatewayipv6;
2641
		var namev6;
2642
		function show_add_gateway() {
2643
			document.getElementById("addgateway").style.display = '';
2644
			document.getElementById("addgwbox").style.display = 'none';
2645
			document.getElementById("gateway").style.display = 'none';
2646
			document.getElementById("save").style.display = 'none';
2647
			document.getElementById("cancel").style.display = 'none';
2648
			document.getElementById("gwsave").style.display = '';
2649
			document.getElementById("gwcancel").style.display = '';
2650
			jQuery('#notebox').html("");
2651
		}
2652
		function show_add_gateway_v6() {
2653
			document.getElementById("addgatewayv6").style.display = '';
2654
			document.getElementById("addgwboxv6").style.display = 'none';
2655
			document.getElementById("gatewayv6").style.display = 'none';
2656
			document.getElementById("save").style.display = 'none';
2657
			document.getElementById("cancel").style.display = 'none';
2658
			document.getElementById("gwsave").style.display = '';
2659
			document.getElementById("gwcancel").style.display = '';
2660
			jQuery('#noteboxv6').html("");
2661
		}
2662
		function hide_add_gateway() {
2663
			document.getElementById("addgateway").style.display = 'none';
2664
			document.getElementById("addgwbox").style.display = '';
2665
			document.getElementById("gateway").style.display = '';
2666
			document.getElementById("save").style.display = '';
2667
			document.getElementById("cancel").style.display = '';
2668
			document.getElementById("gwsave").style.display = '';
2669
			document.getElementById("gwcancel").style.display = '';
2670
		}
2671
		function hide_add_gateway_v6() {
2672
			document.getElementById("addgatewayv6").style.display = 'none';
2673
			document.getElementById("addgwboxv6").style.display = '';
2674
			document.getElementById("gatewayv6").style.display = '';
2675
			document.getElementById("save").style.display = '';
2676
			document.getElementById("cancel").style.display = '';
2677
			document.getElementById("gwsave").style.display = '';
2678
			document.getElementById("gwcancel").style.display = '';
2679
		}
2680
		function hide_add_gatewaysave() {
2681
			document.getElementById("addgateway").style.display = 'none';
2682
			jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2683
			var iface = jQuery('#if').val();
2684
			name = jQuery('#name').val();
2685
			var descr = jQuery('#gatewaydescr').val();
2686
			gatewayip = jQuery('#gatewayip').val();
2687

    
2688
			var defaultgw = jQuery('#defaultgw').val();
2689
			var url = "system_gateways_edit.php";
2690
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2691
			jQuery.ajax(
2692
				url,
2693
				{
2694
					type: 'post',
2695
					data: pars,
2696
					error: report_failure,
2697
					complete: save_callback
2698
				});
2699
		}
2700
		function hide_add_gatewaysave_v6() {
2701
			document.getElementById("addgatewayv6").style.display = 'none';
2702
			jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2703
			var iface = jQuery('#if').val();
2704
			name = jQuery('#namev6').val();
2705
			var descr = jQuery('#gatewaydescrv6').val();
2706
			gatewayip = jQuery('#gatewayipv6').val();
2707
			var defaultgw = jQuery('#defaultgwv6').val();
2708
			var url_v6 = "system_gateways_edit.php";
2709
			var pars_v6 = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2710
			jQuery.ajax(
2711
				url_v6,
2712
				{
2713
					type: 'post',
2714
					data: pars_v6,
2715
					error: report_failure_v6,
2716
					complete: save_callback_v6
2717
				});
2718
		}
2719
		function addOption(selectbox,text,value)
2720
		{
2721
			var optn = document.createElement("OPTION");
2722
			optn.text = text;
2723
			optn.value = value;
2724
			selectbox.append(optn);
2725
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2726
			jQuery('#notebox').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2727
		}
2728
		function addOption_v6(selectbox,text,value)
2729
		{
2730
			var optn = document.createElement("OPTION");
2731
			optn.text = text;
2732
			optn.value = value;
2733
			selectbox.append(optn);
2734
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2735
			jQuery('#noteboxv6').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2736
		}
2737
		function report_failure(request, textStatus, errorThrown) {
2738
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
2739
				alert(request.responseText);
2740
			} else {
2741
				alert("Sorry, we could not create your IPv4 gateway at this time.");
2742
			}
2743
			hide_add_gateway();
2744
		}
2745
		function report_failure_v6(request, textStatus, errorThrown) {
2746
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
2747
				alert(request.responseText);
2748
			} else {
2749
				alert("Sorry, we could not create your IPv6 gateway at this time.");
2750
			}
2751
			hide_add_gateway_v6();
2752
		}
2753
		function save_callback(transport) {
2754
			var response = transport.responseText;
2755
			if(response) {
2756
				document.getElementById("addgateway").style.display = 'none';
2757
				hide_add_gateway();
2758
				jQuery('#status').html('');
2759
				var gwtext = escape(name) + " - " + gatewayip;
2760
				addOption(jQuery('#gateway'), gwtext, name);
2761
				// Auto submit form?
2762
				//document.iform.submit();
2763
				//jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif">');
2764
			} else {
2765
				report_failure();
2766
			}
2767
		}
2768
		function show_advanced_media() {
2769
			document.getElementById("showadvmediabox").innerHTML='';
2770
			aodiv = document.getElementById('showmediaadv');
2771
			aodiv.style.display = "block";
2772
		}
2773
		function save_callback_v6(transport) {
2774
			var response_v6 = transport.responseText;
2775
			if(response_v6) {
2776
				document.getElementById("addgatewayv6").style.display = 'none';
2777
				hide_add_gateway_v6();
2778
				jQuery('#statusv6').html('');
2779
				var gwtext_v6 = escape(name) + " - " + gatewayip;
2780
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
2781
				// Auto submit form?
2782
				//document.iform.submit();
2783
				//jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif">');
2784
			} else {
2785
				report_failure_v6();
2786
			}
2787
		}
2788
		<?php
2789
		echo "show_allcfg(document.iform.enable);";
2790
		echo "updateType('{$pconfig['type']}');\n";
2791
		echo "updateTypeSix('{$pconfig['type6']}');\n";
2792
		?>
2793
	</script>
2794
	<?php include("fend.inc"); ?>
2795
	</body>
2796
</html>
(93-93/249)