Project

General

Profile

Download (95.4 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-2010 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
// Get configured interface list
58
$ifdescrs = get_configured_interface_with_descr(false, true);
59

    
60
$if = "wan";
61
if ($_REQUEST['if'])
62
	$if = $_REQUEST['if'];
63

    
64
if (empty($ifdescrs[$if])) {
65
	Header("Location: interfaces.php");
66
	exit;
67
}
68

    
69
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
70
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
71
define("CRON_DAILY_PATTERN", "0 0 * * *");
72
define("CRON_HOURLY_PATTERN", "0 * * * *");
73

    
74
if (!is_array($config['ppps']['ppp']))
75
	$config['ppps']['ppp'] = array();
76

    
77
$a_ppps = &$config['ppps']['ppp'];
78

    
79
function remove_bad_chars($string) {
80
	return preg_replace('/[^a-z_0-9]/i','',$string);
81
}
82

    
83
if (!is_array($config['gateways']['gateway_item']))
84
	$config['gateways']['gateway_item'] = array();
85
$a_gateways = &$config['gateways']['gateway_item'];
86

    
87
$wancfg = &$config['interfaces'][$if];
88
// Populate page descr if it does not exist.
89
if ($if == "wan" && !$wancfg['descr'])
90
	$wancfg['descr'] = "WAN";
91
else if ($if == "lan" && !$wancfg['descr'])
92
	$wancfg['descr'] = "LAN";
93

    
94

    
95
foreach ($a_ppps as $pppid => $ppp) {
96
	if ($wancfg['if'] == $ppp['if'])
97
		break;
98
}
99

    
100
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
101
	$pconfig['pppid'] = $pppid;
102
	$pconfig['ptpid'] = $a_ppps[$pppid]['ptpid'];
103
	$pconfig['port'] = $a_ppps[$pppid]['ports'];
104
	if ($a_ppps[$pppid]['type'] == "ppp"){
105
		$pconfig['username'] = $a_ppps[$pppid]['username'];
106
		$pconfig['password'] = base64_decode($a_ppps[$pppid]['password']);
107

    
108
		$pconfig['phone'] = $a_ppps[$pppid]['phone'];
109
		$pconfig['apn'] = $a_ppps[$pppid]['apn'];
110
	}
111

    
112
	if ($a_ppps[$pppid]['type'] == "pppoe"){
113
		$pconfig['pppoe_username'] = $a_ppps[$pppid]['username'];
114
		$pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']);
115
		$pconfig['provider'] = $a_ppps[$pppid]['provider'];
116
		$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
117
		$pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout'];
118

    
119
		/* ================================================ */
120
		/* = force a connection reset at a specific time? = */
121
		/* ================================================ */
122

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

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

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

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

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

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

    
307
		if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
308
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
309
			foreach ($toapplylist as $ifapply) {
310
				if (isset($config['interfaces'][$ifapply]['enable']))
311
					interface_configure($ifapply, true);
312
				else
313
					interface_bring_down($ifapply);
314
			}
315
		}
316
		/* restart snmp so that it binds to correct address */
317
		services_snmpd_configure();
318

    
319
		/* sync filter configuration */
320
		setup_gateways_monitor();
321

    
322
		clear_subsystem_dirty('staticroutes');
323

    
324
		filter_configure();
325

    
326
		enable_rrd_graphing();
327
	}
328
	@unlink("{$g['tmp_path']}/.interfaces.apply");
329
	header("Location: interfaces.php?if={$if}");
330
	exit;
