Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
95

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

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

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

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

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

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

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

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

    
216
switch($wancfg['ipaddrv6']) {
217
	case "dhcp6":
218
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
219
		if($wancfg['dhcp6-ia-pd-len'] == "")
220
			$wancfg['dhcp6-ia-pd-len'] = "none";
221
		$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
222
		$pconfig['type6'] = "dhcp6";
223
		break;
224
	default:
225
		if(is_ipaddr($wancfg['ipaddrv6'])) {
226
			$pconfig['type6'] = "staticv6";
227
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
228
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
229
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
230
			$pconfig['dhcp6-pd-sla-id'] = $wancfg['dhcp6-pd-sla-id'];
231
		} else
232
			$pconfig['type6'] = "none";
233
		break;
234
}
235

    
236
// print_r($pconfig);
237

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

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

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

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

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

    
354
		clear_subsystem_dirty('staticroutes');
355

    
356
		filter_configure();
357

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

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

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

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

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

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

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

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

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

    
667
		switch($_POST['type']) {
668
			case "staticv4":
669
				$wancfg['ipaddr'] = $_POST['ipaddr'];
670
				$wancfg['subnet'] = $_POST['subnet'];
671
				if ($_POST['gateway'] != "none") {
672
					$wancfg['gateway'] = $_POST['gateway'];
673
				}
674
				break;
675
			case "dhcp":
676
				$wancfg['ipaddr'] = "dhcp";
677
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
678
				$wancfg['alias-address'] = $_POST['alias-address'];
679
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
680
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
681
				if($gateway_item) {
682
					$a_gateways[] = $gateway_item;
683
				}
684
				break;
685
			case "carpdev-dhcp":
686
				$wancfg['ipaddr'] = "carpdev-dhcp";
687
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
688
				$wancfg['alias-address'] = $_POST['alias-address'];
689
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
690
				if($gateway_item) {
691
					$a_gateways[] = $gateway_item;
692
				}
693
				break;
694
			case "ppp":
695
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
696
				$a_ppps[$pppid]['type'] = $_POST['type'];
697
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
698
				$a_ppps[$pppid]['ports'] = $_POST['port'];
699
				$a_ppps[$pppid]['username'] = $_POST['username'];
700
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
701
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
702
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
703
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
704
				$wancfg['ipaddr'] = $_POST['type'];
705
				unset($a_ppps[$pppid]['ondemand']);
706
				unset($a_ppps[$pppid]['idletimeout']);
707
				break;
708

    
709
			case "pppoe":
710
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
711
				$a_ppps[$pppid]['type'] = $_POST['type'];
712
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
713
				if (isset($_POST['ppp_port']))
714
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
715
				else
716
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
717
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
718
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
719
				if (!empty($_POST['provider']))
720
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
721
				else
722
					$a_ppps[$pppid]['provider'] = true;
723
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
724
				if (!empty($_POST['idletimeout']))
725
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
726
				else
727
					unset($a_ppps[$pppid]['idletimeout']);
728

    
729
				if (!empty($_POST['pppoe-reset-type']))
730
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
731
				else
732
					unset($a_ppps[$pppid]['pppoe-reset-type']);
733
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
734
				$wancfg['ipaddr'] = $_POST['type'];
735
				if($gateway_item) {
736
					$a_gateways[] = $gateway_item;
737
				}
738

    
739
				break;
740
			case "pptp":
741
			case "l2tp":
742
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
743
				$a_ppps[$pppid]['type'] = $_POST['type'];
744
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
745
				if (isset($_POST['ppp_port']))
746
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
747
				else
748
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
749
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
750
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
751
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
752
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
753
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
754
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
755
				if (!empty($_POST['idletimeout']))
756
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
757
				else
758
					unset($a_ppps[$pppid]['idletimeout']);
759
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
760
				$wancfg['ipaddr'] = $_POST['type'];
761
				if($gateway_item) {
762
					$a_gateways[] = $gateway_item;
763
				}
764
				break;
765
			case "none":
766
				break;
767
		}
