Project

General

Profile

Download (125 KB) Statistics
| Branch: | Tag: | Revision:
1 8a9edda5 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4 b2bc44cd Scott Ullrich
	interfaces.php
5 78fcfb9c Scott Ullrich
	Copyright (C) 2004-2008 Scott Ullrich
6 744ea190 Scott Ullrich
	Copyright (C) 2006 Daniel S. Haischt.
7 32764288 Namezero
	Copyright (C) 2008-2010 Ermal Lu?i
8 c3b3cd36 Scott Ullrich
	All rights reserved.
9 b1c525ee Scott Ullrich
10 c3b3cd36 Scott Ullrich
	originally part of m0n0wall (http://m0n0.ch/wall)
11 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
12
	All rights reserved.
13 e2cd32df Scott Ullrich
14 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16 e2cd32df Scott Ullrich
17 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19 e2cd32df Scott Ullrich
20 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
21
	   notice, this list of conditions and the following disclaimer in the
22
	   documentation and/or other materials provided with the distribution.
23 e2cd32df Scott Ullrich
24 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
	POSSIBILITY OF SUCH DAMAGE.
34
*/
35 7ac5a4cb Scott Ullrich
/*
36
	pfSense_BUILDER_BINARIES:	/usr/sbin/arp
37
	pfSense_MODULE:	interfaces
38
*/
39 5b237745 Scott Ullrich
40 6b07c15a Matthew Grooms
##|+PRIV
41 01eb687d Ermal Luçi
##|*IDENT=page-interfaces
42 6b07c15a Matthew Grooms
##|*NAME=Interfaces: WAN page
43 998552f8 Ermal Luçi
##|*DESCR=Allow access to the 'Interfaces' page.
44 01eb687d Ermal Luçi
##|*MATCH=interfaces.php*
45 6b07c15a Matthew Grooms
##|-PRIV
46
47 f81cfcc9 jim-p
require_once("guiconfig.inc");
48
require_once("ipsec.inc");
49
require_once("functions.inc");
50
require_once("captiveportal.inc");
51
require_once("filter.inc");
52
require_once("shaper.inc");
53
require_once("rrd.inc");
54
require_once("vpn.inc");
55 1fb064e8 Erik Fonnesbeck
require_once("xmlparse_attr.inc");
56 199d8121 Ermal Luçi
57 94556105 Scott Ullrich
// Get configured interface list
58 dd18038e Ermal
$ifdescrs = get_configured_interface_with_descr(false, true);
59 94556105 Scott Ullrich
60 dd18038e Ermal
$if = "wan";
61
if ($_REQUEST['if'])
62 bd58d230 Scott Ullrich
	$if = $_REQUEST['if'];
63 dd18038e Ermal
64
if (empty($ifdescrs[$if])) {
65
	Header("Location: interfaces.php");
66
	exit;
67 9ff9a1c7 Seth Mos
}
68 6b07c15a Matthew Grooms
69 58af5941 Scott Ullrich
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
70
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
71
define("CRON_DAILY_PATTERN", "0 0 * * *");
72
define("CRON_HOURLY_PATTERN", "0 * * * *");
73 dc711694 Scott Ullrich
74 d85ba87f gnhb
if (!is_array($config['ppps']['ppp']))
75
	$config['ppps']['ppp'] = array();
76
77
$a_ppps = &$config['ppps']['ppp'];
78 58af5941 Scott Ullrich
79 f1f60c92 Ermal Luçi
function remove_bad_chars($string) {
80 e7346f05 Erik Fonnesbeck
	return preg_replace('/[^a-z_0-9]/i','',$string);
81 f1f60c92 Ermal Luçi
}
82
83 d173230c Seth Mos
if (!is_array($config['gateways']['gateway_item']))
84
	$config['gateways']['gateway_item'] = array();
85
$a_gateways = &$config['gateways']['gateway_item'];
86
87 f1f60c92 Ermal Luçi
$wancfg = &$config['interfaces'][$if];
88 ee5c01b5 Seth Mos
$old_wancfg = $wancfg;
89 dd18038e Ermal
// Populate page descr if it does not exist.
90
if ($if == "wan" && !$wancfg['descr'])
91
	$wancfg['descr'] = "WAN";
92
else if ($if == "lan" && !$wancfg['descr'])
93
	$wancfg['descr'] = "LAN";
94
95 5b237745 Scott Ullrich
96 8256f324 gnhb
foreach ($a_ppps as $pppid => $ppp) {
97 1d7e1d6c gnhb
	if ($wancfg['if'] == $ppp['if'])
98 8256f324 gnhb
		break;
99 30ade846 gnhb
}
100
101 1d7e1d6c gnhb
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
102 30ade846 gnhb
	$pconfig['pppid'] = $pppid;
103 1d7e1d6c gnhb
	$pconfig['ptpid'] = $a_ppps[$pppid]['ptpid'];
104
	$pconfig['port'] = $a_ppps[$pppid]['ports'];
105 70e46e62 Ermal
	if ($a_ppps[$pppid]['type'] == "ppp") {
106 3a906378 gnhb
		$pconfig['username'] = $a_ppps[$pppid]['username'];
107
		$pconfig['password'] = base64_decode($a_ppps[$pppid]['password']);
108 c0948c6c Renato Botelho
109 3a906378 gnhb
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
110
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
111
	}
112 70e46e62 Ermal
	else if ($a_ppps[$pppid]['type'] == "pppoe") {
113 d85ba87f gnhb
		$pconfig['pppoe_username'] = $a_ppps[$pppid]['username'];
114
		$pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']);
115
		$pconfig['provider'] = $a_ppps[$pppid]['provider'];
116
		$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
117
		$pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout'];
118 5b237745 Scott Ullrich
119 d85ba87f gnhb
		/* ================================================ */
120
		/* = force a connection reset at a specific time? = */
121
		/* ================================================ */
122 c0948c6c Renato Botelho
123 d85ba87f gnhb
		if (isset($a_ppps[$pppid]['pppoe-reset-type'])) {
124
			$pconfig['pppoe-reset-type'] = $a_ppps[$pppid]['pppoe-reset-type'];
125 1d7e1d6c gnhb
			$itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']);
126 70e46e62 Ermal
			if ($itemhash)
127
				$cronitem = $itemhash['ITEM'];
128 e40e6724 gnhb
			if (isset($cronitem)) {
129
				$resetTime = "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
130
			} else {
131
				$resetTime = NULL;
132
			}
133 70e46e62 Ermal
			//log_error("ResetTime:".$resetTime);
134 d85ba87f gnhb
			if ($a_ppps[$pppid]['pppoe-reset-type'] == "custom") {
135 70e46e62 Ermal
				if ($cronitem) {
136
					$pconfig['pppoe_pr_custom'] = true;
137
					$pconfig['pppoe_resetminute'] = $cronitem['minute'];
138
					$pconfig['pppoe_resethour'] = $cronitem['hour'];
139
					if ($cronitem['mday'] <> "*" && $cronitem['month'] <> "*")
140
						$pconfig['pppoe_resetdate'] = "{$cronitem['month']}/{$cronitem['mday']}/" . date("Y");
141 af13aad6 Ermal
				}
142 d85ba87f gnhb
			} else if ($a_ppps[$pppid]['pppoe-reset-type'] == "preset") {
143
				$pconfig['pppoe_pr_preset'] = true;
144
				switch ($resetTime) {
145
					case CRON_MONTHLY_PATTERN:
146
						$pconfig['pppoe_monthly'] = true;
147
						break;
148
					case CRON_WEEKLY_PATTERN:
149
						$pconfig['pppoe_weekly'] = true;
150
						break;
151
					case CRON_DAILY_PATTERN:
152
						$pconfig['pppoe_daily'] = true;
153
						break;
154
					case CRON_HOURLY_PATTERN:
155
						$pconfig['pppoe_hourly'] = true;
156
						break;
157
				}
158
			}
159
		}// End force pppoe reset at specific time
160 c0948c6c Renato Botelho
	}// End if type == pppoe
161 e4d40f41 gnhb
	else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp"){
162 d85ba87f gnhb
		$pconfig['pptp_username'] = $a_ppps[$pppid]['username'];
163
		$pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']);
164 4a1ee8ac gnhb
		$pconfig['pptp_local'] = explode(",",$a_ppps[$pppid]['localip']);
165
		$pconfig['pptp_subnet'] = explode(",",$a_ppps[$pppid]['subnet']);
166
		$pconfig['pptp_remote'] = explode(",",$a_ppps[$pppid]['gateway']);
167 d85ba87f gnhb
		$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
168
		$pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout'];
169
	}
170 8256f324 gnhb
} else {
171 1d7e1d6c gnhb
	$pconfig['ptpid'] = interfaces_ptpid_next();
172 8256f324 gnhb
	$pppid = count($a_ppps);
173 d85ba87f gnhb
}
174 5b237745 Scott Ullrich
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
175 bc40d758 Seth Mos
$pconfig['alias-address'] = $wancfg['alias-address'];
176
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
177 e4d40f41 gnhb
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
178 f1f60c92 Ermal Luçi
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
179 6a688547 Ermal
$pconfig['enable'] = isset($wancfg['enable']);
180 f1f60c92 Ermal Luçi
181 9ff9a1c7 Seth Mos
if (is_array($config['aliases']['alias'])) {
182
	foreach($config['aliases']['alias'] as $alias) {
183
		if($alias['name'] == $wancfg['descr']) {
184 ea6be4a7 Erik Fonnesbeck
			$input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."),$wancfg['descr']);
185 9ff9a1c7 Seth Mos
		}
186
	}
187
}
188
189
switch($wancfg['ipaddr']) {
190
	case "dhcp":
191
		$pconfig['type'] = "dhcp";
192
		break;
193
	case "pppoe":
194
	case "pptp":
195 e4d40f41 gnhb
	case "l2tp":
196 611ae852 Ermal
	case "ppp":
197 d85ba87f gnhb
		$pconfig['type'] = $wancfg['ipaddr'];
198 611ae852 Ermal
		break;
199 9ff9a1c7 Seth Mos
	default:
200 85e9cfee Phil Davis
		if(is_ipaddrv4($wancfg['ipaddr'])) {
201 47593ac6 Seth Mos
			$pconfig['type'] = "staticv4";
202 9ff9a1c7 Seth Mos
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
203
			$pconfig['subnet'] = $wancfg['subnet'];
204
			$pconfig['gateway'] = $wancfg['gateway'];
205 dd18038e Ermal
		} else
206 9ff9a1c7 Seth Mos
			$pconfig['type'] = "none";
207
		break;
208
}
209 5b237745 Scott Ullrich
210 47593ac6 Seth Mos
switch($wancfg['ipaddrv6']) {
211 feb88a14 smos
	case "slaac":
212
		$pconfig['type6'] = "slaac";
213
		break;
214 e029943a Seth Mos
	case "dhcp6":
215
		$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
216 8839e3fb bcyrill
		if(!isset($wancfg['dhcp6-ia-pd-len']))
217 e029943a Seth Mos
			$wancfg['dhcp6-ia-pd-len'] = "none";
218
		$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
219
		$pconfig['type6'] = "dhcp6";
220
		break;
221 31c43fd3 smos
	case "6to4":
222
		$pconfig['type6'] = "6to4";
223
		break;
224 20a7cb15 smos
	case "track6":
225
		$pconfig['type6'] = "track6";
226
		$pconfig['track6-interface'] = $wancfg['track6-interface'];
227
		$pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
228 6b2d4b5a Darren Embry
		if ($wancfg['track6-prefix-id'] == "" || $wancfg['track6-prefix-id'] == "none") {
229
			$pconfig['track6-prefix-id--hex'] = "";
230
		} else {
231
			$pconfig['track6-prefix-id--hex'] = sprintf("%x", $wancfg['track6-prefix-id']);
232
		}
233 20a7cb15 smos
		break;
234 7d567088 smos
	case "6rd":
235
		$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
236 12215bfb smos
		if($wancfg['prefix-6rd-v4plen'] == "")
237
			$wancfg['prefix-6rd-v4plen'] = "0";
238
		$pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen'];
239 7d567088 smos
		$pconfig['type6'] = "6rd";
240
		$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
241
		break;
242 47593ac6 Seth Mos
	default:
243 85e9cfee Phil Davis
		if(is_ipaddrv6($wancfg['ipaddrv6'])) {
244 e029943a Seth Mos
			$pconfig['type6'] = "staticv6";
245 47593ac6 Seth Mos
			$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
246
			$pconfig['subnetv6'] = $wancfg['subnetv6'];
247
			$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
248 e029943a Seth Mos
		} else
249
			$pconfig['type6'] = "none";
250 47593ac6 Seth Mos
		break;
251
}
252
253 0eb78676 smos
// print_r($pconfig);
254 47593ac6 Seth Mos
255 5b237745 Scott Ullrich
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
256 ff1955ee Bill Marquette
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
257 5b237745 Scott Ullrich
$pconfig['spoofmac'] = $wancfg['spoofmac'];
258
$pconfig['mtu'] = $wancfg['mtu'];
259 4cea5cf8 Ermal
$pconfig['mss'] = $wancfg['mss'];
260 5b237745 Scott Ullrich
261
/* Wireless interface? */
262 b7f01f59 Bill Marquette
if (isset($wancfg['wireless'])) {
263 ebf94efb Erik Fonnesbeck
	/* Sync first to be sure it displays the actual settings that will be used */
264
	interface_sync_wireless_clones($wancfg, false);
265 4634cb48 Ermal Luçi
	/* Get wireless modes */
266 10394059 Scott Ullrich
	$wlanif = get_real_interface($if);
267 3f23b74d Erik Fonnesbeck
	if (!does_interface_exist($wlanif))
268
		interface_wireless_clone($wlanif, $wancfg);
269 34808d4e Erik Fonnesbeck
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
270 6681fdd3 Erik Fonnesbeck
	preg_match("/^(.*?)([0-9]*)$/", $wlanbaseif, $wlanbaseif_split);
271 10394059 Scott Ullrich
	$wl_modes = get_wireless_modes($if);
272 f4094f0d Erik Fonnesbeck
	$wl_chaninfo = get_wireless_channel_info($if);
273 6681fdd3 Erik Fonnesbeck
	$wl_sysctl_prefix = 'dev.' . $wlanbaseif_split[1] . '.' . $wlanbaseif_split[2];
274 537bf7b3 Erik Fonnesbeck
	$wl_sysctl = get_sysctl(array("{$wl_sysctl_prefix}.diversity", "{$wl_sysctl_prefix}.txantenna", "{$wl_sysctl_prefix}.rxantenna",
275
	                              "{$wl_sysctl_prefix}.slottime", "{$wl_sysctl_prefix}.acktimeout", "{$wl_sysctl_prefix}.ctstimeout"));
276 071d63b9 Erik Fonnesbeck
	$wl_regdomain_xml_attr = array();
277
	$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
278
	$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
279
	$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
280
	$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
281
	$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
282 f62c44d8 Erik Fonnesbeck
	$pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]);
283 4634cb48 Ermal Luçi
	$pconfig['standard'] = $wancfg['wireless']['standard'];
284
	$pconfig['mode'] = $wancfg['wireless']['mode'];
285
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
286 ff2f4e43 Ermal Luçi
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
287 4634cb48 Ermal Luçi
	$pconfig['channel'] = $wancfg['wireless']['channel'];
288
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
289 537bf7b3 Erik Fonnesbeck
	$pconfig['diversity'] = $wancfg['wireless']['diversity'];
290
	$pconfig['txantenna'] = $wancfg['wireless']['txantenna'];
291
	$pconfig['rxantenna'] = $wancfg['wireless']['rxantenna'];
292 4634cb48 Ermal Luçi
	$pconfig['distance'] = $wancfg['wireless']['distance'];
293 20f09b3b Erik Fonnesbeck
	$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
294
	$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
295
	$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
296 4634cb48 Ermal Luçi
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
297 57bbd532 Erik Fonnesbeck
	if (isset($wancfg['wireless']['puren']['enable']))
298
		$pconfig['puremode'] = '11n';
299
	else if (isset($wancfg['wireless']['pureg']['enable']))
300
		$pconfig['puremode'] = '11g';
301
	else
302
		$pconfig['puremode'] = 'any';
303 4634cb48 Ermal Luçi
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
304
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
305
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
306 5949124c Scott Ullrich
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
307
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
308
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
309 32764288 Namezero
	$pconfig['auth_server_addr2'] = $wancfg['wireless']['auth_server_addr2'];
310
	$pconfig['auth_server_port2'] = $wancfg['wireless']['auth_server_port2'];
311
	$pconfig['auth_server_shared_secret2'] = $wancfg['wireless']['auth_server_shared_secret2'];
312 4634cb48 Ermal Luçi
	if (is_array($wancfg['wireless']['wpa'])) {
313
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
314
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
315
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
316
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
317
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
318
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
319
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
320
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
321
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
322
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
323
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
324 bfe1ef8c Ermal Luçi
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
325 ea62cd32 Scott Ullrich
		$pconfig['rsn_preauth'] = isset($wancfg['wireless']['wpa']['rsn_preauth']);
326 4634cb48 Ermal Luçi
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
327
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
328
	}
329
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
330
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
331 270c4607 Scott Ullrich
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
332 53c82ef9 Scott Ullrich
		$i = 1;
333
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
334
			$pconfig['key' . $i] = $wepkey['value'];
335
			if (isset($wepkey['txkey']))
336
				$pconfig['txkey'] = $i;
337
			$i++;
338
		}
339
		if (!isset($wepkey['txkey']))
340
			$pconfig['txkey'] = 1;
341 4634cb48 Ermal Luçi
	}
