Project

General

Profile

Download (72.5 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['puren_enable'] = isset($wancfg['wireless']['puren']['enable']);
231
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
232
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
233
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
234
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
235
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
236
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
237
	if (is_array($wancfg['wireless']['wpa'])) {
238
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
239
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
240
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
241
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
242
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
243
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
244
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
245
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
246
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
247
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
248
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
249
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
250
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
251
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
252
	}
253
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
254
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
255
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
256
		$i = 1;
257
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
258
			$pconfig['key' . $i] = $wepkey['value'];
259
			if (isset($wepkey['txkey']))
260
				$pconfig['txkey'] = $i;
261
			$i++;
262
		}
263
		if (!isset($wepkey['txkey']))
264
			$pconfig['txkey'] = 1;
265
	}
266
}
267

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

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

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

    
298
if ($_POST && $_POST['enable'] != "yes") {
299
	unset($wancfg['enable']);
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
		check_wireless_mode();
420
		/* loop through keys and enforce size */
421
		for ($i = 1; $i <= 4; $i++) {
422
			if ($_POST['key' . $i]) {
423
				/* 64 bit */
424
				if (strlen($_POST['key' . $i]) == 5)
425
					continue;
426
				if (strlen($_POST['key' . $i]) == 10) {
427
					/* hex key */
428
					if (stristr($_POST['key' . $i], "0x") == false) {
429
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
430
					}
431
					continue;
432
				}
433
				if (strlen($_POST['key' . $i]) == 12) {
434
					/* hex key */
435
					if(stristr($_POST['key' . $i], "0x") == false) {
436
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
437
					}
438
					continue;
439
				}
440
				/* 128 bit */
441
				if (strlen($_POST['key' . $i]) == 13)
442
					continue;
443
				if (strlen($_POST['key' . $i]) == 26) {
444
					/* hex key */
445
					if (stristr($_POST['key' . $i], "0x") == false)
446
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
447
					continue;
448
				}
449
				if(strlen($_POST['key' . $i]) == 28)
450
					continue;
451
				$input_errors[] =  "Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.";
452
				break;
453
			}
454
		}
455

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

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

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

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

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

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

    
791
function check_wireless_mode() {
792
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
793

    
794
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
795
		return;
796

    
797
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
798
		$clone_count = 1;
799
	else
800
		$clone_count = 0;
801
	if (is_array($config['wireless']['clone'])) {
802
		foreach ($config['wireless']['clone'] as $clone) {
803
			if ($clone['if'] == $wlanbaseif)
804
				$clone_count++;
805
		}
806
	}
807
	if ($clone_count > 1) {
808
		$old_wireless_mode = $wancfg['wireless']['mode'];
809
		$wancfg['wireless']['mode'] = $_POST['mode'];
810
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
811
			$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.";
812
		} else {
813
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
814
		}
815
		$wancfg['wireless']['mode'] = $old_wireless_mode;
816
	}
817
}
818

    
819
$pgtitle = array("Interfaces", $pconfig['descr']);
820
$closehead = false;
821
include("head.inc");
822
$types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" => "PPPoE", "pptp" => "PPTP" /* , "carpdev-dhcp" => "CarpDev"*/); 
823

    
824
?>
825

    
826
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
827
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
828
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
829
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
830

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

    
851
	function show_allcfg(obj) {
852
		if (obj.checked)
853
			$('allcfg').show();
854
		else
855
			$('allcfg').hide();
856
	}
857
	
858
	function show_periodic_reset(obj) {
859
		if (obj.checked)
860
			$('presetwrap').show();
861
		else
862
			$('presetwrap').hide();
863
	}
864

    
865
	function show_mon_config() {
866
		document.getElementById("showmonbox").innerHTML='';
867
		aodiv = document.getElementById('showmon');
868
		aodiv.style.display = "block";
869
	}
870

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