Project

General

Profile

Download (176 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces.php
5
        Copyright (C) 2013-2014 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
													if($i <> 31) {
1789
														echo "<option value=\"{$i}\" ";
1790
														if ($i == $pconfig['subnet']) echo "selected=\"selected\"";
1791
														echo ">" . $i . "</option>";
1792
													}
1793
												}
1794
												?>
1795
											</select>
1796
										</td>
1797
									</tr>
1798
									<tr>
1799
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Upstream Gateway"); ?></td>
1800
										<td width="78%" class="vtable">
1801
											<select name="gateway" class="formselect" id="gateway">
1802
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1803
													<?php
1804
													if(count($a_gateways) > 0) {
1805
														foreach ($a_gateways as $gateway) {
1806
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1807
													?>
1808
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected=\"selected\""; ?>>
1809
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1810
															</option>
1811
													<?php
1812
															}
1813
														}
1814
													}
1815
													?>
1816
											</select>
1817
											- or  <strong><a onclick="show_add_gateway();" href="#gatewaysection"><?=gettext("add a new one."); ?></a></strong>
1818
											<br />
1819
											<div id='addgwbox'>
1820
												<?=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 />
1821
												<?=gettext("On local LANs the upstream gateway should be \"none\"."); ?>
1822
											</div>
1823
											<div id='notebox'>
1824
											</div>
1825
											<div id="status">
1826
											</div>
1827
											<div style="display:none" id="addgateway">
1828
												<p>&nbsp;</p>
1829
												<table border="1" class="addgatewaybox" summary="addgateway">
1830
													<tr>
1831
														<td>
1832
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgateway">
1833
																<tr><td>&nbsp;</td></tr>
1834
																<tr>
1835
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1836
																</tr>
1837
																<tr><td>&nbsp;</td></tr>
1838
																<?php
1839
																if($if == "wan" || $if == "WAN")
1840
																	$checked = " checked=\"checked\"";
1841
																?>
1842
																<tr>
1843
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></font></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?> /></td>
1844
																</tr>
1845
																<tr>
1846
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></font></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>" /></td>
1847
																</tr>
1848
																<tr>
1849
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></font></td><td><input id="gatewayip" name="gatewayip" /></td>
1850
																</tr>
1851
																<tr>
1852
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescr" name="gatewaydescr" /></td>
1853
																</tr>
1854
																<tr><td>&nbsp;</td></tr>
1855
																<tr>
1856
																	<td colspan="2">
1857
																		<center>
1858
																			<div id='savebuttondiv'>
1859
																				<input id="gwsave" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave();' />
1860
																				<input id="gwcancel" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway();' />
1861
																			</div>
1862
																		</center>
1863
																	</td>
1864
																</tr>
1865
																<tr><td>&nbsp;</td></tr>
1866
															</table>
1867
														</td>
1868
													</tr>
1869
												</table>
1870
											</div>
1871
										</td>
1872
									</tr>
1873
									<tr>
1874
										<td colspan="2" valign="top" height="16"></td>
1875
									</tr>
1876
								</table>
1877
							</td>
1878
						</tr>
1879
						<tr style="display:none;" id="staticv6">
1880
							<td colspan="2" style="padding:0px;">
1881
								<a name="gatewayv6section"></a>
1882
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="staticv6">
1883
									<tr>
1884
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1885
									</tr>
1886
									<tr>
1887
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1888
										<td width="78%" class="vtable">
1889
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>" />
1890
											/
1891
											<select name="subnetv6" class="formselect" id="subnetv6">
1892
												<?php
1893
												for ($i = 128; $i > 0; $i--) {
1894
													if($i <> 127) {
1895
														echo "<option value=\"{$i}\" ";
1896
														if ($i == $pconfig['subnetv6']) echo "selected=\"selected\"";
1897
														echo ">" . $i . "</option>";
1898
													}
1899
												}
1900
												?>
1901
											</select>
1902
										</td>
1903
									</tr>
1904
									<tr>
1905
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Upstream Gateway"); ?></td>
1906
										<td width="78%" class="vtable">
1907
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1908
												<option value="none" selected="selected"><?=gettext("None"); ?></option>
1909
													<?php
1910
													if(count($a_gateways) > 0) {
1911
														foreach ($a_gateways as $gateway) {
1912
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1913
													?>
1914
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected=\"selected\""; ?>>
1915
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1916
															</option>
1917
													<?php
1918
															}
1919
														}
