Project

General

Profile

Download (99.9 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
	else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp"){
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['dhcp_plus'] = isset($wancfg['dhcp_plus']);
179
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
180
$pconfig['enable'] = isset($wancfg['enable']);
181

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

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

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

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

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

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

    
321
		/* sync filter configuration */
322
		setup_gateways_monitor();
323

    
324
		clear_subsystem_dirty('staticroutes');
325

    
326
		filter_configure();
327

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

    
349
	unset($input_errors);
350
	$pconfig = $_POST;
351
	conf_mount_rw();
352

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

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

    
380
	switch(strtolower($_POST['type'])) {
381
		case "static":
382
			$reqdfields = explode(" ", "ipaddr subnet gateway");
383
			$reqdfieldsn = array(gettext("IP address"),gettext("Subnet bit count"),gettext("Gateway"));
384
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
385
			break;
386
		case "none":
387
			if(is_array($config['virtualip']['vip'])) {
388
				foreach ($config['virtualip']['vip'] as $vip) {
389
					if ($vip['interface'] == $if)
390
						$input_errors[] = gettext("This interface is referenced by VIPs please delete those before setting the interface to 'none' configuration.");
391
				}
392
			}
393
		case "dhcp":
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
		case "l2tp":
421
			if ($_POST['pptp_dialondemand']) {
422
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout");
423
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
424
			} else {
425
				$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote");
426
				$reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"));
427
			}
428
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
429
			break;
430
	}
431

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

    
521
		if ($_POST['passphrase']) {
522
                	$passlen = strlen($_POST['passphrase']);
523
                	if ($passlen < 8 || $passlen > 64)
524
                        	$input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters.");
525
		}
526
	}
527
	if (!$input_errors) {
528
		if ($wancfg['ipaddr'] != $_POST['type']) {
529
			if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
530
				$wancfg['if'] = $a_ppps[$pppid]['ports'];
531
				unset($a_ppps[$pppid]);
532
			} else if ($wancfg['ipaddr'] == "dhcp") {
533
				$pid = find_dhclient_process($realif);
534
				if($pid)
535
					posix_kill($pid, SIGTERM);
536
			}
537
				
538
		}
539
		$ppp = array();
540
		if ($wancfg['ipaddr'] != "ppp")
541
			unset($wancfg['ipaddr']);
542
		unset($wancfg['subnet']);
543
		unset($wancfg['gateway']);
544
		unset($wancfg['dhcphostname']);
545
		unset($wancfg['pppoe_username']);
546
		unset($wancfg['pppoe_password']);
547
		unset($wancfg['pptp_username']);
548
		unset($wancfg['pptp_password']);
549
		unset($wancfg['provider']);
550
		unset($wancfg['ondemand']);
551
		unset($wancfg['timeout']);
552
		if (isset($wancfg['pppoe']['pppoe-reset-type']))
553
			unset($wancfg['pppoe']['pppoe-reset-type']);
554
		unset($wancfg['local']);
555
		unset($wancfg['subnet']);
556
		unset($wancfg['remote']);
557
		unset($a_ppps[$pppid]['apn']);
558
		unset($a_ppps[$pppid]['phone']);
559
		unset($a_ppps[$pppid]['localip']);
560
		unset($a_ppps[$pppid]['subnet']);
561
		unset($a_ppps[$pppid]['gateway']);
562
		unset($a_ppps[$pppid]['pppoe-reset-type']);
563
		unset($a_ppps[$pppid]['provider']);
564

    
565
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
566
		$wancfg['enable'] =  $_POST['enable']  == "yes" ? true : false;
567

    
568
		/* for dynamic interfaces we tack a gateway item onto the array to prevent system
569
		 * log messages from appearing. They can also manually add these items */
570
		/* 1st added gateway gets a default bit */
571
		if(!empty($a_gateways)) {
572
			$gateway_item = array();
573
			/* check for duplicates */
574
			$skip = false;
575
			foreach($a_gateways as $item) {
576
				if(($item['interface'] == "$if") && ($item['gateway'] == "dynamic")) {
577
					$skip = true;
578
				}
579
			}
580
			if($skip == false) {
581
				$gateway_item['gateway'] = gettext("dynamic");
582
				$gateway_item['descr'] = gettext("Interface") . $if . gettext("dynamic gateway");
583
				$gateway_item['name'] = "GW_" . strtoupper($if);
584
				$gateway_item['interface'] = "{$if}";
585
			} else {
586
				unset($gateway_item);
587
			}
588
		}
