Project

General

Profile

Download (84.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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
301
		/* sync filter configuration */
302
		setup_gateways_monitor();
303

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

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

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

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

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

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

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

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

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

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

    
778
function check_wireless_mode() {
779
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
780

    
781
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
782
		return;
783

    
784
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
785
		$clone_count = 1;
786
	else
787
		$clone_count = 0;
788
	if (is_array($config['wireless']['clone'])) {
789
		foreach ($config['wireless']['clone'] as $clone) {
790
			if ($clone['if'] == $wlanbaseif)
791
				$clone_count++;
792
		}
793
	}
794
	if ($clone_count > 1) {
795
		$old_wireless_mode = $wancfg['wireless']['mode'];
796
		$wancfg['wireless']['mode'] = $_POST['mode'];
797
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
798
			$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.";
799
		} else {
800
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
801
		}
802
		$wancfg['wireless']['mode'] = $old_wireless_mode;
803
	}
804
}
805

    
806
$pgtitle = array("Interfaces", $pconfig['descr']);
807
$statusurl = "status_interfaces.php";
808

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

    
813
?>
814

    
815
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
816
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
817
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
818
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
819

    
820
<script type="text/javascript">
821
	function updateType(t) {
822
		switch(t) {
823
			case "none": {
824
				$('static','dhcp','pppoe','pptp', 'ppp').invoke('hide');
825
				break;
826
			}
827
			case "static": {
828
				$('none','dhcp','pppoe','pptp', 'ppp').invoke('hide');
829
				break;
830
			}
831
			case "dhcp": {
832
				$('none','static','pppoe','pptp', 'ppp').invoke('hide');
833
				break;
834
			}
835
			case "ppp": {
836
				$('none','static','dhcp','pptp', 'pppoe').invoke('hide');
837
				country_list();
838
				break;
839
			}
840
			case "pppoe": {
841
				$('none','static','dhcp','pptp', 'ppp').invoke('hide');
842
				break;
843
			}
844
			case "pptp": {
845
				$('none','static','dhcp','pppoe', 'ppp').invoke('hide');
846
				break;
847
			}
848
		}
849
		$(t).show();
850
	}
851

    
852
	function show_allcfg(obj) {
853
		if (obj.checked)
854
			$('allcfg').show();
855
		else
856
			$('allcfg').hide();
857
	}
858

    
859
	function show_reset_settings(reset_type) {
860
		if (reset_type == 'preset') { 
861
			Effect.Appear('pppoepresetwrap', { duration: 0.0 });
862
			Effect.Fade('pppoecustomwrap', { duration: 0.0 }); 
863
		} 
864
		else if (reset_type == 'custom') { 
865
			Effect.Appear('pppoecustomwrap', { duration: 0.0 });
866
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
867
		} else {
868
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
869
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
870
		}
871
	}
872
	function show_mon_config() {
873
		document.getElementById("showmonbox").innerHTML='';
874
		aodiv = document.getElementById('showmon');
875
		aodiv.style.display = "block";
876
	}
877

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

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

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