331
} else if ($_POST && $_POST['enable'] != "yes") {
332
	unset($wancfg['enable']);
333
	if (isset($wancfg['wireless']))
334
		interface_sync_wireless_clones($wancfg, false);
335
	write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
336
	mark_subsystem_dirty('interfaces');
337
	if (file_exists("{$g['tmp_path']}/.interfaces.apply"))
338
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
339
	else
340
		$toapplylist = array();
341
	$toapplylist[$if] = $if; 
342
	file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
343
	header("Location: interfaces.php?if={$if}");
344
	exit;
345
} else if ($_POST) {
346

    
347
	unset($input_errors);
348
	$pconfig = $_POST;
349
	conf_mount_rw();
350

    
351
	/* filter out spaces from descriptions  */
352
	$_POST['descr'] = remove_bad_chars($_POST['descr']);
353

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

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

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

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

    
544
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
545
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
546

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

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

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

    
630
				if (!empty($_POST['pppoe-reset-type']))
631
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
632
				else
633
					unset($a_ppps[$pppid]['pppoe-reset-type']);
634
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
635
				$wancfg['ipaddr'] = $_POST['type'];
636
				if($gateway_item) {
637
					$a_gateways[] = $gateway_item;
638
				}
639

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

    
670
		if($_POST['blockpriv'] == "yes") {
671
			$wancfg['blockpriv'] = true;
672
		} else {
673
			unset($wancfg['blockpriv']);
674
		}
675
		if($_POST['blockbogons'] == "yes") {
676
			$wancfg['blockbogons'] = true;
677
		} else {
678
			unset($wancfg['blockbogons']);
679
		}
680
		$wancfg['spoofmac'] = $_POST['spoofmac'];
681
		if (empty($_POST['mtu'])) {
682
			unset($wancfg['mtu']);
683
		} else {
684
			$wancfg['mtu'] = $_POST['mtu'];
685
		}
686
		if (empty($_POST['mss'])) {
687
			unset($wancfg['mss']);
688
		} else {
689
			$wancfg['mss'] = $_POST['mss'];
690
		}
691
		if (isset($wancfg['wireless'])) {
692
			handle_wireless_post();
693
		}
694

    
695
		conf_mount_ro();
696
		write_config();
697

    
698
		if (file_exists("{$g['tmp_path']}/.interfaces.apply"))
699
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
700
		else
701
			$toapplylist = array();
702
		$toapplylist[$if] = $if; 
703
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
704

    
705
		mark_subsystem_dirty('interfaces');
706

    
707
		/* regenerate cron settings/crontab file */
708
		configure_cron();
709

    
710
		header("Location: interfaces.php?if={$if}");
711
		exit;
712
	}
713

    
714
} // end if($_POST)
715

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

    
849
function check_wireless_mode() {
850
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
851

    
852
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
853
		return;
854

    
855
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
856
		$clone_count = 1;
857
	else
858
		$clone_count = 0;
859
	if (is_array($config['wireless']['clone'])) {
860
		foreach ($config['wireless']['clone'] as $clone) {
861
			if ($clone['if'] == $wlanbaseif)
862
				$clone_count++;
863
		}
864
	}
865
	if ($clone_count > 1) {
866
		$old_wireless_mode = $wancfg['wireless']['mode'];
867
		$wancfg['wireless']['mode'] = $_POST['mode'];
868
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
869
			$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']]);
870
		} else {
871
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
872
		}
873
		$wancfg['wireless']['mode'] = $old_wireless_mode;
874
	}
875
}
876

    
877
$pgtitle = array(gettext("Interfaces"), strtoupper($pconfig['descr']));
878
$statusurl = "status_interfaces.php";
879

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

    
884
?>
885

    
886
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
887
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
888
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
889
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
890

    
891
<script type="text/javascript">
892
	function updateType(t) {
893
		switch(t) {
894
			case "none": {
895
				$('static','dhcp','pppoe','pptp', 'ppp').invoke('hide');
896
				break;
897
			}
898
			case "static": {
899
				$('none','dhcp','pppoe','pptp', 'ppp').invoke('hide');
900
				break;
901
			}
902
			case "dhcp": {
903
				$('none','static','pppoe','pptp', 'ppp').invoke('hide');
904
				break;
905
			}
906
			case "ppp": {
907
				$('none','static','dhcp','pptp', 'pppoe').invoke('hide');
908
				country_list();
909
				break;
910
			}
911
			case "pppoe": {
912
				$('none','static','dhcp','pptp', 'ppp').invoke('hide');
913
				break;
914
			}
915
			case "pptp": {
916
				$('none','static','dhcp','pppoe', 'ppp').invoke('hide');
917
				break;
918
			}
919
		}
920
		$(t).show();
921
	}
922

    
923
	function show_allcfg(obj) {
924
		if (obj.checked)
925
			$('allcfg').show();
926
		else
927
			$('allcfg').hide();
928
	}