589

    
590
		switch($_POST['type']) {
591
			case "static":
592
				$wancfg['ipaddr'] = $_POST['ipaddr'];
593
				$wancfg['subnet'] = $_POST['subnet'];
594
				if ($_POST['gateway'] != "none") {
595
					$wancfg['gateway'] = $_POST['gateway'];
596
				}
597
				break;
598
			case "dhcp":
599
				$wancfg['ipaddr'] = "dhcp";
600
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
601
				$wancfg['alias-address'] = $_POST['alias-address'];
602
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
603
				$wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false;
604
				if($gateway_item) {
605
					$a_gateways[] = $gateway_item;
606
				}
607
				break;
608
			case "carpdev-dhcp":
609
				$wancfg['ipaddr'] = "carpdev-dhcp";
610
				$wancfg['dhcphostname'] = $_POST['dhcphostname'];
611
				$wancfg['alias-address'] = $_POST['alias-address'];
612
				$wancfg['alias-subnet'] = $_POST['alias-subnet'];
613
				if($gateway_item) {
614
					$a_gateways[] = $gateway_item;
615
				}
616
				break;
617
			case "ppp":
618
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
619
				$a_ppps[$pppid]['type'] = $_POST['type'];
620
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
621
				$a_ppps[$pppid]['ports'] = $_POST['port'];
622
				$a_ppps[$pppid]['username'] = $_POST['username'];
623
				$a_ppps[$pppid]['password'] = base64_encode($_POST['password']);
624
				$a_ppps[$pppid]['phone'] = $_POST['phone'];
625
				$a_ppps[$pppid]['apn'] = $_POST['apn'];
626
				$wancfg['if'] = $_POST['type'] . $_POST['ptpid'];
627
				$wancfg['ipaddr'] = $_POST['type'];
628
				unset($a_ppps[$pppid]['ondemand']);
629
				unset($a_ppps[$pppid]['idletimeout']);
630
				break;
631

    
632
			case "pppoe":
633
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
634
				$a_ppps[$pppid]['type'] = $_POST['type'];
635
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
636
				if (isset($_POST['ppp_port']))
637
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
638
				else
639
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
640
				$a_ppps[$pppid]['username'] = $_POST['pppoe_username'];
641
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']);
642
				if (!empty($_POST['provider']))
643
					$a_ppps[$pppid]['provider'] = $_POST['provider'];
644
				else
645
					unset($a_ppps[$pppid]['provider']);
646
				$a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
647
				if (!empty($_POST['idletimeout']))
648
					$a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout'];
649
				else
650
					unset($a_ppps[$pppid]['idletimeout']);
651

    
652
				if (!empty($_POST['pppoe-reset-type']))
653
					$a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
654
				else
655
					unset($a_ppps[$pppid]['pppoe-reset-type']);
656
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
657
				$wancfg['ipaddr'] = $_POST['type'];
658
				if($gateway_item) {
659
					$a_gateways[] = $gateway_item;
660
				}
661

    
662
				break;
663
			case "pptp":
664
			case "l2tp":
665
				$a_ppps[$pppid]['ptpid'] = $_POST['ptpid'];
666
				$a_ppps[$pppid]['type'] = $_POST['type'];
667
				$a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid'];
668
				if (isset($_POST['ppp_port']))
669
					$a_ppps[$pppid]['ports'] = $_POST['ppp_port'];
670
				else
671
					$a_ppps[$pppid]['ports'] = $wancfg['if'];
672
				$a_ppps[$pppid]['username'] = $_POST['pptp_username'];
673
				$a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']);
674
				$a_ppps[$pppid]['localip'] = $_POST['pptp_local'];
675
				$a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet'];
676
				$a_ppps[$pppid]['gateway'] = $_POST['pptp_remote'];
677
				$a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
678
				if (!empty($_POST['idletimeout']))
679
					$a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout'];
680
				else
681
					unset($a_ppps[$pppid]['idletimeout']);
682
				$wancfg['if'] = $_POST['type'].$_POST['ptpid'];
683
				$wancfg['ipaddr'] = $_POST['type'];
684
				if($gateway_item) {
685
					$a_gateways[] = $gateway_item;
686
				}
687
				break;
688
			case "none":
689
				break;
690
		}
