Project

General

Profile

Download (122 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 = explode(" ", $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['ipaddr'] = "";
197
		break;
198
	case "pppoe":
199
	case "pptp":
200
	case "l2tp":
201
	case "ppp":
202
		$pconfig['type'] = $wancfg['ipaddr'];
203
		break;
204
	default:
205
		if(is_ipaddr($wancfg['ipaddr'])) {
206
			$pconfig['type'] = "staticv4";
207
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
208
			$pconfig['subnet'] = $wancfg['subnet'];
209
			$pconfig['gateway'] = $wancfg['gateway'];
210
		} else
211
			$pconfig['type'] = "none";
212
		break;
213
}
214

    
215
switch($wancfg['ipaddrv6']) {
216
	case "dhcp6":
217
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
218
		if($wancfg['dhcp6-ia-pd-len'] == "")
219
			$wancfg['dhcp6-ia-pd-len'] = "none";
220
		$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
221
		$pconfig['type6'] = "dhcp6";
222
		break;
223
	case "6rd":
224
		$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
225
		if($wancfg['prefix-6rd-len'] == "")
226
			$wancfg['prefix-6rd-len'] = "0";
227
		$pconfig['prefix-6rd-len'] = $wancfg['prefix-6rd-len'];
228
		$pconfig['type6'] = "6rd";
229
		$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
230
		break;
231
	default:
232
		if(is_ipaddr($wancfg['ipaddrv6'])) {
233
			$pconfig['type6'] = "staticv6";
234
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
235
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
236
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
237
			$pconfig['dhcp6-pd-sla-id'] = $wancfg['dhcp6-pd-sla-id'];
238
			$pconfig['prefix-6rd-id'] = $wancfg['prefix-6rd-id'];
239
		} else
240
			$pconfig['type6'] = "none";
241
		break;
242
}
243

    
244
// print_r($pconfig);
245

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

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

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

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

    
356
					interface_bring_down($ifapply);
357
				}
358
			}
359
		}
360
		/* restart snmp so that it binds to correct address */
361
		services_snmpd_configure();
362

    
363
		/* sync filter configuration */
364
		setup_gateways_monitor();
365

    
366
		clear_subsystem_dirty('staticroutes');
367

    
368
		filter_configure();
369

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

    
396
	unset($input_errors);
397
	$pconfig = $_POST;
398
	conf_mount_rw();
399

    
400
	/* filter out spaces from descriptions  */
401
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
402

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

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

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

    
606
		if ($_POST['passphrase']) {
607
                	$passlen = strlen($_POST['passphrase']);
608
                	if ($passlen < 8 || $passlen > 64)
609
                        	$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
610
		}
611
	}
612
	if (!$input_errors) {
613
		if ($wancfg['ipaddr'] != $_POST['type']) {
614
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
615
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
616
				unset($a_ppps[$pppid]);
617
			} else if ($wancfg['ipaddrv6'] == "dhcp6") {
618
				$pid = find_dhcp6c_process($realif);
619
				if($pid)
620
					posix_kill($pid, SIGTERM);
621
			} else if ($wancfg['ipaddr'] == "dhcp") {
622
				$pid = find_dhclient_process($realif);
623
				if($pid)
624
					posix_kill($pid, SIGTERM);
625
			}
626
				
627
		}
628
		$ppp = array();
629
		if ($wancfg['ipaddr'] != "ppp")
630
			unset($wancfg['ipaddr']);
631
		if ($wancfg['ipaddrv6'] != "ppp")
632
			unset($wancfg['ipaddrv6']);
633
		unset($wancfg['subnet']);
634
		unset($wancfg['gateway']);
635
		unset($wancfg['subnetv6']);
636
		unset($wancfg['gatewayv6']);
637
		unset($wancfg['dhcphostname']);
638
		unset($wancfg['dhcp6-pd-sla-id']);
639
		unset($wancfg['dhcp6-duid']);
640
		unset($wancfg['dhcp6-ia-pd-len']);
641
		unset($wancfg['prefix-6rd']);
642
		unset($wancfg['prefix-6rd-len']);
643
		unset($wancfg['gateway-6rd']);
644
		unset($wancfg['prefix-6rd-id']);
645
		unset($wancfg['pppoe_password']);
646
		unset($wancfg['pptp_username']);