1920
													}
1921
													?>
1922
											</select>
1923
											- or <strong><a onclick="show_add_gateway_v6();" href="#gatewayv6section"><?=gettext("add a new one."); ?></a></strong>
1924
											<br />
1925
											<div id='addgwboxv6'>
1926
												<?=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 />
1927
												<?=gettext("On local LANs the upstream gateway should be \"none\"."); ?>
1928
											</div>
1929
											<div id='noteboxv6'>
1930
											</div>
1931
											<div id="statusv6">
1932
											</div>
1933
											<div style="display:none" id="addgatewayv6">
1934
												<p>&nbsp;</p>
1935
												<table border="1" class="addgatewaybox" summary="addgatewayv6">
1936
													<tr>
1937
														<td>
1938
															<table class="addgatewaybox" cellpadding="1" cellspacing="1" summary="addgatewayv6">
1939
																<tr><td>&nbsp;</td></tr>
1940
																<tr>
1941
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1942
																</tr>
1943
																<tr><td>&nbsp;</td></tr>
1944
																<?php
1945
																if($if == "wan" || $if == "WAN")
1946
																	$checked = " checked=\"checked\"";
1947
																?>
1948
																<tr>
1949
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></font></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?> /></td>
1950
																</tr>
1951
																<tr>
1952
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></font></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>" /></td>
1953
																</tr>
1954
																<tr>
1955
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></font></td><td><input id="gatewayipv6" name="gatewayipv6" /></td>
1956
																</tr>
1957
																<tr>
1958
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></font></td><td><input id="gatewaydescrv6" name="gatewaydescrv6" /></td>
1959
																</tr>
1960
																<tr><td>&nbsp;</td></tr>
1961
																<tr>
1962
																	<td colspan="2">
1963
																		<center>
1964
																			<div id='savebuttondivv6'>
1965
																				<input id="gwsavev6" type="button" value="<?=gettext("Save Gateway"); ?>" onclick='hide_add_gatewaysave_v6();' />
1966
																				<input id="gwcancelv6" type="button" value="<?=gettext("Cancel"); ?>" onclick='hide_add_gateway_v6();' />
1967
																			</div>
1968
																		</center>
1969
																	</td>
1970
																</tr>
1971
																<tr><td>&nbsp;</td></tr>
1972
															</table>
1973
														</td>
1974
													</tr>
1975
												</table>
1976
											</div>
1977
										</td>
1978
									</tr>
1979
									<tr>
1980
										<td colspan="2" valign="top" height="16"></td>
1981
									</tr>
1982
								</table>
1983
							</td>
1984
						</tr>
1985
						<tr style="display:none;" id="dhcp">
1986
							<td colspan="2" style="padding: 0px;">
1987
								<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="dhcp">
1988
									<tr>
1989
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration &nbsp; &nbsp; " .
1990
										' <input name="adv_dhcp_config_advanced" type="checkbox" id="adv_dhcp_config_advanced" value="" onclick="show_adv_dhcp_config(this)" /> ' .
1991
										" Advanced &nbsp; &nbsp; " .
1992
										' <input name="adv_dhcp_config_file_override" type="checkbox" id="adv_dhcp_config_file_override" value="" onclick="show_adv_dhcp_config(this)" /> ' .
1993
										" Config File Override &nbsp; &nbsp; "); ?>
1994
										</td>
1995
									</tr>
1996
									<!-- Uncomment to expose DHCP+ in GUI
1997
									<tr>
1998
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1999
										<td width="78%" class="vtable">
2000
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked=\"checked\""; ?> />
2001
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
2002
										<br />
2003
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
2004
										</td>
2005
									</tr>
2006
									-->
2007
									<tr style='display:none' id="show_basic_dhcphostname">
2008
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
2009
										<td width="78%" class="vtable">
2010
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>" />
2011
											<br />
2012
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
2013
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
2014
											"this (for client identification)."); ?>
2015
										</td>
2016
									</tr>
2017
									<tr style='display:none' id="show_basic_dhcpalias-address">
2018
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
2019
										<td width="78%" class="vtable">
2020
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>" />
2021
											<select name="alias-subnet" class="formselect" id="alias-subnet">
2022
												<?php
2023
												for ($i = 32; $i > 0; $i--) {
2024
													if($i <> 31) {
2025
														echo "<option value=\"{$i}\" ";
2026
														if ($i == $pconfig['alias-subnet']) echo "selected=\"selected\"";
2027
														echo ">" . $i . "</option>";
2028
													}
2029
												}
