Project

General

Profile

Download (41.7 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces_wan.php
5
        Copyright (C) 2007 Scott Ullrich
6
	All rights reserved.
7

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

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

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

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

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

    
34
##|+PRIV
35
##|*IDENT=page-interfaces-wan
36
##|*NAME=Interfaces: WAN page
37
##|*DESCR=Allow access to the 'Interfaces: WAN' page.
38
##|*MATCH=interfaces_wan.php*
39
##|-PRIV
40

    
41
if ($_REQUEST['if'])
42
	$if = $_REQUEST['if'];
43
else
44
	$if = "wan";
45

    
46
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
47
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
48
define("CRON_DAILY_PATTERN", "0 0 * * *");
49
define("CRON_HOURLY_PATTERN", "0 * * * *");
50
define("CRON_PPPOE_CMD_FILE", "/etc/pppoerestart");
51
define("CRON_PPPOE_CMD", "#!/bin/sh\necho '<?php require(\"interfaces.inc\"); interfaces_wan_pppoe_restart($if); services_dyndns_reset($if); ?>' | /usr/local/bin/php -q");
52

    
53
function getMPDCRONSettings() {
54
  global $config;
55

    
56
  if (is_array($config['cron']['item'])) {
57
    for ($i = 0; $i < count($config['cron']['item']); $i++) {
58
      $item =& $config['cron']['item'][$i];
59

    
60
      if (strpos($item['command'], CRON_PPPOE_CMD_FILE) !== false) {
61
        return array("ID" => $i, "ITEM" => $item);
62
      }
63
    }
64
  }
65

    
66
  return NULL;
67
}
68

    
69
function getMPDResetTimeFromConfig() {
70
  $itemhash = getMPDCRONSettings();
71
  $cronitem = $itemhash['ITEM'];
72

    
73
  if (isset($cronitem)) {
74

    
75
    return "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
76
  } else {
77
    return NULL;
78
  }
79
}
80

    
81
function remove_bad_chars($string) {
82
        return preg_replace('/[^a-z|_|0-9]/i','',$string);
83
}
84

    
85
require("guiconfig.inc");
86

    
87
if (!is_array($config['gateways']['gateway_item']))
88
	$config['gateways']['gateway_item'] = array();
89
$a_gateways = &$config['gateways']['gateway_item'];
90

    
91
$wancfg = &$config['interfaces'][$if];
92

    
93
$pconfig['pppoe_username'] = $wancfg['pppoe_username'];
94
$pconfig['pppoe_password'] = $wancfg['pppoe_password'];
95
$pconfig['provider'] = $wancfg['provider'];
96
$pconfig['pppoe_dialondemand'] = isset($wancfg['ondemand']);
97
$pconfig['pppoe_idletimeout'] = $wancfg['timeout'];
98

    
99
/* ================================================ */
100
/* = force a connection reset at a specific time? = */
101
/* ================================================ */
102

    
103
if (isset($wancfg['pppoe']['pppoe-reset-type'])) {
104
  $resetTime = getMPDResetTimeFromConfig();  
105
  $pconfig['pppoe_preset'] = true;
106
  
107
  if ($wancfg['pppoe']['pppoe-reset-type'] == "custom") {
108
    $resetTime_a = split(" ", $resetTime);
109
    $pconfig['pppoe_pr_custom'] = true;
110
    $pconfig['pppoe_resetminute'] = $resetTime_a[0];
111
    $pconfig['pppoe_resethour'] = $resetTime_a[1];
112

    
113
    /* just initialize $pconfig['pppoe_resetdate'] if the
114
     * coresponding item contains appropriate numeric values.
115
     */
116
    if ($resetTime_a[2] <> "*" && $resetTime_a[3] <> "*") {
117
      $pconfig['pppoe_resetdate'] = "{$resetTime_a[3]}/{$resetTime_a[2]}/" . date("Y");
118
    }
119
  } else if ($wancfg['pppoe']['pppoe-reset-type'] == "preset") {
120
    $pconfig['pppoe_pr_preset'] = true;
121
    
122
    switch ($resetTime) {
123
      case CRON_MONTHLY_PATTERN:
124
        $pconfig['pppoe_monthly'] = true;
125
        break;
126
      case CRON_WEEKLY_PATTERN:
127
        $pconfig['pppoe_weekly'] = true;
128
        break;
129
      case CRON_DAILY_PATTERN:
130
        $pconfig['pppoe_daily'] = true;
131
        break;
132
      case CRON_HOURLY_PATTERN:
133
        $pconfig['pppoe_hourly'] = true;
134
        break;
135
    }
136
  }
137
}
138

    
139
$pconfig['pptp_username'] = $wancfg['pptp_username'];
140
$pconfig['pptp_password'] = $wancfg['pptp_password'];
141
$pconfig['pptp_local'] = $wancfg['local'];
142
$pconfig['pptp_subnet'] = $wancfg['subnet'];
143
$pconfig['pptp_remote'] = $wancfg['remote'];
144
$pconfig['pptp_dialondemand'] = isset($wancfg['ondemand']);
145
$pconfig['pptp_idletimeout'] = $wancfg['timeout'];
146

    
147
$pconfig['disableftpproxy'] = isset($wancfg['disableftpproxy']);
148

    
149
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
150
$pconfig['alias-address'] = $wancfg['alias-address'];
151
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
152
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
153
if ($if == "wan" || $if == "lan")
154
	$pconfig['enable'] = true;
155
else
156
	$pconfig['enable'] = isset($wancfg['enable']);
157

    
158
if (is_array($config['aliases']['alias']))
159
foreach($config['aliases']['alias'] as $alias)
160
        if($alias['name'] == $wancfg['descr'])
161
                $input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} a