647
		unset($wancfg['pptp_password']);
648
		unset($wancfg['provider']);
649
		unset($wancfg['ondemand']);
650
		unset($wancfg['timeout']);
651
		if (isset($wancfg['pppoe']['pppoe-reset-type']))
652
			unset($wancfg['pppoe']['pppoe-reset-type']);
653
		unset($wancfg['local']);
654
		
655
		unset($wancfg['remote']);
656
		unset($a_ppps[$pppid]['apn']);
657
		unset($a_ppps[$pppid]['phone']);
658
		unset($a_ppps[$pppid]['localip']);
659
		unset($a_ppps[$pppid]['subnet']);
660
		unset($a_ppps[$pppid]['gateway']);
661
		unset($a_ppps[$pppid]['pppoe-reset-type']);
662
		unset($a_ppps[$pppid]['provider']);
663

    
664
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
665
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
666

    
667
		/* for dynamic interfaces we tack a gateway item onto the array to prevent system
668
		 * log messages from appearing. They can also manually add these items */
669
		/* 1st added gateway gets a default bit */
670
		if(!empty($a_gateways)) {
671
			$gateway_item = array();
672
			/* check for duplicates */
673
			$skip = false;
674
			foreach($a_gateways as $item) {
675
				if(($item['interface'] == "$if") && (preg_match("/dynamic/", $item['gateway']))) {
676
					$skip = true;
677
				}
678
			}
679
			if($skip == false) {
680
				$gateway_item['gateway'] = "dynamic";
681
				$gateway_item['descr'] = sprintf(gettext("Interface %s dynamic gateway"),$if);
682
				$gateway_item['name'] = "GW_" . strtoupper($if);
683
				$gateway_item['interface'] = "{$if}";
684
			} else {
685
				unset($gateway_item);
686
			}
687
		}
688

    
689
		switch($_POST['type']) {
690
			case "staticv4":
691
				$wancfg['ipaddr'] = $_POST['ipaddr'];
692
				$wancfg['subnet'] = $_POST['subnet'];
693
				if ($_POST['gateway'] != "none") {
694
					$wancfg['gateway'] = $_POST['gateway'];
695
				}
696
				break;
697
			case "dhcp":
698
				$wancfg['ipaddr'] = "dhcp";
699
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
700
				$wancfg['alias-address'] = $_POST['alias-address'];
701
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
702
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
703
				if($gateway_item) {
704
					$a_gateways[] = $gateway_item;
705
				}
706
				break;
707
			case "carpdev-dhcp":
708
				$wancfg['ipaddr'] = "carpdev-dhcp";
709
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
710
				$wancfg['alias-address'] = $_POST['alias-address'];
711
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
712
				if($gateway_item) {
713
					$a_gateways[] = $gateway_item;
714
				}
715
				break;
716
			case "ppp":
717
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
718
				$a_ppps[$pppid]['type'] = $_POST['type'];
719
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
720
				$a_ppps[$pppid]['ports'] = $_POST['port'];
721
				$a_ppps[$pppid]['username'] = $_POST['username'];
722
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
723
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
724
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
725
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
726
				$wancfg['ipaddr'] = $_POST['type'];
727
				unset($a_ppps[$pppid]['ondemand']);
728
				unset($a_ppps[$pppid]['idletimeout']);
729
				break;
730

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

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

    
761
				break;
762
			case "pptp":
763
			case "l2tp":
764
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
765
				$a_ppps[$pppid]['type'] = $_POST['type'];
766
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
767
				if (isset($_POST['ppp_port']))
768
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
769
				else
770
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
771
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
772
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
773
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
774
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
775
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
776
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
777
				if (!empty($_POST['idletimeout']))
778
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
779
				else
780
					unset($a_ppps[$pppid]['idletimeout']);
781
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
782
				$wancfg['ipaddr'] = $_POST['type'];
783
				if($gateway_item) {
784
					$a_gateways[] = $gateway_item;
785
				}
786
				break;
787
			case "none":
788
				break;
789
		}
