Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
95

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

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

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

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

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

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

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

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

    
227
switch($wancfg['ipaddrv6']) {
228
	default:
229
		/* if we have dual stack we need a combined type */
230
		if(is_ipaddrv6($wancfg['ipaddrv6'])) {
231
			$pconfig['type'] = "staticv6";
232
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
233
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
234
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
235
			$pconfig['dhcp6-pd-sla-id'] = $wancfg['dhcp6-pd-sla-id'];
236
			if((is_ipaddrv6($wancfg['ipaddrv6'])) && (is_ipaddr($wancfg['ipaddr']))) {
237
				$pconfig['type'] = "staticv4v6";
238
			}
239
		}
240
		break;
241
}
242

    
243
// print_r($pconfig);
244

    
245
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
246
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
247
$pconfig['spoofmac'] = $wancfg['spoofmac'];
248
$pconfig['mtu'] = $wancfg['mtu'];
249
$pconfig['mss'] = $wancfg['mss'];
250

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

    
331
if ($_POST['apply']) {
332
	unset($input_errors);
333
	if (!is_subsystem_dirty('interfaces'))
334
		$intput_errors[] = gettext("You have already applied your settings!");
335
	else {
336
		unlink_if_exists("{$g['tmp_path']}/config.cache");
337
		clear_subsystem_dirty('interfaces');
338

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

    
358
		/* sync filter configuration */
359
		setup_gateways_monitor();
360

    
361
		clear_subsystem_dirty('staticroutes');
362

    
363
		filter_configure();
364

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

    
391
	unset($input_errors);
392
	$pconfig = $_POST;
393
	conf_mount_rw();
394

    
395
	/* filter out spaces from descriptions  */
396
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
397

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

    
422
	switch(strtolower($_POST['type'])) {
423
		case "staticv4":
424
			$reqdfields = explode(" ", "ipaddr subnet gateway");
425
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
426
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
427
			break;
428
		case "staticv6":
429
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6 dhcp6-pd-sla-id");
430
			$reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
431
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
432
			break;
433
		case "staticv4v6":
434
			/* if the saved v6 address is empty we just lookup the link-local address */
435
			/* dhcp-pd will override the LAN address and we will setup a router advertisment in the background */
436
			if(empty($_POST['ipaddrv6'])) {
437
				exec("/sbin/ifconfig {$wancfg['if']} inet6 | awk '/fe80:/ {print $2}' | awk -F% '{print $1}'", $output);
438
				$_POST['ipaddrv6'] = trim($output[0]);
439
				$_POST['subnetv6'] = "64";
440
			}
441
			$reqdfields = explode(" ", "ipaddr subnet gateway ipaddrv6 subnetv6 gatewayv6 dhcp6-pd-sla-id");
442
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"),gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
443
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
444
			break;
445
		case "none":
446
			if(is_array($config['virtualip']['vip'])) {
447
				foreach ($config['virtualip']['vip'] as $vip) {
448
					if ($vip['interface'] == $if)
449
						$input_errors[] = gettext("This interface is referenced by VIPs please delete those before setting the interface to 'none' configuration.");
450
				}
451
			}
452
		case "dhcp":
453
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp")))
454
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
455
			if (in_array($wancfg['ipaddrv6'], array("ppp", "pppoe", "pptp", "l2tp")))
456
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
457
			break;
458
		case "ppp":
459
			$reqdfields = explode(" ", "port phone");
460
			$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
461
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
462
			break;
463
		case "pppoe":
464
			if ($_POST['pppoe_dialondemand']) {
465
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
466
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
467
			} else {
468
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
469
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
470
			}
471
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
472
			break;
473
		case "pptp":
474
			if ($_POST['pptp_dialondemand']) {
475
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
476
				$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"));
477
			} else {
478
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
479
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
480
			}
481
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
482
			break;
483
		case "l2tp":
484
			if ($_POST['pptp_dialondemand']) {
485
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
486
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
487
			} else {
488
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
489
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"));
490
			}
491
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
492
			break;
493
	}
494

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

    
593
		if ($_POST['passphrase']) {
594
                	$passlen = strlen($_POST['passphrase']);
595
                	if ($passlen < 8 || $passlen > 64)
596
                        	$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
597
		}
598
	}
599
	if (!$input_errors) {
600
		if ($wancfg['ipaddr'] != $_POST['type']) {
601
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
602
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
603
				unset($a_ppps[$pppid]);
604
			} else if ($wancfg['ipaddr'] == "dhcp") {
605
				$pid = find_dhclient_process($realif);
606
				if($pid)
607
					posix_kill($pid, SIGTERM);
608
			}
609
				
610
		}
611
		$ppp = array();
612
		if ($wancfg['ipaddr'] != "ppp")
613
			unset($wancfg['ipaddr']);
614
		if ($wancfg['ipaddrv6'] != "ppp")
615
			unset($wancfg['ipaddrv6']);
616
		unset($wancfg['subnet']);
617
		unset($wancfg['gateway']);
618
		unset($wancfg['subnetv6']);
619
		unset($wancfg['gatewayv6']);
620
		unset($wancfg['dhcphostname']);
621
		unset($wancfg['dhcp6-pd-sla-id']);
622
		unset($wancfg['dhcp6-duid']);
623
		unset($wancfg['dhcp6-ia-pd-len']);
624
		unset($wancfg['pppoe_username']);
625
		unset($wancfg['pppoe_password']);
626
		unset($wancfg['pptp_username']);
627
		unset($wancfg['pptp_password']);
628
		unset($wancfg['provider']);
629
		unset($wancfg['ondemand']);
630
		unset($wancfg['timeout']);
631
		if (isset($wancfg['pppoe']['pppoe-reset-type']))
632
			unset($wancfg['pppoe']['pppoe-reset-type']);
633
		unset($wancfg['local']);
634
		unset($wancfg['remote']);
635
		unset($a_ppps[$pppid]['apn']);
636
		unset($a_ppps[$pppid]['phone']);
637
		unset($a_ppps[$pppid]['localip']);
638
		unset($a_ppps[$pppid]['subnet']);
639
		unset($a_ppps[$pppid]['gateway']);
640
		unset($a_ppps[$pppid]['pppoe-reset-type']);
641
		unset($a_ppps[$pppid]['provider']);
642

    
643
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
644
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
645

    
646
		/* for dynamic interfaces we tack a gateway item onto the array to prevent system
647
		 * log messages from appearing. They can also manually add these items */
648
		/* 1st added gateway gets a default bit */
649
		if(!empty($a_gateways)) {
650
			$gateway_item = array();
651
			/* check for duplicates */
652
			$skip = false;
653
			foreach($a_gateways as $item) {
654
				if(($item['interface'] == "$if") && ($item['gateway'] == "dynamic")) {
655
					$skip = true;
656
				}
657
			}
658
			if($skip == false) {
659
				$gateway_item['gateway'] = "dynamic";
660
				$gateway_item['descr'] = sprintf(gettext("Interface %s dynamic gateway"),$if);
661
				$gateway_item['name'] = "GW_" . strtoupper($if);
662
				$gateway_item['interface'] = "{$if}";
663
			} else {
664
				unset($gateway_item);
665
			}
666
		}
667

    
668
		switch($_POST['type']) {
669
			case "staticv4":
670
				$wancfg['ipaddr'] = $_POST['ipaddr'];
671
				$wancfg['subnet'] = $_POST['subnet'];
672
				if ($_POST['gateway'] != "none") {
673
					$wancfg['gateway'] = $_POST['gateway'];
674
				}
675
				break;
676
			case "staticv6":
677
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
678
				$wancfg['subnetv6'] = $_POST['subnetv6'];
679
				$wancfg['dhcp6-pd-sla-id'] = $_POST['dhcp6-pd-sla-id'];
680
				if ($_POST['gatewayv6'] != "none") {
681
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
682
				}
683
				break;
684
			case "staticv4v6":
685
				$wancfg['ipaddr'] = $_POST['ipaddr'];
686
				$wancfg['subnet'] = $_POST['subnet'];
687
				if ($_POST['gateway'] != "none") {
688
					$wancfg['gateway'] = $_POST['gateway'];
689
				}
690
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
691
				$wancfg['subnetv6'] = $_POST['subnetv6'];
692
				$wancfg['dhcp6-pd-sla-id'] = $_POST['dhcp6-pd-sla-id'];
693
				if ($_POST['gatewayv6'] != "none") {
694
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
695
				}
696
				break;
697
			case "dhcp":
698
				$wancfg['ipaddr'] = "dhcp";
699
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
700
				$wancfg['alias-address'] = $_POST['alias-address'];
701
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
702
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
703
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
704
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
705
				if($gateway_item) {
706
					$a_gateways[] = $gateway_item;
707
				}
708
				break;
709
			case "carpdev-dhcp":
710
				$wancfg['ipaddr'] = "carpdev-dhcp";
711
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
712
				$wancfg['alias-address'] = $_POST['alias-address'];
713
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
714
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
715
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
716
				if($gateway_item) {
717
					$a_gateways[] = $gateway_item;
718
				}
719
				break;
720
			case "ppp":
721
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
722
				$a_ppps[$pppid]['type'] = $_POST['type'];
723
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
724
				$a_ppps[$pppid]['ports'] = $_POST['port'];
725
				$a_ppps[$pppid]['username'] = $_POST['username'];
726
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
727
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
728
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
729
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
730
				$wancfg['ipaddr'] = $_POST['type'];
731
				unset($a_ppps[$pppid]['ondemand']);
732
				unset($a_ppps[$pppid]['idletimeout']);
733
				break;
734

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

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

    
765
				break;
766
			case "pptp":
767
			case "l2tp":
768
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
769
				$a_ppps[$pppid]['type'] = $_POST['type'];
770
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
771
				if (isset($_POST['ppp_port']))
772
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
773
				else
774
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
775
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
776
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
777
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
778
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
779
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
780
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
781
				if (!empty($_POST['idletimeout']))
782
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
783
				else
784
					unset($a_ppps[$pppid]['idletimeout']);
785
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
786
				$wancfg['ipaddr'] = $_POST['type'];
787
				if($gateway_item) {
788
					$a_gateways[] = $gateway_item;
789
				}
790
				break;
791
			case "none":
792
				break;
793
		}
794
		handle_pppoe_reset($_POST);
795

    
796
		if($_POST['blockpriv'] == "yes") {
797
			$wancfg['blockpriv'] = true;
798
		} else {
799
			unset($wancfg['blockpriv']);
800
		}
801
		if($_POST['blockbogons'] == "yes") {
802
			$wancfg['blockbogons'] = true;
803
		} else {
804
			unset($wancfg['blockbogons']);
805
		}
806
		$wancfg['spoofmac'] = $_POST['spoofmac'];
807
		if (empty($_POST['mtu'])) {
808
			unset($wancfg['mtu']);
809
		} else {
810
			$wancfg['mtu'] = $_POST['mtu'];
811
		}
812
		if (empty($_POST['mss'])) {
813
			unset($wancfg['mss']);
814
		} else {
815
			$wancfg['mss'] = $_POST['mss'];
816
		}
817
		if (empty($_POST['mediaopt'])) {
818
			unset($wancfg['media']);
819
			unset($wancfg['mediaopt']);
820
		} else {
821
			$mediaopts = explode(' ', $_POST['mediaopt']);	
822
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
823
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
824
			else { unset($wancfg['mediaopt']); }
825
		}
826
		if (isset($wancfg['wireless'])) {
827
			handle_wireless_post();
828
		}
829

    
830
		conf_mount_ro();
831
		write_config();
832

    
833
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
834
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
835
		} else {
836
			$toapplylist = array();
837
		}
