Project

General

Profile

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

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

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

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

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

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

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

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

    
58
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces.php');
59

    
60
// Get configured interface list
61
$ifdescrs = get_configured_interface_with_descr(false, true);
62

    
63
$if = "wan";
64
if ($_REQUEST['if'])
65
	$if = $_REQUEST['if'];
66

    
67
if (empty($ifdescrs[$if])) {
68
	header("Location: interfaces.php");
69
	exit;
70
}
71

    
72
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
73
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
74
define("CRON_DAILY_PATTERN", "0 0 * * *");
75
define("CRON_HOURLY_PATTERN", "0 * * * *");
76

    
77
if (!is_array($pconfig))
78
	$pconfig = array();
79

    
80
if (!is_array($config['ppps']))
81
	$config['ppps'] = array();
82
if (!is_array($config['ppps']['ppp']))
83
	$config['ppps']['ppp'] = array();
84
$a_ppps = &$config['ppps']['ppp'];
85

    
86
function remove_bad_chars($string) {
87
	return preg_replace('/[^a-z_0-9]/i','',$string);
88
}
89

    
90
if (!is_array($config['gateways']['gateway_item']))
91
	$config['gateways']['gateway_item'] = array();
92
$a_gateways = &$config['gateways']['gateway_item'];
93

    
94
$wancfg = &$config['interfaces'][$if];
95
$old_wancfg = $wancfg;
96
$old_wancfg['realif'] = get_real_interface($if);
97
$old_ppps = $a_ppps;
98
// Populate page descr if it does not exist.
99
if ($if == "wan" && !$wancfg['descr'])
100
	$wancfg['descr'] = "WAN";
101
else if ($if == "lan" && !$wancfg['descr'])
102
	$wancfg['descr'] = "LAN";
103

    
104
/* NOTE: The code here is used to set the $pppid for the curious */
105
foreach ($a_ppps as $pppid => $ppp) {
106
	if ($wancfg['if'] == $ppp['if'])
107
		break;
108
}
109

    
110
$type_disabled = (substr($wancfg['if'], 0, 3) == 'gre') ? 'disabled="disabled"' : '';
111

    
112
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
113
	$pconfig['pppid'] = $pppid;
114
	$pconfig['ptpid'] = $a_ppps[$pppid]['ptpid'];
115
	$pconfig['port'] = $a_ppps[$pppid]['ports'];
116
	if ($a_ppps[$pppid]['type'] == "ppp") {
117
		$pconfig['username'] = $a_ppps[$pppid]['username'];
118
		$pconfig['password'] = base64_decode($a_ppps[$pppid]['password']);
119

    
120
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
121
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
122
	}
123
	else if ($a_ppps[$pppid]['type'] == "pppoe") {
124
		$pconfig['pppoe_username'] = $a_ppps[$pppid]['username'];
125
		$pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']);
126
		$pconfig['provider'] = $a_ppps[$pppid]['provider'];
127
		$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
128
		$pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout'];
129

    
130
		/* ================================================ */
131
		/* = force a connection reset at a specific time? = */
132
		/* ================================================ */
133

    
134
		if (isset($a_ppps[$pppid]['pppoe-reset-type'])) {
135
			$pconfig['pppoe-reset-type'] = $a_ppps[$pppid]['pppoe-reset-type'];
136
			$itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']);
137
			if ($itemhash)
138
				$cronitem = $itemhash['ITEM'];
139
			if (isset($cronitem)) {
140
				$resetTime = "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
141
			} else {
142
				$resetTime = NULL;
143
			}
144
			//log_error("ResetTime:".$resetTime);
145
			if ($a_ppps[$pppid]['pppoe-reset-type'] == "custom") {
146
				if ($cronitem) {
147
					$pconfig['pppoe_pr_custom'] = true;
148
					$pconfig['pppoe_resetminute'] = $cronitem['minute'];
149
					$pconfig['pppoe_resethour'] = $cronitem['hour'];
150
					if ($cronitem['mday'] <> "*" && $cronitem['month'] <> "*")
151
						$pconfig['pppoe_resetdate'] = "{$cronitem['month']}/{$cronitem['mday']}/" . date("Y");
152
				}
153
			} else if ($a_ppps[$pppid]['pppoe-reset-type'] == "preset") {
154
				$pconfig['pppoe_pr_preset'] = true;
155
				switch ($resetTime) {
156
					case CRON_MONTHLY_PATTERN:
157
						$pconfig['pppoe_monthly'] = true;
158
						break;
159
					case CRON_WEEKLY_PATTERN:
160
						$pconfig['pppoe_weekly'] = true;
161
						break;
162
					case CRON_DAILY_PATTERN:
163
						$pconfig['pppoe_daily'] = true;
164
						break;
165
					case CRON_HOURLY_PATTERN:
166
						$pconfig['pppoe_hourly'] = true;
167
						break;
168
				}
169
			}
170
		}// End force pppoe reset at specific time
171
	}// End if type == pppoe
172
	else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp"){
173
		$pconfig['pptp_username'] = $a_ppps[$pppid]['username'];
174
		$pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']);
175
		$pconfig['pptp_local'] = explode(",",$a_ppps[$pppid]['localip']);
176
		$pconfig['pptp_subnet'] = explode(",",$a_ppps[$pppid]['subnet']);
177
		$pconfig['pptp_remote'] = explode(",",$a_ppps[$pppid]['gateway']);
178
		$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
179
		$pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout'];
180
	}
181
} else {
182
	$pconfig['ptpid'] = interfaces_ptpid_next();
183
	$pppid = count($a_ppps);
184
}
185
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
186
$pconfig['alias-address'] = $wancfg['alias-address'];
187
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
188
$pconfig['dhcprejectfrom'] = $wancfg['dhcprejectfrom'];
189

    
190
$pconfig['adv_dhcp_pt_timeout'] = $wancfg['adv_dhcp_pt_timeout'];
191
$pconfig['adv_dhcp_pt_retry'] = $wancfg['adv_dhcp_pt_retry'];
192
$pconfig['adv_dhcp_pt_select_timeout'] = $wancfg['adv_dhcp_pt_select_timeout'];
193
$pconfig['adv_dhcp_pt_reboot'] = $wancfg['adv_dhcp_pt_reboot'];
194
$pconfig['adv_dhcp_pt_backoff_cutoff'] = $wancfg['adv_dhcp_pt_backoff_cutoff'];
195
$pconfig['adv_dhcp_pt_initial_interval'] = $wancfg['adv_dhcp_pt_initial_interval'];
196

    
197
$pconfig['adv_dhcp_pt_values'] = $wancfg['adv_dhcp_pt_values'];
198

    
199
$pconfig['adv_dhcp_send_options'] = $wancfg['adv_dhcp_send_options'];
200
$pconfig['adv_dhcp_request_options'] = $wancfg['adv_dhcp_request_options'];
201
$pconfig['adv_dhcp_required_options'] = $wancfg['adv_dhcp_required_options'];
202
$pconfig['adv_dhcp_option_modifiers'] = $wancfg['adv_dhcp_option_modifiers'];
203

    
204
$pconfig['adv_dhcp_config_advanced'] = $wancfg['adv_dhcp_config_advanced'];
205
$pconfig['adv_dhcp_config_file_override'] = $wancfg['adv_dhcp_config_file_override'];
206
$pconfig['adv_dhcp_config_file_override_path'] = $wancfg['adv_dhcp_config_file_override_path'];
207

    
208
$pconfig['adv_dhcp6_interface_statement_send_options'] = $wancfg['adv_dhcp6_interface_statement_send_options'];
209
$pconfig['adv_dhcp6_interface_statement_request_options'] = $wancfg['adv_dhcp6_interface_statement_request_options'];
210
$pconfig['adv_dhcp6_interface_statement_information_only_enable'] = $wancfg['adv_dhcp6_interface_statement_information_only_enable'];
211
$pconfig['adv_dhcp6_interface_statement_script'] = $wancfg['adv_dhcp6_interface_statement_script'];
212

    
213
$pconfig['adv_dhcp6_id_assoc_statement_address_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_address_enable'];
214
$pconfig['adv_dhcp6_id_assoc_statement_address'] = $wancfg['adv_dhcp6_id_assoc_statement_address'];
215
$pconfig['adv_dhcp6_id_assoc_statement_address_id'] = $wancfg['adv_dhcp6_id_assoc_statement_address_id'];
216
$pconfig['adv_dhcp6_id_assoc_statement_address_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_pltime'];
217
$pconfig['adv_dhcp6_id_assoc_statement_address_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_vltime'];
218

    
219
$pconfig['adv_dhcp6_id_assoc_statement_prefix_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'];
220
$pconfig['adv_dhcp6_id_assoc_statement_prefix'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix'];
221
$pconfig['adv_dhcp6_id_assoc_statement_prefix_id'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_id'];
222
$pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'];
223
$pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'];
224

    
225
$pconfig['adv_dhcp6_prefix_interface_statement_sla_id'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_id'];
226
$pconfig['adv_dhcp6_prefix_interface_statement_sla_len'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_len'];
227

    
228
$pconfig['adv_dhcp6_authentication_statement_authname'] = $wancfg['adv_dhcp6_authentication_statement_authname'];
229
$pconfig['adv_dhcp6_authentication_statement_protocol'] = $wancfg['adv_dhcp6_authentication_statement_protocol'];
230
$pconfig['adv_dhcp6_authentication_statement_algorithm'] = $wancfg['adv_dhcp6_authentication_statement_algorithm'];
231
$pconfig['adv_dhcp6_authentication_statement_rdm'] = $wancfg['adv_dhcp6_authentication_statement_rdm'];
232

    
233
$pconfig['adv_dhcp6_key_info_statement_keyname'] = $wancfg['adv_dhcp6_key_info_statement_keyname'];
234
$pconfig['adv_dhcp6_key_info_statement_realm'] = $wancfg['adv_dhcp6_key_info_statement_realm'];
235
$pconfig['adv_dhcp6_key_info_statement_keyid'] = $wancfg['adv_dhcp6_key_info_statement_keyid'];
236
$pconfig['adv_dhcp6_key_info_statement_secret'] = $wancfg['adv_dhcp6_key_info_statement_secret'];
237
$pconfig['adv_dhcp6_key_info_statement_expire'] = $wancfg['adv_dhcp6_key_info_statement_expire'];
238

    
239
$pconfig['adv_dhcp6_config_advanced'] = $wancfg['adv_dhcp6_config_advanced'];
240
$pconfig['adv_dhcp6_config_file_override'] = $wancfg['adv_dhcp6_config_file_override'];
241
$pconfig['adv_dhcp6_config_file_override_path'] = $wancfg['adv_dhcp6_config_file_override_path'];
242

    
243
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
244
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
245
$pconfig['enable'] = isset($wancfg['enable']);
246

    
247
if (is_array($config['aliases']['alias'])) {
248
	foreach($config['aliases']['alias'] as $alias) {
249
		if($alias['name'] == $wancfg['descr']) {
250
			$input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."),$wancfg['descr']);
251
		}
252
	}
253
}
254

    
255
switch($wancfg['ipaddr']) {
256
	case "dhcp":
257
		$pconfig['type'] = "dhcp";
258
		break;
259
	case "pppoe":
260
	case "pptp":
261
	case "l2tp":
262
	case "ppp":
263
		$pconfig['type'] = $wancfg['ipaddr'];
264
		break;
265
	default:
266
		if(is_ipaddrv4($wancfg['ipaddr'])) {
267
			$pconfig['type'] = "staticv4";
268
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
269
			$pconfig['subnet'] = $wancfg['subnet'];
270
			$pconfig['gateway'] = $wancfg['gateway'];
271
		} else
272
			$pconfig['type'] = "none";
273
		break;
274
}
275

    
276
switch($wancfg['ipaddrv6']) {
277
	case "slaac":
278
		$pconfig['type6'] = "slaac";
279
		break;
280
	case "dhcp6":
281
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
282
		if(!isset($wancfg['dhcp6-ia-pd-len']))
283
			$wancfg['dhcp6-ia-pd-len'] = "none";
284
		$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
285
		$pconfig['dhcp6-ia-pd-send-hint'] = isset($wancfg['dhcp6-ia-pd-send-hint']);
286
		$pconfig['type6'] = "dhcp6";
287
		$pconfig['dhcp6prefixonly'] = isset($wancfg['dhcp6prefixonly']);
288
		$pconfig['dhcp6usev4iface'] = isset($wancfg['dhcp6usev4iface']);
289
		break;
290
	case "6to4":
291
		$pconfig['type6'] = "6to4";
292
		break;
293
	case "track6":
294
		$pconfig['type6'] = "track6";
295
		$pconfig['track6-interface'] = $wancfg['track6-interface'];
296
		if ($wancfg['track6-prefix-id'] == "")
297
			$pconfig['track6-prefix-id'] = 0;
298
		else
299
			$pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
300
		$pconfig['track6-prefix-id--hex'] = sprintf("%x", $pconfig['track6-prefix-id']);
301
		break;
302
	case "6rd":
303
		$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
304
		if($wancfg['prefix-6rd-v4plen'] == "")
305
			$wancfg['prefix-6rd-v4plen'] = "0";
306
		$pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen'];
307
		$pconfig['type6'] = "6rd";
308
		$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
309
		break;
310
	default:
311
		if(is_ipaddrv6($wancfg['ipaddrv6'])) {
312
			$pconfig['type6'] = "staticv6";
313
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
314
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
315
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
316
		} else
317
			$pconfig['type6'] = "none";
318
		break;
319
}
320

    
321
// print_r($pconfig);
322

    
323
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
324
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
325
$pconfig['spoofmac'] = $wancfg['spoofmac'];
326
$pconfig['mtu'] = $wancfg['mtu'];
327
$pconfig['mss'] = $wancfg['mss'];
328

    
329
/* Wireless interface? */
330
if (isset($wancfg['wireless'])) {
331
	/* Sync first to be sure it displays the actual settings that will be used */
332
	interface_sync_wireless_clones($wancfg, false);
333
	/* Get wireless modes */
334
	$wlanif = get_real_interface($if);
335
	if (!does_interface_exist($wlanif))
336
		interface_wireless_clone($wlanif, $wancfg);
337
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
338
	preg_match("/^(.*?)([0-9]*)$/", $wlanbaseif, $wlanbaseif_split);
339
	$wl_modes = get_wireless_modes($if);
340
	$wl_chaninfo = get_wireless_channel_info($if);
341
	$wl_sysctl_prefix = 'dev.' . $wlanbaseif_split[1] . '.' . $wlanbaseif_split[2];
342
	$wl_sysctl = get_sysctl(array("{$wl_sysctl_prefix}.diversity", "{$wl_sysctl_prefix}.txantenna", "{$wl_sysctl_prefix}.rxantenna",
343
				      "{$wl_sysctl_prefix}.slottime", "{$wl_sysctl_prefix}.acktimeout", "{$wl_sysctl_prefix}.ctstimeout"));
344
	$wl_regdomain_xml_attr = array();
345
	$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
346
	$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
347
	$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
348
	$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
349
	$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
350
	$pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]);
351
	$pconfig['standard'] = $wancfg['wireless']['standard'];
352
	$pconfig['mode'] = $wancfg['wireless']['mode'];
353
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
354
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
355
	$pconfig['channel'] = $wancfg['wireless']['channel'];
356
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
357
	$pconfig['diversity'] = $wancfg['wireless']['diversity'];
358
	$pconfig['txantenna'] = $wancfg['wireless']['txantenna'];
359
	$pconfig['rxantenna'] = $wancfg['wireless']['rxantenna'];
360
	$pconfig['distance'] = $wancfg['wireless']['distance'];
361
	$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
362
	$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
363
	$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
364
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
365
	if (isset($wancfg['wireless']['puren']['enable']))
366
		$pconfig['puremode'] = '11n';
367
	else if (isset($wancfg['wireless']['pureg']['enable']))
368
		$pconfig['puremode'] = '11g';
369
	else
370
		$pconfig['puremode'] = 'any';
371
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
372
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
373
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
374
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
375
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
376
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
377
	$pconfig['auth_server_addr2'] = $wancfg['wireless']['auth_server_addr2'];
378
	$pconfig['auth_server_port2'] = $wancfg['wireless']['auth_server_port2'];
379
	$pconfig['auth_server_shared_secret2'] = $wancfg['wireless']['auth_server_shared_secret2'];
380
	if (is_array($wancfg['wireless']['wpa'])) {
381
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
382
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
383
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
384
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
385
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
386
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
387
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
388
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
389
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
390
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
391
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
392
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
393
		$pconfig['rsn_preauth'] = isset($wancfg['wireless']['wpa']['rsn_preauth']);
394
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
395
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
396
	}
397
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
398
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
399
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
400
		$i = 1;
401
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
402
			$pconfig['key' . $i] = $wepkey['value'];
403
			if (isset($wepkey['txkey']))
404
				$pconfig['txkey'] = $i;
405
			$i++;
406
		}
407
		if (!isset($wepkey['txkey']))
408
			$pconfig['txkey'] = 1;
409
	}
410
}
411

    
412
if ($_POST['apply']) {
413
	unset($input_errors);
414
	if (!is_subsystem_dirty('interfaces'))
415
		$input_errors[] = gettext("You have already applied your settings!");
416
	else {
417
		unlink_if_exists("{$g['tmp_path']}/config.cache");
418
		clear_subsystem_dirty('interfaces');
419

    
420
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
421
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
422
			foreach ($toapplylist as $ifapply => $ifcfgo) {
423
				if (isset($config['interfaces'][$ifapply]['enable'])) {
424
					interface_bring_down($ifapply, false, $ifcfgo);
425
					interface_configure($ifapply, true);
426
				} else {
427
					interface_bring_down($ifapply, true, $ifcfgo);
428
					if (isset($config['dhcpd'][$ifapply]['enable']) ||
429
					    isset($config['dhcpdv6'][$ifapply]['enable']))
430
						services_dhcpd_configure();
431
				}
432
			}
433
		}
434
		/* restart snmp so that it binds to correct address */
435
		services_snmpd_configure();
436

    
437
		/* sync filter configuration */
438
		setup_gateways_monitor();
439

    
440
		clear_subsystem_dirty('interfaces');
441

    
442
		filter_configure();
443

    
444
		enable_rrd_graphing();
445

    
446
		if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0))
