Project

General

Profile

Download (48.6 KB) Statistics
| Branch: | Tag: | Revision:
1 e2cd32df Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	interfaces_wan.php
5 15aea4cb Seth Mos
        Copyright (C) 2007 Scott Ullrich
6 c3b3cd36 Scott Ullrich
	All rights reserved.
7 b1c525ee Scott Ullrich
8 c3b3cd36 Scott Ullrich
	originally part of m0n0wall (http://m0n0.ch/wall)
9 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11 e2cd32df Scott Ullrich
12 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14 e2cd32df Scott Ullrich
15 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17 e2cd32df Scott Ullrich
18 5b237745 Scott Ullrich
	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 e2cd32df Scott Ullrich
22 5b237745 Scott Ullrich
	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 58af5941 Scott Ullrich
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 ceed9314 Scott Ullrich
define("CRON_PPPOE_CMD", "#!/bin/sh\necho '<?php require(\"interfaces.inc\"); interfaces_wan_pppoe_restart(); services_dyndns_reset(); ?>' | /usr/local/bin/php -q");
40 58af5941 Scott Ullrich
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 5b237745 Scott Ullrich
require("guiconfig.inc");
70
71 d173230c Seth Mos
if (!is_array($config['gateways']['gateway_item']))
72
	$config['gateways']['gateway_item'] = array();
73
$a_gateways = &$config['gateways']['gateway_item'];
74
75 5b237745 Scott Ullrich
$wancfg = &$config['interfaces']['wan'];
76 8bb29531 Scott Ullrich
$optcfg = &$config['interfaces']['wan'];
77 5b237745 Scott Ullrich
78
$pconfig['username'] = $config['pppoe']['username'];
79
$pconfig['password'] = $config['pppoe']['password'];
80
$pconfig['provider'] = $config['pppoe']['provider'];
81 a23d7248 Scott Ullrich
$pconfig['pppoe_dialondemand'] = isset($config['pppoe']['ondemand']);
82 5b237745 Scott Ullrich
$pconfig['pppoe_idletimeout'] = $config['pppoe']['timeout'];
83
84 58af5941 Scott Ullrich
/* ================================================ */
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 5b237745 Scott Ullrich
$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 a23d7248 Scott Ullrich
$pconfig['pptp_dialondemand'] = isset($config['pptp']['ondemand']);
130 5b237745 Scott Ullrich
$pconfig['pptp_idletimeout'] = $config['pptp']['timeout'];
131
132 c1ec2c2f Scott Ullrich
$pconfig['disableftpproxy'] = isset($wancfg['disableftpproxy']);
133
134 5b237745 Scott Ullrich
$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 bc40d758 Seth Mos
$pconfig['alias-address'] = $wancfg['alias-address'];
142
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
143 5b237745 Scott Ullrich
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 588a183b Scott Ullrich
	$pconfig['gateway'] = $config['interfaces']['wan']['gateway'];
157 a23d7248 Scott Ullrich
	$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
158 5b237745 Scott Ullrich
}
159
160
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
161 ff1955ee Bill Marquette
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
162 5b237745 Scott Ullrich
$pconfig['spoofmac'] = $wancfg['spoofmac'];
163
$pconfig['mtu'] = $wancfg['mtu'];
164
165
/* Wireless interface? */
166 b7f01f59 Bill Marquette
if (isset($wancfg['wireless'])) {
167 5b237745 Scott Ullrich
	require("interfaces_wlan.inc");
168
	wireless_config_init();
169
}
170
171
if ($_POST) {
172
173
	unset($input_errors);
174
	$pconfig = $_POST;
175 58af5941 Scott Ullrich
  
176 15aea4cb Seth Mos
	/* 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 5b237745 Scott Ullrich
191 ee968e4f Scott Ullrich
	if($_POST['gateway'] and $pconfig['gateway'] <> $_POST['gateway']) {
192 6fc5bf35 Scott Ullrich
		/* 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 8bddc5b7 Scott Ullrich
			            if($svr[1] == $pconfig['gateway'])  {
199
			            		$_POST['gateway']  = $pconfig['gateway'];
200 de42a08e Scott Ullrich
			            		$input_errors[] = "Cannot change {$svr[1]} gateway.  It is currently referenced by the load balancer pools.";
201 8bddc5b7 Scott Ullrich
			            }
202 6fc5bf35 Scott Ullrich
					}
203
				}
204 8bddc5b7 Scott Ullrich
			}
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 6fc5bf35 Scott Ullrich
		}
212
	}
213
214 5b237745 Scott Ullrich
	/* 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 e2cd32df Scott Ullrich
243 4f3401e0 Bill Marquette
        /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
244
        $_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
245
246 5b237745 Scott Ullrich
	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 bc40d758 Seth Mos
	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 d173230c Seth Mos
	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 5b237745 Scott Ullrich
	}
268 a23d7248 Scott Ullrich
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) {
269
		$input_errors[] = "A valid point-to-point IP address must be specified.";
270
	}
271 5b237745 Scott Ullrich
	if (($_POST['provider'] && !is_domain($_POST['provider']))) {
272
		$input_errors[] = "The service name contains invalid characters.";
273
	}
274 a23d7248 Scott Ullrich
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
275 5b237745 Scott Ullrich
		$input_errors[] = "The idle timeout value must be an integer.";
276
	}
277 15aea4cb Seth Mos
	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 5b237745 Scott Ullrich
	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 a23d7248 Scott Ullrich
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) {
298 5b237745 Scott Ullrich
		$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 e2cd32df Scott Ullrich
316 5b237745 Scott Ullrich
	/* Wireless interface? */
317 b7f01f59 Bill Marquette
	if (isset($wancfg['wireless'])) {
318 5b237745 Scott Ullrich
		$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 e2cd32df Scott Ullrich
326 9a6757a1 Scott Ullrich
		$bridge = discover_bridge($wancfg['if'], filter_translate_type_to_real_interface($wancfg['bridge']));
327 0d429e43 Scott Ullrich
		if($bridge <> "-1") {
328 1665e79c Scott Ullrich
			destroy_bridge($bridge);
329 91e8aab2 Scott Ullrich
		}
330 b1c525ee Scott Ullrich
331 5b237745 Scott Ullrich
		unset($wancfg['ipaddr']);
332
		unset($wancfg['subnet']);
333 588a183b Scott Ullrich
		unset($config['interfaces']['wan']['gateway']);
334 a23d7248 Scott Ullrich
		unset($wancfg['pointtopoint']);
335 5b237745 Scott Ullrich
		unset($wancfg['dhcphostname']);
336 15aea4cb Seth Mos
		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 5b237745 Scott Ullrich
		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 c1ec2c2f Scott Ullrich
		unset($wancfg['disableftpproxy']);
359 b1c525ee Scott Ullrich
360 c1ec2c2f Scott Ullrich
		/* per interface pftpx helper */
361
		if($_POST['disableftpproxy'] == "yes") {
362
			$wancfg['disableftpproxy'] = true;
363
			system_start_ftp_helpers();
364 b1c525ee Scott Ullrich
		} else {
365 c1ec2c2f Scott Ullrich
			system_start_ftp_helpers();
366
		}
367 e2cd32df Scott Ullrich
368 5b237745 Scott Ullrich
		if ($_POST['type'] == "Static") {
369
			$wancfg['ipaddr'] = $_POST['ipaddr'];
370
			$wancfg['subnet'] = $_POST['subnet'];
371 588a183b Scott Ullrich
			$config['interfaces']['wan']['gateway'] = $_POST['gateway'];
372 a23d7248 Scott Ullrich
			if (isset($wancfg['ispointtopoint']))
373
				$wancfg['pointtopoint'] = $_POST['pointtopoint'];
374 5b237745 Scott Ullrich
		} else if ($_POST['type'] == "DHCP") {
375
			$wancfg['ipaddr'] = "dhcp";
376
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
377 bc40d758 Seth Mos
			$wancfg['alias-address'] = $_POST['alias-address'];
378
			$wancfg['alias-subnet'] = $_POST['alias-subnet'];
379 5b237745 Scott Ullrich
		} 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 a23d7248 Scott Ullrich
			$config['pppoe']['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
385 5b237745 Scott Ullrich
			$config['pppoe']['timeout'] = $_POST['pppoe_idletimeout'];
386 58af5941 Scott Ullrich
      
387 15aea4cb Seth Mos
			/* 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 5b237745 Scott Ullrich
		} 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 a23d7248 Scott Ullrich
			$config['pptp']['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
475 5b237745 Scott Ullrich
			$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 58af5941 Scott Ullrich
    
485 15aea4cb Seth Mos
		/* 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 e2cd32df Scott Ullrich
493 90ebf755 Scott Ullrich
		if($_POST['blockpriv'] == "yes")
494
			$wancfg['blockpriv'] = true;
495
		else
496 42a58cb9 Scott Ullrich
			unset($wancfg['blockpriv']);
497 b1c525ee Scott Ullrich
498 90ebf755 Scott Ullrich
		if($_POST['blockbogons'] == "yes")
499
			$wancfg['blockbogons'] = true;
500
		else
501
			unset($wancfg['blockbogons']);
502 b1c525ee Scott Ullrich
503 5b237745 Scott Ullrich
		$wancfg['spoofmac'] = $_POST['spoofmac'];
504
		$wancfg['mtu'] = $_POST['mtu'];
505 e2cd32df Scott Ullrich
506 5b237745 Scott Ullrich
		write_config();
507 58af5941 Scott Ullrich
    
508
		/* finally install the pppoerestart file */
509
		if (isset($_POST['pppoe_preset'])) {
510 15aea4cb Seth Mos
		config_lock();
511
		conf_mount_rw();
512 58af5941 Scott Ullrich
      
513 15aea4cb Seth Mos
		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 58af5941 Scott Ullrich
      
518 15aea4cb Seth Mos
		/* regenerate cron settings/crontab file */
519
		configure_cron();
520
		sigkillbypid("{$g['varrun_path']}/cron.pid", "HUP");
521 58af5941 Scott Ullrich
      
522 15aea4cb Seth Mos
		conf_mount_ro();
523
		config_unlock();
524 58af5941 Scott Ullrich
		}
525 e2cd32df Scott Ullrich
526 5b237745 Scott Ullrich
		$retval = 0;
527 824edb6c Scott Ullrich
		$savemsg = get_std_save_message($retval);
528 5b237745 Scott Ullrich
	}
529
}
530 7f43ca88 Scott Ullrich
531 d88c6a9f Scott Ullrich
$pgtitle = array("Interfaces","WAN");
532 58af5941 Scott Ullrich
$closehead = false;
533 7f43ca88 Scott Ullrich
include("head.inc");
534
535 5b237745 Scott Ullrich
?>
536 7f43ca88 Scott Ullrich
537 58af5941 Scott Ullrich
<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 5b237745 Scott Ullrich
<!--
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 15aea4cb Seth Mos
			document.iform.pppoe_preset.disabled = 1;
575
			document.iform.pppoe_preset.checked = 0;
576
			Effect.Fade('presetwrap', { duration: 1.0 });
577 5b237745 Scott Ullrich
			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 15aea4cb Seth Mos
			document.iform.pppoe_preset.disabled = 1;
601
			document.iform.pppoe_preset.checked = 0;
602
			Effect.Fade('presetwrap', { duration: 1.0 });
603 5b237745 Scott Ullrich
			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 15aea4cb Seth Mos
			document.iform.pppoe_preset.disabled = 0;
631 5b237745 Scott Ullrich
			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 15aea4cb Seth Mos
			document.iform.pppoe_preset.disabled = 1;
655
			document.iform.pppoe_preset.checked = 0;
656
			Effect.Fade('presetwrap', { duration: 1.0 });			
657 5b237745 Scott Ullrich
			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 15aea4cb Seth Mos
			document.iform.pppoe_preset.disabled = 1;
685
			document.iform.pppoe_preset.checked = 0;
686
			Effect.Fade('presetwrap', { duration: 1.0 });
687 5b237745 Scott Ullrich
			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 15aea4cb Seth Mos
707
function show_mon_config() {
708
	document.getElementById("showmonbox").innerHTML='';
709
	aodiv = document.getElementById('showmon');
710
	aodiv.style.display = "block";
711
}
712
713 5b237745 Scott Ullrich
//-->
714
</script>
715 58af5941 Scott Ullrich
</head>
716 5b237745 Scott Ullrich
<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 e2cd32df Scott Ullrich
                <tr>
723 8fdc8744 Bill Marquette
                  <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 b5c78501 Seth Mos
                  <td class="vtable"> <select name="type" class="formselect" id="type" onchange="type_change()">
728 5b237745 Scott Ullrich
                      <?php $opts = split(" ", "Static DHCP PPPoE PPTP BigPond");
729
				foreach ($opts as $opt): ?>
730 e2cd32df Scott Ullrich
                      <option <?php if ($opt == $pconfig['type']) echo "selected";?>>
731 5b237745 Scott Ullrich
                      <?=htmlspecialchars($opt);?>
732
                      </option>
733
                      <?php endforeach; ?>
734
                    </select></td>
735
                </tr>
736 e2cd32df Scott Ullrich
                <tr>
737 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">MAC address</td>
738 b5c78501 Seth Mos
                  <td class="vtable"> <input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
739 1e694bee Scott Ullrich
		    <?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 b1c525ee Scott Ullrich
		    <a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#">Copy my MAC address</a>
745 1e694bee Scott Ullrich
		    <br>
746 e2cd32df Scott Ullrich
                    This field can be used to modify (&quot;spoof&quot;) the MAC
747 5b237745 Scott Ullrich
                    address of the WAN interface<br>
748
                    (may be required with some cable connections)<br>
749 e2cd32df Scott Ullrich
                    Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx
750 5b237745 Scott Ullrich
                    or leave blank</td>
751
                </tr>
752 e2cd32df Scott Ullrich
                <tr>
753 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">MTU</td>
754 b5c78501 Seth Mos
                  <td class="vtable"> <input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
755 5b237745 Scott Ullrich
                    <br>
756 e2cd32df Scott Ullrich
                    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 5b237745 Scott Ullrich
                    connection types will be assumed.</td>
761
                </tr>
762 e2cd32df Scott Ullrich
                <tr>
763 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
764
                </tr>
765 e2cd32df Scott Ullrich
                <tr>
766 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">Static IP configuration</td>
767 5b237745 Scott Ullrich
                </tr>
768 e2cd32df Scott Ullrich
                <tr>
769 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">IP address</td>
770 b5c78501 Seth Mos
                  <td class="vtable"> <input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
771 e2cd32df Scott Ullrich
                    /
772 b5c78501 Seth Mos
                    <select name="subnet" class="formselect" id="subnet">
773 fa3b333d Scott Ullrich
			<?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 5b237745 Scott Ullrich
                    </select></td>
783 a23d7248 Scott Ullrich
                </tr><?php if (isset($wancfg['ispointtopoint'])): ?>
784 7f5b4824 Scott Ullrich
                <tr>
785 a23d7248 Scott Ullrich
                  <td valign="top" class="vncellreq">Point-to-point IP address </td>
786
                  <td class="vtable">
787 b5c78501 Seth Mos
                    <input name="pointtopoint" type="text" class="formfld unknown" id="pointtopoint" size="20" value="<?=htmlspecialchars($pconfig['pointtopoint']);?>">
788 a23d7248 Scott Ullrich
                  </td>
789
                </tr><?php endif; ?>
790 e2cd32df Scott Ullrich
                <tr>
791 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Gateway</td>
792 d173230c Seth Mos
                  <td class="vtable"><select name="gateway" class="formselect" id="gateway">
793
			<?php
794 2be84cfa Seth Mos
			if(count($a_gateways) > 0) {
795
				foreach ($a_gateways as $gateway) {
796
					if($gateway['interface'] == "wan") {
797 d173230c Seth Mos
			?>
798
					<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
799
					<?=htmlspecialchars($gateway['name']);?>
800
					</option>
801
			<?php
802 2be84cfa Seth Mos
					}
803 d173230c Seth Mos
				}
804
			}
805
			?>
806 2be84cfa Seth Mos
			</select>Select a existing Gateway from the list or add one on the <a href="/system_gateways.php">Gateways</a> page<br>
807 5b237745 Scott Ullrich
                  </td>
808
                </tr>
809 e2cd32df Scott Ullrich
                <tr>
810 73c38fa2 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
811
                </tr>
812 e2cd32df Scott Ullrich
                <tr>
813 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">DHCP client configuration</td>
814 5b237745 Scott Ullrich
                </tr>
815 e2cd32df Scott Ullrich
                <tr>
816 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Hostname</td>
817 b5c78501 Seth Mos
                  <td class="vtable"> <input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
818 5b237745 Scott Ullrich
                    <br>
819 e2cd32df Scott Ullrich
                    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 5b237745 Scott Ullrich
                    this (for client identification).</td>
822
                </tr>
823 bc40d758 Seth Mos
                <tr>
824
                  <td width="100" valign="top" class="vncellreq">Alias IP address</td>
825 b5c78501 Seth Mos
                  <td class="vtable"> <input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
826 bc40d758 Seth Mos
                    <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 e2cd32df Scott Ullrich
                <tr>
841 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
842
                </tr>
843 e2cd32df Scott Ullrich
                <tr>
844 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">PPPoE configuration</td>
845 5b237745 Scott Ullrich
                </tr>
846 e2cd32df Scott Ullrich
                <tr>
847 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Username</td>
848 b5c78501 Seth Mos
                  <td class="vtable"><input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
849 5b237745 Scott Ullrich
                  </td>
850
                </tr>
851 e2cd32df Scott Ullrich
                <tr>
852 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Password</td>
853 239b93b3 Scott Ullrich
                  <td class="vtable"><input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
854 5b237745 Scott Ullrich
                  </td>
855
                </tr>
856 e2cd32df Scott Ullrich
                <tr>
857 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Service name</td>
858 b5c78501 Seth Mos
                  <td class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
859 e2cd32df Scott Ullrich
                    <br> <span class="vexpl">Hint: this field can usually be left
860 5b237745 Scott Ullrich
                    empty</span></td>
861
                </tr>
862 e2cd32df Scott Ullrich
                <tr>
863 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Dial on demand</td>
864 e2cd32df Scott Ullrich
                  <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 5b237745 Scott Ullrich
                    <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 b5c78501 Seth Mos
                    <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 5b237745 Scott Ullrich
                </tr>
874 58af5941 Scott Ullrich
                <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 e2cd32df Scott Ullrich
                <tr>
932 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
933
                </tr>
934 e2cd32df Scott Ullrich
                <tr>
935 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">PPTP configuration</td>
936 5b237745 Scott Ullrich
                </tr>
937 e2cd32df Scott Ullrich
                <tr>
938 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Username</td>
939 b5c78501 Seth Mos
                  <td class="vtable"><input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
940 5b237745 Scott Ullrich
                  </td>
941
                </tr>
942 e2cd32df Scott Ullrich
                <tr>
943 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Password</td>
944 b5c78501 Seth Mos
                  <td class="vtable"><input name="pptp_password" type="text" class="formfld pwd" id="pptp_password" size="20" 
945
value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
946 5b237745 Scott Ullrich
                  </td>
947
                </tr>
948 e2cd32df Scott Ullrich
                <tr>
949 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">Local IP address</td>
950 b5c78501 Seth Mos
                  <td class="vtable"> <input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20" 
951
value="<?=htmlspecialchars($pconfig['pptp_local']);?>">
952 e2cd32df Scott Ullrich
                    /
953 b5c78501 Seth Mos
                    <select name="pptp_subnet" class="formselect" id="pptp_subnet">
954 a23d7248 Scott Ullrich
                      <?php for ($i = 31; $i > 0; $i--): ?>
955 e2cd32df Scott Ullrich
                      <option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet']) echo "selected"; ?>>
956 5b237745 Scott Ullrich
                      <?=$i;?>
957
                      </option>
958
                      <?php endfor; ?>
959
                    </select></td>
960
                </tr>
961 e2cd32df Scott Ullrich
                <tr>
962 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">Remote IP address</td>
963 b5c78501 Seth Mos
                  <td class="vtable"> <input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote']);?>">
964 5b237745 Scott Ullrich
                  </td>
965
                </tr>
966 e2cd32df Scott Ullrich
                <tr>
967 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Dial on demand</td>
968 e2cd32df Scott Ullrich
                  <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 5b237745 Scott Ullrich
                    <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 b5c78501 Seth Mos
                    <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 5b237745 Scott Ullrich
                </tr>
978 e2cd32df Scott Ullrich
                <tr>
979 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
980
                </tr>
981 e2cd32df Scott Ullrich
                <tr>
982 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">BigPond Cable configuration</td>
983 5b237745 Scott Ullrich
                </tr>
984 e2cd32df Scott Ullrich
                <tr>
985 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Username</td>
986 b5c78501 Seth Mos
                  <td class="vtable"><input name="bigpond_username" type="text" class="formfld user" id="bigpond_username" size="20" value="<?=htmlspecialchars($pconfig['bigpond_username']);?>">
987 5b237745 Scott Ullrich
                  </td>
988
                </tr>
989 e2cd32df Scott Ullrich
                <tr>
990 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Password</td>
991 b5c78501 Seth Mos
                  <td class="vtable"><input name="bigpond_password" type="text" class="formfld pwd" id="bigpond_password" size="20" value="<?=htmlspecialchars($pconfig['bigpond_password']);?>">
992 5b237745 Scott Ullrich
                  </td>
993
                </tr>
994 e2cd32df Scott Ullrich
                <tr>
995 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Authentication server</td>
996 b5c78501 Seth Mos
                  <td class="vtable"><input name="bigpond_authserver" type="text" class="formfld unknown" id="bigpond_authserver" size="20" value="<?=htmlspecialchars($pconfig['bigpond_authserver']);?>">
997 5b237745 Scott Ullrich
                    <br>
998
                  <span class="vexpl">If this field is left empty, the default (&quot;dce-server&quot;) is used. </span></td>
999
                </tr>
1000 e2cd32df Scott Ullrich
                <tr>
1001 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Authentication domain</td>
1002 b5c78501 Seth Mos
                  <td class="vtable"><input name="bigpond_authdomain" type="text" class="formfld unknown" id="bigpond_authdomain" size="20" value="<?=htmlspecialchars($pconfig['bigpond_authdomain']);?>">
1003 5b237745 Scott Ullrich
                    <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 b5c78501 Seth Mos
                    <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 5b237745 Scott Ullrich
                </tr>
1013 da56c4d7 Scott Ullrich
                <tr>
1014
                  <td colspan="2" valign="top" height="16"></td>
1015
                </tr>
1016
                <tr>
1017 15aea4cb Seth Mos
                  <td colspan="2" valign="top" class="listtopic">Other</td>
1018 b1c525ee Scott Ullrich
                </tr>
1019 da56c4d7 Scott Ullrich
		<tr>
1020
			<td width="22%" valign="top" class="vncell">FTP Helper</td>
1021
			<td width="78%" class="vtable">
1022 0135299b Scott Ullrich
				<input name="disableftpproxy" type="checkbox" id="disableftpproxy" value="yes" <?php if ($pconfig['disableftpproxy']) echo "checked"; ?> onclick="enable_change(false)" />
1023 da56c4d7 Scott Ullrich
				<strong>Disable the userland FTP-Proxy application</strong>
1024
				<br />
1025
			</td>
1026
		</tr>
1027 fa3b333d Scott Ullrich
		        <?php
1028
				/* Wireless interface? */
1029 b7f01f59 Bill Marquette
				if (isset($wancfg['wireless']))
1030 5b237745 Scott Ullrich
					wireless_config_print();
1031 fa3b333d Scott Ullrich
			?>
1032 e2cd32df Scott Ullrich
                <tr>
1033 5b237745 Scott Ullrich
                  <td height="16" colspan="2" valign="top"></td>
1034
                </tr>
1035 e2cd32df Scott Ullrich
                <tr>
1036 5b237745 Scott Ullrich
                  <td valign="middle">&nbsp;</td>
1037 d9eeccbd Scott Ullrich
                  <td class="vtable"><a name="rfc1918"></a> <input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
1038 5b237745 Scott Ullrich
                    <strong>Block private networks</strong><br>
1039 e2cd32df Scott Ullrich
                    When set, this option blocks traffic from IP addresses that
1040 5b237745 Scott Ullrich
                    are reserved for private<br>
1041 e2cd32df Scott Ullrich
                    networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as
1042 5b237745 Scott Ullrich
                    well as loopback addresses<br>
1043 e2cd32df Scott Ullrich
                    (127/8). You should generally leave this option turned on,
1044 5b237745 Scott Ullrich
                    unless your WAN network<br>
1045
                    lies in such a private address space, too.</td>
1046
                </tr>
1047 ff1955ee Bill Marquette
                <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 c1ec2c2f Scott Ullrich
		</tr>
1055 b1c525ee Scott Ullrich
1056 e2cd32df Scott Ullrich
                <tr>
1057 5b237745 Scott Ullrich
                  <td width="100" valign="top">&nbsp;</td>
1058 e2cd32df Scott Ullrich
                  <td> &nbsp;<br> <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change_pptp(true)&&enable_change(true)">
1059 5b237745 Scott Ullrich
                  </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 e4e8c30f Scott Ullrich
1072
1073
<?php
1074
1075
if ($_POST) {
1076
1077
	if (!$input_errors) {
1078 b1c525ee Scott Ullrich
1079
		unlink_if_exists("{$g['tmp_path']}/config.cache");
1080
1081 2e70a096 Scott Ullrich
		ob_flush();
1082
		flush();
1083 b1c525ee Scott Ullrich
		sleep(1);
1084
1085 e4e8c30f Scott Ullrich
		interfaces_wan_configure();
1086 b1c525ee Scott Ullrich
1087 610b1136 Scott Ullrich
		reset_carp();
1088 b1c525ee Scott Ullrich
1089 e4e8c30f Scott Ullrich
		/* sync filter configuration */
1090
		filter_configure();
1091 8e11b23f Scott Ullrich
1092
 		/* set up static routes */
1093
		system_routing_configure();
1094
1095 e4e8c30f Scott Ullrich
	}
1096
}
1097
1098 8e11b23f Scott Ullrich
?>