838
		$toapplylist[$if] = array();
839
		/* we need to be able remove IP aliases for IPv6 */
840
		if(($old_wancfg['ipaddrv6'] != $wancfg['ipaddrv6']) && (is_ipaddrv6($old_wancfg['ipaddrv6']))) {
841
			$toapplylist[$if]['ipaddrv6'] = $old_wancfg['ipaddrv6'];
842
		}
843
		
844
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
845

    
846
		mark_subsystem_dirty('interfaces');
847

    
848
		/* regenerate cron settings/crontab file */
849
		configure_cron();
850

    
851
		header("Location: interfaces.php?if={$if}");
852
		exit;
853
	}
854

    
855
} // end if($_POST)
856

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

    
990
function check_wireless_mode() {
991
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
992

    
993
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
994
		return;
995

    
996
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
997
		$clone_count = 1;
998
	else
999
		$clone_count = 0;
1000
	if (is_array($config['wireless']['clone'])) {
1001
		foreach ($config['wireless']['clone'] as $clone) {
1002
			if ($clone['if'] == $wlanbaseif)
1003
				$clone_count++;
1004
		}
1005
	}
1006
	if ($clone_count > 1) {
1007
		$old_wireless_mode = $wancfg['wireless']['mode'];
1008
		$wancfg['wireless']['mode'] = $_POST['mode'];
1009
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1010
			$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']]);
1011
		} else {
1012
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
1013
		}
1014
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1015
	}
