Project

General

Profile

Download (66.4 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("functions.inc");
49
require("filter.inc");
50
require("shaper.inc");
51
require("rrd.inc");
52

    
53
if ($_REQUEST['if'])
54
	$if = $_REQUEST['if'];
55
else
56
	$if = "wan";
57

    
58
define("CRON_PPPOE_CMD_FILE", "/conf/pppoe{$if}restart");
59
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
60
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
61
define("CRON_DAILY_PATTERN", "0 0 * * *");
62
define("CRON_HOURLY_PATTERN", "0 * * * *");
63

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

    
77
function getMPDResetTimeFromConfig() {
78
	$itemhash = getMPDCRONSettings();
79
	$cronitem = $itemhash['ITEM'];
80
	if (isset($cronitem)) 
81
		return "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
82
	else 
83
		return NULL;
84
}
85

    
86
function remove_bad_chars($string) {
87
	return preg_replace('/[^a-z|_|0-9]/i','',$string);
88
}
89

    
90
if (!is_array($config['gateways']['gateway_item']))
91
	$config['gateways']['gateway_item'] = array();
92

    
93
$a_gateways = &$config['gateways']['gateway_item'];
94

    
95
$wancfg = &$config['interfaces'][$if];
96

    
97
$pconfig['pppoe_username'] = $wancfg['pppoe_username'];
98
$pconfig['pppoe_password'] = $wancfg['pppoe_password'];
99
$pconfig['provider'] = $wancfg['provider'];
100
$pconfig['pppoe_dialondemand'] = isset($wancfg['ondemand']);
101
$pconfig['pppoe_idletimeout'] = $wancfg['timeout'];
102

    
103
/* ================================================ */
104
/* = force a connection reset at a specific time? = */
105
/* ================================================ */
106

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

    
139
$pconfig['pptp_username'] = $wancfg['pptp_username'];
140
$pconfig['pptp_password'] = $wancfg['pptp_password'];
141
$pconfig['pptp_local'] = $wancfg['local'];
142
$pconfig['pptp_subnet'] = $wancfg['subnet'];
143
$pconfig['pptp_remote'] = $wancfg['remote'];
144
$pconfig['pptp_dialondemand'] = isset($wancfg['ondemand']);
145
$pconfig['pptp_idletimeout'] = $wancfg['timeout'];
146

    
147
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
148
$pconfig['alias-address'] = $wancfg['alias-address'];
149
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
150

    
151
// Populate page descr if it does not exist.
152
if($if == "wan" && !$wancfg['descr'])
153
	$wancfg['descr'] = "WAN";
154
else if ($if == "lan" && !$wancfg['descr'])
155
	$wancfg['descr'] = "LAN";
156
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
157

    
158
if ($if == "wan" || $if == "lan")
159
	$pconfig['enable'] = true;
160
else
161
	$pconfig['enable'] = isset($wancfg['enable']);
162

    
163
if (is_array($config['aliases']['alias']))
164
foreach($config['aliases']['alias'] as $alias)
165
	if($alias['name'] == $wancfg['descr'])
166
		$input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} already exists.");
167
if ($wancfg['ipaddr'] == "dhcp") {
168
	$pconfig['type'] = "dhcp";
169
} else if ($wancfg['ipaddr'] == "carpdev-dhcp") {
170
	$pconfig['type'] = "carpdev-dhcp";
171
	$pconfig['ipaddr'] = "";	    
172
} else if ($wancfg['ipaddr'] == "pppoe") {
173
	$pconfig['type'] = "pppoe";
174
} else if ($wancfg['ipaddr'] == "pptp") {
175
	$pconfig['type'] = "pptp";
176
} else if ($wancfg['ipaddr'] != "") {
177
	$pconfig['type'] = "static";
178
	$pconfig['ipaddr'] = $wancfg['ipaddr'];
179
	$pconfig['subnet'] = $wancfg['subnet'];
180
	$pconfig['gateway'] = $wancfg['gateway'];
181
	$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
182
} else
183
	$pconfig['type'] = "none";
184

    
185
// Handle PPP type interfaces
186
if($wancfg['serialport']) 
187
	$pconfig['type'] = "none";
