Project

General

Profile

Download (94.6 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
	preg_match("/^(.*?)([0-9]*)$/", $wlanbaseif, $wlanbaseif_split);
227
	$wl_modes = get_wireless_modes($if);
228
	$wl_chaninfo = get_wireless_channel_info($if);
229
	$wl_sysctl_prefix = 'dev.' . $wlanbaseif_split[1] . '.' . $wlanbaseif_split[2];
230
	$wl_sysctl = get_sysctl(array("{$wl_sysctl_prefix}.diversity", "{$wl_sysctl_prefix}.txantenna", "{$wl_sysctl_prefix}.rxantenna",
231
	                              "{$wl_sysctl_prefix}.slottime", "{$wl_sysctl_prefix}.acktimeout", "{$wl_sysctl_prefix}.ctstimeout"));
232
	$wl_regdomain_xml_attr = array();
233
	$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
234
	$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
235
	$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
236
	$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
237
	$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
238
	$pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]);
239
	$pconfig['standard'] = $wancfg['wireless']['standard'];
240
	$pconfig['mode'] = $wancfg['wireless']['mode'];
241
	$pconfig['protmode'] = $wancfg['wireless']['protmode'];
242
	$pconfig['ssid'] = $wancfg['wireless']['ssid'];
243
	$pconfig['channel'] = $wancfg['wireless']['channel'];
244
	$pconfig['txpower'] = $wancfg['wireless']['txpower'];
245
	$pconfig['diversity'] = $wancfg['wireless']['diversity'];
246
	$pconfig['txantenna'] = $wancfg['wireless']['txantenna'];
247
	$pconfig['rxantenna'] = $wancfg['wireless']['rxantenna'];
248
	$pconfig['distance'] = $wancfg['wireless']['distance'];
249
	$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
250
	$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
251
	$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
252
	$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
253
	if (isset($wancfg['wireless']['puren']['enable']))
254
		$pconfig['puremode'] = '11n';
255
	else if (isset($wancfg['wireless']['pureg']['enable']))
256
		$pconfig['puremode'] = '11g';
257
	else
258
		$pconfig['puremode'] = 'any';
259
	$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
260
	$pconfig['authmode'] = $wancfg['wireless']['authmode'];
261
	$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
262
	$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
263
	$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
264
	$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
265
	if (is_array($wancfg['wireless']['wpa'])) {
266
		$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
267
		$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
268
		$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
269
		$pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs'];
270
		$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
271
		$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
272
		$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
273
		$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
274
		$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
275
		$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
276
		$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
277
		$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
278
		$pconfig['rsn_preauth'] = isset($wancfg['wireless']['wpa']['rsn_preauth']);
279
		$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
280
		$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
281
	}
282
	$pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']);
283
	$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
284
	if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) {
285
		$i = 1;
286
		foreach ($wancfg['wireless']['wep']['key'] as $wepkey) {
287
			$pconfig['key' . $i] = $wepkey['value'];
288
			if (isset($wepkey['txkey']))
289
				$pconfig['txkey'] = $i;
290
			$i++;
291
		}
292
		if (!isset($wepkey['txkey']))
293
			$pconfig['txkey'] = 1;
294
	}
295
}
296

    
297
if ($_POST['apply']) {
298
	unset($input_errors);
299
	if (!is_subsystem_dirty('interfaces'))
300
		$intput_errors[] = gettext("You have already applied your settings!");
301
	else {
302
		unlink_if_exists("{$g['tmp_path']}/config.cache");
303
		clear_subsystem_dirty('interfaces');
304
		if ($pconfig['enable'])
305
			interface_configure($if, true);
306
		else
307
			interface_bring_down($if);
308

    
309
		/* restart snmp so that it binds to correct address */
310
		services_snmpd_configure();
311
		if ($if == "lan")
312
			$savemsg = gettext("The changes have been applied.  You may need to correct your web browser's IP address.");
313

    
314
		/* sync filter configuration */
315
		setup_gateways_monitor();
316

    
317
		clear_subsystem_dirty('staticroutes');
318

    
319
		filter_configure();
320

    
321
		enable_rrd_graphing();
322
	}
323
	header("Location: interfaces.php?if={$if}");
324
	exit;
325
} else
326

    
327
if ($_POST && $_POST['enable'] != "yes") {
328
	unset($wancfg['enable']);
329
	if (isset($wancfg['wireless'])) {
330
		interface_sync_wireless_clones($wancfg, false);
331
	}
332
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
333
	mark_subsystem_dirty('interfaces');
334
	header("Location: interfaces.php?if={$if}");
335
	exit;
336
} else
337

    
338
if ($_POST) {
339
	unset($input_errors);
340
	$pconfig = $_POST;
341
	conf_mount_rw();
342

    
343
	/* filter out spaces from descriptions  */
344
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
345

    
346
	/* okay first of all, cause we are just hiding the PPPoE HTML
347
	 * fields releated to PPPoE resets, we are going to unset $_POST
348
	 * vars, if the reset feature should not be used. Otherwise the
349
	 * data validation procedure below, may trigger a false error
350
	 * message.
351
	 */
352
	if (empty($_POST['pppoe-reset-type'])) {
353
		unset($_POST['pppoe_pr_type']);
354
		unset($_POST['pppoe_resethour']);
355
		unset($_POST['pppoe_resetminute']);
356
		unset($_POST['pppoe_resetdate']);
357
		unset($_POST['pppoe_pr_preset_val']);
358
	}
359
	/* optional interface if list */
360
	$iflist = get_configured_interface_with_descr(false, true);
361
	/* description unique? */
362
	foreach ($iflist as $ifent => $ifdescr) {
363
		if ($if != $ifent && $ifdescr == $_POST['descr']) {
364
			$input_errors[] = gettext("An interface with the specified description already exists.");
365
			break;
366
		}
367
	}
368
	/* input validation */
369
	if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && $_POST['type'] != "static")
370
		$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.");
371

    
372
	switch($_POST['type']) {
373
		case "static":
374
			$reqdfields = explode(" ", "ipaddr subnet gateway");
375
			$reqdfieldsn = array(gettext("IP address"),gettext("Subnet bit count"),gettext("Gateway"));
376
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
377
			break;
378
		case "none":
379
			if(is_array($config['virtualip']['vip'])) {
380
				foreach ($config['virtualip']['vip'] as $vip) {
381
					if ($vip['interface'] == $if)
382
						$input_errors[] = gettext("This interface is referenced by VIPs please delete those before setting the interface to 'none' configuration.");
383
				}
384
			}
385
		case "dhcp":
386
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp")))
387
				$input_errors[] = gettext("You have to reassign the interface to be able to configure as {$_POST['type']}.");
388
			break;
389
		case "ppp":
390
			$reqdfields = explode(" ", "port phone");
391
			$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
392
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
393
			break;
394
		case "PPPoE":
395
			if ($_POST['pppoe_dialondemand']) {
396
				$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
397
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
398
			} else {
399
				$reqdfields = explode(" ", "pppoe_username pppoe_password");
400
				$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"));
401
			}
402
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
403
			break;
404
		case "PPTP":
405
			if ($_POST['pptp_dialondemand']) {
406
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
407
				$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"));
408
			} else {
409
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
410
				$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"));
411
			}
412
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
413
			break;
414
	}
415

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

    
505
		if ($_POST['passphrase']) {
506
                	$passlen = strlen($_POST['passphrase']);
507
                	if ($passlen < 8 || $passlen > 64)
508
                        	$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
509
		}
510
	}
