Project

General

Profile

Download (75.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces.php
5
	Copyright (C) 2004-2008 Scott Ullrich
6
	Copyright (C) 2006 Daniel S. Haischt.
7
	Copyright (C) 2008 Ermal Lu?i
8
	All rights reserved.
9

    
10
	originally part of m0n0wall (http://m0n0.ch/wall)
11
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
12
	All rights reserved.
13

    
14
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16

    
17
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19

    
20
	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

    
24
	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
/*
36
	pfSense_BUILDER_BINARIES:	/usr/sbin/arp
37
	pfSense_MODULE:	interfaces
38
*/
39

    
40
##|+PRIV
41
##|*IDENT=page-interfaces
42
##|*NAME=Interfaces: WAN page
43
##|*DESCR=Allow access to the 'Interfaces' page.
44
##|*MATCH=interfaces.php*
45
##|-PRIV
46

    
47
require("guiconfig.inc");
48
require("ipsec.inc");
49
require("functions.inc");
50
require("captiveportal.inc");
51
require("filter.inc");
52
require("shaper.inc");
53
require("rrd.inc");
54
require("vpn.inc");
55

    
56
if ($_REQUEST['if']) {
57
	$if = $_REQUEST['if'];
58
} else {
59
	$if = "wan";
60
}
61

    
62
define("CRON_PPPOE_CMD_FILE", "/conf/pppoe{$if}restart");
63
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

    
68
function getMPDCRONSettings() {
69
	global $config;
70
	if (is_array($config['cron']['item'])) {
71
		for ($i = 0; $i < count($config['cron']['item']); $i++) {
72
			$item = $config['cron']['item'][$i];
73
			if (strpos($item['command'], CRON_PPPOE_CMD_FILE) !== false) {
74
				return array("ID" => $i, "ITEM" => $item);
75
			}
76
		}
77
	}
78
	return NULL;
79
}
80

    
81
function getMPDResetTimeFromConfig() {
82
	$itemhash = getMPDCRONSettings();
83
	$cronitem = $itemhash['ITEM'];
84
	if (isset($cronitem)) {
85
		return "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
86
	} else {
87
		return NULL;
88
	}
89
}
90

    
91
function remove_bad_chars($string) {
92
	return preg_replace('/[^a-z|_|0-9]/i','',$string);
93
}
94

    
95
if (!is_array($config['gateways']['gateway_item']))
96
	$config['gateways']['gateway_item'] = array();
97

    
98
$a_gateways = &$config['gateways']['gateway_item'];
99

    
100
$wancfg = &$config['interfaces'][$if];
101

    
102
$pconfig['pppoe_username'] = $wancfg['pppoe_username'];
103
$pconfig['pppoe_password'] = $wancfg['pppoe_password'];
104
$pconfig['provider'] = $wancfg['provider'];
105
$pconfig['pppoe_dialondemand'] = isset($wancfg['ondemand']);
106
$pconfig['pppoe_idletimeout'] = $wancfg['timeout'];
107

    
108
/* ================================================ */
109
/* = force a connection reset at a specific time? = */
110
/* ================================================ */
111

    
112
if (isset($wancfg['pppoe']['pppoe-reset-type'])) {
113
	$resetTime = getMPDResetTimeFromConfig();  
114
	$pconfig['pppoe_preset'] = true;
115
	if ($wancfg['pppoe']['pppoe-reset-type'] == "custom") {
116
		$resetTime_a = split(" ", $resetTime);
117
		$pconfig['pppoe_pr_custom'] = true;
118
		$pconfig['pppoe_resetminute'] = $resetTime_a[0];
119
		$pconfig['pppoe_resethour'] = $resetTime_a[1];
120
		/*  just initialize $pconfig['pppoe_resetdate'] if the
121
		 *  coresponding item contains appropriate numeric values.
122
		 */
123
		if ($resetTime_a[2] <> "*" && $resetTime_a[3] <> "*") 
124
			$pconfig['pppoe_resetdate'] = "{$resetTime_a[3]}/{$resetTime_a[2]}/" . date("Y");
125
	} else if ($wancfg['pppoe']['pppoe-reset-type'] == "preset") {
126
		$pconfig['pppoe_pr_preset'] = true;
127
		switch ($resetTime) {
128
			case CRON_MONTHLY_PATTERN:
129
				$pconfig['pppoe_monthly'] = true;
130
				break;
131
			case CRON_WEEKLY_PATTERN:
132
				$pconfig['pppoe_weekly'] = true;
133
				break;
134
			case CRON_DAILY_PATTERN:
135
				$pconfig['pppoe_daily'] = true;
136
				break;
137
			case CRON_HOURLY_PATTERN:
138
				$pconfig['pppoe_hourly'] = true;
139
				break;
140
		}
141
	}
142
}
143

    
144
$pconfig['pptp_username'] = $wancfg['pptp_username'];
145
$pconfig['pptp_password'] = $wancfg['pptp_password'];
146
$pconfig['pptp_local'] = $wancfg['local'];
147
$pconfig['pptp_subnet'] = $wancfg['subnet'];
148
$pconfig['pptp_remote'] = $wancfg['remote'];
149
$pconfig['pptp_dialondemand'] = isset($wancfg['ondemand']);
150
$pconfig['pptp_idletimeout'] = $wancfg['timeout'];
151

    
152
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
153
$pconfig['alias-address'] = $wancfg['alias-address'];
154
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
155

    
156
// Populate page descr if it does not exist.
157
if($if == "wan" && !$wancfg['descr']) {
158
	$wancfg['descr'] = "WAN";
159
} else if ($if == "lan" && !$wancfg['descr']) {
160
	$wancfg['descr'] = "LAN";
161
}
162
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
163

    
164
$pconfig['enable'] = isset($wancfg['enable']);
165

    
166
if (is_array($config['aliases']['alias'])) {
167
	foreach($config['aliases']['alias'] as $alias) {
168
		if($alias['name'] == $wancfg['descr']) {
169
			$input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} already exists.");
170
		}
171
	}
172
}
173

    
174
switch($wancfg['ipaddr']) {
175
	case "dhcp":
176
		$pconfig['type'] = "dhcp";
177
		break;
178
	case "carpdev-dhcp":
179
		$pconfig['type'] = "carpdev-dhcp";
180
		$pconfig['ipaddr'] = "";
181
		break;
182
	case "pppoe":
183
		$pconfig['type'] = "pppoe";
184
		break;
185
	case "pptp":
186
		$pconfig['type'] = "pptp";
187
		break;
188
	case "ppp":
189
		$pconfig['type'] = "ppp";
190
		break;
191
	default:
192
		if(is_ipaddr($wancfg['ipaddr'])) {
193
			$pconfig['type'] = "static";
194
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
195
			$pconfig['subnet'] = $wancfg['subnet'];
196
			$pconfig['gateway'] = $wancfg['gateway'];
197
		} else {
198
			$pconfig['type'] = "none";
199
		}
200
		break;
201
}
202

    
203
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
204
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
205
$pconfig['spoofmac'] = $wancfg['spoofmac'];
206
$pconfig['mtu'] = $wancfg['mtu'];
207

    
208
/* Wireless interface? */
209
if (isset($wancfg['wireless'])) {
210
	/* Get wireless modes */
211
	$wlanif = get_real_interface($if);
212
	if (!does_interface_exist($wlanif))
213
		interface_wireless_clone($wlanif, $wancfg);
214
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
215
	$wl_modes = get_wireless_modes($if);
216
	$wl_regdomain_xml_attr = array();
217
	$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
218
	$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
219
	$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
220
	$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
221
	$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
222
	$pconfig['standard'] = $wancfg['wireless']['standard'];
223
	$pconfig['mode'] = $wancfg['wireless']['mode'];
224
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
225
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
226
	$pconfig['channel'] = $wancfg['wireless']['channel'];
227
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
228
	$pconfig['distance'] = $wancfg['wireless']['distance'];
229
	$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
230
	$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
231
	$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
232
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
233
	if (isset($wancfg['wireless']['puren']['enable']))
234
		$pconfig['puremode'] = '11n';
235
	else if (isset($wancfg['wireless']['pureg']['enable']))
236
		$pconfig['puremode'] = '11g';
237
	else
238
		$pconfig['puremode'] = 'any';
239
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
240
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
241
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
242
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
243
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
244
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
245
	if (is_array($wancfg['wireless']['wpa'])) {
246
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
247
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
248
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
249
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
250
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
251
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
252
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
253
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
254
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
255
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
256
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
257
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
258
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
259
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
260
	}
261
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
262
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
263
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
264
		$i = 1;
265
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
266
			$pconfig['key' . $i] = $wepkey['value'];
267
			if (isset($wepkey['txkey']))
268
				$pconfig['txkey'] = $i;
269
			$i++;
270
		}
271
		if (!isset($wepkey['txkey']))
272
			$pconfig['txkey'] = 1;
273
	}
