Project

General

Profile

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

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

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

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

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

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

    
40
##|+PRIV
41
##|*IDENT=page-interfaces
42
##|*NAME=Interfaces: WAN page
43
##|*DESCR=Allow access to the 'Interfaces' page.
44
##|*MATCH=interfaces.php*
45
##|-PRIV
46

    
47
require_once("guiconfig.inc");
48
require_once("ipsec.inc");
49
require_once("functions.inc");
50
require_once("captiveportal.inc");
51
require_once("filter.inc");
52
require_once("shaper.inc");
53
require_once("rrd.inc");
54
require_once("vpn.inc");
55
require_once("xmlparse_attr.inc");
56

    
57
if ($_REQUEST['if']) {
58
	$if = $_REQUEST['if'];
59
} else {
60
	$if = "wan";
61
}
62

    
63
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
64
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
65
define("CRON_DAILY_PATTERN", "0 0 * * *");
66
define("CRON_HOURLY_PATTERN", "0 * * * *");
67

    
68
if (!is_array($config['ppps']['ppp']))
69
	$config['ppps']['ppp'] = array();
70

    
71
$a_ppps = &$config['ppps']['ppp'];
72

    
73
function remove_bad_chars($string) {
74
	return preg_replace('/[^a-z|_|0-9]/i','',$string);
75
}
76

    
77
if (!is_array($config['gateways']['gateway_item']))
78
	$config['gateways']['gateway_item'] = array();
79

    
80
$a_gateways = &$config['gateways']['gateway_item'];
81

    
82
$wancfg = &$config['interfaces'][$if];
83

    
84
foreach ($a_ppps as $pppid => $ppp) {
85
	if ($wancfg['if'] == $ppp['if'])
86
		break;
87
}
88

    
89
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
90
	$pconfig['pppid'] = $pppid;
91
	$pconfig['ptpid'] = $a_ppps[$pppid]['ptpid'];
92
	$pconfig['port'] = $a_ppps[$pppid]['ports'];
93
	if ($a_ppps[$pppid]['type'] == "ppp"){
94
		$pconfig['username'] = $a_ppps[$pppid]['username'];
95
		$pconfig['password'] = base64_decode($a_ppps[$pppid]['password']);
96
		
97
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
98
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
99
	}
100
	
101
	if ($a_ppps[$pppid]['type'] == "pppoe"){
102
		$pconfig['pppoe_username'] = $a_ppps[$pppid]['username'];
103
		$pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']);
104
		$pconfig['provider'] = $a_ppps[$pppid]['provider'];
105
		$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
106
		$pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout'];
107

    
108
		/* ================================================ */
109
		/* = force a connection reset at a specific time? = */
110
		/* ================================================ */
111
		
112
		if (isset($a_ppps[$pppid]['pppoe-reset-type'])) {
113
			$pconfig['pppoe-reset-type'] = $a_ppps[$pppid]['pppoe-reset-type'];
114
			$itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']);
115
			$cronitem = $itemhash['ITEM'];
116
			if (isset($cronitem)) {
117
				$resetTime = "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
118
			} else {
119
				$resetTime = NULL;
120
			}
121
			log_error("ResetTime:".$resetTime);
122
			if ($a_ppps[$pppid]['pppoe-reset-type'] == "custom") {
123
				$resetTime_a = split(" ", $resetTime);
124
				$pconfig['pppoe_pr_custom'] = true;
125
				$pconfig['pppoe_resetminute'] = $resetTime_a[0];
126
				$pconfig['pppoe_resethour'] = $resetTime_a[1];
127
				/*  just initialize $pconfig['pppoe_resetdate'] if the
128
				 *  coresponding item contains appropriate numeric values.
129
				 */
130
				if ($resetTime_a[2] <> "*" && $resetTime_a[3] <> "*") 
131
					$pconfig['pppoe_resetdate'] = "{$resetTime_a[3]}/{$resetTime_a[2]}/" . date("Y");
132
			} else if ($a_ppps[$pppid]['pppoe-reset-type'] == "preset") {
133
				$pconfig['pppoe_pr_preset'] = true;
134
				switch ($resetTime) {
135
					case CRON_MONTHLY_PATTERN:
136
						$pconfig['pppoe_monthly'] = true;
137
						break;
138
					case CRON_WEEKLY_PATTERN:
139
						$pconfig['pppoe_weekly'] = true;
140
						break;
141
					case CRON_DAILY_PATTERN:
142
						$pconfig['pppoe_daily'] = true;
143
						break;
144
					case CRON_HOURLY_PATTERN:
145
						$pconfig['pppoe_hourly'] = true;
146
						break;
147
				}
148
			}
149
		}// End force pppoe reset at specific time
150
	}// End if type == pppoe		
151
	if ($a_ppps[$pppid]['type'] == "pptp"){
152
		$pconfig['pptp_username'] = $a_ppps[$pppid]['username'];
153
		$pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']);
154
		$pconfig['pptp_local'] = explode(",",$a_ppps[$pppid]['localip']);
155
		$pconfig['pptp_subnet'] = explode(",",$a_ppps[$pppid]['subnet']);
156
		$pconfig['pptp_remote'] = explode(",",$a_ppps[$pppid]['gateway']);
157
		$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
158
		$pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout'];
159
	}
160
} else {
161
	$pconfig['ptpid'] = interfaces_ptpid_next();
162
	$pppid = count($a_ppps);
163
}
164
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
165
$pconfig['alias-address'] = $wancfg['alias-address'];
166
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
167

    
168
// Populate page descr if it does not exist.
169
if($if == "wan" && !$wancfg['descr']) {
170
	$wancfg['descr'] = "WAN";
171
} else if ($if == "lan" && !$wancfg['descr']) {
172
	$wancfg['descr'] = "LAN";
173
}
174
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
175

    
176
$pconfig['enable'] = isset($wancfg['enable']);
177

    
178
if (is_array($config['aliases']['alias'])) {
179
	foreach($config['aliases']['alias'] as $alias) {
180
		if($alias['name'] == $wancfg['descr']) {
181
			$input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} already exists.");
182
		}
183
	}
184
}
185

    
186
switch($wancfg['ipaddr']) {
187
	case "dhcp":
188
		$pconfig['type'] = "dhcp";
189
		break;
190
	case "carpdev-dhcp":
191
		$pconfig['type'] = "carpdev-dhcp";
192
		$pconfig['ipaddr'] = "";
193
		break;
194
	case "pppoe":
195
	case "pptp":
196
	case "ppp":
197
		$pconfig['type'] = $wancfg['ipaddr'];
198
		break;
199
	default:
200
		if(is_ipaddr($wancfg['ipaddr'])) {
201
			$pconfig['type'] = "static";
202
			$pconfig['ipaddr'] = $wancfg['ipaddr'];
203
			$pconfig['subnet'] = $wancfg['subnet'];
204
			$pconfig['gateway'] = $wancfg['gateway'];
205
		} else {
206
			$pconfig['type'] = "none";
207
		}
208
		break;
209
}
210

    
211
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
212
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
213
$pconfig['spoofmac'] = $wancfg['spoofmac'];
214
$pconfig['mtu'] = $wancfg['mtu'];
215

    
216
/* Wireless interface? */
217
if (isset($wancfg['wireless'])) {
218
	/* Get wireless modes */
219
	$wlanif = get_real_interface($if);
220
	if (!does_interface_exist($wlanif))
221
		interface_wireless_clone($wlanif, $wancfg);
222
	$wlanbaseif = interface_get_wireless_base($wancfg['if']);
223
	$wl_modes = get_wireless_modes($if);
224
	$wl_chaninfo = get_wireless_channel_info($if);
225
	$wl_regdomain_xml_attr = array();
226
	$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
227
	$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
228
	$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
229
	$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
230
	$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
231
	$pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]);
232
	$pconfig['standard'] = $wancfg['wireless']['standard'];
233
	$pconfig['mode'] = $wancfg['wireless']['mode'];
234
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
235
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
236
	$pconfig['channel'] = $wancfg['wireless']['channel'];
237
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
238
	$pconfig['distance'] = $wancfg['wireless']['distance'];
239
	$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
240
	$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
241
	$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
242
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
243
	if (isset($wancfg['wireless']['puren']['enable']))
244
		$pconfig['puremode'] = '11n';
245
	else if (isset($wancfg['wireless']['pureg']['enable']))
246
		$pconfig['puremode'] = '11g';
247
	else
248
		$pconfig['puremode'] = 'any';
249
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
250
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
251
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
252
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
253
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
254
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
255
	if (is_array($wancfg['wireless']['wpa'])) {
256
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
257
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
258
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
259
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
260
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
261
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
262
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
263
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
264
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
265
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
266
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
267
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
268
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
269
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
270
	}
271
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
272
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
273
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
274
		$i = 1;
275
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
276
			$pconfig['key' . $i] = $wepkey['value'];
277
			if (isset($wepkey['txkey']))
278
				$pconfig['txkey'] = $i;
279
			$i++;
280
		}
281
		if (!isset($wepkey['txkey']))
282
			$pconfig['txkey'] = 1;
283
	}
