Project

General

Profile

Download (120 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
		} else
239
			$pconfig['type6'] = "none";
240
		break;
241
}
242

    
243
// print_r($pconfig);
244

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

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

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

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

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

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

    
365
		clear_subsystem_dirty('staticroutes');
366

    
367
		filter_configure();
368

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

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

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

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

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

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

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

    
651
		unset($wancfg['remote']);
652
		unset($a_ppps[$pppid]['apn']);
653
		unset($a_ppps[$pppid]['phone']);
654
		unset($a_ppps[$pppid]['localip']);
655
		unset($a_ppps[$pppid]['subnet']);
656
		unset($a_ppps[$pppid]['gateway']);
657
		unset($a_ppps[$pppid]['pppoe-reset-type']);
658
		unset($a_ppps[$pppid]['provider']);
659

    
660
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
661
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
662

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

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

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

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

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

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

    
851
		conf_mount_ro();
852
		write_config();
853

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

    
867
		mark_subsystem_dirty('interfaces');
868

    
869
		/* regenerate cron settings/crontab file */
870
		configure_cron();
871

    
872
		header("Location: interfaces.php?if={$if}");
873
		exit;
874
	}
875

    
876
} // end if($_POST)
877

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

    
1015
function check_wireless_mode() {
1016
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1017

    
1018
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1019
		return;
1020

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

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

    
1058
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1059
$statusurl = "status_interfaces.php";
1060

    
1061
$closehead = false;
1062
include("head.inc");
1063
$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"*/);
1064
$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCP6"), "6rd" => gettext("6RD"));
1065

    
1066
?>
1067

    
1068
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1069
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1070
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1071
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1072

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

    
1120
				break;
1121
			}
1122
			case "6rd": {
1123
				jQuery('#none, #dhcp6', '#staticv6').hide();
1124

    
1125
				break;
1126
			}
1127
		}
1128
		if (t != "l2tp" && t != "pptp")
1129
			jQuery('#'+t).show();
1130
	}
1131

    
1132
	function show_allcfg(obj) {
1133
		if (obj.checked)
1134
			jQuery('#allcfg').show();
1135
		else
1136
			jQuery('#allcfg').hide();
1137
	}
1138

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

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

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

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

    
1218
						var option = new Element('option');
1219
						option.text = providerplan[0] + " - " + providerplan[1];
1220
						option.value = providerplan[1];
1221
						jQuery('#providerplan').append(option);
1222
					}
1223
				});
1224
			}
1225
		});
1226
		jQuery('#trproviderplan').css("display","table-row");
1227
	}
1228

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

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

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

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

    
2537
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2538
						<tr>
2539
							<td width="22%" valign="top">
2540
								&nbsp;
2541
							</td>
2542
							<td width="78%">
2543
								<br/>
2544
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2545
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2546
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2547
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2548
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2549
								<?php endif; ?>
2550
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2551
							</td>
2552
						</tr>
2553
					</table>
2554
				</td>
2555
			</tr>
2556
		</table>
2557
		<!--
2558
		</div>
2559
		</td></tr>
2560
		</table>
2561
		-->
2562
	</form>
2563
	<script type="text/javascript">
2564
		var gatewayip;
2565
		var name;
2566
		var gatewayipv6;
2567
		var namev6;
2568
		function show_add_gateway() {
2569
			document.getElementById("addgateway").style.display = '';
2570
			document.getElementById("addgwbox").style.display = 'none';
2571
			document.getElementById("gateway").style.display = 'none';
2572
			document.getElementById("save").style.display = 'none';
2573
			document.getElementById("cancel").style.display = 'none';
2574
			document.getElementById("gwsave").style.display = '';
2575
			document.getElementById("gwcancel").style.display = '';
2576
			jQuery('#notebox').html("");
2577
		}
2578
		function show_add_gateway_v6() {
2579
			document.getElementById("addgatewayv6").style.display = '';
2580
			document.getElementById("addgwboxv6").style.display = 'none';
2581
			document.getElementById("gatewayv6").style.display = 'none';
2582
			document.getElementById("save").style.display = 'none';
2583
			document.getElementById("cancel").style.display = 'none';
2584
			document.getElementById("gwsave").style.display = '';
2585
			document.getElementById("gwcancel").style.display = '';
2586
			jQuery('#noteboxv6').html("");
2587
		}
2588
		function hide_add_gateway() {
2589
			document.getElementById("addgateway").style.display = 'none';
2590
			document.getElementById("addgwbox").style.display = '';
2591
			document.getElementById("gateway").style.display = '';
2592
			document.getElementById("save").style.display = '';
2593
			document.getElementById("cancel").style.display = '';
2594
			document.getElementById("gwsave").style.display = '';
2595
			document.getElementById("gwcancel").style.display = '';
2596
		}
