Project

General

Profile

Download (67.8 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
if ($if == "wan" || $if == "lan")
165
	$pconfig['enable'] = true;
166
else
167
	$pconfig['enable'] = isset($wancfg['enable']);
168

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

    
177
switch($wancfg['ipaddr']) {
178
	case "dhcp":
179
		$pconfig['type'] = "dhcp";
180
		break;
181
	case "carpdev-dhcp":
182
		$pconfig['type'] = "carpdev-dhcp";
183
		$pconfig['ipaddr'] = "";
184
		break;
185
	case "pppoe":
186
		$pconfig['type'] = "pppoe";
187
		break;
188
	case "pptp":
189
		$pconfig['type'] = "pptp";
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
			$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
198
		} else {
199
			$pconfig['type'] = "none";
200
		}
201
		break;
202
}
203

    
204
// Handle PPP type interfaces
205
if($wancfg['serialport']) 
206
	$pconfig['type'] = "none";
207

    
208
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
209
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
210
$pconfig['spoofmac'] = $wancfg['spoofmac'];
211
$pconfig['mtu'] = $wancfg['mtu'];
212

    
213
/* Wireless interface? */
214
if (isset($wancfg['wireless'])) {
215
	/* Get wireless modes */
216
	$wlanif = get_real_interface($if);
217
	interface_wireless_clone($wlanif, $wancfg);
218
	$wl_modes = get_wireless_modes($if);
219
	$pconfig['standard'] = $wancfg['wireless']['standard'];
220
	$pconfig['mode'] = $wancfg['wireless']['mode'];
221
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
222
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
223
	$pconfig['channel'] = $wancfg['wireless']['channel'];
224
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
225
	$pconfig['distance'] = $wancfg['wireless']['distance'];
226
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
227
	$pconfig['pureg_enable'] = isset($wancfg['wireless']['pureg']['enable']);
228
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
229
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
230
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
231
	if (is_array($wancfg['wireless']['wpa'])) {
232
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
233
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
234
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
235
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
236
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
237
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
238
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
239
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
240
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
241
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
242
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
243
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
244
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
245
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
246
	}
247
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
248
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
249
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
250
		$i = 1;
251
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
252
			$pconfig['key' . $i] = $wepkey['value'];
253
			if (isset($wepkey['txkey']))
254
				$pconfig['txkey'] = $i;
255
			$i++;
256
		}
257
		if (!isset($wepkey['txkey']))
258
			$pconfig['txkey'] = 1;
259
	}
260
}
261

    
262
if ($_POST['apply']) {
263
	unset($input_errors);
264
	if (!is_subsystem_dirty('interfaces'))
265
		$intput_errors[] = "You have already applied your settings!";
266
	else {	
267
		unlink_if_exists("{$g['tmp_path']}/config.cache");
268
		clear_subsystem_dirty('interfaces');
269
		interface_configure($if, true);
270
		
271
		/* restart snmp so that it binds to correct address */		
272
		services_snmpd_configure();		
273
		if ($if == "lan") 		
274
			$savemsg = "The changes have been applied.  You may need to correct your web browser's IP address.";
275

    
276
		/* sync filter configuration */
277
		setup_gateways_monitor();
278

    
279
		clear_subsystem_dirty('staticroutes');
280
		
281
		filter_configure();
282
		
283
		enable_rrd_graphing();
284
	}
285
	header("Location: interfaces.php?if={$if}");
286
	exit;
287
} else
288

    
289
if ($_POST && $_POST['enable'] == "no") {
290
	unset($wancfg['enable']);
291
	interface_bring_down($if);
292
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
293
	mark_subsystem_dirty('interfaces');
294
	header("Location: interfaces.php?if={$if}");
295
	exit;
296
} else
297

    
298
if ($_POST) {
299
	unset($input_errors);
300
	$pconfig = $_POST;
301
	conf_mount_rw();
302
	/* filter out spaces from descriptions  */
303
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
304
	/* okay first of all, cause we are just hiding the PPPoE HTML
305
	 * fields releated to PPPoE resets, we are going to unset $_POST
306
	 * vars, if the reset feature should not be used. Otherwise the
307
	 * data validation procedure below, may trigger a false error
308
	 * message.
309
	 */
310
	if (empty($_POST['pppoe_preset'])) {
311
		unset($_POST['pppoe_pr_type']);                
312
		unset($_POST['pppoe_resethour']);
313
		unset($_POST['pppoe_resetminute']);
314
		unset($_POST['pppoe_resetdate']);
315
		unset($_POST['pppoe_pr_preset_val']);
316
	}
317
	/* optional interface if list */
318
	$iflist = get_configured_interface_with_descr();
319
	/* description unique? */
320
	foreach ($iflist as $ifent => $ifdescr) {
321
		if ($if != $ifent && $ifdescr == $_POST['descr'])
322
			$input_errors[] = "An interface with the specified description already exists.";
323
	}
324
	/* input validation */
325
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && $_POST['type'] != "static")
326
		$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.";