790
		switch($_POST['type6']) {
791
			case "staticv6":
792
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
793
				$wancfg['subnetv6'] = $_POST['subnetv6'];
794
				$wancfg['dhcp6-pd-sla-id'] = $_POST['dhcp6-pd-sla-id'];
795
				$wancfg['prefix-6rd-id'] = $_POST['prefix-6rd-id'];
796
				if ($_POST['gatewayv6'] != "none") {
797
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
798
				}
799
				break;
800
			case "dhcp6":
801
				$wancfg['ipaddrv6'] = "dhcp6";
802
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
803
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
804
				if($gateway_item) {
805
					$a_gateways[] = $gateway_item;
806
				}
807
				break;
808
			case "6rd":
809
				$wancfg['ipaddrv6'] = "6rd";
810
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
811
				$wancfg['prefix-6rd-len'] = $_POST['prefix-6rd-len'];
812
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
813
				if($gateway_item) {
814
					$a_gateways[] = $gateway_item;
815
				}
816
				break;
817
			case "none":
818
				break;
819
		}
820
		handle_pppoe_reset($_POST);
821

    
822
		if($_POST['blockpriv'] == "yes") {
823
			$wancfg['blockpriv'] = true;
824
		} else {
825
			unset($wancfg['blockpriv']);
826
		}
827
		if($_POST['blockbogons'] == "yes") {
828
			$wancfg['blockbogons'] = true;
829
		} else {
830
			unset($wancfg['blockbogons']);
831
		}
832
		$wancfg['spoofmac'] = $_POST['spoofmac'];
833
		if (empty($_POST['mtu'])) {
834
			unset($wancfg['mtu']);
835
		} else {
836
			$wancfg['mtu'] = $_POST['mtu'];
837
		}
838
		if (empty($_POST['mss'])) {
839
			unset($wancfg['mss']);
840
		} else {
841
			$wancfg['mss'] = $_POST['mss'];
842
		}
843
		if (empty($_POST['mediaopt'])) {
844
			unset($wancfg['media']);
845
			unset($wancfg['mediaopt']);
846
		} else {
847
			$mediaopts = explode(' ', $_POST['mediaopt']);	
848
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
849
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
850
			else { unset($wancfg['mediaopt']); }
851
		}
852
		if (isset($wancfg['wireless'])) {
853
			handle_wireless_post();
854
		}
855

    
856
		conf_mount_ro();
857
		write_config();
858

    
859
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
860
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
861
		} else {
862
			$toapplylist = array();
863
		}
864
		$toapplylist[$if] = array();
865
		/* we need to be able remove IP aliases for IPv6 */
866
		if(($old_wancfg['ipaddrv6'] != $wancfg['ipaddrv6']) && (is_ipaddrv6($old_wancfg['ipaddrv6']))) {
867
			$toapplylist[$if]['ipaddrv6'] = $old_wancfg['ipaddrv6'];
868
		}
869
		
870
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
871

    
872
		mark_subsystem_dirty('interfaces');
873

    
874
		/* regenerate cron settings/crontab file */
875
		configure_cron();
876

    
877
		header("Location: interfaces.php?if={$if}");
878
		exit;
879
	}
880

    
881
} // end if($_POST)
882

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

    
1020
function check_wireless_mode() {
1021
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1022

    
1023
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1024
		return;
1025

    
1026
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1027
		$clone_count = 1;
1028
	else
1029
		$clone_count = 0;
1030
	if (is_array($config['wireless']['clone'])) {
1031
		foreach ($config['wireless']['clone'] as $clone) {
1032
			if ($clone['if'] == $wlanbaseif)
1033
				$clone_count++;
1034
		}
1035
	}
1036
	if ($clone_count > 1) {
1037
		$old_wireless_mode = $wancfg['wireless']['mode'];
1038
		$wancfg['wireless']['mode'] = $_POST['mode'];
1039
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1040
			$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']]);
1041
		} else {
1042
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
1043
		}
1044
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1045
	}
1046
}
1047

    
1048
// Find all possible media options for the interface
1049
$mediaopts_list = array();
1050
$intrealname = $config['interfaces'][$if]['if'];
1051
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1052
foreach ($mediaopts as $mediaopt){
1053
	preg_match("/media (.*)/", $mediaopt, $matches);
1054
 	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1055
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1056
 		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1057
	}else{
1058
		// there is only media like "media 1000baseT"
1059
		array_push($mediaopts_list, $matches[1]);
1060
	}