284
}
285

    
286
if ($_POST['apply']) {
287
	unset($input_errors);
288
	if (!is_subsystem_dirty('interfaces'))
289
		$intput_errors[] = "You have already applied your settings!";
290
	else {	
291
		unlink_if_exists("{$g['tmp_path']}/config.cache");
292
		clear_subsystem_dirty('interfaces');
293
		if ($pconfig['enable'])
294
			interface_configure($if, true);
295
		else
296
			interface_bring_down($if);
297
		
298
		/* restart snmp so that it binds to correct address */		
299
		services_snmpd_configure();		
300
		if ($if == "lan") 		
301
			$savemsg = "The changes have been applied.  You may need to correct your web browser's IP address.";
302

    
303
		/* sync filter configuration */
304
		setup_gateways_monitor();
305

    
306
		clear_subsystem_dirty('staticroutes');
307
		
308
		filter_configure();
309
		
310
		enable_rrd_graphing();
311
	}
312
	header("Location: interfaces.php?if={$if}");
313
	exit;
314
} else
315

    
316
if ($_POST && $_POST['enable'] != "yes") {
317
	unset($wancfg['enable']);
318
	if (isset($wancfg['wireless'])) {
319
		interface_sync_wireless_clones($wancfg, false);
320
	}
321
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
322
	mark_subsystem_dirty('interfaces');
323
	header("Location: interfaces.php?if={$if}");
324
	exit;
325
} else
326

    
327
if ($_POST) {
328
	unset($input_errors);
329
	$pconfig = $_POST;
330
	conf_mount_rw();
331
	/* filter out spaces from descriptions  */
332
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
333
	/* okay first of all, cause we are just hiding the PPPoE HTML
334
	 * fields releated to PPPoE resets, we are going to unset $_POST
335
	 * vars, if the reset feature should not be used. Otherwise the
336
	 * data validation procedure below, may trigger a false error
337
	 * message.
338
	 */
339
	if (empty($_POST['pppoe-reset-type'])) {
340
		unset($_POST['pppoe_pr_type']);                
341
		unset($_POST['pppoe_resethour']);
342
		unset($_POST['pppoe_resetminute']);
343
		unset($_POST['pppoe_resetdate']);
344
		unset($_POST['pppoe_pr_preset_val']);
345
	}
346
	/* optional interface if list */
347
	$iflist = get_configured_interface_with_descr();
348
	/* description unique? */
349
	foreach ($iflist as $ifent => $ifdescr) {
350
		if ($if != $ifent && $ifdescr == $_POST['descr'])
351
			$input_errors[] = "An interface with the specified description already exists.";
352
	}
353
	/* input validation */
354
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && $_POST['type'] != "static")
355
		$input_errors[] = "The DHCP Server is active on this interface and it can be used only with a static IP configuration. Please disable the DHCP Server service on this interface first, then change the interface configuration.";
356

    
357
	switch($_POST['type']) {
358
		case "static":
359
			$reqdfields = explode(" ", "ipaddr subnet gateway");
360
			$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
361
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
362
			break;
363
		case "ppp":
364
			$reqdfields = explode(" ", "port phone");
365
			$reqdfieldsn = explode(",", "Modem Port,Phone Number");
366
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
367
			break;
368
		case "PPPoE":
369
			if ($_POST['pppoe_dialondemand']) {
370
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
371
				$reqdfieldsn = explode(",", "PPPoE username,PPPoE password,Dial on demand,Idle timeout value");
372
			} else {
373
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
374
				$reqdfieldsn = explode(",", "PPPoE username,PPPoE password");
375
			}
376
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
377
			break;
378
		case "PPTP":
379
			if ($_POST['pptp_dialondemand']) {
380
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
381
				$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address,Dial on demand,Idle timeout value");
382
			} else {
383
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
384
				$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address");
385
			}
386
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
387
			break;
388
	}
389

    
390
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
391
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
392
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) 
393
		$input_errors[] = "A valid IP address must be specified.";
394
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) 
395
		$input_errors[] = "A valid subnet bit count must be specified.";
396
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) 
397
		$input_errors[] = "A valid alias IP address must be specified.";
398
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) 
399
		$input_errors[] = "A valid alias subnet bit count must be specified.";
400
	if ($_POST['gateway'] != "none") {
401
		$match = false;
402
		foreach($a_gateways as $gateway) {
403
			if(in_array($_POST['gateway'], $gateway)) {
404
				$match = true;
405
			}
406
		}
407
		if(!$match) {
408
			$input_errors[] = "A valid gateway must be specified.";
409
		}
410
	}
411
	if (($_POST['provider'] && !is_domain($_POST['provider']))) 
412
		$input_errors[] = "The service name contains invalid characters.";
413
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) 
414
		$input_errors[] = "The idle timeout value must be an integer.";
415
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) && 
416
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) 
417
			$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
418
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) && 
419
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) 
420
			$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
421
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) 
422
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
423
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) 
424
		$input_errors[] = "A valid PPTP local IP address must be specified.";
425
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) 
426
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
427
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) 
428
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
429
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) 
430
		$input_errors[] = "The idle timeout value must be an integer.";
431
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) 
432
		$input_errors[] = "A valid MAC address must be specified.";
433
	if ($_POST['mtu'] && ($_POST['mtu'] < 576)) 
434
		$input_errors[] = "The MTU must be greater than 576 bytes.";
435
	/* Wireless interface? */
436
	if (isset($wancfg['wireless'])) {
437
		$reqdfields = explode(" ", "mode ssid");
438
		$reqdfieldsn = explode(",", "Mode,SSID");
439
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
440
		check_wireless_mode();
441
		/* loop through keys and enforce size */
442
		for ($i = 1; $i <= 4; $i++) {
443
			if ($_POST['key' . $i]) {
444
				/* 64 bit */
445
				if (strlen($_POST['key' . $i]) == 5)
446
					continue;
447
				if (strlen($_POST['key' . $i]) == 10) {
448
					/* hex key */
449
					if (stristr($_POST['key' . $i], "0x") == false) {
450
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
451
					}
452
					continue;
453
				}
454
				if (strlen($_POST['key' . $i]) == 12) {
455
					/* hex key */
456
					if(stristr($_POST['key' . $i], "0x") == false) {
457
					$_POST['key' . $i] = "0x" . $_POST['key' . $i];
458
					}
459
					continue;
460
				}
461
				/* 128 bit */
462
				if (strlen($_POST['key' . $i]) == 13)
463
					continue;
464
				if (strlen($_POST['key' . $i]) == 26) {
465
					/* hex key */
466
					if (stristr($_POST['key' . $i], "0x") == false)
467
						$_POST['key' . $i] = "0x" . $_POST['key' . $i];
468
					continue;
469
				}
470
				if(strlen($_POST['key' . $i]) == 28)
471
					continue;
472
				$input_errors[] =  "Invalid WEP key size.   Sizes should be 40 (64) bit keys or 104 (128) bit.";
473
				break;
474
			}
475
		}
476

    
477
		if ($_POST['passphrase']) {
478
                	$passlen = strlen($_POST['passphrase']);
479
                	if ($passlen < 8 || $passlen > 64)
480
                        	$input_errors[] = "The length of the passphrase should be between 8 and 63 characters.";
481
		}
482
	}