274
}
275

    
276
if ($_POST['apply']) {
277
	unset($input_errors);
278
	if (!is_subsystem_dirty('interfaces'))
279
		$intput_errors[] = "You have already applied your settings!";
280
	else {	
281
		unlink_if_exists("{$g['tmp_path']}/config.cache");
282
		clear_subsystem_dirty('interfaces');
283
		if ($pconfig['enable'])
284
			interface_configure($if, true);
285
		else
286
			interface_bring_down($if);
287
		
288
		/* restart snmp so that it binds to correct address */		
289
		services_snmpd_configure();		
290
		if ($if == "lan") 		
291
			$savemsg = "The changes have been applied.  You may need to correct your web browser's IP address.";
292

    
293
		/* sync filter configuration */
294
		setup_gateways_monitor();
295

    
296
		clear_subsystem_dirty('staticroutes');
297
		
298
		filter_configure();
299
		
300
		enable_rrd_graphing();
301
	}
302
	header("Location: interfaces.php?if={$if}");
303
	exit;
304
} else
305

    
306
if ($_POST && $_POST['enable'] != "yes") {
307
	unset($wancfg['enable']);
308
	if (isset($wancfg['wireless'])) {
309
		interface_sync_wireless_clones($wancfg, false);
310
	}
311
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
312
	mark_subsystem_dirty('interfaces');
313
	header("Location: interfaces.php?if={$if}");
314
	exit;
315
} else
316

    
317
if ($_POST) {
318
	unset($input_errors);
319
	$pconfig = $_POST;
320
	conf_mount_rw();
321
	/* filter out spaces from descriptions  */
322
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
323
	/* okay first of all, cause we are just hiding the PPPoE HTML
324
	 * fields releated to PPPoE resets, we are going to unset $_POST
325
	 * vars, if the reset feature should not be used. Otherwise the
326
	 * data validation procedure below, may trigger a false error
327
	 * message.
328
	 */
329
	if (empty($_POST['pppoe_preset'])) {
330
		unset($_POST['pppoe_pr_type']);                
331
		unset($_POST['pppoe_resethour']);
332
		unset($_POST['pppoe_resetminute']);
333
		unset($_POST['pppoe_resetdate']);
334
		unset($_POST['pppoe_pr_preset_val']);
335
	}
336
	/* optional interface if list */
337
	$iflist = get_configured_interface_with_descr();
338
	/* description unique? */
339
	foreach ($iflist as $ifent => $ifdescr) {
340
		if ($if != $ifent && $ifdescr == $_POST['descr'])
341
			$input_errors[] = "An interface with the specified description already exists.";
342
	}
343
	/* input validation */
344
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && $_POST['type'] != "static")
345
		$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.";
346

    
347
	switch($_POST['type']) {
348
		case "static":
349
			$reqdfields = explode(" ", "ipaddr subnet gateway");
350
			$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
351
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
352
			break;
353
		case "PPPoE":
354
			if ($_POST['pppoe_dialondemand']) {
355
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
356
				$reqdfieldsn = explode(",", "PPPoE username,PPPoE password,Dial on demand,Idle timeout value");
357
			} else {
358
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
359
				$reqdfieldsn = explode(",", "PPPoE username,PPPoE password");
360
			}
361
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
362
			break;
363
		case "PPTP":
364
			if ($_POST['pptp_dialondemand']) {
365
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
366
				$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address,Dial on demand,Idle timeout value");
367
			} else {
368
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
369
				$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address");
370
			}
371
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
372
			break;
373
	}
374

    
375
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
376
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
377
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) 
378
		$input_errors[] = "A valid IP address must be specified.";
379
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) 
380
		$input_errors[] = "A valid subnet bit count must be specified.";
381
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) 
382
		$input_errors[] = "A valid alias IP address must be specified.";
383
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) 
384
		$input_errors[] = "A valid alias subnet bit count must be specified.";
385
	if ($_POST['gateway'] != "none") {
386
		$match = false;
387
		foreach($a_gateways as $gateway) {
388
			if(in_array($_POST['gateway'], $gateway)) {
389
				$match = true;
390
			}
391
		}
392
		if(!$match) {
393
			$input_errors[] = "A valid gateway must be specified.";
394
		}
395
	}
396
	if (($_POST['provider'] && !is_domain($_POST['provider']))) 
397
		$input_errors[] = "The service name contains invalid characters.";
398
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) 
399
		$input_errors[] = "The idle timeout value must be an integer.";
400
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) && 
401
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) 
402
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
403
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) && 
404
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) 
405
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
406
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) 
407
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
408
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) 
409
		$input_errors[] = "A valid PPTP local IP address must be specified.";
410
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) 
411
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
412
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) 
413
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
414
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) 
415
		$input_errors[] = "The idle timeout value must be an integer.";
416
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) 
417
		$input_errors[] = "A valid MAC address must be specified.";
418
	if ($_POST['mtu'] && ($_POST['mtu'] < 576)) 
419
		$input_errors[] = "The MTU must be greater than 576 bytes.";
420
	/* Wireless interface? */
421
	if (isset($wancfg['wireless'])) {
422
		$reqdfields = explode(" ", "mode ssid");
423
		$reqdfieldsn = explode(",", "Mode,SSID");
424
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
425
		check_wireless_mode();
426
		/* loop through keys and enforce size */
427
		for ($i = 1; $i <= 4; $i++) {
428
			if ($_POST['key' . $i]) {
429
				/* 64 bit */
430
				if (strlen($_POST['key' . $i]) == 5)
431
					continue;
432
				if (strlen($_POST['key' . $i]) == 10) {
433
					/* hex key */
434
					if (stristr($_POST['key' . $i], "0x") == false) {
435
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
436
					}
437
					continue;
438
				}
439
				if (strlen($_POST['key' . $i]) == 12) {
440
					/* hex key */
441
					if(stristr($_POST['key' . $i], "0x") == false) {
442
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
443
					}
444
					continue;
445
				}
446
				/* 128 bit */
447
				if (strlen($_POST['key' . $i]) == 13)
448
					continue;
449
				if (strlen($_POST['key' . $i]) == 26) {
450
					/* hex key */
451
					if (stristr($_POST['key' . $i], "0x") == false)
452
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
453
					continue;
454
				}
455
				if(strlen($_POST['key' . $i]) == 28)
456
					continue;
457
				$input_errors[] =  "Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.";
458
				break;
459
			}
460
		}
461

    
462
		if ($_POST['passphrase']) {
463
                	$passlen = strlen($_POST['passphrase']);
464
                	if ($passlen < 8 || $passlen > 64)
465
                        	$input_errors[] = "The length of the passphrase should be between 8 and 63 characters.";
466
		}
467
	}