768
		switch($_POST['type6']) {
769
			case "staticv6":
770
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
771
				$wancfg['subnetv6'] = $_POST['subnetv6'];
772
				$wancfg['dhcp6-pd-sla-id'] = $_POST['dhcp6-pd-sla-id'];
773
				if ($_POST['gatewayv6'] != "none") {
774
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
775
				}
776
				break;
777
			case "dhcp6":
778
				$wancfg['ipaddrv6'] = "dhcp6";
779
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
780
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
781
				if($gateway_item) {
782
					$a_gateways[] = $gateway_item;
783
				}
784
				break;
785
			case "none":
786
				break;
787
		}
788
		handle_pppoe_reset($_POST);
789

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

    
824
		conf_mount_ro();
825
		write_config();
826

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

    
840
		mark_subsystem_dirty('interfaces');
841

    
842
		/* regenerate cron settings/crontab file */
843
		configure_cron();
844

    
845
		header("Location: interfaces.php?if={$if}");
846
		exit;
847
	}
848

    
849
} // end if($_POST)
850

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

    
984
function check_wireless_mode() {
985
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
986

    
987
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
988
		return;
989

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

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

    
1027
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1028
$statusurl = "status_interfaces.php";
1029

    
1030
$closehead = false;
1031
include("head.inc");
1032
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP") /* , "carpdev-dhcp" => "CarpDev"*/);
1033
$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCP6"));
1034

    
1035
?>
1036

    
1037
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1038
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1039
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1040
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1041

    
1042
<script type="text/javascript">
1043
	function updateType(t) {
1044
		switch(t) {
1045
			case "none": {
1046
				$('staticv4', 'dhcp', 'pppoe','pptp', 'ppp').invoke('hide');
1047
				break;
1048
			}
1049
			case "staticv4": {
1050
				$('none', 'dhcp', 'pppoe', 'pptp', 'ppp').invoke('hide');
1051
				break;
1052
			}
1053
			case "dhcp": {
1054
				$('none', 'staticv4', 'pppoe', 'pptp', 'ppp').invoke('hide');
1055
				break;
1056
			}
1057
			case "ppp": {
1058
				$('none', 'staticv4', 'dhcp', 'pptp', 'pppoe').invoke('hide');
1059
				country_list();
1060
				break;
1061
			}
1062
			case "pppoe": {
1063
				$('none', 'staticv4', 'dhcp', 'pptp', 'ppp').invoke('hide');
1064
				break;
1065
			}
1066
			case "l2tp":
1067
			case "pptp": {
1068
				$('none', 'staticv4', 'dhcp', 'pppoe', 'ppp').invoke('hide');
1069
				$('pptp').show();
1070
				break;
1071
			}
1072
		}
1073
		if (t != "l2tp" && t != "pptp")
1074
			$(t).show();
1075
	}
1076
	function updateTypeSix(t) {
1077
		switch(t) {
1078
			case "none": {
1079
				$('staticv6', 'dhcp6').invoke('hide');
1080
				break;
1081
			}
1082
			case "staticv6": {
1083
				$('none', 'dhcp6').invoke('hide');
1084
				break;
1085
			}
1086
			case "dhcp6": {
1087
				$('none', 'staticv6').invoke('hide');
1088
				break;
1089
			}
1090
		}
1091
		if (t != "l2tp" && t != "pptp")
1092
			$(t).show();
1093
	}
1094
	function show_allcfg(obj) {
1095
		if (obj.checked)
1096
			$('allcfg').show();
1097
		else
1098
			$('allcfg').hide();
1099
	}
1100

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

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

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

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

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

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

    
1211
</script>
1212
</head>
1213
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1214
	<?php include("fbegin.inc"); ?>
1215
	<form action="interfaces.php" method="post" name="iform" id="iform">
1216
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1217
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1218
		<?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 />
1219
		<?php endif; ?>
1220
		<?php if ($savemsg) print_info_box($savemsg); ?>
1221
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
1222
			<tr>
1223
				<td id="mainarea">
1224
					<div class="tabcont">
1225
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1226
						<tr>
1227
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1228
						</tr>
1229
						<tr>
1230
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1231
							<td width="78%" class="vtable">
1232
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked"; ?> onClick="show_allcfg(this);">
1233
							<strong><?=gettext("Enable Interface"); ?></strong>
1234
							</td>
1235
						</tr>
1236
					</table>
1237
					<div style="display:none;" name="allcfg" id="allcfg">
1238
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1239
						<tr>
1240
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1241
							<td width="78%" class="vtable">
1242
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
1243
								<br><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1244
							</td>
1245
						</tr>
1246
						<tr>
1247
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1248
							<td class="vtable">
1249
								<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
1250
								<?php
1251
									foreach ($types4 as $key => $opt) {
1252
										echo "<option onClick=\"updateType('{$key}');\"";
1253
										if ($key == $pconfig['type'])
1254
											echo " selected";
1255
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1256
										echo "</option>";
1257
									}
1258
								?>
1259
								</select>
1260
							</td>
1261
						</tr>
1262
						<tr>
1263
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1264
							<td class="vtable">
1265
								<select name="type6" onChange="updateTypeSix(this.value);" class="formselect" id="type6">
1266
								<?php
1267
									foreach ($types6 as $key => $opt) {
1268
										echo "<option onClick=\"updateTypeSix('{$key}');\"";
1269
										if ($key == $pconfig['type6'])
1270
											echo " selected";
1271
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1272
										echo "</option>";
1273
									}
1274
								?>
1275
								</select>
1276
							</td>
1277
						</tr>
1278
						<tr>
1279
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1280
							<td class="vtable">
1281
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
1282
								<?php
1283
									$ip = getenv('REMOTE_ADDR');
1284
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1285
									$mac = str_replace("\n","",$mac);
1286
									if($mac):
1287
								?>
1288
									<a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1289
								<?php endif; ?>
1290
								<br>
1291
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1292
								"address of this interface"); ?><br>