162
lready exists.");
163

    
164
if ($wancfg['ipaddr'] == "dhcp") {
165
	$pconfig['type'] = "dhcp";
166
} else if ($wancfg['ipaddr'] == "carpdev-dhcp") {
167
	$pconfig['type'] = "carpdev-dhcp";
168
	$pconfig['ipaddr'] = "";	    
169
} else if ($wancfg['ipaddr'] == "pppoe") {
170
	$pconfig['type'] = "pppoe";
171
} else if ($wancfg['ipaddr'] == "pptp") {
172
	$pconfig['type'] = "pptp";
173
} else if ($wancfg['ipaddr'] != "") {
174
	$pconfig['type'] = "static";
175
	$pconfig['ipaddr'] = $wancfg['ipaddr'];
176
	$pconfig['subnet'] = $wancfg['subnet'];
177
	$pconfig['gateway'] = $wancfg['gateway'];
178
	$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
179
} else
180
	$pconfig['type'] = "none";
181

    
182
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
183
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
184
$pconfig['spoofmac'] = $wancfg['spoofmac'];
185
$pconfig['mtu'] = $wancfg['mtu'];
186

    
187
/* Wireless interface? */
188
if (isset($wancfg['wireless'])) {
189
	require("interfaces_wlan.inc");
190
	wireless_config_init($wancfg);
191
}
192

    
193
if ($_POST) {
194

    
195
	unset($input_errors);
196
	$pconfig = $_POST;
197
  
198
	/* filter out spaces from descriptions  */
199
        $_POST['descr'] = remove_bad_chars($_POST['descr']);
200

    
201
	if ($_POST['enable'] || $if == "wan" || $if = "lan") {
202
		/* optional interface if list */
203
                $iflist = get_configured_interface_with_descr(true);
204

    
205
                /* description unique? */
206
                foreach ($iflist as $ifent => $ifdescr) {
207
                        if ($if != $ifent && $ifdescr == $_POST['descr'])
208
                                $input_errors[] = "An interface with the specified descriptio
209
n already exists.";
210
                }
211

    
212
	/* okay first of all, cause we are just hidding the PPPoE HTML
213
	 * fields releated to PPPoE resets, we are going to unset $_POST
214
	 * vars, if the reset feature should not be used. Otherwise the
215
	 * data validation procedure below, may trigger a false error
216
	 * message.
217
	 */
218
	if (empty($_POST['pppoe_preset'])) {
219
		unset($_POST['pppoe_pr_type']);
220
		unset($_POST['pppoe_resethour']);
221
		unset($_POST['pppoe_resetminute']);
222
		unset($_POST['pppoe_resetdate']);
223
		unset($_POST['pppoe_pr_preset_val']);
224
		unlink_if_exists(CRON_PPPOE_CMD_FILE);
225
	}
226

    
227
	/* input validation */
228
	if ($_POST['type'] == "static") {
229
		if ($if == "wan") {
230
			$reqdfields = explode(" ", "ipaddr subnet gateway");
231
			$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
232
		} else  {
233
			$reqdfields = explode(" ", "ipaddr subnet");
234
                        $reqdfieldsn = explode(",", "IP address,Subnet bit count");
235
		}
236
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
237
	} else if ($_POST['type'] == "PPPoE") {
238
		if ($_POST['pppoe_dialondemand']) {
239
			$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
240
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password,Dial on demand,Idle timeout value");
241
		} else {
242
			$reqdfields = explode(" ", "pppoe_username pppoe_password");
243
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password");
244
		}
245
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
246
	} else if ($_POST['type'] == "PPTP") {
247
		if ($_POST['pptp_dialondemand']) {
248
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
249
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address,Dial on demand,Idle timeout value");
250
		} else {
251
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
252
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address");
253
		}
254
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
255
	}
256

    
257
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
258
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
259

    
260
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
261
		$input_errors[] = "A valid IP address must be specified.";
262
	}
263
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
264
		$input_errors[] = "A valid subnet bit count must be specified.";
265
	}
266
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) {
267
		$input_errors[] = "A valid alias IP address must be specified.";
268
	}
269
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) {
270
		$input_errors[] = "A valid alias subnet bit count must be specified.";
271
	}
