Project

General

Profile

Download (44.2 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
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
35
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
36
define("CRON_DAILY_PATTERN", "0 0 * * *");
37
define("CRON_HOURLY_PATTERN", "0 * * * *");
38
define("CRON_PPPOE_CMD_FILE", "/etc/pppoerestart");
39
define("CRON_PPPOE_CMD", "#!/bin/sh\necho '<?php require(\"interfaces.inc\"); interfaces_wan_pppoe_restart(); services_dyndns_reset(); ?>' | /usr/local/bin/php -q");
40

    
41
function getMPDCRONSettings() {
42
  global $config;
43

    
44
  if (is_array($config['cron']['item'])) {
45
    for ($i = 0; $i < count($config['cron']['item']); $i++) {
46
      $item =& $config['cron']['item'][$i];
47

    
48
      if (strpos($item['command'], CRON_PPPOE_CMD_FILE) !== false) {
49
        return array("ID" => $i, "ITEM" => $item);
50
      }
51
    }
52
  }
53

    
54
  return NULL;
55
}
56

    
57
function getMPDResetTimeFromConfig() {
58
  $itemhash = getMPDCRONSettings();
59
  $cronitem = $itemhash['ITEM'];
60

    
61
  if (isset($cronitem)) {
62

    
63
    return "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
64
  } else {
65
    return NULL;
66
  }
67
}
68

    
69
require("guiconfig.inc");
70

    
71
if (!is_array($config['gateways']['gateway_item']))
72
	$config['gateways']['gateway_item'] = array();
73
$a_gateways = &$config['gateways']['gateway_item'];
74

    
75
$wancfg = &$config['interfaces']['wan'];
76
$optcfg = &$config['interfaces']['wan'];
77

    
78
$pconfig['username'] = $config['pppoe']['username'];
79
$pconfig['password'] = $config['pppoe']['password'];
80
$pconfig['provider'] = $config['pppoe']['provider'];
81
$pconfig['pppoe_dialondemand'] = isset($config['pppoe']['ondemand']);
82
$pconfig['pppoe_idletimeout'] = $config['pppoe']['timeout'];
83

    
84
/* ================================================ */
85
/* = force a connection reset at a specific time? = */
86
/* ================================================ */
87

    
88
if (isset($wancfg['pppoe']['pppoe-reset-type'])) {
89
  $resetTime = getMPDResetTimeFromConfig();  
90
  $pconfig['pppoe_preset'] = true;
91
  
92
  if ($wancfg['pppoe']['pppoe-reset-type'] == "custom") {
93
    $resetTime_a = split(" ", $resetTime);
94
    $pconfig['pppoe_pr_custom'] = true;
95
    $pconfig['pppoe_resetminute'] = $resetTime_a[0];
96
    $pconfig['pppoe_resethour'] = $resetTime_a[1];
97

    
98
    /* just initialize $pconfig['pppoe_resetdate'] if the
99
     * coresponding item contains appropriate numeric values.
100
     */
101
    if ($resetTime_a[2] <> "*" && $resetTime_a[3] <> "*") {
102
      $pconfig['pppoe_resetdate'] = "{$resetTime_a[3]}/{$resetTime_a[2]}/" . date("Y");
103
    }
104
  } else if ($wancfg['pppoe']['pppoe-reset-type'] == "preset") {
105
    $pconfig['pppoe_pr_preset'] = true;
106
    
107
    switch ($resetTime) {
108
      case CRON_MONTHLY_PATTERN:
109
        $pconfig['pppoe_monthly'] = true;
110
        break;
111
      case CRON_WEEKLY_PATTERN:
112
        $pconfig['pppoe_weekly'] = true;
113
        break;
114
      case CRON_DAILY_PATTERN:
115
        $pconfig['pppoe_daily'] = true;
116
        break;
117
      case CRON_HOURLY_PATTERN:
118
        $pconfig['pppoe_hourly'] = true;
119
        break;
120
    }
121
  }
122
}
123

    
124
$pconfig['pptp_username'] = $config['pptp']['username'];
125
$pconfig['pptp_password'] = $config['pptp']['password'];
126
$pconfig['pptp_local'] = $config['pptp']['local'];
127
$pconfig['pptp_subnet'] = $config['pptp']['subnet'];
128
$pconfig['pptp_remote'] = $config['pptp']['remote'];
129
$pconfig['pptp_dialondemand'] = isset($config['pptp']['ondemand']);
130
$pconfig['pptp_idletimeout'] = $config['pptp']['timeout'];
131

    
132
$pconfig['disableftpproxy'] = isset($wancfg['disableftpproxy']);
133

    
134
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
135
$pconfig['alias-address'] = $wancfg['alias-address'];
136
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
137

    
138
if ($wancfg['ipaddr'] == "dhcp") {
139
	$pconfig['type'] = "DHCP";
140
} else if ($wancfg['ipaddr'] == "carpdev-dhcp") {
141
	$pconfig['type'] = "CarpDEV-DHCP";
142
	$pconfig['ipaddr'] = "";	    
143
} else if ($wancfg['ipaddr'] == "pppoe") {
144
	$pconfig['type'] = "PPPoE";
145
} else if ($wancfg['ipaddr'] == "pptp") {
146
	$pconfig['type'] = "PPTP";
147
} else {
148
	$pconfig['type'] = "Static";
149
	$pconfig['ipaddr'] = $wancfg['ipaddr'];
150
	$pconfig['subnet'] = $wancfg['subnet'];
151
	$pconfig['gateway'] = $config['interfaces']['wan']['gateway'];
152
	$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
153
}
154

    
155
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
156
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
157
$pconfig['spoofmac'] = $wancfg['spoofmac'];
158
$pconfig['mtu'] = $wancfg['mtu'];
159

    
160
/* Wireless interface? */
161
if (isset($wancfg['wireless'])) {
162
	require("interfaces_wlan.inc");
163
	wireless_config_init();
164
}
165

    
166
if ($_POST) {
167

    
168
	unset($input_errors);
169
	$pconfig = $_POST;
170
  
171
	/* okay first of all, cause we are just hidding the PPPoE HTML
172
	 * fields releated to PPPoE resets, we are going to unset $_POST
173
	 * vars, if the reset feature should not be used. Otherwise the
174
	 * data validation procedure below, may trigger a false error
175
	 * message.
176
	 */
177
	if (empty($_POST['pppoe_preset'])) {
178
		unset($_POST['pppoe_pr_type']);
179
		unset($_POST['pppoe_resethour']);
180
		unset($_POST['pppoe_resetminute']);
181
		unset($_POST['pppoe_resetdate']);
182
		unset($_POST['pppoe_pr_preset_val']);
183
		unlink_if_exists(CRON_PPPOE_CMD_FILE);
184
	}
185

    
186
	if($_POST['gateway'] and $pconfig['gateway'] <> $_POST['gateway']) {
187
		/* enumerate slbd gateways and make sure we are not creating a route loop */
188
		if(is_array($config['load_balancer']['lbpool'])) {
189
			foreach($config['load_balancer']['lbpool'] as $lbpool) {
190
				if($lbpool['type'] == "gateway") {
191
				    foreach ((array) $lbpool['servers'] as $server) {
192
			            $svr = split("\|", $server);
193
			            if($svr[1] == $pconfig['gateway'])  {
194
			            		$_POST['gateway']  = $pconfig['gateway'];
195
			            		$input_errors[] = "Cannot change {$svr[1]} gateway.  It is currently referenced by the load balancer pools.";
196
			            }
197
					}
198
				}
199
			}
200
			foreach($config['filter']['rule'] as $rule) {
201
				if($rule['gateway'] == $pconfig['gateway']) {
202
	            		$_POST['gateway']  = $pconfig['gateway'];
203
	            		$input_errors[] = "Cannot change {$svr[1]} gateway.  It is currently referenced by the filter rules via policy based routing.";
204
				}
205
			}
206
		}
207
	}
208

    
209
	/* input validation */
210
	if ($_POST['type'] == "Static") {
211
		$reqdfields = explode(" ", "ipaddr subnet gateway");
212
		$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
213
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
214
	} else if ($_POST['type'] == "PPPoE") {
215
		if ($_POST['pppoe_dialondemand']) {
216
			$reqdfields = explode(" ", "username password pppoe_dialondemand pppoe_idletimeout");
217
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password,Dial on demand,Idle timeout value");
218
		} else {
219
			$reqdfields = explode(" ", "username password");
220
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password");
221
		}
222
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
223
	} else if ($_POST['type'] == "PPTP") {
224
		if ($_POST['pptp_dialondemand']) {
225
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
226
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address,Dial on demand,Idle timeout value");
227
		} else {
228
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
229
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address");
230
		}
231
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
232
	}
233

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

    
237
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
238
		$input_errors[] = "A valid IP address must be specified.";
239
	}
240
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
241
		$input_errors[] = "A valid subnet bit count must be specified.";
242
	}