342 5b237745 Scott Ullrich
}
343
344 6b2d4b5a Darren Embry
$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']);
345
$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length);
346
347 43e255d2 Ermal Luçi
if ($_POST['apply']) {
348 7994c3f8 Ermal Luçi
	unset($input_errors);
349 a368a026 Ermal Lu?i
	if (!is_subsystem_dirty('interfaces'))
350 136c598d Carlos Eduardo Ramos
		$intput_errors[] = gettext("You have already applied your settings!");
351 c0948c6c Renato Botelho
	else {
352 270c4607 Scott Ullrich
		unlink_if_exists("{$g['tmp_path']}/config.cache");
353 a368a026 Ermal Lu?i
		clear_subsystem_dirty('interfaces');
354 c0948c6c Renato Botelho
355 dd18038e Ermal
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
356
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
357 18f338da Ermal Lu?i
			foreach ($toapplylist as $ifapply => $ifcfgo) {
358 4144aa81 Ermal
				if (isset($config['interfaces'][$ifapply]['enable'])) {
359
					interface_bring_down($ifapply, false, $ifcfgo);
360 613a3cc5 Renato Botelho
					interface_configure($ifapply, true);
361 4144aa81 Ermal
				} else
362 dd1fc379 Ermal
					interface_bring_down($ifapply, true, $ifcfgo);
363 dd18038e Ermal
			}
364
		}
365 c0948c6c Renato Botelho
		/* restart snmp so that it binds to correct address */
366
		services_snmpd_configure();
367 a5d6f60b Ermal Lu?i
368 270c4607 Scott Ullrich
		/* sync filter configuration */
369 61fc1160 Scott Ullrich
		setup_gateways_monitor();
370 a5d6f60b Ermal Lu?i
371 18f338da Ermal Lu?i
		clear_subsystem_dirty('interfaces');
372 c0948c6c Renato Botelho
373 b4d36392 Scott Ullrich
		filter_configure();
374 c0948c6c Renato Botelho
375 1ee5d4b3 sullrich
		enable_rrd_graphing();
376 7994c3f8 Ermal Luçi
	}
377 dd18038e Ermal
	@unlink("{$g['tmp_path']}/.interfaces.apply");
378 7994c3f8 Ermal Luçi
	header("Location: interfaces.php?if={$if}");
379
	exit;
380 dd18038e Ermal
} else if ($_POST && $_POST['enable'] != "yes") {
381 270c4607 Scott Ullrich
	unset($wancfg['enable']);
382 dd18038e Ermal
	if (isset($wancfg['wireless']))
383 8f0289e7 Erik Fonnesbeck
		interface_sync_wireless_clones($wancfg, false);
384 270c4607 Scott Ullrich
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
385 a368a026 Ermal Lu?i
	mark_subsystem_dirty('interfaces');
386 ee5c01b5 Seth Mos
	if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
387 dd18038e Ermal
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
388 ee5c01b5 Seth Mos
	} else {
389 dd18038e Ermal
		$toapplylist = array();
390 ee5c01b5 Seth Mos
	}
391 18f338da Ermal Lu?i
	$toapplylist[$if] = $wancfg;
392 ee5c01b5 Seth Mos
	/* we need to be able remove IP aliases for IPv6 */
393 dd18038e Ermal
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
394 270c4607 Scott Ullrich
	header("Location: interfaces.php?if={$if}");
395
	exit;
396 dd18038e Ermal
} else if ($_POST) {
397 270c4607 Scott Ullrich
398 53c82ef9 Scott Ullrich
	unset($input_errors);
399
	$pconfig = $_POST;
400 6b2d4b5a Darren Embry
	if ($pconfig['track6-prefix-id--hex'] === "") {
401
		$pconfig['track6-prefix-id'] = "none";
402
	} else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
403
		$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
404
	} else {
405
		$pconfig['track6-prefix-id'] = "none";
406
	}
407 53c82ef9 Scott Ullrich
	conf_mount_rw();
408 fe24301f Ermal
409 53c82ef9 Scott Ullrich
	/* filter out spaces from descriptions  */
410
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
411 fe24301f Ermal
412 b4d36392 Scott Ullrich
	/* okay first of all, cause we are just hiding the PPPoE HTML
413 53c82ef9 Scott Ullrich
	 * fields releated to PPPoE resets, we are going to unset $_POST
414
	 * vars, if the reset feature should not be used. Otherwise the
415
	 * data validation procedure below, may trigger a false error
416
	 * message.
417
	 */
418 e40e6724 gnhb
	if (empty($_POST['pppoe-reset-type'])) {
419 c0948c6c Renato Botelho
		unset($_POST['pppoe_pr_type']);
420 53c82ef9 Scott Ullrich
		unset($_POST['pppoe_resethour']);
421
		unset($_POST['pppoe_resetminute']);
422
		unset($_POST['pppoe_resetdate']);
423
		unset($_POST['pppoe_pr_preset_val']);
424
	}
425
	/* description unique? */
426 dd18038e Ermal
	foreach ($ifdescrs as $ifent => $ifdescr) {
427 79851fc8 Ermal
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
428 136c598d Carlos Eduardo Ramos
			$input_errors[] = gettext("An interface with the specified description already exists.");
429 79851fc8 Ermal
			break;
430
		}
431 53c82ef9 Scott Ullrich
	}
432
	/* input validation */
433 e029943a Seth Mos
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^staticv4/", $_POST['type'])))
434 136c598d Carlos Eduardo Ramos
		$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.");
435 e029943a Seth Mos
	if (isset($config['dhcpd6']) && isset($config['dhcpd6'][$if]['enable']) && (! preg_match("/^staticv6/", $_POST['type6'])))
436
		$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.");
437 0c9da721 Ermal Lu?i
438 ef130e9f Ermal
	switch(strtolower($_POST['type'])) {
439 47593ac6 Seth Mos
		case "staticv4":
440 9ff9a1c7 Seth Mos
			$reqdfields = explode(" ", "ipaddr subnet gateway");
441 47593ac6 Seth Mos
			$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
442
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
443
			break;
444 88c00a65 Ermal
		case "none":
445 62a4abc9 Ermal
			if(is_array($config['virtualip']['vip'])) {
446
				foreach ($config['virtualip']['vip'] as $vip) {
447 2452cc37 Darren Embry
					if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if)
448
						$input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration.");
449 62a4abc9 Ermal
				}
450
			}
451 88c00a65 Ermal
		case "dhcp":
452 a9543eae Seth Mos
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp")))
453 d1d0a1ad Vinicius Coque
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
454 47593ac6 Seth Mos
			break;
455 513b762e gnhb
		case "ppp":
456
			$reqdfields = explode(" ", "port phone");
457 8cc6876f groo
			$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
458 513b762e gnhb
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
459
			break;
460 ef130e9f Ermal
		case "pppoe":
461 9ff9a1c7 Seth Mos
			if ($_POST['pppoe_dialondemand']) {
462
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
463 8cc6876f groo
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
464 9ff9a1c7 Seth Mos
			} else {
465
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
466 8cc6876f groo
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
467 9ff9a1c7 Seth Mos
			}
468
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
469
			break;
470 ef130e9f Ermal
		case "pptp":
471 9ff9a1c7 Seth Mos
			if ($_POST['pptp_dialondemand']) {
472
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
473 8cc6876f groo
				$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"));
474 9ff9a1c7 Seth Mos
			} else {
475
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
476 8cc6876f groo
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
477 9ff9a1c7 Seth Mos
			}
478
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
479
			break;
480 e4d40f41 gnhb
		case "l2tp":
481
			if ($_POST['pptp_dialondemand']) {
482
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
483
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
484
			} else {
485
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
486
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"));
487
			}
488
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
489
			break;
490 53c82ef9 Scott Ullrich
	}
491 e029943a Seth Mos
	switch(strtolower($_POST['type6'])) {
492
		case "staticv6":
493 20b49b17 Seth Mos
			$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
494 1e37f324 smos
			$reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway"));
495 e029943a Seth Mos
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
496
			break;
497
		case "none":
498
			if(is_array($config['virtualip']['vip'])) {
499
				foreach ($config['virtualip']['vip'] as $vip) {
500 2452cc37 Darren Embry
					if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if)
501
						$input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration.");
502 e029943a Seth Mos
				}
503
			}
504
		case "dhcp6":
505
			if (in_array($wancfg['ipaddrv6'], array()))
506 8b198c64 smos
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
507 e029943a Seth Mos
			break;
508 7d567088 smos
		case "6rd":
509 8b198c64 smos
			foreach ($ifdescrs as $ifent => $ifdescr) {
510 c616b3c7 smos
				if ($if != $ifent && (($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6']) || ($config[interfaces][$ifent]['ipaddrv6'] == "6to4")) ) {
511 8b198c64 smos
					$input_errors[] = sprintf(gettext("You can only have one interface configured as %s or 6to4."),$_POST['type6']);
512
					break;
513
				}
514
			}
515 7d567088 smos
			if (in_array($wancfg['ipaddrv6'], array()))
516 8b198c64 smos
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
517 7d567088 smos
			break;
518 31c43fd3 smos
		case "6to4":
519 8b198c64 smos
			foreach ($ifdescrs as $ifent => $ifdescr) {
520 c616b3c7 smos
				if ($if != $ifent && (($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6']) || ($config[interfaces][$ifent]['ipaddrv6'] == "6rd")) ) {
521 8b198c64 smos
					$input_errors[] = sprintf(gettext("You can only have one interface configured as %s or 6rd."),$_POST['type6']);
522
					break;
523
				}
524
			}
525 31c43fd3 smos
			if (in_array($wancfg['ipaddrv6'], array()))
526 8b198c64 smos
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
527 31c43fd3 smos
			break;
528 20a7cb15 smos
		case "track6":
529
			/* needs to check if $track6-prefix-id is used on another interface */
530
			if (in_array($wancfg['ipaddrv6'], array()))
531 8b198c64 smos
				$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']);
532 6b2d4b5a Darren Embry
533
			if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
534
				$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
535
			} else {
536
				$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
537
				if ($track6_prefix_id < 0 || $track6_prefix_id >= $ipv6_num_prefix_ids) {
538
					$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.");
539
				}
540
			}
541 20a7cb15 smos
			break;
542 e029943a Seth Mos
	}
543 9ff9a1c7 Seth Mos
544 e029943a Seth Mos
	
545 53c82ef9 Scott Ullrich
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
546
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
547 e6c60013 Renato Botelho
	if ($_POST['ipaddr']) {
548
		if (!is_ipaddrv4($_POST['ipaddr']))
549
			$input_errors[] = gettext("A valid IPv4 address must be specified.");
550
		else if (is_ipaddr_configured($_POST['ipaddr'], $if, true, true))
551
			$input_errors[] = gettext("This IPv4 address is being used by another interface or VIP.");
552
	}
553 85e9cfee Phil Davis
	if (($_POST['ipaddrv6'] && !is_ipaddrv6($_POST['ipaddrv6'])))
554 47593ac6 Seth Mos
		$input_errors[] = gettext("A valid IPv6 address must be specified.");
555 c0948c6c Renato Botelho
	if (($_POST['subnet'] && !is_numeric($_POST['subnet'])))
556 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
557 47593ac6 Seth Mos
	if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6'])))
558
		$input_errors[] = gettext("A valid subnet bit count must be specified.");
559 85e9cfee Phil Davis
	if (($_POST['alias-address'] && !is_ipaddrv4($_POST['alias-address'])))
560 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid alias IP address must be specified.");
561 c0948c6c Renato Botelho
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet'])))
562 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
563 47593ac6 Seth Mos
	if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
564 53c82ef9 Scott Ullrich
		$match = false;
565 9ff9a1c7 Seth Mos
		foreach($a_gateways as $gateway) {
566
			if(in_array($_POST['gateway'], $gateway)) {
567 53c82ef9 Scott Ullrich
				$match = true;
568 9ff9a1c7 Seth Mos
			}
569
		}
570 47593ac6 Seth Mos
		foreach($a_gateways as $gateway) {
571
			if(in_array($_POST['gatewayv6'], $gateway)) {
572
				$match = true;
573
			}
574
		}
575 9ff9a1c7 Seth Mos
		if(!$match) {
576 136c598d Carlos Eduardo Ramos
			$input_errors[] = gettext("A valid gateway must be specified.");
577 9ff9a1c7 Seth Mos
		}
578 53c82ef9 Scott Ullrich
	}
579 c0948c6c Renato Botelho
	if (($_POST['provider'] && !is_domain($_POST['provider'])))
580 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("The service name contains invalid characters.");
581 c0948c6c Renato Botelho
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout']))
582 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("The idle timeout value must be an integer.");
583 c0948c6c Renato Botelho
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
584
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23)
585 53c82ef9 Scott Ullrich
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
586 c0948c6c Renato Botelho
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) &&
587
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59)
588 53c82ef9 Scott Ullrich
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
589 c0948c6c Renato Botelho
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate'])))
590 53c82ef9 Scott Ullrich
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
591 85e9cfee Phil Davis
	if (($_POST['pptp_local'] && !is_ipaddrv4($_POST['pptp_local'])))
592 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
593 c0948c6c Renato Botelho
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet'])))
594 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
595 85e9cfee Phil Davis
	if (($_POST['pptp_remote'] && !is_ipaddrv4($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface])))
596 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
597 c0948c6c Renato Botelho
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout']))
598 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("The idle timeout value must be an integer.");
599 c0948c6c Renato Botelho
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])))
600 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid MAC address must be specified.");
601 c0948c6c Renato Botelho
	if ($_POST['mtu'] && ($_POST['mtu'] < 576))
602 136c598d Carlos Eduardo Ramos
		$input_errors[] = gettext("The MTU must be greater than 576 bytes.");
603 c0948c6c Renato Botelho
	if ($_POST['mss'] && ($_POST['mss'] < 576))
604 4cea5cf8 Ermal
		$input_errors[] = gettext("The MSS must be greater than 576 bytes.");
605 53c82ef9 Scott Ullrich
	/* Wireless interface? */
606
	if (isset($wancfg['wireless'])) {
607 bb9d70d2 Erik Fonnesbeck
		$reqdfields = array("mode");
608
		$reqdfieldsn = array(gettext("Mode"));
609
		if ($_POST['mode'] == 'hostap') {
610
			$reqdfields[] = "ssid";
611
			$reqdfieldsn[] = gettext("SSID");
612
		}
613 53c82ef9 Scott Ullrich
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
614 597330aa Erik Fonnesbeck
		check_wireless_mode();
615 53c82ef9 Scott Ullrich
		/* loop through keys and enforce size */
616
		for ($i = 1; $i <= 4; $i++) {
617
			if ($_POST['key' . $i]) {
618
				/* 64 bit */
619
				if (strlen($_POST['key' . $i]) == 5)
620
					continue;
621
				if (strlen($_POST['key' . $i]) == 10) {
622
					/* hex key */
623
					if (stristr($_POST['key' . $i], "0x") == false) {
624 4634cb48 Ermal Luçi
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
625
					}
626 53c82ef9 Scott Ullrich
					continue;
627
				}
628
				if (strlen($_POST['key' . $i]) == 12) {
629
					/* hex key */
630
					if(stristr($_POST['key' . $i], "0x") == false) {
631
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
632 4634cb48 Ermal Luçi
					}
633 53c82ef9 Scott Ullrich
					continue;
634
				}
635
				/* 128 bit */
636
				if (strlen($_POST['key' . $i]) == 13)
637
					continue;
638
				if (strlen($_POST['key' . $i]) == 26) {
639
					/* hex key */
640
					if (stristr($_POST['key' . $i], "0x") == false)
641
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
642
					continue;
643 4634cb48 Ermal Luçi
				}
644 53c82ef9 Scott Ullrich
				if(strlen($_POST['key' . $i]) == 28)
645
					continue;
646 136c598d Carlos Eduardo Ramos
				$input_errors[] =  gettext("Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.");
647 53c82ef9 Scott Ullrich
				break;
648 4634cb48 Ermal Luçi
			}
649 5b237745 Scott Ullrich
		}
650 08fae438 Ermal Lu?i
651
		if ($_POST['passphrase']) {
652
                	$passlen = strlen($_POST['passphrase']);
653
                	if ($passlen < 8 || $passlen > 64)
654 136c598d Carlos Eduardo Ramos
                        	$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
655 08fae438 Ermal Lu?i
		}
656 53c82ef9 Scott Ullrich
	}
657
	if (!$input_errors) {
658 8b1e7d04 Ermal
		if ($wancfg['ipaddr'] != $_POST['type']) {
659 ef130e9f Ermal
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
660
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
661
				unset($a_ppps[$pppid]);
662 e029943a Seth Mos
			} else if ($wancfg['ipaddrv6'] == "dhcp6") {
663 76ac460b jim-p
				$pid = find_dhcp6c_process($wancfg['if']);
664 e029943a Seth Mos
				if($pid)
665
					posix_kill($pid, SIGTERM);
666 8b1e7d04 Ermal
			} else if ($wancfg['ipaddr'] == "dhcp") {
667 76ac460b jim-p
				$pid = find_dhclient_process($wancfg['if']);
668 1f676b67 Ermal
				if($pid)
669
					posix_kill($pid, SIGTERM);
670 ef130e9f Ermal
			}
671 1f676b67 Ermal
				
672 ef130e9f Ermal
		}
673 d85ba87f gnhb
		$ppp = array();
674 da75413d Ermal
		if ($wancfg['ipaddr'] != "ppp")
675
			unset($wancfg['ipaddr']);
676 47593ac6 Seth Mos
		if ($wancfg['ipaddrv6'] != "ppp")
677
			unset($wancfg['ipaddrv6']);
678 53c82ef9 Scott Ullrich
		unset($wancfg['subnet']);
679
		unset($wancfg['gateway']);
680 47593ac6 Seth Mos
		unset($wancfg['subnetv6']);
681
		unset($wancfg['gatewayv6']);
682 53c82ef9 Scott Ullrich
		unset($wancfg['dhcphostname']);
683 ed395640 Seth Mos
		unset($wancfg['dhcp6-duid']);