272
	if ($_POST['gateway']) {
273
		$match = false;
274
		foreach($a_gateways as $gateway) {
275
			if(in_array($_POST['gateway'], $gateway)) {
276
				$match = true;
277
			}
278
		}
279
		if(!$match)
280
			$input_errors[] = "A valid gateway must be specified.";
281
	}
282
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) {
283
		$input_errors[] = "A valid point-to-point IP address must be specified.";
284
	}
285
	if (($_POST['provider'] && !is_domain($_POST['provider']))) {
286
		$input_errors[] = "The service name contains invalid characters.";
287
	}
288
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
289
		$input_errors[] = "The idle timeout value must be an integer.";
290
	}
291
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) && 
292
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) {
293
		$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
294
	}
295
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) && 
296
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) {
297
		$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
298
	}
299
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) {
300
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
301
	}
302
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) {
303
		$input_errors[] = "A valid PPTP local IP address must be specified.";
304
	}
305
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) {
306
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
307
	}
308
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) {
309
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
310
	}
311
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) {
312
		$input_errors[] = "The idle timeout value must be an integer.";
313
	}
314
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) {
315
		$input_errors[] = "A valid MAC address must be specified.";
316
	}
317
	if ($_POST['mtu'] && ($_POST['mtu'] < 576)) {
318
		$input_errors[] = "The MTU must be greater than 576 bytes.";
319
	}
320
	}
321

    
322
	/* Wireless interface? */
323
	if (isset($wancfg['wireless'])) {
324
		$wi_input_errors = wireless_config_post($wancfg);
325
		if (!is_array($input_errors))
326
			$input_errors = array();
327
		if (is_array($wi_input_errors)) {
328
			$input_errors = array_merge($input_errors, $wi_input_errors);
329
		}
330
	}
331

    
332
	if (!$input_errors) {
333

    
334
		unset($wancfg['ipaddr']);
335
		unset($wancfg['subnet']);
336
		unset($wancfg['gateway']);
337
		unset($wancfg['pointtopoint']);
338
		unset($wancfg['dhcphostname']);
339
		unset($wancfg['pppoe_username']);
340
		unset($wancfg['pppoe_password']);
341
		unset($wancfg['pptp_username']);
342
		unset($wancfg['pptp_password']);
343
		unset($wancfg['provider']);
344
		unset($wancfg['ondemand']);
345
		unset($wancfg['timeout']);
346
		if ($wancfg['pppoe']['pppoe-reset-type'])
347
			unset($wancfg['pppoe']['pppoe-reset-type']);
348
		unset($wancfg['local']);
349
		unset($wancfg['subnet']);
350
		unset($wancfg['remote']);
351
		unset($wancfg['disableftpproxy']);
352

    
353
		/* per interface pftpx helper */
354
		if($_POST['disableftpproxy'] == "yes") {
355
			$wancfg['disableftpproxy'] = true;
356
			system_start_ftp_helpers();
357
		} else {
358
			system_start_ftp_helpers();
359
		}
360

    
361
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
362
		if ($if == "wan" || $if == "lan")
363
			$wancfg['enable'] = true;
364
		else
365
			$wancfg['enable'] =  $_POST['enable'] ? true : false;
366

    
367
		if ($_POST['type'] == "static") {
368
			$wancfg['ipaddr'] = $_POST['ipaddr'];
369
			$wancfg['subnet'] = $_POST['subnet'];
370
			$wancfg['gateway'] = $_POST['gateway'];
371
			if (isset($wancfg['ispointtopoint']))
372
				$wancfg['pointtopoint'] = $_POST['pointtopoint'];
373
		} else if ($_POST['type'] == "dhcp") {
374
			$wancfg['ipaddr'] = "dhcp";
375
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
376
			$wancfg['alias-address'] = $_POST['alias-address'];
377
			$wancfg['alias-subnet'] = $_POST['alias-subnet'];
378
		} else if ($_POST['type'] == "carpdev-dhcp") {
379
			$wancfg['ipaddr'] = "carpdev-dhcp";
380
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
381
			$wancfg['alias-address'] = $_POST['alias-address'];
382
			$wancfg['alias-subnet'] = $_POST['alias-subnet'];			
383
		} else if ($_POST['type'] == "pppoe") {
384
			$wancfg['ipaddr'] = "pppoe";
385
			$wancfg['pppoe_username'] = $_POST['pppoe_username'];
386
			$wancfg['pppoe_password'] = $_POST['pppoe_password'];
387
			$wancfg['provider'] = $_POST['provider'];
388
			$wancfg['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
389
			$wancfg['timeout'] = $_POST['pppoe_idletimeout'];
390
      
391
			/* perform a periodic reset? */
392
			if (isset($_POST['pppoe_preset'])) {
393
				if (! is_array($config['cron']['item'])) { $config['cron']['item'] = array(); }
394

    
395
					$itemhash = getMPDCRONSettings();
396
					$item = $itemhash['ITEM'];
397

    
398
					if (empty($item)) {
399
						$item = array();
400
					}
401

    
402
					if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] == "custom") {
403
						$wancfg['pppoe']['pppoe-reset-type'] = "custom";
404
						$pconfig['pppoe_pr_custom'] = true;
405

    
406
						$item['minute'] = $_POST['pppoe_resetminute'];
407
						$item['hour'] = $_POST['pppoe_resethour'];
408

    
409
						if (isset($_POST['pppoe_resetdate']) && 
410
							$_POST['pppoe_resetdate'] <> "" && 
411
							strlen($_POST['pppoe_resetdate']) == 10) {
412
							$date = explode("/", $_POST['pppoe_resetdate']);
413
							$item['mday'] = $date[1];
414
							$item['month'] = $date[0];
415
						} else {
416
							$item['mday'] = "*";
417
							$item['month'] = "*";
418
						}
419
						$item['wday'] = "*";
420
						$item['who'] = "root";
421
						$item['command'] = CRON_PPPOE_CMD_FILE;
422
					} else if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] = "preset") {
423
						$wancfg['pppoe']['pppoe-reset-type'] = "preset";
424
						$pconfig['pppoe_pr_preset'] = true;
425

    
426
						switch ($_POST['pppoe_pr_preset_val']) {
427
							case "monthly":
428
								$item['minute'] = "0";
429
								$item['hour'] = "0";
430
								$item['mday'] = "1";
431
								$item['month'] = "*";
432
								$item['wday'] = "*";
433
								$item['who'] = "root";
434
								$item['command'] = CRON_PPPOE_CMD_FILE;
435
								break;
436
					        	case "weekly":
437
								$item['minute'] = "0";
438
								$item['hour'] = "0";
439
								$item['mday'] = "*";
440
								$item['month'] = "*";
441
								$item['wday'] = "0";
442
								$item['who'] = "root";
443
								$item['command'] = CRON_PPPOE_CMD_FILE;
444
								break;
445
							case "daily":
446
								$item['minute'] = "0";
447
								$item['hour'] = "0";
448
								$item['mday'] = "*";
449
								$item['month'] = "*";
450
								$item['wday'] = "*";
451
								$item['who'] = "root";
452
								$item['command'] = CRON_PPPOE_CMD_FILE;
453
								break;
454
							case "hourly":
455
								$item['minute'] = "0";
456
								$item['hour'] = "*";
457
								$item['mday'] = "*";
458
								$item['month'] = "*";
459
								$item['wday'] = "*";
460
								$item['who'] = "root";
461
								$item['command'] = CRON_PPPOE_CMD_FILE;
462
								break;
463
						} // end switch
464
					} // end if