483
	if (!$input_errors) {
484
		$ppp = array();
485
		if ($wancfg['ipaddr'] != "ppp")
486
			unset($wancfg['ipaddr']);
487
		unset($wancfg['subnet']);
488
		unset($wancfg['gateway']);
489
		unset($wancfg['dhcphostname']);
490
		unset($wancfg['pppoe_username']);
491
		unset($wancfg['pppoe_password']);
492
		unset($wancfg['pptp_username']);
493
		unset($wancfg['pptp_password']);
494
		unset($wancfg['provider']);
495
		unset($wancfg['ondemand']);
496
		unset($wancfg['timeout']);
497
		if (isset($wancfg['pppoe']['pppoe-reset-type']))
498
			unset($wancfg['pppoe']['pppoe-reset-type']);
499
		unset($wancfg['local']);
500
		unset($wancfg['subnet']);
501
		unset($wancfg['remote']);
502
		unset($a_ppps[$pppid]['apn']);
503
		unset($a_ppps[$pppid]['phone']);
504
		unset($a_ppps[$pppid]['localip']);
505
		unset($a_ppps[$pppid]['subnet']);
506
		unset($a_ppps[$pppid]['gateway']);
507
		unset($a_ppps[$pppid]['pppoe-reset-type']);
508
		unset($a_ppps[$pppid]['provider']);
509
		
510
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
511
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
512

    
513
		/* for dynamic interfaces we tack a gateway item onto the array to prevent system
514
		 * log messages from appearing. They can also manually add these items */
515
		/* 1st added gateway gets a default bit */
516
		if(!empty($a_gateways)) {
517
			$gateway_item = array();
518
			/* check for duplicates */
519
			$skip = false;
520
			foreach($a_gateways as $item) {
521
				if(($item['interface'] == "$if") && ($item['gateway'] == "dynamic")) {
522
					$skip = true;
523
				}
524
			}
525
			if($skip == false) {
526
				$gateway_item['gateway'] = "dynamic";
527
				$gateway_item['descr'] = "Interface {$if} dynamic gateway";
528
				$gateway_item['name'] = "GW_" . strtoupper($if);
529
				$gateway_item['interface'] = "{$if}";
530
			} else {
531
				unset($gateway_item);
532
			}
533
		}
534
			
535
		switch($_POST['type']) {
536
			case "static":
537
				$wancfg['ipaddr'] = $_POST['ipaddr'];
538
				$wancfg['subnet'] = $_POST['subnet'];
539
				if ($_POST['gateway'] != "none") {
540
					$wancfg['gateway'] = $_POST['gateway'];
541
				}
542
				break;
543
			case "dhcp":
544
				$wancfg['ipaddr'] = "dhcp";
545
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
546
				$wancfg['alias-address'] = $_POST['alias-address'];
547
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
548
				if($gateway_item) {
549
					$a_gateways[] = $gateway_item;
550
				}
551
				break;
552
			case "carpdev-dhcp":
553
				$wancfg['ipaddr'] = "carpdev-dhcp";
554
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
555
				$wancfg['alias-address'] = $_POST['alias-address'];
556
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
557
				if($gateway_item) {
558
					$a_gateways[] = $gateway_item;
559
				}
560
				break;
561
			case "ppp":
562
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
563
				$a_ppps[$pppid]['type'] = $_POST['type'];
564
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
565
				$a_ppps[$pppid]['ports'] = $_POST['port'];
566
				$a_ppps[$pppid]['username'] = $_POST['username'];
567
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
568
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
569
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
570
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
571
				$wancfg['ipaddr'] = $_POST['type'];
572
				unset($a_ppps[$pppid]['ondemand']);
573
				unset($a_ppps[$pppid]['idletimeout']);
574
				break;
575

    
576
			case "pppoe":
577
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
578
				$a_ppps[$pppid]['type'] = $_POST['type'];
579
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
580
				if (isset($_POST['ppp_port']))
581
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
582
				else
583
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
584
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
585
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
586
				if (!empty($_POST['provider']))
587
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
588
				else
589
					unset($a_ppps[$pppid]['provider']);
590
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
591
				if (!empty($_POST['idletimeout']))
592
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
593
				else
594
					unset($a_ppps[$pppid]['idletimeout']);
595

    
596
				if (!empty($_POST['pppoe-reset-type']))
597
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
598
				else
599
					unset($a_ppps[$pppid]['pppoe-reset-type']);
600
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
601
				$wancfg['ipaddr'] = $_POST['type'];
602
				if($gateway_item) {
603
					$a_gateways[] = $gateway_item;
604
				}
605
				
606
				break;
607
			case "pptp":
608
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
609
				$a_ppps[$pppid]['type'] = $_POST['type'];
610
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
611
				if (isset($_POST['ppp_port']))
612
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
613
				else
614
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
615
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
616
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
617
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
618
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
619
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
620
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
621
				if (!empty($_POST['idletimeout']))
622
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
623
				else
624
					unset($a_ppps[$pppid]['idletimeout']);
625
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
626
				$wancfg['ipaddr'] = $_POST['type'];
627
				if($gateway_item) {
628
					$a_gateways[] = $gateway_item;
629
				}
630
				break;
631
			case "none":
632
				break;
633
		}
634
		handle_pppoe_reset($_POST);
635
		
636
		if($_POST['blockpriv'] == "yes") {
637
			$wancfg['blockpriv'] = true;
638
		} else {
639
			unset($wancfg['blockpriv']);
640
		}
641
		if($_POST['blockbogons'] == "yes") {
642
			$wancfg['blockbogons'] = true;
643
		} else {
644
			unset($wancfg['blockbogons']);
645
		}
646
		$wancfg['spoofmac'] = $_POST['spoofmac'];
647
		if (empty($_POST['mtu'])) {
648
			unset($wancfg['mtu']);
649
		} else {
650
			$wancfg['mtu'] = $_POST['mtu'];
651
		}
652
		if (isset($wancfg['wireless'])) {
653
			handle_wireless_post();
654
		}
655
		
656
		write_config();
657
		mark_subsystem_dirty('interfaces');
658
		/* regenerate cron settings/crontab file */
659
		configure_cron();
660
		conf_mount_ro();
661
		header("Location: interfaces.php?if={$if}");
662
		exit;
663
	}
664
	
665
	
666
	
667
} // end if($_POST) 
668

    
669
function handle_wireless_post() {
670
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
671
	if (!is_array($wancfg['wireless']))
672
		$wancfg['wireless'] = array();
673
	$wancfg['wireless']['standard'] = $_POST['standard'];
674
	$wancfg['wireless']['mode'] = $_POST['mode'];
675
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
676
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
677
	$wancfg['wireless']['channel'] = $_POST['channel'];
678
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
679
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
680
	$wancfg['wireless']['distance'] = $_POST['distance'];
681
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
682
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
683
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
684
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
685
		foreach($wl_countries_attr as $wl_country) {
686
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
687
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
688
				break;
689
			}
690
		}
691
	}
692
	if (!is_array($wancfg['wireless']['wpa']))
693
		$wancfg['wireless']['wpa'] = array();
694
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
695
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
696
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
697
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
698
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
699
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
700
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
701
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
702
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
703
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
704
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
705
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
706
	if ($_POST['persistcommonwireless'] == "yes") {
707
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
708
			$config['wireless']['interfaces'][$wlanbaseif] = array();
709
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
710
		unset($config['wireless']['interfaces'][$wlanbaseif]);
711
	if ($_POST['hidessid_enable'] == "yes")
712
		$wancfg['wireless']['hidessid']['enable'] = true;
713
	else if (isset($wancfg['wireless']['hidessid']['enable']))
714
		unset($wancfg['wireless']['hidessid']['enable']);
715
	if ($_POST['mac_acl_enable'] == "yes")
716
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
717
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
718
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
719
	if ($_POST['ieee8021x'] == "yes")
720
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
721
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
722
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
723
	if ($_POST['wpa_strict_rekey'] == "yes")
724
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
725
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
726
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
727
	if ($_POST['debug_mode'] == "yes")
728
		$wancfg['wireless']['wpa']['debug_mode'] = true;
729
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
730
		sunset($wancfg['wireless']['wpa']['debug_mode']);
731
	if ($_POST['wpa_enable'] == "yes")
732
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
733
	else if (isset($wancfg['wireless']['wpa']['enable']))
734
		unset($wancfg['wireless']['wpa']['enable']);
735
	if ($_POST['wep_enable'] == "yes") {
736
		if (!is_array($wancfg['wireless']['wep']))
737
			$wancfg['wireless']['wep'] = array();
738
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
739
	} else if (isset($wancfg['wireless']['wep']))
740
		unset($wancfg['wireless']['wep']);
741
	if ($_POST['wme_enable'] == "yes") {
742
		if (!is_array($wancfg['wireless']['wme']))
743
			$wancfg['wireless']['wme'] = array();
744
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
745
	} else if (isset($wancfg['wireless']['wme']['enable']))
746
		unset($wancfg['wireless']['wme']['enable']);
747
	if ($_POST['puremode'] == "11g") {
748
		if (!is_array($wancfg['wireless']['pureg']))
749
			$wancfg['wireless']['pureg'] = array();
750
		$wancfg['wireless']['pureg']['enable'] = true;
751
	} else if ($_POST['puremode'] == "11n") {
752
		if (!is_array($wancfg['wireless']['puren']))
753
			$wancfg['wireless']['puren'] = array();
754
		$wancfg['wireless']['puren']['enable'] = true;
755
	} else {
756
		if (isset($wancfg['wireless']['pureg']))
757
			unset($wancfg['wireless']['pureg']);
758
		if (isset($wancfg['wireless']['puren']))
759
			unset($wancfg['wireless']['puren']);
760
	}
761
	if ($_POST['apbridge_enable'] == "yes") {
762
		if (!is_array($wancfg['wireless']['apbridge']))
763
			$wancfg['wireless']['apbridge'] = array();
764
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
765
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
766
		unset($wancfg['wireless']['apbridge']['enable']);
767
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
768
		if (!is_array($wancfg['wireless']['turbo']))
769
			$wancfg['wireless']['turbo'] = array();
770
		$wancfg['wireless']['turbo']['enable'] = true;
771
	} else if (isset($wancfg['wireless']['turbo']['enable']))
772
		unset($wancfg['wireless']['turbo']['enable']);
773
	$wancfg['wireless']['wep']['key'] = array();
774
	for ($i = 1; $i <= 4; $i++) {
775
		if ($_POST['key' . $i]) {
776
			$newkey = array();
777
			$newkey['value'] = $_POST['key' . $i];
778
			if ($_POST['txkey'] == $i)
779
				$newkey['txkey'] = true;
780
			$wancfg['wireless']['wep']['key'][] = $newkey;
781
		}
782
	}
783
	interface_sync_wireless_clones($wancfg, true);
784
}
785

    
786
function check_wireless_mode() {
787
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
788

    
789
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
790
		return;
791

    
792
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
793
		$clone_count = 1;
794
	else
795
		$clone_count = 0;
796
	if (is_array($config['wireless']['clone'])) {
797
		foreach ($config['wireless']['clone'] as $clone) {
798
			if ($clone['if'] == $wlanbaseif)
799
				$clone_count++;
800
		}
801
	}
802
	if ($clone_count > 1) {
803
		$old_wireless_mode = $wancfg['wireless']['mode'];
804
		$wancfg['wireless']['mode'] = $_POST['mode'];
805
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
806
			$input_errors[] = "Unable to change mode to {$wlan_modes[$wancfg['wireless']['mode']]}.  You may already have the maximum number of wireless clones supported in this mode.";
807
		} else {
808
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
809
		}
810
		$wancfg['wireless']['mode'] = $old_wireless_mode;
811
	}