447
			clear_subsystem_dirty('staticroutes');
448
	}
449
	@unlink("{$g['tmp_path']}/.interfaces.apply");
450
	header("Location: interfaces.php?if={$if}");
451
	exit;
452
} else if ($_POST && $_POST['enable'] != "yes") {
453
	unset($wancfg['enable']);
454
	if (isset($wancfg['wireless']))
455
		interface_sync_wireless_clones($wancfg, false);
456
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
457
	mark_subsystem_dirty('interfaces');
458
	if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
459
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
460
	} else {
461
		$toapplylist = array();
462
	}
463
	$toapplylist[$if]['ifcfg'] = $wancfg;
464
	$toapplylist[$if]['ppps'] = $a_ppps;
465
	/* we need to be able remove IP aliases for IPv6 */
466
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
467
	header("Location: interfaces.php?if={$if}");
468
	exit;
469
} else if ($_POST) {
470

    
471
	unset($input_errors);
472
	$pconfig = $_POST;
473

    
474
	if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
475
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
476
	else
477
		$pconfig['track6-prefix-id'] = 0;
478
	conf_mount_rw();
479

    
480
	/* filter out spaces from descriptions  */
481
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
482

    
483
	/* okay first of all, cause we are just hiding the PPPoE HTML
484
	 * fields releated to PPPoE resets, we are going to unset $_POST
485
	 * vars, if the reset feature should not be used. Otherwise the
486
	 * data validation procedure below, may trigger a false error
487
	 * message.
488
	 */
489
	if (empty($_POST['pppoe-reset-type'])) {
490
		unset($_POST['pppoe_pr_type']);
491
		unset($_POST['pppoe_resethour']);
492
		unset($_POST['pppoe_resetminute']);
493
		unset($_POST['pppoe_resetdate']);
494
		unset($_POST['pppoe_pr_preset_val']);
495
	}
496
	/* description unique? */
497
	foreach ($ifdescrs as $ifent => $ifdescr) {
498
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
499
			$input_errors[] = gettext("An interface with the specified description already exists.");
500
			break;
501
		}
502
	}
503
	if(is_numeric($_POST['descr'])) {
504
		$input_errors[] = gettext("The interface description cannot contain only numbers.");
505
	}
506
	/* input validation */
507
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^staticv4/", $_POST['type'])))
508
		$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.");
509
	if (isset($config['dhcpdv6']) && isset($config['dhcpdv6'][$if]['enable']) && (! preg_match("/^staticv6/", $_POST['type6'])))
510
		$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.");
511

    
512
	switch(strtolower($_POST['type'])) {
513
		case "staticv4":
514
			$reqdfields = explode(" ", "ipaddr subnet gateway");
515
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
516
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
517
			break;
518
		case "none":
519
			if(is_array($config['virtualip']['vip'])) {
520
				foreach ($config['virtualip']['vip'] as $vip) {
521
					if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if)
522
						$input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration.");
523
				}
524
			}
525
		case "dhcp":
526
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp")))
527
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
528
			break;
529
		case "ppp":
530
			$reqdfields = explode(" ", "port phone");
531
			$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
532
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
533
			break;
534
		case "pppoe":
535
			if ($_POST['pppoe_dialondemand']) {
536
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
537
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
538
			} else {
539
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
540
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
541
			}
542
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
543
			break;
544
		case "pptp":
545
			if ($_POST['pptp_dialondemand']) {
546
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
547
				$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"));
548
			} else {
549
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
550
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
551
			}
552
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
553
			break;
554
		case "l2tp":
555
			if ($_POST['pptp_dialondemand']) {
556
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
557
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
558
			} else {
559
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
560
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"));
561
			}
562
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
563
			break;
564
	}
565
	switch(strtolower($_POST['type6'])) {
566
		case "staticv6":
567
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
568
			$reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
569
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
570
			break;
571
		case "none":
572
			if(is_array($config['virtualip']['vip'])) {
573
				foreach ($config['virtualip']['vip'] as $vip) {
574
					if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if)
575
						$input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration.");
576
				}
577
			}
578
		case "dhcp6":
579
			if (in_array($wancfg['ipaddrv6'], array()))
580
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
581
			break;
582
		case "6rd":
583
			foreach ($ifdescrs as $ifent => $ifdescr) {
584
				if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
585
					if ($config[interfaces][$ifent]['prefix-6rd'] == $_POST['prefix-6rd']) {
586
						$input_errors[] = gettext("You can only have one interface configured in 6rd with same prefix.");
587
						break;
588
					}
589
				}
590
			}
591
			if (in_array($wancfg['ipaddrv6'], array()))
592
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
593
			break;
594
		case "6to4":
595
			foreach ($ifdescrs as $ifent => $ifdescr) {
596
				if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
597
					$input_errors[] = sprintf(gettext("You can only have one interface configured as 6to4."),$_POST['type6']);
598
					break;
599
				}
600
			}
601
			if (in_array($wancfg['ipaddrv6'], array()))
602
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
603
			break;
604
		case "track6":
605
			/* needs to check if $track6-prefix-id is used on another interface */
606
			if (in_array($wancfg['ipaddrv6'], array()))
607
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
608

    
609
			if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
610
				$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
611
			} else {
612
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
613
				if ($track6_prefix_id < 0 || $track6_prefix_id > $_POST['ipv6-num-prefix-ids-' . $_POST['track6-interface']]) {
614
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range. ({$_POST['track6-interface']}) - ({$_POST['ipv6-num-prefix-ids-' . $_POST['track6-interface']]}) - ({$ipv6_delegation_length})");
615
				} else {
616
					foreach ($ifdescrs as $ifent => $ifdescr) {
617
						if ($if == $ifent)
618
							continue;
619
						if ($config['interfaces'][$ifent]['ipaddrv6'] == 'track6' &&
620
						    $config['interfaces'][$ifent]['track6-interface'] == $_POST['track6-interface'] &&
621
						    $config['interfaces'][$ifent]['track6-prefix-id'] == $track6_prefix_id)
622
							$input_errors[] = sprintf(gettext("This track6 prefix ID is already being used in %s."), $ifdescr);
623
					}
624
				}
625
			}
626
			break;
627
	}
628

    
629

    
630
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
631
	$staticroutes = get_staticroutes(true);
632
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
633
	if ($_POST['ipaddr']) {
634
		if (!is_ipaddrv4($_POST['ipaddr']))
635
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
636
		else {
637
			if (is_ipaddr_configured($_POST['ipaddr'], $if, true))
638
				$input_errors[] = gettext("This IPv4 address is being used by another interface or VIP.");
639

    
640
			/* Do not accept network or broadcast address, except if subnet is 31 or 32 */
641
			if ($_POST['subnet'] < 31) {
642
				if ($_POST['ipaddr'] == gen_subnet($_POST['ipaddr'], $_POST['subnet']))
643
					$input_errors[] = gettext("This IPv4 address is the network address and cannot be used");
644
				else if ($_POST['ipaddr'] == gen_subnet_max($_POST['ipaddr'], $_POST['subnet']))
645
					$input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used");
646
			}
647

    
648
			foreach ($staticroutes as $route_subnet) {
649
				list($network, $subnet) = explode("/", $route_subnet);
650
				if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
651
					$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
652
					break;
653
				}
654
				unset($network, $subnet);
655
			}
656
		}
657
	}
658
	if ($_POST['ipaddrv6']) {
659
		if (!is_ipaddrv6($_POST['ipaddrv6']))
660
			$input_errors[] = gettext("A valid IPv6 address must be specified.");
661
		else {
662
			if (is_ipaddr_configured($_POST['ipaddrv6'], $if, true))
663
				$input_errors[] = gettext("This IPv6 address is being used by another interface or VIP.");
664

    
665
			foreach ($staticroutes as $route_subnet) {
666
				list($network, $subnet) = explode("/", $route_subnet);
667
				if ($_POST['subnetv6'] == $subnet && $network == gen_subnetv6($_POST['ipaddrv6'], $_POST['subnetv6'])) {
668
					$input_errors[] = gettext("This IPv6 address conflicts with a Static Route.");
669
					break;
670
				}
671
				unset($network, $subnet);
672
			}
673
		}
674
	}
675
	if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
676
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
677
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6'])))
678
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
679
	if (($_POST['alias-address'] && !is_ipaddrv4($_POST['alias-address'])))
680
		$input_errors[] = gettext("A valid alias IP address must be specified.");
681
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
682
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
683
	if ($_POST['dhcprejectfrom'] && !is_ipaddrv4($_POST['dhcprejectfrom']))
684
		$input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from.");
685
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
686
		$match = false;
687
		foreach($a_gateways as $gateway) {
688
			if(in_array($_POST['gateway'], $gateway)) {
689
				$match = true;
690
			}
691
		}
692
		foreach($a_gateways as $gateway) {
693
			if(in_array($_POST['gatewayv6'], $gateway)) {
694
				$match = true;
695
			}
696
		}
697
		if(!$match) {
698
			$input_errors[] = gettext("A valid gateway must be specified.");
699
		}
700
	}
701
	if (($_POST['provider'] && !is_domain($_POST['provider'])))
702
		$input_errors[] = gettext("The service name contains invalid characters.");
703
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
704
		$input_errors[] = gettext("The idle timeout value must be an integer.");
705
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
706
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23)
707
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
708
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
709
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59)
710
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
711
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate'])))
712
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
713
	if (($_POST['pptp_local'] && !is_ipaddrv4($_POST['pptp_local'])))
714
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
715
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet'])))
716
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
717
	if (($_POST['pptp_remote'] && !is_ipaddrv4($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface])))
718
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
719
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout']))
720
		$input_errors[] = gettext("The idle timeout value must be an integer.");
721
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])))
722
		$input_errors[] = gettext("A valid MAC address must be specified.");
723
	if ($_POST['mtu']) {
724
		if (!is_numericint($_POST['mtu']))
725
			$input_errors[] = "MTU must be an integer.";
726
		if (substr($wancfg['if'], 0, 3) == 'gif') {
727
			$min_mtu = 1280;
728
			$max_mtu = 8192;
729
		} else {
730
			$min_mtu = 576;
731
			$max_mtu = 9000;
732
		}
733

    
734
		if ($_POST['mtu'] < $min_mtu || $_POST['mtu'] > $max_mtu)
735
			$input_errors[] = sprintf(gettext("The MTU must be between %d and %d bytes."), $min_mtu, $max_mtu);
736

    
737
		unset($min_mtu, $max_mtu);
738

    
739
		if (stristr($wancfg['if'], "_vlan")) {
740
			$realhwif_array = get_parent_interface($wancfg['if']);
741
			// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
742
			$parent_realhwif = $realhwif_array[0];
743
			$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
744
			if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) {
745
				if ($_POST['mtu'] > intval($config['interfaces'][$parent_if]['mtu']))
746
					$input_errors[] = gettext("The MTU of a VLAN cannot be greater than that of its parent interface.");
747
			}
748
		} else {
749
			foreach ($config['interfaces'] as $idx => $ifdata) {
750
				if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if']))
751
					continue;
752

    
753
				$realhwif_array = get_parent_interface($ifdata['if']);
754
				// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
755
				$parent_realhwif = $realhwif_array[0];
756

    
757
				if ($parent_realhwif != $wancfg['if'])
758
					continue;
759

    
760
				if (isset($ifdata['mtu']) && $ifdata['mtu'] > $_POST['mtu'])
761
					$input_errors[] = sprintf(gettext("Interface %s (VLAN) has MTU set to a larger value"), $ifdata['descr']);
762
			}
763
		}
764
	}
765
	if ($_POST['mss'] <> '')
766
		if (!is_numericint($_POST['mss']) || ($_POST['mss'] < 576 || $_POST['mss'] > 65535))
767
			$input_errors[] = gettext("The MSS must be an integer between 576 and 65535 bytes.");
768
	/* Wireless interface? */
769
	if (isset($wancfg['wireless'])) {
770
		$reqdfields = array("mode");
771
		$reqdfieldsn = array(gettext("Mode"));
772
		if ($_POST['mode'] == 'hostap') {
773
			$reqdfields[] = "ssid";
774
			$reqdfieldsn[] = gettext("SSID");
775
		}
776
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
777
		check_wireless_mode();
778
		/* loop through keys and enforce size */
779
		for ($i = 1; $i <= 4; $i++) {
780
			if ($_POST['key' . $i]) {
781
				/* 64 bit */
782
				if (strlen($_POST['key' . $i]) == 5)
783
					continue;
784
				if (strlen($_POST['key' . $i]) == 10) {
785
					/* hex key */
786
					if (stristr($_POST['key' . $i], "0x") == false) {
787
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
788
					}
789
					continue;
790
				}
791
				if (strlen($_POST['key' . $i]) == 12) {
792
					/* hex key */
793
					if(stristr($_POST['key' . $i], "0x") == false) {
794
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
795
					}
796
					continue;
797
				}
798
				/* 128 bit */
799
				if (strlen($_POST['key' . $i]) == 13)
800
					continue;
801
				if (strlen($_POST['key' . $i]) == 26) {
802
					/* hex key */
803
					if (stristr($_POST['key' . $i], "0x") == false)
804
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
805
					continue;
806
				}
807
				if(strlen($_POST['key' . $i]) == 28)
808
					continue;
809
				$input_errors[] =  gettext("Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.");
810
				break;
811
			}
812
		}
813

    
814
		if ($_POST['passphrase']) {
815
			$passlen = strlen($_POST['passphrase']);
816
			if ($passlen < 8 || $passlen > 63)
817
				$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
818
		}
819
	}
820
	if (!$input_errors) {
821
		if ($wancfg['ipaddr'] != $_POST['type']) {
822
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
823
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
824
				unset($a_ppps[$pppid]);
825
			} else if ($wancfg['ipaddr'] == "dhcp") {
826
				kill_dhclient_process($wancfg['if']);
827
			}
828
			if ($wancfg['ipaddrv6'] == "dhcp6") {
829
				$pid = find_dhcp6c_process($wancfg['if']);
830
				if($pid)
831
					posix_kill($pid, SIGTERM);
832
			}
833
		}
834
		$ppp = array();
835
		if ($wancfg['ipaddr'] != "ppp")
836
			unset($wancfg['ipaddr']);
837
		if ($wancfg['ipaddrv6'] != "ppp")
838
			unset($wancfg['ipaddrv6']);
839
		unset($wancfg['subnet']);
840
		unset($wancfg['gateway']);
841
		unset($wancfg['subnetv6']);
842
		unset($wancfg['gatewayv6']);
843
		unset($wancfg['dhcphostname']);
844
		unset($wancfg['dhcprejectfrom']);
845
		unset($wancfg['dhcp6-duid']);
846
		unset($wancfg['dhcp6-ia-pd-len']);
847
		unset($wancfg['dhcp6-ia-pd-send-hint']);
848
		unset($wancfg['dhcp6prefixonly']);
849
		unset($wancfg['dhcp6usev4iface']);
850
		unset($wancfg['track6-interface']);
851
		unset($wancfg['track6-prefix-id']);
852
		unset($wancfg['prefix-6rd']);
853
		unset($wancfg['prefix-6rd-v4plen']);
854
		unset($wancfg['gateway-6rd']);
855

    
856
		unset($wancfg['adv_dhcp_pt_timeout']);
857
		unset($wancfg['adv_dhcp_pt_retry']);
858
		unset($wancfg['adv_dhcp_pt_select_timeout']);
859
		unset($wancfg['adv_dhcp_pt_reboot']);
860
		unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
861
		unset($wancfg['adv_dhcp_pt_initial_interval']);
862

    
863
		unset($wancfg['adv_dhcp_pt_values']);
864

    
865
		unset($wancfg['adv_dhcp_send_options']);
866
		unset($wancfg['adv_dhcp_request_options']);
867
		unset($wancfg['adv_dhcp_required_options']);
868
		unset($wancfg['adv_dhcp_option_modifiers']);
869

    
870
		unset($wancfg['adv_dhcp_config_advanced']);
871
		unset($wancfg['adv_dhcp_config_file_override']);
872
		unset($wancfg['adv_dhcp_config_file_override_path']);
873

    
874
		unset($wancfg['adv_dhcp6_interface_statement_send_options']);
875
		unset($wancfg['adv_dhcp6_interface_statement_request_options']);
876
		unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']);
877
		unset($wancfg['adv_dhcp6_interface_statement_script']);
878

    
879
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']);
880
		unset($wancfg['adv_dhcp6_id_assoc_statement_address']);
881
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']);
882
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']);
883
		unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']);
884

    
885
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']);
886
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']);
887
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']);
888
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']);
889
		unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']);
890

    
891
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']);
892
		unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']);
893

    
894
		unset($wancfg['adv_dhcp6_authentication_statement_authname']);
895
		unset($wancfg['adv_dhcp6_authentication_statement_protocol']);
896
		unset($wancfg['adv_dhcp6_authentication_statement_algorithm']);
897
		unset($wancfg['adv_dhcp6_authentication_statement_rdm']);
898

    
899
		unset($wancfg['adv_dhcp6_key_info_statement_keyname']);
900
		unset($wancfg['adv_dhcp6_key_info_statement_realm']);
901
		unset($wancfg['adv_dhcp6_key_info_statement_keyid']);
902
		unset($wancfg['adv_dhcp6_key_info_statement_secret']);
903
		unset($wancfg['adv_dhcp6_key_info_statement_expire']);
904

    
905
		unset($wancfg['adv_dhcp6_config_advanced']);
906
		unset($wancfg['adv_dhcp6_config_file_override']);
907
		unset($wancfg['adv_dhcp6_config_file_override_path']);
908

    
909
		unset($wancfg['pppoe_password']);
910
		unset($wancfg['pptp_username']);
911
		unset($wancfg['pptp_password']);
912
		unset($wancfg['provider']);
913
		unset($wancfg['ondemand']);
914
		unset($wancfg['timeout']);
915
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
916
			unset($wancfg['pppoe']['pppoe-reset-type']);
917
		unset($wancfg['local']);
918

    
919
		unset($wancfg['remote']);