468
	if (!$input_errors) {
469
		if ($wancfg['ipaddr'] != "ppp")
470
			unset($wancfg['ipaddr']);
471
		unset($wancfg['subnet']);
472
		unset($wancfg['gateway']);
473
		unset($wancfg['dhcphostname']);
474
		unset($wancfg['pppoe_username']);
475
		unset($wancfg['pppoe_password']);
476
		unset($wancfg['pptp_username']);
477
		unset($wancfg['pptp_password']);
478
		unset($wancfg['provider']);
479
		unset($wancfg['ondemand']);
480
		unset($wancfg['timeout']);
481
		if ($wancfg['pppoe']['pppoe-reset-type'])
482
			unset($wancfg['pppoe']['pppoe-reset-type']);
483
		unset($wancfg['local']);
484
		unset($wancfg['subnet']);
485
		unset($wancfg['remote']);
486

    
487
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
488
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
489

    
490
		/* for dynamic interfaces we tack a gateway item onto the array to prevent system
491
		 * log messages from appearing. They can also manually add these items */
492
		/* 1st added gateway gets a default bit */
493
		if(!empty($a_gateways)) {
494
			$gateway_item = array();
495
			/* check for duplicates */
496
			$skip = false;
497
			foreach($a_gateways as $item) {
498
				if(($item['interface'] == "$if") && ($item['gateway'] == "dynamic")) {
499
					$skip = true;
500
				}
501
			}
502
			if($skip == false) {
503
				$gateway_item['gateway'] = "dynamic";
504
				$gateway_item['descr'] = "Interface {$if} dynamic gateway";
505
				$gateway_item['name'] = "GW_" . strtoupper($if);
506
				$gateway_item['interface'] = "{$if}";
507
			} else {
508
				unset($gateway_item);
509
			}
510
		}
511

    
512
		switch($_POST['type']) {
513
			case "static":
514
				$wancfg['ipaddr'] = $_POST['ipaddr'];
515
				$wancfg['subnet'] = $_POST['subnet'];
516
				if ($_POST['gateway'] != "none") {
517
					$wancfg['gateway'] = $_POST['gateway'];
518
				}
519
				break;
520
			case "dhcp":
521
				$wancfg['ipaddr'] = "dhcp";
522
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
523
				$wancfg['alias-address'] = $_POST['alias-address'];
524
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
525
				if($gateway_item) {
526
					$a_gateways[] = $gateway_item;
527
				}
528
				break;
529
			case "carpdev-dhcp":
530
				$wancfg['ipaddr'] = "carpdev-dhcp";
531
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
532
				$wancfg['alias-address'] = $_POST['alias-address'];
533
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
534
				if($gateway_item) {
535
					$a_gateways[] = $gateway_item;
536
				}
537
				break;
538
			case "pppoe":
539
				$wancfg['ipaddr'] = "pppoe";
540
				$wancfg['pppoe_username'] = $_POST['pppoe_username'];
541
				$wancfg['pppoe_password'] = $_POST['pppoe_password'];
542
				$wancfg['provider'] = $_POST['provider'];
543
				$wancfg['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
544
				$wancfg['timeout'] = $_POST['pppoe_idletimeout'];
545
				if($gateway_item) {
546
					$a_gateways[] = $gateway_item;
547
				}
548
				break;
549
			case "pptp":
550
				$wancfg['ipaddr'] = "pptp";
551
				$wancfg['pptp_username'] = $_POST['pptp_username'];
552
				$wancfg['pptp_password'] = $_POST['pptp_password'];
553
				$wancfg['local'] = $_POST['pptp_local'];
554
				$wancfg['subnet'] = $_POST['pptp_subnet'];
555
				$wancfg['remote'] = $_POST['pptp_remote'];
556
				$wancfg['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
557
				$wancfg['timeout'] = $_POST['pptp_idletimeout'];
558
				if($gateway_item) {
559
					$a_gateways[] = $gateway_item;
560
				}
561
				break;
562
		}
563
		handle_pppoe_reset();
564
		/* reset cron items if necessary */
565
		if (empty($_POST['pppoe_preset'])) {
566
			/* test whether a cron item exists and unset() it if necessary */
567
			$itemhash = getMPDCRONSettings();
568
			$item = $itemhash['ITEM'];
569
			if (isset($item))
570
				unset($config['cron']['item'][$itemhash['ID']]); 
571
		}
572
		if($_POST['blockpriv'] == "yes") {
573
			$wancfg['blockpriv'] = true;
574
		} else {
575
			unset($wancfg['blockpriv']);
576
		}
577
		if($_POST['blockbogons'] == "yes") {
578
			$wancfg['blockbogons'] = true;
579
		} else {
580
			unset($wancfg['blockbogons']);
581
		}
582
		$wancfg['spoofmac'] = $_POST['spoofmac'];
583
		if (empty($_POST['mtu'])) {
584
			unset($wancfg['mtu']);
585
		} else {
586
			$wancfg['mtu'] = $_POST['mtu'];
587
		}
588
		if (isset($wancfg['wireless'])) {
589
			handle_wireless_post();
590
		}
591
		write_config();
592
		mark_subsystem_dirty('interfaces');
593
		/* regenerate cron settings/crontab file */
594
		configure_cron();
595
		conf_mount_ro();
596
		header("Location: interfaces.php?if={$if}");
597
		exit;
598
	}
599
} // end if($_POST) 
600

    
601
function handle_pppoe_reset() {
602
	global $_POST, $config, $g, $wancfg, $if;
603
	/* perform a periodic reset? */
604
	if(!isset($_POST['pppoe_preset'])) {
605
		setup_pppoe_reset_file($if, false);		
606
		return;
607
	}
608
	if (!is_array($config['cron']['item'])) 
609
		$config['cron']['item'] = array(); 
610
	$itemhash = getMPDCRONSettings();
611
	$item = $itemhash['ITEM'];
612
	if (empty($item)) 
613
		$item = array();
614
	if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] == "custom") {
615
		$wancfg['pppoe']['pppoe-reset-type'] = "custom";
616
		$pconfig['pppoe_pr_custom'] = true;
617
		$item['minute'] = $_POST['pppoe_resetminute'];
618
		$item['hour'] = $_POST['pppoe_resethour'];
619
		if (isset($_POST['pppoe_resetdate']) && $_POST['pppoe_resetdate'] <> "" && strlen($_POST['pppoe_resetdate']) == 10) {
620
			$date = explode("/", $_POST['pppoe_resetdate']);
621
			$item['mday'] = $date[1];
622
			$item['month'] = $date[0];
623
		} else {
624
			$item['mday'] = "*";
625
			$item['month'] = "*";
626
		}
627
		$item['wday'] = "*";
628
		$item['who'] = "root";
629
		$item['command'] = CRON_PPPOE_CMD_FILE;
630
	} else if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] = "preset") {
631
		$wancfg['pppoe']['pppoe-reset-type'] = "preset";
632
		$pconfig['pppoe_pr_preset'] = true;
633
		switch ($_POST['pppoe_pr_preset_val']) {
634
			case "monthly":
635
				$item['minute'] = "0";
636
				$item['hour'] = "0";
637
				$item['mday'] = "1";
638
				$item['month'] = "*";
639
				$item['wday'] = "*";
640
				$item['who'] = "root";
641
				$item['command'] = CRON_PPPOE_CMD_FILE;
642
				break;
643
	        	case "weekly":
644
				$item['minute'] = "0";
645
				$item['hour'] = "0";
646
				$item['mday'] = "*";
647
				$item['month'] = "*";
648
				$item['wday'] = "0";
649
				$item['who'] = "root";
650
				$item['command'] = CRON_PPPOE_CMD_FILE;
651
				break;
652
			case "daily":
653
				$item['minute'] = "0";
654
				$item['hour'] = "0";
655
				$item['mday'] = "*";
656
				$item['month'] = "*";
657
				$item['wday'] = "*";
658
				$item['who'] = "root";
659
				$item['command'] = CRON_PPPOE_CMD_FILE;
660
				break;
661
			case "hourly":
662
				$item['minute'] = "0";
663
				$item['hour'] = "*";
664
				$item['mday'] = "*";
665
				$item['month'] = "*";
666
				$item['wday'] = "*";
667
				$item['who'] = "root";
668
				$item['command'] = CRON_PPPOE_CMD_FILE;
669
				break;
670
		} // end switch
671
	} // end if
672
	if (isset($itemhash['ID'])) 
673
		$config['cron']['item'][$itemhash['ID']] = $item;
674
	else 
675
		$config['cron']['item'][] = $item;
676
	/* finally install the pppoerestart file */
677
	if (isset($_POST['pppoe_preset'])) {
678
		setup_pppoe_reset_file($if, true);
679
		$wancfg['pppoe_reset'] = true;
680
		$wancfg['pppoe_preset'] = true;
681
		sigkillbypid("{$g['varrun_path']}/cron.pid", "HUP");
682
	} else {
683
		unset($wancfg['pppoe_reset']);
684
		unset($wancfg['pppoe_preset']);		
685
		setup_pppoe_reset_file($if, false);	
686
	}
687
}
688

    
689
function handle_wireless_post() {
690
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr;
691
	if (!is_array($wancfg['wireless']))
692
		$wancfg['wireless'] = array();
693
	$wancfg['wireless']['standard'] = $_POST['standard'];
694
	$wancfg['wireless']['mode'] = $_POST['mode'];
695
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
696
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
697
	$wancfg['wireless']['channel'] = $_POST['channel'];
698
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
699
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
700
	$wancfg['wireless']['distance'] = $_POST['distance'];
701
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
702
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
703
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
704
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
705
		foreach($wl_countries_attr as $wl_country) {
706
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
707
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
708
				break;
709
			}
710
		}
711
	}
712
	if (!is_array($wancfg['wireless']['wpa']))
713
		$wancfg['wireless']['wpa'] = array();
