Project

General

Profile

Download (65.6 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
##|+PRIV
37
##|*IDENT=page-interfaces
38
##|*NAME=Interfaces: WAN page
39
##|*DESCR=Allow access to the 'Interfaces' page.
40
##|*MATCH=interfaces.php*
41
##|-PRIV
42

    
43
require("guiconfig.inc");
44

    
45
if ($_REQUEST['if'])
46
	$if = $_REQUEST['if'];
47
else
48
	$if = "wan";
49

    
50
define("CRON_PPPOE_CMD_FILE", "/conf/pppoe{$if}restart");
51
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
52
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
53
define("CRON_DAILY_PATTERN", "0 0 * * *");
54
define("CRON_HOURLY_PATTERN", "0 * * * *");
55

    
56
function getMPDCRONSettings() {
57
  global $config;
58
  if (is_array($config['cron']['item'])) {
59
    for ($i = 0; $i < count($config['cron']['item']); $i++) {
60
      $item = $config['cron']['item'][$i];
61
      if (strpos($item['command'], CRON_PPPOE_CMD_FILE) !== false) {
62
        return array("ID" => $i, "ITEM" => $item);
63
      }
64
    }
65
  }
66
  return NULL;
67
}
68

    
69
function getMPDResetTimeFromConfig() {
70
	$itemhash = getMPDCRONSettings();
71
	$cronitem = $itemhash['ITEM'];
72
	if (isset($cronitem)) 
73
		return "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
74
	else 
75
		return NULL;
76
}
77

    
78
function remove_bad_chars($string) {
79
	return preg_replace('/[^a-z|_|0-9]/i','',$string);
80
}
81

    
82
if (!is_array($config['gateways']['gateway_item']))
83
	$config['gateways']['gateway_item'] = array();
84

    
85
$a_gateways = &$config['gateways']['gateway_item'];
86

    
87
$wancfg = &$config['interfaces'][$if];
88

    
89
$pconfig['pppoe_username'] = $wancfg['pppoe_username'];
90
$pconfig['pppoe_password'] = $wancfg['pppoe_password'];
91
$pconfig['provider'] = $wancfg['provider'];
92
$pconfig['pppoe_dialondemand'] = isset($wancfg['ondemand']);
93
$pconfig['pppoe_idletimeout'] = $wancfg['timeout'];
94

    
95
/* ================================================ */
96
/* = force a connection reset at a specific time? = */
97
/* ================================================ */
98

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

    
131
$pconfig['pptp_username'] = $wancfg['pptp_username'];
132
$pconfig['pptp_password'] = $wancfg['pptp_password'];
133
$pconfig['pptp_local'] = $wancfg['local'];
134
$pconfig['pptp_subnet'] = $wancfg['subnet'];
135
$pconfig['pptp_remote'] = $wancfg['remote'];
136
$pconfig['pptp_dialondemand'] = isset($wancfg['ondemand']);
137
$pconfig['pptp_idletimeout'] = $wancfg['timeout'];
138

    
139
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
140
$pconfig['alias-address'] = $wancfg['alias-address'];
141
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
142

    
143
// Populate page descr if it does not exist.
144
if($if == "wan" && !$wancfg['descr'])
145
	$wancfg['descr'] = "WAN";
146
else if ($if == "lan" && !$wancfg['descr'])
147
	$wancfg['descr'] = "LAN";
148
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
149

    
150
if ($if == "wan" || $if == "lan")
151
	$pconfig['enable'] = true;
152
else
153
	$pconfig['enable'] = isset($wancfg['enable']);
154

    
155
if (is_array($config['aliases']['alias']))
156
foreach($config['aliases']['alias'] as $alias)
157
	if($alias['name'] == $wancfg['descr'])
158
		$input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} already exists.");
159
if ($wancfg['ipaddr'] == "dhcp") {
160
	$pconfig['type'] = "dhcp";
161
} else if ($wancfg['ipaddr'] == "carpdev-dhcp") {
162
	$pconfig['type'] = "carpdev-dhcp";
163
	$pconfig['ipaddr'] = "";	    
164
} else if ($wancfg['ipaddr'] == "pppoe") {
165
	$pconfig['type'] = "pppoe";
166
} else if ($wancfg['ipaddr'] == "pptp") {
167
	$pconfig['type'] = "pptp";
168
} else if ($wancfg['ipaddr'] != "") {
169
	$pconfig['type'] = "static";
170
	$pconfig['ipaddr'] = $wancfg['ipaddr'];
171
	$pconfig['subnet'] = $wancfg['subnet'];
172
	$pconfig['gateway'] = $wancfg['gateway'];
173
	$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
174
} else
175
	$pconfig['type'] = "none";