920
		if (is_array($a_ppps[$pppid]) && in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
921
			if ($wancfg['ipaddr'] != 'ppp') {
922
				unset($a_ppps[$pppid]['apn']);
923
				unset($a_ppps[$pppid]['phone']);
924
				unset($a_ppps[$pppid]['provider']);
925
				unset($a_ppps[$pppid]['ondemand']);
926
			}
927
			if (in_array($wancfg['ipaddr'], array("pppoe", "pptp", "l2tp"))) {
928
				unset($a_ppps[$pppid]['localip']);
929
				unset($a_ppps[$pppid]['subnet']);
930
				unset($a_ppps[$pppid]['gateway']);
931
			}
932
			if ($wancfg['ipaddr'] != 'pppoe')
933
				unset($a_ppps[$pppid]['pppoe-reset-type']);
934
			if ($wancfg['type'] != $_POST['type']) {
935
				unset($a_ppps[$pppid]['idletimeout']);
936
			}
937
		}
938

    
939
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
940
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
941

    
942
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
943
		switch($_POST['type']) {
944
			case "staticv4":
945
				$wancfg['ipaddr'] = $_POST['ipaddr'];
946
				$wancfg['subnet'] = $_POST['subnet'];
947
				if ($_POST['gateway'] != "none") {
948
					$wancfg['gateway'] = $_POST['gateway'];
949
				}
950
				break;
951
			case "dhcp":
952
				$wancfg['ipaddr'] = "dhcp";
953
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
954
				$wancfg['alias-address'] = $_POST['alias-address'];
955
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
956
				$wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom'];
957

    
958
				$wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout'];
959
				$wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry'];
960
				$wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout'];
961
				$wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot'];
962
				$wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff'];
963
				$wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval'];
964

    
965
				$wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values'];
966

    
967
				$wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options'];
968
				$wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options'];
969
				$wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options'];
970
				$wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers'];
971

    
972
				$wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced'];
973
				$wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override'];
974
				$wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path'];
975

    
976
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
977
				if($gateway_item) {
978
					$a_gateways[] = $gateway_item;
979
				}
980
				break;
981
			case "ppp":
982
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
983
				$a_ppps[$pppid]['type'] = $_POST['type'];
984
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
985
				$a_ppps[$pppid]['ports'] = $_POST['port'];
986
				$a_ppps[$pppid]['username'] = $_POST['username'];
987
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
988
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
989
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
990
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
991
				$wancfg['ipaddr'] = $_POST['type'];
992
				break;
993

    
994
			case "pppoe":
995
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
996
				$a_ppps[$pppid]['type'] = $_POST['type'];
997
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
998
				if (isset($_POST['ppp_port']))
999
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
1000
				else
1001
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
1002
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
1003
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
1004
				if (!empty($_POST['provider']))
1005
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
1006
				else
1007
					$a_ppps[$pppid]['provider'] = true;
1008
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
1009
				if (!empty($_POST['pppoe_idletimeout']))
1010
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
1011
				else
1012
					unset($a_ppps[$pppid]['idletimeout']);
1013

    
1014
				if (!empty($_POST['pppoe-reset-type']))
1015
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
1016
				else
1017
					unset($a_ppps[$pppid]['pppoe-reset-type']);
1018
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1019
				$wancfg['ipaddr'] = $_POST['type'];
1020
				if($gateway_item) {
1021
					$a_gateways[] = $gateway_item;
1022
				}
1023

    
1024
				break;
1025
			case "pptp":
1026
			case "l2tp":
1027
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
1028
				$a_ppps[$pppid]['type'] = $_POST['type'];
1029
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
1030
				if (isset($_POST['ppp_port']))
1031
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
1032
				else
1033
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
1034
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
1035
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
1036
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
1037
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
1038
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
1039
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
1040
				if (!empty($_POST['pptp_idletimeout']))
1041
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
1042
				else
1043
					unset($a_ppps[$pppid]['idletimeout']);
1044
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
1045
				$wancfg['ipaddr'] = $_POST['type'];
1046
				if($gateway_item) {
1047
					$a_gateways[] = $gateway_item;
1048
				}
1049
				break;
1050
			case "none":
1051
				break;
1052
		}
1053
		switch($_POST['type6']) {
1054
			case "staticv6":
1055
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
1056
				$wancfg['subnetv6'] = $_POST['subnetv6'];
1057
				if ($_POST['gatewayv6'] != "none") {
1058
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
1059
				}
1060
				break;
1061
			case "slaac":
1062
				$wancfg['ipaddrv6'] = "slaac";
1063
				break;
1064
			case "dhcp6":
1065
				$wancfg['ipaddrv6'] = "dhcp6";
1066
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
1067
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
1068
				if($_POST['dhcp6-ia-pd-send-hint'] == "yes")
1069
					$wancfg['dhcp6-ia-pd-send-hint'] = true;
1070
				if($_POST['dhcp6prefixonly'] == "yes")
1071
					$wancfg['dhcp6prefixonly'] = true;
1072
				if($_POST['dhcp6usev4iface'] == "yes")
1073
					$wancfg['dhcp6usev4iface'] = true;
1074

    
1075
				if (!empty($_POST['adv_dhcp6_interface_statement_send_options']))
1076
					$wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options'];
1077
				if (!empty($_POST['adv_dhcp6_interface_statement_request_options']))
1078
					$wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options'];
1079
				if (isset($_POST['adv_dhcp6_interface_statement_information_only_enable']))
1080
					$wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable'];
1081
				if (!empty($_POST['adv_dhcp6_interface_statement_script']))
1082
					$wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script'];
1083

    
1084
				if (isset($_POST['adv_dhcp6_id_assoc_statement_address_enable']))
1085
					$wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable'];
1086
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address']))
1087
					$wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address'];
1088
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_id']))
1089
					$wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id'];
1090
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_pltime']))
1091
					$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime'];
1092
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_address_vltime']))
1093
					$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime'];
1094

    
1095
				if (isset($_POST['adv_dhcp6_id_assoc_statement_prefix_enable']))
1096
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable'];
1097
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix']))
1098
					$wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix'];
1099
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_id']))
1100
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id'];
1101
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_pltime']))
1102
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime'];
1103
				if (!empty($_POST['adv_dhcp6_id_assoc_statement_prefix_vltime']))
1104
					$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime'];
1105

    
1106
				if (!empty($_POST['adv_dhcp6_prefix_interface_statement_sla_id']))
1107
					$wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id'];
1108
				if (!empty($_POST['adv_dhcp6_prefix_interface_statement_sla_len']))
1109
					$wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len'];
1110

    
1111
				if (!empty($_POST['adv_dhcp6_authentication_statement_authname']))
1112
					$wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname'];
1113
				if (!empty($_POST['adv_dhcp6_authentication_statement_protocol']))
1114
					$wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol'];
1115
				if (!empty($_POST['adv_dhcp6_authentication_statement_algorithm']))
1116
					$wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm'];
1117
				if (!empty($_POST['adv_dhcp6_authentication_statement_rdm']))
1118
					$wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm'];
1119

    
1120
				if (!empty($_POST['adv_dhcp6_key_info_statement_keyname']))
1121
					$wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname'];
1122
				if (!empty($_POST['adv_dhcp6_key_info_statement_realm']))
1123
					$wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm'];
1124
				if (!empty($_POST['adv_dhcp6_key_info_statement_keyid']))
1125
					$wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid'];
1126
				if (!empty($_POST['adv_dhcp6_key_info_statement_secret']))
1127
					$wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret'];
1128
				if (!empty($_POST['adv_dhcp6_key_info_statement_expire']))
1129
					$wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire'];
1130

    
1131
				if (!empty($_POST['adv_dhcp6_config_advanced']))
1132
					$wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced'];
1133
				if (!empty($_POST['adv_dhcp6_config_file_override']))
1134
					$wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override'];
1135
				if (!empty($_POST['adv_dhcp6_config_file_override_path']))
1136
					$wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path'];
1137

    
1138
				if($gateway_item) {
1139
					$a_gateways[] = $gateway_item;
1140
				}
1141
				break;
1142
			case "6rd":
1143
				$wancfg['ipaddrv6'] = "6rd";
1144
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
1145
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
1146
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
1147
				if($gateway_item) {
1148
					$a_gateways[] = $gateway_item;
1149
				}
1150
				break;
1151
			case "6to4":
1152
				$wancfg['ipaddrv6'] = "6to4";
1153
				break;
1154
			case "track6":
1155
				$wancfg['ipaddrv6'] = "track6";
1156
				$wancfg['track6-interface'] = $_POST['track6-interface'];
1157
				if ($_POST['track6-prefix-id--hex'] === "")
1158
					$wancfg['track6-prefix-id'] = 0;
1159
				else if (is_numeric("0x" . $_POST['track6-prefix-id--hex']))
1160
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
1161
				else
1162
					$wancfg['track6-prefix-id'] = 0;
1163
				break;
1164
			case "none":
1165
				break;
1166
		}
1167
		handle_pppoe_reset($_POST);
1168

    
1169
		if($_POST['blockpriv'] == "yes") {
1170
			$wancfg['blockpriv'] = true;
1171
		} else {
1172
			unset($wancfg['blockpriv']);
1173
		}
1174
		if($_POST['blockbogons'] == "yes") {
1175
			$wancfg['blockbogons'] = true;
1176
		} else {
1177
			unset($wancfg['blockbogons']);
1178
		}
1179
		$wancfg['spoofmac'] = $_POST['spoofmac'];
1180
		if (empty($_POST['mtu'])) {
1181
			unset($wancfg['mtu']);
1182
		} else {
1183
			$wancfg['mtu'] = $_POST['mtu'];
1184
		}
1185
		if (empty($_POST['mss'])) {
1186
			unset($wancfg['mss']);
1187
		} else {
1188
			$wancfg['mss'] = $_POST['mss'];
1189
		}
1190
		if (empty($_POST['mediaopt'])) {
1191
			unset($wancfg['media']);
1192
			unset($wancfg['mediaopt']);
1193
		} else {
1194
			$mediaopts = explode(' ', $_POST['mediaopt']);
1195
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
1196
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
1197
			else { unset($wancfg['mediaopt']); }
1198
		}
1199
		if (isset($wancfg['wireless'])) {
1200
			handle_wireless_post();
1201
		}
1202

    
1203
		conf_mount_ro();
1204
		write_config();
1205

    
1206
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
1207
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
1208
		} else {
1209
			$toapplylist = array();
1210
		}
1211
		$toapplylist[$if]['ifcfg'] = $old_wancfg;
1212
		$toapplylist[$if]['ppps'] = $old_ppps;
1213
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
1214

    
1215
		mark_subsystem_dirty('interfaces');
1216

    
1217
		/* regenerate cron settings/crontab file */
1218
		configure_cron();
1219

    
1220
		header("Location: interfaces.php?if={$if}");
1221
		exit;
1222
	}
1223

    
1224
} // end if($_POST)
1225

    
1226
function handle_wireless_post() {
1227
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
1228
	if (!is_array($wancfg['wireless']))
1229
		$wancfg['wireless'] = array();
1230
	$wancfg['wireless']['standard'] = $_POST['standard'];
1231
	$wancfg['wireless']['mode'] = $_POST['mode'];
1232
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
1233
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
1234
	$wancfg['wireless']['channel'] = $_POST['channel'];
1235
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
1236
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
1237
	$wancfg['wireless']['distance'] = $_POST['distance'];
1238
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
1239
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
1240
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
1241
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
1242
		foreach($wl_countries_attr as $wl_country) {
1243
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
1244
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
1245
				break;
1246
			}
1247
		}
1248
	}
1249
	if (!is_array($wancfg['wireless']['wpa']))
1250
		$wancfg['wireless']['wpa'] = array();
1251
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
1252
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
1253
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
1254
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
1255
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
1256
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
1257
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
1258
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
1259
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
1260
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
1261
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
1262
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
1263
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
1264
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
1265
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
1266

    
1267
	if ($_POST['persistcommonwireless'] == "yes") {
1268
		if (!is_array($config['wireless']))
1269
			$config['wireless'] = array();
1270
		if (!is_array($config['wireless']['interfaces']))
1271
			$config['wireless']['interfaces'] = array();
1272
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
1273
			$config['wireless']['interfaces'][$wlanbaseif] = array();
1274
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
1275
		unset($config['wireless']['interfaces'][$wlanbaseif]);
1276
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
1277
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
1278
	else if (isset($wancfg['wireless']['diversity']))
1279
		unset($wancfg['wireless']['diversity']);
1280
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
1281
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
1282
	else if (isset($wancfg['wireless']['txantenna']))
1283
		unset($wancfg['wireless']['txantenna']);
1284
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
1285
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
1286
	else if (isset($wancfg['wireless']['rxantenna']))
1287
		unset($wancfg['wireless']['rxantenna']);
1288
	if ($_POST['hidessid_enable'] == "yes")
1289
		$wancfg['wireless']['hidessid']['enable'] = true;
1290
	else if (isset($wancfg['wireless']['hidessid']['enable']))
1291
		unset($wancfg['wireless']['hidessid']['enable']);
1292
	if ($_POST['mac_acl_enable'] == "yes")
1293
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
1294
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
1295
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
1296
	if ($_POST['rsn_preauth'] == "yes")
1297
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
1298
	else
1299
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
1300
	if ($_POST['ieee8021x'] == "yes")
1301
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
1302
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
1303
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
1304
	if ($_POST['wpa_strict_rekey'] == "yes")
1305
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
1306
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
1307
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
1308
	if ($_POST['debug_mode'] == "yes")
1309
		$wancfg['wireless']['wpa']['debug_mode'] = true;
1310
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
1311
		sunset($wancfg['wireless']['wpa']['debug_mode']);
1312
	if ($_POST['wpa_enable'] == "yes")
1313
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
1314
	else if (isset($wancfg['wireless']['wpa']['enable']))
1315
		unset($wancfg['wireless']['wpa']['enable']);
1316
	if ($_POST['wep_enable'] == "yes") {
1317
		if (!is_array($wancfg['wireless']['wep']))
1318
			$wancfg['wireless']['wep'] = array();
1319
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
1320
	} else if (isset($wancfg['wireless']['wep']))
1321
		unset($wancfg['wireless']['wep']);
1322
	if ($_POST['wme_enable'] == "yes") {
1323
		if (!is_array($wancfg['wireless']['wme']))
1324
			$wancfg['wireless']['wme'] = array();
1325
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1326
	} else if (isset($wancfg['wireless']['wme']['enable']))
1327
		unset($wancfg['wireless']['wme']['enable']);
1328
	if ($_POST['puremode'] == "11g") {
1329
		if (!is_array($wancfg['wireless']['pureg']))
1330
			$wancfg['wireless']['pureg'] = array();
1331
		$wancfg['wireless']['pureg']['enable'] = true;
1332
	} else if ($_POST['puremode'] == "11n") {
1333
		if (!is_array($wancfg['wireless']['puren']))
1334
			$wancfg['wireless']['puren'] = array();
1335
		$wancfg['wireless']['puren']['enable'] = true;
1336
	} else {
1337
		if (isset($wancfg['wireless']['pureg']))
1338
			unset($wancfg['wireless']['pureg']);
1339
		if (isset($wancfg['wireless']['puren']))
1340
			unset($wancfg['wireless']['puren']);
1341
	}
1342
	if ($_POST['apbridge_enable'] == "yes") {
1343
		if (!is_array($wancfg['wireless']['apbridge']))
1344
			$wancfg['wireless']['apbridge'] = array();
1345
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1346
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
1347
		unset($wancfg['wireless']['apbridge']['enable']);
1348
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1349
		if (!is_array($wancfg['wireless']['turbo']))
1350
			$wancfg['wireless']['turbo'] = array();
1351
		$wancfg['wireless']['turbo']['enable'] = true;
1352
	} else if (isset($wancfg['wireless']['turbo']['enable']))
1353
		unset($wancfg['wireless']['turbo']['enable']);
1354
	$wancfg['wireless']['wep']['key'] = array();
1355
	for ($i = 1; $i <= 4; $i++) {
1356
		if ($_POST['key' . $i]) {
1357
			$newkey = array();
1358
			$newkey['value'] = $_POST['key' . $i];
1359
			if ($_POST['txkey'] == $i)
1360
				$newkey['txkey'] = true;
1361
			$wancfg['wireless']['wep']['key'][] = $newkey;
1362
		}
1363
	}
1364
	interface_sync_wireless_clones($wancfg, true);
1365
}
1366

    
1367
function check_wireless_mode() {
1368
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1369

    
1370
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1371
		return;
1372

    
1373
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1374
		$clone_count = 1;
1375
	else
1376
		$clone_count = 0;
1377
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1378
		foreach ($config['wireless']['clone'] as $clone) {
1379
			if ($clone['if'] == $wlanbaseif)
1380
				$clone_count++;
1381
		}
1382
	}
1383
	if ($clone_count > 1) {
1384
		$old_wireless_mode = $wancfg['wireless']['mode'];
1385
		$wancfg['wireless']['mode'] = $_POST['mode'];
1386
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1387
			$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']]);
1388
		} else {
1389
			mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy");
1390
		}
1391
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1392
	}
1393
}
1394

    
1395
// Find all possible media options for the interface
1396
$mediaopts_list = array();
1397
$intrealname = $config['interfaces'][$if]['if'];
1398
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1399
foreach ($mediaopts as $mediaopt){
1400
	preg_match("/media (.*)/", $mediaopt, $matches);
1401
	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1402
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1403
		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1404
	}else{
1405
		// there is only media like "media 1000baseT"
1406
		array_push($mediaopts_list, $matches[1]);
1407
	}
1408
}
1409

    
1410
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1411
$shortcut_section = "interfaces";
1412

    
1413
$closehead = false;
1414
include("head.inc");
1415
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1416
$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCP6"), "slaac" => gettext("SLAAC"), "6rd" => gettext("6rd Tunnel"), "6to4" => gettext("6to4 Tunnel"), "track6" => gettext("Track Interface"));
1417

    
1418
?>
1419

    
1420
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1421
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1422
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1423
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1424

    
1425
<script type="text/javascript">
1426
//<![CDATA[
1427
	function updateType(t) {
1428
		switch(t) {
1429
			case "none": {
1430
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1431
				break;
1432
			}
1433
			case "staticv4": {
1434
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1435
				break;
1436
			}
1437
			case "dhcp": {
1438
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1439
				break;
1440
			}
1441
			case "ppp": {
1442
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1443
				country_list();
1444
				break;
1445
			}
1446
			case "pppoe": {
1447
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1448
				break;
1449
			}
1450
			case "l2tp":
1451
			case "pptp": {
1452
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1453
				jQuery('#pptp').show();
1454
				break;
1455
			}
1456
		}
1457
		if (t != "l2tp" && t != "pptp")
1458
			jQuery('#'+t).show();
1459
	}