188

    
189
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
190
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
191
$pconfig['spoofmac'] = $wancfg['spoofmac'];
192
$pconfig['mtu'] = $wancfg['mtu'];
193

    
194
/* Wireless interface? */
195
if (isset($wancfg['wireless'])) {
196
	/* Get wireless modes */
197
	interface_wireless_clone($if, $wancfg);
198
	$curif = convert_friendly_interface_to_real_interface_name($if);
199
	$wlanif = get_real_interface($if);
200
	$wl_modes = get_wireless_modes($if);
201
	$pconfig['standard'] = $wancfg['wireless']['standard'];
202
	$pconfig['mode'] = $wancfg['wireless']['mode'];
203
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
204
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
205
	$pconfig['channel'] = $wancfg['wireless']['channel'];
206
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
207
	$pconfig['distance'] = $wancfg['wireless']['distance'];
208
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
209
	$pconfig['pureg_enable'] = isset($wancfg['wireless']['pureg']['enable']);
210
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
211
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
212
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
213
	if (is_array($wancfg['wireless']['wpa'])) {
214
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
215
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
216
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
217
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
218
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
219
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
220
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
221
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
222
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
223
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
224
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
225
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
226
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
227
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
228
	}
229
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
230
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
231
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
232
		$i = 1;
233
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
234
			$pconfig['key' . $i] = $wepkey['value'];
235
			if (isset($wepkey['txkey']))
236
				$pconfig['txkey'] = $i;
237
			$i++;
238
		}
239
		if (!isset($wepkey['txkey']))
240
			$pconfig['txkey'] = 1;
241
	}
242
}
243

    
244
if ($_POST['apply']) {
245
	unset($input_errors);
246
	if (!is_subsystem_dirty('interfaces'))
247
		$intput_errors[] = "You have already applied your settings!";
248
	else {	
249
		unlink_if_exists("{$g['tmp_path']}/config.cache");
250
		clear_subsystem_dirty('interfaces');
251
		interface_configure($if);
252
		
253
		/* restart snmp so that it binds to correct address */		
254
		services_snmpd_configure();		
255
		if ($if == "lan") 		
256
			$savemsg = "The changes have been applied.  You may need to correct your web browser's IP address.";
257

    
258
		/* sync filter configuration */
259
		setup_gateways_monitor();
260

    
261
		clear_subsystem_dirty('staticroutes');
262
		
263
		filter_configure();
264
		
265
		enable_rrd_graphing();
266
	}
267
	header("Location: interfaces.php?if={$if}");
268
	exit;
269
} else
270

    
271
if ($_POST && $_POST['enable'] == "no") {
272
	unset($wancfg['enable']);
273
	interface_bring_down($if);
274
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
275
	mark_subsystem_dirty('interfaces');
276
	header("Location: interfaces.php?if={$if}");
277
	exit;
278
} else
279

    
280
if ($_POST) {
281
	unset($input_errors);
282
	$pconfig = $_POST;
283
	conf_mount_rw();
284
	/* filter out spaces from descriptions  */
285
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
286
	/* okay first of all, cause we are just hiding the PPPoE HTML
287
	 * fields releated to PPPoE resets, we are going to unset $_POST
288
	 * vars, if the reset feature should not be used. Otherwise the
289
	 * data validation procedure below, may trigger a false error
290
	 * message.
291
	 */
292
	if (empty($_POST['pppoe_preset'])) {
293
		unset($_POST['pppoe_pr_type']);                
294
		unset($_POST['pppoe_resethour']);
295
		unset($_POST['pppoe_resetminute']);
296
		unset($_POST['pppoe_resetdate']);
297
		unset($_POST['pppoe_pr_preset_val']);
298
	}
299
	/* optional interface if list */
300
	$iflist = get_configured_interface_with_descr();
301
	/* description unique? */
302
	foreach ($iflist as $ifent => $ifdescr) {
303
		if ($if != $ifent && $ifdescr == $_POST['descr'])
304
			$input_errors[] = "An interface with the specified description already exists.";
305
	}
306
	/* input validation */
307
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && $_POST['type'] != "static")
308
		$input_errors[] = "Dhcpd service is active on this interface and it can be used only with a static ip configuration. Please disable the service first and than change the interface configuration.";