1016
}
1017

    
1018
// Find all possible media options for the interface
1019
$mediaopts_list = array();
1020
$intrealname = $config['interfaces'][$if]['if'];
1021
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1022
foreach ($mediaopts as $mediaopt){
1023
	preg_match("/media (.*)/", $mediaopt, $matches);
1024
 	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1025
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1026
 		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1027
	}else{
1028
		// there is only media like "media 1000baseT"
1029
		array_push($mediaopts_list, $matches[1]);
1030
	}
1031
}
1032

    
1033
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1034
$statusurl = "status_interfaces.php";
1035

    
1036
$closehead = false;
1037
include("head.inc");
1038
$types = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "staticv6" => gettext("Static IPv6"), "staticv4v6" => gettext("Static IPv4 + IPv6"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP") /* , "carpdev-dhcp" => "CarpDev"*/);
1039

    
1040
?>
1041

    
1042
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1043
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1044
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1045
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1046

    
1047
<script type="text/javascript">
1048
	function updateType(t) {
1049
		switch(t) {
1050
			case "none": {
1051
				$('staticv4', 'staticv6', 'dhcp', 'pppoe','pptp', 'ppp').invoke('hide');
1052
				break;
1053
			}
1054
			case "staticv4": {
1055
				$('none', 'staticv6', 'dhcp', 'pppoe', 'pptp', 'ppp').invoke('hide');
1056
				break;
1057
			}
1058
			case "staticv6": {
1059
				$('none', 'staticv4', 'dhcp', 'pppoe','pptp', 'ppp').invoke('hide');
1060
				break;
1061
			}
1062
			case "staticv4v6": {
1063
				$('none', 'dhcp', 'pppoe', 'pptp', 'ppp').invoke('hide');
1064
				$('staticv4').show();
1065
				$('staticv6').show();
1066
				break;
1067
			}
1068
			case "dhcp": {
1069
				$('none', 'staticv4', 'staticv6', 'pppoe', 'pptp', 'ppp').invoke('hide');
1070
				break;
1071
			}
1072
			case "ppp": {
1073
				$('none', 'staticv4', 'staticv6', 'dhcp', 'pptp', 'pppoe').invoke('hide');
1074
				country_list();
1075
				break;
1076
			}
1077
			case "pppoe": {
1078
				$('none', 'staticv4', 'staticv6', 'dhcp', 'pptp', 'ppp').invoke('hide');
1079
				break;
1080
			}
1081
			case "l2tp":
1082
			case "pptp": {
1083
				$('none', 'staticv4', 'staticv6', 'dhcp', 'pppoe', 'ppp').invoke('hide');
1084
				$('pptp').show();
1085
				break;
1086
			}
1087
		}
1088
		if (t != "l2tp" && t != "pptp")
1089
			$(t).show();
1090
	}
1091

    
1092
	function show_allcfg(obj) {
1093
		if (obj.checked)
1094
			$('allcfg').show();
1095
		else
1096
			$('allcfg').hide();
1097
	}
1098

    
1099
	function show_reset_settings(reset_type) {
1100
		if (reset_type == 'preset') {
1101
			Effect.Appear('pppoepresetwrap', { duration: 0.0 });
1102
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
1103
		}
1104
		else if (reset_type == 'custom') {
1105
			Effect.Appear('pppoecustomwrap', { duration: 0.0 });
1106
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
1107
		} else {
1108
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
1109
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
1110
		}
1111
	}
1112
	function show_mon_config() {
1113
		document.getElementById("showmonbox").innerHTML='';
1114
		aodiv = document.getElementById('showmon');
1115
		aodiv.style.display = "block";
1116
	}
1117

    
1118
	function openwindow(url) {
1119
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1120
		if (oWin==null || typeof(oWin)=="undefined")
1121
			return false;
1122
		else
1123
			return true;
1124
	}
1125
	function country_list() {
1126
		$('country').childElements().each(function(node) { node.remove(); });
1127
		$('provider').childElements().each(function(node) { node.remove(); });
1128
		$('providerplan').childElements().each(function(node) { node.remove(); });
1129
		new Ajax.Request("getserviceproviders.php",{
1130
			onSuccess: function(response) {
1131
				var responseTextArr = response.responseText.split("\n");
1132
				responseTextArr.sort();
1133
				responseTextArr.each( function(value) {
1134
					var option = new Element('option');
1135
					country = value.split(":");
1136
					option.text = country[0];
1137
					option.value = country[1];
1138
					$('country').insert({ bottom : option });
1139
				});
1140
			}
1141
		});
1142
		$('trcountry').setStyle({display : "table-row"});
1143
	}
1144

    
1145
	function providers_list() {
1146
		$('provider').childElements().each(function(node) { node.remove(); });
1147
		$('providerplan').childElements().each(function(node) { node.remove(); });
1148
		new Ajax.Request("getserviceproviders.php",{
1149
			parameters: {country : $F('country')},
1150
			onSuccess: function(response) {
1151
				var responseTextArr = response.responseText.split("\n");
1152
				responseTextArr.sort();
1153
				responseTextArr.each( function(value) {
1154
					var option = new Element('option');
1155
					option.text = value;
1156
					option.value = value;
1157
					$('provider').insert({ bottom : option });
1158
				});
1159
			}
1160
		});
1161
		$('trprovider').setStyle({display : "table-row"});
1162
		$('trproviderplan').setStyle({display : "none"});
1163
	}
1164

    
1165
	function providerplan_list() {
1166
		$('providerplan').childElements().each(function(node) { node.remove(); });
1167
		$('providerplan').insert( new Element('option') );
1168
		new Ajax.Request("getserviceproviders.php",{
1169
			parameters: {country : $F('country'), provider : $F('provider')},
1170
			onSuccess: function(response) {
1171
				var responseTextArr = response.responseText.split("\n");
1172
				responseTextArr.sort();
1173
				responseTextArr.each( function(value) {
1174
					if(value != "") {
1175
						providerplan = value.split(":");
1176

    
1177
						var option = new Element('option');
1178
						option.text = providerplan[0] + " - " + providerplan[1];
1179
						option.value = providerplan[1];
1180
						$('providerplan').insert({ bottom : option });
1181
					}
1182
				});
1183
			}
1184
		});
1185
		$('trproviderplan').setStyle({display : "table-row"});
1186
	}
1187

    
1188
	function prefill_provider() {
1189
		new Ajax.Request("getserviceproviders.php",{
1190
			parameters: {country : $F('country'), provider : $F('provider'), plan : $F('providerplan')},
1191
			onSuccess: function(response) {
1192
				var xmldoc = response.responseXML;
1193
				var provider = xmldoc.getElementsByTagName('connection')[0];
1194
				$('username').setValue('');
1195
				$('password').setValue('');
1196
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1197
					$('phone').setValue('#777');
1198
					$('apn').setValue('');
1199
				} else {
1200
					$('phone').setValue('*99#');
1201
					$('apn').setValue(provider.getElementsByTagName('apn')[0].firstChild.data);
1202
				}
1203
				$('username').setValue(provider.getElementsByTagName('username')[0].firstChild.data);
1204
				$('password').setValue(provider.getElementsByTagName('password')[0].firstChild.data);
1205
			}
1206
		});
1207
	}