714
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
715
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
716
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
717
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
718
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
719
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
720
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
721
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
722
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
723
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
724
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
725
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
726
	if ($_POST['hidessid_enable'] == "yes")
727
		$wancfg['wireless']['hidessid']['enable'] = true;
728
	else if (isset($wancfg['wireless']['hidessid']['enable']))
729
		unset($wancfg['wireless']['hidessid']['enable']);
730
	if ($_POST['mac_acl_enable'] == "yes")
731
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
732
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
733
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
734
	if ($_POST['ieee8021x'] == "yes")
735
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
736
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
737
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
738
	if ($_POST['wpa_strict_rekey'] == "yes")
739
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
740
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
741
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
742
	if ($_POST['debug_mode'] == "yes")
743
		$wancfg['wireless']['wpa']['debug_mode'] = true;
744
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
745
		sunset($wancfg['wireless']['wpa']['debug_mode']);
746
	if ($_POST['wpa_enable'] == "yes")
747
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
748
	else if (isset($wancfg['wireless']['wpa']['enable']))
749
		unset($wancfg['wireless']['wpa']['enable']);
750
	if ($_POST['wep_enable'] == "yes") {
751
		if (!is_array($wancfg['wireless']['wep']))
752
			$wancfg['wireless']['wep'] = array();
753
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
754
	} else if (isset($wancfg['wireless']['wep']))
755
		unset($wancfg['wireless']['wep']);
756
	if ($_POST['wme_enable'] == "yes") {
757
		if (!is_array($wancfg['wireless']['wme']))
758
			$wancfg['wireless']['wme'] = array();
759
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
760
	} else if (isset($wancfg['wireless']['wme']['enable']))
761
		unset($wancfg['wireless']['wme']['enable']);
762
	if ($_POST['puremode'] == "11g") {
763
		if (!is_array($wancfg['wireless']['pureg']))
764
			$wancfg['wireless']['pureg'] = array();
765
		$wancfg['wireless']['pureg']['enable'] = true;
766
	} else if ($_POST['puremode'] == "11n") {
767
		if (!is_array($wancfg['wireless']['puren']))
768
			$wancfg['wireless']['puren'] = array();
769
		$wancfg['wireless']['puren']['enable'] = true;
770
	} else {
771
		if (isset($wancfg['wireless']['pureg']))
772
			unset($wancfg['wireless']['pureg']);
773
		if (isset($wancfg['wireless']['puren']))
774
			unset($wancfg['wireless']['puren']);
775
	}
776
	if ($_POST['apbridge_enable'] == "yes") {
777
		if (!is_array($wancfg['wireless']['apbridge']))
778
			$wancfg['wireless']['apbridge'] = array();
779
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
780
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
781
		unset($wancfg['wireless']['apbridge']['enable']);
782
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
783
		if (!is_array($wancfg['wireless']['turbo']))
784
			$wancfg['wireless']['turbo'] = array();
785
		$wancfg['wireless']['turbo']['enable'] = true;
786
	} else if (isset($wancfg['wireless']['turbo']['enable']))
787
		unset($wancfg['wireless']['turbo']['enable']);
788
	$wancfg['wireless']['wep']['key'] = array();
789
	for ($i = 1; $i <= 4; $i++) {
790
		if ($_POST['key' . $i]) {
791
			$newkey = array();
792
			$newkey['value'] = $_POST['key' . $i];
793
			if ($_POST['txkey'] == $i)
794
				$newkey['txkey'] = true;
795
			$wancfg['wireless']['wep']['key'][] = $newkey;
796
		}
797
	}
798
	interface_sync_wireless_clones($wancfg, true);
799
}
800

    
801
function check_wireless_mode() {
802
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
803

    
804
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
805
		return;
806

    
807
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
808
		$clone_count = 1;
809
	else
810
		$clone_count = 0;
811
	if (is_array($config['wireless']['clone'])) {
812
		foreach ($config['wireless']['clone'] as $clone) {
813
			if ($clone['if'] == $wlanbaseif)
814
				$clone_count++;
815
		}
816
	}
817
	if ($clone_count > 1) {
818
		$old_wireless_mode = $wancfg['wireless']['mode'];
819
		$wancfg['wireless']['mode'] = $_POST['mode'];
820
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
821
			$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.";
822
		} else {
823
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
824
		}
825
		$wancfg['wireless']['mode'] = $old_wireless_mode;
826
	}
827
}
828

    
829
$pgtitle = array("Interfaces", $pconfig['descr']);
830
$closehead = false;
831
include("head.inc");
832
$types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" => "PPPoE", "pptp" => "PPTP" /* , "carpdev-dhcp" => "CarpDev"*/); 
833

    
834
?>
835

    
836
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
837
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
838
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
839
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
840

    
841
<script type="text/javascript">
842
	function updateType(t){
843
		switch(t) {
844
	<?php
845
		/* OK, so this is sick using php to generate javascript, but it needed to be done */
846
		foreach ($types as $key => $val) {
847
			echo "case \"{$key}\": {\n";
848
			$t = $types;
849
			foreach ($t as $k => $v) {
850
				if ($k != $key) {
851
					echo "$('{$k}').hide();\n";
852
				}
853
			}
854
			echo "}\n";
855
		}
856
	?>
857
		}
858
		$(t).show();
859
	}
860

    
861
	function show_allcfg(obj) {
862
		if (obj.checked)
863
			$('allcfg').show();
864
		else
865
			$('allcfg').hide();
866
	}
867
	
868
	function show_periodic_reset(obj) {
869
		if (obj.checked)
870
			$('presetwrap').show();
871
		else
872
			$('presetwrap').hide();
873
	}
874

    
875
	function show_mon_config() {
876
		document.getElementById("showmonbox").innerHTML='';
877
		aodiv = document.getElementById('showmon');
878
		aodiv.style.display = "block";
879
	}
880

    
881
	function openwindow(url) {
882
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
883
		if (oWin==null || typeof(oWin)=="undefined") 
884
			return false;
885
		else 
886
			return true;
887
	}
888
</script>
889
</head>
890
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
891
	<?php include("fbegin.inc"); ?>
892
	<form action="interfaces.php" method="post" name="iform" id="iform">
893
		<?php if ($input_errors) print_input_errors($input_errors); ?>
894
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
895
		<?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 before applying."));?><br />
896
		<?php endif; ?>
897
		<?php if ($savemsg) print_info_box($savemsg); ?>
898
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
899
		<tr>
900
                                <td id="mainarea">
901
                                        <div class="tabcont">
902
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
903
		<tr>
904
			<td colspan="2" valign="top" class="listtopic">General configuration</td>
905
		</tr>
906
		<tr>
907
			<td width="22%" valign="top" class="vncell">Enable</td>
908
			<td width="78%" class="vtable">
909
				<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked"; ?> onClick="show_allcfg(this);">
910
			<strong>Enable Interface</strong>
911
			</td>
912
		</tr>
913
		</table>
914
		<div style="display:none;" name="allcfg" id="allcfg">
915
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
916
			<tr>
917
				<td width="22%" valign="top" class="vncell">Description</td>
918
				<td width="78%" class="vtable">
919
					<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
920
					<br><span class="vexpl">Enter a description (name) for the interface here.</span>
921
				</td>
922
			</tr>
923
		<?
924
		 if(!$wancfg['serialport']):
925
		?>
926
			<tr>
927
				<td valign="middle" class="vncell"><strong>Type</strong></td>
928
				<td class="vtable"> 
929
					<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
930
					<?php 
931
						foreach ($types as $key => $opt) { 
932
							echo "<option onClick=\"updateType('{$key}');\"";
933
							if ($key == $pconfig['type']) 
934
								echo " selected";
935
							echo " value=\"{$key}\" >" . htmlspecialchars($opt);
936
							echo "</option>";
937
					    } 
938
					?>
939
					</select>
940
				</td>
941
			</tr>
942
			<?php endif; ?>
943
			<tr>
944
				<td valign="top" class="vncell">MAC address</td>
945
				<td class="vtable">
946
					<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
947
				    <?php
948
						$ip = getenv('REMOTE_ADDR');
949
						$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
950
						$mac = str_replace("\n","",$mac);
951
						if($mac):
952
					?>
953
						<a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#">Insert my local MAC address</a>
954
					<?php endif; ?>
955
					<br>
956
					This field can be used to modify (&quot;spoof&quot;) the MAC
957
					address of the WAN interface<br>
958
					(may be required with some cable connections)<br>
959
					Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx
960
					or leave blank
961
				</td>
