Project

General

Profile

Download (41.5 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
$pconfig['enable'] = $if == "wan" ? true : isset($wancfg['enable']);
154

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

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

    
179
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
180
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
181
$pconfig['spoofmac'] = $wancfg['spoofmac'];
182
$pconfig['mtu'] = $wancfg['mtu'];
183

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

    
190
if ($_POST) {
191

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

    
198
	if ($_POST['enable'] || $if == "wan") {
199
		/* optional interface if list */
200
                $iflist = get_configured_interface_with_descr(true);
201

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

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

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

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

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

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

    
329
	if (!$input_errors) {
330

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

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

    
358
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
359
		$wancfg['enable'] = $if == "wan" ? true : $_POST['enable'] ? true : false;
360

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

    
389
					$itemhash = getMPDCRONSettings();
390
					$item = $itemhash['ITEM'];
391

    
392
					if (empty($item)) {
393
						$item = array();
394
					}
395

    
396
					if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] == "custom") {
397
						$wancfg['pppoe']['pppoe-reset-type'] = "custom";
398
						$pconfig['pppoe_pr_custom'] = true;
399

    
400
						$item['minute'] = $_POST['pppoe_resetminute'];
401
						$item['hour'] = $_POST['pppoe_resethour'];
402

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

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

    
484
		if($_POST['blockpriv'] == "yes")
485
			$wancfg['blockpriv'] = true;
486
		else
487
			unset($wancfg['blockpriv']);
488

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

    
494
		$wancfg['spoofmac'] = $_POST['spoofmac'];
495
		$wancfg['mtu'] = $_POST['mtu'];
496

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

    
523
		$retval = 0;
524
		$savemsg = get_std_save_message($retval);
525
	}
526
}
527

    
528
// Populate page descr if it does not exist.
529
if($if == "wan" && !$wancfg['descr'])
530
	$wancfg['descr'] = "WAN";
531
	
532
$pgtitle = array("Interfaces", $wancfg['descr']);
533
$closehead = false;
534
include("head.inc");
535

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

    
539
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
540
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
541

    
542
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
543
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css" />
544

    
545
<script type="text/javascript" src="/javascript/scriptaculous/prototype.js"></script>
546
<script type="text/javascript" src="/javascript/scriptaculous/scriptaculous.js"></script>
547

    
548
<script type="text/javascript">
549
<!--
550

    
551
function updateType(t){
552
        switch(t) {
553
<?php
554
        /* OK, so this is sick using php to generate javascript, but it needed to be done */
555
        foreach ($types as $key => $val) {
556
                echo "          case \"{$key}\": {\n";
557
                $t = $types;
558
                foreach ($t as $k => $v) {
559
                        if ($k != $key) {
560
                                echo "                  $('{$k}').hide();\n";
561
                        }
562
                }
563
                echo "          }\n";
564
        }
565
?>
566
        }
567
        $(t).appear();
568
}
569

    
570
function show_allcfg(obj) {
571
	if (obj.checked)
572
		$('allcfg').appear();
573
	else
574
		$('allcfg').hide();
575
}
576

    
577
function show_mon_config() {
578
	document.getElementById("showmonbox").innerHTML='';
579
	aodiv = document.getElementById('showmon');
580
	aodiv.style.display = "block";
581
}
582

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

    
954

    
955
<?php
956

    
957
if ($_POST) {
958

    
959
	if (!$input_errors) {
960

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

    
963
		ob_flush();
964
		flush();
965
		sleep(1);
966

    
967
		interfaces_wan_configure($if);
968

    
969
		reset_carp();
970

    
971
		/* sync filter configuration */
972
		filter_configure();
973

    
974
 		/* set up static routes */
975
		system_routing_configure();
976

    
977
	}
978
}
979

    
980
?>
(73-73/211)