Project

General

Profile

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