1293
								<?=gettext("(may be required with some cable connections)"); ?><br>
1294
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1295
								"or leave blank"); ?>
1296
							</td>
1297
						</tr>
1298
						<tr>
1299
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1300
							<td class="vtable">
1301
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
1302
								<br>
1303
								<?=gettext("If you leave this field blank, the adapter's default MTU will " .
1304
								"be used. This is typically 1500 bytes but can vary on some hardware."); ?>
1305
							</td>
1306
						</tr>
1307
						<tr>
1308
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1309
							<td class="vtable">
1310
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>">
1311
								<br>
1312
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1313
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1314
								"header size) will be in effect."); ?>
1315
							</td>
1316
						</tr>
1317
						<?php 
1318
						if (count($mediaopts_list) > 0){
1319
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1320
						echo "<tr>";
1321
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1322
							echo '<td class="vtable">';
1323
                                			echo '<div id="showadvmediabox"';
1324
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1325
								else echo '>';
1326
								echo '<input type="button" onClick="show_advanced_media()" value="' . gettext("Advanced") . '"></input> - ' . gettext("Show advanced option");
1327
							echo "</div>";
1328
							echo '<div id="showmediaadv" ';
1329
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1330
							else echo '>';
1331
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1332
								print "<option value=\"\">Default</option>";
1333
								foreach($mediaopts_list as $mediaopt){
1334
									if ($mediaopt != rtrim($mediaopt_from_config)){
1335
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1336
									} else {
1337
										print "<option value=\"$mediaopt\" selected>" . gettext("$mediaopt") . "</option>";
1338
									}
1339
								}
1340
								echo '</select><br>';
1341
								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.");
1342
						echo '</div>';
1343
							echo '</td>';
1344
						echo '</tr>';
1345
						}
1346
						?>
1347
						<tr>
1348
							<td colspan="2" valign="top" height="16"></td>
1349
						</tr>