812
}
813

    
814
$pgtitle = array("Interfaces", $pconfig['descr']);
815
$statusurl = "status_interfaces.php";
816

    
817
$closehead = false;
818
include("head.inc");
819
$types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "ppp" => "PPP", "pppoe" => "PPPoE", "pptp" => "PPTP" /* , "carpdev-dhcp" => "CarpDev"*/); 
820

    
821
?>
822

    
823
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
824
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
825
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
826
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
827

    
828
<script type="text/javascript">
829
	function updateType(t) {
830
		switch(t) {
831
			case "none": {
832
				$('static','dhcp','pppoe','pptp', 'ppp').invoke('hide');
833
				break;
834
			}
835
			case "static": {
836
				$('none','dhcp','pppoe','pptp', 'ppp').invoke('hide');
837
				break;
838
			}
839
			case "dhcp": {
840
				$('none','static','pppoe','pptp', 'ppp').invoke('hide');
841
				break;
842
			}
843
			case "ppp": {
844
				$('none','static','dhcp','pptp', 'pppoe').invoke('hide');
845
				country_list();
846
				break;
847
			}
848
			case "pppoe": {
849
				$('none','static','dhcp','pptp', 'ppp').invoke('hide');
850
				break;
851
			}
852
			case "pptp": {
853
				$('none','static','dhcp','pppoe', 'ppp').invoke('hide');
854
				break;
855
			}
856
		}
857
		$(t).show();
858
	}
859

    
860
	function show_allcfg(obj) {
861
		if (obj.checked)
862
			$('allcfg').show();
863
		else
864
			$('allcfg').hide();
865
	}
866

    
867
	function show_reset_settings(reset_type) {
868
		if (reset_type == 'preset') { 
869
			Effect.Appear('pppoepresetwrap', { duration: 0.0 });
870
			Effect.Fade('pppoecustomwrap', { duration: 0.0 }); 
871
		} 
872
		else if (reset_type == 'custom') { 
873
			Effect.Appear('pppoecustomwrap', { duration: 0.0 });
874
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
875
		} else {
876
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
877
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
878
		}
879
	}
880
	function show_mon_config() {
881
		document.getElementById("showmonbox").innerHTML='';
882
		aodiv = document.getElementById('showmon');
883
		aodiv.style.display = "block";
884
	}
885

    
886
	function openwindow(url) {
887
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
888
		if (oWin==null || typeof(oWin)=="undefined") 
889
			return false;
890
		else 
891
			return true;
892
	}
893
	function country_list() {
894
		$('country').childElements().each(function(node) { node.remove(); });
895
		$('provider').childElements().each(function(node) { node.remove(); });
896
		$('providerplan').childElements().each(function(node) { node.remove(); });
897
		new Ajax.Request("getserviceproviders.php",{
898
			onSuccess: function(response) {
899
				var responseTextArr = response.responseText.split("\n");
900
				responseTextArr.sort();
901
				responseTextArr.each( function(value) {
902
					var option = new Element('option');
903
					country = value.split(":");
904
					option.text = country[0];
905
					option.value = country[1];
906
					$('country').insert({ bottom : option });
907
				});
908
			}
909
		});
910
		$('trcountry').setStyle({display : "table-row"});
911
	}
912
	
913
	function providers_list() {
914
		$('provider').childElements().each(function(node) { node.remove(); });
915
		$('providerplan').childElements().each(function(node) { node.remove(); });
916
		new Ajax.Request("getserviceproviders.php",{
917
			parameters: {country : $F('country')},
918
			onSuccess: function(response) {
919
				var responseTextArr = response.responseText.split("\n");
920
				responseTextArr.sort();
921
				responseTextArr.each( function(value) {
922
					var option = new Element('option');
923
					option.text = value;
924
					option.value = value;
925
					$('provider').insert({ bottom : option });
926
				});
927
			}
928
		});
929
		$('trprovider').setStyle({display : "table-row"});
930
		$('trproviderplan').setStyle({display : "none"});
931
	}
932
	
933
	function providerplan_list() {
934
		$('providerplan').childElements().each(function(node) { node.remove(); });
935
		$('providerplan').insert( new Element('option') );
936
		new Ajax.Request("getserviceproviders.php",{
937
			parameters: {country : $F('country'), provider : $F('provider')},
938
			onSuccess: function(response) {
939
				var responseTextArr = response.responseText.split("\n");
940
				responseTextArr.sort();
941
				responseTextArr.each( function(value) {
942
					if(value != "") {
943
						providerplan = value.split(":");
944
	
945
						var option = new Element('option');
946
						option.text = providerplan[0] + " - " + providerplan[1];
947
						option.value = providerplan[1];
948
						$('providerplan').insert({ bottom : option });
949
					}
950
				});
951
			}
952
		});
953
		$('trproviderplan').setStyle({display : "table-row"});
954
	}
955
	
956
	function prefill_provider() {
957
		new Ajax.Request("getserviceproviders.php",{
958
			parameters: {country : $F('country'), provider : $F('provider'), plan : $F('providerplan')},
959
			onSuccess: function(response) {
960
				var xmldoc = response.responseXML;
961
				var provider = xmldoc.getElementsByTagName('connection')[0];
962
				$('username').setValue('');
963
				$('password').setValue('');
964
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
965
					$('phone').setValue('*777');
966
					$('apn').setValue('');
967
				} else {
968
					$('phone').setValue('*99#');
969
					$('apn').setValue(provider.getElementsByTagName('apn')[0].firstChild.data);
970
				}
971
				$('username').setValue(provider.getElementsByTagName('username')[0].firstChild.data);
972
				$('password').setValue(provider.getElementsByTagName('password')[0].firstChild.data);
973
			}
974
		});
975
	}
976

    
977
</script>
978
</head>
979
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
980
	<?php include("fbegin.inc"); ?>
981
	<form action="interfaces.php" method="post" name="iform" id="iform">
982
		<?php if ($input_errors) print_input_errors($input_errors); ?>
983
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
984
		<?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 after applying."));?><br />
985
		<?php endif; ?>
986
		<?php if ($savemsg) print_info_box($savemsg); ?>
987
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
988
			<tr>
989
				<td id="mainarea">
990
					<div class="tabcont">
991
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
992
						<tr>
993
							<td colspan="2" valign="top" class="listtopic">General configuration</td>
994
						</tr>
995
						<tr>
996
							<td width="22%" valign="top" class="vncell">Enable</td>
997
							<td width="78%" class="vtable">
998
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked"; ?> onClick="show_allcfg(this);">
999
							<strong>Enable Interface</strong>
1000
							</td>
1001
						</tr>
1002
					</table>
1003
					<div style="display:none;" name="allcfg" id="allcfg">
1004
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1005
						<tr>
1006
							<td width="22%" valign="top" class="vncell">Description</td>
1007
							<td width="78%" class="vtable">
1008
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
1009
								<br><span class="vexpl">Enter a description (name) for the interface here.</span>
1010
							</td>
1011
						</tr>
1012
						<tr>
1013
							<td valign="middle" class="vncell"><strong>Type</strong></td>
1014
							<td class="vtable"> 
1015
								<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
1016
								<?php 
1017
									foreach ($types as $key => $opt) { 
1018
										echo "<option onClick=\"updateType('{$key}');\"";
1019
										if ($key == $pconfig['type']) 
1020
											echo " selected";
1021
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1022
										echo "</option>";
1023
									} 
1024
								?>
1025
								</select>
1026
							</td>
1027
						</tr>
1028
						<tr>
1029
							<td valign="top" class="vncell">MAC address</td>
1030
							<td class="vtable">
1031
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
1032
								<?php
1033
									$ip = getenv('REMOTE_ADDR');
1034
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1035
									$mac = str_replace("\n","",$mac);
1036
									if($mac):
1037
								?>
1038
									<a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#">Insert my local MAC address</a>
1039
								<?php endif; ?>
1040
								<br>
1041
								This field can be used to modify (&quot;spoof&quot;) the MAC
1042
								address of the WAN interface<br>
1043
								(may be required with some cable connections)<br>
1044
								Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx
1045
								or leave blank
1046
							</td>
1047
						</tr>
1048
						<tr>
1049
							<td valign="top" class="vncell">MTU</td>
1050
							<td class="vtable"> 
1051
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
1052
								<br>
1053
								If you enter a value in this field, then MSS clamping for
1054
								TCP connections to the value entered above minus 40 (TCP/IP
1055
								header size) will be in effect. If you leave this field blank,
1056
								an MTU of 1500 bytes will be assumed.
1057
							</td>
1058
						</tr>
1059
						<tr>
1060
							<td colspan="2" valign="top" height="16"></td>
1061
						</tr>			
1062
						<tr style="display:none;" name="none" id="none">
1063
						</tr>
1064
						<tr style="display:none;" name="static" id="static">
1065
							<td colspan="2" style="padding:0px;">
1066
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1067
									<tr>
1068
										<td colspan="2" valign="top" class="listtopic">Static IP configuration</td>
1069
									</tr>
1070
									<tr>
1071
										<td width="22%" valign="top" class="vncellreq">IP address</td>
1072
										<td width="78%" class="vtable"> 
1073
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
1074
											/
1075
											<select name="subnet" class="formselect" id="subnet">
1076
												<?php
1077
												for ($i = 32; $i > 0; $i--) {
1078
													if($i <> 31) {
1079
														echo "<option value=\"{$i}\" ";
1080
														if ($i == $pconfig['subnet']) echo "selected";
1081
														echo ">" . $i . "</option>";
1082
													}
1083
												}
1084
												?>
1085
											</select>
1086
										</td>
1087
									</tr>
1088
									<tr>
1089
										<td width="22%" valign="top" class="vncellreq">Gateway</td>
1090
										<td width="78%" class="vtable">