465
				if (isset($itemhash['ID'])) {
466
					$config['cron']['item'][$itemhash['ID']] = $item;
467
				} else {
468
					$config['cron']['item'][] = $item;
469
				}
470
			} // end if
471
		} else if ($_POST['type'] == "pptp") {
472
			$wancfg['ipaddr'] = "pptp";
473
			$wancfg['pptp_username'] = $_POST['pptp_username'];
474
			$wancfg['pptp_password'] = $_POST['pptp_password'];
475
			$wancfg['local'] = $_POST['pptp_local'];
476
			$wancfg['subnet'] = $_POST['pptp_subnet'];
477
			$wancfg['remote'] = $_POST['pptp_remote'];
478
			$wancfg['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
479
			$wancfg['timeout'] = $_POST['pptp_idletimeout'];
480
		}
481
    
482
		/* reset cron items if necessary */
483
		if (empty($_POST['pppoe_preset'])) {
484
			/* test whether a cron item exists and unset() it if necessary */
485
			$itemhash = getMPDCRONSettings();
486
			$item = $itemhash['ITEM'];
487
			if (isset($item)) { unset($config['cron']['item'][$itemhash['ID']]); }
488
		}
489

    
490
		if($_POST['blockpriv'] == "yes")
491
			$wancfg['blockpriv'] = true;
492
		else
493
			unset($wancfg['blockpriv']);
494

    
495
		if($_POST['blockbogons'] == "yes")
496
			$wancfg['blockbogons'] = true;
497
		else
498
			unset($wancfg['blockbogons']);
499

    
500
		$wancfg['spoofmac'] = $_POST['spoofmac'];
501
		$wancfg['mtu'] = $_POST['mtu'];
502

    
503
		write_config();
504
	
505
		if ($if = "lan") {
506
			/* restart snmp so that it binds to correct address */
507
                	services_snmpd_configure();
508
			$savemsg = "The changes have been applied.  You may need to correct your web browser's IP address.";
509
		}
510
    
511
		/* finally install the pppoerestart file */
512
		if (isset($_POST['pppoe_preset'])) {
513
		config_lock();
514
		conf_mount_rw();
515
      
516
		if (! file_exists(CRON_PPPOE_CMD_FILE)) {
517
			file_put_contents(CRON_PPPOE_CMD_FILE, CRON_PPPOE_CMD);
518
			chmod(CRON_PPPOE_CMD_FILE, 0700);
519
		}
520
      
521
		/* regenerate cron settings/crontab file */
522
		configure_cron();
523
		sigkillbypid("{$g['varrun_path']}/cron.pid", "HUP");
524
      
525
		conf_mount_ro();
526
		config_unlock();
527
		}
528

    
529
		$retval = 0;
530
		$savemsg = get_std_save_message($retval);
531
	}
