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(empty($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
				if (isset($config['interfaces'][$ifapply]['enable'])) {
359
					interface_bring_down($ifapply, false, $ifcfgo);
360
					interface_configure($ifapply);
361
				} else
362
					interface_bring_down($ifapply, false, $ifcfgo);
363
			}
364
		}
365
		/* restart snmp so that it binds to correct address */
366
		services_snmpd_configure();
367

    
368
		/* sync filter configuration */
369
		setup_gateways_monitor();
370

    
371
		clear_subsystem_dirty('interfaces');
372

    
373
		filter_configure();
374

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

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

    
409
	/* filter out spaces from descriptions  */
410
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
411

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

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

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

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

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

    
705
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
706
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
707

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

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

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

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

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

    
882
		conf_mount_ro();
883
		write_config();
884

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

    
893
		mark_subsystem_dirty('interfaces');
894

    
895
		/* regenerate cron settings/crontab file */
896
		configure_cron();
897

    
898
		header("Location: interfaces.php?if={$if}");
899
		exit;
900
	}
901

    
902
} // end if($_POST)
903

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

    
1045
function check_wireless_mode() {
1046
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1047

    
1048
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1049
		return;
1050

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

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

    
1088
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1089
$shortcut_section = "interfaces";
1090

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

    
1096
?>
1097

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

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

    
1173
	function show_allcfg(obj) {
1174
		if (obj.checked)
1175
			jQuery('#allcfg').show();
1176
		else
1177
			jQuery('#allcfg').hide();
1178
	}
1179

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

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

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

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

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

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

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

    
1522

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

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

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

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