243
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) {
244
		$input_errors[] = "A valid alias IP address must be specified.";
245
	}
246
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) {
247
		$input_errors[] = "A valid alias subnet bit count must be specified.";
248
	}
249
	if ($_POST['gateway']) {
250
		$match = false;
251
		foreach($a_gateways as $gateway) {
252
			if(in_array($_POST['gateway'], $gateway)) {
253
				$match = true;
254
			}
255
		}
256
		if(!$match)
257
			$input_errors[] = "A valid gateway must be specified.";
258
	}
259
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) {
260
		$input_errors[] = "A valid point-to-point IP address must be specified.";
261
	}
262
	if (($_POST['provider'] && !is_domain($_POST['provider']))) {
263
		$input_errors[] = "The service name contains invalid characters.";
264
	}
265
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
266
		$input_errors[] = "The idle timeout value must be an integer.";
267
	}
268
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) && 
269
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) {
270
		$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
271
	}
272
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) && 
273
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) {
274
		$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
275
	}
276
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) {
277
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
278
	}
279
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) {
280
		$input_errors[] = "A valid PPTP local IP address must be specified.";
281
	}
282
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) {
283
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
284
	}
285
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) {
286
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
287
	}
288
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) {
289
		$input_errors[] = "The idle timeout value must be an integer.";
290
	}
291
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) {
292
		$input_errors[] = "A valid MAC address must be specified.";
293
	}