1208

    
1209
</script>
1210
</head>
1211
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1212
	<?php include("fbegin.inc"); ?>
1213
	<form action="interfaces.php" method="post" name="iform" id="iform">
1214
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1215
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1216
		<?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 />
1217
		<?php endif; ?>
1218
		<?php if ($savemsg) print_info_box($savemsg); ?>
1219
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
1220
			<tr>
1221
				<td id="mainarea">
1222
					<div class="tabcont">
1223
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1224
						<tr>
1225
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1226
						</tr>
1227
						<tr>
1228
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1229
							<td width="78%" class="vtable">
1230
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked"; ?> onClick="show_allcfg(this);">
1231
							<strong><?=gettext("Enable Interface"); ?></strong>
1232
							</td>
1233
						</tr>
1234
					</table>
1235
					<div style="display:none;" name="allcfg" id="allcfg">
1236
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1237
						<tr>
1238
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1239
							<td width="78%" class="vtable">
1240
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
1241
								<br><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1242
							</td>
1243
						</tr>
1244
						<tr>
1245
							<td valign="middle" class="vncell"><strong><?=gettext("Type"); ?></strong></td>
1246
							<td class="vtable">
1247
								<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
1248
								<?php
1249
									foreach ($types as $key => $opt) {
1250
										echo "<option onClick=\"updateType('{$key}');\"";
1251
										if ($key == $pconfig['type'])
1252
											echo " selected";
1253
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1254
										echo "</option>";
1255
									}
1256
								?>
1257
								</select>
1258
							</td>
1259
						</tr>
1260
						<tr>
1261
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1262
							<td class="vtable">
1263
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
1264
								<?php
1265
									$ip = getenv('REMOTE_ADDR');
1266
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1267
									$mac = str_replace("\n","",$mac);
1268
									if($mac):
1269
								?>
1270
									<a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1271
								<?php endif; ?>
1272
								<br>
1273
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1274
								"address of this interface"); ?><br>
1275
								<?=gettext("(may be required with some cable connections)"); ?><br>
1276
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1277
								"or leave blank"); ?>
1278
							</td>
1279
						</tr>
1280
						<tr>
1281
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1282
							<td class="vtable">
1283
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
1284
								<br>
1285
								<?=gettext("If you leave this field blank, the adapter's default MTU will " .
1286
								"be used. This is typically 1500 bytes but can vary on some hardware."); ?>
1287
							</td>
1288
						</tr>
1289
						<tr>
1290
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1291
							<td class="vtable">
1292
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>">
1293
								<br>
1294
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1295
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1296
								"header size) will be in effect."); ?>
1297
							</td>
1298
						</tr>
1299
						<?php 