962
			</tr>
963
			<tr>
964
				<td valign="top" class="vncell">MTU</td>
965
				<td class="vtable"> 
966
					<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
967
					<br>
968
					If you enter a value in this field, then MSS clamping for
969
					TCP connections to the value entered above minus 40 (TCP/IP
970
					header size) will be in effect. If you leave this field blank,
971
					an MTU of 1500 bytes will be assumed.
972
				</td>
973
			</tr>
974
			<tr>
975
				<td colspan="2" valign="top" height="16"></td>
976
			</tr>			
977
			<tr style="display:none;" name="none" id="none">
978
			</tr>
979
			<tr style="display:none;" name="static" id="static">
980
				<td colspan="2" style="padding:0px;">
981
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
982
						<tr>
983
							<td colspan="2" valign="top" class="listtopic">Static IP configuration</td>
984
						</tr>
985
						<tr>
986
							<td width="22%" valign="top" class="vncellreq">IP address</td>
987
							<td width="78%" class="vtable"> 
988
								<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
989
								/
990
								<select name="subnet" class="formselect" id="subnet">
991
									<?php
992
									for ($i = 32; $i > 0; $i--) {
993
										if($i <> 31) {
994
											echo "<option value=\"{$i}\" ";
995
											if ($i == $pconfig['subnet']) echo "selected";
996
											echo ">" . $i . "</option>";
997
										}
998
									}
999
									?>
1000
								</select>
1001
							</td>
1002
						</tr>
1003
						<tr>
1004
							<td width="22%" valign="top" class="vncellreq">Gateway</td>
1005
							<td width="78%" class="vtable">
1006
								<select name="gateway" class="formselect" id="gateway">
1007
									<option value="none" selected>None</option>
1008
										<?php
1009
										if(count($a_gateways) > 0) {
1010
											foreach ($a_gateways as $gateway) {
1011
												if($gateway['interface'] == $if) {
1012
										?>
1013
												<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
1014
													<?=htmlspecialchars($gateway['name']);?>
1015
												</option>
1016
										<?php
1017
												}
1018
											}
1019
										}
1020
										?>
1021
								</select>
1022
								<br/>
1023
								<div id='addgwbox'>
1024
									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>.
1025
								</div>
1026
								<div id='notebox'>
1027
								</div>
1028
								<div id="status">
1029
								</div>								
1030
								<div style="display:none" id="addgateway" name="addgateway">
1031
									<p> 
1032
									<table border="1" style="background:#990000; border-style: none none none none; width:225px;"><tr><td>
1033
										<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1034
											<tr><td>&nbsp;</td>
1035
											<tr>
1036
												<td colspan="2"><center><b><font color="white">Add new gateway:</b></center></td>
1037
											</tr>
1038
											<tr><td>&nbsp;</td>
1039
											<?php
1040
											if($if == "wan" || $if == "WAN")
1041
												$checked = " CHECKED";
1042
											?>
1043
											<tr>
1044
												<td width="45%" align="right"><font color="white">Default  gateway:</td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
1045
											</tr>												
1046
											<tr>
1047
												<td align="right"><font color="white">Gateway Name:</td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td>
1048
											</tr>
1049
											<tr>
1050
												<td align="right"><font color="white">Gateway IP:</td><td><input id="gatewayip" name="gatewayip"></td>
1051
											</tr>
1052
											<tr>
1053
												<td align="right"><font color="white">Description:</td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1054
											</tr>
1055
											<tr><td>&nbsp;</td>
1056
											<tr>
1057
												<td colspan="2">
1058
													<center>
1059
														<div id='savebuttondiv'>
1060
															<input type="hidden" name="addrtype" id="addrtype" value="IPv4" />
1061
															<input id="gwsave" type="Button" value="Save Gateway" onClick='hide_add_gatewaysave();'> 
1062
															<input id="gwcancel" type="Button" value="Cancel" onClick='hide_add_gateway();'>
1063
														</div>
1064
													</center>
1065
												</td>
1066
											</tr>
1067
											<tr><td>&nbsp;</td>
1068
										</table>
1069
										</td></tr></table>
1070
									<p/>
1071
								</div>
1072
							</td>
1073
						</tr>
1074
					</table>
1075
				</td>
1076
				</tr>
1077
				<tr style="display:none;" name="dhcp" id="dhcp">
1078
					<td colspan="2" style="padding: 0px;">
1079
						<table width="100%" border="0" cellpadding="6" cellspacing="0">
1080
							<tr>
1081
								<td colspan="2" valign="top" class="listtopic">DHCP client configuration</td>
1082
							</tr>
1083
							<tr>
1084
								<td width="22%" valign="top" class="vncell">Hostname</td>
1085
								<td width="78%" class="vtable">
1086
									<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1087
									<br>
1088
									The value in this field is sent as the DHCP client identifier
1089
									and hostname when requesting a DHCP lease. Some ISPs may require
1090
									this (for client identification).
1091
								</td>
1092
							</tr>
1093
							<tr>
1094
								<td width="22%" valign="top" class="vncell">Alias IP address</td>
1095
								<td width="78%" class="vtable"> 
1096
									<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
1097
									<select name="alias-subnet" class="formselect" id="alias-subnet">
1098
										<?php
1099
										for ($i = 32; $i > 0; $i--) {
1100
											if($i <> 31) {
1101
												echo "<option value=\"{$i}\" ";
1102
												if ($i == $pconfig['alias-subnet']) echo "selected";
1103
												echo ">" . $i . "</option>";
1104
											}
1105
										}
1106
										?>
1107
									</select>
1108
									The value in this field is used as a fixed alias IP address by the
1109
									DHCP client.
1110
								</td>
1111
							</tr>
1112
						</table>
1113
					</td>
1114
				</tr>
1115
				<tr style="display:none;" name="pppoe" id="pppoe">
1116
					<td colspan="2" style="padding:0px;">
1117
						<table width="100%" border="0" cellpadding="6" cellspacing="0">
1118
							<tr>
1119
								<td colspan="2" valign="top" class="listtopic">PPPoE configuration</td>
1120
							</tr>
1121
							<tr>
1122
								<td width="22%" valign="top" class="vncellreq">Username</td>
1123
								<td width="78%" class="vtable">
1124
										<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
1125
								</td>
1126
							</tr>
1127
							<tr>
1128
								<td width="22%" valign="top" class="vncellreq">Password</td>
1129
								<td width="78%" class="vtable">
1130
									<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
1131
								</td>
1132
							</tr>
1133
							<tr>
1134
								<td width="22%" valign="top" class="vncell">Service name</td>
1135
								<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
1136
									<br> <span class="vexpl">Hint: this field can usually be left empty</span>
1137
								</td>
1138
							</tr>
1139
							<tr>
1140
								<td width="22%" valign="top" class="vncell">Dial on demand</td>
1141
								<td width="78%" class="vtable">
1142
									<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>>
1143
									<strong>Enable Dial-On-Demand mode</strong><br>
1144
		    						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.
1145
								</td>
1146
							</tr>
1147
							<tr>
1148
								<td width="22%" valign="top" class="vncell">Idle timeout</td>
1149
								<td width="78%" class="vtable">
1150
									<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.
1151
								</td>
1152
							</tr>
1153
							<tr>
1154
								<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
1155
								<td width="78%" class="vtable">
1156
									<input name="pppoe_preset" type="checkbox" id="pppoe_preset" value="yes" <?php if ($pconfig['pppoe_preset']) echo "checked=\"checked\""; ?> onclick="show_periodic_reset(this);" />
1157
										<?= gettext("enable periodic PPPoE resets"); ?>
1158
										<br />
1159
										<?php if ($pconfig['pppoe_preset']): ?>
1160
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
1161
											<?php else: ?>
1162
												<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%" style="display: none;">
1163
												<?php endif; ?>
1164
												<tr>
1165
													<td align="left" valign="top">
1166
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
1167
															<input name="pppoe_pr_type" type="radio" id="pppoe_pr_custom" value="custom" <?php if ($pconfig['pppoe_pr_custom']) echo "checked=\"checked\""; ?> onclick="if (this.checked) { Effect.Appear('pppoecustomwrap', { duration: 0.0 }); Effect.Fade('pppoepresetwrap', { duration: 0.0 }); }" /> 
1168
																<?= gettext("provide a custom reset time"); ?>
1169
																<br />
