Project

General

Profile

Download (65.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces.php
5
	Copyright (C) 2004-2008 Scott Ullrich
6
	Copyright (C) 2008 Ermal Lu?i
7
	All rights reserved.
8

    
9
	originally part of m0n0wall (http://m0n0.ch/wall)
10
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
	All rights reserved.
12

    
13
	Redistribution and use in source and binary forms, with or without
14
	modification, are permitted provided that the following conditions are met:
15

    
16
	1. Redistributions of source code must retain the above copyright notice,
17
	   this list of conditions and the following disclaimer.
18

    
19
	2. Redistributions in binary form must reproduce the above copyright
20
	   notice, this list of conditions and the following disclaimer in the
21
	   documentation and/or other materials provided with the distribution.
22

    
23
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
	POSSIBILITY OF SUCH DAMAGE.
33
*/
34

    
35
##|+PRIV
36
##|*IDENT=page-interfaces
37
##|*NAME=Interfaces: WAN page
38
##|*DESCR=Allow access to the 'Interfaces' page.
39
##|*MATCH=interfaces.php*
40
##|-PRIV
41

    
42
require("guiconfig.inc");
43

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

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

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

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

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

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

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

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

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

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

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

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

    
138
$pconfig['disableftpproxy'] = isset($wancfg['disableftpproxy']);
139

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

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

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

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

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

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

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

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

    
269
if ($_POST) {
270
	unset($input_errors);
271
	$pconfig = $_POST;
272
	conf_mount_rw();
273
	/* filter out spaces from descriptions  */
274
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
275
	/* okay first of all, cause we are just hidding the PPPoE HTML
276
	 * fields releated to PPPoE resets, we are going to unset $_POST
277
	 * vars, if the reset feature should not be used. Otherwise the
278
	 * data validation procedure below, may trigger a false error
279
	 * message.
280
	 */
281
	if (empty($_POST['pppoe_preset'])) {
282
		unset($_POST['pppoe_pr_type']);                
283
		unset($_POST['pppoe_resethour']);
284
		unset($_POST['pppoe_resetminute']);
285
		unset($_POST['pppoe_resetdate']);
286
		unset($_POST['pppoe_pr_preset_val']);
287
	}
288
	/* optional interface if list */
289
	$iflist = get_configured_interface_with_descr();
290
	/* description unique? */
291
	foreach ($iflist as $ifent => $ifdescr) {
292
		if ($if != $ifent && $ifdescr == $_POST['descr'])
293
			$input_errors[] = "An interface with the specified description already exists.";
294
	}
295
	/* input validation */
296
	if ($_POST['type'] == "static") {
297
		$reqdfields = explode(" ", "ipaddr subnet gateway");
298
		$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
299
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
300
	} else if ($_POST['type'] == "PPPoE") {
301
		if ($_POST['pppoe_dialondemand']) {
302
			$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
303
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password,Dial on demand,Idle timeout value");
304
		} else {
305
			$reqdfields = explode(" ", "pppoe_username pppoe_password");
306
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password");
307
		}
308
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
309
	} else if ($_POST['type'] == "PPTP") {
310
		if ($_POST['pptp_dialondemand']) {
311
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
312
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address,Dial on demand,Idle timeout value");
313
		} else {
314
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
315
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address");
316
		}
317
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
318
	}
319
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
320
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
321
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) 
322
		$input_errors[] = "A valid IP address must be specified.";
323
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) 
324
		$input_errors[] = "A valid subnet bit count must be specified.";
325
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) 
326
		$input_errors[] = "A valid alias IP address must be specified.";
327
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) 
328
		$input_errors[] = "A valid alias subnet bit count must be specified.";
329
	if ($_POST['gateway'] != "none") {
330
		$match = false;
331
		foreach($a_gateways as $gateway) 
332
			if(in_array($_POST['gateway'], $gateway)) 
333
				$match = true;
334
		if(!$match)
335
			$input_errors[] = "A valid gateway must be specified.";
336
	}
337
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) 
338
		$input_errors[] = "A valid point-to-point IP address must be specified.";
339
	if (($_POST['provider'] && !is_domain($_POST['provider']))) 
340
		$input_errors[] = "The service name contains invalid characters.";
341
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) 
342
		$input_errors[] = "The idle timeout value must be an integer.";
343
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) && 
344
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) 
345
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
346
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) && 
347
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) 
348
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
349
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) 
350
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
351
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) 
352
		$input_errors[] = "A valid PPTP local IP address must be specified.";
353
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) 
354
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
355
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) 
356
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
357
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) 
358
		$input_errors[] = "The idle timeout value must be an integer.";
359
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) 
360
		$input_errors[] = "A valid MAC address must be specified.";
361
	if ($_POST['mtu'] && ($_POST['mtu'] < 576)) 
362
		$input_errors[] = "The MTU must be greater than 576 bytes.";
363
	/* Wireless interface? */
364
	if (isset($wancfg['wireless'])) {
365
		$reqdfields = explode(" ", "mode ssid");
366
		$reqdfieldsn = explode(",", "Mode,SSID");
367
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
368
		/* loop through keys and enforce size */
369
		for ($i = 1; $i <= 4; $i++) {
370
			if ($_POST['key' . $i]) {
371
				/* 64 bit */
372
				if (strlen($_POST['key' . $i]) == 5)
373
					continue;
374
				if (strlen($_POST['key' . $i]) == 10) {
375
					/* hex key */
376
					if (stristr($_POST['key' . $i], "0x") == false) {
377
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
378
					}
379
					continue;
380
				}
381
				if (strlen($_POST['key' . $i]) == 12) {
382
					/* hex key */
383
					if(stristr($_POST['key' . $i], "0x") == false) {
384
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
385
					}
386
					continue;
387
				}
388
				/* 128 bit */
389
				if (strlen($_POST['key' . $i]) == 13)
390
					continue;
391
				if (strlen($_POST['key' . $i]) == 26) {
392
					/* hex key */
393
					if (stristr($_POST['key' . $i], "0x") == false)
394
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
395
					continue;
396
				}
397
				if(strlen($_POST['key' . $i]) == 28)
398
					continue;
399
				$input_errors[] =  "Invalid wep key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.";
400
				break;
401
			}
402
		}
403
	}
