Project

General

Profile

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