309

    
310
	if ($_POST['type'] == "static") {
311
		$reqdfields = explode(" ", "ipaddr subnet gateway");
312
		$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
313
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
314
	} else if ($_POST['type'] == "PPPoE") {
315
		if ($_POST['pppoe_dialondemand']) {
316
			$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
317
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password,Dial on demand,Idle timeout value");
318
		} else {
319
			$reqdfields = explode(" ", "pppoe_username pppoe_password");
320
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password");
321
		}
322
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
323
	} else if ($_POST['type'] == "PPTP") {
324
		if ($_POST['pptp_dialondemand']) {
325
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
326
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address,Dial on demand,Idle timeout value");
327
		} else {
328
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
329
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address");
330
		}
331
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
332
	}
333
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
334
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
335
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) 
336
		$input_errors[] = "A valid IP address must be specified.";
337
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) 
338
		$input_errors[] = "A valid subnet bit count must be specified.";
339
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) 
340
		$input_errors[] = "A valid alias IP address must be specified.";
341
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) 
342
		$input_errors[] = "A valid alias subnet bit count must be specified.";
343
	if ($_POST['gateway'] != "none") {
344
		$match = false;
345
		foreach($a_gateways as $gateway) 
346
			if(in_array($_POST['gateway'], $gateway)) 
347
				$match = true;
348
		if(!$match)
349
			$input_errors[] = "A valid gateway must be specified.";
350
	}
351
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) 
352
		$input_errors[] = "A valid point-to-point IP address must be specified.";
353
	if (($_POST['provider'] && !is_domain($_POST['provider']))) 
354
		$input_errors[] = "The service name contains invalid characters.";
355
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) 
356
		$input_errors[] = "The idle timeout value must be an integer.";
357
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) && 
358
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) 
359
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
360
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) && 
361
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) 
362
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
363
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) 
364
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
365
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) 
366
		$input_errors[] = "A valid PPTP local IP address must be specified.";
367
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) 
368
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
369
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) 
370
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
371
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) 
372
		$input_errors[] = "The idle timeout value must be an integer.";
373
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) 
374
		$input_errors[] = "A valid MAC address must be specified.";
375
	if ($_POST['mtu'] && ($_POST['mtu'] < 576)) 
376
		$input_errors[] = "The MTU must be greater than 576 bytes.";
377
	/* Wireless interface? */
378
	if (isset($wancfg['wireless'])) {
379
		$reqdfields = explode(" ", "mode ssid");
380
		$reqdfieldsn = explode(",", "Mode,SSID");
381
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
382
		/* loop through keys and enforce size */
383
		for ($i = 1; $i <= 4; $i++) {
384
			if ($_POST['key' . $i]) {
385
				/* 64 bit */
386
				if (strlen($_POST['key' . $i]) == 5)
387
					continue;
388
				if (strlen($_POST['key' . $i]) == 10) {
389
					/* hex key */
390
					if (stristr($_POST['key' . $i], "0x") == false) {
391
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
392
					}
393
					continue;
394
				}
395
				if (strlen($_POST['key' . $i]) == 12) {
396
					/* hex key */
397
					if(stristr($_POST['key' . $i], "0x") == false) {
398
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
399
					}
400
					continue;
401
				}
402
				/* 128 bit */
403
				if (strlen($_POST['key' . $i]) == 13)
404
					continue;
405
				if (strlen($_POST['key' . $i]) == 26) {
406
					/* hex key */
407
					if (stristr($_POST['key' . $i], "0x") == false)
408
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
409
					continue;
410
				}
411
				if(strlen($_POST['key' . $i]) == 28)
412
					continue;
413
				$input_errors[] =  "Invalid wep key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.";
414
				break;
415
			}
416
		}
417
	}
