Project

General

Profile

Download (48.6 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['bigpond_username'] = $config['bigpond']['username'];
135
$pconfig['bigpond_password'] = $config['bigpond']['password'];
136
$pconfig['bigpond_authserver'] = $config['bigpond']['authserver'];
137
$pconfig['bigpond_authdomain'] = $config['bigpond']['authdomain'];
138
$pconfig['bigpond_minheartbeatinterval'] = $config['bigpond']['minheartbeatinterval'];
139

    
140
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
141
$pconfig['alias-address'] = $wancfg['alias-address'];
142
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
143

    
144
if ($wancfg['ipaddr'] == "dhcp") {
145
	$pconfig['type'] = "DHCP";
146
} else if ($wancfg['ipaddr'] == "pppoe") {
147
	$pconfig['type'] = "PPPoE";
148
} else if ($wancfg['ipaddr'] == "pptp") {
149
	$pconfig['type'] = "PPTP";
150
} else if ($wancfg['ipaddr'] == "bigpond") {
151
	$pconfig['type'] = "BigPond";
152
} else {
153
	$pconfig['type'] = "Static";
154
	$pconfig['ipaddr'] = $wancfg['ipaddr'];
155
	$pconfig['subnet'] = $wancfg['subnet'];
156
	$pconfig['gateway'] = $config['interfaces']['wan']['gateway'];
157
	$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
158
}
159

    
160
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
161
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
162
$pconfig['spoofmac'] = $wancfg['spoofmac'];
163
$pconfig['mtu'] = $wancfg['mtu'];
164

    
165
/* Wireless interface? */
166
if (isset($wancfg['wireless'])) {
167
	require("interfaces_wlan.inc");
168
	wireless_config_init();
169
}
170

    
171
if ($_POST) {
172

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

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

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

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

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

    
316
	/* Wireless interface? */
317
	if (isset($wancfg['wireless'])) {
318
		$wi_input_errors = wireless_config_post();
319
		if ($wi_input_errors) {
320
			$input_errors = array_merge($input_errors, $wi_input_errors);
321
		}
322
	}
323

    
324
	if (!$input_errors) {
325

    
326
		$bridge = discover_bridge($wancfg['if'], filter_translate_type_to_real_interface($wancfg['bridge']));
327
		if($bridge <> "-1") {
328
			destroy_bridge($bridge);
329
		}
330

    
331
		unset($wancfg['ipaddr']);
332
		unset($wancfg['subnet']);
333
		unset($config['interfaces']['wan']['gateway']);
334
		unset($wancfg['pointtopoint']);
335
		unset($wancfg['dhcphostname']);
336
		if (is_array($wancfg['pppoe'])) {
337
			unset($config['pppoe']['username']);
338
			unset($config['pppoe']['password']);
339
			unset($config['pppoe']['provider']);
340
			unset($config['pppoe']['ondemand']);
341
			unset($config['pppoe']['timeout']);
342
			unset($wancfg['pppoe']['pppoe-reset-type']);
343
		}
344
		if (is_array($wancfg['pptp'])) {
345
			unset($config['pptp']['username']);
346
			unset($config['pptp']['password']);
347
			unset($config['pptp']['local']);
348
			unset($config['pptp']['subnet']);
349
			unset($config['pptp']['remote']);
350
			unset($config['pptp']['ondemand']);
351
			unset($config['pptp']['timeout']);
352
		}
353
		unset($config['bigpond']['username']);
354
		unset($config['bigpond']['password']);
355
		unset($config['bigpond']['authserver']);
356
		unset($config['bigpond']['authdomain']);
357
		unset($config['bigpond']['minheartbeatinterval']);
358
		unset($wancfg['disableftpproxy']);
359

    
360
		/* per interface pftpx helper */
361
		if($_POST['disableftpproxy'] == "yes") {
362
			$wancfg['disableftpproxy'] = true;
363
			system_start_ftp_helpers();
364
		} else {
365
			system_start_ftp_helpers();
366
		}
367

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

    
391
					$itemhash = getMPDCRONSettings();
392
					$item = $itemhash['ITEM'];
393

    
394
					if (empty($item)) {
395
						$item = array();
396
					}
397

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

    
402
						$item['minute'] = $_POST['pppoe_resetminute'];
403
						$item['hour'] = $_POST['pppoe_resethour'];
404

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

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

    
493
		if($_POST['blockpriv'] == "yes")
494
			$wancfg['blockpriv'] = true;
495
		else
496
			unset($wancfg['blockpriv']);
497

    
498
		if($_POST['blockbogons'] == "yes")
499
			$wancfg['blockbogons'] = true;
500
		else
501
			unset($wancfg['blockbogons']);
502

    
503
		$wancfg['spoofmac'] = $_POST['spoofmac'];
504
		$wancfg['mtu'] = $_POST['mtu'];
505

    
506
		write_config();
507
    
508
		/* finally install the pppoerestart file */
509
		if (isset($_POST['pppoe_preset'])) {
510
		config_lock();
511
		conf_mount_rw();
512
      
513
		if (! file_exists(CRON_PPPOE_CMD_FILE)) {
514
			file_put_contents(CRON_PPPOE_CMD_FILE, CRON_PPPOE_CMD);
515
			chmod(CRON_PPPOE_CMD_FILE, 0700);
516
		}
517
      
518
		/* regenerate cron settings/crontab file */
519
		configure_cron();
520
		sigkillbypid("{$g['varrun_path']}/cron.pid", "HUP");
521
      
522
		conf_mount_ro();
523
		config_unlock();
524
		}
525

    
526
		$retval = 0;
527
		$savemsg = get_std_save_message($retval);
528
	}
529
}
530

    
531
$pgtitle = array("Interfaces","WAN");
532
$closehead = false;
533
include("head.inc");
534

    
535
?>
536

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

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

    
543
<script type="text/javascript" src="/javascript/scriptaculous/prototype.js"></script>
544
<script type="text/javascript" src="/javascript/scriptaculous/scriptaculous.js"></script>
545

    
546
<script type="text/javascript">
547
<!--
548
function enable_change(enable_change) {
549
	if (document.iform.pppoe_dialondemand.checked || enable_change) {
550
		document.iform.pppoe_idletimeout.disabled = 0;
551
	} else {
552
		document.iform.pppoe_idletimeout.disabled = 1;
553
	}
554
}
555

    
556
function enable_change_pptp(enable_change_pptp) {
557
	if (document.iform.pptp_dialondemand.checked || enable_change_pptp) {
558
		document.iform.pptp_idletimeout.disabled = 0;
559
		document.iform.pptp_local.disabled = 0;
560
		document.iform.pptp_remote.disabled = 0;
561
	} else {
562
		document.iform.pptp_idletimeout.disabled = 1;
563
	}
564
}
565

    
566
function type_change(enable_change,enable_change_pptp) {
567
	switch (document.iform.type.selectedIndex) {
568
		case 0:
569
			document.iform.username.disabled = 1;
570
			document.iform.password.disabled = 1;
571
			document.iform.provider.disabled = 1;
572
			document.iform.pppoe_dialondemand.disabled = 1;
573
			document.iform.pppoe_idletimeout.disabled = 1;
574
			document.iform.pppoe_preset.disabled = 1;
575
			document.iform.pppoe_preset.checked = 0;
576
			Effect.Fade('presetwrap', { duration: 1.0 });
577
			document.iform.ipaddr.disabled = 0;
578
			document.iform.subnet.disabled = 0;
579
			document.iform.gateway.disabled = 0;
580
			document.iform.pptp_username.disabled = 1;
581
			document.iform.pptp_password.disabled = 1;
582
			document.iform.pptp_local.disabled = 1;
583
			document.iform.pptp_subnet.disabled = 1;
584
			document.iform.pptp_remote.disabled = 1;
585
			document.iform.pptp_dialondemand.disabled = 1;
586
			document.iform.pptp_idletimeout.disabled = 1;
587
			document.iform.bigpond_username.disabled = 1;
588
			document.iform.bigpond_password.disabled = 1;
589
			document.iform.bigpond_authserver.disabled = 1;
590
			document.iform.bigpond_authdomain.disabled = 1;
591
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
592
			document.iform.dhcphostname.disabled = 1;
593
			break;
594
		case 1:
595
			document.iform.username.disabled = 1;
596
			document.iform.password.disabled = 1;
597
			document.iform.provider.disabled = 1;
598
			document.iform.pppoe_dialondemand.disabled = 1;
599
			document.iform.pppoe_idletimeout.disabled = 1;
600
			document.iform.pppoe_preset.disabled = 1;
601
			document.iform.pppoe_preset.checked = 0;
602
			Effect.Fade('presetwrap', { duration: 1.0 });
603
			document.iform.ipaddr.disabled = 1;
604
			document.iform.subnet.disabled = 1;
605
			document.iform.gateway.disabled = 1;
606
			document.iform.pptp_username.disabled = 1;
607
			document.iform.pptp_password.disabled = 1;
608
			document.iform.pptp_local.disabled = 1;
609
			document.iform.pptp_subnet.disabled = 1;
610
			document.iform.pptp_remote.disabled = 1;
611
			document.iform.pptp_dialondemand.disabled = 1;
612
			document.iform.pptp_idletimeout.disabled = 1;
613
			document.iform.bigpond_username.disabled = 1;
614
			document.iform.bigpond_password.disabled = 1;
615
			document.iform.bigpond_authserver.disabled = 1;
616
			document.iform.bigpond_authdomain.disabled = 1;
617
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
618
			document.iform.dhcphostname.disabled = 0;
619
			break;
620
		case 2:
621
			document.iform.username.disabled = 0;
622
			document.iform.password.disabled = 0;
623
			document.iform.provider.disabled = 0;
624
			document.iform.pppoe_dialondemand.disabled = 0;
625
			if (document.iform.pppoe_dialondemand.checked || enable_change) {
626
				document.iform.pppoe_idletimeout.disabled = 0;
627
			} else {
628
				document.iform.pppoe_idletimeout.disabled = 1;
629
			}
630
			document.iform.pppoe_preset.disabled = 0;
631
			document.iform.ipaddr.disabled = 1;
632
			document.iform.subnet.disabled = 1;
633
			document.iform.gateway.disabled = 1;
634
			document.iform.pptp_username.disabled = 1;
635
			document.iform.pptp_password.disabled = 1;
636
			document.iform.pptp_local.disabled = 1;
637
			document.iform.pptp_subnet.disabled = 1;
638
			document.iform.pptp_remote.disabled = 1;
639
			document.iform.pptp_dialondemand.disabled = 1;
640
			document.iform.pptp_idletimeout.disabled = 1;
641
			document.iform.bigpond_username.disabled = 1;
642
			document.iform.bigpond_password.disabled = 1;
643
			document.iform.bigpond_authserver.disabled = 1;
644
			document.iform.bigpond_authdomain.disabled = 1;
645
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
646
			document.iform.dhcphostname.disabled = 1;
647
			break;
648
		case 3:
649
			document.iform.username.disabled = 1;
650
			document.iform.password.disabled = 1;
651
			document.iform.provider.disabled = 1;
652
			document.iform.pppoe_dialondemand.disabled = 1;
653
			document.iform.pppoe_idletimeout.disabled = 1;
654
			document.iform.pppoe_preset.disabled = 1;
655
			document.iform.pppoe_preset.checked = 0;
656
			Effect.Fade('presetwrap', { duration: 1.0 });			
657
			document.iform.ipaddr.disabled = 1;
658
			document.iform.subnet.disabled = 1;
659
			document.iform.gateway.disabled = 1;
660
			document.iform.pptp_username.disabled = 0;
661
			document.iform.pptp_password.disabled = 0;
662
			document.iform.pptp_local.disabled = 0;
663
			document.iform.pptp_subnet.disabled = 0;
664
			document.iform.pptp_remote.disabled = 0;
665
			document.iform.pptp_dialondemand.disabled = 0;
666
			if (document.iform.pptp_dialondemand.checked || enable_change_pptp) {
667
				document.iform.pptp_idletimeout.disabled = 0;
668
			} else {
669
				document.iform.pptp_idletimeout.disabled = 1;
670
			}
671
			document.iform.bigpond_username.disabled = 1;
672
			document.iform.bigpond_password.disabled = 1;
673
			document.iform.bigpond_authserver.disabled = 1;
674
			document.iform.bigpond_authdomain.disabled = 1;
675
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
676
			document.iform.dhcphostname.disabled = 1;
677
			break;
678
		case 4:
679
			document.iform.username.disabled = 1;
680
			document.iform.password.disabled = 1;
681
			document.iform.provider.disabled = 1;
682
			document.iform.pppoe_dialondemand.disabled = 1;
683
			document.iform.pppoe_idletimeout.disabled = 1;
684
			document.iform.pppoe_preset.disabled = 1;
685
			document.iform.pppoe_preset.checked = 0;
686
			Effect.Fade('presetwrap', { duration: 1.0 });
687
			document.iform.ipaddr.disabled = 1;
688
			document.iform.subnet.disabled = 1;
689
			document.iform.gateway.disabled = 1;
690
			document.iform.pptp_username.disabled = 1;
691
			document.iform.pptp_password.disabled = 1;
692
			document.iform.pptp_local.disabled = 1;
693
			document.iform.pptp_subnet.disabled = 1;
694
			document.iform.pptp_remote.disabled = 1;
695
			document.iform.pptp_dialondemand.disabled = 1;
696
			document.iform.pptp_idletimeout.disabled = 1;
697
			document.iform.bigpond_username.disabled = 0;
698
			document.iform.bigpond_password.disabled = 0;
699
			document.iform.bigpond_authserver.disabled = 0;
700
			document.iform.bigpond_authdomain.disabled = 0;
701
			document.iform.bigpond_minheartbeatinterval.disabled = 0;
702
			document.iform.dhcphostname.disabled = 1;
703
			break;
704
	}
705
}
706

    
707
function show_mon_config() {
708
	document.getElementById("showmonbox").innerHTML='';
709
	aodiv = document.getElementById('showmon');
710
	aodiv.style.display = "block";
711
}
712

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

    
1056
                <tr>
1057
                  <td width="100" valign="top">&nbsp;</td>
1058
                  <td> &nbsp;<br> <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change_pptp(true)&&enable_change(true)">
1059
                  </td>
1060
                </tr>
1061
              </table>
1062
</form>
1063
<script language="JavaScript">
1064
<!--
1065
type_change();
1066
//-->
1067
</script>
1068
<?php include("fend.inc"); ?>
1069
</body>
1070
</html>
1071

    
1072

    
1073
<?php
1074

    
1075
if ($_POST) {
1076

    
1077
	if (!$input_errors) {
1078

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

    
1081
		ob_flush();
1082
		flush();
1083
		sleep(1);
1084

    
1085
		interfaces_wan_configure();
1086

    
1087
		reset_carp();
1088

    
1089
		/* sync filter configuration */
1090
		filter_configure();
1091

    
1092
 		/* set up static routes */
1093
		system_routing_configure();
1094

    
1095
	}
1096
}
1097

    
1098
?>
(73-73/187)