691
		handle_pppoe_reset($_POST);
692

    
693
		if($_POST['blockpriv'] == "yes") {
694
			$wancfg['blockpriv'] = true;
695
		} else {
696
			unset($wancfg['blockpriv']);
697
		}
698
		if($_POST['blockbogons'] == "yes") {
699
			$wancfg['blockbogons'] = true;
700
		} else {
701
			unset($wancfg['blockbogons']);
702
		}
703
		$wancfg['spoofmac'] = $_POST['spoofmac'];
704
		if (empty($_POST['mtu'])) {
705
			unset($wancfg['mtu']);
706
		} else {
707
			$wancfg['mtu'] = $_POST['mtu'];
708
		}
709
		if (empty($_POST['mss'])) {
710
			unset($wancfg['mss']);
711
		} else {
712
			$wancfg['mss'] = $_POST['mss'];
713
		}
714
		if (empty($_POST['mediaopt'])) {
715
			unset($wancfg['media']);
716
			unset($wancfg['mediaopt']);
717
		} else {
718
			$mediaopts = explode(' ', $_POST['mediaopt']);	
719
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
720
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
721
			else { unset($wancfg['mediaopt']); }
722
		}
723
		if (isset($wancfg['wireless'])) {
724
			handle_wireless_post();
725
		}
726

    
727
		conf_mount_ro();
728
		write_config();
729

    
730
		if (file_exists("{$g['tmp_path']}/.interfaces.apply"))
731
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
732
		else
733
			$toapplylist = array();
734
		$toapplylist[$if] = $if; 
735
		file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
736

    
737
		mark_subsystem_dirty('interfaces');
738

    
739
		/* regenerate cron settings/crontab file */
740
		configure_cron();
741

    
742
		header("Location: interfaces.php?if={$if}");
743
		exit;
744
	}
745

    
746
} // end if($_POST)
747

    
748
function handle_wireless_post() {
749
	global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif;
750
	if (!is_array($wancfg['wireless']))
751
		$wancfg['wireless'] = array();
752
	$wancfg['wireless']['standard'] = $_POST['standard'];
753
	$wancfg['wireless']['mode'] = $_POST['mode'];
754
	$wancfg['wireless']['protmode'] = $_POST['protmode'];
755
	$wancfg['wireless']['ssid'] = $_POST['ssid'];
756
	$wancfg['wireless']['channel'] = $_POST['channel'];
757
	$wancfg['wireless']['authmode'] = $_POST['authmode'];
758
	$wancfg['wireless']['txpower'] = $_POST['txpower'];
759
	$wancfg['wireless']['distance'] = $_POST['distance'];
760
	$wancfg['wireless']['regdomain'] = $_POST['regdomain'];
761
	$wancfg['wireless']['regcountry'] = $_POST['regcountry'];
762
	$wancfg['wireless']['reglocation'] = $_POST['reglocation'];
763
	if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) {
764
		foreach($wl_countries_attr as $wl_country) {
765
			if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) {
766
				$wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF'];
767
				break;
768
			}
769
		}
770
	}
771
	if (!is_array($wancfg['wireless']['wpa']))
772
		$wancfg['wireless']['wpa'] = array();
773
	$wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl'];
774
	$wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs'];
775
	$wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode'];
776
	$wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt'];
777
	$wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise'];
778
	$wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey'];
779
	$wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey'];
780
	$wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase'];
781
	$wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw'];
782
	$wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr'];
783
	$wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port'];
784
	$wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret'];
785
	if ($_POST['persistcommonwireless'] == "yes") {
786
		if (!is_array($config['wireless']['interfaces'][$wlanbaseif]))
787
			$config['wireless']['interfaces'][$wlanbaseif] = array();
788
	} else if (isset($config['wireless']['interfaces'][$wlanbaseif]))
789
		unset($config['wireless']['interfaces'][$wlanbaseif]);
790
	if (isset($_POST['diversity']) && is_numeric($_POST['diversity']))
791
		$wancfg['wireless']['diversity'] = $_POST['diversity'];
792
	else if (isset($wancfg['wireless']['diversity']))
