Project

General

Profile

Download (71.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
	if (isset($wancfg['wireless'])) {
300
		interface_sync_wireless_clones($wancfg, false);
301
	}
302
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
303
	mark_subsystem_dirty('interfaces');
304
	header("Location: interfaces.php?if={$if}");
305
	exit;
306
} else
307

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

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

    
366
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
367
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
368
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) 
369
		$input_errors[] = "A valid IP address must be specified.";
370
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) 
371
		$input_errors[] = "A valid subnet bit count must be specified.";
372
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) 
373
		$input_errors[] = "A valid alias IP address must be specified.";
374
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) 
375
		$input_errors[] = "A valid alias subnet bit count must be specified.";
376
	if ($_POST['gateway'] != "none") {
377
		$match = false;
378
		foreach($a_gateways as $gateway) {
379
			if(in_array($_POST['gateway'], $gateway)) {
380
				$match = true;
381
			}
382
		}
383
		if(!$match) {
384
			$input_errors[] = "A valid gateway must be specified.";
385
		}
386
	}
387
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) 
388
		$input_errors[] = "A valid point-to-point IP address must be specified.";
389
	if (($_POST['provider'] && !is_domain($_POST['provider']))) 
390
		$input_errors[] = "The service name contains invalid characters.";
391
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) 
392
		$input_errors[] = "The idle timeout value must be an integer.";
393
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) && 
394
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) 
395
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
396
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) && 
397
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) 
398
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
399
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) 
400
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
401
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) 
402
		$input_errors[] = "A valid PPTP local IP address must be specified.";
403
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) 
404
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
405
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) 
406
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
407
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) 
408
		$input_errors[] = "The idle timeout value must be an integer.";
409
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) 
410
		$input_errors[] = "A valid MAC address must be specified.";
411
	if ($_POST['mtu'] && ($_POST['mtu'] < 576)) 
412
		$input_errors[] = "The MTU must be greater than 576 bytes.";
413
	/* Wireless interface? */
414
	if (isset($wancfg['wireless'])) {
415
		$reqdfields = explode(" ", "mode ssid");
416
		$reqdfieldsn = explode(",", "Mode,SSID");
417
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
418
		check_wireless_mode();
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
function check_wireless_mode() {
785
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
786

    
787
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
788
		return;
789

    
790
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
791
		$clone_count = 1;
792
	else
793
		$clone_count = 0;
794
	if (is_array($config['wireless']['clone'])) {
795
		foreach ($config['wireless']['clone'] as $clone) {
796
			if ($clone['if'] == $wlanbaseif)
797
				$clone_count++;
798
		}
799
	}
800
	if ($clone_count > 1) {
801
		$old_wireless_mode = $wancfg['wireless']['mode'];
802
		$wancfg['wireless']['mode'] = $_POST['mode'];
803
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
804
			$input_errors[] = "Unable to change mode to {$wlan_modes[$wancfg['wireless']['mode']]}.  You may already have the maximum number of wireless clones supported in this mode.";
805
		} else {
806
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
807
		}
808
		$wancfg['wireless']['mode'] = $old_wireless_mode;
809
	}
810
}
811

    
812
$pgtitle = array("Interfaces", $pconfig['descr']);
813
$closehead = false;
814
include("head.inc");
815
$types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" => "PPPoE", "pptp" => "PPTP" /* , "carpdev-dhcp" => "CarpDev"*/); 
816

    
817
?>
818

    
819
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
820
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
821
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
822
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
823

    
824
<script type="text/javascript">
825
	function updateType(t){
826
		switch(t) {
827
	<?php
828
		/* OK, so this is sick using php to generate javascript, but it needed to be done */
829
		foreach ($types as $key => $val) {
830
			echo "case \"{$key}\": {\n";
831
			$t = $types;
832
			foreach ($t as $k => $v) {
833
				if ($k != $key) {
834
					echo "$('{$k}').hide();\n";
835
				}
836
			}
837
			echo "}\n";
838
		}
839
	?>
840
		}
841
		$(t).show();
842
	}
843

    
844
	function show_allcfg(obj) {
845
		if (obj.checked)
846
			$('allcfg').show();
847
		else
848
			$('allcfg').hide();
849
	}
850
	
851
	function show_periodic_reset(obj) {
852
		if (obj.checked)
853
			$('presetwrap').show();
854
		else
855
			$('presetwrap').hide();
856
	}
857

    
858
	function show_mon_config() {
859
		document.getElementById("showmonbox").innerHTML='';
860
		aodiv = document.getElementById('showmon');
861
		aodiv.style.display = "block";
862
	}
863

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