327

    
328
	switch($_POST['type']) {
329
		case "static":
330
			$reqdfields = explode(" ", "ipaddr subnet gateway");
331
			$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
332
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
333
			break;
334
		case "PPPoE":
335
			if ($_POST['pppoe_dialondemand']) {
336
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
337
				$reqdfieldsn = explode(",", "PPPoE username,PPPoE password,Dial on demand,Idle timeout value");
338
			} else {
339
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
340
				$reqdfieldsn = explode(",", "PPPoE username,PPPoE password");
341
			}
342
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
343
			break;
344
		case "PPTP":
345
			if ($_POST['pptp_dialondemand']) {
346
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
347
				$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address,Dial on demand,Idle timeout value");
348
			} else {
349
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
350
				$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address");
351
			}
352
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
353
			break;
354
	}
355

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

    
444
		if ($_POST['passphrase']) {
445
                	$passlen = strlen($_POST['passphrase']);
446
                	if ($passlen < 8 || $passlen > 64)
447
                        	$input_errors[] = "The length of the passphrase should be between 8 and 63 characters.";
448
		}
449
	}
450
	if (!$input_errors) {
451
		unset($wancfg['ipaddr']);
452
		unset($wancfg['subnet']);
453
		unset($wancfg['gateway']);
454
		unset($wancfg['pointtopoint']);
455
		unset($wancfg['dhcphostname']);
456
		unset($wancfg['pppoe_username']);
457
		unset($wancfg['pppoe_password']);
458
		unset($wancfg['pptp_username']);
459
		unset($wancfg['pptp_password']);
460
		unset($wancfg['provider']);
461
		unset($wancfg['ondemand']);
462
		unset($wancfg['timeout']);
463
		if ($wancfg['pppoe']['pppoe-reset-type'])
464
			unset($wancfg['pppoe']['pppoe-reset-type']);
465
		unset($wancfg['local']);
466
		unset($wancfg['subnet']);
467
		unset($wancfg['remote']);
468

    
469
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
470
		if ($if == "wan" || $if == "lan") {
471
			$wancfg['enable'] = true;
472
		} else {
473
			$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
474
		}
475

    
476
		/* for dynamic interfaces we tack a gateway item onto the array to prevent system
477
		 * log messages from appearing. They can also manually add these items */
478
		/* 1st added gateway gets a default bit */
479
		$gateway_item = array();
480
		if(empty($a_gateways)) {
481
			$gateway_item['defaultgw'] = "true";
482
		} else {
483
			/* check for duplicates */
484
			$skip = false;
485
			foreach($a_gateways as $item) {
486
				if(($item['interface'] == "$if") && ($item['gateway'] == "dynamic")) {
487
					$skip = true;
488
				}
489
			}
490
			if($skip == false) {
491
				$gateway_item['gateway'] = "dynamic";
492
				$gateway_item['descr'] = "Interface {$if} dynamic gateway";
493
				$gateway_item['name'] = "GW_" . strtoupper($if);
494
				$gateway_item['interface'] = "{$if}";
495
			} else {
496
				unset($gateway_item);
497
			}
498
		}
499

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

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

    
680
function handle_wireless_post() {
681
	global $_POST, $config, $g, $wancfg, $if;
682
	if (!is_array($wancfg['wireless']))
683
		$wancfg['wireless'] = array();
684
	$wancfg['wireless']['standard'] = $_POST['standard'];
685
	$wancfg['wireless']['mode'] = $_POST['mode'];
686
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
687
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
688
	$wancfg['wireless']['channel'] = $_POST['channel'];
689
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
690
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
691
	$wancfg['wireless']['distance'] = $_POST['distance'];
692
	if (!is_array($wancfg['wireless']['wpa']))
693
		$wancfg['wireless']['wpa'] = array();
694
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
695
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
696
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
697
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
698
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
699
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
700
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
701
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
702
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
703
	if ($_POST['hidessid_enable'] == "yes")
704
		$wancfg['wireless']['hidessid']['enable'] = true;
705
	else if (isset($wancfg['wireless']['hidessid']['enable']))
706
		unset($wancfg['wireless']['hidessid']['enable']);
707
	if ($_POST['mac_acl_enable'] == "yes")
708
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
709
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
710
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
711
	if ($_POST['ieee8021x'] == "yes")
712
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
713
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
714
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
715
	if ($_POST['wpa_strict_rekey'] == "yes")
716
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
717
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
718
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
719
	if ($_POST['debug_mode'] == "yes")
720
		$wancfg['wireless']['wpa']['debug_mode'] = true;
721
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
722
		sunset($wancfg['wireless']['wpa']['debug_mode']);
723
	if ($_POST['wpa_enable'] == "yes")
724
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
725
	else if (isset($wancfg['wireless']['wpa']['enable']))
726
		unset($wancfg['wireless']['wpa']['enable']);
727
	if ($_POST['wep_enable'] == "yes") {
728
		if (!is_array($wancfg['wireless']['wep']))
729
			$wancfg['wireless']['wep'] = array();
730
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
731
	} else if (isset($wancfg['wireless']['wep']))
732
		unset($wancfg['wireless']['wep']);
733
	if ($_POST['wme_enable'] == "yes") {
734
		if (!is_array($wancfg['wireless']['wme']))
735
			$wancfg['wireless']['wme'] = array();
736
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
737
	} else if (isset($wancfg['wireless']['wme']['enable']))
738
		unset($wancfg['wireless']['wme']['enable']);
739
	if ($_POST['pureg_enable'] == "yes") {
740
		if (!is_array($wancfg['wireless']['pureg']))
741
			$wancfg['wireless']['pureg'] = array();
742
		$wancfg['wireless']['pureg']['enable'] = $_POST['pureg_enable'] = true;
743
	} else if (isset($wancfg['wireless']['pureg']['enable']))
744
		unset($wancfg['wireless']['pureg']['enable']);
745
	if ($_POST['apbridge_enable'] == "yes") {
746
		if (!is_array($wancfg['wireless']['apbridge']))
747
			$wancfg['wireless']['apbridge'] = array();
748
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
749
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
750
		unset($wancfg['wireless']['apbridge']['enable']);
751
	if ($_POST['standard'] == "11a Turbo") {
752
		if (!is_array($wancfg['wireless']['turbo']))
753
			$wancfg['wireless']['turbo'] = array();
754
		$wancfg['wireless']['turbo']['enable'] = true;
755
	} else if (isset($wancfg['wireless']['turbo']['enable']))
756
		unset($wancfg['wireless']['turbo']['enable']);
757
	$wancfg['wireless']['wep']['key'] = array();
758
	for ($i = 1; $i <= 4; $i++) {
759
		if ($_POST['key' . $i]) {
760
			$newkey = array();
761
			$newkey['value'] = $_POST['key' . $i];
762
			if ($_POST['txkey'] == $i)
763
				$newkey['txkey'] = true;
764
			$wancfg['wireless']['wep']['key'][] = $newkey;
765
		}
766
	}
767
}
768

    
769
$pgtitle = array("Interfaces", $pconfig['descr']);
770
$closehead = false;
771
include("head.inc");
772
$types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" => "PPPoE", "pptp" => "PPTP" /* , "carpdev-dhcp" => "CarpDev"*/); 
773

    
774
?>
775

    
776
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
777
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
778
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
779
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
780

    
781
<script type="text/javascript">
782
	function updateType(t){
783
		switch(t) {
784
	<?php
785
		/* OK, so this is sick using php to generate javascript, but it needed to be done */
786
		foreach ($types as $key => $val) {
787
			echo "case \"{$key}\": {\n";
788
			$t = $types;
789
			foreach ($t as $k => $v) {
790
				if ($k != $key) {
791
					echo "$('{$k}').hide();\n";
792
				}
793
			}
794
			echo "}\n";
795
		}
796
	?>
797
		}
798
		$(t).show();
799
	}
800

    
801
	function show_allcfg(obj) {
802
		if (obj.checked)
803
			$('allcfg').show();
804
		else
805
			$('allcfg').hide();
806
	}
807
	
808
	function show_periodic_reset(obj) {
809
		if (obj.checked)
810
			$('presetwrap').show();
811
		else
812
			$('presetwrap').hide();
813
	}
814

    
815
	function show_mon_config() {
816
		document.getElementById("showmonbox").innerHTML='';
817
		aodiv = document.getElementById('showmon');
818
		aodiv.style.display = "block";
819
	}
820

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