1460
	function updateTypeSix(t) {
1461
		if (!isNaN(t[0])) t = '_' + t;
1462
		switch(t) {
1463
			case "none": {
1464
				jQuery('#staticv6, #dhcp6, #_6rd, #_6to4, #track6, #slaac').hide();
1465
				break;
1466
			}
1467
			case "staticv6": {
1468
				jQuery('#none, #dhcp6, #_6rd, #_6to4, #track6, #slaac').hide();
1469
				break;
1470
			}
1471
			case "slaac": {
1472
				jQuery('#none, #staticv6, #_6rd, #_6to4, #track6, #dhcp6').hide();
1473
				break;
1474
			}
1475
			case "dhcp6": {
1476
				jQuery('#none, #staticv6, #_6rd, #_6to4, #track6, #slaac').hide();
1477
				break;
1478
			}
1479
			case "_6rd": {
1480
				jQuery('#none, #dhcp6, #staticv6, #_6to4, #track6, #slaac').hide();
1481
				break;
1482
			}
1483
			case "_6to4": {
1484
				jQuery('#none, #dhcp6, #staticv6, #_6rd, #track6, #slaac').hide();
1485
				break;
1486
			}
1487
			case "track6": {
1488
				jQuery('#none, #dhcp6, #staticv6, #_6rd, #_6to4, #slaac').hide();
1489
				update_track6_prefix();
1490
				break;
1491
			}
1492
		}
1493
		if (t != "l2tp" && t != "pptp")
1494
			jQuery('#'+t).show();
1495
	}
1496

    
1497
	function show_allcfg(obj) {
1498
		if (obj.checked)
1499
			jQuery('#allcfg').show();
1500
		else
1501
			jQuery('#allcfg').hide();
1502
	}
1503

    
1504
	function show_reset_settings(reset_type) {
1505
		if (reset_type == 'preset') {
1506
			jQuery('#pppoepresetwrap').show();
1507
			jQuery('#pppoecustomwrap').hide();
1508
		}
1509
		else if (reset_type == 'custom') {
1510
			jQuery('#pppoecustomwrap').show();
1511
			jQuery('#pppoepresetwrap').hide();
1512
		} else {
1513
			jQuery('#pppoecustomwrap').hide();
1514
			jQuery('#pppoepresetwrap').hide();
1515
		}
1516
	}
1517
	function show_mon_config() {
1518
		jQuery("#showmonbox").html('');
1519
		jQuery('#showmon').css('display','block');
1520
	}
1521

    
1522
	function openwindow(url) {
1523
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1524
		if (oWin==null || typeof(oWin)=="undefined")
1525
			return false;
1526
		else
1527
			return true;
1528
	}
1529
	function country_list() {
1530
		jQuery('#country').children().remove();
1531
		jQuery('#provider_list').children().remove();
1532
		jQuery('#providerplan').children().remove();
1533
		jQuery.ajax("getserviceproviders.php",{
1534
			success: function(response) {
1535
				var responseTextArr = response.split("\n");
1536
				responseTextArr.sort();
1537
				responseTextArr.each( function(value) {
1538
					var option = new Element('option');
1539
					country = value.split(":");
1540
					option.text = country[0];
1541
					option.value = country[1];
1542
					jQuery('#country').append(option);
1543
				});
1544
			}
1545
		});
1546
		jQuery('#trcountry').css('display',"table-row");
1547
	}
1548

    
1549
	function providers_list() {
1550
		jQuery('#provider_list').children().remove();
1551
		jQuery('#providerplan').children().remove();
1552
		jQuery.ajax("getserviceproviders.php",{
1553
			type: 'post',
1554
			data: {country : jQuery('#country').val()},
1555
			success: function(response) {
1556
				var responseTextArr = response.split("\n");
1557
				responseTextArr.sort();
1558
				responseTextArr.each( function(value) {
1559
					var option = new Element('option');
1560
					option.text = value;
1561
					option.value = value;
1562
					jQuery('#provider_list').append(option);
1563
				});
1564
			}
1565
		});
1566
		jQuery('#trprovider').css("display","table-row");
1567
		jQuery('#trproviderplan').css("display","none");
1568
	}
1569

    
1570
	function providerplan_list() {
1571
		jQuery('#providerplan').children().remove();
1572
		jQuery('#providerplan').append( new Element('option') );
1573
		jQuery.ajax("getserviceproviders.php",{
1574
			type: 'post',
1575
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val()},
1576
			success: function(response) {
1577
				var responseTextArr = response.split("\n");
1578
				responseTextArr.sort();
1579
				responseTextArr.each( function(value) {
1580
					if(value != "") {
1581
						providerplan = value.split(":");
1582

    
1583
						var option = new Element('option');
1584
						option.text = providerplan[0] + " - " + providerplan[1];
1585
						option.value = providerplan[1];
1586
						jQuery('#providerplan').append(option);
1587
					}
1588
				});
1589
			}
1590
		});
1591
		jQuery('#trproviderplan').css("display","table-row");
1592
	}
1593

    
1594
	function prefill_provider() {
1595
		jQuery.ajax("getserviceproviders.php",{
1596
			type: 'post',
1597
			data: {country : jQuery('#country').val(), provider : jQuery('#provider_list').val(), plan : jQuery('#providerplan').val()},
1598
			success: function(data,textStatus,response) {
1599
				var xmldoc = response.responseXML;
1600
				var provider = xmldoc.getElementsByTagName('connection')[0];
1601
				jQuery('#username').val('');
1602
				jQuery('#password').val('');
1603
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1604
					jQuery('#phone').val('#777');
1605
					jQuery('#apn').val('');
1606
				} else {
1607
					jQuery('#phone').val('*99#');
1608
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1609
				}
1610
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1611
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1612
				jQuery('#username').val(username);
1613
				jQuery('#password').val(password);
1614
			}
1615
		});
1616
	}
1617

    
1618
	function update_track6_prefix() {
1619
		var iface = jQuery("#track6-interface").val();
1620
		if (iface == null)
1621
			return;
1622
		var track6_prefix_ids = jQuery('#ipv6-num-prefix-ids-' + iface).val();
1623
		if (track6_prefix_ids == null)
1624
			return;
1625
		track6_prefix_ids = parseInt(track6_prefix_ids).toString(16);
1626
		jQuery('#track6-prefix-id-range').html('(<b>hexadecimal</b> from 0 to ' + track6_prefix_ids + ')');
1627
	}
1628

    
1629
//]]>
1630
</script>
1631
</head>
1632
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1633
	<?php include("fbegin.inc"); ?>
1634
	<form action="interfaces.php" method="post" name="iform" id="iform">
1635
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1636
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1637
		<?php print_info_box_np(sprintf(gettext("The %s configuration has been changed."),$wancfg['descr'])."</p><p>".gettext("You must apply the changes in order for them to take effect.")."</p><p>".gettext("Don't forget to adjust the DHCP Server range if needed after applying."));?></p><br />
1638
		<?php endif; ?>
1639
		<?php if ($savemsg) print_info_box($savemsg); ?>
1640
		<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="interfaces">
1641
			<tr>
1642
				<td id="mainarea">
1643
					<div class="tabcont">
1644
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="tabs">
1645
						<tr>
1646
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1647
						</tr>
1648
						<tr>
1649
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1650
							<td width="78%" class="vtable">
1651
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked=\"checked\""; ?> onclick="show_allcfg(this);" />
1652
							<strong><?=gettext("Enable Interface"); ?></strong>
1653
							</td>
1654
						</tr>
1655
					</table>
1656
					<div style="display:none;" id="allcfg">
1657
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="allcfg">
1658
						<tr>
1659
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1660
							<td width="78%" class="vtable">
1661
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>" />
1662
								<br /><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1663
							</td>
1664
						</tr>
1665
						<tr>
1666
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1667
							<td class="vtable">
1668
							<select name="type" onchange="updateType(this.value);" <?php echo $type_disabled; ?> class="formselect" id="type">
1669
								<?php
1670
									foreach ($types4 as $key => $opt) {
1671
										echo "<option onclick=\"updateType('{$key}');\"";
1672
										if ($key == $pconfig['type'])
1673
											echo " selected=\"selected\"";
1674
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1675
										echo "</option>";
1676
									}
1677
								?>
1678
								</select>
1679
							</td>
1680
						</tr>
1681
						<tr>
1682
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1683
							<td class="vtable">
1684
							<select name="type6" onchange="updateTypeSix(this.value);" <?php echo $type_disabled; ?> class="formselect" id="type6">
1685
								<?php
1686
									foreach ($types6 as $key => $opt) {
1687
										echo "<option onclick=\"updateTypeSix('{$key}');\"";
1688
										if ($key == $pconfig['type6'])
1689
											echo " selected=\"selected\"";
1690
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1691
										echo "</option>";
1692
									}
1693
								?>
1694
								</select>
1695
							</td>
1696
						</tr>
1697
						<tr>
1698
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1699
							<td class="vtable">
1700
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>" />
1701
								<?php
1702
									$ip = getenv('REMOTE_ADDR');
1703
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1704
									$mac = str_replace("\n","",$mac);
1705
									if($mac):
1706
								?>
1707
									<a onclick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1708
								<?php endif; ?>
1709
								<br />
1710
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1711
								"address of this interface"); ?><br />
1712
								<?=gettext("(may be required with some cable connections)"); ?><br />
1713
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1714
								"or leave blank"); ?>
1715
							</td>
1716
						</tr>
1717
						<tr>
1718
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1719
							<td class="vtable">
1720
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>" />
1721
								<br />
1722
								<?php
1723
									print gettext("If you leave this field blank, the adapter's default MTU will " .
1724
									"be used. This is typically 1500 bytes but can vary in some circumstances.");
1725
								?>
1726
							</td>
1727
						</tr>
1728
						<tr>
1729
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1730
							<td class="vtable">
1731
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>" />
1732
								<br />
1733
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1734
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1735
								"header size) will be in effect."); ?>
1736
							</td>
1737
						</tr>
1738
						<?php
1739
						if (count($mediaopts_list) > 0){
1740
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1741
						echo "<tr>";
1742
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1743
							echo '<td class="vtable">';
1744
							echo '<div id="showadvmediabox"';
1745
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1746
								else echo '>';
1747
								echo '<input type="button" onclick="show_advanced_media()" value="' . gettext("Advanced") . '" /> - ' . gettext("Show advanced option");
1748
							echo "</div>";
1749
							echo '<div id="showmediaadv" ';
1750
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1751
							else echo '>';
1752
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1753
								print "<option value=\"\">Default (no preference, typically autoselect)</option>";
1754
								print "<option value=\"\">------- Media Supported by this interface -------</option>";
1755
								foreach($mediaopts_list as $mediaopt){
1756
									if ($mediaopt != rtrim($mediaopt_from_config)){
1757
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1758
									} else {
1759
										print "<option value=\"$mediaopt\" selected=\"selected\">" . gettext("$mediaopt") . "</option>";
1760
									}
1761
								}
1762
								echo '</select><br />';
1763
								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.");
1764
						echo '</div>';
1765
							echo '</td>';
1766
						echo '</tr>';
1767
						}
1768
						?>
1769
						<tr>
1770
							<td colspan="2" valign="top" height="16"></td>
1771
						</tr>
1772
						<tr style="display:none;" id="none"><td style="display:none;"></td></tr>
1773
						<tr style="display:none;" id="staticv4">
1774
							<td colspan="2" style="padding:0px;">
1775
								<a name="gatewaysection"></a>
1776
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv4">
1777
									<tr>
1778
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1779
									</tr>
1780
									<tr>
1781
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1782
										<td width="78%" class="vtable">
1783
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" />
1784
											/
1785
											<select name="subnet" class="formselect" id="subnet">
1786
												<?php
1787
												for ($i = 32; $i > 0; $i--) {
1788
													echo "<option value=\"{$i}\" ";
1789
													if ($i == $pconfig['subnet']) echo "selected=\"selected\"";
1790
													echo ">" . $i . "</option>";
1791
												}
1792
												?>
1793
											</select>
1794
										</td>
1795
									</tr>
1796
									<tr>
1797
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Upstream Gateway"); ?></td>
1798
										<td width="78%" class="vtable">
1799
											<select name="gateway" class="formselect" id="gateway">
1800
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1801
													<?php
1802
													if(count($a_gateways) > 0) {
1803
														foreach ($a_gateways as $gateway) {
1804
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1805
													?>
1806
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected=\"selected\""; ?>>
1807
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1808
															</option>
1809
													<?php
1810
															}
1811
														}
1812
													}
1813
													?>
1814
											</select>
1815
											- or  <strong><a onclick="show_add_gateway();" href="#gatewaysection"><?=gettext("add a new one."); ?></a></strong>
1816
											<br />
1817
											<div id='addgwbox'>
1818
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above."); ?><br />
1819
												<?=gettext("On local LANs the upstream gateway should be \"none\"."); ?>
1820
											</div>
1821
											<div id='notebox'>
1822
											</div>
1823
											<div id="status">
1824
											</div>
1825
											<div style="display:none" id="addgateway">
1826
												<p>&nbsp;</p>
1827
												<table border="1" class="addgatewaybox" summary="addgateway">
1828
													<tr>
1829
														<td>
1830
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgateway">
1831
																<tr><td>&nbsp;</td></tr>
1832
																<tr>
1833
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1834
																</tr>
1835
																<tr><td>&nbsp;</td></tr>
1836
																<?php
1837
																if($if == "wan" || $if == "WAN")
1838
																	$checked = " checked=\"checked\"";
1839
																?>
1840
																<tr>
1841
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></font></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?> /></td>
1842
																</tr>
1843
																<tr>
1844
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></font></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>" /></td>
1845
																</tr>
1846
																<tr>
1847
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></font></td><td><input id="gatewayip" name="gatewayip" /></td>
1848
																</tr>
1849
																<tr>
1850
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescr" name="gatewaydescr" /></td>
1851
																</tr>
1852
																<tr><td>&nbsp;</td></tr>
1853
																<tr>
1854
																	<td colspan="2">
1855
																		<center>
1856
																			<div id='savebuttondiv'>
1857
																				<input id="gwsave" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave();' />
1858
																				<input id="gwcancel" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway();' />
1859
																			</div>
1860
																		</center>
1861
																	</td>
1862
																</tr>
1863
																<tr><td>&nbsp;</td></tr>
1864
															</table>
1865
														</td>
1866
													</tr>
1867
												</table>
1868
											</div>
1869
										</td>
1870
									</tr>
1871
									<tr>
1872
										<td colspan="2" valign="top" height="16"></td>
1873
									</tr>
1874
								</table>
1875
							</td>
1876
						</tr>
1877
						<tr style="display:none;" id="staticv6">
1878
							<td colspan="2" style="padding:0px;">
1879
								<a name="gatewayv6section"></a>
1880
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv6">
1881
									<tr>
1882
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1883
									</tr>
1884
									<tr>
1885
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1886
										<td width="78%" class="vtable">
1887
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>" />
1888
											/
1889
											<select name="subnetv6" class="formselect" id="subnetv6">
1890
												<?php
1891
												for ($i = 128; $i > 0; $i--) {
1892
													echo "<option value=\"{$i}\" ";
1893
													if ($i == $pconfig['subnetv6']) echo "selected=\"selected\"";
1894
													echo ">" . $i . "</option>";
1895
												}
1896
												?>
1897
											</select>
1898
										</td>
1899
									</tr>
1900
									<tr>
1901
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Upstream Gateway"); ?></td>
1902
										<td width="78%" class="vtable">
1903
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1904
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1905
													<?php
1906
													if(count($a_gateways) > 0) {
1907
														foreach ($a_gateways as $gateway) {
1908
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1909
													?>
1910
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected=\"selected\""; ?>>
1911
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1912
															</option>
1913
													<?php
1914
															}
1915
														}
1916
													}
1917
													?>
1918
											</select>
1919
											- or <strong><a onclick="show_add_gateway_v6();" href="#gatewayv6section"><?=gettext("add a new one."); ?></a></strong>
1920
											<br />
1921
											<div id='addgwboxv6'>
1922
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above."); ?><br />
1923
												<?=gettext("On local LANs the upstream gateway should be \"none\"."); ?>
1924
											</div>
1925
											<div id='noteboxv6'>
1926
											</div>
1927
											<div id="statusv6">
1928
											</div>
1929
											<div style="display:none" id="addgatewayv6">
1930
												<p>&nbsp;</p>
1931
												<table border="1" class="addgatewaybox" summary="addgatewayv6">
1932
													<tr>
1933
														<td>
1934
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgatewayv6">
1935
																<tr><td>&nbsp;</td></tr>
1936
																<tr>
1937
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1938
																</tr>
1939
																<tr><td>&nbsp;</td></tr>
1940
																<?php
1941
																if($if == "wan" || $if == "WAN")
1942
																	$checked = " checked=\"checked\"";
1943
																?>
1944
																<tr>
1945
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></font></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?> /></td>
1946
																</tr>
1947
																<tr>
1948
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></font></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>" /></td>
1949
																</tr>
1950
																<tr>
1951
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></font></td><td><input id="gatewayipv6" name="gatewayipv6" /></td>
1952
																</tr>
1953
																<tr>
1954
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescrv6" name="gatewaydescrv6" /></td>
1955
																</tr>
1956
																<tr><td>&nbsp;</td></tr>
1957
																<tr>
1958
																	<td colspan="2">
1959
																		<center>
1960
																			<div id='savebuttondivv6'>
1961
																				<input id="gwsavev6" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave_v6();' />
1962
																				<input id="gwcancelv6" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway_v6();' />
1963
																			</div>
1964
																		</center>
1965
																	</td>
1966
																</tr>