1350
						<tr style="display:none;" name="none" id="none">
1351
						</tr>
1352
						<tr style="display:none;" name="staticv4" id="staticv4">
1353
							<td colspan="2" style="padding:0px;">
1354
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1355
									<tr>
1356
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1357
									</tr>
1358
									<tr>
1359
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1360
										<td width="78%" class="vtable">
1361
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
1362
											/
1363
											<select name="subnet" class="formselect" id="subnet">
1364
												<?php
1365
												for ($i = 32; $i > 0; $i--) {
1366
													if($i <> 31) {
1367
														echo "<option value=\"{$i}\" ";
1368
														if ($i == $pconfig['subnet']) echo "selected";
1369
														echo ">" . $i . "</option>";
1370
													}
1371
												}
1372
												?>
1373
											</select>
1374
										</td>
1375
									</tr>
1376
									<tr>
1377
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway"); ?></td>
1378
										<td width="78%" class="vtable">
1379
											<select name="gateway" class="formselect" id="gateway">
1380
												<option value="none" selected><?=gettext("None"); ?></option>
1381
													<?php
1382
													if(count($a_gateways) > 0) {
1383
														foreach ($a_gateways as $gateway) {
1384
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1385
													?>
1386
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
1387
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1388
															</option>
1389
													<?php
1390
															}
1391
														}
1392
													}
1393
													?>
1394
											</select>
1395
											- or  <strong><a OnClick="show_add_gateway();" href="#"><?=gettext("add a new one."); ?></a></strong>
1396
											<br/>
1397
											<div id='addgwbox'>
1398
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add one using the link above"); ?>
1399
											</div>
1400
											<div id='notebox'>
1401
											</div>
1402
											<div id="status">
1403
											</div>
1404
											<div style="display:none" id="addgateway" name="addgateway">
1405
												<p>
1406
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1407
													<tr>
1408
														<td>
1409
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1410
																<tr><td>&nbsp;</td>
1411
																<tr>
1412
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1413
																</tr>
1414
																<tr><td>&nbsp;</td>
1415
																<?php
1416
																if($if == "wan" || $if == "WAN")
1417
																	$checked = " CHECKED";
1418
																?>
1419
																<tr>
1420
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
1421
																</tr>
1422
																<tr>
1423
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td>
1424
																</tr>
1425
																<tr>
1426
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></td><td><input id="gatewayip" name="gatewayip"></td>
1427
																</tr>
1428
																<tr>
1429
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1430
																</tr>
1431
																<tr><td>&nbsp;</td>
1432
																<tr>
1433
																	<td>&nbsp;</td>
1434
																	<td>
1435
																		<center>
1436
																			<div id='savebuttondiv'>
1437
																				<input id="gwsave" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave();'>
1438
																				<input id="gwcancel" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway();'>
1439
																			</div>
1440
																		</center>
1441
																	</td>
1442
																</tr>
1443
																<tr><td>&nbsp;</td></tr>
1444
															</table>
1445
														</td>
1446
													</tr>
1447
												</table>
1448
												<p/>
1449
											</div>
1450
										</td>
1451
									</tr>
1452
								</table>
1453
							</td>
1454
						</tr>
1455
						<tr style="display:none;" name="staticv6" id="staticv6">
1456
							<td colspan="2" style="padding:0px;">
1457
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1458
									<tr>
1459
										<td colspan="2" valign="top">&nbsp;</td>
1460
									</tr>
1461
									<tr>
1462
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1463
									</tr>
1464
									<tr>
1465
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1466
										<td width="78%" class="vtable">
1467
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>">
1468
											/
1469
											<select name="subnetv6" class="formselect" id="subnetv6">
1470
												<?php
1471
												for ($i = 128; $i > 0; $i--) {
1472
													if($i <> 127) {
1473
														echo "<option value=\"{$i}\" ";
1474
														if ($i == $pconfig['subnetv6']) echo "selected";
1475
														echo ">" . $i . "</option>";
1476
													}
1477
												}