684
		unset($wancfg['dhcp6-ia-pd-len']);
685 20a7cb15 smos
		unset($wancfg['track6-interface']);
686
		unset($wancfg['track6-prefix-id']);		
687 7d567088 smos
		unset($wancfg['prefix-6rd']);
688 12215bfb smos
		unset($wancfg['prefix-6rd-v4plen']);
689 7d567088 smos
		unset($wancfg['gateway-6rd']);
690 53c82ef9 Scott Ullrich
		unset($wancfg['pppoe_password']);
691
		unset($wancfg['pptp_username']);
692
		unset($wancfg['pptp_password']);
693
		unset($wancfg['provider']);
694
		unset($wancfg['ondemand']);
695
		unset($wancfg['timeout']);
696 70e46e62 Ermal
		if (empty($wancfg['pppoe']['pppoe-reset-type']))
697 8b7ae9a3 jim-p
			unset($wancfg['pppoe']['pppoe-reset-type']);
698 53c82ef9 Scott Ullrich
		unset($wancfg['local']);
699 cb3c3fe4 Namezero
		
700 53c82ef9 Scott Ullrich
		unset($wancfg['remote']);
701 8256f324 gnhb
		unset($a_ppps[$pppid]['apn']);
702
		unset($a_ppps[$pppid]['phone']);
703
		unset($a_ppps[$pppid]['localip']);
704
		unset($a_ppps[$pppid]['subnet']);
705
		unset($a_ppps[$pppid]['gateway']);
706
		unset($a_ppps[$pppid]['pppoe-reset-type']);
707 1d7e1d6c gnhb
		unset($a_ppps[$pppid]['provider']);
708 c0948c6c Renato Botelho
709 53c82ef9 Scott Ullrich
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
710 6a688547 Ermal
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
711 9ff9a1c7 Seth Mos
712 2fe06a32 smos
		/* let return_gateways_array() do the magic on dynamic interfaces for us */
713 9ff9a1c7 Seth Mos
		switch($_POST['type']) {
714 47593ac6 Seth Mos
			case "staticv4":
715
				$wancfg['ipaddr'] = $_POST['ipaddr'];
716
				$wancfg['subnet'] = $_POST['subnet'];
717
				if ($_POST['gateway'] != "none") {
718
					$wancfg['gateway'] = $_POST['gateway'];
719
				}
720
				break;
721 9ff9a1c7 Seth Mos
			case "dhcp":
722
				$wancfg['ipaddr'] = "dhcp";
723
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
724
				$wancfg['alias-address'] = $_POST['alias-address'];
725
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
726 e4d40f41 gnhb
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
727 9ff9a1c7 Seth Mos
				if($gateway_item) {
728
					$a_gateways[] = $gateway_item;
729
				}
730
				break;
731 3a906378 gnhb
			case "ppp":
732
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
733
				$a_ppps[$pppid]['type'] = $_POST['type'];
734 1d7e1d6c gnhb
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
735 3a906378 gnhb
				$a_ppps[$pppid]['ports'] = $_POST['port'];
736
				$a_ppps[$pppid]['username'] = $_POST['username'];
737
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
738 8256f324 gnhb
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
739 3a906378 gnhb
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
740 1d7e1d6c gnhb
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
741 8256f324 gnhb
				$wancfg['ipaddr'] = $_POST['type'];
742
				unset($a_ppps[$pppid]['ondemand']);
743
				unset($a_ppps[$pppid]['idletimeout']);
744 3a906378 gnhb
				break;
745
746 9ff9a1c7 Seth Mos
			case "pppoe":
747 6c05cfb0 gnhb
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
748
				$a_ppps[$pppid]['type'] = $_POST['type'];
749 1d7e1d6c gnhb
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
750 d85ba87f gnhb
				if (isset($_POST['ppp_port']))
751 6c05cfb0 gnhb
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
752 d85ba87f gnhb
				else
753 6c05cfb0 gnhb
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
754
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
755
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
756 d85ba87f gnhb
				if (!empty($_POST['provider']))
757 6c05cfb0 gnhb
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
758 d85ba87f gnhb
				else
759 233e2af1 jim-p
					$a_ppps[$pppid]['provider'] = true;
760 6c05cfb0 gnhb
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
761 0ff214f2 Renato Botelho
				if (!empty($_POST['pppoe_idletimeout']))
762 6c05cfb0 gnhb
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
763 d85ba87f gnhb
				else
764 6c05cfb0 gnhb
					unset($a_ppps[$pppid]['idletimeout']);
765 d85ba87f gnhb
766
				if (!empty($_POST['pppoe-reset-type']))
767 6c05cfb0 gnhb
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
768 d85ba87f gnhb
				else
769 6c05cfb0 gnhb
					unset($a_ppps[$pppid]['pppoe-reset-type']);
770 1d7e1d6c gnhb
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
771 d85ba87f gnhb
				$wancfg['ipaddr'] = $_POST['type'];
772 9ff9a1c7 Seth Mos
				if($gateway_item) {
773
					$a_gateways[] = $gateway_item;
774
				}
775 c0948c6c Renato Botelho
776 9ff9a1c7 Seth Mos
				break;
777
			case "pptp":
778 e4d40f41 gnhb
			case "l2tp":
779 6c05cfb0 gnhb
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
780
				$a_ppps[$pppid]['type'] = $_POST['type'];
781 1d7e1d6c gnhb
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
782 d85ba87f gnhb
				if (isset($_POST['ppp_port']))
783 6c05cfb0 gnhb
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
784 d85ba87f gnhb
				else
785 6c05cfb0 gnhb
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
786
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
787
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
788 ced4df74 gnhb
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
789 6c05cfb0 gnhb
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
790
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
791
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
792 0ff214f2 Renato Botelho
				if (!empty($_POST['pptp_idletimeout']))
793 6c05cfb0 gnhb
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
794 d85ba87f gnhb
				else
795 6c05cfb0 gnhb
					unset($a_ppps[$pppid]['idletimeout']);
796 1d7e1d6c gnhb
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
797 d85ba87f gnhb
				$wancfg['ipaddr'] = $_POST['type'];
798 9ff9a1c7 Seth Mos
				if($gateway_item) {
799
					$a_gateways[] = $gateway_item;
800
				}
801
				break;
802 6c05cfb0 gnhb
			case "none":
803
				break;
804 4634cb48 Ermal Luçi
		}
805 e029943a Seth Mos
		switch($_POST['type6']) {
806
			case "staticv6":
807
				$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
808
				$wancfg['subnetv6'] = $_POST['subnetv6'];
809
				if ($_POST['gatewayv6'] != "none") {
810
					$wancfg['gatewayv6'] = $_POST['gatewayv6'];
811
				}
812
				break;
813 feb88a14 smos
			case "slaac":
814
				$wancfg['ipaddrv6'] = "slaac";
815
				break;
816 e029943a Seth Mos
			case "dhcp6":
817
				$wancfg['ipaddrv6'] = "dhcp6";
818
				$wancfg['dhcp6-duid'] = $_POST['dhcp6-duid'];
819
				$wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len'];
820
				if($gateway_item) {
821
					$a_gateways[] = $gateway_item;
822
				}
823
				break;
824 7d567088 smos
			case "6rd":
825
				$wancfg['ipaddrv6'] = "6rd";
826
				$wancfg['prefix-6rd'] = $_POST['prefix-6rd'];
827 12215bfb smos
				$wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen'];
828 7d567088 smos
				$wancfg['gateway-6rd'] = $_POST['gateway-6rd'];
829
				if($gateway_item) {
830
					$a_gateways[] = $gateway_item;
831
				}
832
				break;
833 31c43fd3 smos
			case "6to4":
834
				$wancfg['ipaddrv6'] = "6to4";
835
				break;
836 20a7cb15 smos
			case "track6":
837
				$wancfg['ipaddrv6'] = "track6";
838
				$wancfg['track6-interface'] = $_POST['track6-interface'];
839 6b2d4b5a Darren Embry
				if ($_POST['track6-prefix-id--hex'] === "") {
840
					$wancfg['track6-prefix-id'] = "none";
841
				} else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
842
					$wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
843
				} else {
844
					$wancfg['track6-prefix-id'] = "none";
845
				}
846 20a7cb15 smos
				break;
847 e029943a Seth Mos
			case "none":
848
				break;
849
		}
850 1d7e1d6c gnhb
		handle_pppoe_reset($_POST);
851 c0948c6c Renato Botelho
852 9ff9a1c7 Seth Mos
		if($_POST['blockpriv'] == "yes") {
853 53c82ef9 Scott Ullrich
			$wancfg['blockpriv'] = true;
854 9ff9a1c7 Seth Mos
		} else {
855 53c82ef9 Scott Ullrich
			unset($wancfg['blockpriv']);
856 9ff9a1c7 Seth Mos
		}
857
		if($_POST['blockbogons'] == "yes") {
858 53c82ef9 Scott Ullrich
			$wancfg['blockbogons'] = true;
859 9ff9a1c7 Seth Mos
		} else {
860 53c82ef9 Scott Ullrich
			unset($wancfg['blockbogons']);
861 9ff9a1c7 Seth Mos
		}
862 53c82ef9 Scott Ullrich
		$wancfg['spoofmac'] = $_POST['spoofmac'];
863 9ff9a1c7 Seth Mos
		if (empty($_POST['mtu'])) {
864 d6a891da Ermal Lu?i
			unset($wancfg['mtu']);
865 9ff9a1c7 Seth Mos
		} else {
866 d6a891da Ermal Lu?i
			$wancfg['mtu'] = $_POST['mtu'];
867 9ff9a1c7 Seth Mos
		}
868 4cea5cf8 Ermal
		if (empty($_POST['mss'])) {
869
			unset($wancfg['mss']);
870
		} else {
871
			$wancfg['mss'] = $_POST['mss'];
872
		}
873 509ca889 Evgeny Yurchenko
		if (empty($_POST['mediaopt'])) {
874
			unset($wancfg['media']);
875
			unset($wancfg['mediaopt']);
876
		} else {
877
			$mediaopts = explode(' ', $_POST['mediaopt']);	
878
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
879
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
880
			else { unset($wancfg['mediaopt']); }
881
		}
882 9ff9a1c7 Seth Mos
		if (isset($wancfg['wireless'])) {
883 25a6411a Scott Ullrich
			handle_wireless_post();
884 9ff9a1c7 Seth Mos
		}
885 c0948c6c Renato Botelho
886 dd18038e Ermal
		conf_mount_ro();
887 53c82ef9 Scott Ullrich
		write_config();
888 dd18038e Ermal
889 ee5c01b5 Seth Mos
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
890 dd18038e Ermal
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
891 ee5c01b5 Seth Mos
		} else {
892 dd18038e Ermal
			$toapplylist = array();
893 ee5c01b5 Seth Mos
		}
894 18f338da Ermal Lu?i
		$toapplylist[$if] = $old_wancfg;
895 dd18038e Ermal
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
896
897 a368a026 Ermal Lu?i
		mark_subsystem_dirty('interfaces');
898 dd18038e Ermal
899 53c82ef9 Scott Ullrich
		/* regenerate cron settings/crontab file */
900
		configure_cron();
901 dd18038e Ermal
902 53c82ef9 Scott Ullrich
		header("Location: interfaces.php?if={$if}");
903
		exit;
904
	}
905 c0948c6c Renato Botelho
906
} // end if($_POST)
907 270c4607 Scott Ullrich
908 25a6411a Scott Ullrich
function handle_wireless_post() {
909 f62c44d8 Erik Fonnesbeck
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
910 270c4607 Scott Ullrich
	if (!is_array($wancfg['wireless']))
911
		$wancfg['wireless'] = array();
912
	$wancfg['wireless']['standard'] = $_POST['standard'];
913
	$wancfg['wireless']['mode'] = $_POST['mode'];
914
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
915
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
916
	$wancfg['wireless']['channel'] = $_POST['channel'];
917
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
918
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
919
	$wancfg['wireless']['distance'] = $_POST['distance'];
920 20f09b3b Erik Fonnesbeck
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
921
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
922
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
923
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
924 071d63b9 Erik Fonnesbeck
		foreach($wl_countries_attr as $wl_country) {
925
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
926
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
927 20f09b3b Erik Fonnesbeck
				break;
928
			}
929
		}
930
	}
931 270c4607 Scott Ullrich
	if (!is_array($wancfg['wireless']['wpa']))
932
		$wancfg['wireless']['wpa'] = array();
933
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
934
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
935
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
936
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
937
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
938
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
939
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
940
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
941
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
942 5949124c Scott Ullrich
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
943
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
944
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
945 32764288 Namezero
	$wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2'];
946
	$wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2'];
947
	$wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2'];
948
	
949 f62c44d8 Erik Fonnesbeck
	if ($_POST['persistcommonwireless'] == "yes") {
950 6ef2297b Erik Fonnesbeck
		if (!is_array($config['wireless']))
951
			$config['wireless'] = array();
952
		if (!is_array($config['wireless']['interfaces']))
953
			$config['wireless']['interfaces'] = array();
954
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
955 f62c44d8 Erik Fonnesbeck
			$config['wireless']['interfaces'][$wlanbaseif] = array();
956
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
957
		unset($config['wireless']['interfaces'][$wlanbaseif]);
958 1930ccb6 Erik Fonnesbeck
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
959 537bf7b3 Erik Fonnesbeck
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
960
	else if (isset($wancfg['wireless']['diversity']))
961
		unset($wancfg['wireless']['diversity']);
962 1930ccb6 Erik Fonnesbeck
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
963 537bf7b3 Erik Fonnesbeck
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
964
	else if (isset($wancfg['wireless']['txantenna']))
965
		unset($wancfg['wireless']['txantenna']);
966 1930ccb6 Erik Fonnesbeck
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
967 537bf7b3 Erik Fonnesbeck
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
968
	else if (isset($wancfg['wireless']['rxantenna']))
969
		unset($wancfg['wireless']['rxantenna']);
970 270c4607 Scott Ullrich
	if ($_POST['hidessid_enable'] == "yes")
971
		$wancfg['wireless']['hidessid']['enable'] = true;
972
	else if (isset($wancfg['wireless']['hidessid']['enable']))
973
		unset($wancfg['wireless']['hidessid']['enable']);
974
	if ($_POST['mac_acl_enable'] == "yes")
975
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
976
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
977
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
978 c9e7d30d Scott Ullrich
	if ($_POST['rsn_preauth'] == "yes")
979 ea62cd32 Scott Ullrich
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
980 c0948c6c Renato Botelho
	else
981 ea62cd32 Scott Ullrich
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
982 270c4607 Scott Ullrich
	if ($_POST['ieee8021x'] == "yes")
983
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
984
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
985
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
986
	if ($_POST['wpa_strict_rekey'] == "yes")
987
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
988
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
989
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
990
	if ($_POST['debug_mode'] == "yes")
991
		$wancfg['wireless']['wpa']['debug_mode'] = true;
992
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
993
		sunset($wancfg['wireless']['wpa']['debug_mode']);
994
	if ($_POST['wpa_enable'] == "yes")
995
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
996
	else if (isset($wancfg['wireless']['wpa']['enable']))
997
		unset($wancfg['wireless']['wpa']['enable']);
998
	if ($_POST['wep_enable'] == "yes") {
999
		if (!is_array($wancfg['wireless']['wep']))
1000
			$wancfg['wireless']['wep'] = array();
1001
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
1002
	} else if (isset($wancfg['wireless']['wep']))
1003
		unset($wancfg['wireless']['wep']);
1004
	if ($_POST['wme_enable'] == "yes") {
1005
		if (!is_array($wancfg['wireless']['wme']))
1006
			$wancfg['wireless']['wme'] = array();
1007
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
1008
	} else if (isset($wancfg['wireless']['wme']['enable']))
1009
		unset($wancfg['wireless']['wme']['enable']);
1010 57bbd532 Erik Fonnesbeck
	if ($_POST['puremode'] == "11g") {
1011 270c4607 Scott Ullrich
		if (!is_array($wancfg['wireless']['pureg']))
1012
			$wancfg['wireless']['pureg'] = array();
1013 57bbd532 Erik Fonnesbeck
		$wancfg['wireless']['pureg']['enable'] = true;
1014
	} else if ($_POST['puremode'] == "11n") {
1015 ed459692 Erik Fonnesbeck
		if (!is_array($wancfg['wireless']['puren']))
1016
			$wancfg['wireless']['puren'] = array();
1017 57bbd532 Erik Fonnesbeck
		$wancfg['wireless']['puren']['enable'] = true;
1018
	} else {
1019
		if (isset($wancfg['wireless']['pureg']))
1020
			unset($wancfg['wireless']['pureg']);
1021
		if (isset($wancfg['wireless']['puren']))
1022
			unset($wancfg['wireless']['puren']);
1023
	}
1024 270c4607 Scott Ullrich
	if ($_POST['apbridge_enable'] == "yes") {
1025
		if (!is_array($wancfg['wireless']['apbridge']))
1026
			$wancfg['wireless']['apbridge'] = array();
1027
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
1028
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
1029
		unset($wancfg['wireless']['apbridge']['enable']);
1030 9be20928 Erik Fonnesbeck
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
1031 270c4607 Scott Ullrich
		if (!is_array($wancfg['wireless']['turbo']))
1032
			$wancfg['wireless']['turbo'] = array();
1033
		$wancfg['wireless']['turbo']['enable'] = true;
1034
	} else if (isset($wancfg['wireless']['turbo']['enable']))
1035
		unset($wancfg['wireless']['turbo']['enable']);
1036
	$wancfg['wireless']['wep']['key'] = array();
1037
	for ($i = 1; $i <= 4; $i++) {
1038
		if ($_POST['key' . $i]) {
1039
			$newkey = array();
1040
			$newkey['value'] = $_POST['key' . $i];
1041
			if ($_POST['txkey'] == $i)
1042
				$newkey['txkey'] = true;
1043
			$wancfg['wireless']['wep']['key'][] = $newkey;
1044
		}
1045 5b237745 Scott Ullrich
	}
1046 8f0289e7 Erik Fonnesbeck
	interface_sync_wireless_clones($wancfg, true);
1047 5b237745 Scott Ullrich
}
1048 7f43ca88 Scott Ullrich
1049 597330aa Erik Fonnesbeck
function check_wireless_mode() {
1050 651fff4f Erik Fonnesbeck
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
1051 597330aa Erik Fonnesbeck
1052
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
1053
		return;
1054
1055
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
1056
		$clone_count = 1;
1057
	else
1058
		$clone_count = 0;
1059 6ef2297b Erik Fonnesbeck
	if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) {
1060 597330aa Erik Fonnesbeck
		foreach ($config['wireless']['clone'] as $clone) {
1061
			if ($clone['if'] == $wlanbaseif)
1062
				$clone_count++;
1063
		}
1064
	}