2030
												?>
2031
											</select>
2032
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
2033
											"DHCP client."); ?>
2034
										</td>
2035
									</tr>
2036
									<tr style='display:none' id="show_basic_dhcprejectlease">
2037
										<td width="22%" valign="top" class="vncell"><?=gettext("Reject Leases From"); ?></td>
2038
										<td width="78%" class="vtable">
2039
											<input name="dhcprejectfrom" type="text" class="formfld unknown" id="dhcprejectfrom" size="20" value="<?=htmlspecialchars($pconfig['dhcprejectfrom']);?>" />
2040
											<br />
2041
											<?=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."); ?>
2042
											<?=gettext("This is useful for rejecting leases from cable modems that offer private IPs when they lose upstream sync."); ?>
2043
										</td>
2044
									</tr>
2045

    
2046
									<tr style='display:none' id="show_adv_dhcp_protocol_timing">
2047
										<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>
2048
										<td width="48%" class="vtable">
2049
											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, '');" />
2050
											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, '');" />
2051
											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, '');" />
2052

    
2053
											&nbsp; &nbsp; &nbsp; &nbsp; 
2054
											Presets: &nbsp;
2055
											<input name="adv_dhcp_pt_values" type="radio" value="DHCP"	id="customdhcpptdhcpdefaults"	onclick="customdhcpptsetvalues(this, iform);" />FreeBSD Default &nbsp; 
2056
											<input name="adv_dhcp_pt_values" type="radio" value="Clear"	id="customdhcpptclear"		onclick="customdhcpptsetvalues(this, iform);" />Clear
2057

    
2058
											<br />
2059
											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, '');" />
2060
											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, '');" />
2061
											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, '');" />
2062

    
2063
											&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
2064
											<input name="adv_dhcp_pt_values" type="radio" value="pfSense"	id="customdhcpptpfsensedefaults"	onclick="customdhcpptsetvalues(this, iform);" />pfSense Default &nbsp; 
2065
											<input name="adv_dhcp_pt_values" type="radio" value="SavedCfg" checked="checked"	id="customdhcpptsavedcfg"		onclick="customdhcpptsetvalues(this, iform);" />Saved Cfg 
2066

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

    
2070
											<script type="text/javascript">
2071
											//<![CDATA[
2072
												function customdhcpptcheckradiobuton(T, BUTTON) {
2073
													for (var i = 0; i < T.length; i++) {
2074
														T[i].checked = false;
2075
														if (T[i].value == BUTTON) T[i].checked = true;
2076
													}
2077
													T.value = BUTTON;
2078
												}
2079

    
2080
												function customdhcpptsetvalues(T, FORM) {
2081
													// timeout, retry, select-timeout, reboot, backoff-cutoff, initial-interval
2082
													if (T.value == "DHCP")		customdhcpptsetvaluesnow(T, FORM, "60", "300", "0", "10", "120", "10");
2083
													if (T.value == "pfSense")	customdhcpptsetvaluesnow(T, FORM, "60", "15", "0", "", "", "1");
2084
													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']);?>");
2085
													if (T.value == "Clear")		customdhcpptsetvaluesnow(T, FORM, "", "", "", "", "", "");
2086
												}
2087

    
2088
												function customdhcpptsetvaluesnow(T, FORM, timeout, retry, selecttimeout, reboot, backoffcutoff, initialinterval) {
2089
													FORM.adv_dhcp_pt_timeout.value = timeout;
2090
													FORM.adv_dhcp_pt_retry.value = retry;
2091
													FORM.adv_dhcp_pt_select_timeout.value = selecttimeout;
2092
													FORM.adv_dhcp_pt_reboot.value = reboot;
2093
													FORM.adv_dhcp_pt_backoff_cutoff.value = backoffcutoff;
2094
													FORM.adv_dhcp_pt_initial_interval.value = initialinterval;
2095

    
2096
													FORM.adv_dhcp_pt_values.value = T.value;
2097
												}
2098

    
2099
												<!-- Set the adv_dhcp_pt_values radio button from saved config -->
2100
												var RADIOBUTTON_VALUE = "<?=htmlspecialchars($pconfig['adv_dhcp_pt_values']);?>";
2101
												if (RADIOBUTTON_VALUE == "") RADIOBUTTON_VALUE = "SavedCfg";