1478
												?>
1479
											</select>
1480
										</td>
1481
									</tr>
1482
									<tr>
1483
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway IPv6"); ?></td>
1484
										<td width="78%" class="vtable">
1485
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1486
												<option value="none" selected><?=gettext("None"); ?></option>
1487
													<?php
1488
													if(count($a_gateways) > 0) {
1489
														foreach ($a_gateways as $gateway) {
1490
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1491
													?>
1492
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected"; ?>>
1493
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1494
															</option>
1495
													<?php
1496
															}
1497
														}
1498
													}
1499
													?>
1500
											</select>
1501
											- or <strong><a OnClick="show_add_gateway_v6();" href="#"><?=gettext("add a new one."); ?></a></strong>
1502
											<br/>
1503
											<div id='addgwboxv6'>
1504
											<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above"); ?>
1505
											</div>
1506
											<div id='noteboxv6'>
1507
											</div>
1508
											<div id="statusv6">
1509
											</div>
1510
											<div style="display:none" id="addgatewayv6" name="addgatewayv6">
1511
												<p>
1512
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1513
													<tr>
1514
														<td>
1515
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1516
																<tr><td>&nbsp;</td>
1517
																<tr>
1518
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1519
																</tr>
1520
																<tr><td>&nbsp;</td>
1521
																<?php
1522
																if($if == "wan" || $if == "WAN")
1523
																	$checked = " CHECKED";
1524
																?>
1525
																<tr>
1526
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?>></td>
1527
																</tr>
1528
																<tr>
1529
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>"></td>
1530
																</tr>
1531
																<tr>
1532
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></td><td><input id="gatewayipv6" name="gatewayipv6"></td>
1533
																</tr>
1534
																<tr>
1535
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescrv6" name="gatewaydescrv6"></td>
1536
																</tr>
1537
																<tr><td>&nbsp;</td>
1538
																<tr>
1539
																	<td>&nbsp;</td>
1540
																	<td>
1541
																		<center>
1542
																			<div id='savebuttondivv6'>
1543
																				<input id="gwsavev6" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave_v6();'>
1544
																				<input id="gwcancelv6" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway_v6();'>
1545
																			</div>
1546
																		</center>
1547
																	</td>
1548
																</tr>
1549
																<tr><td>&nbsp;</td></tr>
1550
															</table>
1551
														</td>
1552
													</tr>
1553
												</table>
1554
												<p/>
1555
											</div>
1556
										</td>
1557
									</tr>
1558
									<tr>
1559
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation ID"); ?></td>
1560
										<td width="78%" class="vtable">
1561
											<select name="dhcp6-pd-sla-id" class="formselect" id="dhcp6-pd-sla-id">
1562
												<option value="none" selected><?=gettext("None"); ?></option>
1563
												<?php
1564
												// Needs to check if the ID is not used on another interface
1565
												foreach($ifdescrs as $pdif => $pddescr) {
1566
													if($config['interfaces'][$pdif]['dhcp6-ia-pd-len'] > 0) {
1567
														$pdlen = $config['interfaces'][$pdif]['dhcp6-ia-pd-len'];
1568
														continue;
1569
													}
1570
												}
1571
												$numbers = pow(2, $pdlen);
1572
												$i = 0;
1573
												while($i < $numbers) {
1574
													if($i <> $number) {
1575
														echo "<option value=\"{$i}\" ";
1576
														if ($i == $pconfig['dhcp6-pd-sla-id']) echo "selected";
1577
														echo ">" . dechex($i) . "</option>";
1578
													}
1579
													$i++;
1580
												}
1581
												?> 
1582
											</select>
1583
											<?=gettext("This ID sets the delegated DHCP-PD prefix number which will be used to setup the interface.");?>
1584
										</td>
1585
									</tr>
1586
								</table>
1587
							</td>
1588
						</tr>
1589
						<tr style="display:none;" name="dhcp" id="dhcp">
1590
							<td colspan="2" style="padding: 0px;">