1065
	if ($clone_count > 1) {
1066
		$old_wireless_mode = $wancfg['wireless']['mode'];
1067
		$wancfg['wireless']['mode'] = $_POST['mode'];
1068
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
1069 4c807d76 Erik Fonnesbeck
			$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']]);
1070 597330aa Erik Fonnesbeck
		} else {
1071
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
1072
		}
1073
		$wancfg['wireless']['mode'] = $old_wireless_mode;
1074
	}
1075
}
1076
1077 509ca889 Evgeny Yurchenko
// Find all possible media options for the interface
1078
$mediaopts_list = array();
1079
$intrealname = $config['interfaces'][$if]['if'];
1080
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
1081
foreach ($mediaopts as $mediaopt){
1082
	preg_match("/media (.*)/", $mediaopt, $matches);
1083
 	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
1084
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
1085
 		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
1086
	}else{
1087
		// there is only media like "media 1000baseT"
1088
		array_push($mediaopts_list, $matches[1]);
1089
	}
1090
}
1091
1092 a6d9251e Scott Ullrich
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
1093 b32dd0a6 jim-p
$shortcut_section = "interfaces";
1094 af1e2031 jim-p
1095 58af5941 Scott Ullrich
$closehead = false;
1096 7f43ca88 Scott Ullrich
include("head.inc");
1097 3e662cb0 Ermal
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP"));
1098 feb88a14 smos
$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"));
1099 7f43ca88 Scott Ullrich
1100 5b237745 Scott Ullrich
?>
1101 7f43ca88 Scott Ullrich
1102 8098302a Scott Ullrich
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
1103 58af5941 Scott Ullrich
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
1104 8098302a Scott Ullrich
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
1105
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
1106 58af5941 Scott Ullrich
1107
<script type="text/javascript">
1108 9978e156 gnhb
	function updateType(t) {
1109 886f1f69 Scott Ullrich
		switch(t) {
1110 9978e156 gnhb
			case "none": {
1111 076b14b2 Vinicius Coque
				jQuery('#staticv4, #dhcp, #pppoe, #pptp, #ppp').hide();
1112 47593ac6 Seth Mos
				break;
1113
			}
1114
			case "staticv4": {
1115 076b14b2 Vinicius Coque
				jQuery('#none, #dhcp, #pppoe, #pptp, #ppp').hide();
1116 9978e156 gnhb
				break;
1117
			}
1118
			case "dhcp": {
1119 076b14b2 Vinicius Coque
				jQuery('#none, #staticv4, #pppoe, #pptp, #ppp').hide();
1120 6c05cfb0 gnhb
				break;
1121
			}
1122
			case "ppp": {
1123 076b14b2 Vinicius Coque
				jQuery('#none, #staticv4, #dhcp, #pptp, #pppoe').hide();
1124 3a906378 gnhb
				country_list();
1125 9978e156 gnhb
				break;
1126
			}
1127
			case "pppoe": {
1128 076b14b2 Vinicius Coque
				jQuery('#none, #staticv4, #dhcp, #pptp, #ppp').hide();
1129 9978e156 gnhb
				break;
1130
			}
1131 e4d40f41 gnhb
			case "l2tp":
1132 9978e156 gnhb
			case "pptp": {
1133 076b14b2 Vinicius Coque
				jQuery('#none, #staticv4, #dhcp, #pppoe, #ppp').hide();
1134
				jQuery('#pptp').show();
1135 9978e156 gnhb
				break;
1136 09583657 Scott Ullrich
			}
1137 886f1f69 Scott Ullrich
		}
1138 e4d40f41 gnhb
		if (t != "l2tp" && t != "pptp")
1139 076b14b2 Vinicius Coque
			jQuery('#'+t).show();
1140 09583657 Scott Ullrich
	}
1141 e029943a Seth Mos
	function updateTypeSix(t) {
1142
		switch(t) {
1143
			case "none": {
1144 feb88a14 smos
				jQuery('#staticv6, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1145 e029943a Seth Mos
				break;
1146
			}
1147
			case "staticv6": {
1148 feb88a14 smos
				jQuery('#none, #dhcp6, #6rd, #6to4, #track6, #slaac').hide();
1149
				break;
1150
			}
1151
			case "slaac": {
1152
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #dhcp6').hide();
1153 e029943a Seth Mos
				break;
1154
			}
1155
			case "dhcp6": {
1156 feb88a14 smos
				jQuery('#none, #staticv6, #6rd, #6to4, #track6, #slaac').hide();
1157 7d567088 smos
				break;
1158
			}
1159 adc91ab7 smos
			case "6rd": {
1160 feb88a14 smos
				jQuery('#none, #dhcp6, #staticv6, #6to4, #track6, #slaac').hide();
1161 31c43fd3 smos
				break;
1162
			}
1163
			case "6to4": {
1164 feb88a14 smos
				jQuery('#none, #dhcp6, #staticv6, #6rd, #track6, #slaac').hide();
1165 20a7cb15 smos
				break;
1166
			}
1167
			case "track6": {
1168 feb88a14 smos
				jQuery('#none, #dhcp6, #staticv6, #6rd, #6to4, #slaac').hide();
1169 e029943a Seth Mos
				break;
1170
			}
1171
		}
1172
		if (t != "l2tp" && t != "pptp")
1173 076b14b2 Vinicius Coque
			jQuery('#'+t).show();
1174 e029943a Seth Mos
	}
1175 32764288 Namezero
1176 886f1f69 Scott Ullrich
	function show_allcfg(obj) {
1177
		if (obj.checked)
1178 076b14b2 Vinicius Coque
			jQuery('#allcfg').show();
1179 886f1f69 Scott Ullrich
		else
1180 076b14b2 Vinicius Coque
			jQuery('#allcfg').hide();
1181 886f1f69 Scott Ullrich
	}
1182 9978e156 gnhb
1183 d85ba87f gnhb
	function show_reset_settings(reset_type) {
1184 c0948c6c Renato Botelho
		if (reset_type == 'preset') {
1185 076b14b2 Vinicius Coque
			jQuery('#pppoepresetwrap').show();
1186
			jQuery('#pppoecustomwrap').hide();
1187 c0948c6c Renato Botelho
		}
1188
		else if (reset_type == 'custom') {
1189 076b14b2 Vinicius Coque
			jQuery('#pppoecustomwrap').show();
1190
			jQuery('#pppoepresetwrap').hide();
1191 d85ba87f gnhb
		} else {
1192 076b14b2 Vinicius Coque
			jQuery('#pppoecustomwrap').hide();
1193
			jQuery('#pppoepresetwrap').hide();
1194 d85ba87f gnhb
		}
1195
	}
1196 886f1f69 Scott Ullrich
	function show_mon_config() {
1197 076b14b2 Vinicius Coque
		jQuery("#showmonbox").html('');
1198
		jQuery('#showmon').css('display','block');
1199 886f1f69 Scott Ullrich
	}
1200 4634cb48 Ermal Luçi
1201 886f1f69 Scott Ullrich
	function openwindow(url) {
1202
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1203 c0948c6c Renato Botelho
		if (oWin==null || typeof(oWin)=="undefined")
1204 886f1f69 Scott Ullrich
			return false;
1205 c0948c6c Renato Botelho
		else
1206 886f1f69 Scott Ullrich
			return true;
1207
	}
1208 3a906378 gnhb
	function country_list() {
1209 076b14b2 Vinicius Coque
		jQuery('#country').children().remove();
1210
		jQuery('#provider').children().remove();
1211
		jQuery('#providerplan').children().remove();
1212
		jQuery.ajax("getserviceproviders.php",{
1213
			success: function(response) {
1214
				var responseTextArr = response.split("\n");
1215 3a906378 gnhb
				responseTextArr.sort();
1216
				responseTextArr.each( function(value) {
1217
					var option = new Element('option');
1218
					country = value.split(":");
1219
					option.text = country[0];
1220
					option.value = country[1];
1221 076b14b2 Vinicius Coque
					jQuery('#country').append(option);
1222 3a906378 gnhb
				});
1223
			}
1224
		});
1225 076b14b2 Vinicius Coque
		jQuery('#trcountry').css('display',"table-row");
1226 3a906378 gnhb
	}
1227 c0948c6c Renato Botelho
1228 3a906378 gnhb
	function providers_list() {
1229 076b14b2 Vinicius Coque
		jQuery('#provider').children().remove();
1230
		jQuery('#providerplan').children().remove();
1231
		jQuery.ajax("getserviceproviders.php",{
1232
			type: 'post',
1233
			data: {country : jQuery('#country').val()},
1234
			success: function(response) {
1235
				var responseTextArr = response.split("\n");
1236 3a906378 gnhb
				responseTextArr.sort();
1237
				responseTextArr.each( function(value) {
1238
					var option = new Element('option');
1239
					option.text = value;
1240
					option.value = value;
1241 076b14b2 Vinicius Coque
					jQuery('#provider').append(option);
1242 3a906378 gnhb
				});
1243
			}
1244
		});
1245 076b14b2 Vinicius Coque
		jQuery('#trprovider').css("display","table-row");
1246
		jQuery('#trproviderplan').css("display","none");
1247 3a906378 gnhb
	}
1248 c0948c6c Renato Botelho
1249 3a906378 gnhb
	function providerplan_list() {
1250 076b14b2 Vinicius Coque
		jQuery('#providerplan').children().remove();
1251
		jQuery('#providerplan').append( new Element('option') );
1252
		jQuery.ajax("getserviceproviders.php",{
1253
			type: 'post',
1254
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val()},
1255
			success: function(response) {
1256
				var responseTextArr = response.split("\n");
1257 3a906378 gnhb
				responseTextArr.sort();
1258
				responseTextArr.each( function(value) {
1259
					if(value != "") {
1260
						providerplan = value.split(":");
1261 c0948c6c Renato Botelho
1262 3a906378 gnhb
						var option = new Element('option');
1263
						option.text = providerplan[0] + " - " + providerplan[1];
1264
						option.value = providerplan[1];
1265 076b14b2 Vinicius Coque
						jQuery('#providerplan').append(option);
1266 3a906378 gnhb
					}
1267
				});
1268
			}
1269
		});
1270 076b14b2 Vinicius Coque
		jQuery('#trproviderplan').css("display","table-row");
1271 3a906378 gnhb
	}
1272 c0948c6c Renato Botelho
1273 3a906378 gnhb
	function prefill_provider() {
1274 076b14b2 Vinicius Coque
		jQuery.ajax("getserviceproviders.php",{
1275
			type: 'post',
1276
			data: {country : jQuery('#country').val(), provider : jQuery('#provider').val(), plan : jQuery('#providerplan').val()},
1277
			success: function(data,textStatus,response) {
1278 3a906378 gnhb
				var xmldoc = response.responseXML;
1279
				var provider = xmldoc.getElementsByTagName('connection')[0];
1280 076b14b2 Vinicius Coque
				jQuery('#username').val('');
1281
				jQuery('#password').val('');
1282 3a906378 gnhb
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1283 076b14b2 Vinicius Coque
					jQuery('#phone').val('#777');
1284
					jQuery('#apn').val('');
1285 3a906378 gnhb
				} else {
1286 076b14b2 Vinicius Coque
					jQuery('#phone').val('*99#');
1287
					jQuery('#apn').val(provider.getElementsByTagName('apn')[0].firstChild.data);
1288 3a906378 gnhb
				}
1289 076b14b2 Vinicius Coque
				username = provider.getElementsByTagName('username')[0].firstChild.data;
1290
				password = provider.getElementsByTagName('password')[0].firstChild.data;
1291
				jQuery('#username').val(username);
1292
				jQuery('#password').val(password);
1293 3a906378 gnhb
			}
1294
		});
1295
	}
1296
1297 5b237745 Scott Ullrich
</script>
1298 58af5941 Scott Ullrich
</head>
1299 886f1f69 Scott Ullrich
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1300
	<?php include("fbegin.inc"); ?>
1301
	<form action="interfaces.php" method="post" name="iform" id="iform">
1302
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1303 a368a026 Ermal Lu?i
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1304 ea6be4a7 Erik Fonnesbeck
		<?php print_info_box_np(sprintf(gettext("The %s configuration has been changed."),$wancfg['descr'])."<p>".gettext("You must apply the changes in order for them to take effect.")."<p>".gettext("Don't forget to adjust the DHCP Server range if needed after applying."));?><br />
1305 744ea190 Scott Ullrich
		<?php endif; ?>
1306
		<?php if ($savemsg) print_info_box($savemsg); ?>
1307 98f43e13 Scott Ullrich
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
1308 09583657 Scott Ullrich
			<tr>
1309 30ade846 gnhb
				<td id="mainarea">
1310
					<div class="tabcont">
1311 09583657 Scott Ullrich
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1312
						<tr>
1313 136c598d Carlos Eduardo Ramos
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1314 09583657 Scott Ullrich
						</tr>
1315
						<tr>
1316 136c598d Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1317 30ade846 gnhb
							<td width="78%" class="vtable">
1318
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked"; ?> onClick="show_allcfg(this);">
1319 136c598d Carlos Eduardo Ramos
							<strong><?=gettext("Enable Interface"); ?></strong>
1320 09583657 Scott Ullrich
							</td>
1321
						</tr>
1322 30ade846 gnhb
					</table>
1323
					<div style="display:none;" name="allcfg" id="allcfg">
1324
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1325 09583657 Scott Ullrich
						<tr>
1326 136c598d Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1327 09583657 Scott Ullrich
							<td width="78%" class="vtable">
1328 30ade846 gnhb
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
1329 8cc6876f groo
								<br><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1330 30ade846 gnhb
							</td>
1331
						</tr>
1332
						<tr>
1333 e029943a Seth Mos
							<td valign="middle" class="vncell"><strong><?=gettext("IPv4 Configuration Type"); ?></strong></td>
1334 c0948c6c Renato Botelho
							<td class="vtable">
1335 20b49b17 Seth Mos
								<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
1336 c0948c6c Renato Botelho
								<?php
1337 e029943a Seth Mos
									foreach ($types4 as $key => $opt) {
1338 3a13f094 gnhb
										echo "<option onClick=\"updateType('{$key}');\"";
1339 c0948c6c Renato Botelho
										if ($key == $pconfig['type'])
1340 3a13f094 gnhb
											echo " selected";
1341
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1342
										echo "</option>";
1343 c0948c6c Renato Botelho
									}
1344 30ade846 gnhb
								?>
1345 667a3184 Scott Ullrich
								</select>
1346 30ade846 gnhb
							</td>
1347
						</tr>
1348 e029943a Seth Mos
						<tr>
1349
							<td valign="middle" class="vncell"><strong><?=gettext("IPv6 Configuration Type"); ?></strong></td>
1350
							<td class="vtable">
1351
								<select name="type6" onChange="updateTypeSix(this.value);" class="formselect" id="type6">
1352
								<?php
1353
									foreach ($types6 as $key => $opt) {
1354
										echo "<option onClick=\"updateTypeSix('{$key}');\"";
1355
										if ($key == $pconfig['type6'])
1356
											echo " selected";
1357
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1358
										echo "</option>";
1359
									}
1360
								?>
1361
								</select>
1362
							</td>
1363
						</tr>
1364 30ade846 gnhb
						<tr>
1365 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1366 30ade846 gnhb
							<td class="vtable">
1367
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
1368
								<?php
1369
									$ip = getenv('REMOTE_ADDR');
1370
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1371
									$mac = str_replace("\n","",$mac);
1372
									if($mac):
1373
								?>
1374 136c598d Carlos Eduardo Ramos
									<a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1375 30ade846 gnhb
								<?php endif; ?>
1376
								<br>
1377 136c598d Carlos Eduardo Ramos
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1378 cf371185 Chris Buechler
								"address of this interface"); ?><br>
1379 136c598d Carlos Eduardo Ramos
								<?=gettext("(may be required with some cable connections)"); ?><br>
1380
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1381
								"or leave blank"); ?>
1382 30ade846 gnhb
							</td>
1383
						</tr>
1384
						<tr>
1385 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1386 c0948c6c Renato Botelho
							<td class="vtable">
1387 30ade846 gnhb
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
1388
								<br>
1389 bd6f4dcc jim-p
								<?=gettext("If you leave this field blank, the adapter's default MTU will " .
1390 fcbf8a60 Chris Buechler
								"be used. This is typically 1500 bytes but can vary in some circumstances."); ?>
1391 4cea5cf8 Ermal
							</td>
1392
						</tr>
1393
						<tr>
1394
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1395 c0948c6c Renato Botelho
							<td class="vtable">
1396 4cea5cf8 Ermal
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>">
1397
								<br>
1398 136c598d Carlos Eduardo Ramos
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1399 c0948c6c Renato Botelho
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1400
								"header size) will be in effect."); ?>
1401 30ade846 gnhb
							</td>
1402
						</tr>
1403 509ca889 Evgeny Yurchenko
						<?php 