404
	if (!$input_errors) {
405
		unset($wancfg['ipaddr']);
406
		unset($wancfg['subnet']);
407
		unset($wancfg['gateway']);
408
		unset($wancfg['pointtopoint']);
409
		unset($wancfg['dhcphostname']);
410
		unset($wancfg['pppoe_username']);
411
		unset($wancfg['pppoe_password']);
412
		unset($wancfg['pptp_username']);
413
		unset($wancfg['pptp_password']);
414
		unset($wancfg['provider']);
415
		unset($wancfg['ondemand']);
416
		unset($wancfg['timeout']);
417
		if ($wancfg['pppoe']['pppoe-reset-type'])
418
			unset($wancfg['pppoe']['pppoe-reset-type']);
419
		unset($wancfg['local']);
420
		unset($wancfg['subnet']);
421
		unset($wancfg['remote']);
422
		unset($wancfg['disableftpproxy']);
423
		/* per interface pftpx helper */
424
		if ($_POST['disableftpproxy'] == "yes")
425
			$wancfg['disableftpproxy'] = true;
426
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
427
		if ($if == "wan" || $if == "lan")
428
			$wancfg['enable'] = true;
429
		else
430
			$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
431
		if ($_POST['type'] == "static") {
432
			$wancfg['ipaddr'] = $_POST['ipaddr'];
433
			$wancfg['subnet'] = $_POST['subnet'];
434
			if ($_POST['gateway'] != "none")
435
				$wancfg['gateway'] = $_POST['gateway'];
436
			if (isset($wancfg['ispointtopoint']))
437
				$wancfg['pointtopoint'] = $_POST['pointtopoint'];
438
		} else if ($_POST['type'] == "dhcp") {
439
			$wancfg['ipaddr'] = "dhcp";
440
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
441
			$wancfg['alias-address'] = $_POST['alias-address'];
442
			$wancfg['alias-subnet'] = $_POST['alias-subnet'];
443
		} else if ($_POST['type'] == "carpdev-dhcp") {
444
			$wancfg['ipaddr'] = "carpdev-dhcp";
445
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
446
			$wancfg['alias-address'] = $_POST['alias-address'];
447
			$wancfg['alias-subnet'] = $_POST['alias-subnet'];			
448
		} else if ($_POST['type'] == "pppoe") {
449
			$wancfg['ipaddr'] = "pppoe";
450
			$wancfg['pppoe_username'] = $_POST['pppoe_username'];
451
			$wancfg['pppoe_password'] = $_POST['pppoe_password'];
452
			$wancfg['provider'] = $_POST['provider'];
453
			$wancfg['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
454
			$wancfg['timeout'] = $_POST['pppoe_idletimeout'];
455
		} else if ($_POST['type'] == "pptp") {
456
			$wancfg['ipaddr'] = "pptp";
457
			$wancfg['pptp_username'] = $_POST['pptp_username'];
458
			$wancfg['pptp_password'] = $_POST['pptp_password'];
459
			$wancfg['local'] = $_POST['pptp_local'];
460
			$wancfg['subnet'] = $_POST['pptp_subnet'];
461
			$wancfg['remote'] = $_POST['pptp_remote'];
462
			$wancfg['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
463
			$wancfg['timeout'] = $_POST['pptp_idletimeout'];
464
		}
465
		handle_pppoe_reset();
466
		/* reset cron items if necessary */
467
		if (empty($_POST['pppoe_preset'])) {
468
			/* test whether a cron item exists and unset() it if necessary */
469
			$itemhash = getMPDCRONSettings();
470
			$item = $itemhash['ITEM'];
471
			if (isset($item))
472
				unset($config['cron']['item'][$itemhash['ID']]); 
473
		}
474
		if($_POST['blockpriv'] == "yes")
475
			$wancfg['blockpriv'] = true;
476
		else
477
			unset($wancfg['blockpriv']);
478
		if($_POST['blockbogons'] == "yes")
479
			$wancfg['blockbogons'] = true;
480
		else
481
			unset($wancfg['blockbogons']);
482
		$wancfg['spoofmac'] = $_POST['spoofmac'];
483
		$wancfg['mtu'] = $_POST['mtu'];
484
		if (isset($wancfg['wireless'])) 
485
			handle_wireless_post();
486
		write_config();
487
		touch($d_landirty_path);
488
		conf_mount_ro();
489
		/* regenerate cron settings/crontab file */
490
		configure_cron();
491
		header("Location: interfaces.php?if={$if}");
492
		exit;
493
	}
494
} // end if($_POST) 
495

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

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

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

    
678
?>
679

    
680
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
681
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
682
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
683
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
684
<script type="text/javascript" src="/javascript/scriptaculous/prototype.js"></script>
685
<script type="text/javascript" src="/javascript/scriptaculous/scriptaculous.js"></script>
686

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

    
707
	function show_allcfg(obj) {
708
		if (obj.checked)
709
			$('allcfg').show();
710
		else
711
			$('allcfg').hide();
712
	}
713

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

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