Project

General

Profile

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