1404
						if (count($mediaopts_list) > 0){
1405
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1406
						echo "<tr>";
1407
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1408
							echo '<td class="vtable">';
1409 6e2a15e6 Evgeny Yurchenko
                                			echo '<div id="showadvmediabox"';
1410
								if ($mediaopt_from_config != 'autoselect ' && $mediaopt_from_config != ' ') echo " style='display:none'>";
1411
								else echo '>';
1412
								echo '<input type="button" onClick="show_advanced_media()" value="' . gettext("Advanced") . '"></input> - ' . gettext("Show advanced option");
1413
							echo "</div>";
1414
							echo '<div id="showmediaadv" ';
1415
							if ($mediaopt_from_config == 'autoselect ' || $mediaopt_from_config == ' ') echo "style='display:none'>";
1416
							else echo '>';
1417 509ca889 Evgeny Yurchenko
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1418 433e9842 jim-p
								print "<option value=\"\">Default (no preference, typically autoselect)</option>";
1419
								print "<option value=\"\">------- Media Supported by this interface -------</option>";
1420 509ca889 Evgeny Yurchenko
								foreach($mediaopts_list as $mediaopt){
1421
									if ($mediaopt != rtrim($mediaopt_from_config)){
1422
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1423
									} else {
1424
										print "<option value=\"$mediaopt\" selected>" . gettext("$mediaopt") . "</option>";
1425
									}
1426
								}
1427
								echo '</select><br>';
1428 433e9842 jim-p
								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.");
1429 6e2a15e6 Evgeny Yurchenko
						echo '</div>';
1430 509ca889 Evgeny Yurchenko
							echo '</td>';
1431
						echo '</tr>';
1432
						}
1433
						?>
1434 30ade846 gnhb
						<tr>
1435
							<td colspan="2" valign="top" height="16"></td>
1436 c0948c6c Renato Botelho
						</tr>
1437 30ade846 gnhb
						<tr style="display:none;" name="none" id="none">
1438
						</tr>
1439 47593ac6 Seth Mos
						<tr style="display:none;" name="staticv4" id="staticv4">
1440 30ade846 gnhb
							<td colspan="2" style="padding:0px;">
1441
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1442
									<tr>
1443 47593ac6 Seth Mos
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td>
1444 30ade846 gnhb
									</tr>
1445
									<tr>
1446 47593ac6 Seth Mos
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td>
1447 c0948c6c Renato Botelho
										<td width="78%" class="vtable">
1448 30ade846 gnhb
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
1449
											/
1450
											<select name="subnet" class="formselect" id="subnet">
1451
												<?php
1452
												for ($i = 32; $i > 0; $i--) {
1453
													if($i <> 31) {
1454
														echo "<option value=\"{$i}\" ";
1455
														if ($i == $pconfig['subnet']) echo "selected";
1456
														echo ">" . $i . "</option>";
1457
													}
1458
												}
1459
												?>
1460
											</select>
1461
										</td>
1462
									</tr>
1463
									<tr>
1464 6d3fd938 Seth Mos
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway"); ?></td>
1465 30ade846 gnhb
										<td width="78%" class="vtable">
1466
											<select name="gateway" class="formselect" id="gateway">
1467 136c598d Carlos Eduardo Ramos
												<option value="none" selected><?=gettext("None"); ?></option>
1468 9978e156 gnhb
													<?php
1469 30ade846 gnhb
													if(count($a_gateways) > 0) {
1470
														foreach ($a_gateways as $gateway) {
1471 47593ac6 Seth Mos
															if(($gateway['interface'] == $if)  && (is_ipaddrv4($gateway['gateway']))) {
1472 9978e156 gnhb
													?>
1473 30ade846 gnhb
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
1474
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1475
															</option>
1476
													<?php
1477
															}
1478
														}
1479
													}
1480
													?>
1481
											</select>
1482 6d3fd938 Seth Mos
											- or  <strong><a OnClick="show_add_gateway();" href="#"><?=gettext("add a new one."); ?></a></strong>
1483 30ade846 gnhb
											<br/>
1484
											<div id='addgwbox'>
1485 6d3fd938 Seth Mos
												<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add one using the link above"); ?>
1486 30ade846 gnhb
											</div>
1487
											<div id='notebox'>
1488
											</div>
1489
											<div id="status">
1490 c0948c6c Renato Botelho
											</div>
1491 30ade846 gnhb
											<div style="display:none" id="addgateway" name="addgateway">
1492 c0948c6c Renato Botelho
												<p>
1493 30ade846 gnhb
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1494 9978e156 gnhb
													<tr>
1495 30ade846 gnhb
														<td>
1496
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1497
																<tr><td>&nbsp;</td>
1498
																<tr>
1499 933ea015 Carlos Eduardo Ramos
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1500 30ade846 gnhb
																</tr>
1501
																<tr><td>&nbsp;</td>
1502
																<?php
1503
																if($if == "wan" || $if == "WAN")
1504
																	$checked = " CHECKED";
1505
																?>
1506
																<tr>
1507 933ea015 Carlos Eduardo Ramos
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
1508 c0948c6c Renato Botelho
																</tr>
1509 30ade846 gnhb
																<tr>
1510 933ea015 Carlos Eduardo Ramos
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td>
1511 30ade846 gnhb
																</tr>
1512
																<tr>
1513 47593ac6 Seth Mos
																	<td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></td><td><input id="gatewayip" name="gatewayip"></td>
1514 30ade846 gnhb
																</tr>
1515
																<tr>
1516 933ea015 Carlos Eduardo Ramos
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1517 30ade846 gnhb
																</tr>
1518
																<tr><td>&nbsp;</td>
1519
																<tr>
1520 7b8db0c3 Erik Fonnesbeck
																	<td>&nbsp;</td>
1521
																	<td>
1522 30ade846 gnhb
																		<center>
1523
																			<div id='savebuttondiv'>
1524 32764288 Namezero
1525 cb3c3fe4 Namezero
1526 c0948c6c Renato Botelho
																				<input id="gwsave" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave();'>
1527 136c598d Carlos Eduardo Ramos
																				<input id="gwcancel" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway();'>
1528 30ade846 gnhb
																			</div>
1529
																		</center>
1530
																	</td>
1531
																</tr>
1532 93ee6323 gnhb
																<tr><td>&nbsp;</td></tr>
1533 30ade846 gnhb
															</table>
1534 9978e156 gnhb
														</td>
1535
													</tr>
1536
												</table>
1537 30ade846 gnhb
												<p/>
1538
											</div>
1539
										</td>
1540
									</tr>
1541
								</table>
1542
							</td>
1543
						</tr>
1544 47593ac6 Seth Mos
						<tr style="display:none;" name="staticv6" id="staticv6">
1545
							<td colspan="2" style="padding:0px;">
1546
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1547 56f024e8 Scott Ullrich
									<tr>
1548
										<td colspan="2" valign="top">&nbsp;</td>
1549
									</tr>
1550 47593ac6 Seth Mos
									<tr>
1551
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td>
1552
									</tr>
1553
									<tr>
1554
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td>
1555
										<td width="78%" class="vtable">
1556 85e9cfee Phil Davis
											<input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="28" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>">
1557 47593ac6 Seth Mos
											/
1558 85e9cfee Phil Davis
											<select name="subnetv6" class="formselect" id="subnetv6">
1559 47593ac6 Seth Mos
												<?php
1560
												for ($i = 128; $i > 0; $i--) {
1561
													if($i <> 127) {
1562
														echo "<option value=\"{$i}\" ";
1563
														if ($i == $pconfig['subnetv6']) echo "selected";
1564
														echo ">" . $i . "</option>";
1565
													}
1566
												}
1567
												?>
1568
											</select>
1569
										</td>
1570
									</tr>
1571
									<tr>
1572 6d3fd938 Seth Mos
										<td width="22%" valign="top" class="vncell"><?=gettext("Gateway IPv6"); ?></td>
1573 47593ac6 Seth Mos
										<td width="78%" class="vtable">
1574
											<select name="gatewayv6" class="formselect" id="gatewayv6">
1575
												<option value="none" selected><?=gettext("None"); ?></option>
1576
													<?php
1577
													if(count($a_gateways) > 0) {
1578
														foreach ($a_gateways as $gateway) {
1579
															if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) {
1580
													?>
1581
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected"; ?>>
1582
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1583
															</option>
1584
													<?php
1585
															}
1586
														}
1587
													}
1588
													?>
1589
											</select>
1590 6d3fd938 Seth Mos
											- or <strong><a OnClick="show_add_gateway_v6();" href="#"><?=gettext("add a new one."); ?></a></strong>
1591 47593ac6 Seth Mos
											<br/>
1592 cfd40454 Seth Mos
											<div id='addgwboxv6'>
1593 6d3fd938 Seth Mos
											<?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the link above"); ?>
1594 47593ac6 Seth Mos
											</div>
1595 cfd40454 Seth Mos
											<div id='noteboxv6'>
1596 47593ac6 Seth Mos
											</div>
1597 cfd40454 Seth Mos
											<div id="statusv6">
1598 47593ac6 Seth Mos
											</div>
1599 cfd40454 Seth Mos
											<div style="display:none" id="addgatewayv6" name="addgatewayv6">
1600 47593ac6 Seth Mos
												<p>
1601
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1602
													<tr>
1603
														<td>
1604
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1605
																<tr><td>&nbsp;</td>
1606
																<tr>
1607
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td>
1608
																</tr>
1609
																<tr><td>&nbsp;</td>
1610
																<?php
1611
																if($if == "wan" || $if == "WAN")
1612
																	$checked = " CHECKED";
1613
																?>
1614
																<tr>
1615
																	<td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?>></td>
1616
																</tr>
1617
																<tr>
1618 cfd40454 Seth Mos
																	<td align="right"><font color="white"><?=gettext("Gateway Name IPv6:"); ?></td><td><input id="namev6" name="namev6" value="<?=$wancfg['descr'] . "GWv6"?>"></td>
1619 47593ac6 Seth Mos
																</tr>
1620
																<tr>
1621 cfd40454 Seth Mos
																	<td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></td><td><input id="gatewayipv6" name="gatewayipv6"></td>
1622 47593ac6 Seth Mos
																</tr>
1623
																<tr>
1624 cfd40454 Seth Mos
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescrv6" name="gatewaydescrv6"></td>
1625 47593ac6 Seth Mos
																</tr>
1626
																<tr><td>&nbsp;</td>
1627
																<tr>
1628
																	<td>&nbsp;</td>
1629
																	<td>
1630
																		<center>
1631 cfd40454 Seth Mos
																			<div id='savebuttondivv6'>
1632
																				<input id="gwsavev6" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave_v6();'>
1633
																				<input id="gwcancelv6" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway_v6();'>
1634 47593ac6 Seth Mos
																			</div>
1635
																		</center>
1636
																	</td>
1637
																</tr>
1638
																<tr><td>&nbsp;</td></tr>
1639
															</table>
1640
														</td>
1641
													</tr>
1642
												</table>
1643
												<p/>
1644
											</div>
1645
										</td>
1646
									</tr>
1647
								</table>
1648
							</td>
1649
						</tr>
1650 30ade846 gnhb
						<tr style="display:none;" name="dhcp" id="dhcp">
1651
							<td colspan="2" style="padding: 0px;">
1652
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1653
									<tr>
1654 a9543eae Seth Mos
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration"); ?></td>
1655 30ade846 gnhb
									</tr>
1656 e4d40f41 gnhb
									<!-- Uncomment to expose DHCP+ in GUI
1657
									<tr>
1658
										<td width="22%" valign="top" class="vncell"><?=gettext("Enable DHCP+"); ?></td>
1659
										<td width="78%" class="vtable">
1660
											<input name="dhcp_plus" type="checkbox" value="yes" <?php if ($pconfig['dhcp_plus'] == true) echo "checked"; ?> >
1661
										<strong><?=gettext("Enable DHCP+L2TP or DHCP+PPTP."); ?></strong>
1662
										<br/>
1663
										<?=gettext("Status changes on this interface will trigger reconfiguration (if necessary) of the associated PPTP/L2TP link."); ?>
1664
										</td>
1665
									</tr>
1666
									-->
1667 30ade846 gnhb
									<tr>
1668 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1669 30ade846 gnhb
										<td width="78%" class="vtable">
1670
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1671
											<br>
1672 136c598d Carlos Eduardo Ramos
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1673
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1674 933ea015 Carlos Eduardo Ramos
											"this (for client identification)."); ?>
1675 30ade846 gnhb
										</td>
1676
									</tr>
1677 ed395640 Seth Mos
									<tr>
1678
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IPv4 address"); ?></td>
1679
										<td width="78%" class="vtable">
1680
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
1681
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1682
												<?php
1683
												for ($i = 32; $i > 0; $i--) {
1684
													if($i <> 31) {
1685
														echo "<option value=\"{$i}\" ";
1686
														if ($i == $pconfig['alias-subnet']) echo "selected";
1687
														echo ">" . $i . "</option>";
1688
													}
1689
												}
1690
												?>
1691
											</select>
1692
											<?=gettext("The value in this field is used as a fixed alias IPv4 address by the " .
1693
											"DHCP client."); ?>
1694
										</td>
1695 bfab2419 smos
									</tr>
1696 e029943a Seth Mos
								</table>
1697
							</td>
1698
						</tr>
1699
						<tr style="display:none;" name="dhcp6" id="dhcp6">
1700
							<td colspan="2" style="padding: 0px;">
1701
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1702
									<tr>
1703
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration"); ?></td>
1704 ed395640 Seth Mos
									</tr>
1705 20a7cb15 smos
									<!--- Leave commented out for now
1706 a9543eae Seth Mos
									<tr>
1707
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
1708
										<td width="78%" class="vtable">
1709 ed395640 Seth Mos
											<input name="dhcp6-duid" type="text" class="formfld unknown" id="dhcp6-duid" size="40" value="<?=htmlspecialchars($pconfig['dhcp6-duid']);?>">
1710 a9543eae Seth Mos
											<br>
1711
											<?=gettext("The value in this field is sent as the DHCPv6 client identifier " .
1712 7149c4e7 Seth Mos
											"when requesting a DHCPv6 lease."); ?><br />
1713
											<?php	if(is_readable("/var/db/dhcp6c_duid")) {
1714 ed395640 Seth Mos
													// $current_duid = file_get_contents("/var/db/dhcp6c_duid");
1715 7149c4e7 Seth Mos
												}
1716 b1e4005f Vinicius Coque
												printf(gettext("The current DUID is: '%s'"),$current_duid);
1717 bfab2419 smos
												// hexdump -e '"%07.7_ax " 1/2 "%04x" " " 14/1 "%02x:" "\n"'
1718 7149c4e7 Seth Mos
											?>
1719
										</td>
1720
									</tr>
1721 20a7cb15 smos
									-->
1722 7149c4e7 Seth Mos
									<tr>
1723
										<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
1724
										<td width="78%" class="vtable">
1725 ed395640 Seth Mos
											<select name="dhcp6-ia-pd-len" class="formselect" id="dhcp6-ia-pd-len">
1726 7149c4e7 Seth Mos
												<?php
1727 ed395640 Seth Mos
												$sizes = array("none" => "None", 16 => "48", 12 => "52", 8 => "56", 4 => "60", 2 => "62", 1 => "63", 0 => "64");
1728 7149c4e7 Seth Mos
												foreach($sizes as $bits => $length) {
1729
													echo "<option value=\"{$bits}\" ";
1730 ed395640 Seth Mos
													if (is_numeric($pconfig['dhcp6-ia-pd-len']) && ($bits == $pconfig['dhcp6-ia-pd-len'])) echo "selected";
1731 7149c4e7 Seth Mos
													echo ">" . $length . "</option>";
1732
												}
1733
												?>
1734
											</select>
1735
											<br>
1736 ed395640 Seth Mos
											<?=gettext("The value in this field is the delegated prefix length provided by the DHCPv6 server. Normally specified by the ISP."); ?>
1737 30ade846 gnhb
										</td>
1738
									</tr>
1739 47593ac6 Seth Mos
								</table>
1740
							</td>
1741
						</tr>
1742 adc91ab7 smos
						<tr style="display:none;" name="6rd" id="6rd">
1743 7d567088 smos
							<td colspan="2" style="padding: 0px;">
1744
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1745
									<tr>
1746
										<td colspan="2" valign="top" class="listtopic"><?=gettext("6RD Rapid Deployment"); ?></td>
1747
									</tr>
1748
									<tr>
1749
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD prefix"); ?></td>
1750
										<td width="78%" class="vtable">
1751
											<input name="prefix-6rd" type="text" class="formfld unknown" id="prefix-6rd" size="40" value="<?=htmlspecialchars($pconfig['prefix-6rd']);?>">
1752
											<br>
1753 32dc8109 smos
											<?=gettext("The value in this field is the 6RD IPv6 prefix assigned by your ISP. e.g. '2001:db8::/32'") ?><br />
1754 7d567088 smos
										</td>
1755
									</tr>
1756
									<tr>
1757 12215bfb smos
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD Border Relay"); ?></td>
1758 7d567088 smos
										<td width="78%" class="vtable">
1759
											<input name="gateway-6rd" type="text" class="formfld unknown" id="gateway-6rd" size="40" value="<?=htmlspecialchars($pconfig['gateway-6rd']);?>">
1760
											<br>
1761 32dc8109 smos
											<?=gettext("The value in this field is 6RD IPv4 gateway address assigned by your ISP") ?><br />
1762 7d567088 smos
										</td>
1763
									</tr>
1764
									<tr>
1765 12215bfb smos
										<td width="22%" valign="top" class="vncell"><?=gettext("6RD IPv4 Prefix length"); ?></td>
1766 7d567088 smos
										<td width="78%" class="vtable">
1767 12215bfb smos
											<select name="prefix-6rd-v4plen" class="formselect" id="prefix-6rd-v4plen">
1768 7d567088 smos
												<?php