1300
						if (count($mediaopts_list) > 0){
1301
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1302
						echo "<tr>";
1303
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1304
							echo '<td class="vtable">';
1305
                                			echo '<div id="showadvmediabox"';
1306
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1307
								else echo '>';
1308
								echo '<input type="button" onClick="show_advanced_media()" value="' . gettext("Advanced") . '"></input> - ' . gettext("Show advanced option");
1309
							echo "</div>";
1310
							echo '<div id="showmediaadv" ';
1311
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1312
							else echo '>';
1313
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1314
								print "<option value=\"\">Default</option>";
1315
								foreach($mediaopts_list as $mediaopt){
1316
									if ($mediaopt != rtrim($mediaopt_from_config)){
1317
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1318
									} else {
1319
										print "<option value=\"$mediaopt\" selected>" . gettext("$mediaopt") . "</option>";
1320
									}
1321
								}
1322
								echo '</select><br>';
1323
								echo gettext("Here you can explicitly set speed and duplex mode for this interface. WARNING: You MUST leave this set to autonegotiate unless the port this interface connects to has its speed and duplex forced.");
1324
						echo '</div>';
1325
							echo '</td>';
1326
						echo '</tr>';
1327
						}
1328
						?>
1329
						<tr>
1330
							<td colspan="2" valign="top" height="16"></td>
1331
						</tr>
1332
						<tr style="display:none;" name="none" id="none">
1333
						</tr>
1334
						<tr style="display:none;" name="staticv4" id="staticv4">
1335
							<td colspan="2" style="padding:0px;">
1336
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1337
									<tr>
1338
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1339
									</tr>
1340
									<tr>
1341
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1342
										<td width="78%" class="vtable">
1343
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
1344
											/
1345
											<select name="subnet" class="formselect" id="subnet">
1346
												<?php
1347
												for ($i = 32; $i > 0; $i--) {
1348
													if($i <> 31) {
1349
														echo "<option value=\"{$i}\" ";
1350
														if ($i == $pconfig['subnet']) echo "selected";
1351
														echo ">" . $i . "</option>";
1352
													}
1353
												}
1354
												?>
1355
											</select>
1356
										</td>
1357
									</tr>
1358
									<tr>
1359
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway"); ?></td>
1360
										<td width="78%" class="vtable">
1361
											<select name="gateway" class="formselect" id="gateway">
1362
												<option value="none" selected><?=gettext("None"); ?></option>
1363
													<?php
1364
													if(count($a_gateways) > 0) {
1365
														foreach ($a_gateways as $gateway) {
1366
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1367
													?>
1368
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
1369
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1370
															</option>
1371
													<?php
1372
															}
1373
														}
1374
													}
1375
													?>
1376
											</select>
1377
											- or  <strong><a OnClick="show_add_gateway();" href="#"><?=gettext("add a new one."); ?></a></strong>
1378
											<br/>
1379
											<div id='addgwbox'>
1380
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add one using the link above"); ?>
1381
											</div>
1382
											<div id='notebox'>
1383
											</div>
1384
											<div id="status">
1385
											</div>
1386
											<div style="display:none" id="addgateway" name="addgateway">
1387
												<p>
1388
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1389
													<tr>
1390
														<td>
1391
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1392
																<tr><td>&nbsp;</td>
1393
																<tr>
1394
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1395
																</tr>
1396
																<tr><td>&nbsp;</td>
1397
																<?php
1398
																if($if == "wan" || $if == "WAN")
1399
																	$checked = " CHECKED";
1400
																?>
1401
																<tr>
1402
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
1403
																</tr>
1404
																<tr>
1405
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td>
1406
																</tr>
1407
																<tr>
1408
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></td><td><input id="gatewayip" name="gatewayip"></td>
1409
																</tr>
1410
																<tr>
1411
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1412
																</tr>
1413
																<tr><td>&nbsp;</td>
1414
																<tr>
1415
																	<td>&nbsp;</td>
1416
																	<td>
1417
																		<center>
1418
																			<div id='savebuttondiv'>
1419
																				<input id="gwsave" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave();'>
1420
																				<input id="gwcancel" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway();'>
1421
																			</div>
1422
																		</center>
1423
																	</td>
1424
																</tr>
1425
																<tr><td>&nbsp;</td></tr>
1426
															</table>
1427
														</td>
1428
													</tr>
1429
												</table>
1430
												<p/>
1431
											</div>
1432
										</td>
1433
									</tr>
1434
								</table>
1435
							</td>
1436
						</tr>
1437
						<tr style="display:none;" name="staticv6" id="staticv6">
1438
							<td colspan="2" style="padding:0px;">
1439
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1440
									<tr>
1441
										<td colspan="2" valign="top">&nbsp;</td>
1442
									</tr>
1443
									<tr>
1444
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1445
									</tr>
1446
									<tr>
1447
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1448
										<td width="78%" class="vtable">
1449
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>">
1450
											/
1451
											<select name="subnetv6" class="formselect" id="subnetv6">
1452
												<?php
1453
												for ($i = 128; $i > 0; $i--) {
1454
													if($i <> 127) {
1455
														echo "<option value=\"{$i}\" ";
1456
														if ($i == $pconfig['subnetv6']) echo "selected";
1457
														echo ">" . $i . "</option>";
1458
													}
1459
												}
1460
												?>
1461
											</select>
1462
										</td>
1463
									</tr>
1464
									<tr>
1465
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation ID"); ?></td>
1466
										<td width="78%" class="vtable">
1467
											<select name="dhcp6-pd-sla-id" class="formselect" id="dhcp6-pd-sla-id">
1468
												<option value="none" selected><?=gettext("None"); ?></option>
1469
												<?php
1470
												// FIXME: Needs to calculate from prefix length from dhcp-pd
1471
												// Needs to check if the ID is not used on another interface
