Project

General

Profile

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