2102
												customdhcpptcheckradiobuton(document.iform.adv_dhcp_pt_values, RADIOBUTTON_VALUE);
2103
											//]]>
2104
											</script>
2105
										</td>
2106
									</tr>
2107

    
2108
									<tr style='display:none' id="show_adv_dhcp_lease_requirements_and_requests">
2109
										<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>
2110
										<td width="78%" class="vtable">
2111
											<?=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 />
2112
											<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']);?>" />
2113
											<br />
2114
											<?=gettext("The values in this field are DHCP options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2115
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2116
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2117
											"Some ISPs may require certain options be or not be sent. "); ?>
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\">Request</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_request_options" type="text" class="formfld unknown" id="adv_dhcp_request_options" size="86" value="<?=htmlspecialchars($pconfig['adv_dhcp_request_options']);?>" />
2121
											<br />
2122
											<?=gettext("The values in this field are DHCP option 55 to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2123
											"Some ISPs may require certain options be or not be requested. "); ?>
2124
											<hr/>
2125
											<?=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 />
2126
											<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']);?>" />
2127
											<br />
2128
											<?=gettext("The values in this field are DHCP options required by the client when requesting a DHCP lease.  [option [, ...]] "); ?>
2129
										</td>
2130
									</tr>
2131

    
2132
									<tr style='display:none' id="show_adv_dhcp_option_modifiers">
2133
										<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>
2134
										<td width="78%" class="vtable">
2135
											<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']);?>" />
2136
											<br />
2137
											<?=gettext("The values in this field are DHCP option modifiers applied to obtained DHCP lease.  [modifier option declaration [, ...]] <br /> " .
2138
											"modifiers: (default, supersede, prepend, append)"); ?>
2139
										</td>
2140
									</tr>
2141

    
2142
									<tr style='display:none' id="show_adv_dhcp_config_file_override">
2143
										<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>
2144
										<td width="78%" class="vtable">
2145
 											<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']);?>" />
2146
											<br />
2147
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2148
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2149
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2150
											"Some ISPs may require certain options be or not be sent. "); ?>
2151
										</td>
2152
									</tr>
2153

    
2154
 									<tr>
2155
 										<td colspan="2" valign="top" height="16"></td>
2156
 									</tr>
2157

    
2158
								</table>
2159

    
2160
									<script type="text/javascript">
2161
									//<![CDATA[
2162
										function show_adv_dhcp_config(T) {
2163

    
2164
											if (T.checked) T.value = "Selected";
2165
											else T.value = "";
2166

    
2167
											     if (document.iform.adv_dhcp_config_file_override.checked)	show_hide_adv_dhcp('none', 'none', '');
2168
											else if (document.iform.adv_dhcp_config_advanced.checked)	show_hide_adv_dhcp('', '', 'none');
2169
											else 									show_hide_adv_dhcp('', 'none', 'none');
2170
										}
2171

    
2172
										function show_hide_adv_dhcp(basic, advanced, override) {
2173

    
2174
											document.getElementById("show_basic_dhcphostname").style.display = basic;
2175
											document.getElementById("show_basic_dhcpalias-address").style.display = basic;
2176
											document.getElementById("show_basic_dhcprejectlease").style.display = basic;
2177

    
2178
											document.getElementById("show_adv_dhcp_protocol_timing").style.display = advanced;
2179
											document.getElementById("show_adv_dhcp_lease_requirements_and_requests").style.display = advanced;
2180
											document.getElementById("show_adv_dhcp_option_modifiers").style.display = advanced;
2181

    
2182
											document.getElementById("show_adv_dhcp_config_file_override").style.display = override;
2183
										}
2184

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

    
2189
										<!-- Set the adv_dhcp_config_file_override checkbox from saved config -->
2190
										if ("<?=htmlspecialchars($pconfig['adv_dhcp_config_file_override']);?>" == "Selected") document.iform.adv_dhcp_config_file_override.checked = true;
2191
										show_adv_dhcp_config(document.iform.adv_dhcp_config_file_override);
2192
									//]]>
2193
									</script>
2194

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

    
2264
									<tr style='display:none' id="show_adv_dhcp6_interface_statement">
2265
										<td width="22%" valign="top" class="vncell">
2266
											<?=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>"); ?>
2267
											<br /><br />
2268
											<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)" />
2269
											<?=gettext("Information Only"); ?>
2270
										</td>