532
}
533

    
534
// Populate page descr if it does not exist.
535
if($if == "wan" && !$wancfg['descr'])
536
	$wancfg['descr'] = "WAN";
537
else if ($if == "lan" && !$wancfg['descr'])
538
	$wancfg['descr'] = "LAN";
539
	
540
$pgtitle = array("Interfaces", $wancfg['descr']);
541
$closehead = false;
542
include("head.inc");
543

    
544
        $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" => "PPPoE", "pptp" => "PPTP" /* , "carpdev-dhcp" => "CarpDev"*/); 
545
?>
546

    
547
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
548
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
549

    
550
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
551
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css" />
552

    
553
<script type="text/javascript" src="/javascript/scriptaculous/prototype.js"></script>
554
<script type="text/javascript" src="/javascript/scriptaculous/scriptaculous.js"></script>
555

    
556
<script type="text/javascript">
557
<!--
558

    
559
function updateType(t){
560
        switch(t) {
561
<?php
562
        /* OK, so this is sick using php to generate javascript, but it needed to be done */
563
        foreach ($types as $key => $val) {
564
                echo "          case \"{$key}\": {\n";
565
                $t = $types;
566
                foreach ($t as $k => $v) {
567
                        if ($k != $key) {
568
                                echo "                  $('{$k}').hide();\n";
569
                        }
570
                }
571
                echo "          }\n";
572
        }
573
?>
574
        }
575
        $(t).appear();
576
}
577

    
578
function show_allcfg(obj) {
579
	if (obj.checked)
580
		$('allcfg').appear();
581
	else
582
		$('allcfg').hide();
583
}
584

    
585
function show_mon_config() {
586
	document.getElementById("showmonbox").innerHTML='';
587
	aodiv = document.getElementById('showmon');
588
	aodiv.style.display = "block";
589
}
590

    
591
//-->
592
</script>
593
</head>
594
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
595
<?php include("fbegin.inc"); ?>
596
<?php if ($input_errors) print_input_errors($input_errors); ?>
597

    
598
<?php if ($savemsg) print_info_box($savemsg); ?>
599
            <form action="interfaces_wan.php?if=<?php echo "{$if}";?>" method="post" name="iform" id="iform">
600
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
601
                <tr>
602
                  <td colspan="2" valign="top" class="listtopic">General configuration</td>
603
                </tr>
604
<?php if ($if != "wan" || $if != "lan"): ?>
605
                <tr>
606
                  <td width="22%" valign="top" class="vtable">&nbsp;</td>
607
                  <td width="78%" class="vtable">
608
                        <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="show_allcfg(this);">
609
                    <strong>Enable Interface</strong></td>
610
                </tr>
611
<?php endif; ?>
612
		<tr style="display:none;" name="allcfg" id="allcfg">
613
		<td colspan="2"> 
614
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
615
                <tr>
616
                  <td width="22%" valign="top" class="vncell">Description</td>
617
                  <td width="78%" class="vtable">
618
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
619
                                        <br> <span class="vexpl">Enter a description (name) for the interface here.</span>
620
                  </td>
621
                </tr>
622
                <tr>
623
                  <td valign="middle" class="vncell"><strong>Type</strong></td>
624
                  <td class="vtable"> <select name="type" onChange="updateType(this.value);" class="formselect" id="type">
625
                      <?php 
626
			foreach ($types as $key => $opt) { 
627
	                      echo "<option onClick=\"updateType('{$key}');\"";
628
			      if ($key == $pconfig['type']) 
629
				echo " selected";
630
			      echo " value=\"{$key}\" >" . htmlspecialchars($opt);
631
	                      echo "</option>";
632
                      } ?>
633
                    </select></td>
634
                </tr>
635
                <tr>
636
                  <td valign="top" class="vncell">MAC address</td>
637
                  <td class="vtable"> <input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
638
		    <?php
639
			$ip = getenv('REMOTE_ADDR');
640
			$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
641
			$mac = str_replace("\n","",$mac);
642
		    ?>
643
		    <a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#">Copy my MAC address</a>
644
		    <br>
645
                    This field can be used to modify (&quot;spoof&quot;) the MAC
646
                    address of the WAN interface<br>
647
                    (may be required with some cable connections)<br>
648
                    Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx
649
                    or leave blank</td>
650
                </tr>
651
                <tr>
652
                  <td valign="top" class="vncell">MTU</td>