793
		unset($wancfg['wireless']['diversity']);
794
	if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna']))
795
		$wancfg['wireless']['txantenna'] = $_POST['txantenna'];
796
	else if (isset($wancfg['wireless']['txantenna']))
797
		unset($wancfg['wireless']['txantenna']);
798
	if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna']))
799
		$wancfg['wireless']['rxantenna'] = $_POST['rxantenna'];
800
	else if (isset($wancfg['wireless']['rxantenna']))
801
		unset($wancfg['wireless']['rxantenna']);
802
	if ($_POST['hidessid_enable'] == "yes")
803
		$wancfg['wireless']['hidessid']['enable'] = true;
804
	else if (isset($wancfg['wireless']['hidessid']['enable']))
805
		unset($wancfg['wireless']['hidessid']['enable']);
806
	if ($_POST['mac_acl_enable'] == "yes")
807
		$wancfg['wireless']['wpa']['mac_acl_enable'] = true;
808
	else if (isset($wancfg['wireless']['wpa']['mac_acl_enable']))
809
		unset($wancfg['wireless']['wpa']['mac_acl_enable']);
810
	if ($_POST['rsn_preauth'] == "yes")
811
		$wancfg['wireless']['wpa']['rsn_preauth'] = true;
812
	else
813
		unset($wancfg['wireless']['wpa']['rsn_preauth']);
814
	if ($_POST['ieee8021x'] == "yes")
815
		$wancfg['wireless']['wpa']['ieee8021x']['enable'] = true;
816
	else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable']))
817
		unset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
818
	if ($_POST['wpa_strict_rekey'] == "yes")
819
		$wancfg['wireless']['wpa']['wpa_strict_rekey'] = true;
820
	else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey']))
821
		unset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
822
	if ($_POST['debug_mode'] == "yes")
823
		$wancfg['wireless']['wpa']['debug_mode'] = true;
824
	else if (isset($wancfg['wireless']['wpa']['debug_mode']))
825
		sunset($wancfg['wireless']['wpa']['debug_mode']);
826
	if ($_POST['wpa_enable'] == "yes")
827
		$wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true;
828
	else if (isset($wancfg['wireless']['wpa']['enable']))
829
		unset($wancfg['wireless']['wpa']['enable']);
830
	if ($_POST['wep_enable'] == "yes") {
831
		if (!is_array($wancfg['wireless']['wep']))
832
			$wancfg['wireless']['wep'] = array();
833
		$wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true;
834
	} else if (isset($wancfg['wireless']['wep']))
835
		unset($wancfg['wireless']['wep']);
836
	if ($_POST['wme_enable'] == "yes") {
837
		if (!is_array($wancfg['wireless']['wme']))
838
			$wancfg['wireless']['wme'] = array();
839
		$wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true;
840
	} else if (isset($wancfg['wireless']['wme']['enable']))
841
		unset($wancfg['wireless']['wme']['enable']);
842
	if ($_POST['puremode'] == "11g") {
843
		if (!is_array($wancfg['wireless']['pureg']))
844
			$wancfg['wireless']['pureg'] = array();
845
		$wancfg['wireless']['pureg']['enable'] = true;
846
	} else if ($_POST['puremode'] == "11n") {
847
		if (!is_array($wancfg['wireless']['puren']))
848
			$wancfg['wireless']['puren'] = array();
849
		$wancfg['wireless']['puren']['enable'] = true;
850
	} else {
851
		if (isset($wancfg['wireless']['pureg']))
852
			unset($wancfg['wireless']['pureg']);
853
		if (isset($wancfg['wireless']['puren']))
854
			unset($wancfg['wireless']['puren']);
855
	}
856
	if ($_POST['apbridge_enable'] == "yes") {
857
		if (!is_array($wancfg['wireless']['apbridge']))
858
			$wancfg['wireless']['apbridge'] = array();
859
		$wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true;
860
	} else if (isset($wancfg['wireless']['apbridge']['enable']))
861
		unset($wancfg['wireless']['apbridge']['enable']);
862
	if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") {
863
		if (!is_array($wancfg['wireless']['turbo']))
864
			$wancfg['wireless']['turbo'] = array();
865
		$wancfg['wireless']['turbo']['enable'] = true;