1967
																<tr><td>&nbsp;</td></tr>
1968
															</table>
1969
														</td>
1970
													</tr>
1971
												</table>
1972
											</div>
1973
										</td>
1974
									</tr>
1975
									<tr>
1976
										<td colspan="2" valign="top" height="16"></td>
1977
									</tr>
1978
								</table>
1979
							</td>
1980
						</tr>
1981
						<tr style="display:none;" id="dhcp">
1982
							<td colspan="2" style="padding: 0px;">
1983
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp">
1984
									<tr>
1985
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration &nbsp; &nbsp; " .
1986
										' <input name="adv_dhcp_config_advanced" type="checkbox" id="adv_dhcp_config_advanced" value="" onclick="show_adv_dhcp_config(this)" /> ' .
1987
										" Advanced &nbsp; &nbsp; " .
1988
										' <input name="adv_dhcp_config_file_override" type="checkbox" id="adv_dhcp_config_file_override" value="" onclick="show_adv_dhcp_config(this)" /> ' .
1989
										" Config File Override &nbsp; &nbsp; "); ?>
1990
										</td>
1991
									</tr>
1992
									<!-- Uncomment to expose DHCP+ in GUI
1993
									<tr>
1994
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1995
										<td width="78%" class="vtable">
1996
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked=\"checked\""; ?> />
1997
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1998
										<br />
1999
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
2000
										</td>
2001
									</tr>
2002
									-->
2003
									<tr style='display:none' id="show_basic_dhcphostname">
2004
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
2005
										<td width="78%" class="vtable">
2006
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>" />
2007
											<br />
2008
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
2009
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
2010
											"this (for client identification)."); ?>
2011
										</td>
2012
									</tr>
2013
									<tr style='display:none' id="show_basic_dhcpalias-address">
2014
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
2015
										<td width="78%" class="vtable">
2016
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>" />
2017
											<select name="alias-subnet" class="formselect" id="alias-subnet">
2018
												<?php
2019
												for ($i = 32; $i > 0; $i--) {
2020
													echo "<option value=\"{$i}\" ";
2021
													if ($i == $pconfig['alias-subnet']) echo "selected=\"selected\"";
2022
													echo ">" . $i . "</option>";
2023
												}
2024
												?>
2025
											</select>
2026
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
2027
											"DHCP client."); ?>
2028
										</td>
2029
									</tr>
2030
									<tr style='display:none' id="show_basic_dhcprejectlease">
2031
										<td width="22%" valign="top" class="vncell"><?=gettext("Reject Leases From"); ?></td>
2032
										<td width="78%" class="vtable">
2033
											<input name="dhcprejectfrom" type="text" class="formfld unknown" id="dhcprejectfrom" size="20" value="<?=htmlspecialchars($pconfig['dhcprejectfrom']);?>" />
2034
											<br />
2035
											<?=gettext("If there is a certain upstream DHCP server that should be ignored, place the IP address or subnet of the DHCP server to be ignored here."); ?>
2036
											<?=gettext("This is useful for rejecting leases from cable modems that offer private IPs when they lose upstream sync."); ?>
2037
										</td>
2038
									</tr>
2039

    
2040
									<tr style='display:none' id="show_adv_dhcp_protocol_timing">
2041
										<td width="22%" valign="top" class="vncell"><a target="_blank" href="http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#PROTOCOL_TIMING"><?=gettext("Protocol Timing"); ?></a></td>
2042
										<td width="48%" class="vtable">
2043
											Timeout: <input name="adv_dhcp_pt_timeout" type="text" class="formfld unknown" id="adv_dhcp_pt_timeout" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_timeout']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
2044
											Retry:   <input name="adv_dhcp_pt_retry"   type="text" class="formfld unknown" id="adv_dhcp_pt_retry"   size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_retry']);?>"   onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
2045
											Select Timeout: <input name="adv_dhcp_pt_select_timeout" type="text" class="formfld unknown" id="adv_dhcp_pt_select_timeout" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_select_timeout']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
2046

    
2047
											&nbsp; &nbsp; &nbsp; &nbsp; 
2048
											Presets: &nbsp;
2049
											<input name="adv_dhcp_pt_values" type="radio" value="DHCP"	id="customdhcpptdhcpdefaults"	onclick="customdhcpptsetvalues(this, iform);" />FreeBSD Default &nbsp; 
2050
											<input name="adv_dhcp_pt_values" type="radio" value="Clear"	id="customdhcpptclear"		onclick="customdhcpptsetvalues(this, iform);" />Clear
2051

    
2052
											<br />
2053
											Reboot: <input name="adv_dhcp_pt_reboot" type="text" class="formfld unknown" id="adv_dhcp_pt_reboot" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_reboot']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
2054
											Backoff Cutoff:   <input name="adv_dhcp_pt_backoff_cutoff"   type="text" class="formfld unknown" id="adv_dhcp_pt_backoff_cutoff"   size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_backoff_cutoff']);?>"   onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
2055
											Initial Interval: <input name="adv_dhcp_pt_initial_interval" type="text" class="formfld unknown" id="adv_dhcp_pt_initial_interval" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp_pt_initial_interval']);?>" onchange="customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, '');" />
2056

    
2057
											&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
2058
											<input name="adv_dhcp_pt_values" type="radio" value="pfSense"	id="customdhcpptpfsensedefaults"	onclick="customdhcpptsetvalues(this, iform);" />pfSense Default &nbsp; 
2059
											<input name="adv_dhcp_pt_values" type="radio" value="SavedCfg" checked="checked"	id="customdhcpptsavedcfg"		onclick="customdhcpptsetvalues(this, iform);" />Saved Cfg 
2060

    
2061
											<br />
2062
											<?=gettext("The values in these fields are DHCP protocol timings used when requesting a lease. <br /> " ); ?>
2063

    
2064
											<script type="text/javascript">
2065
											//<![CDATA[
2066
												function customdhcpptcheckradiobuton(T, BUTTON) {
2067
													for (var i = 0; i < T.length; i++) {
2068
														T[i].checked = false;
2069
														if (T[i].value == BUTTON) T[i].checked = true;
2070
													}
2071
													T.value = BUTTON;
2072
												}
2073

    
2074
												function customdhcpptsetvalues(T, FORM) {
2075
													// timeout, retry, select-timeout, reboot, backoff-cutoff, initial-interval
2076
													if (T.value == "DHCP")		customdhcpptsetvaluesnow(T, FORM, "60", "300", "0", "10", "120", "10");
2077
													if (T.value == "pfSense")	customdhcpptsetvaluesnow(T, FORM, "60", "15", "0", "", "", "1");
2078
													if (T.value == "SavedCfg")	customdhcpptsetvaluesnow(T, FORM, "<?=htmlspecialchars($pconfig['adv_dhcp_pt_timeout']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_retry']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_select_timeout']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_reboot']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_backoff_cutoff']);?>", "<?=htmlspecialchars($pconfig['adv_dhcp_pt_initial_interval']);?>");
2079
													if (T.value == "Clear")		customdhcpptsetvaluesnow(T, FORM, "", "", "", "", "", "");
2080
												}
2081

    
2082
												function customdhcpptsetvaluesnow(T, FORM, timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
2083
													FORM.adv_dhcp_pt_timeout.value = timeout;
2084
													FORM.adv_dhcp_pt_retry.value = retry;
2085
													FORM.adv_dhcp_pt_select_timeout.value = selecttimeout;
2086
													FORM.adv_dhcp_pt_reboot.value = reboot;
2087
													FORM.adv_dhcp_pt_backoff_cutoff.value = backoffcutoff;
2088
													FORM.adv_dhcp_pt_initial_interval.value = initialinterval;
2089

    
2090
													FORM.adv_dhcp_pt_values.value = T.value;
2091
												}
2092

    
2093
												<!-- Set the adv_dhcp_pt_values radio button from saved config -->
2094
												var RADIOBUTTON_VALUE = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values']);?>";
2095
												if (RADIOBUTTON_VALUE == "") RADIOBUTTON_VALUE = "SavedCfg";
2096
												customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, RADIOBUTTON_VALUE);
2097
											//]]>
2098
											</script>
2099
										</td>
2100
									</tr>
2101

    
2102
									<tr style='display:none' id="show_adv_dhcp_lease_requirements_and_requests">
2103
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Lease Requirements and Requests</a>"); ?></td>
2104
										<td width="78%" class="vtable">
2105
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Send</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Options</a>"); ?><br />
2106
											<input name="adv_dhcp_send_options" type="text" class="formfld unknown" id="adv_dhcp_send_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_send_options']);?>" />
2107
											<br />
2108
											<?=gettext("The values in this field are DHCP options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2109
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2110
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2111
											"Some ISPs may require certain options be or not be sent. "); ?>
2112
											<hr/>
2113
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Request</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Options</a>"); ?><br />
2114
											<input name="adv_dhcp_request_options" type="text" class="formfld unknown" id="adv_dhcp_request_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_request_options']);?>" />
2115
											<br />
2116
											<?=gettext("The values in this field are DHCP option 55 to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2117
											"Some ISPs may require certain options be or not be requested. "); ?>
2118
											<hr/>
2119
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#LEASE_REQUIREMENTS_AND_REQUESTS\">Require</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Options</a>"); ?><br />
2120
											<input name="adv_dhcp_required_options" type="text" class="formfld unknown" id="adv_dhcp_required_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_required_options']);?>" />
2121
											<br />
2122
											<?=gettext("The values in this field are DHCP options required by the client when requesting a DHCP lease.  [option [, ...]] "); ?>
2123
										</td>
2124
									</tr>
2125

    
2126
									<tr style='display:none' id="show_adv_dhcp_option_modifiers">
2127
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp-options&amp;sektion=5\">Option</a> <a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5#OPTION_MODIFIERS\">Modifiers</a>"); ?></td>
2128
										<td width="78%" class="vtable">
2129
											<input name="adv_dhcp_option_modifiers" type="text" class="formfld unknown" id="adv_dhcp_option_modifiers" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_option_modifiers']);?>" />
2130
											<br />
2131
											<?=gettext("The values in this field are DHCP option modifiers applied to obtained DHCP lease.  [modifier option declaration [, ...]] <br /> " .
2132
											"modifiers: (default, supersede, prepend, append)"); ?>
2133
										</td>
2134
									</tr>
2135

    
2136
									<tr style='display:none' id="show_adv_dhcp_config_file_override">
2137
										<td width="22%" valign="top" class="vncell"><?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhclient.conf&amp;sektion=5\">Configuration File</a> Override"); ?></td>
2138
										<td width="78%" class="vtable">
2139
 											<input name="adv_dhcp_config_file_override_path"   type="text" class="formfld unknown" id="adv_dhcp_config_file_override_path"  size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override_path']);?>" />
2140
											<br />
2141
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2142
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2143
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2144
											"Some ISPs may require certain options be or not be sent. "); ?>
2145
										</td>
2146
									</tr>
2147

    
2148
 									<tr>
2149
 										<td colspan="2" valign="top" height="16"></td>
2150
 									</tr>
2151

    
2152
								</table>
2153

    
2154
									<script type="text/javascript">
2155
									//<![CDATA[
2156
										function show_adv_dhcp_config(T) {
2157

    
2158
											if (T.checked) T.value = "Selected";
2159
											else T.value = "";
2160

    
2161
											     if (document.iform.adv_dhcp_config_file_override.checked)	show_hide_adv_dhcp('none', 'none', '');
2162
											else if (document.iform.adv_dhcp_config_advanced.checked)	show_hide_adv_dhcp('', '', 'none');
2163
											else 									show_hide_adv_dhcp('', 'none', 'none');
2164
										}
2165

    
2166
										function show_hide_adv_dhcp(basic, advanced, override) {
2167

    
2168
											document.getElementById("show_basic_dhcphostname").style.display = basic;
2169
											document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2170
											document.getElementById("show_basic_dhcprejectlease").style.display = basic;
2171

    
2172
											document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2173
											document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2174
											document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2175

    
2176
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2177
										}
2178

    
2179
										<!-- Set the adv_dhcp_config_advanced checkbox from saved config -->
2180
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_advanced']);?>" == "Selected") document.iform.adv_dhcp_config_advanced.checked = true;
2181
										show_adv_dhcp_config(document.iform.adv_dhcp_config_advanced);
2182

    
2183
										<!-- Set the adv_dhcp_config_file_override checkbox from saved config -->
2184
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override']);?>" == "Selected") document.iform.adv_dhcp_config_file_override.checked = true;
2185
										show_adv_dhcp_config(document.iform.adv_dhcp_config_file_override);
2186
									//]]>
2187
									</script>
2188

    
2189
							</td>
2190
						</tr>
2191
						<tr style="display:none;" id="dhcp6">
2192
							<td colspan="2" style="padding: 0px;">
2193
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp6">
2194
									<tr>
2195
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration &nbsp; &nbsp; " .
2196
										' <input name="adv_dhcp6_config_advanced" type="checkbox" id="adv_dhcp6_config_advanced" value="" onclick="show_adv_dhcp6_config(this)" /> ' .
2197
										" Advanced &nbsp; &nbsp; " .
2198
										' <input name="adv_dhcp6_config_file_override" type="checkbox" id="adv_dhcp6_config_file_override" value="" onclick="show_adv_dhcp6_config(this)" /> ' .
2199
										" Config File Override &nbsp; &nbsp; "); ?>
2200
										</td>
2201
									</tr>
2202
									<!--- Leave commented out for now
2203
									<tr style='display:none' id="basicdhcp6_show_dhcp6_duid">
2204
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
2205
										<td width="78%" class="vtable">
2206
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>" />
2207
											<br />
2208
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
2209
											"when requesting a DHCPv6 lease."); ?><br />
2210
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
2211
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
2212
												}
2213
												printf(gettext("The current DUID is: '%s'"),$current_duid);
2214
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
2215
											?>
2216
										</td>
2217
									</tr>
2218
									-->
2219
									<tr style='display:none' id="basicdhcp6_use_pppoeinterface">
2220
										<td width="22%" valign="top" class="vncell"><?=gettext("Use IPv4 connectivity as parent interface"); ?></td>
2221
										<td width="78%" class="vtable">
2222
											<input name="dhcp6usev4iface" type="checkbox" id="dhcp6usev4iface" value="yes" <?php if ($pconfig['dhcp6usev4iface'] == true) echo "checked=\"checked\""; ?> />
2223
											<?=gettext("Request a IPv6 prefix/information through the IPv4 connectivity link"); ?>
2224
										</td>
2225
									</tr>
2226
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_only">
2227
										<td width="22%" valign="top" class="vncell"><?=gettext("Request only a IPv6 prefix"); ?></td>
2228
										<td width="78%" class="vtable">
2229
											<input name="dhcp6prefixonly" type="checkbox" id="dhcp6prefixonly" value="yes" <?php if ($pconfig['dhcp6prefixonly'] == true) echo "checked=\"checked\""; ?> />
2230
											<?=gettext("Only request a IPv6 prefix, do not request a IPv6 address"); ?>
2231
										</td>
2232
									</tr>
2233
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_delegation_size">
2234
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
2235
										<td width="78%" class="vtable">
2236
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
2237
												<?php
2238
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
2239
												foreach($sizes as $bits => $length) {
2240
													echo "<option value=\"{$bits}\" ";
2241
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected=\"selected\"";
2242
													echo ">" . $length . "</option>";
2243
												}
2244
												?>
2245
											</select>
2246
											<br />
2247
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
2248
										</td>
2249
									</tr>
2250
									<tr style='display:none' id="basicdhcp6_show_dhcp6_prefix_send_hint">
2251
										<td width="22%" valign="top" class="vncell"><?=gettext("Send IPv6 prefix hint"); ?></td>
2252
										<td width="78%" class="vtable">
2253
											<input name="dhcp6-ia-pd-send-hint" type="checkbox" id="dhcp6-ia-pd-send-hint" value="yes" <?php if ($pconfig['dhcp6-ia-pd-send-hint'] == true) echo "checked=\"checked\""; ?> />
2254
											<?=gettext("Send an IPv6 prefix hint to indicate the desired prefix size for delegation"); ?>
2255
										</td>
2256
									</tr>
2257

    
2258
									<tr style='display:none' id="show_adv_dhcp6_interface_statement">
2259
										<td width="22%" valign="top" class="vncell">
2260
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Interface_statement\">Interface Statement</a>"); ?>
2261
											<br /><br />
2262
											<input name="adv_dhcp6_interface_statement_information_only_enable" type="checkbox" id="adv_dhcp6_interface_statement_information_only_enable" value="" onclick="show_adv_dhcp6_config(this)" />
2263
											<?=gettext("Information Only"); ?>
2264
										</td>
2265
										<td width="78%" class="vtable">
2266
											<?=gettext("Send Options"); ?><br />
2267
											<input name="adv_dhcp6_interface_statement_send_options" type="text" class="formfld unknown" id="adv_dhcp6_interface_statement_send_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_send_options']);?>" />
2268
											<br />
2269
											<?=gettext("The values in this field are DHCP send options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2270
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2271
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2272
											"Some DHCP services may require certain options be or not be sent. "); ?>
2273
											<br />
2274
											<br />
2275
											<?=gettext("Request Options"); ?><br />
2276
											<input name="adv_dhcp6_interface_statement_request_options" type="text" class="formfld unknown" id="adv_dhcp6_interface_statement_request_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_request_options']);?>" />
2277
											<br />
2278
											<?=gettext("The values in this field are DHCP request options to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2279
											"Some DHCP services may require certain options be or not be requested. "); ?>
2280
											<br />
2281
											<br />
2282
											<?=gettext("Script"); ?><br />
2283
											<input name="adv_dhcp6_interface_statement_script" type="text" class="formfld unknown" id="adv_dhcp6_interface_statement_script" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_script']);?>" />
2284
											<br />
2285
											<?=gettext("The value in this field is the absolute path to a script invoked on certain conditions including when a reply message is received. <br />" .
2286
											"[/[dirname/[.../]]filename[.ext]] "); ?>
2287
										</td>
2288
									</tr>
2289

    
2290
									<tr style='display:none' id="show_adv_dhcp6_id_assoc_statement">
2291
										<td width="22%" valign="top" class="vncell">