294
	if ($_POST['mtu'] && (($_POST['mtu'] < 576) || ($_POST['mtu'] > 1500))) {
295
		$input_errors[] = "The MTU must be between 576 and 1500 bytes.";
296
	}
297

    
298
	/* Wireless interface? */
299
	if (isset($wancfg['wireless'])) {
300
		$wi_input_errors = wireless_config_post();
301
		if ($wi_input_errors) {
302
			$input_errors = array_merge($input_errors, $wi_input_errors);
303
		}
304
	}
305

    
306
	if (!$input_errors) {
307

    
308
		$bridge = discover_bridge($wancfg['if'], filter_translate_type_to_real_interface($wancfg['bridge']));
309
		if($bridge <> "-1") {
310
			destroy_bridge($bridge);
311
		}
312

    
313
		unset($wancfg['ipaddr']);
314
		unset($wancfg['subnet']);
315
		unset($config['interfaces']['wan']['gateway']);
316
		unset($wancfg['pointtopoint']);
317
		unset($wancfg['dhcphostname']);
318
		if (is_array($wancfg['pppoe'])) {
319
			unset($config['pppoe']['username']);
320
			unset($config['pppoe']['password']);
321
			unset($config['pppoe']['provider']);
322
			unset($config['pppoe']['ondemand']);
323
			unset($config['pppoe']['timeout']);
324
			unset($wancfg['pppoe']['pppoe-reset-type']);
325
		}
326
		if (is_array($wancfg['pptp'])) {
327
			unset($config['pptp']['username']);
328
			unset($config['pptp']['password']);
329
			unset($config['pptp']['local']);
330
			unset($config['pptp']['subnet']);
331
			unset($config['pptp']['remote']);
332
			unset($config['pptp']['ondemand']);
333
			unset($config['pptp']['timeout']);
334
		}
335
		unset($wancfg['disableftpproxy']);
336

    
337
		/* per interface pftpx helper */
338
		if($_POST['disableftpproxy'] == "yes") {
339
			$wancfg['disableftpproxy'] = true;
340
			system_start_ftp_helpers();
341
		} else {
342
			system_start_ftp_helpers();
343
		}
344

    
345
		if ($_POST['type'] == "Static") {
346
			$wancfg['ipaddr'] = $_POST['ipaddr'];
347
			$wancfg['subnet'] = $_POST['subnet'];
348
			$config['interfaces']['wan']['gateway'] = $_POST['gateway'];
349
			if (isset($wancfg['ispointtopoint']))
350
				$wancfg['pointtopoint'] = $_POST['pointtopoint'];
351
		} else if ($_POST['type'] == "DHCP") {
352
			$wancfg['ipaddr'] = "dhcp";
353
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
354
			$wancfg['alias-address'] = $_POST['alias-address'];
355
			$wancfg['alias-subnet'] = $_POST['alias-subnet'];
356
		} else if ($_POST['type'] == "CarpDEV-DHCP") {
357
			$wancfg['ipaddr'] = "carpdev-dhcp";
358
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
359
			$wancfg['alias-address'] = $_POST['alias-address'];
360
			$wancfg['alias-subnet'] = $_POST['alias-subnet'];			
361
		} else if ($_POST['type'] == "PPPoE") {
362
			$wancfg['ipaddr'] = "pppoe";
363
			$config['pppoe']['username'] = $_POST['username'];
364
			$config['pppoe']['password'] = $_POST['password'];
365
			$config['pppoe']['provider'] = $_POST['provider'];
366
			$config['pppoe']['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
367
			$config['pppoe']['timeout'] = $_POST['pppoe_idletimeout'];
368
      
369
			/* perform a periodic reset? */
370
			if (isset($_POST['pppoe_preset'])) {
371
				if (! is_array($config['cron']['item'])) { $config['cron']['item'] = array(); }
372

    
373
					$itemhash = getMPDCRONSettings();
374
					$item = $itemhash['ITEM'];
375

    
376
					if (empty($item)) {
377
						$item = array();
378
					}
379

    
380
					if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] == "custom") {
381
						$wancfg['pppoe']['pppoe-reset-type'] = "custom";
382
						$pconfig['pppoe_pr_custom'] = true;
383

    
384
						$item['minute'] = $_POST['pppoe_resetminute'];
385
						$item['hour'] = $_POST['pppoe_resethour'];
386

    
387
						if (isset($_POST['pppoe_resetdate']) && 
388
							$_POST['pppoe_resetdate'] <> "" && 
389
							strlen($_POST['pppoe_resetdate']) == 10) {
390
							$date = explode("/", $_POST['pppoe_resetdate']);
391
							$item['mday'] = $date[1];
392
							$item['month'] = $date[0];
393
						} else {
394
							$item['mday'] = "*";
395
							$item['month'] = "*";
396
						}
397
						$item['wday'] = "*";
398
						$item['who'] = "root";
399
						$item['command'] = CRON_PPPOE_CMD_FILE;
400
					} else if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] = "preset") {
401
						$wancfg['pppoe']['pppoe-reset-type'] = "preset";
402
						$pconfig['pppoe_pr_preset'] = true;
403

    
404
						switch ($_POST['pppoe_pr_preset_val']) {
405
							case "monthly":
406
								$item['minute'] = "0";
407
								$item['hour'] = "0";
408
								$item['mday'] = "1";
409
								$item['month'] = "*";
410
								$item['wday'] = "*";
411
								$item['who'] = "root";
412
								$item['command'] = CRON_PPPOE_CMD_FILE;
413
								break;
414
					        	case "weekly":
415
								$item['minute'] = "0";
416
								$item['hour'] = "0";
417
								$item['mday'] = "*";
418
								$item['month'] = "*";
419
								$item['wday'] = "0";
420
								$item['who'] = "root";
421
								$item['command'] = CRON_PPPOE_CMD_FILE;
422
								break;
423
							case "daily":
424
								$item['minute'] = "0";
425
								$item['hour'] = "0";
426
								$item['mday'] = "*";
427
								$item['month'] = "*";
428
								$item['wday'] = "*";
429
								$item['who'] = "root";
430
								$item['command'] = CRON_PPPOE_CMD_FILE;
431
								break;
432
							case "hourly":
433
								$item['minute'] = "0";
434
								$item['hour'] = "*";
435
								$item['mday'] = "*";
436
								$item['month'] = "*";
437
								$item['wday'] = "*";
438
								$item['who'] = "root";
439
								$item['command'] = CRON_PPPOE_CMD_FILE;
440
								break;
441
						} // end switch
442
					} // end if
