Project

General

Profile

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

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

    
305
		/* sync filter configuration */
306
		setup_gateways_monitor();
307

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

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

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

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

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

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

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

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

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

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

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

    
791
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
792
		return;
793

    
794
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
795
		$clone_count = 1;
796
	else
797
		$clone_count = 0;
798
	if (is_array($config['wireless']['clone'])) {
799
		foreach ($config['wireless']['clone'] as $clone) {
800
			if ($clone['if'] == $wlanbaseif)
801
				$clone_count++;
802
		}
803
	}
804
	if ($clone_count > 1) {
805
		$old_wireless_mode = $wancfg['wireless']['mode'];
806
		$wancfg['wireless']['mode'] = $_POST['mode'];
807
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
808
			$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.";
809
		} else {
810
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
811
		}
812
		$wancfg['wireless']['mode'] = $old_wireless_mode;
813
	}
814
}
815

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

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

    
823
?>
824

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

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

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

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

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

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

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