511
	if (!$input_errors) {
512
		$ppp = array();
513
		if ($wancfg['ipaddr'] != "ppp")
514
			unset($wancfg['ipaddr']);
515
		unset($wancfg['subnet']);
516
		unset($wancfg['gateway']);
517
		unset($wancfg['dhcphostname']);
518
		unset($wancfg['pppoe_username']);
519
		unset($wancfg['pppoe_password']);
520
		unset($wancfg['pptp_username']);
521
		unset($wancfg['pptp_password']);
522
		unset($wancfg['provider']);
523
		unset($wancfg['ondemand']);
524
		unset($wancfg['timeout']);
525
		if (isset($wancfg['pppoe']['pppoe-reset-type']))
526
			unset($wancfg['pppoe']['pppoe-reset-type']);
527
		unset($wancfg['local']);
528
		unset($wancfg['subnet']);
529
		unset($wancfg['remote']);
530
		unset($a_ppps[$pppid]['apn']);
531
		unset($a_ppps[$pppid]['phone']);
532
		unset($a_ppps[$pppid]['localip']);
533
		unset($a_ppps[$pppid]['subnet']);
534
		unset($a_ppps[$pppid]['gateway']);
535
		unset($a_ppps[$pppid]['pppoe-reset-type']);
536
		unset($a_ppps[$pppid]['provider']);
537

    
538
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
539
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
540

    
541
		/* for dynamic interfaces we tack a gateway item onto the array to prevent system
542
		 * log messages from appearing. They can also manually add these items */
543
		/* 1st added gateway gets a default bit */
544
		if(!empty($a_gateways)) {
545
			$gateway_item = array();
546
			/* check for duplicates */
547
			$skip = false;
548
			foreach($a_gateways as $item) {
549
				if(($item['interface'] == "$if") && ($item['gateway'] == "dynamic")) {
550
					$skip = true;
551
				}
552
			}
553
			if($skip == false) {
554
				$gateway_item['gateway'] = gettext("dynamic");
555
				$gateway_item['descr'] = gettext("Interface") . $if . gettext("dynamic gateway");
556
				$gateway_item['name'] = "GW_" . strtoupper($if);
557
				$gateway_item['interface'] = "{$if}";
558
			} else {
559
				unset($gateway_item);
560
			}
561
		}
562

    
563
		switch($_POST['type']) {
564
			case "static":
565
				$wancfg['ipaddr'] = $_POST['ipaddr'];
566
				$wancfg['subnet'] = $_POST['subnet'];
567
				if ($_POST['gateway'] != "none") {
568
					$wancfg['gateway'] = $_POST['gateway'];
569
				}
570
				break;
571
			case "dhcp":
572
				$wancfg['ipaddr'] = "dhcp";
573
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
574
				$wancfg['alias-address'] = $_POST['alias-address'];
575
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
576
				if($gateway_item) {
577
					$a_gateways[] = $gateway_item;
578
				}
579
				break;
580
			case "carpdev-dhcp":
581
				$wancfg['ipaddr'] = "carpdev-dhcp";
582
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
583
				$wancfg['alias-address'] = $_POST['alias-address'];
584
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
585
				if($gateway_item) {
586
					$a_gateways[] = $gateway_item;
587
				}
588
				break;
589
			case "ppp":
590
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
591
				$a_ppps[$pppid]['type'] = $_POST['type'];
592
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
593
				$a_ppps[$pppid]['ports'] = $_POST['port'];
594
				$a_ppps[$pppid]['username'] = $_POST['username'];
595
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
596
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
597
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
598
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
599
				$wancfg['ipaddr'] = $_POST['type'];
600
				unset($a_ppps[$pppid]['ondemand']);
601
				unset($a_ppps[$pppid]['idletimeout']);
602
				break;
603

    
604
			case "pppoe":
605
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
606
				$a_ppps[$pppid]['type'] = $_POST['type'];
607
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
608
				if (isset($_POST['ppp_port']))
609
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
610
				else
611
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
612
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
613
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
614
				if (!empty($_POST['provider']))
615
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
616
				else
617
					unset($a_ppps[$pppid]['provider']);
618
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
619
				if (!empty($_POST['idletimeout']))
620
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
621
				else
622
					unset($a_ppps[$pppid]['idletimeout']);
623

    
624
				if (!empty($_POST['pppoe-reset-type']))
625
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
626
				else
627
					unset($a_ppps[$pppid]['pppoe-reset-type']);
628
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
629
				$wancfg['ipaddr'] = $_POST['type'];
630
				if($gateway_item) {
631
					$a_gateways[] = $gateway_item;
632
				}
633

    
634
				break;
635
			case "pptp":
636
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
637
				$a_ppps[$pppid]['type'] = $_POST['type'];
638
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
639
				if (isset($_POST['ppp_port']))
640
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
641
				else
642
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
643
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
644
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
645
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
646
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
647
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
648
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
649
				if (!empty($_POST['idletimeout']))
650
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
651
				else
652
					unset($a_ppps[$pppid]['idletimeout']);
653
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
654
				$wancfg['ipaddr'] = $_POST['type'];
655
				if($gateway_item) {
656
					$a_gateways[] = $gateway_item;
657
				}
658
				break;
659
			case "none":
660
				break;
661
		}
662
		handle_pppoe_reset($_POST);
663

    
664
		if($_POST['blockpriv'] == "yes") {
665
			$wancfg['blockpriv'] = true;
666
		} else {
667
			unset($wancfg['blockpriv']);
668
		}
669
		if($_POST['blockbogons'] == "yes") {
670
			$wancfg['blockbogons'] = true;
671
		} else {
672
			unset($wancfg['blockbogons']);
673
		}
674
		$wancfg['spoofmac'] = $_POST['spoofmac'];
675
		if (empty($_POST['mtu'])) {
676
			unset($wancfg['mtu']);
677
		} else {
678
			$wancfg['mtu'] = $_POST['mtu'];
679
		}
680
		if (empty($_POST['mss'])) {
681
			unset($wancfg['mss']);
682
		} else {
683
			$wancfg['mss'] = $_POST['mss'];
684
		}
685
		if (isset($wancfg['wireless'])) {
686
			handle_wireless_post();
687
		}
688

    
689
		write_config();
690
		mark_subsystem_dirty('interfaces');
691
		/* regenerate cron settings/crontab file */
692
		configure_cron();
693
		conf_mount_ro();
694
		header("Location: interfaces.php?if={$if}");
695
		exit;
696
	}
697

    
698

    
699

    
700
} // end if($_POST)
701

    
702
function handle_wireless_post() {
703
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
704
	if (!is_array($wancfg['wireless']))
705
		$wancfg['wireless'] = array();
706
	$wancfg['wireless']['standard'] = $_POST['standard'];
707
	$wancfg['wireless']['mode'] = $_POST['mode'];
708
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
709
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
710
	$wancfg['wireless']['channel'] = $_POST['channel'];
711
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
712
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
713
	$wancfg['wireless']['distance'] = $_POST['distance'];
714
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
715
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
716
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
717
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
718
		foreach($wl_countries_attr as $wl_country) {
719
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
720
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
721
				break;
722
			}
723
		}
724
	}
725
	if (!is_array($wancfg['wireless']['wpa']))
726
		$wancfg['wireless']['wpa'] = array();
727
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
728
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
729
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
730
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
731
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
732
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
733
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
734
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
735
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
736
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
737
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
738
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
739
	if ($_POST['persistcommonwireless'] == "yes") {
740
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
741
			$config['wireless']['interfaces'][$wlanbaseif] = array();
742
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
743
		unset($config['wireless']['interfaces'][$wlanbaseif]);
744
	if (isset($_POST['diversity']) && $_POST['diversity'] != "")
745
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
746
	else if (isset($wancfg['wireless']['diversity']))
747
		unset($wancfg['wireless']['diversity']);
748
	if (isset($_POST['txantenna']) && $_POST['txantenna'] != "")
749
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
750
	else if (isset($wancfg['wireless']['txantenna']))
751
		unset($wancfg['wireless']['txantenna']);
752
	if (isset($_POST['rxantenna']) && $_POST['rxantenna'] != "")
753
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
754
	else if (isset($wancfg['wireless']['rxantenna']))
755
		unset($wancfg['wireless']['rxantenna']);
756
	if ($_POST['hidessid_enable'] == "yes")
757
		$wancfg['wireless']['hidessid']['enable'] = true;
758
	else if (isset($wancfg['wireless']['hidessid']['enable']))
759
		unset($wancfg['wireless']['hidessid']['enable']);
760
	if ($_POST['mac_acl_enable'] == "yes")
761
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
762
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
763
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
764
	if ($_POST['rsn_preauth'] == "yes")
765
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
766
	else
767
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
768
	if ($_POST['ieee8021x'] == "yes")
769
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
770
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
771
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
772
	if ($_POST['wpa_strict_rekey'] == "yes")
773
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
774
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
775
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
776
	if ($_POST['debug_mode'] == "yes")
777
		$wancfg['wireless']['wpa']['debug_mode'] = true;
778
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
779
		sunset($wancfg['wireless']['wpa']['debug_mode']);
780
	if ($_POST['wpa_enable'] == "yes")
781
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
782
	else if (isset($wancfg['wireless']['wpa']['enable']))
783
		unset($wancfg['wireless']['wpa']['enable']);
784
	if ($_POST['wep_enable'] == "yes") {
785
		if (!is_array($wancfg['wireless']['wep']))
786
			$wancfg['wireless']['wep'] = array();
787
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
788
	} else if (isset($wancfg['wireless']['wep']))
789
		unset($wancfg['wireless']['wep']);
790
	if ($_POST['wme_enable'] == "yes") {
791
		if (!is_array($wancfg['wireless']['wme']))
792
			$wancfg['wireless']['wme'] = array();
793
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
794
	} else if (isset($wancfg['wireless']['wme']['enable']))
795
		unset($wancfg['wireless']['wme']['enable']);
796
	if ($_POST['puremode'] == "11g") {
797
		if (!is_array($wancfg['wireless']['pureg']))
798
			$wancfg['wireless']['pureg'] = array();
799
		$wancfg['wireless']['pureg']['enable'] = true;
800
	} else if ($_POST['puremode'] == "11n") {
801
		if (!is_array($wancfg['wireless']['puren']))
802
			$wancfg['wireless']['puren'] = array();
803
		$wancfg['wireless']['puren']['enable'] = true;
804
	} else {
805
		if (isset($wancfg['wireless']['pureg']))
806
			unset($wancfg['wireless']['pureg']);
807
		if (isset($wancfg['wireless']['puren']))
808
			unset($wancfg['wireless']['puren']);
809
	}
810
	if ($_POST['apbridge_enable'] == "yes") {
811
		if (!is_array($wancfg['wireless']['apbridge']))
812
			$wancfg['wireless']['apbridge'] = array();
813
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
814
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
815
		unset($wancfg['wireless']['apbridge']['enable']);
816
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
817
		if (!is_array($wancfg['wireless']['turbo']))
818
			$wancfg['wireless']['turbo'] = array();
819
		$wancfg['wireless']['turbo']['enable'] = true;
820
	} else if (isset($wancfg['wireless']['turbo']['enable']))
821
		unset($wancfg['wireless']['turbo']['enable']);
822
	$wancfg['wireless']['wep']['key'] = array();
823
	for ($i = 1; $i <= 4; $i++) {
824
		if ($_POST['key' . $i]) {
825
			$newkey = array();
826
			$newkey['value'] = $_POST['key' . $i];
827
			if ($_POST['txkey'] == $i)
828
				$newkey['txkey'] = true;
829
			$wancfg['wireless']['wep']['key'][] = $newkey;
830
		}
831
	}
832
	interface_sync_wireless_clones($wancfg, true);
833
}
834

    
835
function check_wireless_mode() {
836
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
837

    
838
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
839
		return;
840

    
841
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
842
		$clone_count = 1;
843
	else
844
		$clone_count = 0;
845
	if (is_array($config['wireless']['clone'])) {
846
		foreach ($config['wireless']['clone'] as $clone) {
847
			if ($clone['if'] == $wlanbaseif)
848
				$clone_count++;
849
		}
850
	}
851
	if ($clone_count > 1) {
852
		$old_wireless_mode = $wancfg['wireless']['mode'];
853
		$wancfg['wireless']['mode'] = $_POST['mode'];
854
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
855
			$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']]);
856
		} else {
857
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
858
		}
859
		$wancfg['wireless']['mode'] = $old_wireless_mode;
860
	}