443
				if (isset($itemhash['ID'])) {
444
					$config['cron']['item'][$itemhash['ID']] = $item;
445
				} else {
446
					$config['cron']['item'][] = $item;
447
				}
448
			} // end if
449
		} else if ($_POST['type'] == "PPTP") {
450
			$wancfg['ipaddr'] = "pptp";
451
			$config['pptp']['username'] = $_POST['pptp_username'];
452
			$config['pptp']['password'] = $_POST['pptp_password'];
453
			$config['pptp']['local'] = $_POST['pptp_local'];
454
			$config['pptp']['subnet'] = $_POST['pptp_subnet'];
455
			$config['pptp']['remote'] = $_POST['pptp_remote'];
456
			$config['pptp']['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
457
			$config['pptp']['timeout'] = $_POST['pptp_idletimeout'];
458
		}
459
    
460
		/* reset cron items if necessary */
461
		if (empty($_POST['pppoe_preset'])) {
462
			/* test whether a cron item exists and unset() it if necessary */
463
			$itemhash = getMPDCRONSettings();
464
			$item = $itemhash['ITEM'];
465
			if (isset($item)) { unset($config['cron']['item'][$itemhash['ID']]); }
466
		}
467

    
468
		if($_POST['blockpriv'] == "yes")
469
			$wancfg['blockpriv'] = true;
470
		else
471
			unset($wancfg['blockpriv']);
472

    
473
		if($_POST['blockbogons'] == "yes")
474
			$wancfg['blockbogons'] = true;
475
		else
476
			unset($wancfg['blockbogons']);
477

    
478
		$wancfg['spoofmac'] = $_POST['spoofmac'];
479
		$wancfg['mtu'] = $_POST['mtu'];
480

    
481
		write_config();
482
    
483
		/* finally install the pppoerestart file */
484
		if (isset($_POST['pppoe_preset'])) {
485
		config_lock();
486
		conf_mount_rw();
487
      
488
		if (! file_exists(CRON_PPPOE_CMD_FILE)) {
489
			file_put_contents(CRON_PPPOE_CMD_FILE, CRON_PPPOE_CMD);
490
			chmod(CRON_PPPOE_CMD_FILE, 0700);
491
		}
492
      
493
		/* regenerate cron settings/crontab file */
494
		configure_cron();
495
		sigkillbypid("{$g['varrun_path']}/cron.pid", "HUP");
496
      
497
		conf_mount_ro();
498
		config_unlock();
499
		}
500

    
501
		$retval = 0;
502
		$savemsg = get_std_save_message($retval);
503
	}