418
	if (!$input_errors) {
419
		unset($wancfg['ipaddr']);
420
		unset($wancfg['subnet']);
421
		unset($wancfg['gateway']);
422
		unset($wancfg['pointtopoint']);
423
		unset($wancfg['dhcphostname']);
424
		unset($wancfg['pppoe_username']);
425
		unset($wancfg['pppoe_password']);
426
		unset($wancfg['pptp_username']);
427
		unset($wancfg['pptp_password']);
428
		unset($wancfg['provider']);
429
		unset($wancfg['ondemand']);
430
		unset($wancfg['timeout']);
431
		if ($wancfg['pppoe']['pppoe-reset-type'])
432
			unset($wancfg['pppoe']['pppoe-reset-type']);
433
		unset($wancfg['local']);
434
		unset($wancfg['subnet']);
435
		unset($wancfg['remote']);
436

    
437
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
438
		if ($if == "wan" || $if == "lan")
439
			$wancfg['enable'] = true;
440
		else
441
			$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
442
		if ($_POST['type'] == "static") {
443
			$wancfg['ipaddr'] = $_POST['ipaddr'];
444
			$wancfg['subnet'] = $_POST['subnet'];
445
			if ($_POST['gateway'] != "none")
446
				$wancfg['gateway'] = $_POST['gateway'];
447
			if (isset($wancfg['ispointtopoint']))
448
				$wancfg['pointtopoint'] = $_POST['pointtopoint'];
449
		} else if ($_POST['type'] == "dhcp") {
450
			$wancfg['ipaddr'] = "dhcp";
451
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
452
			$wancfg['alias-address'] = $_POST['alias-address'];
453
			$wancfg['alias-subnet'] = $_POST['alias-subnet'];
454
		} else if ($_POST['type'] == "carpdev-dhcp") {
455
			$wancfg['ipaddr'] = "carpdev-dhcp";
456
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
457
			$wancfg['alias-address'] = $_POST['alias-address'];
458
			$wancfg['alias-subnet'] = $_POST['alias-subnet'];			
459
		} else if ($_POST['type'] == "pppoe") {
460
			$wancfg['ipaddr'] = "pppoe";
461
			$wancfg['pppoe_username'] = $_POST['pppoe_username'];
462
			$wancfg['pppoe_password'] = $_POST['pppoe_password'];
463
			$wancfg['provider'] = $_POST['provider'];
464
			$wancfg['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
465
			$wancfg['timeout'] = $_POST['pppoe_idletimeout'];
466
		} else if ($_POST['type'] == "pptp") {
467
			$wancfg['ipaddr'] = "pptp";
468
			$wancfg['pptp_username'] = $_POST['pptp_username'];
469
			$wancfg['pptp_password'] = $_POST['pptp_password'];
470
			$wancfg['local'] = $_POST['pptp_local'];
471
			$wancfg['subnet'] = $_POST['pptp_subnet'];
472
			$wancfg['remote'] = $_POST['pptp_remote'];
473
			$wancfg['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
474
			$wancfg['timeout'] = $_POST['pptp_idletimeout'];
475
		}
476
		handle_pppoe_reset();
477
		/* reset cron items if necessary */
478
		if (empty($_POST['pppoe_preset'])) {
479
			/* test whether a cron item exists and unset() it if necessary */
480
			$itemhash = getMPDCRONSettings();
481
			$item = $itemhash['ITEM'];
482
			if (isset($item))
483
				unset($config['cron']['item'][$itemhash['ID']]); 
484
		}
485
		if($_POST['blockpriv'] == "yes")
486
			$wancfg['blockpriv'] = true;
487
		else
488
			unset($wancfg['blockpriv']);
489
		if($_POST['blockbogons'] == "yes")
490
			$wancfg['blockbogons'] = true;
491
		else
492
			unset($wancfg['blockbogons']);
493
		$wancfg['spoofmac'] = $_POST['spoofmac'];
494
		if (empty($_POST['mtu']))
495
			unset($wancfg['mtu']);
496
		else
497
			$wancfg['mtu'] = $_POST['mtu'];
498
		if (isset($wancfg['wireless'])) 
499
			handle_wireless_post();
500
		write_config();
501
		mark_subsystem_dirty('interfaces');
502
		/* regenerate cron settings/crontab file */
503
		configure_cron();
504
		conf_mount_ro();
505
		header("Location: interfaces.php?if={$if}");
506
		exit;
507
	}
508
} // end if($_POST) 
509

    
510
function handle_pppoe_reset() {
511
	global $_POST, $config, $g, $wancfg, $if;
512
	/* perform a periodic reset? */
513
	if(!isset($_POST['pppoe_preset'])) {
514
		setup_pppoe_reset_file($if, false);		
515
		return;
516
	}
517
	if (!is_array($config['cron']['item'])) 
518
		$config['cron']['item'] = array(); 
519
	$itemhash = getMPDCRONSettings();
520
	$item = $itemhash['ITEM'];
521
	if (empty($item)) 
522
		$item = array();
523
	if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] == "custom") {
524
		$wancfg['pppoe']['pppoe-reset-type'] = "custom";
525
		$pconfig['pppoe_pr_custom'] = true;
526
		$item['minute'] = $_POST['pppoe_resetminute'];
527
		$item['hour'] = $_POST['pppoe_resethour'];
528
		if (isset($_POST['pppoe_resetdate']) && $_POST['pppoe_resetdate'] <> "" && strlen($_POST['pppoe_resetdate']) == 10) {
529
			$date = explode("/", $_POST['pppoe_resetdate']);
530
			$item['mday'] = $date[1];
531
			$item['month'] = $date[0];
532
		} else {
533
			$item['mday'] = "*";
534
			$item['month'] = "*";
535
		}
536
		$item['wday'] = "*";
537
		$item['who'] = "root";
538
		$item['command'] = CRON_PPPOE_CMD_FILE;
539
	} else if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] = "preset") {
540
		$wancfg['pppoe']['pppoe-reset-type'] = "preset";
541
		$pconfig['pppoe_pr_preset'] = true;
542
		switch ($_POST['pppoe_pr_preset_val']) {
543
			case "monthly":
544
				$item['minute'] = "0";
545
				$item['hour'] = "0";
546
				$item['mday'] = "1";
547
				$item['month'] = "*";
548
				$item['wday'] = "*";
549
				$item['who'] = "root";
550
				$item['command'] = CRON_PPPOE_CMD_FILE;
551
				break;
552
	        	case "weekly":
553
				$item['minute'] = "0";
554
				$item['hour'] = "0";
555
				$item['mday'] = "*";
556
				$item['month'] = "*";
557
				$item['wday'] = "0";
558
				$item['who'] = "root";
559
				$item['command'] = CRON_PPPOE_CMD_FILE;
560
				break;
561
			case "daily":
562
				$item['minute'] = "0";
563
				$item['hour'] = "0";
564
				$item['mday'] = "*";
565
				$item['month'] = "*";
566
				$item['wday'] = "*";
567
				$item['who'] = "root";
568
				$item['command'] = CRON_PPPOE_CMD_FILE;
569
				break;
570
			case "hourly":
571
				$item['minute'] = "0";
572
				$item['hour'] = "*";
573
				$item['mday'] = "*";
574
				$item['month'] = "*";
575
				$item['wday'] = "*";
576
				$item['who'] = "root";
577
				$item['command'] = CRON_PPPOE_CMD_FILE;
578
				break;
579
		} // end switch
580
	} // end if