1170
																<input name="pppoe_pr_type" type="radio" id="pppoe_pr_preset" value="preset" <?php if ($pconfig['pppoe_pr_preset']) echo "checked=\"checked\""; ?> onclick="if (this.checked) { Effect.Appear('pppoepresetwrap', { duration: 0.0 }); Effect.Fade('pppoecustomwrap', { duration: 0.0 }); }" /> 
1171
																	<?= gettext("select reset time from a preset"); ?>
1172
																</p>
1173
																<?php if ($pconfig['pppoe_pr_custom']): ?>
1174
																	<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
1175
																	<?php else: ?>
1176
																		<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
1177
																		<?php endif; ?>
1178
																		<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" /> 
1179
																		<?= gettext("hour (0-23)"); ?><br />
1180
																		<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" /> 
1181
																		<?= gettext("minute (0-59)"); ?><br />
1182
																		<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']);?>" /> 
1183
																		<?= gettext("reset at a specific date (mm/dd/yyyy)"); ?>
1184
																		<br />&nbsp;<br />
1185
																		<span class="red"><strong>Note: </strong></span>
1186
																		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.
1187
																	</p>
1188
																	<?php if ($pconfig['pppoe_pr_preset']): ?>
1189
																		<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
1190
																		<?php else: ?>
1191
																			<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
1192
																			<?php endif; ?>
1193
																			<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> /> 
1194
																			<?= gettext("reset at each month ('0 0 1 * *')"); ?>
1195
																			<br />
1196
																			<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> /> 
1197
																			<?= gettext("reset at each week ('0 0 * * 0')"); ?>
1198
																			<br />
1199
																			<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> /> 
1200
																			<?= gettext("reset at each day ('0 0 * * *')"); ?>
1201
																			<br />
1202
																			<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> /> 
1203
																			<?= gettext("reset at each hour ('0 * * * *')"); ?>
1204
																		</p>
1205
																	</td>
1206
																</tr>
1207
															</table>
1208
														</td>
1209
													</tr>
1210
												</table>
1211
											</td>
1212
										</tr>
1213
										<tr style="display:none;" name="pptp" id="pptp">
1214
											<td colspan="2" style="padding:0px;">
1215
												<table width="100%" border="0" cellpadding="6" cellspacing="0">
1216
													<tr>
1217
														<td colspan="2" valign="top" class="listtopic">PPTP configuration</td>
1218
													</tr>
1219
													<tr>
1220
														<td width="22%" valign="top" class="vncellreq">Username</td>
1221
														<td width="78%" class="vtable">
1222
															<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
1223
														</td>
1224
													</tr>
1225
													<tr>
1226
														<td width="22%" valign="top" class="vncellreq">Password</td>
1227
														<td width="78%" class="vtable">
1228
															<input name="pptp_password" type="text" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
1229
														</td>
1230
													</tr>
1231
													<tr>
1232
														<td width="22%" width="100" valign="top" class="vncellreq">Local IP address</td>
1233
														<td width="78%" class="vtable"> 
1234
															<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local']);?>">
1235
															/
1236
															<select name="pptp_subnet" class="formselect" id="pptp_subnet">
1237
																<?php for ($i = 31; $i > 0; $i--): ?>
1238
																	<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet']) echo "selected"; ?>>
1239
																		<?=$i;?>
1240
																	</option>
1241
																<?php endfor; ?>
1242
															</select>
1243
														</td>
1244
													</tr>
1245
													<tr>
1246
														<td width="22%" width="100" valign="top" class="vncellreq">Remote IP address</td>
1247
														<td width="78%" class="vtable">
1248
															<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote']);?>">
1249
														</td>
1250
													</tr>
1251
													<tr>
1252
														<td width="22%" valign="top" class="vncell">Dial on demand</td>
1253
														<td width="78%" class="vtable">
1254
															<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?>>
1255
															<strong>Enable Dial-On-Demand mode</strong><br>
1256
															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.
1257
														</td>
1258
													</tr>
1259
													<tr>
1260
														<td width="22%" valign="top" class="vncell">Idle timeout</td>
1261
														<td width="78%" class="vtable">
1262
															<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.
1263
														</td>
1264
													</tr>
1265
												</table>
1266
											</td>
1267
										</tr>
1268
										<?php
1269
											/* Wireless interface? */
1270
											if (isset($wancfg['wireless'])):
1271
										?>
1272
										<tr>
1273
											<td colspan="2" valign="top" height="16"></td>
1274
										</tr>										
1275
										<tr>
1276
											<td colspan="2" valign="top" class="listtopic">Common wireless configuration - Settings apply to all wireless networks on <?=$wlanbaseif;?>.</td>
1277
										</tr>
1278
										<tr>
1279
											<td valign="top" class="vncellreq">Standard</td>
1280
											<td class="vtable">
1281
											<select name="standard" class="formselect" id="standard">
1282
												<?php
1283
												foreach($wl_modes as $wl_standard => $wl_channels) {
1284
													echo "<option ";
1285
													if ($pconfig['standard'] == "$wl_standard")
1286
														echo "selected ";
1287
													echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
1288
												}
1289
												?>
1290
											</select>
1291
										</td>
1292
									</tr>
1293
									<?php if (isset($wl_modes['11g'])): ?>
1294
									<tr>
1295
										<td valign="top" class="vncellreq">802.11g OFDM Protection Mode</td>
1296
										<td class="vtable">
1297
											<select name="protmode" class="formselect" id="protmode">
1298
												<option <? if ($pconfig['protmode'] == 'off') echo "selected";?> value="off">Protection mode off</option>
1299
												<option <? if ($pconfig['protmode'] == 'cts') echo "selected";?> value="cts">Protection mode CTS to self</option>
1300
												<option <? if ($pconfig['protmode'] == 'rtscts') echo "selected";?> value="rtscts">Protection mode RTS and CTS</option>
1301
											</select>
1302
											<br/>
1303
											For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network.
1304
											<br/>
1305
										</td>
1306
									</tr>
1307
									<?php else: ?>
1308
									<input name="protmode" type="hidden" id="protmode" value="off">
1309
									<?php endif; ?>
1310
										<tr>
1311
											<td valign="top" class="vncellreq">Transmit power</td>
1312
											<td class="vtable">
1313
												<select name="txpower" class="formselect" id="txpower">
1314
													<?
1315
													for($x = 99; $x > 0; $x--) {
1316
														if($pconfig["txpower"] == $x)
1317
															$SELECTED = " SELECTED";
1318
														else
1319
															$SELECTED = "";
1320
														echo "<option {$SELECTED}>{$x}</option>\n";
1321
													}
1322
													?>
1323
												</select><br/>
1324
												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.
1325
											</td>
1326
										</tr>
1327
										<tr>
1328
											<td valign="top" class="vncellreq">Channel</td>
1329
											<td class="vtable">
1330
												<select name="channel" class="formselect" id="channel">
1331
													<option <? if ($pconfig['channel'] == 0) echo "selected"; ?> value="0">Auto</option>
1332
													<?php
1333
													foreach($wl_modes as $wl_standard => $wl_channels) {
1334
														if($wl_standard == "11g") { $wl_standard = "11b/g"; }
1335
														else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
1336
														else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
1337
														foreach($wl_channels as $wl_channel) {
1338
															echo "<option ";
1339
															if ($pconfig['channel'] == "$wl_channel") {
1340
																echo "selected ";
1341
															}
1342
															echo "value=\"$wl_channel\">$wl_standard - $wl_channel</option>\n";
1343
														}
1344
													}
1345
													?>
1346
												</select>
1347
												<br/>
1348
												Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above.
1349
											</td>
1350
										</tr>
1351
										<tr>
1352
											<td valign="top" class="vncell">Distance setting</td>
1353
											<td class="vtable">
1354
												<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>">
1355
												<br/>
1356
												Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client<br/>
1357
												(measured in Meters and works only for Atheros based cards !)
1358
											</td>
1359
										</tr>
1360
										<tr>
1361
											<td valign="top" class="vncell">Regulatory settings</td>
1362
											<td class="vtable">
1363
												Regulatory domain<br/>
1364
												<select name="regdomain" class="formselect" id="regdomain">
1365
													<option <? if (empty($pconfig['regdomain'])) echo "selected"; ?> value="">Default</option>
1366
													<?php
1367
													foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
1368
														echo "<option ";
1369
														if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
1370
															echo "selected ";
1371
														}
1372
														echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
1373
													}
1374
													?>
1375
												</select>
1376
												<br/><br/>
1377
												Country (listed with country code and regulatory domain)<br/>
1378
												<select name="regcountry" class="formselect" id="regcountry">