2271
										<td width="78%" class="vtable">
2272
											<?=gettext("Send Options"); ?><br />
2273
											<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']);?>" />
2274
											<br />
2275
											<?=gettext("The values in this field are DHCP send options to be sent when requesting a DHCP lease.  [option declaration [, ...]] <br />" .
2276
											"Value Substitutions: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2277
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2278
											"Some DHCP services may require certain options be or not be sent. "); ?>
2279
											<br />
2280
											<br />
2281
											<?=gettext("Request Options"); ?><br />
2282
											<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']);?>" />
2283
											<br />
2284
											<?=gettext("The values in this field are DHCP request options to be sent when requesting a DHCP lease.  [option [, ...]] <br />" .
2285
											"Some DHCP services may require certain options be or not be requested. "); ?>
2286
											<br />
2287
											<br />
2288
											<?=gettext("Script"); ?><br />
2289
											<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']);?>" />
2290
											<br />
2291
											<?=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 />" .
2292
											"[/[dirname/[.../]]filename[.ext]] "); ?>
2293
										</td>
2294
									</tr>
2295

    
2296
									<tr style='display:none' id="show_adv_dhcp6_id_assoc_statement">
2297
										<td width="22%" valign="top" class="vncell">
2298
											<?=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>"); ?>
2299
										</td>
2300
										<td width="78%" class="vtable">
2301

    
2302
											<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);" />
2303
											<?=gettext("Non-Temporary Address Allocation"); ?>
2304
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_address">
2305
											<?=gettext("id-assoc na"); ?>
2306
											<?=gettext("<i>ID</i>"); ?>
2307
											<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']);?>" />
2308
											<br />
2309
											<?=gettext("Address"); ?>
2310
											<?=gettext("<i>ipv6-address</i>"); ?>
2311
											<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']);?>" />
2312
											<?=gettext("<i>pltime</i>"); ?>
2313
											<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']);?>" />
2314
											<?=gettext("<i>vltime</i>"); ?>
2315
											<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']);?>" />
2316
											</div>
2317
											<hr/>
2318

    
2319
											<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)" />
2320
											<?=gettext("Prefix Delegation"); ?>
2321
											<div style='display:none'  id="show_adv_dhcp6_id_assoc_statement_prefix">
2322
											<?=gettext("id-assoc pd"); ?>
2323
											<?=gettext("<i>ID</i>"); ?>
2324
											<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']);?>" />
2325
											<br />
2326
											<?=gettext("Prefix"); ?>
2327
											<?=gettext("<i>ipv6-prefix</i>"); ?>
2328
											<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']);?>" />
2329
											<?=gettext("<i>pltime</i>"); ?>
2330
											<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']);?>" />
2331
											<?=gettext("<i>vltime</i>"); ?>
2332
											<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']);?>" />
2333
											</div>
2334
										</td>
2335
									</tr>
2336

    
2337
									<tr style='display:none' id="show_adv_dhcp6_prefix_interface_statement">
2338
										<td width="22%" valign="top" class="vncell">
2339
											<?=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>"); ?>
2340
										</td>
2341
										<td width="78%" class="vtable">
2342
											<?=gettext("Prefix Interface "); ?>
2343
											<?=gettext("<i>sla-id</i>"); ?>
2344
											<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']);?>" />
2345
											<?=gettext("<i>sla-len</i>"); ?>
2346
											<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']);?>" />
2347
										</td>
2348
									</tr>
2349

    
2350
									<tr style='display:none' id="show_adv_dhcp6_authentication_statement">
2351
										<td width="22%" valign="top" class="vncell">
2352
											<?=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>"); ?>
2353
										</td>
2354
										<td width="78%" class="vtable">
2355
											<?=gettext("<i>authname</i>"); ?>
2356
											<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']);?>" />
2357
											<?=gettext("<i>protocol</i>"); ?>
2358
											<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']);?>" />
2359
											<?=gettext("<i>algorithm</i>"); ?>
2360
											<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']);?>" />
2361
											<?=gettext("<i>rdm</i>"); ?>
2362
											<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']);?>" />
2363
										</td>
2364
									</tr>
2365

    
2366
									<tr style='display:none' id="show_adv_dhcp6_key_info_statement">
2367
										<td width="22%" valign="top" class="vncell">
2368
											<?=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>"); ?>
2369
										</td>
2370
										<td width="78%" class="vtable">
2371
											<?=gettext("<i>keyname</i>"); ?>