581
	if (isset($itemhash['ID'])) 
582
		$config['cron']['item'][$itemhash['ID']] = $item;
583
	else 
584
		$config['cron']['item'][] = $item;
585
	/* finally install the pppoerestart file */
586
	if (isset($_POST['pppoe_preset'])) {
587
		setup_pppoe_reset_file($if, true);
588
		$wancfg['pppoe_reset'] = true;
589
		$wancfg['pppoe_preset'] = true;
590
		sigkillbypid("{$g['varrun_path']}/cron.pid", "HUP");
591
	} else {
592
		unset($wancfg['pppoe_reset']);
593
		unset($wancfg['pppoe_preset']);		
594
		setup_pppoe_reset_file($if, false);	
595
	}
596
}
597

    
598
function handle_wireless_post() {
599
	global $_POST, $config, $g, $wancfg, $if;
600
	if (!is_array($wancfg['wireless']))
601
		$wancfg['wireless'] = array();
602
	$wancfg['wireless']['standard'] = $_POST['standard'];
603
	$wancfg['wireless']['mode'] = $_POST['mode'];
604
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
605
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
606
	$wancfg['wireless']['channel'] = $_POST['channel'];
607
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
608
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
609
	$wancfg['wireless']['distance'] = $_POST['distance'];
610
	if (!is_array($wancfg['wireless']['wpa']))
611
		$wancfg['wireless']['wpa'] = array();
612
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
613
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
614
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
615
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
616
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
617
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
618
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
619
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
620
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
621
	if ($_POST['hidessid_enable'] == "yes")
622
		$wancfg['wireless']['hidessid']['enable'] = true;
623
	else if (isset($wancfg['wireless']['hidessid']['enable']))
624
		unset($wancfg['wireless']['hidessid']['enable']);
625
	if ($_POST['mac_acl_enable'] == "yes")
626
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
627
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
628
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
629
	if ($_POST['ieee8021x'] == "yes")
630
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
631
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
632
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
633
	if ($_POST['wpa_strict_rekey'] == "yes")
634
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
635
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
636
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
637
	if ($_POST['debug_mode'] == "yes")
638
		$wancfg['wireless']['wpa']['debug_mode'] = true;
639
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
640
		sunset($wancfg['wireless']['wpa']['debug_mode']);
641
	if ($_POST['wpa_enable'] == "yes")
642
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
643
	else if (isset($wancfg['wireless']['wpa']['enable']))
644
		unset($wancfg['wireless']['wpa']['enable']);
645
	if ($_POST['wep_enable'] == "yes") {
646
		if (!is_array($wancfg['wireless']['wep']))
647
			$wancfg['wireless']['wep'] = array();
648
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
649
	} else if (isset($wancfg['wireless']['wep']))
650
		unset($wancfg['wireless']['wep']);
651
	if ($_POST['wme_enable'] == "yes") {
652
		if (!is_array($wancfg['wireless']['wme']))
653
			$wancfg['wireless']['wme'] = array();
654
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
655
	} else if (isset($wancfg['wireless']['wme']['enable']))
656
		unset($wancfg['wireless']['wme']['enable']);
657
	if ($_POST['pureg_enable'] == "yes") {
658
		if (!is_array($wancfg['wireless']['pureg']))
659
			$wancfg['wireless']['pureg'] = array();
660
		$wancfg['wireless']['pureg']['enable'] = $_POST['pureg_enable'] = true;
661
	} else if (isset($wancfg['wireless']['pureg']['enable']))
662
		unset($wancfg['wireless']['pureg']['enable']);
663
	if ($_POST['apbridge_enable'] == "yes") {
664
		if (!is_array($wancfg['wireless']['apbridge']))
665
			$wancfg['wireless']['apbridge'] = array();
666
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
667
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
668
		unset($wancfg['wireless']['apbridge']['enable']);
669
	if ($_POST['standard'] == "11a Turbo") {
670
		if (!is_array($wancfg['wireless']['turbo']))
671
			$wancfg['wireless']['turbo'] = array();
672
		$wancfg['wireless']['turbo']['enable'] = true;
673
	} else if (isset($wancfg['wireless']['turbo']['enable']))
674
		unset($wancfg['wireless']['turbo']['enable']);
675
	$wancfg['wireless']['wep']['key'] = array();
676
	for ($i = 1; $i <= 4; $i++) {
677
		if ($_POST['key' . $i]) {
678
			$newkey = array();
679
			$newkey['value'] = $_POST['key' . $i];
680
			if ($_POST['txkey'] == $i)
681
				$newkey['txkey'] = true;
682
			$wancfg['wireless']['wep']['key'][] = $newkey;
683
		}
684
	}
685
}
686

    
687
$pgtitle = array("Interfaces", $pconfig['descr']);
688
$closehead = false;
689
include("head.inc");
690
$types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" => "PPPoE", "pptp" => "PPTP" /* , "carpdev-dhcp" => "CarpDev"*/); 
691

    
692
?>
693

    
694
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
695
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
696
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
697
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
698

    
699
<script type="text/javascript">
700
	function updateType(t){
701
		switch(t) {
702
	<?php
703
		/* OK, so this is sick using php to generate javascript, but it needed to be done */
704
		foreach ($types as $key => $val) {
705
			echo "case \"{$key}\": {\n";
706
			$t = $types;
707
			foreach ($t as $k => $v) {
708
				if ($k != $key) {
709
					echo "$('{$k}').hide();\n";
710
				}
711
			}
712
			echo "}\n";
713
		}
714
	?>
715
		}
716
		$(t).show();
717
	}
718

    
719
	function show_allcfg(obj) {
720
		if (obj.checked)
721
			$('allcfg').show();
722
		else
723
			$('allcfg').hide();
724
	}
725
	
726
	function show_periodic_reset(obj) {
727
		if (obj.checked)
728
			$('presetwrap').show();
729
		else
730
			$('presetwrap').hide();
731
	}
732

    
733
	function show_mon_config() {
734
		document.getElementById("showmonbox").innerHTML='';
735
		aodiv = document.getElementById('showmon');
736
		aodiv.style.display = "block";
737
	}
738

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