1472
												for ($i = 16; $i > 0; $i--) {
1473
													if($i <> 15) {
1474
														echo "<option value=\"{$i}\" ";
1475
														if ($i == $pconfig['dhcp6-pd-sla-id']) echo "selected";
1476
														echo ">" . $i . "</option>";
1477
													}
1478
												}
1479
												?> 
1480
											</select>
1481
											<?=gettext("This ID sets the delegated DHCP-PD prefix number which will be used to setup the interface.");?>
1482

    
1483
										</td>
1484
									</tr>
1485
									<tr>
1486
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway IPv6"); ?></td>
1487
										<td width="78%" class="vtable">
1488
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1489
												<option value="none" selected><?=gettext("None"); ?></option>
1490
													<?php
1491
													if(count($a_gateways) > 0) {
1492
														foreach ($a_gateways as $gateway) {
1493
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1494
													?>
1495
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected"; ?>>
1496
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1497
															</option>
1498
													<?php
1499
															}
1500
														}
1501
													}
1502
													?>
1503
											</select>
1504
											- or <strong><a OnClick="show_add_gateway_v6();" href="#"><?=gettext("add a new one."); ?></a></strong>
1505
											<br/>
1506
											<div id='addgwboxv6'>
1507
											<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above"); ?>
1508
											</div>
1509
											<div id='noteboxv6'>
1510
											</div>
1511
											<div id="statusv6">
1512
											</div>
1513
											<div style="display:none" id="addgatewayv6" name="addgatewayv6">
1514
												<p>
1515
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1516
													<tr>
1517
														<td>
1518
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1519
																<tr><td>&nbsp;</td>
1520
																<tr>
1521
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1522
																</tr>
1523
																<tr><td>&nbsp;</td>
1524
																<?php
1525
																if($if == "wan" || $if == "WAN")
1526
																	$checked = " CHECKED";
1527
																?>
1528
																<tr>
1529
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?>></td>
1530
																</tr>
1531
																<tr>
1532
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>"></td>
1533
																</tr>
1534
																<tr>
1535
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></td><td><input id="gatewayipv6" name="gatewayipv6"></td>
1536
																</tr>
1537
																<tr>
1538
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescrv6" name="gatewaydescrv6"></td>
1539
																</tr>
1540
																<tr><td>&nbsp;</td>
1541
																<tr>
1542
																	<td>&nbsp;</td>
1543
																	<td>
1544
																		<center>
1545
																			<div id='savebuttondivv6'>
1546
																				<input id="gwsavev6" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave_v6();'>
1547
																				<input id="gwcancelv6" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway_v6();'>
1548
																			</div>
1549
																		</center>
1550
																	</td>
1551
																</tr>
1552
																<tr><td>&nbsp;</td></tr>
1553
															</table>
1554
														</td>
1555
													</tr>
1556
												</table>
1557
												<p/>
1558
											</div>
1559
										</td>
1560
									</tr>
1561
								</table>
1562
							</td>
1563
						</tr>
1564
						<tr style="display:none;" name="dhcp" id="dhcp">
1565
							<td colspan="2" style="padding: 0px;">
1566
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1567
									<tr>
1568
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration"); ?></td>
1569
									</tr>
1570
									<!-- Uncomment to expose DHCP+ in GUI
1571
									<tr>
1572
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1573
										<td width="78%" class="vtable">
1574
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked"; ?> >
1575
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1576
										<br/>
1577
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
1578
										</td>
1579
									</tr>
1580
									-->
1581
									<tr>
1582
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1583
										<td width="78%" class="vtable">
1584
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1585
											<br>
1586
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1587
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1588
											"this (for client identification)."); ?>
1589
										</td>
1590
									</tr>
1591
									<tr>
1592
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
1593
										<td width="78%" class="vtable">
1594
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
1595
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1596
												<?php
1597
												for ($i = 32; $i > 0; $i--) {
1598
													if($i <> 31) {
1599
														echo "<option value=\"{$i}\" ";
1600
														if ($i == $pconfig['alias-subnet']) echo "selected";
1601
														echo ">" . $i . "</option>";
1602
													}
1603
												}
1604
												?>
1605
											</select>
1606
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
1607
											"DHCP client."); ?>
1608
										</td>
1609
									</tr>
1610
									<tr>
1611
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
1612
										<td width="78%" class="vtable">
1613
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>">
1614
											<br>
1615
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
1616
											"when requesting a DHCPv6 lease."); ?><br />
1617
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
1618
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
1619
												}
1620
												printf(gettext("The current DUID is: '%s'"),$current_duid);
1621
											?>
1622
											
1623
										</td>
1624
									</tr>
1625
									<tr>
1626
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
1627
										<td width="78%" class="vtable">
1628
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
1629
												<?php
1630
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
1631
												foreach($sizes as $bits => $length) {
1632
													echo "<option value=\"{$bits}\" ";
1633
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected";
1634
													echo ">" . $length . "</option>";
1635
												}
1636
												?>
1637
											</select>
1638
											<br>
1639
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
1640
										</td>
1641
									</tr>
1642
									
1643
								</table>
1644
							</td>
1645
						</tr>
1646
						<tr style="display:none;" name="ppp" id="ppp">
1647
							<td colspan="2" style="padding: 0px;">
1648
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1649
									<tr>
1650
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
1651
									</tr>
1652
									<tr name="ppp_provider" id="ppp_provider">
1653
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
1654
										<td width="78%" class="vtable">
1655
											<table border="0" cellpadding="0" cellspacing="0">
1656
												<tr id="trcountry">
1657
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
1658
													<td>
1659
														<select class="formselect" name="country" id="country" onChange="providers_list()">
1660
															<option></option>
1661
														</select>
1662
													</td>
1663
												</tr>
1664
												<tr id="trprovider" style="display:none">
1665
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
1666
													<td>
1667
														<select class="formselect" name="provider" id="provider" onChange="providerplan_list()">
1668
															<option></option>
1669
														</select>