2292
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Identity_association_statement\">Identity Association Statement</a>"); ?>
2293
										</td>
2294
										<td width="78%" class="vtable">
2295

    
2296
											<input name="adv_dhcp6_id_assoc_statement_address_enable" type="checkbox" id="adv_dhcp6_id_assoc_statement_address_enable" value="" onclick="show_adv_dhcp6_config(this);" />
2297
											<?=gettext("Non-Temporary Address Allocation"); ?>
2298
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_address">
2299
											<?=gettext("id-assoc na"); ?>
2300
											<?=gettext("<i>ID</i>"); ?>
2301
											<input name="adv_dhcp6_id_assoc_statement_address_id" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address_id" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_id']);?>" />
2302
											<br />
2303
											<?=gettext("Address"); ?>
2304
											<?=gettext("<i>ipv6-address</i>"); ?>
2305
											<input name="adv_dhcp6_id_assoc_statement_address" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address" size="34" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address']);?>" />
2306
											<?=gettext("<i>pltime</i>"); ?>
2307
											<input name="adv_dhcp6_id_assoc_statement_address_pltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address_pltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_pltime']);?>" />
2308
											<?=gettext("<i>vltime</i>"); ?>
2309
											<input name="adv_dhcp6_id_assoc_statement_address_vltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_address_vltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_vltime']);?>" />
2310
											</div>
2311
											<hr/>
2312

    
2313
											<input name="adv_dhcp6_id_assoc_statement_prefix_enable" type="checkbox" id="adv_dhcp6_id_assoc_statement_prefix_enable" value="" onclick="show_adv_dhcp6_config(this)" />
2314
											<?=gettext("Prefix Delegation"); ?>
2315
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_prefix">
2316
											<?=gettext("id-assoc pd"); ?>
2317
											<?=gettext("<i>ID</i>"); ?>
2318
											<input name="adv_dhcp6_id_assoc_statement_prefix_id" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix_id" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_id']);?>" />
2319
											<br />
2320
											<?=gettext("Prefix"); ?>
2321
											<?=gettext("<i>ipv6-prefix</i>"); ?>
2322
											<input name="adv_dhcp6_id_assoc_statement_prefix" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix" size="37" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix']);?>" />
2323
											<?=gettext("<i>pltime</i>"); ?>
2324
											<input name="adv_dhcp6_id_assoc_statement_prefix_pltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix_pltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime']);?>" />
2325
											<?=gettext("<i>vltime</i>"); ?>
2326
											<input name="adv_dhcp6_id_assoc_statement_prefix_vltime" type="text" class="formfld unknown" id="adv_dhcp6_id_assoc_statement_prefix_vltime" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime']);?>" />
2327
											</div>
2328
										</td>
2329
									</tr>
2330

    
2331
									<tr style='display:none' id="show_adv_dhcp6_prefix_interface_statement">
2332
										<td width="22%" valign="top" class="vncell">
2333
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Prefix_interface_statement\">Prefix Interface Statement</a>"); ?>
2334
										</td>
2335
										<td width="78%" class="vtable">
2336
											<?=gettext("Prefix Interface "); ?>
2337
											<?=gettext("<i>sla-id</i>"); ?>
2338
											<input name="adv_dhcp6_prefix_interface_statement_sla_id" type="text" class="formfld unknown" id="adv_dhcp6_prefix_interface_statement_sla_id" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_prefix_interface_statement_sla_id']);?>" />
2339
											<?=gettext("<i>sla-len</i>"); ?>
2340
											<input name="adv_dhcp6_prefix_interface_statement_sla_len" type="text" class="formfld unknown" id="adv_dhcp6_prefix_interface_statement_sla_len" size="3" value="<?=htmlspecialchars($pconfig['adv_dhcp6_prefix_interface_statement_sla_len']);?>" />
2341
										</td>
2342
									</tr>
2343

    
2344
									<tr style='display:none' id="show_adv_dhcp6_authentication_statement">
2345
										<td width="22%" valign="top" class="vncell">
2346
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Authentication_statement\">Authentication Statement</a>"); ?>
2347
										</td>
2348
										<td width="78%" class="vtable">
2349
											<?=gettext("<i>authname</i>"); ?>
2350
											<input name="adv_dhcp6_authentication_statement_authname" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_authname" size="10" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_authname']);?>" />
2351
											<?=gettext("<i>protocol</i>"); ?>
2352
											<input name="adv_dhcp6_authentication_statement_protocol" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_protocol" size="6" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_protocol']);?>" />
2353
											<?=gettext("<i>algorithm</i>"); ?>
2354
											<input name="adv_dhcp6_authentication_statement_algorithm" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_algorithm" size="8" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_algorithm']);?>" />
2355
											<?=gettext("<i>rdm</i>"); ?>
2356
											<input name="adv_dhcp6_authentication_statement_rdm" type="text" class="formfld unknown" id="adv_dhcp6_authentication_statement_rdm" size="9" value="<?=htmlspecialchars($pconfig['adv_dhcp6_authentication_statement_rdm']);?>" />
2357
										</td>
2358
									</tr>
2359

    
2360
									<tr style='display:none' id="show_adv_dhcp6_key_info_statement">
2361
										<td width="22%" valign="top" class="vncell">
2362
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports#Keyinfo_statement\">Keyinfo Statement</a>"); ?>
2363
										</td>
2364
										<td width="78%" class="vtable">
2365
											<?=gettext("<i>keyname</i>"); ?>
2366
											<input name="adv_dhcp6_key_info_statement_keyname" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_keyname" size="27" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_keyname']);?>" />
2367
											<?=gettext("<i>realm</i>"); ?>
2368
											<input name="adv_dhcp6_key_info_statement_realm" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_realm" size="37" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_realm']);?>" />
2369
											<br />
2370
											<?=gettext("<i>keyid</i>"); ?>
2371
											<input name="adv_dhcp6_key_info_statement_keyid" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_keyid" size="2" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_keyid']);?>" />
2372
											<?=gettext("<i>secret</i>"); ?>
2373
											<input name="adv_dhcp6_key_info_statement_secret" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_secret" size="36" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_secret']);?>" />
2374
											<?=gettext("<i>expire</i>"); ?>
2375
											<input name="adv_dhcp6_key_info_statement_expire" type="text" class="formfld unknown" id="adv_dhcp6_key_info_statement_expire" size="15" value="<?=htmlspecialchars($pconfig['adv_dhcp6_key_info_statement_expire']);?>" />
2376
										</td>
2377
									</tr>
2378

    
2379
									<tr style='display:none' id="show_adv_dhcp6_config_file_override">
2380
										<td width="22%" valign="top" class="vncell">
2381
											<?=gettext("<a target=\"FreeBSD_DHCP\" href=\"http://www.freebsd.org/cgi/man.cgi?query=dhcp6c.conf&amp;sektion=5&amp;apropos=0&amp;manpath=FreeBSD+Ports\">Configuration File</a> Override"); ?>
2382
										</td>
2383
										<td width="78%" class="vtable">
2384
 											<input name="adv_dhcp6_config_file_override_path"   type="text" class="formfld unknown" id="adv_dhcp6_config_file_override_path"  size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override_path']);?>" />
2385
											<br />
2386
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2387
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2388
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2389
											"Some ISPs may require certain options be or not be sent. "); ?>
2390
										</td>
2391
									</tr>
2392

    
2393
 									<tr>
2394
 										<td colspan="2" valign="top" height="16"></td>
2395
 									</tr>
2396

    
2397
								</table>
2398

    
2399
									<script type="text/javascript">
2400
									//<![CDATA[
2401
										function show_adv_dhcp6_config(T) {
2402

    
2403
											if (T.checked) T.value = "Selected";
2404
											else T.value = "";
2405

    
2406
											     if (document.iform.adv_dhcp6_config_file_override.checked)	show_hide_adv_dhcp6('none', 'none', ''    );
2407
											else if (document.iform.adv_dhcp6_config_advanced.checked)		show_hide_adv_dhcp6('none', '',     'none');
2408
											else 															show_hide_adv_dhcp6('',     'none', 'none');
2409
										}
2410

    
2411
										function show_hide_adv_dhcp6(basic, advanced, override) {
2412

    
2413
											document.getElementById("basicdhcp6_use_pppoeinterface").style.display = basic;
2414
											document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2415
											document.getElementById("basicdhcp6_show_dhcp6_prefix_send_hint").style.display = basic;
2416
											document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
2417

    
2418
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2419
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2420

    
2421
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2422
											if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked)  {
2423
												document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2424
											}
2425

    
2426
											document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = 'none';
2427
											document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = 'none';
2428
											if (document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked)  {
2429
												document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = advanced;
2430
												document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = advanced;
2431
											}
2432

    
2433
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2434
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2435

    
2436
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2437
										}
2438

    
2439
										<!-- Set the adv_dhcp6_config_advanced checkbox from saved config -->
2440
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_advanced']);?>" == "Selected") document.iform.adv_dhcp6_config_advanced.checked = true;
2441
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_advanced);
2442

    
2443
										<!-- Set the adv_dhcp6_config_file_override checkbox from saved config -->
2444
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_config_file_override']);?>" == "Selected") document.iform.adv_dhcp6_config_file_override.checked = true;
2445
										show_adv_dhcp6_config(document.iform.adv_dhcp6_config_file_override);
2446

    
2447
										<!-- Set the adv_dhcp6_interface_statement_information_only_enable checkbox from saved config -->
2448
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_interface_statement_information_only_enable']);?>" == "Selected") document.iform.adv_dhcp6_interface_statement_information_only_enable.checked = true;
2449
										show_adv_dhcp6_config(document.iform.adv_dhcp6_interface_statement_information_only_enable);
2450

    
2451
										<!-- Set the adv_dhcp6_id_assoc_statement_address_enable checkbox from saved config -->
2452
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_address_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked = true;
2453
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_address_enable);
2454

    
2455
										<!-- Set the adv_dhcp6_id_assoc_statement_prefix_enable checkbox from saved config -->
2456
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked = true;
2457
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_prefix_enable);
2458
									//]]>
2459
									</script>
2460

    
2461
							</td>
2462
						</tr>
2463
						<tr style="display:none;" id="_6rd">
2464
							<td colspan="2" style="padding: 0px;">
2465
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="6rd">
2466
									<tr>
2467
										<td colspan="2" valign="top" class="listtopic"><?=gettext("6RD Configuration"); ?></td>
2468
									</tr>
2469
									<tr>
2470
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD prefix"); ?></td>
2471
										<td width="78%" class="vtable">
2472
											<input name="prefix-6rd" type="text" class="formfld unknown" id="prefix-6rd" size="40" value="<?=htmlspecialchars($pconfig['prefix-6rd']);?>" />
2473
											<br />
2474
											<?=gettext("The value in this field is the 6RD IPv6 prefix assigned by your ISP. e.g. '2001:db8::/32'") ?><br />
2475
										</td>
2476
									</tr>
2477
									<tr>
2478
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD Border Relay"); ?></td>
2479
										<td width="78%" class="vtable">
2480
											<input name="gateway-6rd" type="text" class="formfld unknown" id="gateway-6rd" size="40" value="<?=htmlspecialchars($pconfig['gateway-6rd']);?>" />
2481
											<br />
2482
											<?=gettext("The value in this field is 6RD IPv4 gateway address assigned by your ISP") ?><br />
2483
										</td>
2484
									</tr>
2485
									<tr>
2486
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD IPv4 Prefix length"); ?></td>
2487
										<td width="78%" class="vtable">
2488
											<select name="prefix-6rd-v4plen" class="formselect" id="prefix-6rd-v4plen">
2489
												<?php
2490
												for ($i = 0; $i < 32; $i++) {
2491
													echo "<option value=\"{$i}\" ";
2492
													if (is_numeric($pconfig['prefix-6rd-v4plen']) && ($i == $pconfig['prefix-6rd-v4plen'])) echo "selected=\"selected\"";
2493
													echo ">" . $i . " bits</option>";
2494
												}
2495
												?>
2496
											</select>
2497
											<br />
2498
											<?=gettext("The value in this field is the 6RD IPv4 prefix length. Normally specified by the ISP. A value of 0 means we embed the entire IPv4 address in the 6RD prefix."); ?>
2499
										</td>
2500
									</tr>
2501
									<tr>
2502
										<td colspan="2" valign="top" height="16"></td>
2503
									</tr>
2504
								</table>
2505
							</td>
2506
						</tr>
2507
						<tr style="display:none;" id="track6">
2508
							<td colspan="2" style="padding: 0px;">
2509
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="track6">
2510
									<tr>
2511
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
2512
									</tr>
2513
									<tr>
2514
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
2515
										<td width="78%" class="vtable">
2516
										<select name="track6-interface" id='track6-interface' class='formselect' onchange="update_track6_prefix();">
2517
										<?php
2518
											$interfaces = get_configured_interface_with_descr(false, true);
2519
											$dynv6ifs = array();
2520
											foreach ($interfaces as $iface => $ifacename) {
2521
												switch($config['interfaces'][$iface]['ipaddrv6']) {
2522
													case "6to4":
2523
													case "6rd":
2524
													case "dhcp6":
2525
														$dynv6ifs[$iface] = array(
2526
															'name' => $ifacename,
2527
															'ipv6_num_prefix_ids' => pow(2, calculate_ipv6_delegation_length($iface)) - 1
2528
														);
2529
														break;
2530
													default:
2531
														continue;
2532
												}
2533
											}
2534
											$rowIndex = 0;
2535
											foreach($dynv6ifs as $iface => $ifacedata) {
2536
												$rowIndex++;
2537
												echo "<option value=\"{$iface}\"";
2538
												if ($iface == $pconfig['track6-interface'])
2539
													echo " selected=\"selected\"";
2540
												echo ">" . htmlspecialchars($ifacedata['name']) . "</option>";
2541
											}
2542
											if ($rowIndex == 0)
2543
												echo "<option></option>";
2544
										?>
2545
										</select> <br />
2546
										<?php
2547
											foreach($dynv6ifs as $iface => $ifacedata) {
2548
												echo "<input type=\"hidden\" name=\"ipv6-num-prefix-ids-{$iface}\" id=\"ipv6-num-prefix-ids-{$iface}\" value=\"{$ifacedata['ipv6_num_prefix_ids']}\">\n";
2549
											}
2550
										?>
2551
											<br />
2552
											<?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
2553
										</td>
2554
									</tr>
2555
									<tr>
2556
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
2557
										<td width="78%" class="vtable">
2558
											<?php
2559
												if ($pconfig['track6-prefix-id'] == "")
2560
													$pconfig['track6-prefix-id'] = 0;
2561
												$track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
2562
											?>
2563
											<input name="track6-prefix-id--hex" type="text" class="formfld unknown" id="track6-prefix-id--hex" size="8" value="<?= $track6_prefix_id_hex ?>" />
2564
											<span id="track6-prefix-id-range"></span>
2565
											<input type="hidden" id="track6-prefix-id-max" value="0"></input>
2566
											<br />