1061
}
1062

    
1063
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1064
$statusurl = "status_interfaces.php";
1065

    
1066
$closehead = false;
1067
include("head.inc");
1068
$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"*/);
1069
$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCP6"), "6rd" => gettext("6RD"));
1070

    
1071
?>
1072

    
1073
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1074
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1075
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1076
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1077

    
1078
<script type="text/javascript">
1079
	function updateType(t) {
1080
		switch(t) {
1081
			case "none": {
1082
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1083
				break;
1084
			}
1085
			case "staticv4": {
1086
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1087
				break;
1088
			}
1089
			case "dhcp": {
1090
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1091
				break;
1092
			}
1093
			case "ppp": {
1094
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1095
				country_list();
1096
				break;
1097
			}
1098
			case "pppoe": {
1099
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1100
				break;
1101
			}
1102
			case "l2tp":
1103
			case "pptp": {
1104
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1105
				jQuery('#pptp').show();
1106
				break;
1107
			}
1108
		}
1109
		if (t != "l2tp" && t != "pptp")
1110
			jQuery('#'+t).show();
1111
	}
1112
	function updateTypeSix(t) {
1113
		switch(t) {
1114
			case "none": {
1115
				jQuery('#staticv6, #dhcp6', '#6rd').hide();
1116
				break;
1117
			}
1118
			case "staticv6": {
1119
				jQuery('#none, #dhcp6', '#6rd').hide();
1120
				break;
1121
			}
1122
			case "dhcp6": {
1123
				jQuery('#none, #staticv6', '#6rd').hide();
1124

    
1125
				break;
1126
			}
1127
			case "6rd": {
1128
				jQuery('#none, #dhcp6', '#staticv6').hide();
1129

    
1130
				break;
1131
			}
1132
		}
1133
		if (t != "l2tp" && t != "pptp")
1134
			jQuery('#'+t).show();
1135
	}
1136

    
1137
	function show_allcfg(obj) {
1138
		if (obj.checked)
1139
			jQuery('#allcfg').show();
1140
		else
1141
			jQuery('#allcfg').hide();
1142
	}
1143

    
1144
	function show_reset_settings(reset_type) {
1145
		if (reset_type == 'preset') {
1146
			jQuery('#pppoepresetwrap').show();
1147
			jQuery('#pppoecustomwrap').hide();
1148
		}
1149
		else if (reset_type == 'custom') {
1150
			jQuery('#pppoecustomwrap').show();
1151
			jQuery('#pppoepresetwrap').hide();
1152
		} else {
1153
			jQuery('#pppoecustomwrap').hide();
1154
			jQuery('#pppoepresetwrap').hide();
1155
		}
1156
	}
1157
	function show_mon_config() {
1158
		jQuery("#showmonbox").html('');
1159
		jQuery('#showmon').css('display','block');
1160
	}
1161

    
1162
	function openwindow(url) {
1163
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1164
		if (oWin==null || typeof(oWin)=="undefined")
1165
			return false;
1166
		else
1167
			return true;
1168
	}
1169
	function country_list() {
1170
		jQuery('#country').children().remove();
1171
		jQuery('#provider').children().remove();
1172
		jQuery('#providerplan').children().remove();
1173
		jQuery.ajax("getserviceproviders.php",{
1174
			success: function(response) {
1175
				var responseTextArr = response.split("\n");
1176
				responseTextArr.sort();
1177
				responseTextArr.each( function(value) {
1178
					var option = new Element('option');
1179
					country = value.split(":");
1180
					option.text = country[0];
1181
					option.value = country[1];
1182
					jQuery('#country').append(option);
1183
				});
1184
			}
1185
		});
1186
		jQuery('#trcountry').css('display',"table-row");
1187
	}
1188

    
1189
	function providers_list() {
1190
		jQuery('#provider').children().remove();
1191
		jQuery('#providerplan').children().remove();
1192
		jQuery.ajax("getserviceproviders.php",{
1193
			type: 'post',
1194
			data: {country : jQuery('#country').val()},
1195
			success: function(response) {
1196
				var responseTextArr = response.split("\n");
1197
				responseTextArr.sort();
1198
				responseTextArr.each( function(value) {
1199
					var option = new Element('option');
1200
					option.text = value;
1201
					option.value = value;
1202
					jQuery('#provider').append(option);
1203
				});
1204
			}
1205
		});
1206
		jQuery('#trprovider').css("display","table-row");
1207
		jQuery('#trproviderplan').css("display","none");
1208
	}