504
}
505

    
506
$pgtitle = array("Interfaces","WAN");
507
$closehead = false;
508
include("head.inc");
509

    
510
?>
511

    
512
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
513
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
514

    
515
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
516
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css" />
517

    
518
<script type="text/javascript" src="/javascript/scriptaculous/prototype.js"></script>
519
<script type="text/javascript" src="/javascript/scriptaculous/scriptaculous.js"></script>
520

    
521
<script type="text/javascript">
522
<!--
523
function enable_change(enable_change) {
524
	if (document.iform.pppoe_dialondemand.checked || enable_change) {
525
		document.iform.pppoe_idletimeout.disabled = 0;
526
	} else {
527
		document.iform.pppoe_idletimeout.disabled = 1;
528
	}
529
}
530

    
531
function enable_change_pptp(enable_change_pptp) {
532
	if (document.iform.pptp_dialondemand.checked || enable_change_pptp) {
533
		document.iform.pptp_idletimeout.disabled = 0;
534
		document.iform.pptp_local.disabled = 0;
535
		document.iform.pptp_remote.disabled = 0;
536
	} else {
537
		document.iform.pptp_idletimeout.disabled = 1;
538
	}
539
}
540

    
541
function type_change(enable_change,enable_change_pptp) {
542
	switch (document.iform.type.selectedIndex) {
543
		case 0:
544
			document.iform.username.disabled = 1;
545
			document.iform.password.disabled = 1;
546
			document.iform.provider.disabled = 1;
547
			document.iform.pppoe_dialondemand.disabled = 1;
548
			document.iform.pppoe_idletimeout.disabled = 1;
549
			document.iform.pppoe_preset.disabled = 1;
550
			document.iform.pppoe_preset.checked = 0;
551
			Effect.Fade('presetwrap', { duration: 1.0 });
552
			document.iform.ipaddr.disabled = 0;
553
			document.iform.subnet.disabled = 0;
554
			document.iform.gateway.disabled = 0;
555
			document.iform.pptp_username.disabled = 1;
556
			document.iform.pptp_password.disabled = 1;
557
			document.iform.pptp_local.disabled = 1;
558
			document.iform.pptp_subnet.disabled = 1;
559
			document.iform.pptp_remote.disabled = 1;
560
			document.iform.pptp_dialondemand.disabled = 1;
561
			document.iform.pptp_idletimeout.disabled = 1;
562
			document.iform.dhcphostname.disabled = 1;
563
			break;
564
		case 1:
565
			document.iform.username.disabled = 1;
566
			document.iform.password.disabled = 1;
567
			document.iform.provider.disabled = 1;
568
			document.iform.pppoe_dialondemand.disabled = 1;
569
			document.iform.pppoe_idletimeout.disabled = 1;
570
			document.iform.pppoe_preset.disabled = 1;
571
			document.iform.pppoe_preset.checked = 0;
572
			Effect.Fade('presetwrap', { duration: 1.0 });
573
			document.iform.ipaddr.disabled = 1;
574
			document.iform.subnet.disabled = 1;
575
			document.iform.gateway.disabled = 1;
576
			document.iform.pptp_username.disabled = 1;
577
			document.iform.pptp_password.disabled = 1;
578
			document.iform.pptp_local.disabled = 1;
579
			document.iform.pptp_subnet.disabled = 1;
580
			document.iform.pptp_remote.disabled = 1;
581
			document.iform.pptp_dialondemand.disabled = 1;
582
			document.iform.pptp_idletimeout.disabled = 1;
583
			document.iform.dhcphostname.disabled = 0;
584
			break;
585
		case 2:
586
			document.iform.username.disabled = 0;
587
			document.iform.password.disabled = 0;
588
			document.iform.provider.disabled = 0;
589
			document.iform.pppoe_dialondemand.disabled = 0;
590
			if (document.iform.pppoe_dialondemand.checked || enable_change) {
591
				document.iform.pppoe_idletimeout.disabled = 0;
592
			} else {
593
				document.iform.pppoe_idletimeout.disabled = 1;
594
			}
595
			document.iform.pppoe_preset.disabled = 0;
596
			document.iform.ipaddr.disabled = 1;
597
			document.iform.subnet.disabled = 1;
598
			document.iform.gateway.disabled = 1;
599
			document.iform.pptp_username.disabled = 1;
600
			document.iform.pptp_password.disabled = 1;
601
			document.iform.pptp_local.disabled = 1;
602
			document.iform.pptp_subnet.disabled = 1;
603
			document.iform.pptp_remote.disabled = 1;
604
			document.iform.pptp_dialondemand.disabled = 1;
605
			document.iform.pptp_idletimeout.disabled = 1;
606
			document.iform.dhcphostname.disabled = 1;
607
			break;
608
		case 3:
609
			document.iform.username.disabled = 1;
610
			document.iform.password.disabled = 1;
611
			document.iform.provider.disabled = 1;
612
			document.iform.pppoe_dialondemand.disabled = 1;
613
			document.iform.pppoe_idletimeout.disabled = 1;
614
			document.iform.pppoe_preset.disabled = 1;
615
			document.iform.pppoe_preset.checked = 0;
616
			Effect.Fade('presetwrap', { duration: 1.0 });			
617
			document.iform.ipaddr.disabled = 1;
618
			document.iform.subnet.disabled = 1;
619
			document.iform.gateway.disabled = 1;
620
			document.iform.pptp_username.disabled = 0;
621
			document.iform.pptp_password.disabled = 0;
622
			document.iform.pptp_local.disabled = 0;
623
			document.iform.pptp_subnet.disabled = 0;
624
			document.iform.pptp_remote.disabled = 0;
625
			document.iform.pptp_dialondemand.disabled = 0;
626
			if (document.iform.pptp_dialondemand.checked || enable_change_pptp) {
627
				document.iform.pptp_idletimeout.disabled = 0;
628
			} else {
629
				document.iform.pptp_idletimeout.disabled = 1;
630
			}
631
			document.iform.dhcphostname.disabled = 1;
632
			break;
633
		case 4:
634
			document.iform.username.disabled = 1;
635
			document.iform.password.disabled = 1;
636
			document.iform.provider.disabled = 1;
637
			document.iform.pppoe_dialondemand.disabled = 1;
638
			document.iform.pppoe_idletimeout.disabled = 1;
639
			document.iform.pppoe_preset.disabled = 1;
640
			document.iform.pppoe_preset.checked = 0;
641
			Effect.Fade('presetwrap', { duration: 1.0 });
642
			document.iform.ipaddr.disabled = 1;
643
			document.iform.subnet.disabled = 1;
644
			document.iform.gateway.disabled = 1;
645
			document.iform.pptp_username.disabled = 1;
646
			document.iform.pptp_password.disabled = 1;
647
			document.iform.pptp_local.disabled = 1;
648
			document.iform.pptp_subnet.disabled = 1;
649
			document.iform.pptp_remote.disabled = 1;
650
			document.iform.pptp_dialondemand.disabled = 1;
651
			document.iform.pptp_idletimeout.disabled = 1;
652
			document.iform.dhcphostname.disabled = 1;
653
			break;
654
		case 5:
655
			document.iform.username.disabled = 1;
656
			document.iform.password.disabled = 1;
657
			document.iform.provider.disabled = 1;
658
			document.iform.pppoe_dialondemand.disabled = 1;
659
			document.iform.pppoe_idletimeout.disabled = 1;
660
			document.iform.pppoe_preset.disabled = 1;
661
			document.iform.pppoe_preset.checked = 0;
662
			Effect.Fade('presetwrap', { duration: 1.0 });
663
			document.iform.ipaddr.disabled = 1;
664
			document.iform.subnet.disabled = 1;
665
			document.iform.gateway.disabled = 1;
666
			document.iform.pptp_username.disabled = 1;
667
			document.iform.pptp_password.disabled = 1;
668
			document.iform.pptp_local.disabled = 1;
669
			document.iform.pptp_subnet.disabled = 1;
670
			document.iform.pptp_remote.disabled = 1;
671
			document.iform.pptp_dialondemand.disabled = 1;
672
			document.iform.pptp_idletimeout.disabled = 1;
673
			document.iform.dhcphostname.disabled = 1;
674
			break;
675

    
676
	}
677
}
678

    
679
function show_mon_config() {
680
	document.getElementById("showmonbox").innerHTML='';
681
	aodiv = document.getElementById('showmon');
682
	aodiv.style.display = "block";
683
}
684

    
685
//-->
686
</script>
687
</head>
688
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
689
<?php include("fbegin.inc"); ?>
690
<?php if ($input_errors) print_input_errors($input_errors); ?>
691
<?php if ($savemsg) print_info_box($savemsg); ?>
692
            <form action="interfaces_wan.php" method="post" name="iform" id="iform">