1670
													</td>
1671
												</tr>
1672
												<tr id="trproviderplan" style="display:none">
1673
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
1674
													<td>
1675
														<select class="formselect" name="providerplan" id="providerplan" onChange="prefill_provider()">
1676
															<option></option>
1677
														</select>
1678
													</td>
1679
												</tr>
1680
											</table>
1681
											<br/><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
1682
										</td>
1683
									</tr>
1684
									<tr>
1685
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
1686
										<td width="78%" class="vtable">
1687
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
1688
										</td>
1689
									</tr>
1690
									<tr>
1691
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
1692
										<td width="78%" class="vtable">
1693
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
1694
										</td>
1695
									</tr>
1696
									<tr name="phone_num" id="phone_num">
1697
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
1698
										<td width="78%" class="vtable">
1699
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>">
1700
										</td>
1701
									</tr>
1702
									<tr name="apn_" id="apn_">
1703
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
1704
										<td width="78%" class="vtable">
1705
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
1706
										</td>
1707
									</tr>
1708
									<tr name="interface" id="interface" >
1709
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
1710
										<td width="78%" class="vtable">
1711
											<select name="port" id="port" class="formselect">
1712
											<?php
1713
												$portlist = glob("/dev/cua*");
1714
												$modems = glob("/dev/modem*");
1715
												$portlist = array_merge($portlist, $modems);
1716
												foreach ($portlist as $port) {
1717
													if(preg_match("/\.(lock|init)$/", $port))
1718
														continue;
1719
													echo "<option value=\"".trim($port)."\"";
1720
													if ($pconfig['port'] == $port)
1721
														echo "selected";
1722
													echo ">{$port}</option>";
1723
												}?>
1724
											</select>
1725
										</td>
1726
									</tr>
1727
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
1728
										<?php if (isset($pconfig['pppid'])): ?>
1729
											<td width="78%" class="vtable">
1730
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
1731
											<?=gettext("to edit PPP configuration."); ?>
1732
											</td>
1733
										<?php else: ?>
1734
											<td width="78%" class="vtable">
1735
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
1736
											<?=gettext("to create a PPP configuration."); ?>
1737
											</td>
1738
										<?php endif; ?>
1739
									</tr>
1740
								</table>
1741
							</td>
1742
						</tr>
1743
						<tr style="display:none;" name="pppoe" id="pppoe">
1744
							<td colspan="2" style="padding:0px;">
1745
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1746
									<tr>
1747
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
1748
									</tr>
1749
									<tr>
1750
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
1751
										<td width="78%" class="vtable">
1752
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
1753
										</td>
1754
									</tr>
1755
									<tr>
1756
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
1757
										<td width="78%" class="vtable">
1758
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
1759
										</td>
1760
									</tr>
1761
									<tr>
1762
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
1763
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
1764
											<br> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
1765
										</td>
1766
									</tr>
1767
									<tr>
1768
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
1769
										<td width="78%" class="vtable">
1770
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>>
1771
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
1772
											<?=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."); ?>
1773
										</td>
1774
									</tr>
1775
									<tr>
1776
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
1777
										<td width="78%" class="vtable">
1778
											<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."); ?>
1779
										</td>
1780
									</tr>
1781
									<tr>
1782
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
1783
										<td width="78%" class="vtable">
1784
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
1785
												<tr>
1786
													<td align="left" valign="top">
1787
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
1788
														<select valign="top" id="reset_type" name="pppoe-reset-type" class="formselect" onChange="show_reset_settings(this.value);">
1789
															<option value = ""><?=gettext("Disabled"); ?></option>
1790
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?=gettext("Custom"); ?></option>
1791
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?=gettext("Pre-Set"); ?></option>
1792
														</select> <?=gettext("Select a reset timing type"); ?>
1793
														</p>
1794
														<?php if ($pconfig['pppoe_pr_custom']): ?>
1795
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
1796
														<?php else: ?>
1797
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
1798
														<?php endif; ?>
1799
														<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" />
1800
														<?=gettext("hour (0-23)"); ?><br />
1801
														<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" />
1802
														<?=gettext("minute (0-59)"); ?><br />
1803
														<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']);?>" />
1804
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
1805
														<br />&nbsp;<br />
1806
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
1807
														<?=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."); ?>
1808
														</p>
1809
														<?php if ($pconfig['pppoe_pr_preset']): ?>
1810
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
1811
														<?php else: ?>
1812
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
1813
														<?php endif; ?>
1814
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
1815
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
1816
														<br />
1817
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
1818
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
1819
														<br />
1820
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
1821
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
1822
														<br />
1823
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
1824
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
1825
														</p>
1826
													</td>
1827
												</tr>
1828
											</table>
1829
										</td>
1830
									</tr>
1831

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

    
2397
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2398
						<tr>
2399
							<td width="22%" valign="top">
2400
								&nbsp;
2401
							</td>
2402
							<td width="78%">
2403
								<br/>
2404
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2405
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2406
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2407
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2408
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2409
								<?php endif; ?>
2410
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2411
							</td>
2412
						</tr>
2413
					</table>
2414
				</td>
2415
			</tr>
2416
		</table>
2417
		<!--
2418
		</div>
2419
		</td></tr>
2420
		</table>
2421
		-->
2422
	</form>
2423
	<script type="text/javascript">
2424
		var gatewayip;
2425
		var name;
2426
		var gatewayipv6;
2427
		var namev6;
2428
		function show_add_gateway() {
2429
			document.getElementById("addgateway").style.display = '';
2430
			document.getElementById("addgwbox").style.display = 'none';
2431
			document.getElementById("gateway").style.display = 'none';
2432
			document.getElementById("save").style.display = 'none';
2433
			document.getElementById("cancel").style.display = 'none';
2434
			document.getElementById("gwsave").style.display = '';
2435
			document.getElementById("gwcancel").style.display = '';
2436
			$('notebox').innerHTML="";
2437
		}