1209

    
1210
	function providerplan_list() {
1211
		jQuery('#providerplan').children().remove();
1212
		jQuery('#providerplan').append( new Element('option') );
1213
		jQuery.ajax("getserviceproviders.php",{
1214
			type: 'post',
1215
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1216
			success: function(response) {
1217
				var responseTextArr = response.split("\n");
1218
				responseTextArr.sort();
1219
				responseTextArr.each( function(value) {
1220
					if(value != "") {
1221
						providerplan = value.split(":");
1222

    
1223
						var option = new Element('option');
1224
						option.text = providerplan[0] + " - " + providerplan[1];
1225
						option.value = providerplan[1];
1226
						jQuery('#providerplan').append(option);
1227
					}
1228
				});
1229
			}
1230
		});
1231
		jQuery('#trproviderplan').css("display","table-row");
1232
	}
1233

    
1234
	function prefill_provider() {
1235
		jQuery.ajax("getserviceproviders.php",{
1236
			type: 'post',
1237
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
1238
			success: function(data,textStatus,response) {
1239
				var xmldoc = response.responseXML;
1240
				var provider = xmldoc.getElementsByTagName('connection')[0];
1241
				jQuery('#username').val('');
1242
				jQuery('#password').val('');
1243
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1244
					jQuery('#phone').val('#777');
1245
					jQuery('#apn').val('');
1246
				} else {
1247
					jQuery('#phone').val('*99#');
1248
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1249
				}
1250
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1251
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1252
				jQuery('#username').val(username);
1253
				jQuery('#password').val(password);
1254
			}
1255
		});
1256
	}
1257

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

    
1486

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

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

    
2577
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2578
						<tr>
2579
							<td width="22%" valign="top">
2580
								&nbsp;
2581
							</td>
2582
							<td width="78%">
2583
								<br/>
2584
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2585
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2586
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2587
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2588
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2589
								<?php endif; ?>
2590
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2591
							</td>
2592
						</tr>
2593
					</table>
2594
				</td>
2595
			</tr>
2596
		</table>
2597
		<!--
2598
		</div>
2599
		</td></tr>
2600
		</table>
2601
		-->
2602
	</form>
2603
	<script type="text/javascript">
2604
		var gatewayip;
2605
		var name;
2606
		var gatewayipv6;
2607
		var namev6;
2608
		function show_add_gateway() {
2609
			document.getElementById("addgateway").style.display = '';
2610
			document.getElementById("addgwbox").style.display = 'none';
2611
			document.getElementById("gateway").style.display = 'none';
2612
			document.getElementById("save").style.display = 'none';
2613
			document.getElementById("cancel").style.display = 'none';
2614
			document.getElementById("gwsave").style.display = '';
2615
			document.getElementById("gwcancel").style.display = '';
2616
			jQuery('#notebox').html("");
2617
		}
2618
		function show_add_gateway_v6() {
2619
			document.getElementById("addgatewayv6").style.display = '';
2620
			document.getElementById("addgwboxv6").style.display = 'none';
2621
			document.getElementById("gatewayv6").style.display = 'none';
2622
			document.getElementById("save").style.display = 'none';
2623
			document.getElementById("cancel").style.display = 'none';
2624
			document.getElementById("gwsave").style.display = '';
2625
			document.getElementById("gwcancel").style.display = '';
2626
			jQuery('#noteboxv6').html("");
2627
		}
2628
		function hide_add_gateway() {
2629
			document.getElementById("addgateway").style.display = 'none';
2630
			document.getElementById("addgwbox").style.display = '';
2631
			document.getElementById("gateway").style.display = '';
2632
			document.getElementById("save").style.display = '';
2633
			document.getElementById("cancel").style.display = '';
2634
			document.getElementById("gwsave").style.display = '';
2635
			document.getElementById("gwcancel").style.display = '';
2636
		}
2637
		function hide_add_gateway_v6() {
2638
			document.getElementById("addgatewayv6").style.display = 'none';
2639
			document.getElementById("addgwboxv6").style.display = '';
2640
			document.getElementById("gatewayv6").style.display = '';
2641
			document.getElementById("save").style.display = '';
2642
			document.getElementById("cancel").style.display = '';
2643
			document.getElementById("gwsave").style.display = '';
2644
			document.getElementById("gwcancel").style.display = '';
2645
		}
