Project

General

Profile

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