176

    
177
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
178
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
179
$pconfig['spoofmac'] = $wancfg['spoofmac'];
180
$pconfig['mtu'] = $wancfg['mtu'];
181

    
182
/* Wireless interface? */
183
if (isset($wancfg['wireless'])) {
184
	/* Get wireless modes */
185
	$curif = convert_friendly_interface_to_real_interface_name($if);
186
	$wl_modes = get_wireless_modes($curif);
187
	$pconfig['standard'] = $wancfg['wireless']['standard'];
188
	$pconfig['mode'] = $wancfg['wireless']['mode'];
189
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
190
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
191
	$pconfig['channel'] = $wancfg['wireless']['channel'];
192
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
193
	$pconfig['distance'] = $wancfg['wireless']['distance'];
194
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
195
	$pconfig['pureg_enable'] = isset($wancfg['wireless']['pureg']['enable']);
196
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
197
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
198
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
199
	if (is_array($wancfg['wireless']['wpa'])) {
200
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
201
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
202
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
203
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
204
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
205
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
206
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
207
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
208
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
209
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
210
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
211
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
212
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
213
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
214
	}
215
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
216
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
217
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
218
		$i = 1;
219
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
220
			$pconfig['key' . $i] = $wepkey['value'];
221
			if (isset($wepkey['txkey']))
222
				$pconfig['txkey'] = $i;
223
			$i++;
224
		}
225
		if (!isset($wepkey['txkey']))
226
			$pconfig['txkey'] = 1;
227
	}
228
}
229

    
230
if ($_POST['apply']) {
231
	unset($input_errors);
232
	if (!file_exists($d_landirty_path))
233
		$intput_errors[] = "You have already applied your settings!";
234
	else {	
235
		unlink_if_exists("{$g['tmp_path']}/config.cache");
236
		unlink_if_exists("{$d_landirty_path}");
237
		interface_configure($if);
238
		reset_carp();
239
		/* restart snmp so that it binds to correct address */		
240
		services_snmpd_configure();		
241
		if ($if == "lan") 		
242
			$savemsg = "The changes have been applied.  You may need to correct your web browser's IP address.";
243
		/* sync filter configuration */
244
		config_lock();
245
		setup_gateways_monitor();
246
		if (file_exists($d_staticroutesdirty_path)) 
247
			unlink($d_staticroutesdirty_path);
248
		config_unlock();
249
		filter_configure();
250
		/* set up static routes */
251
		system_routing_configure();
252
		/* start IPsec tunnels */
253
		vpn_ipsec_configure();
254
	}
255
	header("Location: interfaces.php?if={$if}");
256
	exit;
257
}
258

    
259
if ($_POST && $_POST['enable'] == "no") {
260
	unset($wancfg['enable']);
261
	interface_bring_down($if);
262
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
263
	touch($d_landirty_path);
264
	header("Location: interfaces.php?if={$if}");
265
	exit;
266
}
267

    
268
if ($_POST) {
269
	unset($input_errors);
270
	$pconfig = $_POST;
271
	conf_mount_rw();
272
	/* filter out spaces from descriptions  */
273
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
274
	/* okay first of all, cause we are just hidding the PPPoE HTML
275
	 * fields releated to PPPoE resets, we are going to unset $_POST
276
	 * vars, if the reset feature should not be used. Otherwise the
277
	 * data validation procedure below, may trigger a false error
278
	 * message.
279
	 */
280
	if (empty($_POST['pppoe_preset'])) {
281
		unset($_POST['pppoe_pr_type']);                
282
		unset($_POST['pppoe_resethour']);
283
		unset($_POST['pppoe_resetminute']);
284
		unset($_POST['pppoe_resetdate']);
285
		unset($_POST['pppoe_pr_preset_val']);
286
	}
287
	/* optional interface if list */
288
	$iflist = get_configured_interface_with_descr();
289
	/* description unique? */
290
	foreach ($iflist as $ifent => $ifdescr) {
291
		if ($if != $ifent && $ifdescr == $_POST['descr'])
292
			$input_errors[] = "An interface with the specified description already exists.";
293
	}
294
	/* input validation */
295
	if ($_POST['type'] == "static") {
296
		$reqdfields = explode(" ", "ipaddr subnet gateway");
297
		$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
298
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
299
	} else if ($_POST['type'] == "PPPoE") {
300
		if ($_POST['pppoe_dialondemand']) {
301
			$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
302
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password,Dial on demand,Idle timeout value");
303
		} else {
304
			$reqdfields = explode(" ", "pppoe_username pppoe_password");
305
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password");
306
		}
307
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
308
	} else if ($_POST['type'] == "PPTP") {
309
		if ($_POST['pptp_dialondemand']) {
310
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
311
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address,Dial on demand,Idle timeout value");
312
		} else {
313
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
314
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address");
315
		}
316
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
317
	}
318
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
319
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
320
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) 
321
		$input_errors[] = "A valid IP address must be specified.";
322
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) 
323
		$input_errors[] = "A valid subnet bit count must be specified.";
324
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) 
325
		$input_errors[] = "A valid alias IP address must be specified.";
326
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) 
327
		$input_errors[] = "A valid alias subnet bit count must be specified.";