1769 12215bfb smos
												for ($i = 0; $i < 32; $i++) {
1770
													echo "<option value=\"{$i}\" ";
1771
													if (is_numeric($pconfig['prefix-6rd-v4plen']) && ($i == $pconfig['prefix-6rd-v4plen'])) echo "selected";
1772
													echo ">" . $i . " bits</option>";
1773 7d567088 smos
												}
1774
												?>
1775
											</select>
1776
											<br>
1777 12215bfb smos
											<?=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."); ?>
1778 7d567088 smos
										</td>
1779
									</tr>
1780
								</table>
1781
							</td>
1782
						</tr>
1783 20a7cb15 smos
						<tr style="display:none;" name="track6" id="track6">
1784
							<td colspan="2" style="padding: 0px;">
1785
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1786
									<tr>
1787
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
1788
									</tr>
1789
									<tr>
1790
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
1791
										<td width="78%" class="vtable">
1792
										<select name='track6-interface' class='formselect' >
1793
										<?php 
1794
											$interfaces = get_configured_interface_with_descr(false, true);
1795
											$dynv6ifs = array();
1796
											foreach ($interfaces as $iface => $ifacename) {
1797
												switch($config['interfaces'][$iface]['ipaddrv6']) {
1798
													case "6to4":
1799
													case "6rd":
1800
													case "dhcp6":
1801
														$dynv6ifs[$iface] = $ifacename;
1802
														break;
1803
													default:
1804
														continue;
1805
												}
1806
											}
1807
											foreach($dynv6ifs as $iface => $ifacename) {
1808
												echo "<option value=\"{$iface}\"";
1809
												if ($iface == $pconfig['track6-interface'])
1810
													echo " selected";
1811
												echo ">" . htmlspecialchars($ifacename) . "</option>";
1812
											}
1813
										  ?>
1814
										</select> <br>
1815
											<br>
1816
											<?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
1817
										</td>
1818
									</tr>
1819
									<tr>
1820
										<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
1821
										<td width="78%" class="vtable">
1822 6b2d4b5a Darren Embry
											<?php
1823
												if ($pconfig['track6-prefix-id'] == "none" || $pconfig['track6-prefix-id'] == "") {
1824
													$track6_prefix_id_hex = "";
1825
												} else {
1826
													$track6_prefix_id_hex = sprintf("%x", $pconfig['track6-prefix-id']);
1827 20a7cb15 smos
												}
1828 6b2d4b5a Darren Embry
											?>
1829
											<input name="track6-prefix-id--hex" type="text" class="formfld unknown" id="track6-prefix-id--hex" size="8" value="<?= $track6_prefix_id_hex ?>" />
1830
											<br />
1831
											<?= gettext("The value in this field is the (Delegated) IPv6 prefix id. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
1832
											<br />
1833
											<?= sprintf(gettext("Enter a <b>hexadecimal</b> value between %x and %x here, or leave blank."), 0, $ipv6_num_prefix_ids - 1); ?>
1834 20a7cb15 smos
										</td>
1835
									</tr>
1836
										</td>
1837
									</tr>
1838
								</table>
1839
							</td>
1840
						</tr>
1841 6c05cfb0 gnhb
						<tr style="display:none;" name="ppp" id="ppp">
1842
							<td colspan="2" style="padding: 0px;">
1843
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1844
									<tr>
1845 136c598d Carlos Eduardo Ramos
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
1846 6c05cfb0 gnhb
									</tr>
1847 3a906378 gnhb
									<tr name="ppp_provider" id="ppp_provider">
1848 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
1849 3a906378 gnhb
										<td width="78%" class="vtable">
1850
											<table border="0" cellpadding="0" cellspacing="0">
1851
												<tr id="trcountry">
1852 933ea015 Carlos Eduardo Ramos
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
1853 3a906378 gnhb
													<td>
1854
														<select class="formselect" name="country" id="country" onChange="providers_list()">
1855
															<option></option>
1856
														</select>
1857
													</td>
1858
												</tr>
1859
												<tr id="trprovider" style="display:none">
1860 933ea015 Carlos Eduardo Ramos
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
1861 3a906378 gnhb
													<td>
1862
														<select class="formselect" name="provider" id="provider" onChange="providerplan_list()">
1863
															<option></option>
1864
														</select>
1865
													</td>
1866
												</tr>
1867
												<tr id="trproviderplan" style="display:none">
1868 933ea015 Carlos Eduardo Ramos
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
1869 3a906378 gnhb
													<td>
1870
														<select class="formselect" name="providerplan" id="providerplan" onChange="prefill_provider()">
1871
															<option></option>
1872
														</select>
1873
													</td>
1874
												</tr>
1875
											</table>
1876 136c598d Carlos Eduardo Ramos
											<br/><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
1877 3a906378 gnhb
										</td>
1878
									</tr>
1879 6c05cfb0 gnhb
									<tr>
1880 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
1881 3a906378 gnhb
										<td width="78%" class="vtable">
1882
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
1883
										</td>
1884
									</tr>
1885
									<tr>
1886 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
1887 3a906378 gnhb
										<td width="78%" class="vtable">
1888
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
1889
										</td>
1890
									</tr>
1891
									<tr name="phone_num" id="phone_num">
1892 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
1893 3a906378 gnhb
										<td width="78%" class="vtable">
1894
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>">
1895
										</td>
1896
									</tr>
1897
									<tr name="apn_" id="apn_">
1898 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
1899 3a906378 gnhb
										<td width="78%" class="vtable">
1900
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
1901
										</td>
1902
									</tr>
1903
									<tr name="interface" id="interface" >
1904 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
1905 3a906378 gnhb
										<td width="78%" class="vtable">
1906
											<select name="port" id="port" class="formselect">
1907
											<?php
1908
												$portlist = glob("/dev/cua*");
1909
												$modems = glob("/dev/modem*");
1910
												$portlist = array_merge($portlist, $modems);
1911
												foreach ($portlist as $port) {
1912
													if(preg_match("/\.(lock|init)$/", $port))
1913
														continue;
1914
													echo "<option value=\"".trim($port)."\"";
1915
													if ($pconfig['port'] == $port)
1916
														echo "selected";
1917
													echo ">{$port}</option>";
1918
												}?>
1919
											</select>
1920
										</td>
1921
									</tr>
1922 136c598d Carlos Eduardo Ramos
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
1923 6c05cfb0 gnhb
										<?php if (isset($pconfig['pppid'])): ?>
1924
											<td width="78%" class="vtable">
1925 933ea015 Carlos Eduardo Ramos
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
1926
											<?=gettext("to edit PPP configuration."); ?>
1927 6c05cfb0 gnhb
											</td>
1928 ee9933b6 Renato Botelho
										<?php else: ?>
1929 6c05cfb0 gnhb
											<td width="78%" class="vtable">
1930 933ea015 Carlos Eduardo Ramos
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
1931
											<?=gettext("to create a PPP configuration."); ?>
1932 6c05cfb0 gnhb
											</td>
1933 c0948c6c Renato Botelho
										<?php endif; ?>
1934 6c05cfb0 gnhb
									</tr>
1935
								</table>
1936
							</td>
1937
						</tr>
1938 30ade846 gnhb
						<tr style="display:none;" name="pppoe" id="pppoe">
1939
							<td colspan="2" style="padding:0px;">
1940
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1941
									<tr>
1942 136c598d Carlos Eduardo Ramos
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
1943 30ade846 gnhb
									</tr>
1944
									<tr>
1945 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
1946 30ade846 gnhb
										<td width="78%" class="vtable">
1947
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
1948
										</td>
1949
									</tr>
1950
									<tr>
1951 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
1952 30ade846 gnhb
										<td width="78%" class="vtable">
1953
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
1954
										</td>
1955
									</tr>
1956
									<tr>
1957 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
1958 30ade846 gnhb
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
1959 136c598d Carlos Eduardo Ramos
											<br> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
1960 30ade846 gnhb
										</td>
1961
									</tr>
1962
									<tr>
1963 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
1964 30ade846 gnhb
										<td width="78%" class="vtable">
1965
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>>
1966 136c598d Carlos Eduardo Ramos
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
1967 933ea015 Carlos Eduardo Ramos
											<?=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."); ?>
1968 30ade846 gnhb
										</td>
1969
									</tr>
1970
									<tr>
1971 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
1972 30ade846 gnhb
										<td width="78%" class="vtable">
1973 933ea015 Carlos Eduardo Ramos
											<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."); ?>
1974 30ade846 gnhb
										</td>
1975
									</tr>
1976
									<tr>
1977
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
1978
										<td width="78%" class="vtable">
1979
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
1980
												<tr>
1981
													<td align="left" valign="top">
1982
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
1983
														<select valign="top" id="reset_type" name="pppoe-reset-type" class="formselect" onChange="show_reset_settings(this.value);">
1984 136c598d Carlos Eduardo Ramos
															<option value = ""><?=gettext("Disabled"); ?></option>
1985
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?=gettext("Custom"); ?></option>
1986
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?=gettext("Pre-Set"); ?></option>
1987
														</select> <?=gettext("Select a reset timing type"); ?>
1988 30ade846 gnhb
														</p>
1989
														<?php if ($pconfig['pppoe_pr_custom']): ?>
1990
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
1991
														<?php else: ?>
1992
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
1993
														<?php endif; ?>
1994 c0948c6c Renato Botelho
														<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" />
1995 136c598d Carlos Eduardo Ramos
														<?=gettext("hour (0-23)"); ?><br />
1996 c0948c6c Renato Botelho
														<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" />
1997 136c598d Carlos Eduardo Ramos
														<?=gettext("minute (0-59)"); ?><br />
1998 c0948c6c Renato Botelho
														<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']);?>" />
1999 136c598d Carlos Eduardo Ramos
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
2000 30ade846 gnhb
														<br />&nbsp;<br />
2001 933ea015 Carlos Eduardo Ramos
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
2002 136c598d Carlos Eduardo Ramos
														<?=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."); ?>
2003 30ade846 gnhb
														</p>
2004
														<?php if ($pconfig['pppoe_pr_preset']): ?>
2005
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
2006
														<?php else: ?>
2007
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
2008
														<?php endif; ?>
2009 c0948c6c Renato Botelho
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
2010 136c598d Carlos Eduardo Ramos
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
2011 30ade846 gnhb
														<br />
2012 c0948c6c Renato Botelho
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
2013 136c598d Carlos Eduardo Ramos
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
2014 30ade846 gnhb
														<br />
2015 c0948c6c Renato Botelho
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
2016 136c598d Carlos Eduardo Ramos
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
2017 30ade846 gnhb
														<br />
2018 c0948c6c Renato Botelho
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
2019 136c598d Carlos Eduardo Ramos
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
2020 30ade846 gnhb
														</p>
2021
													</td>
2022
												</tr>
2023
											</table>
2024
										</td>
2025
									</tr>
2026 c0948c6c Renato Botelho
2027 30ade846 gnhb
									<tr>
2028 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
2029 30ade846 gnhb
										<?php if (isset($pconfig['pppid'])): ?>
2030 09637075 gnhb
											<td width="78%" class="vtable">
2031 c0948c6c Renato Botelho
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
2032 933ea015 Carlos Eduardo Ramos
											<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
2033 9978e156 gnhb
											</td>
2034 ee9933b6 Renato Botelho
										<?php else: ?>
2035 09637075 gnhb
											<td width="78%" class="vtable">
2036 136c598d Carlos Eduardo Ramos
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
2037 933ea015 Carlos Eduardo Ramos
											<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
2038 30ade846 gnhb
											</td>
2039 c0948c6c Renato Botelho
										<?php endif; ?>
2040 30ade846 gnhb
									</tr>
2041
								</table>
2042 87f0be87 Chris Buechler
							</td>
2043 667a3184 Scott Ullrich
						</tr>
2044 30ade846 gnhb
						<tr style="display:none;" name="pptp" id="pptp">
2045
							<td colspan="2" style="padding:0px;">
2046
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
2047
									<tr>
2048 e4d40f41 gnhb
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP/L2TP configuration"); ?></td>
2049 30ade846 gnhb
									</tr>
2050
									<tr>
2051 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
2052 30ade846 gnhb
										<td width="78%" class="vtable">
2053
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
2054
										</td>
2055
									</tr>
2056
									<tr>
2057 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
2058 30ade846 gnhb
										<td width="78%" class="vtable">
2059 4a1ee8ac gnhb
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
2060 30ade846 gnhb
										</td>
2061
									</tr>
2062
									<tr>
2063 136c598d Carlos Eduardo Ramos
										<td width="22%" width="100" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
2064 c0948c6c Renato Botelho
										<td width="78%" class="vtable">
2065 4a1ee8ac gnhb
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>">
2066 30ade846 gnhb
											/
2067
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
2068
												<?php for ($i = 31; $i > 0; $i--): ?>
2069 4a1ee8ac gnhb
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected"; ?>>
2070 30ade846 gnhb
														<?=$i;?></option>
2071
												<?php endfor; ?>
2072
											</select>
2073
										</td>
2074
									</tr>
2075
									<tr>
2076 136c598d Carlos Eduardo Ramos
										<td width="22%" width="100" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
2077 30ade846 gnhb
										<td width="78%" class="vtable">
2078 4a1ee8ac gnhb
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>">
2079 30ade846 gnhb
										</td>
2080
									</tr>
2081
									<tr>
2082 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
2083 30ade846 gnhb
										<td width="78%" class="vtable">
2084
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?>>
2085 136c598d Carlos Eduardo Ramos
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
2086 933ea015 Carlos Eduardo Ramos
											<?=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."); ?>
2087 30ade846 gnhb
										</td>
2088
									</tr>
2089
									<tr>
2090 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
2091 30ade846 gnhb
										<td width="78%" class="vtable">
2092 933ea015 Carlos Eduardo Ramos
											<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."); ?>
2093 30ade846 gnhb
										</td>
2094
									</tr>
2095 4a1ee8ac gnhb
									<tr>
2096 136c598d Carlos Eduardo Ramos
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
2097 4a1ee8ac gnhb
										<?php if (isset($pconfig['pppid'])): ?>
2098
											<td width="78%" class="vtable">
2099 c0948c6c Renato Botelho
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
2100 933ea015 Carlos Eduardo Ramos
											<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
2101 4a1ee8ac gnhb
											</td>
2102 ee9933b6 Renato Botelho
										<?php else: ?>
2103 4a1ee8ac gnhb
											<td width="78%" class="vtable">
2104 4256d115 Renato Botelho
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
2105
											<?=gettext("for advanced PPTP and L2TP configuration options");?>.
2106 4a1ee8ac gnhb
											</td>
2107 c0948c6c Renato Botelho
										<?php endif; ?>
2108 4a1ee8ac gnhb
									</tr>
2109 30ade846 gnhb
								</table>
2110
							</td>
2111
						</tr>
2112
						<?php
2113
							/* Wireless interface? */
2114
							if (isset($wancfg['wireless'])):
2115
						?>
2116
						<tr>
2117
							<td colspan="2" valign="top" height="16"></td>
2118 c0948c6c Renato Botelho
						</tr>
2119 9978e156 gnhb
						<tr>
2120 136c598d Carlos Eduardo Ramos
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
2121 9978e156 gnhb
						</tr>
2122 f62c44d8 Erik Fonnesbeck
						<tr>
2123 4256d115 Renato Botelho
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
2124 f62c44d8 Erik Fonnesbeck
							<td class="vtable">
2125 ee9933b6 Renato Botelho
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked";?>>
2126 933ea015 Carlos Eduardo Ramos
								<br/><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
2127 f62c44d8 Erik Fonnesbeck
							</td>
2128
						</tr>
2129 9978e156 gnhb
						<tr>
2130 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
2131 30ade846 gnhb
							<td class="vtable">
2132 3a13f094 gnhb
							<select name="standard" class="formselect" id="standard">
2133
								<?php
2134
								foreach($wl_modes as $wl_standard => $wl_channels) {
2135
									echo "<option ";
2136
									if ($pconfig['standard'] == "$wl_standard")
2137
										echo "selected ";
2138
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
2139
								}
2140
								?>
2141
							</select>
2142 30ade846 gnhb
							</td>
2143
						</tr>
2144
						<?php if (isset($wl_modes['11g'])): ?>
2145
						<tr>
2146 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
2147 30ade846 gnhb
							<td class="vtable">
2148
								<select name="protmode" class="formselect" id="protmode">
2149 ee9933b6 Renato Botelho
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected";?> value="off"><?=gettext("Protection mode off"); ?></option>
2150
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
2151
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
2152 30ade846 gnhb
								</select>
2153
								<br/>
2154 933ea015 Carlos Eduardo Ramos
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
2155 30ade846 gnhb
								<br/>
2156
							</td>
2157
						</tr>
2158
						<?php else: ?>
2159
						<input name="protmode" type="hidden" id="protmode" value="off">
2160
						<?php endif; ?>
2161
						<tr>
2162 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
2163 30ade846 gnhb
							<td class="vtable">
2164
								<select name="txpower" class="formselect" id="txpower">
2165
									<?
2166
									for($x = 99; $x > 0; $x--) {
2167
										if($pconfig["txpower"] == $x)
2168
											$SELECTED = " SELECTED";
2169
										else
2170
											$SELECTED = "";
2171
										echo "<option {$SELECTED}>{$x}</option>\n";
2172
									}
2173
									?>
2174
								</select><br/>
2175 3b7f0f53 Erik Fonnesbeck
								<?=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."); ?>
2176 9978e156 gnhb
							</td>
2177
						</tr>
2178
						<tr>
2179 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncellreq"><?=gettext("Channel"); ?></td>
2180 30ade846 gnhb
							<td class="vtable">
2181
								<select name="channel" class="formselect" id="channel">
2182 ee9933b6 Renato Botelho
									<option <?php if ($pconfig['channel'] == 0) echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2183 9978e156 gnhb
									<?php
2184 30ade846 gnhb
									foreach($wl_modes as $wl_standard => $wl_channels) {
2185
										if($wl_standard == "11g") { $wl_standard = "11b/g"; }
2186
										else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
2187
										else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
2188
										foreach($wl_channels as $wl_channel) {
2189
											echo "<option ";
2190
											if ($pconfig['channel'] == "$wl_channel") {
2191
												echo "selected ";
2192
											}
2193
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
2194
											if(isset($wl_chaninfo[$wl_channel]))
2195
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
2196
											echo "</option>\n";
2197 d85ba87f gnhb
										}
2198 9978e156 gnhb
									}
2199
									?>
2200
								</select>
2201 30ade846 gnhb
								<br/>
2202 136c598d Carlos Eduardo Ramos
								<?=gettext("Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)"); ?>
2203 30ade846 gnhb
								<br/>
2204 933ea015 Carlos Eduardo Ramos
								<?=gettext("Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above."); ?>
2205 9978e156 gnhb
							</td>
2206
						</tr>
2207 537bf7b3 Erik Fonnesbeck
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2208
						<tr>
2209
							<td valign="top" class="vncell"><?=gettext("Antenna settings"); ?></td>
2210
							<td class="vtable">
2211
								<table border="0" cellpadding="0" cellspacing="0">
2212
									<tr>
2213
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])): ?>
2214
										<td>
