Project

General

Profile

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