861
}
862

    
863
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
864
$statusurl = "status_interfaces.php";
865

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

    
870
?>
871

    
872
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
873
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
874
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
875
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
876

    
877
<script type="text/javascript">
878
	function updateType(t) {
879
		switch(t) {
880
			case "none": {
881
				$('static','dhcp','pppoe','pptp', 'ppp').invoke('hide');
882
				break;
883
			}
884
			case "static": {
885
				$('none','dhcp','pppoe','pptp', 'ppp').invoke('hide');
886
				break;
887
			}
888
			case "dhcp": {
889
				$('none','static','pppoe','pptp', 'ppp').invoke('hide');
890
				break;
891
			}
892
			case "ppp": {
893
				$('none','static','dhcp','pptp', 'pppoe').invoke('hide');
894
				country_list();
895
				break;
896
			}
897
			case "pppoe": {
898
				$('none','static','dhcp','pptp', 'ppp').invoke('hide');
899
				break;
900
			}
901
			case "pptp": {
902
				$('none','static','dhcp','pppoe', 'ppp').invoke('hide');
903
				break;
904
			}
905
		}
906
		$(t).show();
907
	}
908

    
909
	function show_allcfg(obj) {
910
		if (obj.checked)
911
			$('allcfg').show();
912
		else
913
			$('allcfg').hide();
914
	}
915

    
916
	function show_reset_settings(reset_type) {
917
		if (reset_type == 'preset') {
918
			Effect.Appear('pppoepresetwrap', { duration: 0.0 });
919
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
920
		}
921
		else if (reset_type == 'custom') {
922
			Effect.Appear('pppoecustomwrap', { duration: 0.0 });
923
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
924
		} else {
925
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
926
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
927
		}
928
	}
929
	function show_mon_config() {
930
		document.getElementById("showmonbox").innerHTML='';
931
		aodiv = document.getElementById('showmon');
932
		aodiv.style.display = "block";
933
	}
934

    
935
	function openwindow(url) {
936
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
937
		if (oWin==null || typeof(oWin)=="undefined")
938
			return false;
939
		else
940
			return true;
941
	}
942
	function country_list() {
943
		$('country').childElements().each(function(node) { node.remove(); });
944
		$('provider').childElements().each(function(node) { node.remove(); });
945
		$('providerplan').childElements().each(function(node) { node.remove(); });
946
		new Ajax.Request("getserviceproviders.php",{
947
			onSuccess: function(response) {
948
				var responseTextArr = response.responseText.split("\n");
949
				responseTextArr.sort();
950
				responseTextArr.each( function(value) {
951
					var option = new Element('option');
952
					country = value.split(":");
953
					option.text = country[0];
954
					option.value = country[1];
955
					$('country').insert({ bottom : option });
956
				});
957
			}
958
		});
959
		$('trcountry').setStyle({display : "table-row"});
960
	}
961

    
962
	function providers_list() {
963
		$('provider').childElements().each(function(node) { node.remove(); });
964
		$('providerplan').childElements().each(function(node) { node.remove(); });
965
		new Ajax.Request("getserviceproviders.php",{
966
			parameters: {country : $F('country')},
967
			onSuccess: function(response) {
968
				var responseTextArr = response.responseText.split("\n");
969
				responseTextArr.sort();
970
				responseTextArr.each( function(value) {
971
					var option = new Element('option');
972
					option.text = value;
973
					option.value = value;
974
					$('provider').insert({ bottom : option });
975
				});
976
			}
977
		});
978
		$('trprovider').setStyle({display : "table-row"});
979
		$('trproviderplan').setStyle({display : "none"});
980
	}
981

    
982
	function providerplan_list() {
983
		$('providerplan').childElements().each(function(node) { node.remove(); });
984
		$('providerplan').insert( new Element('option') );
985
		new Ajax.Request("getserviceproviders.php",{
986
			parameters: {country : $F('country'), provider : $F('provider')},
987
			onSuccess: function(response) {
988
				var responseTextArr = response.responseText.split("\n");
989
				responseTextArr.sort();
990
				responseTextArr.each( function(value) {
991
					if(value != "") {
992
						providerplan = value.split(":");
993

    
994
						var option = new Element('option');
995
						option.text = providerplan[0] + " - " + providerplan[1];
996
						option.value = providerplan[1];
997
						$('providerplan').insert({ bottom : option });
998
					}
999
				});
1000
			}
1001
		});
1002
		$('trproviderplan').setStyle({display : "table-row"});
1003
	}
1004

    
1005
	function prefill_provider() {
1006
		new Ajax.Request("getserviceproviders.php",{
1007
			parameters: {country : $F('country'), provider : $F('provider'), plan : $F('providerplan')},
1008
			onSuccess: function(response) {
1009
				var xmldoc = response.responseXML;
1010
				var provider = xmldoc.getElementsByTagName('connection')[0];
1011
				$('username').setValue('');
1012
				$('password').setValue('');
1013
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1014
					$('phone').setValue('#777');
1015
					$('apn').setValue('');
1016
				} else {
1017
					$('phone').setValue('*99#');
1018
					$('apn').setValue(provider.getElementsByTagName('apn')[0].firstChild.data);
1019
				}
1020
				$('username').setValue(provider.getElementsByTagName('username')[0].firstChild.data);
1021
				$('password').setValue(provider.getElementsByTagName('password')[0].firstChild.data);
1022
			}
1023
		});
1024
	}
1025

    
1026
</script>
1027
</head>
1028
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
1029
	<?php include("fbegin.inc"); ?>
1030
	<form action="interfaces.php" method="post" name="iform" id="iform">
1031
		<?php if ($input_errors) print_input_errors($input_errors); ?>
1032
		<?php if (is_subsystem_dirty('interfaces')): ?><p>