929

    
930
	function show_reset_settings(reset_type) {
931
		if (reset_type == 'preset') {
932
			Effect.Appear('pppoepresetwrap', { duration: 0.0 });
933
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
934
		}
935
		else if (reset_type == 'custom') {
936
			Effect.Appear('pppoecustomwrap', { duration: 0.0 });
937
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
938
		} else {
939
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
940
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
941
		}
942
	}
943
	function show_mon_config() {
944
		document.getElementById("showmonbox").innerHTML='';
945
		aodiv = document.getElementById('showmon');
946
		aodiv.style.display = "block";
947
	}
948

    
949
	function openwindow(url) {
950
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
951
		if (oWin==null || typeof(oWin)=="undefined")
952
			return false;
953
		else
954
			return true;
955
	}
956
	function country_list() {
957
		$('country').childElements().each(function(node) { node.remove(); });
958
		$('provider').childElements().each(function(node) { node.remove(); });
959
		$('providerplan').childElements().each(function(node) { node.remove(); });
960
		new Ajax.Request("getserviceproviders.php",{
961
			onSuccess: function(response) {
962
				var responseTextArr = response.responseText.split("\n");
963
				responseTextArr.sort();
964
				responseTextArr.each( function(value) {
965
					var option = new Element('option');
966
					country = value.split(":");
967
					option.text = country[0];
968
					option.value = country[1];
969
					$('country').insert({ bottom : option });
970
				});
971
			}
972
		});
973
		$('trcountry').setStyle({display : "table-row"});
974
	}
975

    
976
	function providers_list() {
977
		$('provider').childElements().each(function(node) { node.remove(); });
978
		$('providerplan').childElements().each(function(node) { node.remove(); });
979
		new Ajax.Request("getserviceproviders.php",{
980
			parameters: {country : $F('country')},
981
			onSuccess: function(response) {
982
				var responseTextArr = response.responseText.split("\n");
983
				responseTextArr.sort();
984
				responseTextArr.each( function(value) {
985
					var option = new Element('option');
986
					option.text = value;
987
					option.value = value;
988
					$('provider').insert({ bottom : option });
989
				});
990
			}
991
		});
992
		$('trprovider').setStyle({display : "table-row"});
993
		$('trproviderplan').setStyle({display : "none"});
994
	}
995

    
996
	function providerplan_list() {
997
		$('providerplan').childElements().each(function(node) { node.remove(); });
998
		$('providerplan').insert( new Element('option') );
999
		new Ajax.Request("getserviceproviders.php",{
1000
			parameters: {country : $F('country'), provider : $F('provider')},
1001
			onSuccess: function(response) {
1002
				var responseTextArr = response.responseText.split("\n");
1003
				responseTextArr.sort();
1004
				responseTextArr.each( function(value) {
1005
					if(value != "") {
1006
						providerplan = value.split(":");
1007

    
1008
						var option = new Element('option');
1009
						option.text = providerplan[0] + " - " + providerplan[1];
1010
						option.value = providerplan[1];
1011
						$('providerplan').insert({ bottom : option });
1012
					}
1013
				});
1014
			}
1015
		});
1016
		$('trproviderplan').setStyle({display : "table-row"});
1017
	}
1018

    
1019
	function prefill_provider() {
1020
		new Ajax.Request("getserviceproviders.php",{
1021
			parameters: {country : $F('country'), provider : $F('provider'), plan : $F('providerplan')},
1022
			onSuccess: function(response) {
1023
				var xmldoc = response.responseXML;
1024
				var provider = xmldoc.getElementsByTagName('connection')[0];
1025
				$('username').setValue('');
1026
				$('password').setValue('');
1027
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1028
					$('phone').setValue('#777');
1029
					$('apn').setValue('');
1030
				} else {
1031
					$('phone').setValue('*99#');
1032
					$('apn').setValue(provider.getElementsByTagName('apn')[0].firstChild.data);
1033
				}
1034
				$('username').setValue(provider.getElementsByTagName('username')[0].firstChild.data);
1035
				$('password').setValue(provider.getElementsByTagName('password')[0].firstChild.data);
1036
			}
1037
		});
1038
	}
1039

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

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

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