693
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
694
                <tr>
695
                  <td colspan="2" valign="top" class="listtopic">General configuration</td>
696
                </tr>
697
                <tr>
698
                  <td valign="middle" class="vncell"><strong>Type</strong></td>
699
                  <td class="vtable"> <select name="type" class="formselect" id="type" onchange="type_change()">
700
                      <?php $opts = split(" ", "Static DHCP PPPoE PPTP CarpDEV-DHCP");
701
					  foreach ($opts as $opt): ?>
702
	                      <option <?php if ($opt == $pconfig['type']) echo "selected";?>>
703
	                      <?=htmlspecialchars($opt);?>
704
	                      </option>
705
                      <?php endforeach; ?>
706
                    </select></td>
707
                </tr>
708
                <tr>
709
                  <td valign="top" class="vncell">MAC address</td>
710
                  <td class="vtable"> <input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
711
		    <?php
712
			$ip = getenv('REMOTE_ADDR');
713
			$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
714
			$mac = str_replace("\n","",$mac);
715
		    ?>
716
		    <a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#">Copy my MAC address</a>
717
		    <br>
718
                    This field can be used to modify (&quot;spoof&quot;) the MAC
719
                    address of the WAN interface<br>
720
                    (may be required with some cable connections)<br>
721
                    Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx
722
                    or leave blank</td>
723
                </tr>
724
                <tr>
725
                  <td valign="top" class="vncell">MTU</td>
726
                  <td class="vtable"> <input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
727
                    <br>
728
                    If you enter a value in this field, then MSS clamping for
729
                    TCP connections to the value entered above minus 40 (TCP/IP
730
                    header size) will be in effect. If you leave this field blank,
731
                    an MTU of 1492 bytes for PPPoE and 1500 bytes for all other
732
                    connection types will be assumed.</td>
733
                </tr>
734
                <tr>
735
                  <td colspan="2" valign="top" height="16"></td>
736
                </tr>
737
                <tr>
738
                  <td colspan="2" valign="top" class="listtopic">Static IP configuration</td>
739
                </tr>
740
                <tr>
741
                  <td width="100" valign="top" class="vncellreq">IP address</td>
742
                  <td class="vtable"> <input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
743
                    /
744
                    <select name="subnet" class="formselect" id="subnet">
745
			<?php
746
			for ($i = 32; $i > 0; $i--) {
747
				if($i <> 31) {
748
					echo "<option value=\"{$i}\" ";
749
					if ($i == $pconfig['subnet']) echo "selected";
750
					echo ">" . $i . "</option>";
751
				}
752
			}
753
			?>
754
                    </select></td>
755
                </tr><?php if (isset($wancfg['ispointtopoint'])): ?>
756
                <tr>
757
                  <td valign="top" class="vncellreq">Point-to-point IP address </td>
758
                  <td class="vtable">
759
                    <input name="pointtopoint" type="text" class="formfld unknown" id="pointtopoint" size="20" value="<?=htmlspecialchars($pconfig['pointtopoint']);?>">