1379
													<option <? if (empty($pconfig['regcountry'])) echo "selected"; ?> value="">Default</option>
1380
													<?php
1381
													foreach($wl_countries as $wl_country_key => $wl_country) {
1382
														echo "<option ";
1383
														if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
1384
															echo "selected ";
1385
														}
1386
														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";
1387
													}
1388
													?>
1389
												</select>
1390
												<br/>
1391
												Note: Any country setting other than "Default" will override the regulatory domain setting.
1392
												<br/><br/>
1393
												Location<br/>
1394
												<select name="reglocation" class="formselect" id="reglocation">
1395
													<option <? if ($pconfig['reglocation'] == 'indoor') echo "selected"; ?> value="indoor">Indoor</option>
1396
													<option <? if ($pconfig['reglocation'] == 'outdoor') echo "selected"; ?> value="outdoor">Outdoor</option>
1397
													<option <? if ($pconfig['reglocation'] == 'anywhere') echo "selected"; ?> value="anywhere">Anywhere</option>
1398
												</select>
1399
												<br/><br/>
1400
												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.
1401
												<br/>
1402
												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.
1403
											</td>
1404
										</tr>
1405
										<tr>
1406
											<td colspan="2" valign="top" height="16"></td>
1407
										</tr>										
1408
										<tr>
1409
											<td colspan="2" valign="top" class="listtopic">Wireless configuration</td>
1410
										</tr>
1411
									<tr>
1412
										<td valign="top" class="vncellreq">Mode</td>
1413
										<td class="vtable">
1414
											<select name="mode" class="formselect" id="mode">
1415
												<option <? if ($pconfig['mode'] == 'bss') echo "selected";?> value="bss">Infrastructure (BSS)</option>
1416
												<option <? if ($pconfig['mode'] == 'adhoc') echo "selected";?> value="adhoc">Ad-hoc (IBSS)</option>
1417
												<option <? if ($pconfig['mode'] == 'hostap') echo "selected";?> value="hostap">Access Point</option>
1418
											</select>
1419
										</td>
1420
									</tr>
1421
									<tr>
1422
										<td valign="top" class="vncellreq">SSID</td>
1423
										<td class="vtable">
1424
											<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>">
1425
										</td>
1426
                					</tr>
1427
									<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
1428
									<tr>
1429
										<td valign="top" class="vncell">Minimum wireless standard</td>
1430
										<td class="vtable">
1431
											<select name="puremode" class="formselect" id="puremode">
1432
												<option <? if ($pconfig['puremode'] == 'any') echo "selected";?> value="any">Any</option>
1433
												<?php if (isset($wl_modes['11g'])): ?>
1434
												<option <? if ($pconfig['puremode'] == '11g') echo "selected";?> value="11g">802.11g</option>
1435
												<?php endif; ?>
1436
												<option <? if ($pconfig['puremode'] == '11n') echo "selected";?> value="11n">802.11n</option>
1437
											</select>
1438
											<br/>
1439
											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).
1440
										</td>
1441
									</tr>
1442
									<?php elseif (isset($wl_modes['11g'])): ?>
1443
									<tr>
1444
										<td valign="top" class="vncell">802.11g only</td>
1445
										<td class="vtable">
1446
											<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <? if ($pconfig['puremode'] == '11g') echo "checked";?>>
1447
											<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).
1448
										</td>
1449
									</tr>
1450
									<?php endif; ?>
1451
									<tr>
1452
										<td valign="top" class="vncell">Allow intra-BSS communication</td>
1453
										<td class="vtable">
1454
											<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <? if ($pconfig['apbridge_enable']) echo "checked";?>>
1455
											<br/>
1456
											When operating as an access point, enable this if you want to pass packets between wireless clients directly.
1457
											<br/>
1458
											Disabling the internal bridging is useful when traffic is to be processed with packet filtering.
1459
										</td>
1460
									</tr>
1461
									<tr>
1462
										<td valign="top" class="vncell">Enable WME</td>
1463
										<td class="vtable">
1464
											<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <? if ($pconfig['wme_enable']) echo "checked";?>>
1465
											<br/>Setting this option will force the card to use WME (wireless QoS).
1466
										</td>
1467
									</tr>
1468
									<tr>
1469
										<td valign="top" class="vncell">Enable Hide SSID</td>
1470
										<td class="vtable">
1471
											<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <? if ($pconfig['hidessid_enable']) echo "checked";?>>
1472
											<br/>
1473
											Setting this option will force the card to NOT broadcast its SSID
1474
											<br/>
1475
											(this might create problems for some clients). </td>
1476
										</tr>
1477
										<tr>
1478
											<td valign="top" class="vncell">WEP</td>
1479
											<td class="vtable"> 
1480
												<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <? if ($pconfig['wep_enable']) echo "checked"; ?>>
1481
												<strong>Enable WEP</strong>
1482
												<table border="0" cellspacing="0" cellpadding="0">
1483
													<tr>
1484
														<td>&nbsp;</td>
1485
														<td>&nbsp;</td>
1486
														<td>&nbsp;TX key&nbsp;</td>
1487
													</tr>
1488
													<tr>
1489
														<td>Key 1:&nbsp;&nbsp;</td>
1490
														<td>
1491
															<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>">
1492
														</td>
1493
														<td align="center">
1494
															<input name="txkey" type="radio" value="1" <? if ($pconfig['txkey'] == 1) echo "checked";?>>
1495
														</td>
1496
													</tr>
1497
													<tr>
1498
														<td>Key 2:&nbsp;&nbsp;</td>
1499
														<td>
1500
															<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>">
1501
														</td>
1502
														<td align="center">
1503
															<input name="txkey" type="radio" value="2" <? if ($pconfig['txkey'] == 2) echo "checked";?>>
1504
														</td>
1505
													</tr>
1506
													<tr>
1507
														<td>Key 3:&nbsp;&nbsp;</td>
1508
														<td>
1509
															<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>">
1510
														</td>
1511
														<td align="center">
1512
															<input name="txkey" type="radio" value="3" <? if ($pconfig['txkey'] == 3) echo "checked";?>>
1513
														</td>
1514
													</tr>
1515
													<tr>
1516
														<td>Key 4:&nbsp;&nbsp;</td>
1517
														<td>
1518
															<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>">
1519
														</td>
1520
														<td align="center">
1521
															<input name="txkey" type="radio" value="4" <? if ($pconfig['txkey'] == 4) echo "checked";?>>
1522
														</td>
1523
													</tr>
1524
												</table>
1525
												<br/>
1526
												40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'.<br/>
1527
												104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'.
1528
											</td>
1529
										</tr>
1530
										<tr>
1531
											<td valign="top" class="vncell">WPA</td>
1532
											<td class="vtable">
1533
												<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <? if ($pconfig['wpa_enable']) echo "checked"; ?>>
1534
												<strong>Enable WPA</strong>
1535
												<br/><br/>
1536
												<table border="0" cellspacing="0" cellpadding="0">
1537
													<tr>
1538
														<td>&nbsp;</td>
1539
														<td>&nbsp;WPA Pre Shared Key&nbsp;</td>
1540
													</tr>
1541
													<tr>
1542
														<td>PSK:&nbsp;&nbsp;</td>
1543
														<td>
1544
															<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>">
1545
														</td>
1546
													</tr>
1547
												</table>
1548
												<br/>Passphrase must be from 8 to 63 characters.
1549
											</td>
1550
										</tr>
1551
										<tr>
1552
											<td valign="top" class="vncell">WPA Mode</td>
1553
											<td class="vtable">
1554
												<select name="wpa_mode" class="formselect" id="wpa_mode">
1555
													<option <? if ($pconfig['wpa_mode'] == '1') echo "selected";?> value="1">WPA</option>
1556
													<option <? if ($pconfig['wpa_mode'] == '2') echo "selected";?> value="2">WPA2</option>
1557
													<option <? if ($pconfig['wpa_mode'] == '3') echo "selected";?> value="3">Both</option>
1558
												</select>
1559
											</td>
1560
										</tr>
1561
										<tr>
1562
											<td valign="top" class="vncell">WPA Key Management Mode</td>
1563
											<td class="vtable"> 
1564
												<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
1565
													<option <? if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected";?> value="WPA-PSK">Pre Shared Key</option>
1566
													<option <? if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected";?> value="WPA-EAP">Extensible Authentication Protocol</option>
1567
													<option <? if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected";?> value="WPA-PSK WPA-EAP">Both</option>
1568
 												</select>
1569
											</td>
1570
										</tr>