2567
											<?= gettext("The value in this field is the (Delegated) IPv6 prefix ID. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
2568
											<br />
2569
											<?= gettext("default value is 0."); ?>
2570
										</td>
2571
									</tr>
2572
									<tr>
2573
										<td colspan="2" valign="top" height="16"></td>
2574
									</tr>
2575
								</table>
2576
							</td>
2577
						</tr>
2578
						<tr style="display:none;" id="ppp">
2579
							<td colspan="2" style="padding: 0px;">
2580
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="ppp">
2581
									<tr>
2582
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
2583
									</tr>
2584
									<tr id="ppp_provider">
2585
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
2586
										<td width="78%" class="vtable">
2587
											<table border="0" cellpadding="0" cellspacing="0" summary="service provider">
2588
												<tr id="trcountry">
2589
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
2590
													<td>
2591
														<select class="formselect" name="country" id="country" onchange="providers_list()">
2592
															<option></option>
2593
														</select>
2594
													</td>
2595
												</tr>
2596
												<tr id="trprovider" style="display:none">
2597
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
2598
													<td>
2599
														<select class="formselect" name="provider_list" id="provider_list" onchange="providerplan_list()">
2600
															<option></option>
2601
														</select>
2602
													</td>
2603
												</tr>
2604
												<tr id="trproviderplan" style="display:none">
2605
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
2606
													<td>
2607
														<select class="formselect" name="providerplan" id="providerplan" onchange="prefill_provider()">
2608
															<option></option>
2609
														</select>
2610
													</td>
2611
												</tr>
2612
											</table>
2613
											<br /><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
2614
										</td>
2615
									</tr>
2616
									<tr>
2617
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
2618
										<td width="78%" class="vtable">
2619
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>" />
2620
										</td>
2621
									</tr>
2622
									<tr>
2623
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
2624
										<td width="78%" class="vtable">
2625
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>" />
2626
										</td>
2627
									</tr>
2628
									<tr id="phone_num">
2629
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
2630
										<td width="78%" class="vtable">
2631
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>" />
2632
										</td>
2633
									</tr>
2634
									<tr id="apn_">
2635
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
2636
										<td width="78%" class="vtable">
2637
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>" />
2638
										</td>
2639
									</tr>
2640
									<tr id="interface" >
2641
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
2642
										<td width="78%" class="vtable">
2643
											<select name="port" id="port" class="formselect">
2644
											<?php
2645
												$portlist = glob("/dev/cua*");
2646
												$modems = glob("/dev/modem*");
2647
												$portlist = array_merge($portlist, $modems);
2648
												$rowIndex = 0;
2649
												foreach ($portlist as $port) {
2650
													if(preg_match("/\.(lock|init)$/", $port))
2651
														continue;
2652
													$rowIndex++;
2653
													echo "<option value=\"".trim($port)."\"";
2654
													if ($pconfig['port'] == $port)
2655
														echo " selected=\"selected\"";
2656
													echo ">{$port}</option>";
2657
												}
2658
												if ($rowIndex == 0)
2659
													echo "<option></option>";
2660
												?>
2661
											</select>
2662
										</td>
2663
									</tr>
2664
									<tr>
2665
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
2666
										<?php if (isset($pconfig['pppid'])): ?>
2667
											<td width="78%" class="vtable">
2668
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2669
											<?=gettext("to edit PPP configuration."); ?>
2670
											</td>
2671
										<?php else: ?>
2672
											<td width="78%" class="vtable">
2673
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2674
											<?=gettext("to create a PPP configuration."); ?>
2675
											</td>
2676
										<?php endif; ?>
2677
									</tr>
2678
									<tr>
2679
										<td colspan="2" valign="top" height="16"></td>
2680
									</tr>
2681
								</table>
2682
							</td>
2683
						</tr>
2684
						<tr style="display:none;" id="pppoe">
2685
							<td colspan="2" style="padding:0px;">
2686
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pppoe">
2687
									<tr>
2688
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
2689
									</tr>
2690
									<tr>
2691
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2692
										<td width="78%" class="vtable">
2693
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>" />
2694
										</td>
2695
									</tr>
2696
									<tr>
2697
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2698
										<td width="78%" class="vtable">
2699
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>" />
2700
										</td>
2701
									</tr>
2702
									<tr>
2703
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
2704
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>" />
2705
											<br /> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
2706
										</td>
2707
									</tr>
2708
									<tr>
2709
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2710
										<td width="78%" class="vtable">
2711
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked=\"checked\""; ?> />
2712
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br />
2713
											<?=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."); ?>
2714
										</td>
2715
									</tr>
2716
									<tr>
2717
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2718
										<td width="78%" class="vtable">
2719
											<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."); ?>
2720
										</td>
2721
									</tr>
2722
									<tr>
2723
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
2724
										<td width="78%" class="vtable">
2725
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%" summary="periodic reset">
2726
												<tr>
2727
													<td align="left" valign="top">
2728
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
2729
														<select style="vertical-align:top" id="reset_type" name="pppoe-reset-type" class="formselect" onchange="show_reset_settings(this.value);">
2730
															<option value=""><?=gettext("Disabled"); ?></option>
2731
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected=\"selected\""; ?>><?=gettext("Custom"); ?></option>
2732
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected=\"selected\""; ?>><?=gettext("Pre-Set"); ?></option>
2733
														</select> <?=gettext("Select a reset timing type"); ?>
2734
														</p>
2735
														<?php if ($pconfig['pppoe_pr_custom']): ?>
2736
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
2737
														<?php else: ?>
2738
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
2739
														<?php endif; ?>
2740
														<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" />
2741
														<?=gettext("hour (0-23)"); ?><br />
2742
														<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" />
2743
														<?=gettext("minute (0-59)"); ?><br />
2744
														<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']);?>" />
2745
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
2746
														<br />&nbsp;<br />
2747
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
2748
														<?=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."); ?>
2749
														</p>
2750
														<?php if ($pconfig['pppoe_pr_preset']): ?>
2751
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
2752
														<?php else: ?>
2753
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
2754
														<?php endif; ?>
2755
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
2756
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
2757
														<br />
2758
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
2759
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
2760
														<br />
2761
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
2762
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
2763
														<br />
2764
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
2765
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
2766
														</p>
2767
													</td>
2768
												</tr>
2769
											</table>
2770
										</td>
2771
									</tr>
2772

    
2773
									<tr>
2774
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
2775
										<?php if (isset($pconfig['pppid'])): ?>
2776
											<td width="78%" class="vtable">
2777
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2778
											<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
2779
											</td>
2780
										<?php else: ?>
2781
											<td width="78%" class="vtable">
2782
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2783
											<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
2784
											</td>
2785
										<?php endif; ?>
2786
									</tr>
2787
									<tr>
2788
										<td colspan="2" valign="top" height="16"></td>
2789
									</tr>
2790
								</table>
2791
							</td>
2792
						</tr>
2793
						<tr style="display:none;" id="pptp">
2794
							<td colspan="2" style="padding:0px;">
2795
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="pptp">
2796
									<tr>
2797
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP/L2TP configuration"); ?></td>
2798
									</tr>
2799
									<tr>
2800
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2801
										<td width="78%" class="vtable">
2802
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>" />
2803
										</td>
2804
									</tr>
2805
									<tr>
2806
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2807
										<td width="78%" class="vtable">
2808
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>" />
2809
										</td>
2810
									</tr>
2811
									<tr>
2812
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
2813
										<td width="78%" class="vtable">
2814
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>" />
2815
											/
2816
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
2817
												<?php for ($i = 31; $i > 0; $i--): ?>
2818
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected=\"selected\""; ?>>
2819
														<?=$i;?></option>
2820
												<?php endfor; ?>
2821
											</select>
2822
										</td>
2823
									</tr>
2824
									<tr>
2825
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
2826
										<td width="78%" class="vtable">
2827
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>" />
2828
										</td>
2829
									</tr>
2830
									<tr>
2831
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2832
										<td width="78%" class="vtable">
2833
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked=\"checked\""; ?> />
2834
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br />
2835
											<?=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."); ?>
2836
										</td>
2837
									</tr>
2838
									<tr>
2839
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2840
										<td width="78%" class="vtable">
2841
											<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."); ?>
2842
										</td>
2843
									</tr>
2844
									<tr>
2845
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
2846
										<?php if (isset($pconfig['pppid'])): ?>
2847
											<td width="78%" class="vtable">
2848
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
2849
											<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
2850
											</td>
2851
										<?php else: ?>
2852
											<td width="78%" class="vtable">
2853
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
2854
											<?=gettext("for advanced PPTP and L2TP configuration options");?>.
2855
											</td>
2856
										<?php endif; ?>
2857
									</tr>
2858
									<tr>
2859
										<td colspan="2" valign="top" height="16"></td>
2860
									</tr>
2861
								</table>
2862
							</td>
2863
						</tr>
2864
						<?php
2865
							/* Wireless interface? */
2866
							if (isset($wancfg['wireless'])):
2867
						?>
2868
						<tr>
2869
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
2870
						</tr>
2871
						<tr>
2872
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
2873
							<td class="vtable">
2874
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked=\"checked\"";?> />
2875
								<br /><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
2876
							</td>
2877
						</tr>
2878
						<tr>
2879
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
2880
							<td class="vtable">
2881
							<select name="standard" class="formselect" id="standard">
2882
								<?php
2883
								$rowIndex = 0;
2884
								foreach($wl_modes as $wl_standard => $wl_channels) {
2885
									$rowIndex++;
2886
									echo "<option ";
2887
									if ($pconfig['standard'] == "$wl_standard")
2888
										echo "selected=\"selected\" ";
2889
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
2890
								}
2891
								if ($rowIndex == 0)
2892
									echo "<option></option>";
2893
								?>
2894
							</select>
2895
							</td>
2896
						</tr>
2897
						<?php if (isset($wl_modes['11g'])): ?>
2898
						<tr>
2899
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
2900
							<td class="vtable">
2901
								<select name="protmode" class="formselect" id="protmode">
2902
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected=\"selected\"";?> value="off"><?=gettext("Protection mode off"); ?></option>
2903
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected=\"selected\"";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
2904
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected=\"selected\"";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
2905
								</select>
2906
								<br />
2907
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
2908
								<br />
2909
							</td>
2910
						</tr>
2911
						<?php else: ?>
2912
						<input name="protmode" type="hidden" id="protmode" value="off" />
2913
						<?php endif; ?>
2914
						<tr>
2915
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
2916
							<td class="vtable">
2917
								<select name="txpower" class="formselect" id="txpower">
2918
									<?
2919
									for($x = 99; $x > 0; $x--) {
2920
										if($pconfig["txpower"] == $x)
2921
											$SELECTED = " selected=\"selected\"";
2922
										else
2923
											$SELECTED = "";
2924
										echo "<option {$SELECTED}>{$x}</option>\n";
2925
									}
2926
									?>
2927
								</select><br />
2928
								<?=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."); ?>
2929
							</td>
2930
						</tr>
2931
						<tr>
2932
							<td valign="top" class="vncellreq"><?=gettext("Channel"); ?></td>
2933
							<td class="vtable">
2934
								<select name="channel" class="formselect" id="channel">
2935
									<option <?php if ($pconfig['channel'] == 0) echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2936
									<?php
2937
									foreach($wl_modes as $wl_standard => $wl_channels) {
2938
										if($wl_standard == "11g") { $wl_standard = "11b/g"; }
2939
										else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
2940
										else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
2941
										foreach($wl_channels as $wl_channel) {
2942
											echo "<option ";
2943
											if ($pconfig['channel'] == "$wl_channel") {
2944
												echo "selected=\"selected\" ";
2945
											}
2946
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
2947
											if(isset($wl_chaninfo[$wl_channel]))
2948
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
2949
											echo "</option>\n";
2950
										}
2951
									}
2952
									?>
2953
								</select>
2954
								<br />
2955
								<?=gettext("Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)"); ?>
2956
								<br />
2957
								<?=gettext("Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above."); ?>
2958
							</td>
2959
						</tr>
2960
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2961
						<tr>
2962
							<td valign="top" class="vncell"><?=gettext("Antenna settings"); ?></td>
2963
							<td class="vtable">
2964
								<table border="0" cellpadding="0" cellspacing="0" summary="antenna settings">
2965
									<tr>
2966
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])): ?>
2967
										<td>
2968
											<?=gettext("Diversity"); ?><br />
2969
											<select name="diversity" class="formselect" id="diversity">