760
                  </td>
761
                </tr><?php endif; ?>
762
                <tr>
763
                  <td valign="top" class="vncellreq">Gateway</td>
764
                  <td class="vtable"><select name="gateway" class="formselect" id="gateway">
765
			<?php
766
			if(count($a_gateways) > 0) {
767
				foreach ($a_gateways as $gateway) {
768
					if($gateway['interface'] == "wan") {
769
			?>
770
					<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
771
					<?=htmlspecialchars($gateway['name']);?>
772
					</option>
773
			<?php
774
					}
775
				}
776
			}
777
			?>
778
			</select>Select a existing Gateway from the list or add one on the <a href="/system_gateways.php">Gateways</a> page<br>
779
                  </td>
780
                </tr>
781
                <tr>
782
                  <td colspan="2" valign="top" height="16"></td>
783
                </tr>
784
                <tr>
785
                  <td colspan="2" valign="top" class="listtopic">DHCP client configuration</td>
786
                </tr>
787
                <tr>
788
                  <td valign="top" class="vncell">Hostname</td>
789
                  <td class="vtable"> <input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
790
                    <br>
791
                    The value in this field is sent as the DHCP client identifier
792
                    and hostname when requesting a DHCP lease. Some ISPs may require
793
                    this (for client identification).</td>
794
                </tr>
795
                <tr>
796
                  <td width="100" valign="top" class="vncellreq">Alias IP address</td>
797
                  <td class="vtable"> <input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
798
                    <select name="alias-subnet" class="formselect" id="alias-subnet">
799
			<?php
800
			for ($i = 32; $i > 0; $i--) {
801
				if($i <> 31) {
802
					echo "<option value=\"{$i}\" ";
803
					if ($i == $pconfig['alias-subnet']) echo "selected";
804
					echo ">" . $i . "</option>";
805
				}
806
			}
807
			?>
808
                    </select>
809
                    The value in this field is used as a fixed alias IP address by the
810
		    DHCP client.</td>
811
                </tr>
812
                <tr>
813
                  <td colspan="2" valign="top" height="16"></td>
814
                </tr>
815
                <tr>
816
                  <td colspan="2" valign="top" class="listtopic">PPPoE configuration</td>
817
                </tr>
818
                <tr>
819
                  <td valign="top" class="vncellreq">Username</td>
820
                  <td class="vtable"><input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
821
                  </td>
822
                </tr>
823
                <tr>
824
                  <td valign="top" class="vncellreq">Password</td>
825
                  <td class="vtable"><input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
826
                  </td>
827
                </tr>
828
                <tr>
829
                  <td valign="top" class="vncell">Service name</td>
830
                  <td class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
831
                    <br> <span class="vexpl">Hint: this field can usually be left
832
                    empty</span></td>
833
                </tr>
834
                <tr>
835
                  <td valign="top" class="vncell">Dial on demand</td>
836
                  <td class="vtable"><input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?> onClick="enable_change(false)" >
837
                    <strong>Enable Dial-On-Demand mode</strong><br>
838
		    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>
839
                </tr>
840
                <tr>
841
                  <td valign="top" class="vncell">Idle timeout</td>
842
                  <td class="vtable">
843
                    <input name="pppoe_idletimeout" type="text" class="formfld unknown" id="pppoe_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pppoe_idletimeout']);?>"> 
844
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>
845
                </tr>
846
                <tr>
847
                  <td valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
848
                  <td class="vtable">
849
                    <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 });" />
850
                    <?= gettext("enable periodic PPPoE resets"); ?>
851
                    <br />
852
                    <?php if ($pconfig['pppoe_preset']): ?>
853
                    <table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
854
                    <?php else: ?>
855
                    <table id="presetwrap" cellspacing="0" cellpadding="0" width="100%" style="display: none;">
856
                    <?php endif; ?>
857
                      <tr>
858
                        <td align="left" valign="top">
859
                          <p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
860
                            <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 }); }" /> 
861
                            <?= gettext("provide a custom reset time"); ?>
862
                            <br />
863
                            <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 }); }" /> 
864
                            <?= gettext("select reset time from a preset"); ?>
865
                          </p>
866
                          <?php if ($pconfig['pppoe_pr_custom']): ?>
867
                          <p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
868
                          <?php else: ?>
869
                          <p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
870
                          <?php endif; ?>
871
                            <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" /> 
872
                            <?= gettext("hour (0-23)"); ?><br />
873
                            <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" /> 
874
                            <?= gettext("minute (0-59)"); ?><br />
875
                            <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']);?>" /> 
876
                            <?= gettext("reset at a specific date (mm/dd/yyyy)"); ?>
877
                            <br />&nbsp;<br />
878
                            <span class="red"><strong>Note: </strong></span>
879
                            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.
880
                          </p>
881
                          <?php if ($pconfig['pppoe_pr_preset']): ?>
882
                          <p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
883
                          <?php else: ?>
884
                          <p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
885
                          <?php endif; ?>
886
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> /> 
887
                            <?= gettext("reset at each month ('0 0 1 * *')"); ?>
888
                            <br />
889
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> /> 
890
                            <?= gettext("reset at each week ('0 0 * * 0')"); ?>