1591
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1592
									<tr>
1593
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration"); ?></td>
1594
									</tr>
1595
									<!-- Uncomment to expose DHCP+ in GUI
1596
									<tr>
1597
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1598
										<td width="78%" class="vtable">
1599
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked"; ?> >
1600
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1601
										<br/>
1602
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
1603
										</td>
1604
									</tr>
1605
									-->
1606
									<tr>
1607
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1608
										<td width="78%" class="vtable">
1609
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1610
											<br>
1611
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1612
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1613
											"this (for client identification)."); ?>
1614
										</td>
1615
									</tr>
1616
									<tr>
1617
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
1618
										<td width="78%" class="vtable">
1619
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
1620
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1621
												<?php
1622
												for ($i = 32; $i > 0; $i--) {
1623
													if($i <> 31) {
1624
														echo "<option value=\"{$i}\" ";
1625
														if ($i == $pconfig['alias-subnet']) echo "selected";
1626
														echo ">" . $i . "</option>";
1627
													}
1628
												}
1629
												?>
1630
											</select>
1631
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
1632
											"DHCP client."); ?>
1633
										</td>
1634
									</tr>									
1635
								</table>
1636
							</td>
1637
						</tr>
1638
						<tr style="display:none;" name="dhcp6" id="dhcp6">
1639
							<td colspan="2" style="padding: 0px;">
1640
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1641
									<tr>
1642
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration"); ?></td>
1643
									</tr>
1644
									<tr>
1645
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
1646
										<td width="78%" class="vtable">
1647
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>">
1648
											<br>
1649
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
1650
											"when requesting a DHCPv6 lease."); ?><br />
1651
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
1652
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
1653
												}
1654
												printf(gettext("The current DUID is: '%s'"),$current_duid);
1655
											?>
1656
											
1657
										</td>
1658
									</tr>
1659
									<tr>
1660
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
1661
										<td width="78%" class="vtable">
1662
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
1663
												<?php
1664
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
1665
												foreach($sizes as $bits => $length) {
1666
													echo "<option value=\"{$bits}\" ";
1667
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected";
1668
													echo ">" . $length . "</option>";
1669
												}
1670
												?>
1671
											</select>
1672
											<br>
1673
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
1674
										</td>
1675
									</tr>
1676
									
1677
								</table>
1678
							</td>
1679
						</tr>
1680
						<tr style="display:none;" name="ppp" id="ppp">
1681
							<td colspan="2" style="padding: 0px;">
1682
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1683
									<tr>
1684
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
1685
									</tr>
1686
									<tr name="ppp_provider" id="ppp_provider">
1687
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
1688
										<td width="78%" class="vtable">
1689
											<table border="0" cellpadding="0" cellspacing="0">
1690
												<tr id="trcountry">
1691
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
1692
													<td>
1693
														<select class="formselect" name="country" id="country" onChange="providers_list()">
1694
															<option></option>
1695
														</select>
1696
													</td>
1697
												</tr>
1698
												<tr id="trprovider" style="display:none">
1699
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
1700
													<td>
1701
														<select class="formselect" name="provider" id="provider" onChange="providerplan_list()">
1702
															<option></option>
1703
														</select>
1704
													</td>
1705
												</tr>
1706
												<tr id="trproviderplan" style="display:none">
1707
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
1708
													<td>
1709
														<select class="formselect" name="providerplan" id="providerplan" onChange="prefill_provider()">
1710
															<option></option>
1711
														</select>
1712
													</td>
1713
												</tr>
1714
											</table>
1715
											<br/><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
1716
										</td>
1717
									</tr>
1718
									<tr>
1719
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
1720
										<td width="78%" class="vtable">
1721
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
1722
										</td>
1723
									</tr>
1724
									<tr>
1725
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
1726
										<td width="78%" class="vtable">
1727
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
1728
										</td>
1729
									</tr>
1730
									<tr name="phone_num" id="phone_num">
1731
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
1732
										<td width="78%" class="vtable">
