Project

General

Profile

Download (65.7 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 (!is_subsystem_dirty('interfaces'))
233
		$intput_errors[] = "You have already applied your settings!";
234
	else {	
235
		unlink_if_exists("{$g['tmp_path']}/config.cache");
236
		clear_subsystem_dirty('interfaces');
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

    
244
		/* sync filter configuration */
245
		setup_gateways_monitor();
246

    
247
		clear_subsystem_dirty('staticroutes');
248
	}
249
	header("Location: interfaces.php?if={$if}");
250
	exit;
251
} else
252

    
253
if ($_POST && $_POST['enable'] == "no") {
254
	unset($wancfg['enable']);
255
	interface_bring_down($if);
256
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
257
	mark_subsystem_dirty('interfaces');
258
	header("Location: interfaces.php?if={$if}");
259
	exit;
260
} else
261

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

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

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

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

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

    
668
?>
669

    
670
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
671
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
672
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
673
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
674

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

    
695
	function show_allcfg(obj) {
696
		if (obj.checked)
697
			$('allcfg').show();
698
		else
699
			$('allcfg').hide();
700
	}
701
	
702
	function show_periodic_reset(obj) {
703
		if (obj.checked)
704
			$('presetwrap').show();
705
		else
706
			$('presetwrap').hide();
707
	}
708

    
709
	function show_mon_config() {
710
		document.getElementById("showmonbox").innerHTML='';
711
		aodiv = document.getElementById('showmon');
712
		aodiv.style.display = "block";
713
	}
714

    
715
	function openwindow(url) {
716
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
717
		if (oWin==null || typeof(oWin)=="undefined") 
718
			return false;
719
		else 
720
			return true;
721
	}
722
</script>
723
</head>
724
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
725
	<?php include("fbegin.inc"); ?>
726
	<form action="interfaces.php" method="post" name="iform" id="iform">
727
		<?php if ($input_errors) print_input_errors($input_errors); ?>
728
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
729
		<?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 />
730
		<?php endif; ?>
731
		<?php if ($savemsg) print_info_box($savemsg); ?>
732
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
733
		<tr>
734
                                <td id="mainarea">
735
                                        <div class="tabcont">
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
					</div>
1436
					</td></tr>
1437
					</table>
1438
				</form>
1439
				<script type="text/javascript">
1440
					var gatewayip;
1441
					var name;
1442
					function show_add_gateway() {
1443
						document.getElementById("addgateway").style.display = '';
1444
						document.getElementById("addgwbox").style.display = 'none';
1445
						document.getElementById("gateway").style.display = 'none';
1446
						document.getElementById("save").style.display = 'none';
1447
						document.getElementById("cancel").style.display = 'none';
1448
						document.getElementById("gwsave").style.display = '';
1449
						document.getElementById("gwcancel").style.display = '';
1450
						$('notebox').innerHTML="";
1451
					}
1452
					function hide_add_gateway() {
1453
						document.getElementById("addgateway").style.display = 'none';
1454
						document.getElementById("addgwbox").style.display = '';	
1455
						document.getElementById("gateway").style.display = '';
1456
						document.getElementById("save").style.display = '';
1457
						document.getElementById("cancel").style.display = '';
1458
						document.getElementById("gwsave").style.display = '';
1459
						document.getElementById("gwcancel").style.display = '';
1460
					}
1461
					function hide_add_gatewaysave() {
1462
						document.getElementById("addgateway").style.display = 'none';
1463
						$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif"> One moment please...';
1464
						var iface = $F('if');
1465
						name = $('name').getValue();
1466
						var descr = $('gatewaydescr').getValue();
1467
						gatewayip = $('gatewayip').getValue();
1468
						addrtype = $('addrtype').getValue();
1469
						var defaultgw = $('defaultgw').getValue();
1470
						var url = "system_gateways_edit.php";
1471
						var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip) + '&type=' + escape(addrtype);
1472
						var myAjax = new Ajax.Request(
1473
							url,
1474
							{
1475
								method: 'post',
1476
								parameters: pars,
1477
								onFailure: report_failure,
1478
								onComplete: save_callback
1479
							});	
1480
					}
1481
					function addOption(selectbox,text,value)
1482
					{
1483
						var optn = document.createElement("OPTION");
1484
						optn.text = text;
1485
						optn.value = value;
1486
						selectbox.options.add(optn);
1487
						selectbox.selectedIndex = (selectbox.options.length-1);
1488
						$('notebox').innerHTML="<p/><strong>NOTE:</strong> You can manage Gateways <a target='_new' href='system_gateways.php'>here</a>.";
1489
					}				
1490
					function report_failure() {
1491
						alert("Sorry, we could not create your gateway at this time.");
1492
						hide_add_gateway();
1493
					}
1494
					function save_callback(transport) {
1495
						var response = transport.responseText;
1496
						if(response) {
1497
							document.getElementById("addgateway").style.display = 'none';
1498
							hide_add_gateway();
1499
							$('status').innerHTML = '';
1500
							addOption($('gateway'), name, name);
1501
							// Auto submit form?
1502
							//document.iform.submit();
1503
							//$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif">';
1504
						} else {
1505
							report_failure();
1506
						}
1507
					}
1508
					<?php
1509
					if ($if == "wan" || $if == "lan")
1510
						echo "\$('allcfg').show();";
1511
					else
1512
						echo "show_allcfg(document.iform.enable);";
1513
					echo "updateType('{$pconfig['type']}')";
1514
					?>
1515
				</script>
1516
				<?php include("fend.inc"); ?>
1517
		</body>
1518
</html>
(78-78/217)