2646
		function hide_add_gatewaysave() {
2647
			document.getElementById("addgateway").style.display = 'none';
2648
			jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2649
			var iface = jQuery('#if').val();
2650
			name = jQuery('#name').val();
2651
			var descr = jQuery('#gatewaydescr').val();
2652
			gatewayip = jQuery('#gatewayip').val();
2653

    
2654
			var defaultgw = jQuery('#defaultgw').val();
2655
			var url = "system_gateways_edit.php";
2656
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2657
			jQuery.ajax(
2658
				url,
2659
				{
2660
					type: 'post',
2661
					data: pars,
2662
					error: report_failure,
2663
					complete: save_callback
2664
				});
2665
		}
2666
		function hide_add_gatewaysave_v6() {
2667
			document.getElementById("addgatewayv6").style.display = 'none';
2668
			jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2669
			var iface = jQuery('#if').val();
2670
			name = jQuery('#namev6').val();
2671
			var descr = jQuery('#gatewaydescrv6').val();
2672
			gatewayip = jQuery('#gatewayipv6').val();
2673
			var defaultgw = jQuery('#defaultgwv6').val();
2674
			var url_v6 = "system_gateways_edit.php";
2675
			var pars_v6 = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2676
			jQuery.ajax(
2677
				url_v6,
2678
				{
2679
					type: 'post',
2680
					data: pars_v6,
2681
					error: report_failure_v6,
2682
					complete: save_callback_v6
2683
				});
2684
		}
2685
		function addOption(selectbox,text,value)
2686
		{
2687
			var optn = document.createElement("OPTION");
2688
			optn.text = text;
2689
			optn.value = value;
2690
			selectbox.append(optn);
2691
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2692
			jQuery('#notebox').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2693
		}
2694
		function addOption_v6(selectbox,text,value)
2695
		{
2696
			var optn = document.createElement("OPTION");
2697
			optn.text = text;
2698
			optn.value = value;
2699
			selectbox.append(optn);
2700
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2701
			jQuery('#noteboxv6').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2702
		}
2703
		function report_failure() {
2704
			alert("Sorry, we could not create your IPv4 gateway at this time.");
2705
			hide_add_gateway();
2706
		}
2707
		function report_failure_v6() {
2708
			alert("Sorry, we could not create your IPv6 gateway at this time.");
2709
			hide_add_gateway_v6();
2710
		}
2711
		function save_callback(transport) {
2712
			var response = transport.responseText;
2713
			if(response) {
2714
				document.getElementById("addgateway").style.display = 'none';
2715
				hide_add_gateway();
2716
				jQuery('#status').html('');
2717
				var gwtext = escape(name) + " - " + gatewayip;
2718
				addOption(jQuery('#gateway'), gwtext, name);
2719
				// Auto submit form?
2720
				//document.iform.submit();
2721
				//jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif">');
2722
			} else {
2723
				report_failure();
2724
			}
2725
		}
2726
		function show_advanced_media() {
2727
			document.getElementById("showadvmediabox").innerHTML='';
2728
			aodiv = document.getElementById('showmediaadv');
2729
			aodiv.style.display = "block";
2730
		}
2731
		function save_callback_v6(transport) {
2732
			var response_v6 = transport.responseText;
2733
			if(response_v6) {
2734
				document.getElementById("addgatewayv6").style.display = 'none';
2735
				hide_add_gateway_v6();
2736
				jQuery('#statusv6').html('');
2737
				var gwtext_v6 = escape(name) + " - " + gatewayip;
2738
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
2739
				// Auto submit form?
2740
				//document.iform.submit();
2741
				//jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif">');
2742
			} else {
2743
				report_failure_v6();
2744
			}
2745
		}
2746
		<?php
2747
		echo "show_allcfg(document.iform.enable);";
2748
		echo "updateType('{$pconfig['type']}');\n";
2749
		echo "updateTypeSix('{$pconfig['type6']}');\n";
2750
		?>
2751
	</script>
2752
	<?php include("fend.inc"); ?>
2753
	</body>
2754
</html>
(89-89/238)