328
	if ($_POST['gateway'] != "none") {
329
		$match = false;
330
		foreach($a_gateways as $gateway) 
331
			if(in_array($_POST['gateway'], $gateway)) 
332
				$match = true;
333
		if(!$match)
334
			$input_errors[] = "A valid gateway must be specified.";
335
	}
336
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) 
337
		$input_errors[] = "A valid point-to-point IP address must be specified.";
338
	if (($_POST['provider'] && !is_domain($_POST['provider']))) 
339
		$input_errors[] = "The service name contains invalid characters.";
340
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) 
341
		$input_errors[] = "The idle timeout value must be an integer.";
342
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) && 
343
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) 
344
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
345
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) && 
346
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) 
347
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
348
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) 
349
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
350
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) 
351
		$input_errors[] = "A valid PPTP local IP address must be specified.";
352
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) 
353
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
354
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) 
355
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
356
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) 
357
		$input_errors[] = "The idle timeout value must be an integer.";
358
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) 
359
		$input_errors[] = "A valid MAC address must be specified.";
360
	if ($_POST['mtu'] && ($_POST['mtu'] < 576)) 
361
		$input_errors[] = "The MTU must be greater than 576 bytes.";
362
	/* Wireless interface? */
363
	if (isset($wancfg['wireless'])) {
364
		$reqdfields = explode(" ", "mode ssid");
365
		$reqdfieldsn = explode(",", "Mode,SSID");
366
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
367
		/* loop through keys and enforce size */
368
		for ($i = 1; $i <= 4; $i++) {
369
			if ($_POST['key' . $i]) {
370
				/* 64 bit */
371
				if (strlen($_POST['key' . $i]) == 5)
372
					continue;
373
				if (strlen($_POST['key' . $i]) == 10) {
374
					/* hex key */
375
					if (stristr($_POST['key' . $i], "0x") == false) {
376
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
377
					}
378
					continue;
379
				}
380
				if (strlen($_POST['key' . $i]) == 12) {
381
					/* hex key */
382
					if(stristr($_POST['key' . $i], "0x") == false) {
383
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
384
					}
385
					continue;
386
				}
387
				/* 128 bit */
388
				if (strlen($_POST['key' . $i]) == 13)
389
					continue;
390
				if (strlen($_POST['key' . $i]) == 26) {
391
					/* hex key */
392
					if (stristr($_POST['key' . $i], "0x") == false)
393
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
394
					continue;
395
				}
396
				if(strlen($_POST['key' . $i]) == 28)
397
					continue;
398
				$input_errors[] =  "Invalid wep key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.";
399
				break;
400
			}
401
		}
402
	}
403
	if (!$input_errors) {
404
		unset($wancfg['ipaddr']);
405
		unset($wancfg['subnet']);
406
		unset($wancfg['gateway']);
407
		unset($wancfg['pointtopoint']);
408
		unset($wancfg['dhcphostname']);
409
		unset($wancfg['pppoe_username']);
410
		unset($wancfg['pppoe_password']);
411
		unset($wancfg['pptp_username']);
412
		unset($wancfg['pptp_password']);
413
		unset($wancfg['provider']);
414
		unset($wancfg['ondemand']);
415
		unset($wancfg['timeout']);
416
		if ($wancfg['pppoe']['pppoe-reset-type'])
417
			unset($wancfg['pppoe']['pppoe-reset-type']);
418
		unset($wancfg['local']);
419
		unset($wancfg['subnet']);
420
		unset($wancfg['remote']);
421

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

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

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

    
669
$pgtitle = array("Interfaces", $pconfig['descr']);
670
$closehead = false;
671
include("head.inc");
672
$types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" => "PPPoE", "pptp" => "PPTP" /* , "carpdev-dhcp" => "CarpDev"*/); 
673

    
674
?>
675

    
676
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
677
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
678
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
679
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
680

    
681
<script type="text/javascript">
682
	function updateType(t){
683
		switch(t) {
684
	<?php
685
		/* OK, so this is sick using php to generate javascript, but it needed to be done */
686
		foreach ($types as $key => $val) {
687
			echo "case \"{$key}\": {\n";
688
			$t = $types;
689
			foreach ($t as $k => $v) {
690
				if ($k != $key) {
691
					echo "$('{$k}').hide();\n";
692
				}
693
			}
694
			echo "}\n";
695
		}
696
	?>
697
		}
698
		$(t).show();
699
	}
700

    
701
	function show_allcfg(obj) {
702
		if (obj.checked)
703
			$('allcfg').show();
704
		else
705
			$('allcfg').hide();
706
	}
707
	
708
	function show_periodic_reset(obj) {
709
		if (obj.checked)
710
			$('presetwrap').show();
711
		else
712
			$('presetwrap').hide();
713
	}
714

    
715
	function show_mon_config() {
716
		document.getElementById("showmonbox").innerHTML='';
717
		aodiv = document.getElementById('showmon');
718
		aodiv.style.display = "block";
719
	}
720

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