2597
		function hide_add_gateway_v6() {
2598
			document.getElementById("addgatewayv6").style.display = 'none';
2599
			document.getElementById("addgwboxv6").style.display = '';
2600
			document.getElementById("gatewayv6").style.display = '';
2601
			document.getElementById("save").style.display = '';
2602
			document.getElementById("cancel").style.display = '';
2603
			document.getElementById("gwsave").style.display = '';
2604
			document.getElementById("gwcancel").style.display = '';
2605
		}
2606
		function hide_add_gatewaysave() {
2607
			document.getElementById("addgateway").style.display = 'none';
2608
			jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2609
			var iface = jQuery('#if').val();
2610
			name = jQuery('#name').val();
2611
			var descr = jQuery('#gatewaydescr').val();
2612
			gatewayip = jQuery('#gatewayip').val();
2613

    
2614
			var defaultgw = jQuery('#defaultgw').val();
2615
			var url = "system_gateways_edit.php";
2616
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2617
			jQuery.ajax(
2618
				url,
2619
				{
2620
					type: 'post',
2621
					data: pars,
2622
					error: report_failure,
2623
					complete: save_callback
2624
				});
2625
		}
2626
		function hide_add_gatewaysave_v6() {
2627
			document.getElementById("addgatewayv6").style.display = 'none';
2628
			jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2629
			var iface = jQuery('#if').val();
2630
			name = jQuery('#namev6').val();
2631
			var descr = jQuery('#gatewaydescrv6').val();
2632
			gatewayip = jQuery('#gatewayipv6').val();
2633
			var defaultgw = jQuery('#defaultgwv6').val();
2634
			var url_v6 = "system_gateways_edit.php";
2635
			var pars_v6 = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2636
			jQuery.ajax(
2637
				url_v6,
2638
				{
2639
					type: 'post',
2640
					data: pars_v6,
2641
					error: report_failure_v6,
2642
					complete: save_callback_v6
2643
				});
2644
		}
2645
		function addOption(selectbox,text,value)
2646
		{
2647
			var optn = document.createElement("OPTION");
2648
			optn.text = text;
2649
			optn.value = value;
2650
			selectbox.append(optn);
2651
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2652
			jQuery('#notebox').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2653
		}
2654
		function addOption_v6(selectbox,text,value)
2655
		{
2656
			var optn = document.createElement("OPTION");
2657
			optn.text = text;
2658
			optn.value = value;
2659
			selectbox.append(optn);
2660
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2661
			jQuery('#noteboxv6').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2662
		}
2663
		function report_failure() {
2664
			alert("Sorry, we could not create your IPv4 gateway at this time.");
2665
			hide_add_gateway();
2666
		}
2667
		function report_failure_v6() {
2668
			alert("Sorry, we could not create your IPv6 gateway at this time.");
2669
			hide_add_gateway_v6();
2670
		}
2671
		function save_callback(transport) {
2672
			var response = transport.responseText;
2673
			if(response) {
2674
				document.getElementById("addgateway").style.display = 'none';
2675
				hide_add_gateway();
2676
				jQuery('#status').html('');
2677
				var gwtext = escape(name) + " - " + gatewayip;
2678
				addOption(jQuery('#gateway'), gwtext, name);
2679
				// Auto submit form?
2680
				//document.iform.submit();
2681
				//jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif">');
2682
			} else {
2683
				report_failure();
2684
			}
2685
		}
2686
		function show_advanced_media() {
2687
			document.getElementById("showadvmediabox").innerHTML='';
2688
			aodiv = document.getElementById('showmediaadv');
2689
			aodiv.style.display = "block";
2690
		}
2691
		function save_callback_v6(transport) {
2692
			var response_v6 = transport.responseText;
2693
			if(response_v6) {
2694
				document.getElementById("addgatewayv6").style.display = 'none';
2695
				hide_add_gateway_v6();
2696
				jQuery('#statusv6').html('');
2697
				var gwtext_v6 = escape(name) + " - " + gatewayip;
2698
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
2699
				// Auto submit form?
2700
				//document.iform.submit();
2701
				//jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif">');
2702
			} else {
2703
				report_failure_v6();
2704
			}
2705
		}
2706
		<?php
2707
		echo "show_allcfg(document.iform.enable);";
2708
		echo "updateType('{$pconfig['type']}');\n";
2709
		echo "updateTypeSix('{$pconfig['type6']}');\n";
2710
		?>
2711
	</script>
2712
	<?php include("fend.inc"); ?>
2713
	</body>
2714
</html>
(89-89/238)