2215
											<?=gettext("Diversity"); ?><br/>
2216
											<select name="diversity" class="formselect" id="diversity">
2217 1930ccb6 Erik Fonnesbeck
												<option <?php if (!isset($pconfig['diversity'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2218
												<option <?php if ($pconfig['diversity'] === '0') echo "selected"; ?> value="0"><?=gettext("Off"); ?></option>
2219
												<option <?php if ($pconfig['diversity'] === '1') echo "selected"; ?> value="1"><?=gettext("On"); ?></option>
2220 537bf7b3 Erik Fonnesbeck
											</select>
2221
										</td>
2222
										<td>&nbsp;&nbsp</td>
2223
										<?php endif; ?>
2224
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])): ?>
2225
										<td>
2226
											<?=gettext("Transmit antenna"); ?><br/>
2227
											<select name="txantenna" class="formselect" id="txantenna">
2228 1930ccb6 Erik Fonnesbeck
												<option <?php if (!isset($pconfig['txantenna'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2229
												<option <?php if ($pconfig['txantenna'] === '0') echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2230
												<option <?php if ($pconfig['txantenna'] === '1') echo "selected"; ?> value="1"><?=gettext("#1"); ?></option>
2231
												<option <?php if ($pconfig['txantenna'] === '2') echo "selected"; ?> value="2"><?=gettext("#2"); ?></option>
2232 537bf7b3 Erik Fonnesbeck
											</select>
2233
										</td>
2234
										<td>&nbsp;&nbsp</td>
2235
										<?php endif; ?>
2236
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
2237
										<td>
2238
											<?=gettext("Receive antenna"); ?><br/>
2239
											<select name="rxantenna" class="formselect" id="rxantenna">
2240 1930ccb6 Erik Fonnesbeck
												<option <?php if (!isset($pconfig['rxantenna'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2241
												<option <?php if ($pconfig['rxantenna'] === '0') echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
2242
												<option <?php if ($pconfig['rxantenna'] === '1') echo "selected"; ?> value="1"><?=gettext("#1"); ?></option>
2243
												<option <?php if ($pconfig['rxantenna'] === '2') echo "selected"; ?> value="2"><?=gettext("#2"); ?></option>
2244 537bf7b3 Erik Fonnesbeck
											</select>
2245
										</td>
2246
										<?php endif; ?>
2247
									</tr>
2248
								</table>
2249
								<br/>
2250
								<?=gettext("Note: The antenna numbers do not always match up with the labels on the card."); ?>
2251
							</td>
2252
						</tr>
2253
						<?php endif; ?>
2254 6681fdd3 Erik Fonnesbeck
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])): ?>
2255 9978e156 gnhb
						<tr>
2256 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Distance setting"); ?></td>
2257 30ade846 gnhb
							<td class="vtable">
2258
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>">
2259
								<br/>
2260 136c598d Carlos Eduardo Ramos
								<?=gettext("Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client"); ?><br/>
2261
								<?=gettext("(measured in Meters and works only for Atheros based cards !)"); ?>
2262 30ade846 gnhb
							</td>
2263 9978e156 gnhb
						</tr>
2264 6681fdd3 Erik Fonnesbeck
						<?php endif; ?>
2265 9978e156 gnhb
						<tr>
2266 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Regulatory settings"); ?></td>
2267 30ade846 gnhb
							<td class="vtable">
2268 136c598d Carlos Eduardo Ramos
								<?=gettext("Regulatory domain"); ?><br/>
2269 30ade846 gnhb
								<select name="regdomain" class="formselect" id="regdomain">
2270 ee9933b6 Renato Botelho
									<option <?php if (empty($pconfig['regdomain'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2271 30ade846 gnhb
									<?php
2272
									foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
2273
										echo "<option ";
2274
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
2275
											echo "selected ";
2276
										}
2277
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
2278
									}
2279
									?>
2280
								</select>
2281
								<br/>
2282 933ea015 Carlos Eduardo Ramos
								<?=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."); ?>
2283 30ade846 gnhb
								<br/><br/>
2284 136c598d Carlos Eduardo Ramos
								<?=gettext("Country (listed with country code and regulatory domain)"); ?><br/>
2285 30ade846 gnhb
								<select name="regcountry" class="formselect" id="regcountry">
2286 ee9933b6 Renato Botelho
									<option <?php if (empty($pconfig['regcountry'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2287 30ade846 gnhb
									<?php
2288
									foreach($wl_countries as $wl_country_key => $wl_country) {
2289
										echo "<option ";
2290
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
2291
											echo "selected ";
2292
										}
2293
										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";
2294
									}
2295
									?>
2296
								</select>
2297
								<br/>
2298 136c598d Carlos Eduardo Ramos
								<?=gettext("Note: Any country setting other than \"Default\" will override the regulatory domain setting"); ?>.
2299 30ade846 gnhb
								<br/><br/>
2300 136c598d Carlos Eduardo Ramos
								<?=gettext("Location"); ?><br/>
2301 30ade846 gnhb
								<select name="reglocation" class="formselect" id="reglocation">
2302 ee9933b6 Renato Botelho
									<option <?php if (empty($pconfig['reglocation'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
2303
									<option <?php if ($pconfig['reglocation'] == 'indoor') echo "selected"; ?> value="indoor"><?=gettext("Indoor"); ?></option>
2304
									<option <?php if ($pconfig['reglocation'] == 'outdoor') echo "selected"; ?> value="outdoor"><?=gettext("Outdoor"); ?></option>
2305
									<option <?php if ($pconfig['reglocation'] == 'anywhere') echo "selected"; ?> value="anywhere"><?=gettext("Anywhere"); ?></option>
2306 30ade846 gnhb
								</select>
2307
								<br/><br/>
2308 933ea015 Carlos Eduardo Ramos
								<?=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."); ?>
2309 30ade846 gnhb
								<br/>
2310 933ea015 Carlos Eduardo Ramos
								<?=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."); ?>
2311 9978e156 gnhb
							</td>
2312
						</tr>
2313
						<tr>
2314 30ade846 gnhb
							<td colspan="2" valign="top" height="16"></td>
2315 c0948c6c Renato Botelho
						</tr>
2316 30ade846 gnhb
						<tr>
2317 4256d115 Renato Botelho
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Network-specific wireless configuration");?></td>
2318 30ade846 gnhb
						</tr>
2319
						<tr>
2320 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncellreq"><?=gettext("Mode"); ?></td>
2321 30ade846 gnhb
							<td class="vtable">
2322
								<select name="mode" class="formselect" id="mode">
2323 ee9933b6 Renato Botelho
									<option <?php if ($pconfig['mode'] == 'bss') echo "selected";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
2324
									<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
2325
									<option <?php if ($pconfig['mode'] == 'hostap') echo "selected";?> value="hostap"><?=gettext("Access Point"); ?></option>
2326 30ade846 gnhb
								</select>
2327 9978e156 gnhb
							</td>
2328
						</tr>
2329
						<tr>
2330 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncellreq"><?=gettext("SSID"); ?></td>
2331 30ade846 gnhb
							<td class="vtable">
2332
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>">
2333 cb3c3fe4 Namezero
								<br/>
2334
								<?=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"); ?>
2335 9978e156 gnhb
							</td>
2336
						</tr>
2337 30ade846 gnhb
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
2338 9978e156 gnhb
						<tr>
2339 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Minimum wireless standard"); ?></td>
2340 30ade846 gnhb
							<td class="vtable">
2341
								<select name="puremode" class="formselect" id="puremode">
2342 ee9933b6 Renato Botelho
									<option <?php if ($pconfig['puremode'] == 'any') echo "selected";?> value="any"><?=gettext("Any"); ?></option>
2343 30ade846 gnhb
									<?php if (isset($wl_modes['11g'])): ?>
2344 ee9933b6 Renato Botelho
									<option <?php if ($pconfig['puremode'] == '11g') echo "selected";?> value="11g"><?=gettext("802.11g"); ?></option>
2345 30ade846 gnhb
									<?php endif; ?>
2346 ee9933b6 Renato Botelho
									<option <?php if ($pconfig['puremode'] == '11n') echo "selected";?> value="11n"><?=gettext("802.11n"); ?></option>
2347 30ade846 gnhb
								</select>
2348
								<br/>
2349 933ea015 Carlos Eduardo Ramos
								<?=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)."); ?>
2350 9978e156 gnhb
							</td>
2351
						</tr>
2352 30ade846 gnhb
						<?php elseif (isset($wl_modes['11g'])): ?>
2353 9978e156 gnhb
						<tr>
2354 933ea015 Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("802.11g only"); ?></td>
2355 30ade846 gnhb
							<td class="vtable">
2356 ee9933b6 Renato Botelho
								<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <?php if ($pconfig['puremode'] == '11g') echo "checked";?>>
2357 933ea015 Carlos Eduardo Ramos
								<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)."); ?>
2358 9978e156 gnhb
							</td>
2359
						</tr>
2360 30ade846 gnhb
						<?php endif; ?>
2361 9978e156 gnhb
						<tr>
2362 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Allow intra-BSS communication"); ?></td>
2363 30ade846 gnhb
							<td class="vtable">
2364 ee9933b6 Renato Botelho
								<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <?php if ($pconfig['apbridge_enable']) echo "checked";?>>
2365 30ade846 gnhb
								<br/>
2366 933ea015 Carlos Eduardo Ramos
								<?=gettext("When operating as an access point, enable this if you want to pass packets between wireless clients directly."); ?>
2367 30ade846 gnhb
								<br/>
2368 933ea015 Carlos Eduardo Ramos
								<?=gettext("Disabling the internal bridging is useful when traffic is to be processed with packet filtering."); ?>
2369 30ade846 gnhb
							</td>
2370
						</tr>
2371
						<tr>
2372 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Enable WME"); ?></td>
2373 30ade846 gnhb
							<td class="vtable">
2374 ee9933b6 Renato Botelho
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <?php if ($pconfig['wme_enable']) echo "checked";?>>
2375 933ea015 Carlos Eduardo Ramos
								<br/><?=gettext("Setting this option will force the card to use WME (wireless QoS)."); ?>
2376 30ade846 gnhb
							</td>
2377
						</tr>
2378
						<tr>
2379 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Enable Hide SSID"); ?></td>
2380 30ade846 gnhb
							<td class="vtable">
2381 ee9933b6 Renato Botelho
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <?php if ($pconfig['hidessid_enable']) echo "checked";?>>
2382 30ade846 gnhb
								<br/>
2383 136c598d Carlos Eduardo Ramos
								<?=gettext("Setting this option will force the card to NOT broadcast its SSID"); ?>
2384 30ade846 gnhb
								<br/>
2385 933ea015 Carlos Eduardo Ramos
								<?=gettext("(this might create problems for some clients)."); ?>
2386 30ade846 gnhb
							</td>
2387
						</tr>
2388
						<tr>
2389 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("WEP"); ?></td>
2390 c0948c6c Renato Botelho
							<td class="vtable">
2391 ee9933b6 Renato Botelho
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <?php if ($pconfig['wep_enable']) echo "checked"; ?>>
2392 136c598d Carlos Eduardo Ramos
								<strong><?=gettext("Enable WEP"); ?></strong>
2393 30ade846 gnhb
								<table border="0" cellspacing="0" cellpadding="0">
2394 9978e156 gnhb
									<tr>
2395 30ade846 gnhb
										<td>&nbsp;</td>
2396
										<td>&nbsp;</td>
2397 136c598d Carlos Eduardo Ramos
										<td>&nbsp;<?=gettext("TX key"); ?>&nbsp;</td>
2398 30ade846 gnhb
									</tr>
2399
									<tr>
2400 933ea015 Carlos Eduardo Ramos
										<td><?=gettext("Key 1:"); ?>&nbsp;&nbsp;</td>
2401 30ade846 gnhb
										<td>
2402
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>">
2403
										</td>
2404
										<td align="center">
2405 ee9933b6 Renato Botelho
											<input name="txkey" type="radio" value="1" <?php if ($pconfig['txkey'] == 1) echo "checked";?>>
2406 30ade846 gnhb
										</td>
2407
									</tr>
2408
									<tr>
2409 933ea015 Carlos Eduardo Ramos
										<td><?=gettext("Key 2:"); ?>&nbsp;&nbsp;</td>
2410 30ade846 gnhb
										<td>
2411
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>">
2412
										</td>
2413
										<td align="center">
2414 ee9933b6 Renato Botelho
											<input name="txkey" type="radio" value="2" <?php if ($pconfig['txkey'] == 2) echo "checked";?>>
2415 30ade846 gnhb
										</td>
2416
									</tr>
2417
									<tr>
2418 933ea015 Carlos Eduardo Ramos
										<td><?=gettext("Key 3:"); ?>&nbsp;&nbsp;</td>
2419 30ade846 gnhb
										<td>
2420
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>">
2421
										</td>
2422
										<td align="center">
2423 ee9933b6 Renato Botelho
											<input name="txkey" type="radio" value="3" <?php if ($pconfig['txkey'] == 3) echo "checked";?>>
2424 30ade846 gnhb
										</td>
2425
									</tr>
2426
									<tr>
2427 933ea015 Carlos Eduardo Ramos
										<td><?=gettext("Key 4:"); ?>&nbsp;&nbsp;</td>
2428 30ade846 gnhb
										<td>
2429
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>">
2430
										</td>
2431
										<td align="center">
2432 ee9933b6 Renato Botelho
											<input name="txkey" type="radio" value="4" <?php if ($pconfig['txkey'] == 4) echo "checked";?>>
2433 9978e156 gnhb
										</td>
2434
									</tr>
2435
								</table>
2436 30ade846 gnhb
								<br/>
2437 933ea015 Carlos Eduardo Ramos
								<?=gettext("40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'."); ?><br/>
2438
								<?=gettext("104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'."); ?>
2439 9978e156 gnhb
							</td>
2440
						</tr>
2441
						<tr>
2442 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("WPA"); ?></td>
2443 30ade846 gnhb
							<td class="vtable">
2444 ee9933b6 Renato Botelho
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <?php if ($pconfig['wpa_enable']) echo "checked"; ?>>
2445 136c598d Carlos Eduardo Ramos
								<strong><?=gettext("Enable WPA"); ?></strong>
2446 30ade846 gnhb
								<br/><br/>
2447
								<table border="0" cellspacing="0" cellpadding="0">
2448
									<tr>
2449
										<td>&nbsp;</td>
2450 2a2b247b jim-p
										<td>&nbsp;<?=gettext("WPA Pre-Shared Key"); ?>&nbsp;</td>
2451 30ade846 gnhb
									</tr>
2452
									<tr>
2453 933ea015 Carlos Eduardo Ramos
										<td><?=gettext("PSK:"); ?>&nbsp;&nbsp;</td>
2454 30ade846 gnhb
										<td>
2455
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>">
2456
										</td>
2457
									</tr>
2458
								</table>
2459 933ea015 Carlos Eduardo Ramos
								<br/><?=gettext("Passphrase must be from 8 to 63 characters."); ?>
2460 30ade846 gnhb
							</td>
2461 9978e156 gnhb
						</tr>
2462
						<tr>
2463 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("WPA Mode"); ?></td>
2464 30ade846 gnhb
							<td class="vtable">
2465
								<select name="wpa_mode" class="formselect" id="wpa_mode">
2466 ee9933b6 Renato Botelho
									<option <?php if ($pconfig['wpa_mode'] == '1') echo "selected";?> value="1"><?=gettext("WPA"); ?></option>
2467
									<option <?php if ($pconfig['wpa_mode'] == '2') echo "selected";?> value="2"><?=gettext("WPA2"); ?></option>
2468
									<option <?php if ($pconfig['wpa_mode'] == '3') echo "selected";?> value="3"><?=gettext("Both"); ?></option>
2469 30ade846 gnhb
								</select>
2470 9978e156 gnhb
							</td>
2471
						</tr>
2472
						<tr>
2473 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("WPA Key Management Mode"); ?></td>
2474 c0948c6c Renato Botelho
							<td class="vtable">
2475 30ade846 gnhb
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
2476 2a2b247b jim-p
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected";?> value="WPA-PSK"><?=gettext("Pre-Shared Key"); ?></option>
2477 ee9933b6 Renato Botelho
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected";?> value="WPA-EAP"><?=gettext("Extensible Authentication Protocol"); ?></option>
2478
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected";?> value="WPA-PSK WPA-EAP"><?=gettext("Both"); ?></option>
2479 30ade846 gnhb
								</select>
2480 9978e156 gnhb
							</td>
2481
						</tr>
2482
						<tr>
2483 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
2484 30ade846 gnhb
							<td class="vtable">
2485
								<select name="auth_algs" class="formselect" id="auth_algs">
2486 ee9933b6 Renato Botelho
									<option <?php if ($pconfig['auth_algs'] == '1') echo "selected";?> value="1"><?=gettext("Open System Authentication"); ?></option>
2487
									<option <?php if ($pconfig['auth_algs'] == '2') echo "selected";?> value="2"><?=gettext("Shared Key Authentication"); ?></option>
2488
									<option <?php if ($pconfig['auth_algs'] == '3') echo "selected";?> value="3"><?=gettext("Both"); ?></option>
2489 9978e156 gnhb
								</select>
2490 933ea015 Carlos Eduardo Ramos
								<br/><?=gettext("Note: Shared Key Authentication requires WEP."); ?></br>
2491 9978e156 gnhb
							</td>
2492
						</tr>
2493
						<tr>
2494 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("WPA Pairwise"); ?></td>
2495 30ade846 gnhb
							<td class="vtable">
2496
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
2497 ee9933b6 Renato Botelho
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected";?> value="CCMP TKIP"><?=gettext("Both"); ?></option>
2498
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected";?> value="CCMP"><?=gettext("AES (recommended)"); ?></option>
2499
									<option <?php if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected";?> value="TKIP"><?=gettext("TKIP"); ?></option>
2500 30ade846 gnhb
								</select>
2501 9978e156 gnhb
							</td>
2502
						</tr>
2503
						<tr>
2504 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Key Rotation"); ?></td>
2505 30ade846 gnhb
							<td class="vtable">
2506 ee9933b6 Renato Botelho
								<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";?>">
2507 933ea015 Carlos Eduardo Ramos
								<br/><?=gettext("Allowed values are 1-9999 but should not be longer than Master Key Regeneration time."); ?>
2508 9978e156 gnhb
							</td>
2509
						</tr>
2510
						<tr>
2511 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Master Key Regeneration"); ?></td>
2512 30ade846 gnhb
							<td class="vtable">
2513 ee9933b6 Renato Botelho
								<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";?>">
2514 933ea015 Carlos Eduardo Ramos
								<br/><?=gettext("Allowed values are 1-9999 but should not be shorter than Key Rotation time."); ?>
2515 9978e156 gnhb
							</td>
2516
						</tr>
2517
						<tr>
2518 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Strict Key Regeneration"); ?></td>
2519 30ade846 gnhb
							<td class="vtable">
2520 ee9933b6 Renato Botelho
								<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <?php if ($pconfig['wpa_strict_rekey']) echo "checked"; ?>>
2521 933ea015 Carlos Eduardo Ramos
								<br/><?=gettext("Setting this option will force the AP to rekey whenever a client disassociates."); ?>
2522 30ade846 gnhb
							</td>
2523 9978e156 gnhb
						</tr>
2524
						<tr>
2525 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("Enable IEEE802.1X Authentication"); ?></td>
2526 30ade846 gnhb
							<td class="vtable">
2527 ee9933b6 Renato Botelho
								<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <?php if ($pconfig['ieee8021x']) echo "checked";?>>
2528 933ea015 Carlos Eduardo Ramos
								<br/><?=gettext("Setting this option will enable 802.1x authentication."); ?>
2529 10e4d55e Pierre POMES
								<br/><span class="red"><strong><?=gettext("NOTE"); ?>:</strong></span> <?=gettext("this option requires checking the \"Enable WPA box\"."); ?>
2530 9978e156 gnhb
							</td>
2531
						</tr>
2532
						<tr>
2533 136c598d Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server IP Address"); ?></td>
2534 30ade846 gnhb
							<td class="vtable">
2535
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>">
2536 136c598d Carlos Eduardo Ramos
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
2537 9978e156 gnhb
							</td>
2538
						</tr>
2539
						<tr>
2540 933ea015 Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Port"); ?></td>
2541 30ade846 gnhb
							<td class="vtable">
2542
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>">
2543 933ea015 Carlos Eduardo Ramos
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
2544 9978e156 gnhb
							</td>
2545
						</tr>
2546
						<tr>
2547 933ea015 Carlos Eduardo Ramos
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Shared Secret"); ?></td>
2548 30ade846 gnhb
							<td class="vtable">
2549
								<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']);?>">
2550
								<br/>
2551 9978e156 gnhb
							</td>
2552 30ade846 gnhb
						</tr>
2553 32764288 Namezero
						<tr>
2554
					<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server IP Address"); ?></td>
2555
							<td class="vtable">
2556
								<input name="auth_server_addr2" id="auth_server_addr2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr2']);?>">
2557
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
2558
							</td>
2559
						</tr>
2560
						<tr>
2561
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Port"); ?></td>
2562
							<td class="vtable">
2563
								<input name="auth_server_port2" id="auth_server_port2" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port2']);?>">
2564
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
2565
							</td>
2566
						</tr>
2567
						<tr>
2568
							<td valign="top" class="vncell"><?=gettext("Secondary 802.1X Authentication Server Shared Secret"); ?></td>
2569
							<td class="vtable">
2570
								<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']);?>">
2571
								<br/>
2572
							</td>
2573
						</tr>
2574 c9e7d30d Scott Ullrich
						<tr>
2575
							<td valign="top" class="vncell">802.1X <?=gettext("Authentication Roaming Preauth"); ?></td>
2576
							<td class="vtable">
2577 a3381369 Colin Fleming
								<input name="rsn_preauth" id="rsn_preauth" type="checkbox" class="formfld unknown" size="66" value="yes" <?php if ($pconfig['rsn_preauth']) echo "checked"; ?>>
2578 c9e7d30d Scott Ullrich
								<br/>
2579
							</td>
2580
						</tr>
2581 ee9933b6 Renato Botelho
						<?php endif; ?>
2582 30ade846 gnhb
						<tr>
2583
							<td colspan="2" valign="top" height="16"></td>
2584
						</tr>
2585
						<tr>
2586 136c598d Carlos Eduardo Ramos
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Private networks"); ?></td>
2587 30ade846 gnhb
						</tr>
2588
						<tr>
2589
							<td valign="middle" class="vncell">&nbsp;</td>
2590
							<td class="vtable">
2591 c0948c6c Renato Botelho
								<a name="rfc1918"></a>
2592 30ade846 gnhb
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
2593 136c598d Carlos Eduardo Ramos
								<strong><?=gettext("Block private networks"); ?></strong><br>
2594
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2595
								"for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as"); ?>
2596 933ea015 Carlos Eduardo Ramos
								<?=gettext("well as loopback addresses (127/8)."); ?>&nbsp;&nbsp; <?=gettext("You should generally " .
2597 136c598d Carlos Eduardo Ramos
								"leave this option turned on, unless your WAN network lies in such " .
2598 c0948c6c Renato Botelho
								"a private address space, too."); ?>
2599 9978e156 gnhb
							</td>
2600
						</tr>
2601
						<tr>
2602 30ade846 gnhb
							<td valign="middle" class="vncell">&nbsp;</td>
2603 c0948c6c Renato Botelho
							<td class="vtable">
2604 30ade846 gnhb
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
2605 136c598d Carlos Eduardo Ramos
								<strong><?=gettext("Block bogon networks"); ?></strong><br>
2606
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2607 933ea015 Carlos Eduardo Ramos
								"(but not RFC 1918) or not yet assigned by IANA."); ?>&nbsp;&nbsp;
2608 136c598d Carlos Eduardo Ramos
								<?=gettext("Bogons are prefixes that should never appear in the Internet routing table, " .
2609 933ea015 Carlos Eduardo Ramos
								"and obviously should not appear as the source address in any packets you receive."); ?>
2610 6b4480dc bcyrill
								<br/><br/>
2611
								<?=gettext("Note: The update frequency can be changed under System->Advanced Firewall/NAT settings.")?>
2612 30ade846 gnhb
							</td>
2613 9978e156 gnhb
						</tr>
2614 1600b1af Scott Ullrich
					</table> <!-- End "allcfg" table -->
2615
					</div> <!-- End "allcfg" div -->
2616
2617
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2618 9978e156 gnhb
						<tr>
2619 7b8db0c3 Erik Fonnesbeck
							<td width="22%" valign="top">
2620 30ade846 gnhb
								&nbsp;
2621
							</td>
2622 7b8db0c3 Erik Fonnesbeck
							<td width="78%">
2623 30ade846 gnhb
								<br/>
2624 c0948c6c Renato Botelho
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2625 136c598d Carlos Eduardo Ramos
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2626 30ade846 gnhb
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2627 1d7e1d6c gnhb
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2628 dd5bf424 Scott Ullrich
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2629 30ade846 gnhb
								<?php endif; ?>
2630 dd5bf424 Scott Ullrich
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2631 9978e156 gnhb
							</td>
2632
						</tr>
2633 1600b1af Scott Ullrich
					</table>
2634 9978e156 gnhb
				</td>
2635
			</tr>
2636
		</table>
2637 30ade846 gnhb
		<!--
2638 9978e156 gnhb
		</div>
2639
		</td></tr>
2640
		</table>
2641 30ade846 gnhb
		-->
2642 9978e156 gnhb
	</form>
2643 30ade846 gnhb
	<script type="text/javascript">
2644
		var gatewayip;
2645
		var name;
2646 cfd40454 Seth Mos
		var gatewayipv6;
2647
		var namev6;
2648 30ade846 gnhb
		function show_add_gateway() {
2649
			document.getElementById("addgateway").style.display = '';
2650
			document.getElementById("addgwbox").style.display = 'none';
2651
			document.getElementById("gateway").style.display = 'none';
2652
			document.getElementById("save").style.display = 'none';
2653
			document.getElementById("cancel").style.display = 'none';
2654
			document.getElementById("gwsave").style.display = '';
2655
			document.getElementById("gwcancel").style.display = '';
2656 076b14b2 Vinicius Coque
			jQuery('#notebox').html("");
2657 30ade846 gnhb
		}
2658 cfd40454 Seth Mos
		function show_add_gateway_v6() {
2659
			document.getElementById("addgatewayv6").style.display = '';
2660
			document.getElementById("addgwboxv6").style.display = 'none';
2661
			document.getElementById("gatewayv6").style.display = 'none';
2662
			document.getElementById("save").style.display = 'none';
2663
			document.getElementById("cancel").style.display = 'none';
2664
			document.getElementById("gwsave").style.display = '';
2665
			document.getElementById("gwcancel").style.display = '';
2666 076b14b2 Vinicius Coque
			jQuery('#noteboxv6').html("");
2667 cfd40454 Seth Mos
		}
2668 30ade846 gnhb
		function hide_add_gateway() {
2669
			document.getElementById("addgateway").style.display = 'none';
2670 c0948c6c Renato Botelho
			document.getElementById("addgwbox").style.display = '';
2671 30ade846 gnhb
			document.getElementById("gateway").style.display = '';
2672
			document.getElementById("save").style.display = '';
2673
			document.getElementById("cancel").style.display = '';
2674
			document.getElementById("gwsave").style.display = '';
2675
			document.getElementById("gwcancel").style.display = '';
2676 56756d31 Renato Botelho
			jQuery('#status').html('');
2677 30ade846 gnhb
		}
2678 cfd40454 Seth Mos
		function hide_add_gateway_v6() {
2679
			document.getElementById("addgatewayv6").style.display = 'none';
2680
			document.getElementById("addgwboxv6").style.display = '';
2681
			document.getElementById("gatewayv6").style.display = '';
2682
			document.getElementById("save").style.display = '';
2683
			document.getElementById("cancel").style.display = '';
2684
			document.getElementById("gwsave").style.display = '';
2685
			document.getElementById("gwcancel").style.display = '';
2686 56756d31 Renato Botelho
			jQuery('#statusv6').html('');
2687 cfd40454 Seth Mos
		}
2688 30ade846 gnhb
		function hide_add_gatewaysave() {
2689
			document.getElementById("addgateway").style.display = 'none';
2690 076b14b2 Vinicius Coque
			jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2691
			var iface = jQuery('#if').val();
2692
			name = jQuery('#name').val();
2693
			var descr = jQuery('#gatewaydescr').val();
2694
			gatewayip = jQuery('#gatewayip').val();
2695 32764288 Namezero
2696 076b14b2 Vinicius Coque
			var defaultgw = jQuery('#defaultgw').val();
2697 30ade846 gnhb
			var url = "system_gateways_edit.php";
2698 cfd40454 Seth Mos
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2699 076b14b2 Vinicius Coque
			jQuery.ajax(
2700 30ade846 gnhb
				url,
2701
				{
2702 076b14b2 Vinicius Coque
					type: 'post',
2703
					data: pars,
2704
					error: report_failure,
2705 56756d31 Renato Botelho
					success: save_callback
2706 c0948c6c Renato Botelho
				});
2707 30ade846 gnhb
		}
2708 cfd40454 Seth Mos
		function hide_add_gatewaysave_v6() {
2709
			document.getElementById("addgatewayv6").style.display = 'none';
2710 076b14b2 Vinicius Coque
			jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif"> One moment please...');
2711
			var iface = jQuery('#if').val();
2712
			name = jQuery('#namev6').val();
2713
			var descr = jQuery('#gatewaydescrv6').val();
2714
			gatewayip = jQuery('#gatewayipv6').val();
2715
			var defaultgw = jQuery('#defaultgwv6').val();
2716 cfd40454 Seth Mos
			var url_v6 = "system_gateways_edit.php";
2717
			var pars_v6 = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip);
2718 076b14b2 Vinicius Coque
			jQuery.ajax(
2719 cfd40454 Seth Mos
				url_v6,
2720
				{
2721 076b14b2 Vinicius Coque
					type: 'post',
2722
					data: pars_v6,
2723
					error: report_failure_v6,
2724 56756d31 Renato Botelho
					success: save_callback_v6
2725 cfd40454 Seth Mos
				});
2726
		}
2727 30ade846 gnhb
		function addOption(selectbox,text,value)
2728
		{
2729
			var optn = document.createElement("OPTION");
2730
			optn.text = text;
2731
			optn.value = value;
2732 076b14b2 Vinicius Coque
			selectbox.append(optn);
2733
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2734
			jQuery('#notebox').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2735 c0948c6c Renato Botelho
		}
2736 cfd40454 Seth Mos
		function addOption_v6(selectbox,text,value)
2737
		{
2738
			var optn = document.createElement("OPTION");
2739
			optn.text = text;
2740
			optn.value = value;
2741 076b14b2 Vinicius Coque
			selectbox.append(optn);
2742
			selectbox.prop('selectedIndex',selectbox.children().length-1);
2743
			jQuery('#noteboxv6').html("<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.");
2744 cfd40454 Seth Mos
		}
2745 a0edece9 Darren Embry
		function report_failure(request, textStatus, errorThrown) {
2746
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
2747
				alert(request.responseText);
2748
			} else {
2749
				alert("Sorry, we could not create your IPv4 gateway at this time.");
2750
			}
2751 30ade846 gnhb
			hide_add_gateway();
2752
		}
2753 a0edece9 Darren Embry
		function report_failure_v6(request, textStatus, errorThrown) {
2754
			if (textStatus === "error" && request.getResponseHeader("Content-Type") === "text/plain") {
2755
				alert(request.responseText);
2756
			} else {
2757
				alert("Sorry, we could not create your IPv6 gateway at this time.");
2758
			}
2759 cfd40454 Seth Mos
			hide_add_gateway_v6();
2760
		}
2761 30ade846 gnhb
		function save_callback(transport) {
2762
			var response = transport.responseText;
2763
			if(response) {
2764
				document.getElementById("addgateway").style.display = 'none';
2765
				hide_add_gateway();
2766 cfd40454 Seth Mos
				var gwtext = escape(name) + " - " + gatewayip;
2767 076b14b2 Vinicius Coque
				addOption(jQuery('#gateway'), gwtext, name);
2768 30ade846 gnhb
				// Auto submit form?
2769
				//document.iform.submit();
2770 ea1cea05 Vinicius Coque
				//jQuery('#status').html('<img src="/themes/metallic/images/misc/loader.gif">');
2771 30ade846 gnhb
			} else {
2772
				report_failure();
2773
			}
2774
		}
2775 6e2a15e6 Evgeny Yurchenko
		function show_advanced_media() {
2776
			document.getElementById("showadvmediabox").innerHTML='';
2777
			aodiv = document.getElementById('showmediaadv');
2778
			aodiv.style.display = "block";
2779
		}
2780 cfd40454 Seth Mos
		function save_callback_v6(transport) {
2781
			var response_v6 = transport.responseText;
2782
			if(response_v6) {
2783
				document.getElementById("addgatewayv6").style.display = 'none';
2784
				hide_add_gateway_v6();
2785
				var gwtext_v6 = escape(name) + " - " + gatewayip;
2786 076b14b2 Vinicius Coque
				addOption_v6(jQuery('#gatewayv6'), gwtext_v6, name);
2787 cfd40454 Seth Mos
				// Auto submit form?
2788
				//document.iform.submit();
2789 ea1cea05 Vinicius Coque
				//jQuery('#statusv6').html('<img src="/themes/metallic/images/misc/loader.gif">');
2790 cfd40454 Seth Mos
			} else {
2791
				report_failure_v6();
2792
			}
2793
		}
2794 30ade846 gnhb
		<?php
2795 8672329c Erik Fonnesbeck
		echo "show_allcfg(document.iform.enable);";
2796 30ade846 gnhb
		echo "updateType('{$pconfig['type']}');\n";
2797 e029943a Seth Mos
		echo "updateTypeSix('{$pconfig['type6']}');\n";
2798 6c05cfb0 gnhb
		?>
2799 30ade846 gnhb
	</script>
2800
	<?php include("fend.inc"); ?>
2801
	</body>
2802 b09a92b7 Ermal Luçi
</html>