1091
											<select name="gateway" class="formselect" id="gateway">
1092
												<option value="none" selected>None</option>
1093
													<?php
1094
													if(count($a_gateways) > 0) {
1095
														foreach ($a_gateways as $gateway) {
1096
															if($gateway['interface'] == $if) {
1097
													?>
1098
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
1099
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1100
															</option>
1101
													<?php
1102
															}
1103
														}
1104
													}
1105
													?>
1106
											</select>
1107
											<br/>
1108
											<div id='addgwbox'>
1109
												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>.
1110
											</div>
1111
											<div id='notebox'>
1112
											</div>
1113
											<div id="status">
1114
											</div>								
1115
											<div style="display:none" id="addgateway" name="addgateway">
1116
												<p> 
1117
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1118
													<tr>
1119
														<td>
1120
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1121
																<tr><td>&nbsp;</td>
1122
																<tr>
1123
																	<td colspan="2"><center><b><font color="white">Add new gateway:</font></b></center></td>
1124
																</tr>
1125
																<tr><td>&nbsp;</td>
1126
																<?php
1127
																if($if == "wan" || $if == "WAN")
1128
																	$checked = " CHECKED";
1129
																?>
1130
																<tr>
1131
																	<td width="45%" align="right"><font color="white">Default  gateway:</td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
1132
																</tr>												
1133
																<tr>
1134
																	<td align="right"><font color="white">Gateway Name:</td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td>
1135
																</tr>
1136
																<tr>
1137
																	<td align="right"><font color="white">Gateway IP:</td><td><input id="gatewayip" name="gatewayip"></td>
1138
																</tr>
1139
																<tr>
1140
																	<td align="right"><font color="white">Description:</td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1141
																</tr>
1142
																<tr><td>&nbsp;</td>
1143
																<tr>
1144
																	<td colspan="2">
1145
																		<center>
1146
																			<div id='savebuttondiv'>
1147
																				<input type="hidden" name="addrtype" id="addrtype" value="IPv4" />
1148
																				<input id="gwsave" type="Button" value="Save Gateway" onClick='hide_add_gatewaysave();'> 
1149
																				<input id="gwcancel" type="Button" value="Cancel" onClick='hide_add_gateway();'>
1150
																			</div>
1151
																		</center>
1152
																	</td>
1153
																</tr>
1154
																<tr><td>&nbsp;</td></tr>
1155
															</table>
1156
														</td>
1157
													</tr>
1158
												</table>
1159
												<p/>
1160
											</div>
1161
										</td>
1162
									</tr>
1163
								</table>
1164
							</td>
1165
						</tr>
1166
						<tr style="display:none;" name="dhcp" id="dhcp">
1167
							<td colspan="2" style="padding: 0px;">
1168
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1169
									<tr>
1170
										<td colspan="2" valign="top" class="listtopic">DHCP client configuration</td>
1171
									</tr>
1172
									<tr>
1173
										<td width="22%" valign="top" class="vncell">Hostname</td>
1174
										<td width="78%" class="vtable">
1175
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1176
											<br>
1177
											The value in this field is sent as the DHCP client identifier
1178
											and hostname when requesting a DHCP lease. Some ISPs may require
1179
											this (for client identification).
1180
										</td>
1181
									</tr>
1182
									<tr>
1183
										<td width="22%" valign="top" class="vncell">Alias IP address</td>
1184
										<td width="78%" class="vtable"> 
1185
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
1186
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1187
												<?php
1188
												for ($i = 32; $i > 0; $i--) {
1189
													if($i <> 31) {
1190
														echo "<option value=\"{$i}\" ";
1191
														if ($i == $pconfig['alias-subnet']) echo "selected";
1192
														echo ">" . $i . "</option>";
1193
													}
1194
												}
1195
												?>
1196
											</select>
1197
											The value in this field is used as a fixed alias IP address by the
1198
											DHCP client.
1199
										</td>
1200
									</tr>
1201
								</table>
1202
							</td>
1203
						</tr>
1204
						<tr style="display:none;" name="ppp" id="ppp">
1205
							<td colspan="2" style="padding: 0px;">
1206
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1207
									<tr>
1208
										<td colspan="2" valign="top" class="listtopic">PPP configuration</td>
1209
									</tr>
1210
									<tr name="ppp_provider" id="ppp_provider">
1211
										<td width="22%" valign="top" class="vncell"><?= gettext("Service Provider"); ?></td>
1212
										<td width="78%" class="vtable">
1213
											<table border="0" cellpadding="0" cellspacing="0">
1214
												<tr id="trcountry">
1215
													<td><?= gettext("Country"); ?> :&nbsp;&nbsp;</td>
1216
													<td>
1217
														<select class="formselect" name="country" id="country" onChange="providers_list()">
1218
															<option></option>
1219
														</select>
1220
													</td>
1221
												</tr>
1222
												<tr id="trprovider" style="display:none">
1223
													<td><?= gettext("Provider"); ?> :&nbsp;&nbsp;</td>
1224
													<td>
1225
														<select class="formselect" name="provider" id="provider" onChange="providerplan_list()">
1226
															<option></option>
1227
														</select>
1228
													</td>
1229
												</tr>
1230
												<tr id="trproviderplan" style="display:none">
1231
													<td><?= gettext("Plan"); ?> :&nbsp;&nbsp;</td>
1232
													<td>
1233
														<select class="formselect" name="providerplan" id="providerplan" onChange="prefill_provider()">
1234
															<option></option>
1235
														</select>
1236
													</td>
1237
												</tr>
1238
											</table>
1239
											<br/><span class="vexpl"><?= gettext("Select to fill in data for your service provider."); ?></span>
1240
										</td>
1241
									</tr>
1242
									<tr>
1243
										<td width="22%" valign="top" class="vncell"><?= gettext("Username"); ?></td>
1244
										<td width="78%" class="vtable">
1245
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
1246
										</td>
1247
									</tr>
1248
									<tr>
1249
										<td width="22%" valign="top" class="vncell"><?= gettext("Password"); ?></td>
1250
										<td width="78%" class="vtable">
1251
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
1252
										</td>
1253
									</tr>
1254
									<tr name="phone_num" id="phone_num">
1255
										<td width="22%" valign="top" class="vncellreq"><?= gettext("Phone Number"); ?></td>
1256
										<td width="78%" class="vtable">
1257
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>">
1258
										</td>
1259
									</tr>
1260
									<tr name="apn_" id="apn_">
1261
										<td width="22%" valign="top" class="vncell"><?= gettext("Access Point Name (APN)"); ?></td>
1262
										<td width="78%" class="vtable">
1263
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
1264
										</td>
1265
									</tr>
1266
									<tr name="interface" id="interface" >
1267
										<td width="22%" valign="top" class="vncellreq"><?= gettext("Modem Port"); ?></td>
1268
										<td width="78%" class="vtable">
1269
											<select name="port" id="port" class="formselect">
1270
											<?php
1271
												$portlist = glob("/dev/cua*");
1272
												$modems = glob("/dev/modem*");
1273
												$portlist = array_merge($portlist, $modems);
1274
												foreach ($portlist as $port) {
1275
													if(preg_match("/\.(lock|init)$/", $port))
1276
														continue;
1277
													echo "<option value=\"".trim($port)."\"";
1278
													if ($pconfig['port'] == $port)
1279
														echo "selected";
1280
													echo ">{$port}</option>";
1281
												}?>
1282
											</select>
1283
										</td>
1284
									</tr>
1285
									<td width="22%" valign="top" class="vncell"><?= gettext("Advanced PPP"); ?></td>
1286
										<?php if (isset($pconfig['pppid'])): ?>
1287
											<td width="78%" class="vtable">
1288
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk">Click here</a>
1289
											to edit PPP configuration.
1290
											</td>
1291
										<? else: ?>
1292
											<td width="78%" class="vtable">
1293
											<a href="/interfaces_ppps_edit.php" class="navlnk">Click here</a>
1294
											to create a PPP configuration.
1295
											</td>
1296
										<? endif; ?>	
1297
									</tr>
1298
								</table>
1299
							</td>
1300
						</tr>
1301
						<tr style="display:none;" name="pppoe" id="pppoe">
1302
							<td colspan="2" style="padding:0px;">
1303
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1304
									<tr>
1305
										<td colspan="2" valign="top" class="listtopic">PPPoE configuration</td>
1306
									</tr>
1307
									<tr>
1308
										<td width="22%" valign="top" class="vncellreq">Username</td>
1309
										<td width="78%" class="vtable">
1310
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
1311
										</td>
1312
									</tr>
1313
									<tr>
1314
										<td width="22%" valign="top" class="vncellreq">Password</td>
1315
										<td width="78%" class="vtable">
1316
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
1317
										</td>
1318
									</tr>
1319
									<tr>
1320
										<td width="22%" valign="top" class="vncell">Service name</td>
1321
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
1322
											<br> <span class="vexpl">Hint: this field can usually be left empty</span>
1323
										</td>
1324
									</tr>
1325
									<tr>
1326
										<td width="22%" valign="top" class="vncell">Dial on demand</td>
1327
										<td width="78%" class="vtable">
1328
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>>
1329
											<strong>Enable Dial-On-Demand mode</strong><br>
1330
											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.
1331
										</td>
1332
									</tr>
1333
									<tr>
1334
										<td width="22%" valign="top" class="vncell">Idle timeout</td>
1335
										<td width="78%" class="vtable">
1336
											<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.
1337
										</td>
1338
									</tr>