891
                            <br />
892
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> /> 
893
                            <?= gettext("reset at each day ('0 0 * * *')"); ?>
894
                            <br />
895
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> /> 
896
                            <?= gettext("reset at each hour ('0 * * * *')"); ?>
897
                          </p>
898
                        </td>
899
                      </tr>
900
                    </table>
901
                  </td>
902
                </tr>                
903
                <tr>
904
                  <td colspan="2" valign="top" height="16"></td>
905
                </tr>
906
                <tr>
907
                  <td colspan="2" valign="top" class="listtopic">PPTP configuration</td>
908
                </tr>
909
                <tr>
910
                  <td valign="top" class="vncellreq">Username</td>
911
                  <td class="vtable"><input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
912
                  </td>
913
                </tr>
914
                <tr>
915
                  <td valign="top" class="vncellreq">Password</td>
916
                  <td class="vtable"><input name="pptp_password" type="text" class="formfld pwd" id="pptp_password" size="20" 
917
value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
918
                  </td>
919
                </tr>
920
                <tr>
921
                  <td width="100" valign="top" class="vncellreq">Local IP address</td>
922
                  <td class="vtable"> <input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20" 
923
value="<?=htmlspecialchars($pconfig['pptp_local']);?>">
924
                    /
925
                    <select name="pptp_subnet" class="formselect" id="pptp_subnet">
926
                      <?php for ($i = 31; $i > 0; $i--): ?>
927
                      <option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet']) echo "selected"; ?>>
928
                      <?=$i;?>
929
                      </option>
930
                      <?php endfor; ?>
931
                    </select></td>
932
                </tr>
933
                <tr>
934
                  <td width="100" valign="top" class="vncellreq">Remote IP address</td>
935
                  <td class="vtable"> <input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote']);?>">
936
                  </td>
937
                </tr>
938
                <tr>
939
                  <td valign="top" class="vncell">Dial on demand</td>
940
                  <td class="vtable"><input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?> onClick="enable_change_pptp(false)" >
941
                    <strong>Enable Dial-On-Demand mode</strong><br>
942
		    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>
943
                </tr>
944
                <tr>
945
                  <td valign="top" class="vncell">Idle timeout</td>
946
                  <td class="vtable">
947
                    <input name="pptp_idletimeout" type="text" class="formfld unknown" id="pptp_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pptp_idletimeout']);?>"> 
948
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>
949
                </tr>
950
                <tr>
951
                  <td colspan="2" valign="top" height="16"></td>
952
                </tr>
953
                <tr>
954
                  <td colspan="2" valign="top" class="listtopic">Other</td>
955
                </tr>
956
		<tr>
957
			<td width="22%" valign="top" class="vncell">FTP Helper</td>
958
			<td width="78%" class="vtable">
959
				<input name="disableftpproxy" type="checkbox" id="disableftpproxy" value="yes" <?php if ($pconfig['disableftpproxy']) echo "checked"; ?> onclick="enable_change(false)" />
960
				<strong>Disable the userland FTP-Proxy application</strong>
961
				<br />
962
			</td>
963
		</tr>
964
		        <?php
965
				/* Wireless interface? */
966
				if (isset($wancfg['wireless']))
967
					wireless_config_print();
968
			?>
969
                <tr>
970
                  <td height="16" colspan="2" valign="top"></td>
971
                </tr>
972
                <tr>
973
                  <td valign="middle">&nbsp;</td>
974
                  <td class="vtable"><a name="rfc1918"></a> <input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
975
                    <strong>Block private networks</strong><br>
976
                    When set, this option blocks traffic from IP addresses that
977
                    are reserved for private<br>
978
                    networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as
979
                    well as loopback addresses<br>
980
                    (127/8). You should generally leave this option turned on,
981
                    unless your WAN network<br>
982
                    lies in such a private address space, too.</td>
983
                </tr>
984
                <tr>
985
                  <td valign="middle">&nbsp;</td>
986
                  <td class="vtable"> <input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
987
                    <strong>Block bogon networks</strong><br>
988
                    When set, this option blocks traffic from IP addresses that
989
                    are reserved (but not RFC 1918) or not yet assigned by IANA.<br>
990
                    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>
991
		</tr>
992

    
993
                <tr>
994
                  <td width="100" valign="top">&nbsp;</td>
995
                  <td> &nbsp;<br> <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change_pptp(true)&&enable_change(true)">
996
                  </td>
997
                </tr>
998
              </table>
999
</form>
1000
<script language="JavaScript">
1001
<!--
1002
type_change();
1003
//-->
1004
</script>
1005
<?php include("fend.inc"); ?>
1006
</body>
1007
</html>
1008

    
1009

    
1010
<?php
1011

    
1012
if ($_POST) {
1013

    
1014
	if (!$input_errors) {
1015

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

    
1018
		ob_flush();
1019
		flush();
1020
		sleep(1);
1021

    
1022
		interfaces_wan_configure();
1023

    
1024
		reset_carp();
1025

    
1026
		/* sync filter configuration */
1027
		filter_configure();
1028

    
1029
 		/* set up static routes */
1030
		system_routing_configure();
1031

    
1032
	}
1033
}
1034

    
1035
?>
(81-81/197)