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
		setup_gateways_monitor();
245
		if (file_exists($d_staticroutesdirty_path)) 
246
			unlink($d_staticroutesdirty_path);
247
		filter_configure();
248
		/* set up static routes */
249
		system_routing_configure();
250
		/* start IPsec tunnels */
251
		vpn_ipsec_configure();
252
	}
253
	header("Location: interfaces.php?if={$if}");
254
	exit;
255
}
256

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

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

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

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

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

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

    
672
?>
673

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

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

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

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

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