2970
												<option <?php if (!isset($pconfig['diversity'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2971
												<option <?php if ($pconfig['diversity'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Off"); ?></option>
2972
												<option <?php if ($pconfig['diversity'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("On"); ?></option>
2973
											</select>
2974
										</td>
2975
										<td>&nbsp;&nbsp;</td>
2976
										<?php endif; ?>
2977
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])): ?>
2978
										<td>
2979
											<?=gettext("Transmit antenna"); ?><br />
2980
											<select name="txantenna" class="formselect" id="txantenna">
2981
												<option <?php if (!isset($pconfig['txantenna'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2982
												<option <?php if ($pconfig['txantenna'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2983
												<option <?php if ($pconfig['txantenna'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("#1"); ?></option>
2984
												<option <?php if ($pconfig['txantenna'] === '2') echo "selected=\"selected\""; ?> value="2"><?=gettext("#2"); ?></option>
2985
											</select>
2986
										</td>
2987
										<td>&nbsp;&nbsp;</td>
2988
										<?php endif; ?>
2989
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2990
										<td>
2991
											<?=gettext("Receive antenna"); ?><br />
2992
											<select name="rxantenna" class="formselect" id="rxantenna">
2993
												<option <?php if (!isset($pconfig['rxantenna'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
2994
												<option <?php if ($pconfig['rxantenna'] === '0') echo "selected=\"selected\""; ?> value="0"><?=gettext("Auto"); ?></option>
2995
												<option <?php if ($pconfig['rxantenna'] === '1') echo "selected=\"selected\""; ?> value="1"><?=gettext("#1"); ?></option>
2996
												<option <?php if ($pconfig['rxantenna'] === '2') echo "selected=\"selected\""; ?> value="2"><?=gettext("#2"); ?></option>
2997
											</select>
2998
										</td>
2999
										<?php endif; ?>
3000
									</tr>
3001
								</table>
3002
								<br />
3003
								<?=gettext("Note: The antenna numbers do not always match up with the labels on the card."); ?>
3004
							</td>
3005
						</tr>
3006
						<?php endif; ?>
3007
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])): ?>
3008
						<tr>
3009
							<td valign="top" class="vncell"><?=gettext("Distance setting"); ?></td>
3010
							<td class="vtable">
3011
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>" />
3012
								<br />
3013
								<?=gettext("Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client"); ?><br />
3014
								<?=gettext("(measured in Meters and works only for Atheros based cards !)"); ?>
3015
							</td>
3016
						</tr>
3017
						<?php endif; ?>
3018
						<tr>
3019
							<td valign="top" class="vncell"><?=gettext("Regulatory settings"); ?></td>
3020
							<td class="vtable">
3021
								<?=gettext("Regulatory domain"); ?><br />
3022
								<select name="regdomain" class="formselect" id="regdomain">
3023
									<option <?php if (empty($pconfig['regdomain'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3024
									<?php
3025
									foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
3026
										echo "<option ";
3027
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
3028
											echo "selected=\"selected\" ";
3029
										}
3030
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
3031
									}
3032
									?>
3033
								</select>
3034
								<br />
3035
								<?=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."); ?>
3036
								<br /><br />
3037
								<?=gettext("Country (listed with country code and regulatory domain)"); ?><br />
3038
								<select name="regcountry" class="formselect" id="regcountry">
3039
									<option <?php if (empty($pconfig['regcountry'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3040
									<?php
3041
									foreach($wl_countries as $wl_country_key => $wl_country) {
3042
										echo "<option ";
3043
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
3044
											echo "selected=\"selected\" ";
3045
										}
3046
										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";
3047
									}
3048
									?>
3049
								</select>
3050
								<br />
3051
								<?=gettext("Note: Any country setting other than \"Default\" will override the regulatory domain setting"); ?>.
3052
								<br /><br />
3053
								<?=gettext("Location"); ?><br />
3054
								<select name="reglocation" class="formselect" id="reglocation">
3055
									<option <?php if (empty($pconfig['reglocation'])) echo "selected=\"selected\""; ?> value=""><?=gettext("Default"); ?></option>
3056
									<option <?php if ($pconfig['reglocation'] == 'indoor') echo "selected=\"selected\""; ?> value="indoor"><?=gettext("Indoor"); ?></option>
3057
									<option <?php if ($pconfig['reglocation'] == 'outdoor') echo "selected=\"selected\""; ?> value="outdoor"><?=gettext("Outdoor"); ?></option>
3058
									<option <?php if ($pconfig['reglocation'] == 'anywhere') echo "selected=\"selected\""; ?> value="anywhere"><?=gettext("Anywhere"); ?></option>
3059
								</select>
3060
								<br /><br />
3061
								<?=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."); ?>
3062
								<br />
3063
								<?=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."); ?>
3064
							</td>
3065
						</tr>
3066
						<tr>
3067
							<td colspan="2" valign="top" height="16"></td>
3068
						</tr>
3069
						<tr>
3070
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Network-specific wireless configuration");?></td>
3071
						</tr>
3072
						<tr>
3073
							<td valign="top" class="vncellreq"><?=gettext("Mode"); ?></td>
3074
							<td class="vtable">
3075
								<select name="mode" class="formselect" id="mode">
3076
									<option <?php if ($pconfig['mode'] == 'bss') echo "selected=\"selected\"";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
3077
									<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected=\"selected\"";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
3078
									<option <?php if ($pconfig['mode'] == 'hostap') echo "selected=\"selected\"";?> value="hostap"><?=gettext("Access Point"); ?></option>
3079
								</select>
3080
							</td>
3081
						</tr>
3082
						<tr>
3083
							<td valign="top" class="vncellreq"><?=gettext("SSID"); ?></td>
3084
							<td class="vtable">
3085
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>" />
3086
								<br />
3087
								<?=gettext("Note: Only required in Access Point mode. If left blank in Ad-hoc or Infrastructure mode, this interface will connect to any available SSID"); ?>
3088
							</td>
3089
						</tr>
3090
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
3091
						<tr>
3092
							<td valign="top" class="vncell"><?=gettext("Minimum wireless standard"); ?></td>
3093
							<td class="vtable">
3094
								<select name="puremode" class="formselect" id="puremode">
3095
									<option <?php if ($pconfig['puremode'] == 'any') echo "selected=\"selected\"";?> value="any"><?=gettext("Any"); ?></option>
3096
									<?php if (isset($wl_modes['11g'])): ?>
3097
									<option <?php if ($pconfig['puremode'] == '11g') echo "selected=\"selected\"";?> value="11g"><?=gettext("802.11g"); ?></option>
3098
									<?php endif; ?>
3099
									<option <?php if ($pconfig['puremode'] == '11n') echo "selected=\"selected\"";?> value="11n"><?=gettext("802.11n"); ?></option>
3100
								</select>
3101
								<br />
3102
								<?=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)."); ?>
3103
							</td>
3104
						</tr>
3105
						<?php elseif (isset($wl_modes['11g'])): ?>
3106
						<tr>
3107
							<td valign="top" class="vncell"><?=gettext("802.11g only"); ?></td>
3108
							<td class="vtable">
3109
								<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <?php if ($pconfig['puremode'] == '11g') echo "checked=\"checked\"";?> />
3110
								<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)."); ?>
3111
							</td>
3112
						</tr>
3113
						<?php endif; ?>
3114
						<tr>
3115
							<td valign="top" class="vncell"><?=gettext("Allow intra-BSS communication"); ?></td>
3116
							<td class="vtable">
3117
								<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <?php if ($pconfig['apbridge_enable']) echo "checked=\"checked\"";?> />
3118
								<br />
3119
								<?=gettext("When operating as an access point, enable this if you want to pass packets between wireless clients directly."); ?>
3120
								<br />
3121
								<?=gettext("Disabling the internal bridging is useful when traffic is to be processed with packet filtering."); ?>
3122
							</td>
3123
						</tr>
3124
						<tr>
3125
							<td valign="top" class="vncell"><?=gettext("Enable WME"); ?></td>
3126
							<td class="vtable">
3127
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <?php if ($pconfig['wme_enable']) echo "checked=\"checked\"";?> />
3128
								<br /><?=gettext("Setting this option will force the card to use WME (wireless QoS)."); ?>
3129
							</td>
3130
						</tr>
3131
						<tr>
3132
							<td valign="top" class="vncell"><?=gettext("Enable Hide SSID"); ?></td>
3133
							<td class="vtable">
3134
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <?php if ($pconfig['hidessid_enable']) echo "checked=\"checked\"";?> />
3135
								<br />
3136
								<?=gettext("Setting this option will force the card to NOT broadcast its SSID"); ?>
3137
								<br />
3138
								<?=gettext("(this might create problems for some clients)."); ?>
3139
							</td>
3140
						</tr>
3141
						<tr>
3142
							<td valign="top" class="vncell"><?=gettext("WEP"); ?></td>
3143
							<td class="vtable">
3144
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <?php if ($pconfig['wep_enable']) echo "checked=\"checked\""; ?> />
3145
								<strong><?=gettext("Enable WEP"); ?></strong>
3146
								<table border="0" cellspacing="0" cellpadding="0" summary="wep">
3147
									<tr>
3148
										<td>&nbsp;</td>
3149
										<td>&nbsp;</td>
3150
										<td>&nbsp;<?=gettext("TX key"); ?>&nbsp;</td>
3151
									</tr>
3152
									<tr>
3153
										<td><?=gettext("Key 1:"); ?>&nbsp;&nbsp;</td>
3154
										<td>
3155
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>" />
3156
										</td>
3157
										<td align="center">
3158
											<input name="txkey" type="radio" value="1" <?php if ($pconfig['txkey'] == 1) echo "checked=\"checked\"";?> />
3159
										</td>
3160
									</tr>
3161
									<tr>
3162
										<td><?=gettext("Key 2:"); ?>&nbsp;&nbsp;</td>
3163
										<td>
3164
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>" />
3165
										</td>
3166
										<td align="center">
3167
											<input name="txkey" type="radio" value="2" <?php if ($pconfig['txkey'] == 2) echo "checked=\"checked\"";?> />
3168
										</td>
3169
									</tr>
3170
									<tr>
3171
										<td><?=gettext("Key 3:"); ?>&nbsp;&nbsp;</td>
3172
										<td>
3173
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>" />
3174
										</td>
3175
										<td align="center">
3176
											<input name="txkey" type="radio" value="3" <?php if ($pconfig['txkey'] == 3) echo "checked=\"checked\"";?> />
3177
										</td>
3178
									</tr>
3179
									<tr>
3180
										<td><?=gettext("Key 4:"); ?>&nbsp;&nbsp;</td>
3181
										<td>
3182
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>" />
3183
										</td>
3184
										<td align="center">
3185
											<input name="txkey" type="radio" value="4" <?php if ($pconfig['txkey'] == 4) echo "checked=\"checked\"";?> />
3186
										</td>
3187
									</tr>
3188
								</table>
3189
								<br />
3190
								<?=gettext("40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'."); ?><br />
3191
								<?=gettext("104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'."); ?>
3192
							</td>
3193
						</tr>
3194
						<tr>
3195
							<td valign="top" class="vncell"><?=gettext("WPA"); ?></td>
3196
							<td class="vtable">
3197
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <?php if ($pconfig['wpa_enable']) echo "checked=\"checked\""; ?> />
3198
								<strong><?=gettext("Enable WPA"); ?></strong>
3199
								<br /><br />
3200
								<table border="0" cellspacing="0" cellpadding="0" summary="wpa">
3201
									<tr>
3202
										<td>&nbsp;</td>
3203
										<td>&nbsp;<?=gettext("WPA Pre-Shared Key"); ?>&nbsp;</td>
3204
									</tr>
3205
									<tr>
3206
										<td><?=gettext("PSK:"); ?>&nbsp;&nbsp;</td>
3207
										<td>
3208
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>" />
3209
										</td>
3210
									</tr>
3211
								</table>
3212
								<br /><?=gettext("Passphrase must be from 8 to 63 characters."); ?>
3213
							</td>
3214
						</tr>
3215
						<tr>
3216
							<td valign="top" class="vncell"><?=gettext("WPA Mode"); ?></td>
3217
							<td class="vtable">
3218
								<select name="wpa_mode" class="formselect" id="wpa_mode">
3219
									<option <?php if ($pconfig['wpa_mode'] == '1') echo "selected=\"selected\"";?> value="1"><?=gettext("WPA"); ?></option>
3220
									<option <?php if ($pconfig['wpa_mode'] == '2') echo "selected=\"selected\"";?> value="2"><?=gettext("WPA2"); ?></option>
3221
									<option <?php if ($pconfig['wpa_mode'] == '3') echo "selected=\"selected\"";?> value="3"><?=gettext("Both"); ?></option>
3222
								</select>
3223
							</td>
3224
						</tr>
3225
						<tr>
3226
							<td valign="top" class="vncell"><?=gettext("WPA Key Management Mode"); ?></td>
3227
							<td class="vtable">
3228
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
3229
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected=\"selected\"";?> value="WPA-PSK"><?=gettext("Pre-Shared Key"); ?></option>
3230
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected=\"selected\"";?> value="WPA-EAP"><?=gettext("Extensible Authentication Protocol"); ?></option>
3231
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected=\"selected\"";?> value="WPA-PSK WPA-EAP"><?=gettext("Both"); ?></option>
3232
								</select>
3233
							</td>
3234
						</tr>
3235
						<tr>
3236
							<td valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
3237
							<td class="vtable">
3238
								<select name="auth_algs" class="formselect" id="auth_algs">
3239
									<option <?php if ($pconfig['auth_algs'] == '1') echo "selected=\"selected\"";?> value="1"><?=gettext("Open System Authentication"); ?></option>
3240
									<option <?php if ($pconfig['auth_algs'] == '2') echo "selected=\"selected\"";?> value="2"><?=gettext("Shared Key Authentication"); ?></option>
3241
									<option <?php if ($pconfig['auth_algs'] == '3') echo "selected=\"selected\"";?> value="3"><?=gettext("Both"); ?></option>
3242
								</select>
3243
								<br /><?=gettext("Note: Shared Key Authentication requires WEP."); ?><br />
3244
							</td>
3245
						</tr>
3246
						<tr>
3247
							<td valign="top" class="vncell"><?=gettext("WPA Pairwise"); ?></td>
3248
							<td class="vtable">
3249
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
3250
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected=\"selected\"";?> value="CCMP TKIP"><?=gettext("Both"); ?></option>
3251
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected=\"selected\"";?> value="CCMP"><?=gettext("AES (recommended)"); ?></option>
3252
									<option <?php if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected=\"selected\"";?> value="TKIP"><?=gettext("TKIP"); ?></option>
3253
								</select>
3254
							</td>
3255
						</tr>
3256
						<tr>
3257
							<td valign="top" class="vncell"><?=gettext("Key Rotation"); ?></td>
3258
							<td class="vtable">
3259
								<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";?>" />
3260
								<br /><?=gettext("Allowed values are 1-9999 but should not be longer than Master Key Regeneration time."); ?>
3261
							</td>
3262
						</tr>
3263
						<tr>
3264
							<td valign="top" class="vncell"><?=gettext("Master Key Regeneration"); ?></td>
3265
							<td class="vtable">
3266
								<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";?>" />
3267
								<br /><?=gettext("Allowed values are 1-9999 but should not be shorter than Key Rotation time."); ?>
3268
							</td>
3269
						</tr>
3270
						<tr>
3271
							<td valign="top" class="vncell"><?=gettext("Strict Key Regeneration"); ?></td>
3272
							<td class="vtable">
3273
								<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <?php if ($pconfig['wpa_strict_rekey']) echo "checked=\"checked\""; ?> />
3274
								<br /><?=gettext("Setting this option will force the AP to rekey whenever a client disassociates."); ?>
3275
							</td>
3276
						</tr>
3277
						<tr>
3278
							<td valign="top" class="vncell"><?=gettext("Enable IEEE802.1X Authentication"); ?></td>
3279
							<td class="vtable">
3280
								<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <?php if ($pconfig['ieee8021x']) echo "checked=\"checked\"";?> />
3281
								<br /><?=gettext("Setting this option will enable 802.1x authentication."); ?>
3282
								<br /><span class="red"><strong><?=gettext("NOTE"); ?>:</strong></span> <?=gettext("this option requires checking the \"Enable WPA box\"."); ?>
3283
							</td>
3284
						</tr>
3285
						<tr>
3286
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server IP Address"); ?></td>
3287
							<td class="vtable">
3288
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>" />
3289
								<br /><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
3290
							</td>
3291
						</tr>
3292
						<tr>
3293
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Port"); ?></td>
3294
							<td class="vtable">
3295
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>" />
3296
								<br /><?=gettext("Leave blank for the default 1812 port."); ?>
3297
							</td>
3298
						</tr>
3299
						<tr>
3300
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Shared Secret"); ?></td>
3301
							<td class="vtable">
3302
								<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']);?>" />
3303
								<br />
3304
							</td>
3305
						</tr>
3306
						<tr>
3307
					<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server IP Address"); ?></td>
3308
							<td class="vtable">
3309
								<input name="auth_server_addr2" id="auth_server_addr2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr2']);?>" />
3310
								<br /><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
3311
							</td>
3312
						</tr>
3313
						<tr>
3314
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Port"); ?></td>
3315
							<td class="vtable">
3316
								<input name="auth_server_port2" id="auth_server_port2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port2']);?>" />
3317
								<br /><?=gettext("Leave blank for the default 1812 port."); ?>
3318
							</td>
3319
						</tr>
3320
						<tr>
3321
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Shared Secret"); ?></td>
3322
							<td class="vtable">
3323
								<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']);?>" />
3324
								<br />
3325
							</td>
3326
						</tr>
3327
						<tr>
3328
							<td valign="top" class="vncell">802.1X <?=gettext("Authentication Roaming Preauth"); ?></td>
3329
							<td class="vtable">
3330
								<input name="rsn_preauth" id="rsn_preauth" type="checkbox" class="formfld unknown" size="66" value="yes" <?php if ($pconfig['rsn_preauth']) echo "checked=\"checked\""; ?> />
3331
								<br />
3332
							</td>
3333
						</tr>
3334
						<tr>
3335
							<td colspan="2" valign="top" height="16"></td>
3336
						</tr>
3337
						<?php endif; ?>
3338
						<tr>
3339
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Private networks"); ?></td>
3340
						</tr>
3341
						<tr>
3342
							<td valign="middle" class="vncell">&nbsp;</td>
3343
							<td class="vtable">
3344
								<a name="rfc1918"></a>
3345
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked=\"checked\""; ?> />
3346
								<strong><?=gettext("Block private networks"); ?></strong><br />
3347
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
3348
								"for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as"); ?>
3349
								<?=gettext("well as loopback addresses (127/8)."); ?>&nbsp;&nbsp; <?=gettext("You should generally " .
3350
								"leave this option turned on, unless your WAN network lies in such " .
3351
								"a private address space, too."); ?>
3352
							</td>
3353
						</tr>
3354
						<tr>
3355
							<td valign="middle" class="vncell">&nbsp;</td>
3356
							<td class="vtable">
3357
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked=\"checked\""; ?> />
3358
								<strong><?=gettext("Block bogon networks"); ?></strong><br />
3359
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
3360
								"(but not RFC 1918) or not yet assigned by IANA."); ?>&nbsp;&nbsp;
3361
								<?=gettext("Bogons are prefixes that should never appear in the Internet routing table, " .
3362
								"and obviously should not appear as the source address in any packets you receive."); ?>
3363
								<br /><br />
3364
								<?=gettext("Note: The update frequency can be changed under System->Advanced Firewall/NAT settings.")?>
3365
							</td>
3366
						</tr>
3367
					</table> <!-- End "allcfg" table -->
3368
					</div> <!-- End "allcfg" div -->
3369

    
3370
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="buttons">
3371
						<tr>
3372
							<td width="22%" valign="top">
3373
								&nbsp;
3374
							</td>
3375
							<td width="78%">
3376
								<br />
3377
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
3378
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
3379
								<input name="if" type="hidden" id="if" value="<?=htmlspecialchars($if);?>" />
3380
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
3381
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>" />
3382
								<?php endif; ?>
3383
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>" />
3384
							</td>
3385
						</tr>
3386
					</table>
3387
					</div>
3388
				</td>
3389
			</tr>
3390
		</table>
3391
	</form>
3392
	<script type="text/javascript">
3393
	//<![CDATA[
3394
		var gatewayip;
3395
		var name;
3396
		var gatewayipv6;
3397
		var namev6;
3398
		function show_add_gateway() {
3399
			document.getElementById("addgateway").style.display = '';
3400
			document.getElementById("addgwbox").style.display = 'none';
3401
			document.getElementById("gateway").style.display = 'none';
3402
			document.getElementById("save").style.display = 'none';
3403
			document.getElementById("cancel").style.display = 'none';
3404
			document.getElementById("gwsave").style.display = '';
3405
			document.getElementById("gwcancel").style.display = '';
3406
			jQuery('#notebox').html("");
3407
		}
3408
		function show_add_gateway_v6() {
3409
			document.getElementById("addgatewayv6").style.display = '';
3410
			document.getElementById("addgwboxv6").style.display = 'none';
3411
			document.getElementById("gatewayv6").style.display = 'none';
3412
			document.getElementById("save").style.display = 'none';
3413
			document.getElementById("cancel").style.display = 'none';
3414
			document.getElementById("gwsave").style.display = '';
3415
			document.getElementById("gwcancel").style.display = '';
3416
			jQuery('#noteboxv6').html("");
3417
		}
3418
		function hide_add_gateway() {
3419
			document.getElementById("addgateway").style.display = 'none';
3420
			document.getElementById("addgwbox").style.display = '';
3421
			document.getElementById("gateway").style.display = '';
3422
			document.getElementById("save").style.display = '';
3423
			document.getElementById("cancel").style.display = '';
3424
			document.getElementById("gwsave").style.display = '';
3425
			document.getElementById("gwcancel").style.display = '';
3426
			jQuery('#status').html('');
3427
		}
3428
		function hide_add_gateway_v6() {
3429
			document.getElementById("addgatewayv6").style.display = 'none';
3430
			document.getElementById("addgwboxv6").style.display = '';
3431
			document.getElementById("gatewayv6").style.display = '';
3432
			document.getElementById("save").style.display = '';
3433
			document.getElementById("cancel").style.display = '';
3434
			document.getElementById("gwsave").style.display = '';
3435
			document.getElementById("gwcancel").style.display = '';
3436
			jQuery('#statusv6').html('');
3437
		}
3438
		function hide_add_gatewaysave() {
3439
			document.getElementById("addgateway").style.display = 'none';
3440
			jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
3441
			var iface = jQuery('#if').val();
3442
			name = jQuery('#name').val();
3443
			var descr = jQuery('#gatewaydescr').val();
3444
			gatewayip = jQuery('#gatewayip').val();
3445

    
3446
			var defaultgw = '';
3447
			if (jQuery('#defaultgw').is(':checked'))
3448
				defaultgw = '&defaultgw=on';
3449
			var url = "system_gateways_edit.php";
3450
			var pars = 'isAjax=true&ipprotocol=inet' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3451
			jQuery.ajax(
3452
				url,
3453
				{
3454
					type: 'post',
3455
					data: pars,
3456
					error: report_failure,
3457
					success: save_callback
3458
				});
3459
		}
3460
		function hide_add_gatewaysave_v6() {
3461
			document.getElementById("addgatewayv6").style.display = 'none';
3462
			jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> One moment please...');
3463
			var iface = jQuery('#if').val();
3464
			name = jQuery('#namev6').val();
3465
			var descr = jQuery('#gatewaydescrv6').val();
3466
			gatewayip = jQuery('#gatewayipv6').val();
3467
			var defaultgw = '';
3468
			if (jQuery('#defaultgwv6').is(':checked'))
3469
				defaultgw = '&defaultgw=on';
3470
			var url_v6 = "system_gateways_edit.php";
3471
			var pars_v6 = 'isAjax=true&ipprotocol=inet6' + defaultgw + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
3472
			jQuery.ajax(
3473
				url_v6,
3474
				{
3475
					type: 'post',
3476
					data: pars_v6,
3477
					error: report_failure_v6,
3478
					success: save_callback_v6
3479
				});
3480
		}
3481
		function addOption(selectbox,text,value)
3482
		{
3483
			var optn = document.createElement("OPTION");
3484
			optn.text = text;
3485
			optn.value = value;
3486
			selectbox.append(optn);
3487
			selectbox.prop('selectedIndex',selectbox.children().length-1);
3488
			jQuery('#notebox').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3489
		}
3490
		function addOption_v6(selectbox,text,value)
3491
		{
3492
			var optn = document.createElement("OPTION");
3493
			optn.text = text;
3494
			optn.value = value;
3495
			selectbox.append(optn);
3496
			selectbox.prop('selectedIndex',selectbox.children().length-1);
3497
			jQuery('#noteboxv6').html("<p><strong><?=gettext("NOTE:"); ?><\/strong> <?=gettext("You can manage Gateways"); ?> <a target='_blank' href='system_gateways.php'><?=gettext("here"); ?><\/a>.<\/p>");
3498
		}
3499
		function report_failure(request, textStatus, errorThrown) {
3500
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3501
				alert(request.responseText);
3502
			} else {
3503
				alert("Sorry, we could not create your IPv4 gateway at this time.");
3504
			}
3505
			hide_add_gateway();
3506
		}
3507
		function report_failure_v6(request, textStatus, errorThrown) {
3508
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
3509
				alert(request.responseText);
3510
			} else {
3511
				alert("Sorry, we could not create your IPv6 gateway at this time.");
3512
			}
3513
			hide_add_gateway_v6();
3514
		}
3515
		function save_callback(response) {
3516
			if(response) {
3517
				document.getElementById("addgateway").style.display = 'none';
3518
				hide_add_gateway();
3519
				var gwtext = escape(name) + " - " + gatewayip;
3520
				addOption(jQuery('#gateway'), gwtext, name);
3521
				// Auto submit form?
3522
				//document.iform.submit();
3523
				//jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader /">');
3524
			} else {
3525
				report_failure();
3526
			}
3527
		}
3528
		function show_advanced_media() {
3529
			document.getElementById("showadvmediabox").innerHTML='';
3530
			aodiv = document.getElementById('showmediaadv');
3531
			aodiv.style.display = "block";
3532
		}
3533
		function save_callback_v6(response_v6) {
3534
			if(response_v6) {
3535
				document.getElementById("addgatewayv6").style.display = 'none';
3536
				hide_add_gateway_v6();
3537
				var gwtext_v6 = escape(name) + " - " + gatewayip;
3538
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
3539
				// Auto submit form?
3540
				//document.iform.submit();
3541
				//jQuery('#statusv6').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" />');
3542
			} else {
3543
				report_failure_v6();
3544
			}
3545
		}
3546
		<?php
3547
		echo "show_allcfg(document.iform.enable);";
3548
		echo "updateType('{$pconfig['type']}');\n";
3549
		echo "updateTypeSix('{$pconfig['type6']}');\n";
3550
		?>
3551
	//]]>
3552
	</script>
3553
	<?php include("fend.inc"); ?>
3554
	</body>
3555
</html>
(95-95/256)