653
                  <td class="vtable"> <input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
654
                    <br>
655
                    If you enter a value in this field, then MSS clamping for
656
                    TCP connections to the value entered above minus 40 (TCP/IP
657
                    header size) will be in effect. If you leave this field blank,
658
                    an MTU of 1492 bytes for PPPoE and 1500 bytes for all other
659
                    connection types will be assumed.</td>
660
                </tr>
661
		<tr style="display:none;" name="none" id="none">
662
		</tr>
663
		<tr style="display:none;" name="static" id="static">
664
		<td colspan="2">
665
        <table width="100%" border="0" cellpadding="6" cellspacing="0">
666
		<tr>
667
                  <td colspan="2" valign="top" class="listtopic">Static IP configuration</td>
668
                </tr>
669
                <tr>
670
                  <td width="22%" valign="top" class="vncellreq">IP address</td>
671
                  <td width="78%" class="vtable"> <input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
672
                    /
673
                    <select name="subnet" class="formselect" id="subnet">
674
			<?php
675
			for ($i = 32; $i > 0; $i--) {
676
				if($i <> 31) {
677
					echo "<option value=\"{$i}\" ";
678
					if ($i == $pconfig['subnet']) echo "selected";
679
					echo ">" . $i . "</option>";
680
				}
681
			}
682
			?>
683
                    </select></td>
684
                </tr><?php if (isset($wancfg['ispointtopoint'])): ?>
685
                <tr>
686
                  <td width="22%" valign="top" class="vncellreq">Point-to-point IP address </td>
687
                  <td width"78%" class="vtable">
688
                    <input name="pointtopoint" type="text" class="formfld unknown" id="pointtopoint" size="20" value="<?=htmlspecialchars($pconfig['pointtopoint']);?>">
689
                  </td>
690
                </tr><?php endif; ?>
691
                <tr>
692
                  <td width="22%" valign="top" class="vncellreq">Gateway</td>
693
                  <td width="78%" class="vtable"><select name="gateway" class="formselect" id="gateway">
694
			<?php
695
			if(count($a_gateways) > 0) {
696
				foreach ($a_gateways as $gateway) {
697
					if($gateway['interface'] == $if) {
698
			?>
699
					<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
700
					<?=htmlspecialchars($gateway['name']);?>
701
					</option>
702
			<?php
703
					}
704
				}
705
			}
706
			?>
707
			</select>Select a existing Gateway from the list or add one on the <a href="/system_gateways.php">Gateways</a> page<br>
708
                  </td>
709
                </tr>
710
	</table>
711
	</td>
712
	</tr>
713
		<tr style="display:none;" name="dhcp" id="dhcp">
714
		<td colspan="2">
715
        <table width="100%" border="0" cellpadding="6" cellspacing="0">
716
                <tr>
717
                  <td colspan="2" valign="top" class="listtopic">DHCP client configuration</td>
718
                </tr>
719
                <tr>
720
                  <td width="22%" valign="top" class="vncell">Hostname</td>
721
                  <td width="78%" class="vtable"> <input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
722
                    <br>
723
                    The value in this field is sent as the DHCP client identifier
724
                    and hostname when requesting a DHCP lease. Some ISPs may require
725
                    this (for client identification).</td>
726
                </tr>
727
                <tr>
728
                  <td width="22%" valign="top" class="vncellreq">Alias IP address</td>
729
                  <td width="78%" class="vtable"> <input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
730
                    <select name="alias-subnet" class="formselect" id="alias-subnet">
731
			<?php
732
			for ($i = 32; $i > 0; $i--) {
733
				if($i <> 31) {
734
					echo "<option value=\"{$i}\" ";
735
					if ($i == $pconfig['alias-subnet']) echo "selected";
736
					echo ">" . $i . "</option>";
737
				}
738
			}
739
			?>
740
                    </select>
741
                    The value in this field is used as a fixed alias IP address by the
742
		    DHCP client.</td>
743
                </tr>
744
	</table>
745
	</td>
746
	</tr>
747
                <tr style="display:none;" name="pppoe" id="pppoe">
748
		<td colspan="2">
749
	<table width="100%" border="0" cellpadding="6" cellspacing="0">
750
                <tr>
751
                  <td colspan="2" valign="top" class="listtopic">PPPoE configuration</td>
752
                </tr>
753
		<tr>
754
                  <td width="22%" valign="top" class="vncellreq">Username</td>
755
                  <td width="78%" class="vtable"><input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
756
                  </td>
757
                </tr>
758
                <tr>
759
                  <td width="22%" valign="top" class="vncellreq">Password</td>
760
                  <td width="78%" class="vtable"><input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
761
                  </td>
762
                </tr>
763
                <tr>
764
                  <td width="22%" valign="top" class="vncell">Service name</td>
765
                  <td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
766
                    <br> <span class="vexpl">Hint: this field can usually be left
767
                    empty</span></td>
768
                </tr>
769
                <tr>
