Project

General

Profile

Download (70.2 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
	if (!does_interface_exist($wlanif))
218
		interface_wireless_clone($wlanif, $wancfg);
219
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
220
	$wl_modes = get_wireless_modes($if);
221
	$pconfig['standard'] = $wancfg['wireless']['standard'];
222
	$pconfig['mode'] = $wancfg['wireless']['mode'];
223
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
224
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
225
	$pconfig['channel'] = $wancfg['wireless']['channel'];
226
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
227
	$pconfig['distance'] = $wancfg['wireless']['distance'];
228
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
229
	$pconfig['pureg_enable'] = isset($wancfg['wireless']['pureg']['enable']);
230
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
231
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
232
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
233
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
234
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
235
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
236
	if (is_array($wancfg['wireless']['wpa'])) {
237
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
238
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
239
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
240
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
241
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
242
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
243
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
244
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
245
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
246
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
247
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
248
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
249
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
250
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
251
	}
252
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
253
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
254
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
255
		$i = 1;
256
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
257
			$pconfig['key' . $i] = $wepkey['value'];
258
			if (isset($wepkey['txkey']))
259
				$pconfig['txkey'] = $i;
260
			$i++;
261
		}
262
		if (!isset($wepkey['txkey']))
263
			$pconfig['txkey'] = 1;
264
	}
265
}
266

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

    
284
		/* sync filter configuration */
285
		setup_gateways_monitor();
286

    
287
		clear_subsystem_dirty('staticroutes');
288
		
289
		filter_configure();
290
		
291
		enable_rrd_graphing();
292
	}
293
	header("Location: interfaces.php?if={$if}");
294
	exit;
295
} else
296

    
297
if ($_POST && $_POST['enable'] != "yes") {
298
	unset($wancfg['enable']);
299
	interface_bring_down($if);
300
	if (isset($wancfg['wireless'])) {
301
		interface_sync_wireless_clones($wancfg, false);
302
	}
303
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
304
	mark_subsystem_dirty('interfaces');
305
	header("Location: interfaces.php?if={$if}");
306
	exit;
307
} else
308

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

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

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

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

    
480
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
481
		if ($if == "wan" || $if == "lan") {
482
			$wancfg['enable'] = true;
483
		} else {
484
			$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
485
		}
486

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

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

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

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

    
784
$pgtitle = array("Interfaces", $pconfig['descr']);
785
$closehead = false;
786
include("head.inc");
787
$types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" => "PPPoE", "pptp" => "PPTP" /* , "carpdev-dhcp" => "CarpDev"*/); 
788

    
789
?>
790

    
791
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
792
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
793
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
794
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
795

    
796
<script type="text/javascript">
797
	function updateType(t){
798
		switch(t) {
799
	<?php
800
		/* OK, so this is sick using php to generate javascript, but it needed to be done */
801
		foreach ($types as $key => $val) {
802
			echo "case \"{$key}\": {\n";
803
			$t = $types;
804
			foreach ($t as $k => $v) {
805
				if ($k != $key) {
806
					echo "$('{$k}').hide();\n";
807
				}
808
			}
809
			echo "}\n";
810
		}
811
	?>
812
		}
813
		$(t).show();
814
	}
815

    
816
	function show_allcfg(obj) {
817
		if (obj.checked)
818
			$('allcfg').show();
819
		else
820
			$('allcfg').hide();
821
	}
822
	
823
	function show_periodic_reset(obj) {
824
		if (obj.checked)
825
			$('presetwrap').show();
826
		else
827
			$('presetwrap').hide();
828
	}
829

    
830
	function show_mon_config() {
831
		document.getElementById("showmonbox").innerHTML='';
832
		aodiv = document.getElementById('showmon');
833
		aodiv.style.display = "block";
834
	}
835

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