Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
796
function check_wireless_mode() {
797
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
798

    
799
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
800
		return;
801

    
802
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
803
		$clone_count = 1;
804
	else
805
		$clone_count = 0;
806
	if (is_array($config['wireless']['clone'])) {
807
		foreach ($config['wireless']['clone'] as $clone) {
808
			if ($clone['if'] == $wlanbaseif)
809
				$clone_count++;
810
		}
811
	}
812
	if ($clone_count > 1) {
813
		$old_wireless_mode = $wancfg['wireless']['mode'];
814
		$wancfg['wireless']['mode'] = $_POST['mode'];
815
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
816
			$input_errors[] = sprintf(gettext("Unable to change mode to %s .  You may already have the maximum number of wireless clones supported in this mode."), $wlan_modes[$wancfg['wireless']['mode']]);
817
		} else {
818
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
819
		}
820
		$wancfg['wireless']['mode'] = $old_wireless_mode;
821
	}
822
}
823

    
824
$pgtitle = array(gettext("Interfaces"),sprintf(gettext("'%s'"),$pconfig['descr']));
825
$statusurl = "status_interfaces.php";
826

    
827
$closehead = false;
828
include("head.inc");
829
$types = array("none" => gettext("None"), "static" => gettext("Static"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP") /* , "carpdev-dhcp" => "CarpDev"*/); 
830

    
831
?>
832

    
833
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
834
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
835
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
836
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
837

    
838
<script type="text/javascript">
839
	function updateType(t) {
840
		switch(t) {
841
			case "none": {
842
				$('static','dhcp','pppoe','pptp', 'ppp').invoke('hide');
843
				break;
844
			}
845
			case "static": {
846
				$('none','dhcp','pppoe','pptp', 'ppp').invoke('hide');
847
				break;
848
			}
849
			case "dhcp": {
850
				$('none','static','pppoe','pptp', 'ppp').invoke('hide');
851
				break;
852
			}
853
			case "ppp": {
854
				$('none','static','dhcp','pptp', 'pppoe').invoke('hide');
855
				country_list();
856
				break;
857
			}
858
			case "pppoe": {
859
				$('none','static','dhcp','pptp', 'ppp').invoke('hide');
860
				break;
861
			}
862
			case "pptp": {
863
				$('none','static','dhcp','pppoe', 'ppp').invoke('hide');
864
				break;
865
			}
866
		}
867
		$(t).show();
868
	}
869

    
870
	function show_allcfg(obj) {
871
		if (obj.checked)
872
			$('allcfg').show();
873
		else
874
			$('allcfg').hide();
875
	}
876

    
877
	function show_reset_settings(reset_type) {
878
		if (reset_type == 'preset') { 
879
			Effect.Appear('pppoepresetwrap', { duration: 0.0 });
880
			Effect.Fade('pppoecustomwrap', { duration: 0.0 }); 
881
		} 
882
		else if (reset_type == 'custom') { 
883
			Effect.Appear('pppoecustomwrap', { duration: 0.0 });
884
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
885
		} else {
886
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
887
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
888
		}
889
	}
890
	function show_mon_config() {
891
		document.getElementById("showmonbox").innerHTML='';
892
		aodiv = document.getElementById('showmon');
893
		aodiv.style.display = "block";
894
	}
895

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

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

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