1339
									<tr>
1340
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
1341
										<td width="78%" class="vtable">
1342
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
1343
												<tr>
1344
													<td align="left" valign="top">
1345
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
1346
														<select valign="top" id="reset_type" name="pppoe-reset-type" class="formselect" onChange="show_reset_settings(this.value);">
1347
															<option value = ""><?= gettext("Disabled"); ?></option>
1348
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?= gettext("Custom"); ?></option>
1349
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?= gettext("Pre-Set"); ?></option>
1350
														</select> <?= gettext("Select a reset timing type"); ?>
1351
														</p>
1352
														<?php if ($pconfig['pppoe_pr_custom']): ?>
1353
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
1354
														<?php else: ?>
1355
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
1356
														<?php endif; ?>
1357
														<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" /> 
1358
														<?= gettext("hour (0-23)"); ?><br />
1359
														<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" /> 
1360
														<?= gettext("minute (0-59)"); ?><br />
1361
														<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']);?>" /> 
1362
														<?= gettext("reset at a specific date (mm/dd/yyyy)"); ?>
1363
														<br />&nbsp;<br />
1364
														<span class="red"><strong>Note: </strong></span>
1365
														<?= gettext("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."); ?>
1366
														</p>
1367
														<?php if ($pconfig['pppoe_pr_preset']): ?>
1368
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
1369
														<?php else: ?>
1370
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
1371
														<?php endif; ?>
1372
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> /> 
1373
														<?= gettext("reset at each month ('0 0 1 * *')"); ?>
1374
														<br />
1375
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> /> 
1376
														<?= gettext("reset at each week ('0 0 * * 0')"); ?>
1377
														<br />
1378
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> /> 
1379
														<?= gettext("reset at each day ('0 0 * * *')"); ?>
1380
														<br />
1381
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> /> 
1382
														<?= gettext("reset at each hour ('0 * * * *')"); ?>
1383
														</p>
1384
													</td>
1385
												</tr>
1386
											</table>
1387
										</td>
1388
									</tr>
1389
									
1390
									<tr>
1391
										<td width="22%" valign="top" class="vncell">Advanced and MLPPP</td>
1392
										<?php if (isset($pconfig['pppid'])): ?>
1393
											<td width="78%" class="vtable">
1394
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk">Click here</a> 
1395
											for additional PPPoE configuration options. Save first if you made changes.
1396
											</td>
1397
										<? else: ?>
1398
											<td width="78%" class="vtable">
1399
											<a href="/interfaces_ppps_edit.php" class="navlnk">Click here</a>
1400
											for advanced PPPoE configuration options and MLPPP configuration.
1401
											</td>
1402
										<? endif; ?>	
1403
									</tr>
1404
								</table>
1405
							</td>
1406
						</tr>
1407
						<tr style="display:none;" name="pptp" id="pptp">
1408
							<td colspan="2" style="padding:0px;">
1409
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1410
									<tr>
1411
										<td colspan="2" valign="top" class="listtopic">PPTP configuration</td>
1412
									</tr>
1413
									<tr>
1414
										<td width="22%" valign="top" class="vncellreq">Username</td>
1415
										<td width="78%" class="vtable">
1416
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
1417
										</td>
1418
									</tr>
1419
									<tr>
1420
										<td width="22%" valign="top" class="vncellreq">Password</td>
1421
										<td width="78%" class="vtable">
1422
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
1423
										</td>
1424
									</tr>
1425
									<tr>
1426
										<td width="22%" width="100" valign="top" class="vncellreq">Local IP address</td>
1427
										<td width="78%" class="vtable"> 
1428
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>">
1429
											/
1430
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
1431
												<?php for ($i = 31; $i > 0; $i--): ?>
1432
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected"; ?>>
1433
														<?=$i;?></option>
1434
												<?php endfor; ?>
1435
											</select>
1436
										</td>
1437
									</tr>
1438
									<tr>
1439
										<td width="22%" width="100" valign="top" class="vncellreq">Remote IP address</td>
1440
										<td width="78%" class="vtable">
1441
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>">
1442
										</td>
1443
									</tr>
1444
									<tr>
1445
										<td width="22%" valign="top" class="vncell">Dial on demand</td>
1446
										<td width="78%" class="vtable">
1447
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?>>
1448
											<strong>Enable Dial-On-Demand mode</strong><br>
1449
											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.
1450
										</td>
1451
									</tr>
1452
									<tr>
1453
										<td width="22%" valign="top" class="vncell">Idle timeout</td>
1454
										<td width="78%" class="vtable">
1455
											<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.
1456
										</td>
1457
									</tr>
1458
									<tr>
1459
										<td width="22%" valign="top" class="vncell">Advanced</td>
1460
										<?php if (isset($pconfig['pppid'])): ?>
1461
											<td width="78%" class="vtable">
1462
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk">Click here</a> 
1463
											for additional PPtP and L2tP configuration options. Save first if you made changes.
1464
											</td>
1465
										<? else: ?>
1466
											<td width="78%" class="vtable">
1467
											<a href="/interfaces_ppps_edit.php" class="navlnk">Click here</a>
1468
											for advanced PPtP and L2tP configuration options.
1469
											</td>
1470
										<? endif; ?>	
1471
									</tr>
1472
								</table>
1473
							</td>
1474
						</tr>
1475
						<?php
1476
							/* Wireless interface? */
1477
							if (isset($wancfg['wireless'])):
1478
						?>
1479
						<tr>
1480
							<td colspan="2" valign="top" height="16"></td>
1481
						</tr>										
1482
						<tr>
1483
							<td colspan="2" valign="top" class="listtopic">Common wireless configuration - Settings apply to all wireless networks on <?=$wlanbaseif;?>.</td>
1484
						</tr>
1485
						<tr>
1486
							<td valign="top" class="vncell">Persist common settings</td>
1487
							<td class="vtable">
1488
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <? if ($pconfig['persistcommonwireless']) echo "checked";?>>
1489
								<br/>Enabling this preserves the common wireless configuration through interface deletions and reassignments.
1490
							</td>
1491
						</tr>
1492
						<tr>
1493
							<td valign="top" class="vncellreq">Standard</td>
1494
							<td class="vtable">
1495
							<select name="standard" class="formselect" id="standard">
1496
								<?php
1497
								foreach($wl_modes as $wl_standard => $wl_channels) {
1498
									echo "<option ";
1499
									if ($pconfig['standard'] == "$wl_standard")
1500
										echo "selected ";
1501
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
1502
								}
1503
								?>
1504
							</select>
1505
							</td>
1506
						</tr>
1507
						<?php if (isset($wl_modes['11g'])): ?>
1508
						<tr>
1509
							<td valign="top" class="vncellreq">802.11g OFDM Protection Mode</td>
1510
							<td class="vtable">
1511
								<select name="protmode" class="formselect" id="protmode">
1512
									<option <? if ($pconfig['protmode'] == 'off') echo "selected";?> value="off">Protection mode off</option>
1513
									<option <? if ($pconfig['protmode'] == 'cts') echo "selected";?> value="cts">Protection mode CTS to self</option>
1514
									<option <? if ($pconfig['protmode'] == 'rtscts') echo "selected";?> value="rtscts">Protection mode RTS and CTS</option>
1515
								</select>
1516
								<br/>
1517
								For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network.
1518
								<br/>
1519
							</td>
1520
						</tr>
1521
						<?php else: ?>
1522
						<input name="protmode" type="hidden" id="protmode" value="off">
1523
						<?php endif; ?>
1524
						<tr>
1525
							<td valign="top" class="vncellreq">Transmit power</td>
1526
							<td class="vtable">
1527
								<select name="txpower" class="formselect" id="txpower">
1528
									<?
1529
									for($x = 99; $x > 0; $x--) {
1530
										if($pconfig["txpower"] == $x)
1531
											$SELECTED = " SELECTED";
1532
										else
1533
											$SELECTED = "";
1534
										echo "<option {$SELECTED}>{$x}</option>\n";
1535
									}
1536
									?>
1537
								</select><br/>
1538
								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.
1539
							</td>
1540
						</tr>
1541
						<tr>
1542
							<td valign="top" class="vncellreq">Channel</td>
1543
							<td class="vtable">
1544
								<select name="channel" class="formselect" id="channel">
1545
									<option <? if ($pconfig['channel'] == 0) echo "selected"; ?> value="0">Auto</option>
1546
									<?php
1547
									foreach($wl_modes as $wl_standard => $wl_channels) {
1548
										if($wl_standard == "11g") { $wl_standard = "11b/g"; }
1549
										else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
1550
										else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
1551
										foreach($wl_channels as $wl_channel) {
1552
											echo "<option ";
1553
											if ($pconfig['channel'] == "$wl_channel") {
1554
												echo "selected ";
1555
											}
1556
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
1557
											if(isset($wl_chaninfo[$wl_channel]))
1558
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
1559
											echo "</option>\n";
1560
										}
1561
									}
1562
									?>
1563
								</select>
1564
								<br/>
1565
								Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)
1566
								<br/>
1567
								Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above.
1568
							</td>
1569
						</tr>
1570
						<tr>
1571
							<td valign="top" class="vncell">Distance setting</td>
1572
							<td class="vtable">
1573
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>">
1574
								<br/>
1575
								Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client<br/>
1576
								(measured in Meters and works only for Atheros based cards !)
1577
							</td>
1578
						</tr>
1579
						<tr>
1580
							<td valign="top" class="vncell">Regulatory settings</td>