2438
		function show_add_gateway_v6() {
2439
			document.getElementById("addgatewayv6").style.display = '';
2440
			document.getElementById("addgwboxv6").style.display = 'none';
2441
			document.getElementById("gatewayv6").style.display = 'none';
2442
			document.getElementById("save").style.display = 'none';
2443
			document.getElementById("cancel").style.display = 'none';
2444
			document.getElementById("gwsave").style.display = '';
2445
			document.getElementById("gwcancel").style.display = '';
2446
			$('noteboxv6').innerHTML="";
2447
		}
2448
		function hide_add_gateway() {
2449
			document.getElementById("addgateway").style.display = 'none';
2450
			document.getElementById("addgwbox").style.display = '';
2451
			document.getElementById("gateway").style.display = '';
2452
			document.getElementById("save").style.display = '';
2453
			document.getElementById("cancel").style.display = '';
2454
			document.getElementById("gwsave").style.display = '';
2455
			document.getElementById("gwcancel").style.display = '';
2456
		}
2457
		function hide_add_gateway_v6() {
2458
			document.getElementById("addgatewayv6").style.display = 'none';
2459
			document.getElementById("addgwboxv6").style.display = '';
2460
			document.getElementById("gatewayv6").style.display = '';
2461
			document.getElementById("save").style.display = '';
2462
			document.getElementById("cancel").style.display = '';
2463
			document.getElementById("gwsave").style.display = '';
2464
			document.getElementById("gwcancel").style.display = '';
2465
		}
2466
		function hide_add_gatewaysave() {
2467
			document.getElementById("addgateway").style.display = 'none';
2468
			$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif"> One moment please...';
2469
			var iface = $F('if');
2470
			name = $('name').getValue();
2471
			var descr = $('gatewaydescr').getValue();
2472
			gatewayip = $('gatewayip').getValue();
2473
			var defaultgw = $('defaultgw').getValue();
2474
			var url = "system_gateways_edit.php";
2475
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2476
			var myAjax = new Ajax.Request(
2477
				url,
2478
				{
2479
					method: 'post',
2480
					parameters: pars,
2481
					onFailure: report_failure,
2482
					onComplete: save_callback
2483
				});
2484
		}
2485
		function hide_add_gatewaysave_v6() {
2486
			document.getElementById("addgatewayv6").style.display = 'none';
2487
			$('statusv6').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif"> One moment please...';
2488
			var iface = $F('if');
2489
			name = $('namev6').getValue();
2490
			var descr = $('gatewaydescrv6').getValue();
2491
			gatewayip = $('gatewayipv6').getValue();
2492
			var defaultgw = $('defaultgwv6').getValue();
2493
			var url_v6 = "system_gateways_edit.php";
2494
			var pars_v6 = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2495
			var myAjax_v6 = new Ajax.Request(
2496
				url_v6,
2497
				{
2498
					method: 'post',
2499
					parameters: pars_v6,
2500
					onFailure: report_failure_v6,
2501
					onComplete: save_callback_v6
2502
				});
2503
		}
2504
		function addOption(selectbox,text,value)
2505
		{
2506
			var optn = document.createElement("OPTION");
2507
			optn.text = text;
2508
			optn.value = value;
2509
			selectbox.options.add(optn);
2510
			selectbox.selectedIndex = (selectbox.options.length-1);
2511
			$('notebox').innerHTML="<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.";
2512
		}
2513
		function addOption_v6(selectbox,text,value)
2514
		{
2515
			var optn = document.createElement("OPTION");
2516
			optn.text = text;
2517
			optn.value = value;
2518
			selectbox.options.add(optn);
2519
			selectbox.selectedIndex = (selectbox.options.length-1);
2520
			$('noteboxv6').innerHTML="<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.";
2521
		}
2522
		function report_failure() {
2523
			alert("Sorry, we could not create your IPv4 gateway at this time.");
2524
			hide_add_gateway();
2525
		}
2526
		function report_failure_v6() {
2527
			alert("Sorry, we could not create your IPv6 gateway at this time.");
2528
			hide_add_gateway_v6();
2529
		}
2530
		function save_callback(transport) {
2531
			var response = transport.responseText;
2532
			if(response) {
2533
				document.getElementById("addgateway").style.display = 'none';
2534
				hide_add_gateway();
2535
				$('status').innerHTML = '';
2536
				var gwtext = escape(name) + " - " + gatewayip;
2537
				addOption($('gateway'), gwtext, name);
2538
				// Auto submit form?
2539
				//document.iform.submit();
2540
				//$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif">';
2541
			} else {
2542
				report_failure();
2543
			}
2544
		}
2545
		function show_advanced_media() {
2546
			document.getElementById("showadvmediabox").innerHTML='';
2547
			aodiv = document.getElementById('showmediaadv');
2548
			aodiv.style.display = "block";
2549
		}
2550
		function save_callback_v6(transport) {
2551
			var response_v6 = transport.responseText;
2552
			if(response_v6) {
2553
				document.getElementById("addgatewayv6").style.display = 'none';
2554
				hide_add_gateway_v6();
2555
				$('statusv6').innerHTML = '';
2556
				var gwtext_v6 = escape(name) + " - " + gatewayip;
2557
				addOption_v6($('gatewayv6'), gwtext_v6, name);
2558
				// Auto submit form?
2559
				//document.iform.submit();
2560
				//$('statusv6').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif">';
2561
			} else {
2562
				report_failure_v6();
2563
			}
2564
		}
2565
		<?php
2566
		echo "show_allcfg(document.iform.enable);";
2567
		echo "updateType('{$pconfig['type']}');\n";
2568
		?>
2569
	</script>
2570
	<?php include("fend.inc"); ?>
2571
	</body>
2572
</html>
(87-87/232)