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