Project

General

Profile

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