1733
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>">
1734
										</td>
1735
									</tr>
1736
									<tr name="apn_" id="apn_">
1737
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
1738
										<td width="78%" class="vtable">
1739
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
1740
										</td>
1741
									</tr>
1742
									<tr name="interface" id="interface" >
1743
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
1744
										<td width="78%" class="vtable">
1745
											<select name="port" id="port" class="formselect">
1746
											<?php
1747
												$portlist = glob("/dev/cua*");
1748
												$modems = glob("/dev/modem*");
1749
												$portlist = array_merge($portlist, $modems);
1750
												foreach ($portlist as $port) {
1751
													if(preg_match("/\.(lock|init)$/", $port))
1752
														continue;
1753
													echo "<option value=\"".trim($port)."\"";
1754
													if ($pconfig['port'] == $port)
1755
														echo "selected";
1756
													echo ">{$port}</option>";
1757
												}?>
1758
											</select>
1759
										</td>
1760
									</tr>
1761
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
1762
										<?php if (isset($pconfig['pppid'])): ?>
1763
											<td width="78%" class="vtable">
1764
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
1765
											<?=gettext("to edit PPP configuration."); ?>
1766
											</td>
1767
										<?php else: ?>
1768
											<td width="78%" class="vtable">
1769
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
1770
											<?=gettext("to create a PPP configuration."); ?>
1771
											</td>
1772
										<?php endif; ?>
1773
									</tr>
1774
								</table>
1775
							</td>
1776
						</tr>
1777
						<tr style="display:none;" name="pppoe" id="pppoe">
1778
							<td colspan="2" style="padding:0px;">
1779
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1780
									<tr>
1781
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
1782
									</tr>
1783
									<tr>
1784
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
1785
										<td width="78%" class="vtable">
1786
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
1787
										</td>
1788
									</tr>
1789
									<tr>
1790
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
1791
										<td width="78%" class="vtable">
1792
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
1793
										</td>
1794
									</tr>
1795
									<tr>
1796
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
1797
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
1798
											<br> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
1799
										</td>
1800
									</tr>
1801
									<tr>
1802
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
1803
										<td width="78%" class="vtable">
1804
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>>
1805
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
1806
											<?=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."); ?>
1807
										</td>
1808
									</tr>
1809
									<tr>
1810
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
1811
										<td width="78%" class="vtable">
1812
											<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."); ?>
1813
										</td>
1814
									</tr>
1815
									<tr>
1816
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
1817
										<td width="78%" class="vtable">
1818
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
1819
												<tr>
1820
													<td align="left" valign="top">
1821
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
1822
														<select valign="top" id="reset_type" name="pppoe-reset-type" class="formselect" onChange="show_reset_settings(this.value);">
1823
															<option value = ""><?=gettext("Disabled"); ?></option>
1824
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?=gettext("Custom"); ?></option>
1825
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?=gettext("Pre-Set"); ?></option>
1826
														</select> <?=gettext("Select a reset timing type"); ?>
1827
														</p>
1828
														<?php if ($pconfig['pppoe_pr_custom']): ?>
1829
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
1830
														<?php else: ?>
1831
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
1832
														<?php endif; ?>
1833
														<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" />
1834
														<?=gettext("hour (0-23)"); ?><br />
1835
														<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" />
1836
														<?=gettext("minute (0-59)"); ?><br />
1837
														<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']);?>" />
1838
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
1839
														<br />&nbsp;<br />
1840
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
1841
														<?=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."); ?>
1842
														</p>
1843
														<?php if ($pconfig['pppoe_pr_preset']): ?>
1844
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
1845
														<?php else: ?>
1846
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
1847
														<?php endif; ?>
1848
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
1849
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
1850
														<br />
1851
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
1852
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
1853
														<br />
1854
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
1855
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
1856
														<br />
1857
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
1858
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
1859
														</p>
1860
													</td>
1861
												</tr>
1862
											</table>
1863
										</td>
1864
									</tr>
1865

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

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