866
	} else if (isset($wancfg['wireless']['turbo']['enable']))
867
		unset($wancfg['wireless']['turbo']['enable']);
868
	$wancfg['wireless']['wep']['key'] = array();
869
	for ($i = 1; $i <= 4; $i++) {
870
		if ($_POST['key' . $i]) {
871
			$newkey = array();
872
			$newkey['value'] = $_POST['key' . $i];
873
			if ($_POST['txkey'] == $i)
874
				$newkey['txkey'] = true;
875
			$wancfg['wireless']['wep']['key'][] = $newkey;
876
		}
877
	}
878
	interface_sync_wireless_clones($wancfg, true);
879
}
880

    
881
function check_wireless_mode() {
882
	global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors;
883

    
884
	if ($wancfg['wireless']['mode'] == $_POST['mode'])
885
		return;
886

    
887
	if (does_interface_exist(interface_get_wireless_clone($wlanbaseif)))
888
		$clone_count = 1;
889
	else
890
		$clone_count = 0;
891
	if (is_array($config['wireless']['clone'])) {
892
		foreach ($config['wireless']['clone'] as $clone) {
893
			if ($clone['if'] == $wlanbaseif)
894
				$clone_count++;
895
		}
896
	}
897
	if ($clone_count > 1) {
898
		$old_wireless_mode = $wancfg['wireless']['mode'];
899
		$wancfg['wireless']['mode'] = $_POST['mode'];
900
		if (!interface_wireless_clone("{$wlanif}_", $wancfg)) {
901
			$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']]);
902
		} else {
903
			mwexec("/sbin/ifconfig {$wlanif}_ destroy");
904
		}
905
		$wancfg['wireless']['mode'] = $old_wireless_mode;
906
	}
907
}
908

    
909
// Find all possible media options for the interface
910
$mediaopts_list = array();
911
$intrealname = $config['interfaces'][$if]['if'];
912
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
913
foreach ($mediaopts as $mediaopt){
914
	preg_match("/media (.*)/", $mediaopt, $matches);
915
 	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
916
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
917
 		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
918
	}else{
919
		// there is only media like "media 1000baseT"
920
		array_push($mediaopts_list, $matches[1]);
921
	}