1581
							<td class="vtable">
1582
								Regulatory domain<br/>
1583
								<select name="regdomain" class="formselect" id="regdomain">
1584
									<option <? if (empty($pconfig['regdomain'])) echo "selected"; ?> value="">Default</option>
1585
									<?php
1586
									foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
1587
										echo "<option ";
1588
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
1589
											echo "selected ";
1590
										}
1591
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
1592
									}
1593
									?>
1594
								</select>
1595
								<br/>
1596
								Note: Some cards have a default that is not recognized and require changing the regulatory domain to one in this list for the changes to other regulatory settings to work.
1597
								<br/><br/>
1598
								Country (listed with country code and regulatory domain)<br/>
1599
								<select name="regcountry" class="formselect" id="regcountry">
1600
									<option <? if (empty($pconfig['regcountry'])) echo "selected"; ?> value="">Default</option>
1601
									<?php
1602
									foreach($wl_countries as $wl_country_key => $wl_country) {
1603
										echo "<option ";
1604
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
1605
											echo "selected ";
1606
										}
1607
										echo "value=\"{$wl_countries_attr[$wl_country_key]['ID']}\">{$wl_country['name']} -- ({$wl_countries_attr[$wl_country_key]['ID']}, " . strtoupper($wl_countries_attr[$wl_country_key]['rd'][0]['REF']) . ")</option>\n";
1608
									}
1609
									?>
1610
								</select>
1611
								<br/>
1612
								Note: Any country setting other than "Default" will override the regulatory domain setting.
1613
								<br/><br/>
1614
								Location<br/>
1615
								<select name="reglocation" class="formselect" id="reglocation">
1616
									<option <? if (empty($pconfig['reglocation'])) echo "selected"; ?> value="">Default</option>
1617
									<option <? if ($pconfig['reglocation'] == 'indoor') echo "selected"; ?> value="indoor">Indoor</option>
1618
									<option <? if ($pconfig['reglocation'] == 'outdoor') echo "selected"; ?> value="outdoor">Outdoor</option>
1619
									<option <? if ($pconfig['reglocation'] == 'anywhere') echo "selected"; ?> value="anywhere">Anywhere</option>
1620
								</select>
1621
								<br/><br/>
1622
								These settings may affect which channels are available and the maximum transmit power allowed on those channels.  Using the correct settings to comply with local regulatory requirements is recommended.
1623
								<br/>
1624
								Note: All wireless networks on this interface will be temporarily brought down when changing regulatory settings.  Some of the regulatory domains or country codes may not be allowed by some cards.  These settings may not be able to add additional channels that are not already supported.
1625
							</td>
1626
						</tr>
1627
						<tr>
1628
							<td colspan="2" valign="top" height="16"></td>
1629
						</tr>										
1630
						<tr>
1631
							<td colspan="2" valign="top" class="listtopic">Network-specific wireless configuration</td>
1632
						</tr>
1633
						<tr>
1634
							<td valign="top" class="vncellreq">Mode</td>
1635
							<td class="vtable">
1636
								<select name="mode" class="formselect" id="mode">
1637
									<option <? if ($pconfig['mode'] == 'bss') echo "selected";?> value="bss">Infrastructure (BSS)</option>
1638
									<option <? if ($pconfig['mode'] == 'adhoc') echo "selected";?> value="adhoc">Ad-hoc (IBSS)</option>
1639
									<option <? if ($pconfig['mode'] == 'hostap') echo "selected";?> value="hostap">Access Point</option>
1640
								</select>
1641
							</td>
1642
						</tr>
1643
						<tr>
1644
							<td valign="top" class="vncellreq">SSID</td>
1645
							<td class="vtable">
1646
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>">
1647
							</td>
1648
						</tr>
1649
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
1650
						<tr>
1651
							<td valign="top" class="vncell">Minimum wireless standard</td>
1652
							<td class="vtable">
1653
								<select name="puremode" class="formselect" id="puremode">
1654
									<option <? if ($pconfig['puremode'] == 'any') echo "selected";?> value="any">Any</option>
1655
									<?php if (isset($wl_modes['11g'])): ?>
1656
									<option <? if ($pconfig['puremode'] == '11g') echo "selected";?> value="11g">802.11g</option>
1657
									<?php endif; ?>
1658
									<option <? if ($pconfig['puremode'] == '11n') echo "selected";?> value="11n">802.11n</option>
1659
								</select>
1660
								<br/>
1661
								When operating as an access point, allow only stations capable of the selected wireless standard to associate (stations not capable are not permitted to associate).
1662
							</td>
1663
						</tr>
1664
						<?php elseif (isset($wl_modes['11g'])): ?>
1665
						<tr>
1666
							<td valign="top" class="vncell">802.11g only</td>
1667
							<td class="vtable">
1668
								<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <? if ($pconfig['puremode'] == '11g') echo "checked";?>>
1669
								<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).
1670
							</td>
1671
						</tr>
1672
						<?php endif; ?>
1673
						<tr>
1674
							<td valign="top" class="vncell">Allow intra-BSS communication</td>
1675
							<td class="vtable">
1676
								<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <? if ($pconfig['apbridge_enable']) echo "checked";?>>
1677
								<br/>
1678
								When operating as an access point, enable this if you want to pass packets between wireless clients directly.
1679
								<br/>
1680
								Disabling the internal bridging is useful when traffic is to be processed with packet filtering.
1681
							</td>
1682
						</tr>
1683
						<tr>
1684
							<td valign="top" class="vncell">Enable WME</td>
1685
							<td class="vtable">
1686
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <? if ($pconfig['wme_enable']) echo "checked";?>>
1687
								<br/>Setting this option will force the card to use WME (wireless QoS).
1688
							</td>
1689
						</tr>
1690
						<tr>
1691
							<td valign="top" class="vncell">Enable Hide SSID</td>
1692
							<td class="vtable">
1693
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <? if ($pconfig['hidessid_enable']) echo "checked";?>>
1694
								<br/>
1695
								Setting this option will force the card to NOT broadcast its SSID
1696
								<br/>
1697
								(this might create problems for some clients).
1698
							</td>
1699
						</tr>
1700
						<tr>
1701
							<td valign="top" class="vncell">WEP</td>
1702
							<td class="vtable"> 
1703
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <? if ($pconfig['wep_enable']) echo "checked"; ?>>
1704
								<strong>Enable WEP</strong>
1705
								<table border="0" cellspacing="0" cellpadding="0">
1706
									<tr>
1707
										<td>&nbsp;</td>
1708
										<td>&nbsp;</td>
1709
										<td>&nbsp;TX key&nbsp;</td>
1710
									</tr>
1711
									<tr>
1712
										<td>Key 1:&nbsp;&nbsp;</td>
1713
										<td>
1714
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>">
1715
										</td>
1716
										<td align="center">
1717
											<input name="txkey" type="radio" value="1" <? if ($pconfig['txkey'] == 1) echo "checked";?>>
1718
										</td>
1719
									</tr>
1720
									<tr>
1721
										<td>Key 2:&nbsp;&nbsp;</td>
1722
										<td>
1723
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>">
1724
										</td>
1725
										<td align="center">
1726
											<input name="txkey" type="radio" value="2" <? if ($pconfig['txkey'] == 2) echo "checked";?>>
1727
										</td>
1728
									</tr>
1729
									<tr>
1730
										<td>Key 3:&nbsp;&nbsp;</td>
1731
										<td>
1732
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>">
1733
										</td>
1734
										<td align="center">
1735
											<input name="txkey" type="radio" value="3" <? if ($pconfig['txkey'] == 3) echo "checked";?>>
1736
										</td>
1737
									</tr>
1738
									<tr>
1739
										<td>Key 4:&nbsp;&nbsp;</td>
1740
										<td>
1741
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>">
1742
										</td>
1743
										<td align="center">
1744
											<input name="txkey" type="radio" value="4" <? if ($pconfig['txkey'] == 4) echo "checked";?>>
1745
										</td>
1746
									</tr>
1747
								</table>
1748
								<br/>
1749
								40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'.<br/>
1750
								104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'.
1751
							</td>
1752
						</tr>
1753
						<tr>
1754
							<td valign="top" class="vncell">WPA</td>
1755
							<td class="vtable">
1756
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <? if ($pconfig['wpa_enable']) echo "checked"; ?>>
1757
								<strong>Enable WPA</strong>
1758
								<br/><br/>
1759
								<table border="0" cellspacing="0" cellpadding="0">
1760
									<tr>
1761
										<td>&nbsp;</td>
1762
										<td>&nbsp;WPA Pre Shared Key&nbsp;</td>
1763
									</tr>
1764
									<tr>
1765
										<td>PSK:&nbsp;&nbsp;</td>
1766
										<td>
1767
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>">
1768
										</td>
1769
									</tr>
1770
								</table>
1771
								<br/>Passphrase must be from 8 to 63 characters.
1772
							</td>
1773
						</tr>
1774
						<tr>
1775
							<td valign="top" class="vncell">WPA Mode</td>
1776
							<td class="vtable">
1777
								<select name="wpa_mode" class="formselect" id="wpa_mode">
1778
									<option <? if ($pconfig['wpa_mode'] == '1') echo "selected";?> value="1">WPA</option>
1779
									<option <? if ($pconfig['wpa_mode'] == '2') echo "selected";?> value="2">WPA2</option>
1780
									<option <? if ($pconfig['wpa_mode'] == '3') echo "selected";?> value="3">Both</option>
1781
								</select>