770
                  <td width="22%" valign="top" class="vncell">Dial on demand</td>
771
                  <td width="78%" class="vtable"><input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>" >
772
                    <strong>Enable Dial-On-Demand mode</strong><br>
773
		    This option causes the interface to operate in dial-on-demand mode, allowing you to have a <i>virtual full time</i> connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected.</td>
774
                </tr>
775
                <tr>
776
                  <td width="22%" valign="top" class="vncell">Idle timeout</td>
777
                  <td width="78%" class="vtable">
778
                    <input name="pppoe_idletimeout" type="text" class="formfld unknown" id="pppoe_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pppoe_idletimeout']);?>"> 
779
seconds<br>If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. An idle timeout of zero disables this feature.</td>
780
                </tr>
781
                <tr>
782
                  <td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
783
                  <td width="78%" class="vtable">
784
                    <input name="pppoe_preset" type="checkbox" id="pppoe_preset" value="yes" <?php if ($pconfig['pppoe_preset']) echo "checked=\"checked\""; ?> onclick="Effect.toggle('presetwrap', 'appear', { duration: 1.0 });" />
785
                    <?= gettext("enable periodic PPPoE resets"); ?>
786
                    <br />
787
                    <?php if ($pconfig['pppoe_preset']): ?>
788
                    <table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
789
                    <?php else: ?>
790
                    <table id="presetwrap" cellspacing="0" cellpadding="0" width="100%" style="display: none;">
791
                    <?php endif; ?>
792
                      <tr>
793
                        <td align="left" valign="top">
794
                          <p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
795
                            <input name="pppoe_pr_type" type="radio" id="pppoe_pr_custom" value="custom" <?php if ($pconfig['pppoe_pr_custom']) echo "checked=\"checked\""; ?> onclick="if (this.checked) { Effect.Appear('pppoecustomwrap', { duration: 1.0 }); Effect.Fade('pppoepresetwrap', { duration: 1.0 }); }" /> 
796
                            <?= gettext("provide a custom reset time"); ?>
797
                            <br />
798
                            <input name="pppoe_pr_type" type="radio" id="pppoe_pr_preset" value="preset" <?php if ($pconfig['pppoe_pr_preset']) echo "checked=\"checked\""; ?> onclick="if (this.checked) { Effect.Appear('pppoepresetwrap', { duration: 1.0 }); Effect.Fade('pppoecustomwrap', { duration: 1.0 }); }" /> 
799
                            <?= gettext("select reset time from a preset"); ?>
800
                          </p>
801
                          <?php if ($pconfig['pppoe_pr_custom']): ?>
802
                          <p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
803
                          <?php else: ?>
804
                          <p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
805
                          <?php endif; ?>
806
                            <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" /> 
807
                            <?= gettext("hour (0-23)"); ?><br />
808
                            <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" /> 
809
                            <?= gettext("minute (0-59)"); ?><br />
810
                            <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']);?>" /> 
811
                            <?= gettext("reset at a specific date (mm/dd/yyyy)"); ?>
812
                            <br />&nbsp;<br />
813
                            <span class="red"><strong>Note: </strong></span>
814
                            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.
815
                          </p>
816
                          <?php if ($pconfig['pppoe_pr_preset']): ?>
817
                          <p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
818
                          <?php else: ?>
819
                          <p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
820
                          <?php endif; ?>
821
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> /> 
822
                            <?= gettext("reset at each month ('0 0 1 * *')"); ?>
823
                            <br />
824
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> /> 
825
                            <?= gettext("reset at each week ('0 0 * * 0')"); ?>
826
                            <br />
827
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> /> 
828
                            <?= gettext("reset at each day ('0 0 * * *')"); ?>
829
                            <br />
830
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> /> 
831
                            <?= gettext("reset at each hour ('0 * * * *')"); ?>
832
                          </p>
833
                        </td>
834
                      </tr>
835
                    </table>
836
                  </td>
837
                </tr>                
838
	</table>
839
		</td>
840
		</tr>
841
		<tr style="display:none;" name="pptp" id="pptp">
842
		<td colspan="2">
843
        <table width="100%" border="0" cellpadding="6" cellspacing="0">
844
                <tr>
845
                  <td colspan="2" valign="top" class="listtopic">PPTP configuration</td>
846
                </tr>
847
                <tr>
848
                  <td width="22%" valign="top" class="vncellreq">Username</td>
849
                  <td width="78%" class="vtable"><input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
850
                  </td>
851
                </tr>
852
                <tr>
853
                  <td width="22%" valign="top" class="vncellreq">Password</td>
854
                  <td width="78%" class="vtable"><input name="pptp_password" type="text" class="formfld pwd" id="pptp_password" size="20" 
855
value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
856
                  </td>
857
                </tr>
858
                <tr>
859
                  <td width="22%" width="100" valign="top" class="vncellreq">Local IP address</td>
860
                  <td width="78%" class="vtable"> <input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20" 