922
}
923

    
924
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
925
$statusurl = "status_interfaces.php";
926

    
927
$closehead = false;
928
include("head.inc");
929
$types = array("none" => gettext("None"), "static" => gettext("Static"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP") /* , "carpdev-dhcp" => "CarpDev"*/);
930

    
931
?>
932

    
933
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
934
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
935
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
936
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
937

    
938
<script type="text/javascript">
939
	function updateType(t) {
940
		switch(t) {
941
			case "none": {
942
				$('static','dhcp','pppoe','pptp', 'ppp').invoke('hide');
943
				break;
944
			}
945
			case "static": {
946
				$('none','dhcp','pppoe','pptp', 'ppp').invoke('hide');
947
				break;
948
			}
949
			case "dhcp": {
950
				$('none','static','pppoe','pptp', 'ppp').invoke('hide');
951
				break;
952
			}
953
			case "ppp": {
954
				$('none','static','dhcp','pptp', 'pppoe').invoke('hide');
955
				country_list();
956
				break;
957
			}
958
			case "pppoe": {
959
				$('none','static','dhcp','pptp', 'ppp').invoke('hide');
960
				break;
961
			}
962
			case "l2tp":
963
			case "pptp": {
964
				$('none','static','dhcp','pppoe', 'ppp').invoke('hide');
965
				$('pptp').show();
966
				break;
967
			}
968
		}
969
		if (t != "l2tp" && t != "pptp")
970
			$(t).show();
971
	}
972

    
973
	function show_allcfg(obj) {
974
		if (obj.checked)
975
			$('allcfg').show();
976
		else
977
			$('allcfg').hide();
978
	}
979

    
980
	function show_reset_settings(reset_type) {
981
		if (reset_type == 'preset') {
982
			Effect.Appear('pppoepresetwrap', { duration: 0.0 });
983
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
984
		}
985
		else if (reset_type == 'custom') {
986
			Effect.Appear('pppoecustomwrap', { duration: 0.0 });
987
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
988
		} else {
989
			Effect.Fade('pppoecustomwrap', { duration: 0.0 });
990
			Effect.Fade('pppoepresetwrap', { duration: 0.0 });
991
		}
992
	}
993
	function show_mon_config() {
994
		document.getElementById("showmonbox").innerHTML='';
995
		aodiv = document.getElementById('showmon');
996
		aodiv.style.display = "block";
997
	}
998

    
999
	function openwindow(url) {
1000
		var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
1001
		if (oWin==null || typeof(oWin)=="undefined")
1002
			return false;
1003
		else
1004
			return true;
1005
	}
1006
	function country_list() {
1007
		$('country').childElements().each(function(node) { node.remove(); });
1008
		$('provider').childElements().each(function(node) { node.remove(); });
1009
		$('providerplan').childElements().each(function(node) { node.remove(); });
1010
		new Ajax.Request("getserviceproviders.php",{
1011
			onSuccess: function(response) {
1012
				var responseTextArr = response.responseText.split("\n");
1013
				responseTextArr.sort();
1014
				responseTextArr.each( function(value) {
1015
					var option = new Element('option');
1016
					country = value.split(":");
1017
					option.text = country[0];
1018
					option.value = country[1];
1019
					$('country').insert({ bottom : option });
1020
				});
1021
			}
1022
		});
1023
		$('trcountry').setStyle({display : "table-row"});
1024
	}
1025

    
1026
	function providers_list() {
1027
		$('provider').childElements().each(function(node) { node.remove(); });
1028
		$('providerplan').childElements().each(function(node) { node.remove(); });
1029
		new Ajax.Request("getserviceproviders.php",{
1030
			parameters: {country : $F('country')},
1031
			onSuccess: function(response) {
1032
				var responseTextArr = response.responseText.split("\n");
1033
				responseTextArr.sort();
1034
				responseTextArr.each( function(value) {
1035
					var option = new Element('option');
1036
					option.text = value;
1037
					option.value = value;
1038
					$('provider').insert({ bottom : option });
1039
				});
1040
			}
1041
		});
1042
		$('trprovider').setStyle({display : "table-row"});
1043
		$('trproviderplan').setStyle({display : "none"});
1044
	}
1045

    
1046
	function providerplan_list() {
1047
		$('providerplan').childElements().each(function(node) { node.remove(); });
1048
		$('providerplan').insert( new Element('option') );
1049
		new Ajax.Request("getserviceproviders.php",{
1050
			parameters: {country : $F('country'), provider : $F('provider')},
1051
			onSuccess: function(response) {
1052
				var responseTextArr = response.responseText.split("\n");
1053
				responseTextArr.sort();
1054
				responseTextArr.each( function(value) {
1055
					if(value != "") {
1056
						providerplan = value.split(":");
1057

    
1058
						var option = new Element('option');
1059
						option.text = providerplan[0] + " - " + providerplan[1];
1060
						option.value = providerplan[1];
1061
						$('providerplan').insert({ bottom : option });
1062
					}
1063
				});
1064
			}
1065
		});
1066
		$('trproviderplan').setStyle({display : "table-row"});
1067
	}
1068

    
1069
	function prefill_provider() {
1070
		new Ajax.Request("getserviceproviders.php",{
1071
			parameters: {country : $F('country'), provider : $F('provider'), plan : $F('providerplan')},
1072
			onSuccess: function(response) {
1073
				var xmldoc = response.responseXML;
1074
				var provider = xmldoc.getElementsByTagName('connection')[0];
1075
				$('username').setValue('');
1076
				$('password').setValue('');
1077
				if(provider.getElementsByTagName('apn')[0].firstChild.data == "CDMA") {
1078
					$('phone').setValue('#777');
1079
					$('apn').setValue('');
1080
				} else {
1081
					$('phone').setValue('*99#');
1082
					$('apn').setValue(provider.getElementsByTagName('apn')[0].firstChild.data);
1083
				}
1084
				$('username').setValue(provider.getElementsByTagName('username')[0].firstChild.data);
1085
				$('password').setValue(provider.getElementsByTagName('password')[0].firstChild.data);
1086
			}
1087
		});
1088
	}
1089

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

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

    
2119
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
2120
						<tr>
2121
							<td width="22%" valign="top">
2122
								&nbsp;
2123
							</td>
2124
							<td width="78%">
2125
								<br/>
2126
								<input id="save" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
2127
								<input id="cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
2128
								<input name="if" type="hidden" id="if" value="<?=$if;?>">
2129
								<?php if ($wancfg['if'] == $a_ppps[$pppid]['if']) : ?>
2130
								<input name="ppp_port" type="hidden" value="<?=htmlspecialchars($pconfig['port']);?>">
2131
								<?php endif; ?>
2132
								<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
2133
							</td>
2134
						</tr>
2135
					</table>
2136
				</td>
2137
			</tr>
2138
		</table>
2139
		<!--
2140
		</div>
2141
		</td></tr>
2142
		</table>
2143
		-->
2144
	</form>
2145
	<script type="text/javascript">
2146
		var gatewayip;
2147
		var name;
2148
		function show_add_gateway() {
2149
			document.getElementById("addgateway").style.display = '';
2150
			document.getElementById("addgwbox").style.display = 'none';
2151
			document.getElementById("gateway").style.display = 'none';
2152
			document.getElementById("save").style.display = 'none';
2153
			document.getElementById("cancel").style.display = 'none';
2154
			document.getElementById("gwsave").style.display = '';
2155
			document.getElementById("gwcancel").style.display = '';
2156
			$('notebox').innerHTML="";
2157
		}
2158
		function hide_add_gateway() {
2159
			document.getElementById("addgateway").style.display = 'none';
2160
			document.getElementById("addgwbox").style.display = '';
2161
			document.getElementById("gateway").style.display = '';
2162
			document.getElementById("save").style.display = '';
2163
			document.getElementById("cancel").style.display = '';
2164
			document.getElementById("gwsave").style.display = '';
2165
			document.getElementById("gwcancel").style.display = '';
2166
		}
2167
		function hide_add_gatewaysave() {
2168
			document.getElementById("addgateway").style.display = 'none';
2169
			$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif"> One moment please...';
2170
			var iface = $F('if');
2171
			name = $('name').getValue();
2172
			var descr = $('gatewaydescr').getValue();
2173
			gatewayip = $('gatewayip').getValue();
2174
			addrtype = $('addrtype').getValue();
2175
			var defaultgw = $('defaultgw').getValue();
2176
			var url = "system_gateways_edit.php";
2177
			var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip) + '&type=' + escape(addrtype);
2178
			var myAjax = new Ajax.Request(
2179
				url,
2180
				{
2181
					method: 'post',
2182
					parameters: pars,
2183
					onFailure: report_failure,
2184
					onComplete: save_callback
2185
				});
2186
		}
2187
		function addOption(selectbox,text,value)
2188
		{
2189
			var optn = document.createElement("OPTION");
2190
			optn.text = text;
2191
			optn.value = value;
2192
			selectbox.options.add(optn);
2193
			selectbox.selectedIndex = (selectbox.options.length-1);
2194
			$('notebox').innerHTML="<p/><strong><?=gettext("NOTE:"); ?></strong> <?=gettext("You can manage Gateways"); ?> <a target='_new' href='system_gateways.php'><?=gettext("here"); ?></a>.";
2195
		}
2196
		function report_failure() {
2197
			alert("Sorry, we could not create your gateway at this time.");
2198
			hide_add_gateway();
2199
		}
2200
		function save_callback(transport) {
2201
			var response = transport.responseText;
2202
			if(response) {
2203
				document.getElementById("addgateway").style.display = 'none';
2204
				hide_add_gateway();
2205
				$('status').innerHTML = '';
2206
				addOption($('gateway'), name, name);
2207
				// Auto submit form?
2208
				//document.iform.submit();
2209
				//$('status').innerHTML = '<img src="/themes/metallic/images/misc/loader.gif">';
2210
			} else {
2211
				report_failure();
2212
			}
2213
		}
2214
		function show_advanced_media() {
2215
			document.getElementById("showadvmediabox").innerHTML='';
2216
			aodiv = document.getElementById('showmediaadv');
2217
			aodiv.style.display = "block";
2218
		}
2219
		<?php
2220
		echo "show_allcfg(document.iform.enable);";
2221
		echo "updateType('{$pconfig['type']}');\n";
2222
		?>
2223
	</script>
2224
	<?php include("fend.inc"); ?>
2225
	</body>
2226
</html>
(84-84/226)