1033
		<?php print_info_box_np(sprintf(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 />
1034
		<?php endif; ?>
1035
		<?php if ($savemsg) print_info_box($savemsg); ?>
1036
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
1037
			<tr>
1038
				<td id="mainarea">
1039
					<div class="tabcont">
1040
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1041
						<tr>
1042
							<td colspan="2" valign="top" class="listtopic"><?=gettext("General configuration"); ?></td>
1043
						</tr>
1044
						<tr>
1045
							<td width="22%" valign="top" class="vncell"><?=gettext("Enable"); ?></td>
1046
							<td width="78%" class="vtable">
1047
								<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable'] == true) echo "checked"; ?> onClick="show_allcfg(this);">
1048
							<strong><?=gettext("Enable Interface"); ?></strong>
1049
							</td>
1050
						</tr>
1051
					</table>
1052
					<div style="display:none;" name="allcfg" id="allcfg">
1053
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1054
						<tr>
1055
							<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
1056
							<td width="78%" class="vtable">
1057
								<input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
1058
								<br><span class="vexpl"><?= gettext("Enter a description (name) for the interface here."); ?></span>
1059
							</td>
1060
						</tr>
1061
						<tr>
1062
							<td valign="middle" class="vncell"><strong><?=gettext("Type"); ?></strong></td>
1063
							<td class="vtable">
1064
								<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
1065
								<?php
1066
									foreach ($types as $key => $opt) {
1067
										echo "<option onClick=\"updateType('{$key}');\"";
1068
										if ($key == $pconfig['type'])
1069
											echo " selected";
1070
										echo " value=\"{$key}\" >" . htmlspecialchars($opt);
1071
										echo "</option>";
1072
									}
1073
								?>
1074
								</select>
1075
							</td>
1076
						</tr>
1077
						<tr>
1078
							<td valign="top" class="vncell"><?=gettext("MAC address"); ?></td>
1079
							<td class="vtable">
1080
								<input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
1081
								<?php
1082
									$ip = getenv('REMOTE_ADDR');
1083
									$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
1084
									$mac = str_replace("\n","",$mac);
1085
									if($mac):
1086
								?>
1087
									<a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#"><?=gettext("Insert my local MAC address"); ?></a>
1088
								<?php endif; ?>
1089
								<br>
1090
								<?=gettext("This field can be used to modify (\"spoof\") the MAC " .
1091
								"address of the WAN interface"); ?><br>
1092
								<?=gettext("(may be required with some cable connections)"); ?><br>
1093
								<?=gettext("Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx " .
1094
								"or leave blank"); ?>
1095
							</td>
1096
						</tr>
1097
						<tr>
1098
							<td valign="top" class="vncell"><?=gettext("MTU"); ?></td>
1099
							<td class="vtable">
1100
								<input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
1101
								<br>
1102
								<?=gettext("If you leave this field blank, " .
1103
								"an MTU of 1500 bytes will be assumed."); ?>
1104
							</td>
1105
						</tr>
1106
						<tr>
1107
							<td valign="top" class="vncell"><?=gettext("MSS"); ?></td>
1108
							<td class="vtable">
1109
								<input name="mss" type="text" class="formfld unknown" id="mss" size="8" value="<?=htmlspecialchars($pconfig['mss']);?>">
1110
								<br>
1111
								<?=gettext("If you enter a value in this field, then MSS clamping for " .
1112
								"TCP connections to the value entered above minus 40 (TCP/IP " .
1113
								"header size) will be in effect."); ?>
1114
							</td>
1115
						</tr>
1116
						<tr>
1117
							<td colspan="2" valign="top" height="16"></td>
1118
						</tr>
1119
						<tr style="display:none;" name="none" id="none">
1120
						</tr>
1121
						<tr style="display:none;" name="static" id="static">
1122
							<td colspan="2" style="padding:0px;">
1123
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1124
									<tr>
1125
										<td colspan="2" valign="top" class="listtopic"><?=gettext("Static IP configuration"); ?></td>
1126
									</tr>
1127
									<tr>
1128
										<td width="22%" valign="top" class="vncellreq"><?=gettext("IP address"); ?></td>
1129
										<td width="78%" class="vtable">
1130
											<input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
1131
											/
1132
											<select name="subnet" class="formselect" id="subnet">
1133
												<?php
1134
												for ($i = 32; $i > 0; $i--) {
1135
													if($i <> 31) {
1136
														echo "<option value=\"{$i}\" ";
1137
														if ($i == $pconfig['subnet']) echo "selected";
1138
														echo ">" . $i . "</option>";
1139
													}
1140
												}
1141
												?>
1142
											</select>
1143
										</td>
1144
									</tr>
1145
									<tr>
1146
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Gateway"); ?></td>
1147
										<td width="78%" class="vtable">
1148
											<select name="gateway" class="formselect" id="gateway">
1149
												<option value="none" selected><?=gettext("None"); ?></option>
1150
													<?php
1151
													if(count($a_gateways) > 0) {
1152
														foreach ($a_gateways as $gateway) {
1153
															if($gateway['interface'] == $if) {
1154
													?>
1155
															<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
1156
																<?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?>
1157
															</option>
1158
													<?php
1159
															}
1160
														}
1161
													}
1162
													?>
1163
											</select>
1164
											<br/>
1165
											<div id='addgwbox'>
1166
												<?=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>
1167
											</div>
1168
											<div id='notebox'>
1169
											</div>
1170
											<div id="status">
1171
											</div>
1172
											<div style="display:none" id="addgateway" name="addgateway">
1173
												<p>
1174
												<table border="1" style="background:#990000; border-style: none none none none; width:225px;">
1175
													<tr>
1176
														<td>
1177
															<table bgcolor="#990000" cellpadding="1" cellspacing="1">
1178
																<tr><td>&nbsp;</td>
1179
																<tr>
1180
																	<td colspan="2"><center><b><font color="white"><?=gettext("Add new gateway:"); ?></font></b></center></td>
1181
																</tr>
1182
																<tr><td>&nbsp;</td>
1183
																<?php
1184
																if($if == "wan" || $if == "WAN")
1185
																	$checked = " CHECKED";
1186
																?>
1187
																<tr>
1188
																	<td width="45%" align="right"><font color="white"><?=gettext("Default  gateway:"); ?></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
1189
																</tr>
1190
																<tr>
1191
																	<td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td>
1192
																</tr>
1193
																<tr>
1194
																	<td align="right"><font color="white"><?=gettext("Gateway IP:"); ?></td><td><input id="gatewayip" name="gatewayip"></td>
1195
																</tr>
1196
																<tr>
1197
																	<td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td>
1198
																</tr>
1199
																<tr><td>&nbsp;</td>
1200
																<tr>
1201
																	<td>&nbsp;</td>
1202
																	<td>
1203
																		<center>
1204
																			<div id='savebuttondiv'>
1205
																				<input type="hidden" name="addrtype" id="addrtype" value="IPv4" />
1206
																				<input id="gwsave" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave();'>
1207
																				<input id="gwcancel" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway();'>
1208
																			</div>
1209
																		</center>
1210
																	</td>
1211
																</tr>
1212
																<tr><td>&nbsp;</td></tr>
1213
															</table>
1214
														</td>
1215
													</tr>
1216
												</table>
1217
												<p/>
1218
											</div>
1219
										</td>
1220
									</tr>
1221
								</table>
1222
							</td>
1223
						</tr>
1224
						<tr style="display:none;" name="dhcp" id="dhcp">
1225
							<td colspan="2" style="padding: 0px;">
1226
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1227
									<tr>
1228
										<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration"); ?></td>
1229
									</tr>
1230
									<tr>
1231
										<td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td>
1232
										<td width="78%" class="vtable">
1233
											<input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
1234
											<br>
1235
											<?=gettext("The value in this field is sent as the DHCP client identifier " .
1236
											"and hostname when requesting a DHCP lease. Some ISPs may require " .
1237
											"this (for client identification)."); ?>
1238
										</td>
1239
									</tr>
1240
									<tr>
1241
										<td width="22%" valign="top" class="vncell"><?=gettext("Alias IP address"); ?></td>
1242
										<td width="78%" class="vtable">
1243
											<input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
1244
											<select name="alias-subnet" class="formselect" id="alias-subnet">
1245
												<?php
1246
												for ($i = 32; $i > 0; $i--) {
1247
													if($i <> 31) {
1248
														echo "<option value=\"{$i}\" ";
1249
														if ($i == $pconfig['alias-subnet']) echo "selected";
1250
														echo ">" . $i . "</option>";
1251
													}
1252
												}
1253
												?>
1254
											</select>
1255
											<?=gettext("The value in this field is used as a fixed alias IP address by the " .
1256
											"DHCP client."); ?>
1257
										</td>
1258
									</tr>
1259
								</table>
1260
							</td>
1261
						</tr>
1262
						<tr style="display:none;" name="ppp" id="ppp">
1263
							<td colspan="2" style="padding: 0px;">
1264
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1265
									<tr>
1266
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPP configuration"); ?></td>
1267
									</tr>
1268
									<tr name="ppp_provider" id="ppp_provider">
1269
										<td width="22%" valign="top" class="vncell"><?=gettext("Service Provider"); ?></td>
1270
										<td width="78%" class="vtable">
1271
											<table border="0" cellpadding="0" cellspacing="0">
1272
												<tr id="trcountry">
1273
													<td><?=gettext("Country:"); ?> &nbsp;&nbsp;</td>
1274
													<td>
1275
														<select class="formselect" name="country" id="country" onChange="providers_list()">
1276
															<option></option>
1277
														</select>
1278
													</td>
1279
												</tr>
1280
												<tr id="trprovider" style="display:none">
1281
													<td><?=gettext("Provider:"); ?> &nbsp;&nbsp;</td>
1282
													<td>
1283
														<select class="formselect" name="provider" id="provider" onChange="providerplan_list()">
1284
															<option></option>
1285
														</select>
1286
													</td>
1287
												</tr>
1288
												<tr id="trproviderplan" style="display:none">
1289
													<td><?=gettext("Plan:"); ?> &nbsp;&nbsp;</td>
1290
													<td>
1291
														<select class="formselect" name="providerplan" id="providerplan" onChange="prefill_provider()">
1292
															<option></option>
1293
														</select>
1294
													</td>
1295
												</tr>
1296
											</table>
1297
											<br/><span class="vexpl"><?=gettext("Select to fill in data for your service provider."); ?></span>
1298
										</td>
1299
									</tr>
1300
									<tr>
1301
										<td width="22%" valign="top" class="vncell"><?=gettext("Username"); ?></td>
1302
										<td width="78%" class="vtable">
1303
										<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
1304
										</td>
1305
									</tr>
1306
									<tr>
1307
										<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
1308
										<td width="78%" class="vtable">
1309
										<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
1310
										</td>
1311
									</tr>
1312
									<tr name="phone_num" id="phone_num">
1313
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Phone Number"); ?></td>
1314
										<td width="78%" class="vtable">
1315
											<input name="phone" type="text" class="formfld unknown" id="phone" size="12" value="<?=htmlspecialchars($pconfig['phone']);?>">
1316
										</td>
1317
									</tr>
1318
									<tr name="apn_" id="apn_">
1319
										<td width="22%" valign="top" class="vncell"><?=gettext("Access Point Name (APN)"); ?></td>
1320
										<td width="78%" class="vtable">
1321
											<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
1322
										</td>
1323
									</tr>
1324
									<tr name="interface" id="interface" >
1325
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Modem Port"); ?></td>
1326
										<td width="78%" class="vtable">
1327
											<select name="port" id="port" class="formselect">
1328
											<?php
1329
												$portlist = glob("/dev/cua*");
1330
												$modems = glob("/dev/modem*");
1331
												$portlist = array_merge($portlist, $modems);
1332
												foreach ($portlist as $port) {
1333
													if(preg_match("/\.(lock|init)$/", $port))
1334
														continue;
1335
													echo "<option value=\"".trim($port)."\"";
1336
													if ($pconfig['port'] == $port)
1337
														echo "selected";
1338
													echo ">{$port}</option>";
1339
												}?>
1340
											</select>
1341
										</td>
1342
									</tr>
1343
									<td width="22%" valign="top" class="vncell"><?=gettext("Advanced PPP"); ?></td>
1344
										<?php if (isset($pconfig['pppid'])): ?>
1345
											<td width="78%" class="vtable">
1346
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
1347
											<?=gettext("to edit PPP configuration."); ?>
1348
											</td>
1349
										<?php else: ?>
1350
											<td width="78%" class="vtable">
1351
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
1352
											<?=gettext("to create a PPP configuration."); ?>
1353
											</td>
1354
										<?php endif; ?>
1355
									</tr>
1356
								</table>
1357
							</td>
1358
						</tr>
1359
						<tr style="display:none;" name="pppoe" id="pppoe">
1360
							<td colspan="2" style="padding:0px;">
1361
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1362
									<tr>
1363
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPPoE configuration"); ?></td>
1364
									</tr>
1365
									<tr>
1366
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
1367
										<td width="78%" class="vtable">
1368
												<input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
1369
										</td>
1370
									</tr>
1371
									<tr>
1372
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
1373
										<td width="78%" class="vtable">
1374
											<input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
1375
										</td>
1376
									</tr>
1377
									<tr>
1378
										<td width="22%" valign="top" class="vncell"><?=gettext("Service name"); ?></td>
1379
										<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
1380
											<br> <span class="vexpl"><?=gettext("Hint: this field can usually be left empty"); ?></span>
1381
										</td>
1382
									</tr>
1383
									<tr>
1384
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
1385
										<td width="78%" class="vtable">
1386
											<input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>>
1387
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
1388
											<?=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."); ?>
1389
										</td>
1390
									</tr>
1391
									<tr>
1392
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
1393
										<td width="78%" class="vtable">
1394
											<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."); ?>
1395
										</td>
1396
									</tr>
1397
									<tr>
1398
										<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
1399
										<td width="78%" class="vtable">
1400
											<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
1401
												<tr>
1402
													<td align="left" valign="top">
1403
														<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
1404
														<select valign="top" id="reset_type" name="pppoe-reset-type" class="formselect" onChange="show_reset_settings(this.value);">
1405
															<option value = ""><?=gettext("Disabled"); ?></option>
1406
															<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?=gettext("Custom"); ?></option>
1407
															<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?=gettext("Pre-Set"); ?></option>
1408
														</select> <?=gettext("Select a reset timing type"); ?>
1409
														</p>
1410
														<?php if ($pconfig['pppoe_pr_custom']): ?>
1411
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
1412
														<?php else: ?>
1413
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
1414
														<?php endif; ?>
1415
														<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" />
1416
														<?=gettext("hour (0-23)"); ?><br />
1417
														<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" />
1418
														<?=gettext("minute (0-59)"); ?><br />
1419
														<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']);?>" />
1420
														<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
1421
														<br />&nbsp;<br />
1422
														<span class="red"><strong><?=gettext("Note:"); ?> </strong></span>
1423
														<?=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."); ?>
1424
														</p>
1425
														<?php if ($pconfig['pppoe_pr_preset']): ?>
1426
															<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
1427
														<?php else: ?>
1428
															<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
1429
														<?php endif; ?>
1430
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> />
1431
														<?=gettext("reset at each month ('0 0 1 * *')"); ?>
1432
														<br />
1433
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> />
1434
														<?=gettext("reset at each week ('0 0 * * 0')"); ?>
1435
														<br />
1436
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> />
1437
														<?=gettext("reset at each day ('0 0 * * *')"); ?>
1438
														<br />
1439
														<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> />
1440
														<?=gettext("reset at each hour ('0 * * * *')"); ?>
1441
														</p>
1442
													</td>
1443
												</tr>
1444
											</table>
1445
										</td>
1446
									</tr>
1447

    
1448
									<tr>
1449
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced and MLPPP"); ?></td>
1450
										<?php if (isset($pconfig['pppid'])): ?>
1451
											<td width="78%" class="vtable">
1452
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here"); ?> </a>
1453
											<?=gettext("for additional PPPoE configuration options. Save first if you made changes."); ?>
1454
											</td>
1455
										<?php else: ?>
1456
											<td width="78%" class="vtable">
1457
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here"); ?> </a>
1458
											<?=gettext("for advanced PPPoE configuration options and MLPPP configuration."); ?>
1459
											</td>
1460
										<?php endif; ?>
1461
									</tr>
1462
								</table>
1463
							</td>
1464
						</tr>
1465
						<tr style="display:none;" name="pptp" id="pptp">
1466
							<td colspan="2" style="padding:0px;">
1467
								<table width="100%" border="0" cellpadding="6" cellspacing="0">
1468
									<tr>
1469
										<td colspan="2" valign="top" class="listtopic"><?=gettext("PPTP configuration"); ?></td>
1470
									</tr>
1471
									<tr>
1472
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Username"); ?></td>
1473
										<td width="78%" class="vtable">
1474
											<input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
1475
										</td>
1476
									</tr>
1477
									<tr>
1478
										<td width="22%" valign="top" class="vncellreq"><?=gettext("Password"); ?></td>
1479
										<td width="78%" class="vtable">
1480
											<input name="pptp_password" type="password" class="formfld pwd" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
1481
										</td>
1482
									</tr>
1483
									<tr>
1484
										<td width="22%" width="100" valign="top" class="vncellreq"><?=gettext("Local IP address"); ?></td>
1485
										<td width="78%" class="vtable">
1486
											<input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20"  value="<?=htmlspecialchars($pconfig['pptp_local'][0]);?>">
1487
											/
1488
											<select name="pptp_subnet" class="formselect" id="pptp_subnet">
1489
												<?php for ($i = 31; $i > 0; $i--): ?>
1490
													<option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet'][0]) echo "selected"; ?>>
1491
														<?=$i;?></option>
1492
												<?php endfor; ?>
1493
											</select>
1494
										</td>
1495
									</tr>
1496
									<tr>
1497
										<td width="22%" width="100" valign="top" class="vncellreq"><?=gettext("Remote IP address"); ?></td>
1498
										<td width="78%" class="vtable">
1499
											<input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote'][0]);?>">
1500
										</td>
1501
									</tr>
1502
									<tr>
1503
										<td width="22%" valign="top" class="vncell"><?=gettext("Dial on demand"); ?></td>
1504
										<td width="78%" class="vtable">
1505
											<input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?>>
1506
											<strong><?=gettext("Enable Dial-On-Demand mode"); ?></strong><br>
1507
											<?=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."); ?>
1508
										</td>
1509
									</tr>
1510
									<tr>
1511
										<td width="22%" valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
1512
										<td width="78%" class="vtable">
1513
											<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."); ?>
1514
										</td>
1515
									</tr>
1516
									<tr>
1517
										<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1518
										<?php if (isset($pconfig['pppid'])): ?>
1519
											<td width="78%" class="vtable">
1520
											<a href="/interfaces_ppps_edit.php?id=<?=htmlspecialchars($pconfig['pppid']);?>" class="navlnk"><?=gettext("Click here");?></a>
1521
											<?=gettext("for additional PPTP and L2TP configuration options. Save first if you made changes.");?>
1522
											</td>
1523
										<?php else: ?>
1524
											<td width="78%" class="vtable">
1525
											<a href="/interfaces_ppps_edit.php" class="navlnk"><?=gettext("Click here");?></a>
1526
											<?=gettext("for advanced PPTP and L2TP configuration options");?>.
1527
											</td>
1528
										<?php endif; ?>
1529
									</tr>
1530
								</table>
1531
							</td>
1532
						</tr>
1533
						<?php
1534
							/* Wireless interface? */
1535
							if (isset($wancfg['wireless'])):
1536
						?>
1537
						<tr>
1538
							<td colspan="2" valign="top" height="16"></td>
1539
						</tr>
1540
						<tr>
1541
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Common wireless configuration - Settings apply to all wireless networks on"); ?> <?=$wlanbaseif;?>.</td>
1542
						</tr>
1543
						<tr>
1544
							<td valign="top" class="vncell"><?=gettext("Persist common settings");?></td>
1545
							<td class="vtable">
1546
								<input name="persistcommonwireless" type="checkbox" value="yes"  class="formfld" id="persistcommonwireless" <?php if ($pconfig['persistcommonwireless']) echo "checked";?>>
1547
								<br/><?=gettext("Enabling this preserves the common wireless configuration through interface deletions and reassignments.");?>
1548
							</td>
1549
						</tr>
1550
						<tr>
1551
							<td valign="top" class="vncellreq"><?=gettext("Standard"); ?></td>
1552
							<td class="vtable">
1553
							<select name="standard" class="formselect" id="standard">
1554
								<?php
1555
								foreach($wl_modes as $wl_standard => $wl_channels) {
1556
									echo "<option ";
1557
									if ($pconfig['standard'] == "$wl_standard")
1558
										echo "selected ";
1559
									echo "value=\"$wl_standard\">802.$wl_standard</option>\n";
1560
								}
1561
								?>
1562
							</select>
1563
							</td>
1564
						</tr>
1565
						<?php if (isset($wl_modes['11g'])): ?>
1566
						<tr>
1567
							<td valign="top" class="vncellreq">802.11g OFDM <?=gettext("Protection Mode"); ?></td>
1568
							<td class="vtable">
1569
								<select name="protmode" class="formselect" id="protmode">
1570
									<option <?php if ($pconfig['protmode'] == 'off') echo "selected";?> value="off"><?=gettext("Protection mode off"); ?></option>
1571
									<option <?php if ($pconfig['protmode'] == 'cts') echo "selected";?> value="cts"><?=gettext("Protection mode CTS to self"); ?></option>
1572
									<option <?php if ($pconfig['protmode'] == 'rtscts') echo "selected";?> value="rtscts"><?=gettext("Protection mode RTS and CTS"); ?></option>
1573
								</select>
1574
								<br/>
1575
								<?=gettext("For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network."); ?>
1576
								<br/>
1577
							</td>
1578
						</tr>
1579
						<?php else: ?>
1580
						<input name="protmode" type="hidden" id="protmode" value="off">
1581
						<?php endif; ?>
1582
						<tr>
1583
							<td valign="top" class="vncellreq"><?=gettext("Transmit power"); ?></td>
1584
							<td class="vtable">
1585
								<select name="txpower" class="formselect" id="txpower">
1586
									<?
1587
									for($x = 99; $x > 0; $x--) {
1588
										if($pconfig["txpower"] == $x)
1589
											$SELECTED = " SELECTED";
1590
										else
1591
											$SELECTED = "";
1592
										echo "<option {$SELECTED}>{$x}</option>\n";
1593
									}
1594
									?>
1595
								</select><br/>
1596
								<?=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 adapters support changing the transmit power setting."); ?>
1597
							</td>
1598
						</tr>
1599
						<tr>
1600
							<td valign="top" class="vncellreq"><?=gettext("Channel"); ?></td>
1601
							<td class="vtable">
1602
								<select name="channel" class="formselect" id="channel">
1603
									<option <?php if ($pconfig['channel'] == 0) echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
1604
									<?php
1605
									foreach($wl_modes as $wl_standard => $wl_channels) {
1606
										if($wl_standard == "11g") { $wl_standard = "11b/g"; }
1607
										else if($wl_standard == "11ng") { $wl_standard = "11b/g/n"; }
1608
										else if($wl_standard == "11na") { $wl_standard = "11a/n"; }
1609
										foreach($wl_channels as $wl_channel) {
1610
											echo "<option ";
1611
											if ($pconfig['channel'] == "$wl_channel") {
1612
												echo "selected ";
1613
											}
1614
											echo "value=\"$wl_channel\">$wl_standard - $wl_channel";
1615
											if(isset($wl_chaninfo[$wl_channel]))
1616
												echo " ({$wl_chaninfo[$wl_channel][1]} @ {$wl_chaninfo[$wl_channel][2]} / {$wl_chaninfo[$wl_channel][3]})";
1617
											echo "</option>\n";
1618
										}
1619
									}
1620
									?>
1621
								</select>
1622
								<br/>
1623
								<?=gettext("Legend: wireless standards - channel # (frequency @ max TX power / TX power allowed in reg. domain)"); ?>
1624
								<br/>
1625
								<?=gettext("Note: Not all channels may be supported by your card.  Auto may override the wireless standard selected above."); ?>
1626
							</td>
1627
						</tr>
1628
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"]) || isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
1629
						<tr>
1630
							<td valign="top" class="vncell"><?=gettext("Antenna settings"); ?></td>
1631
							<td class="vtable">
1632
								<table border="0" cellpadding="0" cellspacing="0">
1633
									<tr>
1634
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.diversity"])): ?>
1635
										<td>
1636
											<?=gettext("Diversity"); ?><br/>
1637
											<select name="diversity" class="formselect" id="diversity">
1638
												<option <?php if (empty($pconfig['diversity'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
1639
												<option <?php if ($pconfig['diversity'] == '0') echo "selected"; ?> value="0"><?=gettext("Off"); ?></option>
1640
												<option <?php if ($pconfig['diversity'] == '1') echo "selected"; ?> value="1"><?=gettext("On"); ?></option>
1641
											</select>
1642
										</td>
1643
										<td>&nbsp;&nbsp</td>
1644
										<?php endif; ?>
1645
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.txantenna"])): ?>
1646
										<td>
1647
											<?=gettext("Transmit antenna"); ?><br/>
1648
											<select name="txantenna" class="formselect" id="txantenna">
1649
												<option <?php if (empty($pconfig['txantenna'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
1650
												<option <?php if ($pconfig['txantenna'] == '0') echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
1651
												<option <?php if ($pconfig['txantenna'] == '1') echo "selected"; ?> value="1"><?=gettext("#1"); ?></option>
1652
												<option <?php if ($pconfig['txantenna'] == '2') echo "selected"; ?> value="2"><?=gettext("#2"); ?></option>
1653
											</select>
1654
										</td>
1655
										<td>&nbsp;&nbsp</td>
1656
										<?php endif; ?>
1657
										<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.rxantenna"])): ?>
1658
										<td>
1659
											<?=gettext("Receive antenna"); ?><br/>
1660
											<select name="rxantenna" class="formselect" id="rxantenna">
1661
												<option <?php if (empty($pconfig['rxantenna'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
1662
												<option <?php if ($pconfig['rxantenna'] == '0') echo "selected"; ?> value="0"><?=gettext("Auto"); ?></option>
1663
												<option <?php if ($pconfig['rxantenna'] == '1') echo "selected"; ?> value="1"><?=gettext("#1"); ?></option>
1664
												<option <?php if ($pconfig['rxantenna'] == '2') echo "selected"; ?> value="2"><?=gettext("#2"); ?></option>
1665
											</select>
1666
										</td>
1667
										<?php endif; ?>
1668
									</tr>
1669
								</table>
1670
								<br/>
1671
								<?=gettext("Note: The antenna numbers do not always match up with the labels on the card."); ?>
1672
							</td>
1673
						</tr>
1674
						<?php endif; ?>
1675
						<?php if (isset($wl_sysctl["{$wl_sysctl_prefix}.slottime"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.acktimeout"]) && isset($wl_sysctl["{$wl_sysctl_prefix}.ctstimeout"])): ?>
1676
						<tr>
1677
							<td valign="top" class="vncell"><?=gettext("Distance setting"); ?></td>
1678
							<td class="vtable">
1679
								<input name="distance" type="text" class="formfld unknown" id="distance" size="5" value="<?=htmlspecialchars($pconfig['distance']);?>">
1680
								<br/>
1681
								<?=gettext("Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client"); ?><br/>
1682
								<?=gettext("(measured in Meters and works only for Atheros based cards !)"); ?>
1683
							</td>
1684
						</tr>
1685
						<?php endif; ?>
1686
						<tr>
1687
							<td valign="top" class="vncell"><?=gettext("Regulatory settings"); ?></td>
1688
							<td class="vtable">
1689
								<?=gettext("Regulatory domain"); ?><br/>
1690
								<select name="regdomain" class="formselect" id="regdomain">
1691
									<option <?php if (empty($pconfig['regdomain'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
1692
									<?php
1693
									foreach($wl_regdomains as $wl_regdomain_key => $wl_regdomain) {
1694
										echo "<option ";
1695
										if ($pconfig['regdomain'] == $wl_regdomains_attr[$wl_regdomain_key]['ID']) {
1696
											echo "selected ";
1697
										}
1698
										echo "value=\"{$wl_regdomains_attr[$wl_regdomain_key]['ID']}\">{$wl_regdomain['name']}</option>\n";
1699
									}
1700
									?>
1701
								</select>
1702
								<br/>
1703
								<?=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."); ?>
1704
								<br/><br/>
1705
								<?=gettext("Country (listed with country code and regulatory domain)"); ?><br/>
1706
								<select name="regcountry" class="formselect" id="regcountry">
1707
									<option <?php if (empty($pconfig['regcountry'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
1708
									<?php
1709
									foreach($wl_countries as $wl_country_key => $wl_country) {
1710
										echo "<option ";
1711
										if ($pconfig['regcountry'] == $wl_countries_attr[$wl_country_key]['ID']) {
1712
											echo "selected ";
1713
										}
1714
										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";
1715
									}
1716
									?>
1717
								</select>
1718
								<br/>
1719
								<?=gettext("Note: Any country setting other than \"Default\" will override the regulatory domain setting"); ?>.
1720
								<br/><br/>
1721
								<?=gettext("Location"); ?><br/>
1722
								<select name="reglocation" class="formselect" id="reglocation">
1723
									<option <?php if (empty($pconfig['reglocation'])) echo "selected"; ?> value=""><?=gettext("Default"); ?></option>
1724
									<option <?php if ($pconfig['reglocation'] == 'indoor') echo "selected"; ?> value="indoor"><?=gettext("Indoor"); ?></option>
1725
									<option <?php if ($pconfig['reglocation'] == 'outdoor') echo "selected"; ?> value="outdoor"><?=gettext("Outdoor"); ?></option>
1726
									<option <?php if ($pconfig['reglocation'] == 'anywhere') echo "selected"; ?> value="anywhere"><?=gettext("Anywhere"); ?></option>
1727
								</select>
1728
								<br/><br/>
1729
								<?=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."); ?>
1730
								<br/>
1731
								<?=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."); ?>
1732
							</td>
1733
						</tr>
1734
						<tr>
1735
							<td colspan="2" valign="top" height="16"></td>
1736
						</tr>
1737
						<tr>
1738
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Network-specific wireless configuration");?></td>
1739
						</tr>
1740
						<tr>
1741
							<td valign="top" class="vncellreq"><?=gettext("Mode"); ?></td>
1742
							<td class="vtable">
1743
								<select name="mode" class="formselect" id="mode">
1744
									<option <?php if ($pconfig['mode'] == 'bss') echo "selected";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
1745
									<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
1746
									<option <?php if ($pconfig['mode'] == 'hostap') echo "selected";?> value="hostap"><?=gettext("Access Point"); ?></option>
1747
								</select>
1748
							</td>
1749
						</tr>
1750
						<tr>
1751
							<td valign="top" class="vncellreq"><?=gettext("SSID"); ?></td>
1752
							<td class="vtable">
1753
								<input name="ssid" type="text" class="formfld unknown" id="ssid" size="20" value="<?=htmlspecialchars($pconfig['ssid']); ?>">
1754
							</td>
1755
						</tr>
1756
						<?php if (isset($wl_modes['11ng']) || isset($wl_modes['11na'])): ?>
1757
						<tr>
1758
							<td valign="top" class="vncell"><?=gettext("Minimum wireless standard"); ?></td>
1759
							<td class="vtable">
1760
								<select name="puremode" class="formselect" id="puremode">
1761
									<option <?php if ($pconfig['puremode'] == 'any') echo "selected";?> value="any"><?=gettext("Any"); ?></option>
1762
									<?php if (isset($wl_modes['11g'])): ?>
1763
									<option <?php if ($pconfig['puremode'] == '11g') echo "selected";?> value="11g"><?=gettext("802.11g"); ?></option>
1764
									<?php endif; ?>
1765
									<option <?php if ($pconfig['puremode'] == '11n') echo "selected";?> value="11n"><?=gettext("802.11n"); ?></option>
1766
								</select>
1767
								<br/>
1768
								<?=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)."); ?>
1769
							</td>
1770
						</tr>
1771
						<?php elseif (isset($wl_modes['11g'])): ?>
1772
						<tr>
1773
							<td valign="top" class="vncell"><?=gettext("802.11g only"); ?></td>
1774
							<td class="vtable">
1775
								<input name="puremode" type="checkbox" value="11g"  class="formfld" id="puremode" <?php if ($pconfig['puremode'] == '11g') echo "checked";?>>
1776
								<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)."); ?>
1777
							</td>
1778
						</tr>
1779
						<?php endif; ?>
1780
						<tr>
1781
							<td valign="top" class="vncell"><?=gettext("Allow intra-BSS communication"); ?></td>
1782
							<td class="vtable">
1783
								<input name="apbridge_enable" type="checkbox" value="yes"  class="formfld" id="apbridge_enable" <?php if ($pconfig['apbridge_enable']) echo "checked";?>>
1784
								<br/>
1785
								<?=gettext("When operating as an access point, enable this if you want to pass packets between wireless clients directly."); ?>
1786
								<br/>
1787
								<?=gettext("Disabling the internal bridging is useful when traffic is to be processed with packet filtering."); ?>
1788
							</td>
1789
						</tr>
1790
						<tr>
1791
							<td valign="top" class="vncell"><?=gettext("Enable WME"); ?></td>
1792
							<td class="vtable">
1793
								<input name="wme_enable" type="checkbox" class="formfld" id="wme_enable" value="yes" <?php if ($pconfig['wme_enable']) echo "checked";?>>
1794
								<br/><?=gettext("Setting this option will force the card to use WME (wireless QoS)."); ?>
1795
							</td>
1796
						</tr>
1797
						<tr>
1798
							<td valign="top" class="vncell"><?=gettext("Enable Hide SSID"); ?></td>
1799
							<td class="vtable">
1800
								<input name="hidessid_enable" type="checkbox" class="formfld" id="hidessid_enable" value="yes" <?php if ($pconfig['hidessid_enable']) echo "checked";?>>
1801
								<br/>
1802
								<?=gettext("Setting this option will force the card to NOT broadcast its SSID"); ?>
1803
								<br/>
1804
								<?=gettext("(this might create problems for some clients)."); ?>
1805
							</td>
1806
						</tr>
1807
						<tr>
1808
							<td valign="top" class="vncell"><?=gettext("WEP"); ?></td>
1809
							<td class="vtable">
1810
								<input name="wep_enable" type="checkbox" id="wep_enable" value="yes" <?php if ($pconfig['wep_enable']) echo "checked"; ?>>
1811
								<strong><?=gettext("Enable WEP"); ?></strong>
1812
								<table border="0" cellspacing="0" cellpadding="0">
1813
									<tr>
1814
										<td>&nbsp;</td>
1815
										<td>&nbsp;</td>
1816
										<td>&nbsp;<?=gettext("TX key"); ?>&nbsp;</td>
1817
									</tr>
1818
									<tr>
1819
										<td><?=gettext("Key 1:"); ?>&nbsp;&nbsp;</td>
1820
										<td>
1821
											<input name="key1" type="text" class="formfld unknown" id="key1" size="30" value="<?=htmlspecialchars($pconfig['key1']);?>">
1822
										</td>
1823
										<td align="center">
1824
											<input name="txkey" type="radio" value="1" <?php if ($pconfig['txkey'] == 1) echo "checked";?>>
1825
										</td>
1826
									</tr>
1827
									<tr>
1828
										<td><?=gettext("Key 2:"); ?>&nbsp;&nbsp;</td>
1829
										<td>
1830
											<input name="key2" type="text" class="formfld unknown" id="key2" size="30" value="<?=htmlspecialchars($pconfig['key2']);?>">
1831
										</td>
1832
										<td align="center">
1833
											<input name="txkey" type="radio" value="2" <?php if ($pconfig['txkey'] == 2) echo "checked";?>>
1834
										</td>
1835
									</tr>
1836
									<tr>
1837
										<td><?=gettext("Key 3:"); ?>&nbsp;&nbsp;</td>
1838
										<td>
1839
											<input name="key3" type="text" class="formfld unknown" id="key3" size="30" value="<?=htmlspecialchars($pconfig['key3']);?>">
1840
										</td>
1841
										<td align="center">
1842
											<input name="txkey" type="radio" value="3" <?php if ($pconfig['txkey'] == 3) echo "checked";?>>
1843
										</td>
1844
									</tr>
1845
									<tr>
1846
										<td><?=gettext("Key 4:"); ?>&nbsp;&nbsp;</td>
1847
										<td>
1848
											<input name="key4" type="text" class="formfld unknown" id="key4" size="30" value="<?=htmlspecialchars($pconfig['key4']);?>">
1849
										</td>
1850
										<td align="center">
1851
											<input name="txkey" type="radio" value="4" <?php if ($pconfig['txkey'] == 4) echo "checked";?>>
1852
										</td>
1853
									</tr>
1854
								</table>
1855
								<br/>
1856
								<?=gettext("40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'."); ?><br/>
1857
								<?=gettext("104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'."); ?>
1858
							</td>
1859
						</tr>
1860
						<tr>
1861
							<td valign="top" class="vncell"><?=gettext("WPA"); ?></td>
1862
							<td class="vtable">
1863
								<input name="wpa_enable" type="checkbox" class="formfld" id="wpa_enable" value="yes" <?php if ($pconfig['wpa_enable']) echo "checked"; ?>>
1864
								<strong><?=gettext("Enable WPA"); ?></strong>
1865
								<br/><br/>
1866
								<table border="0" cellspacing="0" cellpadding="0">
1867
									<tr>
1868
										<td>&nbsp;</td>
1869
										<td>&nbsp;<?=gettext("WPA Pre Shared Key"); ?>&nbsp;</td>
1870
									</tr>
1871
									<tr>
1872
										<td><?=gettext("PSK:"); ?>&nbsp;&nbsp;</td>
1873
										<td>
1874
											<input name="passphrase" type="text" class="formfld unknown" id="passphrase" size="66" value="<?=htmlspecialchars($pconfig['passphrase']);?>">
1875
										</td>
1876
									</tr>
1877
								</table>
1878
								<br/><?=gettext("Passphrase must be from 8 to 63 characters."); ?>
1879
							</td>
1880
						</tr>
1881
						<tr>
1882
							<td valign="top" class="vncell"><?=gettext("WPA Mode"); ?></td>
1883
							<td class="vtable">
1884
								<select name="wpa_mode" class="formselect" id="wpa_mode">
1885
									<option <?php if ($pconfig['wpa_mode'] == '1') echo "selected";?> value="1"><?=gettext("WPA"); ?></option>
1886
									<option <?php if ($pconfig['wpa_mode'] == '2') echo "selected";?> value="2"><?=gettext("WPA2"); ?></option>
1887
									<option <?php if ($pconfig['wpa_mode'] == '3') echo "selected";?> value="3"><?=gettext("Both"); ?></option>
1888
								</select>
1889
							</td>
1890
						</tr>
1891
						<tr>
1892
							<td valign="top" class="vncell"><?=gettext("WPA Key Management Mode"); ?></td>
1893
							<td class="vtable">
1894
								<select name="wpa_key_mgmt" class="formselect" id="wpa_key_mgmt">
1895
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK') echo "selected";?> value="WPA-PSK"><?=gettext("Pre Shared Key"); ?></option>
1896
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-EAP') echo "selected";?> value="WPA-EAP"><?=gettext("Extensible Authentication Protocol"); ?></option>
1897
									<option <?php if ($pconfig['wpa_key_mgmt'] == 'WPA-PSK WPA-EAP') echo "selected";?> value="WPA-PSK WPA-EAP"><?=gettext("Both"); ?></option>
1898
								</select>
1899
							</td>
1900
						</tr>
1901
						<tr>
1902
							<td valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
1903
							<td class="vtable">
1904
								<select name="auth_algs" class="formselect" id="auth_algs">
1905
									<option <?php if ($pconfig['auth_algs'] == '1') echo "selected";?> value="1"><?=gettext("Open System Authentication"); ?></option>
1906
									<option <?php if ($pconfig['auth_algs'] == '2') echo "selected";?> value="2"><?=gettext("Shared Key Authentication"); ?></option>
1907
									<option <?php if ($pconfig['auth_algs'] == '3') echo "selected";?> value="3"><?=gettext("Both"); ?></option>
1908
								</select>
1909
								<br/><?=gettext("Note: Shared Key Authentication requires WEP."); ?></br>
1910
							</td>
1911
						</tr>
1912
						<tr>
1913
							<td valign="top" class="vncell"><?=gettext("WPA Pairwise"); ?></td>
1914
							<td class="vtable">
1915
								<select name="wpa_pairwise" class="formselect" id="wpa_pairwise">
1916
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP TKIP') echo "selected";?> value="CCMP TKIP"><?=gettext("Both"); ?></option>
1917
									<option <?php if ($pconfig['wpa_pairwise'] == 'CCMP') echo "selected";?> value="CCMP"><?=gettext("AES (recommended)"); ?></option>
1918
									<option <?php if ($pconfig['wpa_pairwise'] == 'TKIP') echo "selected";?> value="TKIP"><?=gettext("TKIP"); ?></option>
1919
								</select>
1920
							</td>
1921
						</tr>
1922
						<tr>
1923
							<td valign="top" class="vncell"><?=gettext("Key Rotation"); ?></td>
1924
							<td class="vtable">
1925
								<input name="wpa_group_rekey" type="text" class="formfld unknown" id="wpa_group_rekey" size="30" value="<?php echo $pconfig['wpa_group_rekey'] ? $pconfig['wpa_group_rekey'] : "60";?>">
1926
								<br/><?=gettext("Allowed values are 1-9999 but should not be longer than Master Key Regeneration time."); ?>
1927
							</td>
1928
						</tr>
1929
						<tr>
1930
							<td valign="top" class="vncell"><?=gettext("Master Key Regeneration"); ?></td>
1931
							<td class="vtable">
1932
								<input name="wpa_gmk_rekey" type="text" class="formfld" id="wpa_gmk_rekey" size="30" value="<?php echo $pconfig['wpa_gmk_rekey'] ? $pconfig['wpa_gmk_rekey'] : "3600";?>">
1933
								<br/><?=gettext("Allowed values are 1-9999 but should not be shorter than Key Rotation time."); ?>
1934
							</td>
1935
						</tr>
1936
						<tr>
1937
							<td valign="top" class="vncell"><?=gettext("Strict Key Regeneration"); ?></td>
1938
							<td class="vtable">
1939
								<input name="wpa_strict_rekey" type="checkbox" value="yes"  class="formfld" id="wpa_strict_rekey" <?php if ($pconfig['wpa_strict_rekey']) echo "checked"; ?>>
1940
								<br/><?=gettext("Setting this option will force the AP to rekey whenever a client disassociates."); ?>
1941
							</td>
1942
						</tr>
1943
						<tr>
1944
							<td valign="top" class="vncell"><?=gettext("Enable IEEE802.1X Authentication"); ?></td>
1945
							<td class="vtable">
1946
								<input name="ieee8021x" type="checkbox" value="yes"  class="formfld" id="ieee8021x" <?php if ($pconfig['ieee8021x']) echo "checked";?>>
1947
								<br/><?=gettext("Setting this option will enable 802.1x authentication."); ?>
1948
								<br/><span class="red"><strong><?=gettext("NOTE"); ?>:</strong</span> <?=gettext("this option requires checking the \"Enable WPA box\"."); ?>
1949
							</td>
1950
						</tr>
1951
						<tr>
1952
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server IP Address"); ?></td>
1953
							<td class="vtable">
1954
								<input name="auth_server_addr" id="auth_server_addr" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_addr']);?>">
1955
								<br/><?=gettext("Enter the IP address of the 802.1X Authentication Server.  This is commonly a Radius server (FreeRadius, Internet Authentication Services, etc.)"); ?>
1956
							</td>
1957
						</tr>
1958
						<tr>
1959
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Port"); ?></td>
1960
							<td class="vtable">
1961
								<input name="auth_server_port" id="auth_server_port" type="text" class="formfld unknown" size="66" value="<?=htmlspecialchars($pconfig['auth_server_port']);?>">
1962
								<br/><?=gettext("Leave blank for the default 1812 port."); ?>
1963
							</td>
1964
						</tr>
1965
						<tr>
1966
							<td valign="top" class="vncell"><?=gettext("802.1X Authentication Server Shared Secret"); ?></td>
1967
							<td class="vtable">
1968
								<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']);?>">
1969
								<br/>
1970
							</td>
1971
						</tr>
1972
						<tr>
1973
							<td valign="top" class="vncell">802.1X <?=gettext("Authentication Roaming Preauth"); ?></td>
1974
							<td class="vtable">
1975
								<input name="rsn_preauth" id="rsn_preauth" type="checkbox" class="formfld unknown" size="66" value="yes" <? if ($pconfig['rsn_preauth']) echo "checked"; ?>>
1976
								<br/>
1977
							</td>
1978
						</tr>
1979
						<?php endif; ?>
1980
						<tr>
1981
							<td colspan="2" valign="top" height="16"></td>
1982
						</tr>
1983
						<tr>
1984
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Private networks"); ?></td>
1985
						</tr>
1986
						<tr>
1987
							<td valign="middle" class="vncell">&nbsp;</td>
1988
							<td class="vtable">
1989
								<a name="rfc1918"></a>
1990
								<input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
1991
								<strong><?=gettext("Block private networks"); ?></strong><br>
1992
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
1993
								"for private  networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as"); ?>
1994
								<?=gettext("well as loopback addresses (127/8)."); ?>&nbsp;&nbsp; <?=gettext("You should generally " .
1995
								"leave this option turned on, unless your WAN network lies in such " .
1996
								"a private address space, too."); ?>
1997
							</td>
1998
						</tr>
1999
						<tr>
2000
							<td valign="middle" class="vncell">&nbsp;</td>
2001
							<td class="vtable">
2002
								<input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
2003
								<strong><?=gettext("Block bogon networks"); ?></strong><br>
2004
								<?=gettext("When set, this option blocks traffic from IP addresses that are reserved " .
2005
								"(but not RFC 1918) or not yet assigned by IANA."); ?>&nbsp;&nbsp;
2006
								<?=gettext("Bogons are prefixes that should never appear in the Internet routing table, " .
2007
								"and obviously should not appear as the source address in any packets you receive."); ?>
2008
							</td>
2009
						</tr>
2010
					</table> <!-- End "allcfg" table -->
2011
					</div> <!-- End "allcfg" div -->
2012

    
2013
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2014
						<tr>
2015
							<td width="22%" valign="top">
2016
								&nbsp;
2017
							</td>
2018
							<td width="78%">
2019
								<br/>
2020
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2021
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2022
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2023
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2024
								<input name="ppp_port" type="hidden" value="<?=$pconfig['port'];?>">
2025
								<?php endif; ?>
2026
								<input name="ptpid" type="hidden" value="<?=$pconfig['ptpid'];?>">
2027
							</td>
2028
						</tr>
2029
					</table>
2030
				</td>
2031
			</tr>
2032
		</table>
2033
		<!--
2034
		</div>
2035
		</td></tr>
2036
		</table>
2037
		-->
2038
	</form>
2039
	<script type="text/javascript">
2040
		var gatewayip;
2041
		var name;
2042
		function show_add_gateway() {
2043
			document.getElementById("addgateway").style.display = '';
2044
			document.getElementById("addgwbox").style.display = 'none';
2045
			document.getElementById("gateway").style.display = 'none';
2046
			document.getElementById("save").style.display = 'none';
2047
			document.getElementById("cancel").style.display = 'none';
2048
			document.getElementById("gwsave").style.display = '';
2049
			document.getElementById("gwcancel").style.display = '';
2050
			$('notebox').innerHTML="";
2051
		}
2052
		function hide_add_gateway() {
2053
			document.getElementById("addgateway").style.display = 'none';
2054
			document.getElementById("addgwbox").style.display = '';
2055
			document.getElementById("gateway").style.display = '';
2056
			document.getElementById("save").style.display = '';
2057
			document.getElementById("cancel").style.display = '';
2058
			document.getElementById("gwsave").style.display = '';
2059
			document.getElementById("gwcancel").style.display = '';
2060
		}
2061
		function hide_add_gatewaysave() {
2062
			document.getElementById("addgateway").style.display = 'none';
2063
			$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif"> One moment please...';
2064
			var iface = $F('if');
2065
			name = $('name').getValue();
2066
			var descr = $('gatewaydescr').getValue();
2067
			gatewayip = $('gatewayip').getValue();
2068
			addrtype = $('addrtype').getValue();
2069
			var defaultgw = $('defaultgw').getValue();
2070
			var url = "system_gateways_edit.php";
2071
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip) + '&type=' + escape(addrtype);
2072
			var myAjax = new Ajax.Request(
2073
				url,
2074
				{
2075
					method: 'post',
2076
					parameters: pars,
2077
					onFailure: report_failure,
2078
					onComplete: save_callback
2079
				});
2080
		}
2081
		function addOption(selectbox,text,value)
2082
		{
2083
			var optn = document.createElement("OPTION");
2084
			optn.text = text;
2085
			optn.value = value;
2086
			selectbox.options.add(optn);
2087
			selectbox.selectedIndex = (selectbox.options.length-1);
2088
			$('notebox').innerHTML="<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.";
2089
		}
2090
		function report_failure() {
2091
			alert("Sorry, we could not create your gateway at this time.");
2092
			hide_add_gateway();
2093
		}
2094
		function save_callback(transport) {
2095
			var response = transport.responseText;
2096
			if(response) {
2097
				document.getElementById("addgateway").style.display = 'none';
2098
				hide_add_gateway();
2099
				$('status').innerHTML = '';
2100
				addOption($('gateway'), name, name);
2101
				// Auto submit form?
2102
				//document.iform.submit();
2103
				//$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif">';
2104
			} else {
2105
				report_failure();
2106
			}
2107
		}
2108
		<?php
2109
		echo "show_allcfg(document.iform.enable);";
2110
		echo "updateType('{$pconfig['type']}');\n";
2111
		?>
2112
	</script>
2113
	<?php include("fend.inc"); ?>
2114
	</body>
2115
</html>
(81-81/220)