1782
							</td>
1783
						</tr>
1784
						<tr>
1785
							<td valign="top" class="vncell">WPA Key Management Mode</td>
1786
							<td class="vtable"> 
1787
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
1788
									<option <? if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected";?> value="WPA-PSK">Pre Shared Key</option>
1789
									<option <? if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected";?> value="WPA-EAP">Extensible Authentication Protocol</option>
1790
									<option <? if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected";?> value="WPA-PSK WPA-EAP">Both</option>
1791
								</select>
1792
							</td>
1793
						</tr>
1794
						<tr>
1795
							<td valign="top" class="vncell">Authentication</td>
1796
							<td class="vtable">
1797
								<select name="auth_algs" class="formselect" id="auth_algs">
1798
									<option <? if ($pconfig['auth_algs'] == '1') echo "selected";?> value="1">Open System Authentication</option>
1799
									<option <? if ($pconfig['auth_algs'] == '2') echo "selected";?> value="2">Shared Key Authentication</option>
1800
									<option <? if ($pconfig['auth_algs'] == '3') echo "selected";?> value="3">Both</option>
1801
								</select>
1802
								<br/>Note: Shared Key Authentication requires WEP.</br>
1803
							</td>
1804
						</tr>
1805
						<tr>
1806
							<td valign="top" class="vncell">WPA Pairwise</td>
1807
							<td class="vtable">
1808
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
1809
									<option <? if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected";?> value="CCMP TKIP">Both</option>
1810
									<option <? if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected";?> value="CCMP">AES (recommended)</option>
1811
									<option <? if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected";?> value="TKIP">TKIP</option>
1812
								</select>
1813
							</td>
1814
						</tr>
1815
						<tr>
1816
							<td valign="top" class="vncell">Key Rotation</td>
1817
							<td class="vtable">
1818
								<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";?>">
1819
								<br/>Allowed values are 1-9999 but should not be longer than Master Key Regeneration time.
1820
							</td>
1821
						</tr>
1822
						<tr>
1823
							<td valign="top" class="vncell">Master Key Regeneration</td>
1824
							<td class="vtable">
1825
								<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";?>">
1826
								<br/>Allowed values are 1-9999 but should not be shorter than Key Rotation time.
1827
							</td>
1828
						</tr>
1829
						<tr>
1830
							<td valign="top" class="vncell">Strict Key Regeneration</td>
1831
							<td class="vtable">
1832
								<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <? if ($pconfig['wpa_strict_rekey']) echo "checked"; ?>>
1833
								<br/>Setting this option will force the AP to rekey whenever a client disassociates.
1834
							</td>
1835
						</tr>
1836
						<tr>
1837
							<td valign="top" class="vncell">Enable IEEE802.1X Authentication</td>
1838
							<td class="vtable">
1839
								<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <? if ($pconfig['ieee8021x']) echo "checked";?>>
1840
								<br/>Setting this option will enable 802.1x authentication.
1841
								<br/><span class="red"><strong>NOTE:</strong</span> this option requires checking the "Enable WPA box".
1842
							</td>
1843
						</tr>
1844
						<tr>
1845
							<td valign="top" class="vncell">802.1X Authentication Server IP Address</td>
1846
							<td class="vtable">
1847
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>">
1848
								<br/>Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)
1849
							</td>
1850
						</tr>
1851
						<tr>
1852
							<td valign="top" class="vncell">802.1X Authentication Server Port</td>
1853
							<td class="vtable">
1854
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>">
1855
								<br/>Leave blank for the default 1812 port.
1856
							</td>
1857
						</tr>
1858
						<tr>
1859
							<td valign="top" class="vncell">802.1X Authentication Server Shared Secret</td>
1860
							<td class="vtable">
1861
								<input name="auth_server_shared_secret" id="auth_server_shared_secret" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_shared_secret']);?>">
1862
								<br/>
1863
							</td>
1864
						</tr>
1865
						<? endif; ?>
1866
						<tr>
1867
							<td colspan="2" valign="top" height="16"></td>
1868
						</tr>
1869
						<tr>
1870
							<td colspan="2" valign="top" class="listtopic">Private networks</td>
1871
						</tr>
1872
						<tr>
1873
							<td valign="middle" class="vncell">&nbsp;</td>
1874
							<td class="vtable">
1875
								<a name="rfc1918"></a> 
1876
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
1877
								<strong>Block private networks</strong><br>
1878
								When set, this option blocks traffic from IP addresses that are reserved 
1879
								for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as 
1880
								well as loopback addresses (127/8).&nbsp;&nbsp; You should generally
1881
								leave this option turned on, unless your WAN network lies in such 
1882
								a private address space, too. 
1883
							</td>
1884
						</tr>
1885
						<tr>
1886
							<td valign="middle" class="vncell">&nbsp;</td>
1887
							<td class="vtable"> 
1888
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
1889
								<strong>Block bogon networks</strong><br>
1890
								When set, this option blocks traffic from IP addresses that are reserved 
1891
								(but not RFC 1918) or not yet assigned by IANA.&nbsp;&nbsp;
1892
								Bogons are prefixes that should never appear in the Internet routing table, 
1893
								and obviously should not appear as the source address in any packets you receive.
1894
							</td>
1895
						</tr>
1896
					</table> <!-- End "allcfg" table -->
1897
					</div> <!-- End "allcfg" div -->
1898

    
1899
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1900
						<tr>
1901
							<td width="100" valign="top">
1902
								&nbsp;
1903
							</td>
1904
							<td>
1905
								<br/>
1906
								<input id="save" name="Submit" type="submit" class="formbtn" value="Save"> 
1907
								<input id="cancel" type="button" class="formbtn" value="Cancel" onclick="history.back()">
1908
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
1909
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
1910
								<input name="ppp_port" type="hidden" value="<?=$pconfig['port'];?>">
1911
								<?php endif; ?>
1912
								<input name="ptpid" type="hidden" value="<?=$pconfig['ptpid'];?>">
1913
							</td>
1914
						</tr>
1915
					</table>
1916
				</td>
1917
			</tr>
1918
		</table>
1919
		<!--
1920
		</div>
1921
		</td></tr>
1922
		</table>
1923
		-->
1924
	</form>
1925
	<script type="text/javascript">
1926
		var gatewayip;
1927
		var name;
1928
		function show_add_gateway() {
1929
			document.getElementById("addgateway").style.display = '';
1930
			document.getElementById("addgwbox").style.display = 'none';
1931
			document.getElementById("gateway").style.display = 'none';
1932
			document.getElementById("save").style.display = 'none';
1933
			document.getElementById("cancel").style.display = 'none';
1934
			document.getElementById("gwsave").style.display = '';
1935
			document.getElementById("gwcancel").style.display = '';
1936
			$('notebox').innerHTML="";
1937
		}
1938
		function hide_add_gateway() {
1939
			document.getElementById("addgateway").style.display = 'none';
1940
			document.getElementById("addgwbox").style.display = '';	
1941
			document.getElementById("gateway").style.display = '';
1942
			document.getElementById("save").style.display = '';
1943
			document.getElementById("cancel").style.display = '';
1944
			document.getElementById("gwsave").style.display = '';
1945
			document.getElementById("gwcancel").style.display = '';
1946
		}
1947
		function hide_add_gatewaysave() {
1948
			document.getElementById("addgateway").style.display = 'none';
1949
			$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif"> One moment please...';
1950
			var iface = $F('if');
1951
			name = $('name').getValue();
1952
			var descr = $('gatewaydescr').getValue();
1953
			gatewayip = $('gatewayip').getValue();
1954
			addrtype = $('addrtype').getValue();
1955
			var defaultgw = $('defaultgw').getValue();
1956
			var url = "system_gateways_edit.php";
1957
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip) + '&type=' + escape(addrtype);
1958
			var myAjax = new Ajax.Request(
1959
				url,
1960
				{
1961
					method: 'post',
1962
					parameters: pars,
1963
					onFailure: report_failure,
1964
					onComplete: save_callback
1965
				});	
1966
		}
1967
		function addOption(selectbox,text,value)
1968
		{
1969
			var optn = document.createElement("OPTION");
1970
			optn.text = text;
1971
			optn.value = value;
1972
			selectbox.options.add(optn);
1973
			selectbox.selectedIndex = (selectbox.options.length-1);
1974
			$('notebox').innerHTML="<p/><strong>NOTE:</strong> You can manage Gateways <a target='_new' href='system_gateways.php'>here</a>.";
1975
		}				
1976
		function report_failure() {
1977
			alert("Sorry, we could not create your gateway at this time.");
1978
			hide_add_gateway();
1979
		}
1980
		function save_callback(transport) {
1981
			var response = transport.responseText;
1982
			if(response) {
1983
				document.getElementById("addgateway").style.display = 'none';
1984
				hide_add_gateway();
1985
				$('status').innerHTML = '';
1986
				addOption($('gateway'), name, name);
1987
				// Auto submit form?
1988
				//document.iform.submit();
1989
				//$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif">';
1990
			} else {
1991
				report_failure();
1992
			}
1993
		}
1994
		<?php
1995
		if ($if == "wan" || $if == "lan")
1996
			echo "\$('allcfg').show();\n";
1997
		else
1998
			echo "show_allcfg(document.iform.enable);";
1999
		echo "updateType('{$pconfig['type']}');\n";
2000
		?>
2001
	</script>
2002
	<?php include("fend.inc"); ?>
2003
	</body>
2004
</html>
(82-82/222)