2372
											<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']);?>" />
2373
											<?=gettext("<i>realm</i>"); ?>
2374
											<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']);?>" />
2375
											<br />
2376
											<?=gettext("<i>keyid</i>"); ?>
2377
											<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']);?>" />
2378
											<?=gettext("<i>secret</i>"); ?>
2379
											<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']);?>" />
2380
											<?=gettext("<i>expire</i>"); ?>
2381
											<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']);?>" />
2382
										</td>
2383
									</tr>
2384

    
2385
									<tr style='display:none' id="show_adv_dhcp6_config_file_override">
2386
										<td width="22%" valign="top" class="vncell">
2387
											<?=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"); ?>
2388
										</td>
2389
										<td width="78%" class="vtable">
2390
 											<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']);?>" />
2391
											<br />
2392
											<?=gettext("The value in this field is the full absolute path to a DHCP client configuration file.  [/[dirname/[.../]]filename[.ext]] <br /> " .
2393
											"Value Substitutions in Config File: {interface}, {hostname}, {mac_addr_asciiCD}, {mac_addr_hexCD} <br />" .
2394
											"Where C is U(pper) or L(ower) Case, and D is \" :-.\" Delimiter (space, colon, hyphen, or period) (omitted for none). <br />" .
2395
											"Some ISPs may require certain options be or not be sent. "); ?>
2396
										</td>
2397
									</tr>
2398

    
2399
 									<tr>
2400
 										<td colspan="2" valign="top" height="16"></td>
2401
 									</tr>
2402

    
2403
								</table>
2404

    
2405
									<script type="text/javascript">
2406
									//<![CDATA[
2407
										function show_adv_dhcp6_config(T) {
2408

    
2409
											if (T.checked) T.value = "Selected";
2410
											else T.value = "";
2411

    
2412
											     if (document.iform.adv_dhcp6_config_file_override.checked)	show_hide_adv_dhcp6('none', 'none', ''    );
2413
											else if (document.iform.adv_dhcp6_config_advanced.checked)		show_hide_adv_dhcp6('none', '',     'none');
2414
											else 															show_hide_adv_dhcp6('',     'none', 'none');
2415
										}
2416

    
2417
										function show_hide_adv_dhcp6(basic, advanced, override) {
2418

    
2419
											document.getElementById("basicdhcp6_use_pppoeinterface").style.display = basic;
2420
											document.getElementById("basicdhcp6_show_dhcp6_prefix_delegation_size").style.display = basic;
2421
											document.getElementById("basicdhcp6_show_dhcp6_prefix_send_hint").style.display = basic;
2422
											document.getElementById("basicdhcp6_show_dhcp6_prefix_only").style.display = basic;
2423

    
2424
											document.getElementById("show_adv_dhcp6_interface_statement").style.display = advanced;
2425
											document.getElementById("show_adv_dhcp6_id_assoc_statement").style.display = advanced;
2426

    
2427
											document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = 'none';
2428
											if (document.iform.adv_dhcp6_id_assoc_statement_address_enable.checked)  {
2429
												document.getElementById("show_adv_dhcp6_id_assoc_statement_address").style.display = advanced;
2430
											}
2431

    
2432
											document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = 'none';
2433
											document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = 'none';
2434
											if (document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked)  {
2435
												document.getElementById("show_adv_dhcp6_id_assoc_statement_prefix").style.display = advanced;
2436
												document.getElementById("show_adv_dhcp6_prefix_interface_statement").style.display = advanced;
2437
											}
2438

    
2439
											document.getElementById("show_adv_dhcp6_authentication_statement").style.display = advanced;
2440
											document.getElementById("show_adv_dhcp6_key_info_statement").style.display = advanced;
2441

    
2442
											document.getElementById("show_adv_dhcp6_config_file_override").style.display = override;
2443
										}
2444

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

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

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

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

    
2461
										<!-- Set the adv_dhcp6_id_assoc_statement_prefix_enable checkbox from saved config -->
2462
										if ("<?=htmlspecialchars($pconfig['adv_dhcp6_id_assoc_statement_prefix_enable']);?>" == "Selected") document.iform.adv_dhcp6_id_assoc_statement_prefix_enable.checked = true;
2463
										show_adv_dhcp6_config(document.iform.adv_dhcp6_id_assoc_statement_prefix_enable);
2464
									//]]>
2465
									</script>
2466

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

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

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

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