1571
										<tr>
1572
											<td valign="top" class="vncell">Authentication</td>
1573
											<td class="vtable">
1574
												<select name="auth_algs" class="formselect" id="auth_algs">
1575
													<option <? if ($pconfig['auth_algs'] == '1') echo "selected";?> value="1">Open System Authentication</option>
1576
													<option <? if ($pconfig['auth_algs'] == '2') echo "selected";?> value="2">Shared Key Authentication</option>
1577
													<option <? if ($pconfig['auth_algs'] == '3') echo "selected";?> value="3">Both</option>
1578
												</select>
1579
												<br/>Note: Shared Key Authentication requires WEP.</br>
1580
											</td>
1581
										</tr>
1582
										<tr>
1583
											<td valign="top" class="vncell">WPA Pairwise</td>
1584
											<td class="vtable">
1585
												<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
1586
													<option <? if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected";?> value="CCMP TKIP">Both</option>
1587
													<option <? if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected";?> value="CCMP">AES (recommended)</option>
1588
													<option <? if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected";?> value="TKIP">TKIP</option>
1589
												</select>
1590
											</td>
1591
										</tr>
1592
										<tr>
1593
											<td valign="top" class="vncell">Key Rotation</td>
1594
											<td class="vtable">
1595
												<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";?>">
1596
												<br/>Allowed values are 1-9999 but should not be longer than Master Key Regeneration time.
1597
											</td>
1598
										</tr>
1599
										<tr>
1600
											<td valign="top" class="vncell">Master Key Regeneration</td>
1601
											<td class="vtable">
1602
												<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";?>">
1603
												<br/>Allowed values are 1-9999 but should not be shorter than Key Rotation time.
1604
											</td>
1605
										</tr>
1606
										<tr>
1607
											<td valign="top" class="vncell">Strict Key Regeneration</td>
1608
											<td class="vtable">
1609
												<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <? if ($pconfig['wpa_strict_rekey']) echo "checked"; ?>>
1610
												<br/>Setting this option will force the AP to rekey whenever a client disassociates.
1611
											</td>
1612
										</tr>
1613
										<tr>
1614
											<td valign="top" class="vncell">Enable IEEE802.1X Authentication</td>
1615
											<td class="vtable">
1616
												<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <? if ($pconfig['ieee8021x']) echo "checked";?>>
1617
												<br/>Setting this option will enable 802.1x authentication.
1618
											</td>
1619
										</tr>
1620
										<tr>
1621
											<td valign="top" class="vncell">802.1X Authentication Server IP Address</td>
1622
											<td class="vtable">
1623
												<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>">
1624
												<br/>Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)
1625
											</td>
1626
										</tr>
1627
										<tr>
1628
											<td valign="top" class="vncell">802.1X Authentication Server Port</td>
1629
											<td class="vtable">
1630
												<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>">
1631
												<br/>Leave blank for the default 1812 port.
1632
											</td>
1633
										</tr>
1634
										<tr>
1635
											<td valign="top" class="vncell">802.1X Authentication Server Shared Secret</td>
1636
											<td class="vtable">
1637
												<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']);?>">
1638
												<br/>
1639
											</td>
1640
										</tr>
1641
									<? endif; ?>
1642
									<tr>
1643
										<td colspan="2" valign="top" height="16"></td>
1644
									</tr>
1645
									<tr>
1646
										<td colspan="2" valign="top" class="listtopic">Private networks</td>
1647
									</tr>
1648
									<tr>
1649
										<td valign="middle" class="vncell">&nbsp;</td>
1650
										<td class="vtable">
1651
											<a name="rfc1918"></a> 
1652
											<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
1653
											<strong>Block private networks</strong><br>
1654
											When set, this option blocks traffic from IP addresses that are reserved 
1655
											for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as 
1656
											well as loopback addresses (127/8).&nbsp;&nbsp; You should generally
1657
											leave this option turned on, unless your WAN network lies in such 
1658
											a private address space, too. 
1659
										</td>
1660
									</tr>
1661
									<tr>
1662
										<td valign="middle" class="vncell">&nbsp;</td>
1663
										<td class="vtable"> 
1664
											<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
1665
											<strong>Block bogon networks</strong><br>
1666
											When set, this option blocks traffic from IP addresses that are reserved 
1667
											(but not RFC 1918) or not yet assigned by IANA.&nbsp;&nbsp;
1668
											Bogons are prefixes that should never appear in the Internet routing table, 
1669
											and obviously should not appear as the source address in any packets you receive.
1670
										</td>
1671
									</tr>
1672
								</tr>
1673
				</table>
1674
				</div>
1675
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
1676
								<tr>
1677
									<td width="100" valign="top">
1678
										&nbsp;
1679
									</td>
1680
									<td>
1681
										<br/>
1682
										<input id="save" name="Submit" type="submit" class="formbtn" value="Save"> 
1683
										<input id="cancel" type="button" class="formbtn" value="Cancel" onclick="history.back()">
1684
										<input name="if" type="hidden" id="if" value="<?=$if;?>">
1685
									</td>
1686
								</tr>
1687
							</table>
1688
						</td>
1689
					</table>
1690
					</div>
1691
					</td></tr>
1692
					</table>
1693
				</form>
1694
				<script type="text/javascript">
1695
					var gatewayip;
1696
					var name;
1697
					function show_add_gateway() {
1698
						document.getElementById("addgateway").style.display = '';
1699
						document.getElementById("addgwbox").style.display = 'none';
1700
						document.getElementById("gateway").style.display = 'none';
1701
						document.getElementById("save").style.display = 'none';
1702
						document.getElementById("cancel").style.display = 'none';
1703
						document.getElementById("gwsave").style.display = '';
1704
						document.getElementById("gwcancel").style.display = '';
1705
						$('notebox').innerHTML="";
1706
					}
1707
					function hide_add_gateway() {
1708
						document.getElementById("addgateway").style.display = 'none';
1709
						document.getElementById("addgwbox").style.display = '';	
1710
						document.getElementById("gateway").style.display = '';
1711
						document.getElementById("save").style.display = '';
1712
						document.getElementById("cancel").style.display = '';
1713
						document.getElementById("gwsave").style.display = '';
1714
						document.getElementById("gwcancel").style.display = '';
1715
					}
1716
					function hide_add_gatewaysave() {
1717
						document.getElementById("addgateway").style.display = 'none';
1718
						$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif"> One moment please...';
1719
						var iface = $F('if');
1720
						name = $('name').getValue();
1721
						var descr = $('gatewaydescr').getValue();
1722
						gatewayip = $('gatewayip').getValue();
1723
						addrtype = $('addrtype').getValue();
1724
						var defaultgw = $('defaultgw').getValue();
1725
						var url = "system_gateways_edit.php";
1726
						var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip) + '&type=' + escape(addrtype);
1727
						var myAjax = new Ajax.Request(
1728
							url,
1729
							{
1730
								method: 'post',
1731
								parameters: pars,
1732
								onFailure: report_failure,
1733
								onComplete: save_callback
1734
							});	
1735
					}
1736
					function addOption(selectbox,text,value)
1737
					{
1738
						var optn = document.createElement("OPTION");
1739
						optn.text = text;
1740
						optn.value = value;
1741
						selectbox.options.add(optn);
1742
						selectbox.selectedIndex = (selectbox.options.length-1);
1743
						$('notebox').innerHTML="<p/><strong>NOTE:</strong> You can manage Gateways <a target='_new' href='system_gateways.php'>here</a>.";
1744
					}				
1745
					function report_failure() {
1746
						alert("Sorry, we could not create your gateway at this time.");
1747
						hide_add_gateway();
1748
					}
1749
					function save_callback(transport) {
1750
						var response = transport.responseText;
1751
						if(response) {
1752
							document.getElementById("addgateway").style.display = 'none';
1753
							hide_add_gateway();
1754
							$('status').innerHTML = '';
1755
							addOption($('gateway'), name, name);
1756
							// Auto submit form?
1757
							//document.iform.submit();
1758
							//$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif">';
1759
						} else {
1760
							report_failure();
1761
						}
1762
					}
1763
					<?php
1764
					if ($if == "wan" || $if == "lan")
1765
						echo "\$('allcfg').show();";
1766
					else
1767
						echo "show_allcfg(document.iform.enable);";
1768
					echo "updateType('{$pconfig['type']}')";
1769
					?>
1770
				</script>
1771
				<?php include("fend.inc"); ?>
1772
		</body>
1773
</html>
(78-78/216)