Project

General

Profile

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