861
value="<?=htmlspecialchars($pconfig['pptp_local']);?>">
862
                    /
863
                    <select name="pptp_subnet" class="formselect" id="pptp_subnet">
864
                      <?php for ($i = 31; $i > 0; $i--): ?>
865
                      <option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet']) echo "selected"; ?>>
866
                      <?=$i;?>
867
                      </option>
868
                      <?php endfor; ?>
869
                    </select></td>
870
                </tr>
871
                <tr>
872
                  <td width="22%" width="100" valign="top" class="vncellreq">Remote IP address</td>
873
                  <td width="78%" class="vtable"> <input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote']);?>">
874
                  </td>
875
                </tr>
876
                <tr>
877
                  <td width="22%" valign="top" class="vncell">Dial on demand</td>
878
                  <td width="78%" class="vtable"><input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?>" >
879
                    <strong>Enable Dial-On-Demand mode</strong><br>
880
		    This option causes the interface to operate in dial-on-demand mode, allowing you to have a <i>virtual full time</i> connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected.</td>
881
                </tr>
882
                <tr>
883
                  <td width="22%" valign="top" class="vncell">Idle timeout</td>
884
                  <td width="78%" class="vtable">
885
                    <input name="pptp_idletimeout" type="text" class="formfld unknown" id="pptp_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pptp_idletimeout']);?>"> 
886
seconds<br>If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. An idle timeout of zero disables this feature.</td>
887
                </tr>
888
	</table>
889
	</td>
890
	</tr>
891
	<tr>
892
                  <td width="100" valign="top"></td>
893
                  <td> <input name="Submit" type="submit" class="formbtn" value="Save"></td>
894
	</tr>
895
		<tr>
896
			<td colspan="2" valign="top" height="10"></td>
897
		</tr>
898
                <tr>
899
                  <td colspan="2" valign="top" class="listtopic">Other</td>
900
                </tr>
901
		<tr>
902
			<td width="22%" valign="top" class="vncell">FTP Helper</td>
903
			<td width="78%" class="vtable">
904
				<input name="disableftpproxy" type="checkbox" id="disableftpproxy" value="yes" <?php if ($pconfig['disableftpproxy']) echo "checked"; ?> />
905
				<strong>Disable the userland FTP-Proxy application</strong>
906
				<br />
907
			</td>
908
		</tr>
909
		        <?php
910
				/* Wireless interface? */
911
				if (isset($wancfg['wireless']))
912
					wireless_config_print($wancfg);
913
			?>
914
                <tr>
915
                  <td height="16" colspan="2" valign="top"></td>
916
                </tr>
917
                <tr>
918
                  <td valign="middle">&nbsp;</td>
919
                  <td class="vtable"><a name="rfc1918"></a> <input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
920
                    <strong>Block private networks</strong><br>
921
                    When set, this option blocks traffic from IP addresses that
922
                    are reserved for private<br>
923
                    networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as
924
                    well as loopback addresses<br>
925
                    (127/8). You should generally leave this option turned on,
926
                    unless your WAN network<br>
927
                    lies in such a private address space, too.</td>
928
                </tr>
929
                <tr>
930
                  <td valign="middle">&nbsp;</td>
931
                  <td class="vtable"> <input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
932
                    <strong>Block bogon networks</strong><br>
933
                    When set, this option blocks traffic from IP addresses that
934
                    are reserved (but not RFC 1918) or not yet assigned by IANA.<br>
935
                    Bogons are prefixes that should never appear in the Internet routing table, and obviously should not appear as the source address in any packets you receive.</td>
936
		</tr>
937
        </table>
938
        </td>
939
        </tr>
940
                <tr>
941
                  <td width="100" valign="top">&nbsp;</td>
942
                  <td> &nbsp;<br> <input name="Submit" type="submit" class="formbtn" value="Save">
943
			<input name="if" type="hidden" id="if" value="<?=$if;?>">
944
                  </td>
945
                </tr>
946
              </table>
947
</form>
948
<script language="JavaScript">
949
<!--
950
<?php
951
if ($if == "wan" || $if = "lan")
952
	echo "\$('allcfg').appear();";
953
else
954
	echo "show_allcfg(document.iform.enable);";
955
echo "updateType('{$pconfig['type']}')";
956
?>
957
//-->
958
</script>
959
<?php include("fend.inc"); ?>
960
</body>
961
</html>
962

    
963

    
964
<?php
965

    
966
if ($_POST) {
967

    
968
	if (!$input_errors) {
969

    
970
		unlink_if_exists("{$g['tmp_path']}/config.cache");
971

    
972
		ob_flush();
973
		flush();
974
		sleep(1);
975

    
976
		interfaces_wan_configure($if);
977

    
978
		reset_carp();
979

    
980
		/* sync filter configuration */
981
		filter_configure();
982

    
983
 		/* set up static routes */
984
		system_routing_configure();
985

    
986
	}
987
}
988

    
989
?>
(88-88/211)