Project

General

Profile

Download (47 KB) Statistics
| Branch: | Tag: | Revision:
1 e2cd32df Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	interfaces_wan.php
5 c3b3cd36 Scott Ullrich
        Copyright (C) 2004 Scott Ullrich
6
	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 8171fcd9 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
$wancfg = &$config['interfaces']['wan'];
72 8bb29531 Scott Ullrich
$optcfg = &$config['interfaces']['wan'];
73 5b237745 Scott Ullrich
74
$pconfig['username'] = $config['pppoe']['username'];
75
$pconfig['password'] = $config['pppoe']['password'];
76
$pconfig['provider'] = $config['pppoe']['provider'];
77 a23d7248 Scott Ullrich
$pconfig['pppoe_dialondemand'] = isset($config['pppoe']['ondemand']);
78 5b237745 Scott Ullrich
$pconfig['pppoe_idletimeout'] = $config['pppoe']['timeout'];
79
80 58af5941 Scott Ullrich
/* ================================================ */
81
/* = force a connection reset at a specific time? = */
82
/* ================================================ */
83
84
if (isset($wancfg['pppoe']['pppoe-reset-type'])) {
85
  $resetTime = getMPDResetTimeFromConfig();  
86
  $pconfig['pppoe_preset'] = true;
87
  
88
  if ($wancfg['pppoe']['pppoe-reset-type'] == "custom") {
89
    $resetTime_a = split(" ", $resetTime);
90
    $pconfig['pppoe_pr_custom'] = true;
91
    $pconfig['pppoe_resetminute'] = $resetTime_a[0];
92
    $pconfig['pppoe_resethour'] = $resetTime_a[1];
93
94
    /* just initialize $pconfig['pppoe_resetdate'] if the
95
     * coresponding item contains appropriate numeric values.
96
     */
97
    if ($resetTime_a[2] <> "*" && $resetTime_a[3] <> "*") {
98
      $pconfig['pppoe_resetdate'] = "{$resetTime_a[3]}/{$resetTime_a[2]}/" . date("Y");
99
    }
100
  } else if ($wancfg['pppoe']['pppoe-reset-type'] == "preset") {
101
    $pconfig['pppoe_pr_preset'] = true;
102
    
103
    switch ($resetTime) {
104
      case CRON_MONTHLY_PATTERN:
105
        $pconfig['pppoe_monthly'] = true;
106
        break;
107
      case CRON_WEEKLY_PATTERN:
108
        $pconfig['pppoe_weekly'] = true;
109
        break;
110
      case CRON_DAILY_PATTERN:
111
        $pconfig['pppoe_daily'] = true;
112
        break;
113
      case CRON_HOURLY_PATTERN:
114
        $pconfig['pppoe_hourly'] = true;
115
        break;
116
    }
117
  }
118
}
119
120 5b237745 Scott Ullrich
$pconfig['pptp_username'] = $config['pptp']['username'];
121
$pconfig['pptp_password'] = $config['pptp']['password'];
122
$pconfig['pptp_local'] = $config['pptp']['local'];
123
$pconfig['pptp_subnet'] = $config['pptp']['subnet'];
124
$pconfig['pptp_remote'] = $config['pptp']['remote'];
125 a23d7248 Scott Ullrich
$pconfig['pptp_dialondemand'] = isset($config['pptp']['ondemand']);
126 5b237745 Scott Ullrich
$pconfig['pptp_idletimeout'] = $config['pptp']['timeout'];
127
128 c1ec2c2f Scott Ullrich
$pconfig['disableftpproxy'] = isset($wancfg['disableftpproxy']);
129
130 5b237745 Scott Ullrich
$pconfig['bigpond_username'] = $config['bigpond']['username'];
131
$pconfig['bigpond_password'] = $config['bigpond']['password'];
132
$pconfig['bigpond_authserver'] = $config['bigpond']['authserver'];
133
$pconfig['bigpond_authdomain'] = $config['bigpond']['authdomain'];
134
$pconfig['bigpond_minheartbeatinterval'] = $config['bigpond']['minheartbeatinterval'];
135
136
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
137
138
if ($wancfg['ipaddr'] == "dhcp") {
139
	$pconfig['type'] = "DHCP";
140
} else if ($wancfg['ipaddr'] == "pppoe") {
141
	$pconfig['type'] = "PPPoE";
142
} else if ($wancfg['ipaddr'] == "pptp") {
143
	$pconfig['type'] = "PPTP";
144
} else if ($wancfg['ipaddr'] == "bigpond") {
145
	$pconfig['type'] = "BigPond";
146
} else {
147
	$pconfig['type'] = "Static";
148
	$pconfig['ipaddr'] = $wancfg['ipaddr'];
149
	$pconfig['subnet'] = $wancfg['subnet'];
150 588a183b Scott Ullrich
	$pconfig['gateway'] = $config['interfaces']['wan']['gateway'];
151 a23d7248 Scott Ullrich
	$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
152 5b237745 Scott Ullrich
}
153
154
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
155 ff1955ee Bill Marquette
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
156 5b237745 Scott Ullrich
$pconfig['spoofmac'] = $wancfg['spoofmac'];
157
$pconfig['mtu'] = $wancfg['mtu'];
158
159
/* Wireless interface? */
160 b7f01f59 Bill Marquette
if (isset($wancfg['wireless'])) {
161 5b237745 Scott Ullrich
	require("interfaces_wlan.inc");
162
	wireless_config_init();
163
}
164
165
if ($_POST) {
166
167
	unset($input_errors);
168
	$pconfig = $_POST;
169 58af5941 Scott Ullrich
  
170
  /* okay first of all, cause we are just hidding the PPPoE HTML
171
   * fields releated to PPPoE resets, we are going to unset $_POST
172
   * vars, if the reset feature should not be used. Otherwise the
173
   * data validation procedure below, may trigger a false error
174
   * message.
175
   */
176
  if (empty($_POST['pppoe_preset'])) {
177
    unset($_POST['pppoe_pr_type']);
178
    unset($_POST['pppoe_resethour']);
179
    unset($_POST['pppoe_resetminute']);
180
    unset($_POST['pppoe_resetdate']);
181
    unset($_POST['pppoe_pr_preset_val']);
182
    unlink_if_exists(CRON_PPPOE_CMD_FILE);
183
  }
184 5b237745 Scott Ullrich
185 ee968e4f Scott Ullrich
	if($_POST['gateway'] and $pconfig['gateway'] <> $_POST['gateway']) {
186 6fc5bf35 Scott Ullrich
		/* enumerate slbd gateways and make sure we are not creating a route loop */
187
		if(is_array($config['load_balancer']['lbpool'])) {
188
			foreach($config['load_balancer']['lbpool'] as $lbpool) {
189
				if($lbpool['type'] == "gateway") {
190
				    foreach ((array) $lbpool['servers'] as $server) {
191
			            $svr = split("\|", $server);
192 8bddc5b7 Scott Ullrich
			            if($svr[1] == $pconfig['gateway'])  {
193
			            		$_POST['gateway']  = $pconfig['gateway'];
194 de42a08e Scott Ullrich
			            		$input_errors[] = "Cannot change {$svr[1]} gateway.  It is currently referenced by the load balancer pools.";
195 8bddc5b7 Scott Ullrich
			            }
196 6fc5bf35 Scott Ullrich
					}
197
				}
198 8bddc5b7 Scott Ullrich
			}
199
			foreach($config['filter']['rule'] as $rule) {
200
				if($rule['gateway'] == $pconfig['gateway']) {
201
	            		$_POST['gateway']  = $pconfig['gateway'];
202
	            		$input_errors[] = "Cannot change {$svr[1]} gateway.  It is currently referenced by the filter rules via policy based routing.";
203
				}
204
			}
205 6fc5bf35 Scott Ullrich
		}
206
	}
207
208 5b237745 Scott Ullrich
	/* input validation */
209
	if ($_POST['type'] == "Static") {
210
		$reqdfields = explode(" ", "ipaddr subnet gateway");
211
		$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
212
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
213
	} else if ($_POST['type'] == "PPPoE") {
214
		if ($_POST['pppoe_dialondemand']) {
215
			$reqdfields = explode(" ", "username password pppoe_dialondemand pppoe_idletimeout");
216
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password,Dial on demand,Idle timeout value");
217
		} else {
218
			$reqdfields = explode(" ", "username password");
219
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password");
220
		}
221
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
222
	} else if ($_POST['type'] == "PPTP") {
223
		if ($_POST['pptp_dialondemand']) {
224
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
225
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address,Dial on demand,Idle timeout value");
226
		} else {
227
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
228
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address");
229
		}
230
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
231
	} else if ($_POST['type'] == "BigPond") {
232
		$reqdfields = explode(" ", "bigpond_username bigpond_password");
233
		$reqdfieldsn = explode(",", "BigPond username,BigPond password");
234
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
235
	}
236 e2cd32df Scott Ullrich
237 4f3401e0 Bill Marquette
        /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
238
        $_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
239
240 5b237745 Scott Ullrich
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
241
		$input_errors[] = "A valid IP address must be specified.";
242
	}
243
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
244
		$input_errors[] = "A valid subnet bit count must be specified.";
245
	}
246
	if (($_POST['gateway'] && !is_ipaddr($_POST['gateway']))) {
247
		$input_errors[] = "A valid gateway must be specified.";
248
	}
249 a23d7248 Scott Ullrich
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) {
250
		$input_errors[] = "A valid point-to-point IP address must be specified.";
251
	}
252 5b237745 Scott Ullrich
	if (($_POST['provider'] && !is_domain($_POST['provider']))) {
253
		$input_errors[] = "The service name contains invalid characters.";
254
	}
255 a23d7248 Scott Ullrich
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
256 5b237745 Scott Ullrich
		$input_errors[] = "The idle timeout value must be an integer.";
257
	}
258 58af5941 Scott Ullrich
  if ($_POST['pppoe_resethour'] <> "" && 
259
      !is_numericint($_POST['pppoe_resethour']) && 
260
    $_POST['pppoe_resethour'] >= 0 && 
261
    $_POST['pppoe_resethour'] <=23) {
262
    $input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
263
  }
264
  if ($_POST['pppoe_resetminute'] <> "" && 
265
      !is_numericint($_POST['pppoe_resetminute']) && 
266
    $_POST['pppoe_resetminute'] >= 0 && 
267
    $_POST['pppoe_resetminute'] <=59) {
268
    $input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
269
  }
270
  if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) {
271
    $input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
272
  }
273 5b237745 Scott Ullrich
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) {
274
		$input_errors[] = "A valid PPTP local IP address must be specified.";
275
	}
276
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) {
277
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
278
	}
279
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) {
280
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
281
	}
282 a23d7248 Scott Ullrich
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) {
283 5b237745 Scott Ullrich
		$input_errors[] = "The idle timeout value must be an integer.";
284
	}
285
	if (($_POST['bigpond_authserver'] && !is_domain($_POST['bigpond_authserver']))) {
286
		$input_errors[] = "The authentication server name contains invalid characters.";
287
	}
288
	if (($_POST['bigpond_authdomain'] && !is_domain($_POST['bigpond_authdomain']))) {
289
		$input_errors[] = "The authentication domain name contains invalid characters.";
290
	}
291
	if ($_POST['bigpond_minheartbeatinterval'] && !is_numericint($_POST['bigpond_minheartbeatinterval'])) {
292
		$input_errors[] = "The minimum heartbeat interval must be an integer.";
293
	}
294
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) {
295
		$input_errors[] = "A valid MAC address must be specified.";
296
	}
297
	if ($_POST['mtu'] && (($_POST['mtu'] < 576) || ($_POST['mtu'] > 1500))) {
298
		$input_errors[] = "The MTU must be between 576 and 1500 bytes.";
299
	}
300 e2cd32df Scott Ullrich
301 5b237745 Scott Ullrich
	/* Wireless interface? */
302 b7f01f59 Bill Marquette
	if (isset($wancfg['wireless'])) {
303 5b237745 Scott Ullrich
		$wi_input_errors = wireless_config_post();
304
		if ($wi_input_errors) {
305
			$input_errors = array_merge($input_errors, $wi_input_errors);
306
		}
307
	}
308
309
	if (!$input_errors) {
310 e2cd32df Scott Ullrich
311 9a6757a1 Scott Ullrich
		$bridge = discover_bridge($wancfg['if'], filter_translate_type_to_real_interface($wancfg['bridge']));
312 0d429e43 Scott Ullrich
		if($bridge <> "-1") {
313 1665e79c Scott Ullrich
			destroy_bridge($bridge);
314 91e8aab2 Scott Ullrich
		}
315 b1c525ee Scott Ullrich
316 5b237745 Scott Ullrich
		unset($wancfg['ipaddr']);
317
		unset($wancfg['subnet']);
318 588a183b Scott Ullrich
		unset($config['interfaces']['wan']['gateway']);
319 a23d7248 Scott Ullrich
		unset($wancfg['pointtopoint']);
320 5b237745 Scott Ullrich
		unset($wancfg['dhcphostname']);
321 58af5941 Scott Ullrich
    if (is_array($wancfg['pppoe'])) {
322
      unset($config['pppoe']['username']);
323
      unset($config['pppoe']['password']);
324
      unset($config['pppoe']['provider']);
325
      unset($config['pppoe']['ondemand']);
326
      unset($config['pppoe']['timeout']);
327
      unset($wancfg['pppoe']['pppoe-reset-type']);
328
    }
329
    if (is_array($wancfg['pptp'])) {
330
      unset($config['pptp']['username']);
331
      unset($config['pptp']['password']);
332
      unset($config['pptp']['local']);
333
      unset($config['pptp']['subnet']);
334
      unset($config['pptp']['remote']);
335
      unset($config['pptp']['ondemand']);
336
      unset($config['pptp']['timeout']);
337
    }
338 5b237745 Scott Ullrich
		unset($config['bigpond']['username']);
339
		unset($config['bigpond']['password']);
340
		unset($config['bigpond']['authserver']);
341
		unset($config['bigpond']['authdomain']);
342
		unset($config['bigpond']['minheartbeatinterval']);
343 c1ec2c2f Scott Ullrich
		unset($wancfg['disableftpproxy']);
344 b1c525ee Scott Ullrich
345 c1ec2c2f Scott Ullrich
		/* per interface pftpx helper */
346
		if($_POST['disableftpproxy'] == "yes") {
347
			$wancfg['disableftpproxy'] = true;
348
			system_start_ftp_helpers();
349 b1c525ee Scott Ullrich
		} else {
350 c1ec2c2f Scott Ullrich
			system_start_ftp_helpers();
351
		}
352 e2cd32df Scott Ullrich
353 5b237745 Scott Ullrich
		if ($_POST['type'] == "Static") {
354
			$wancfg['ipaddr'] = $_POST['ipaddr'];
355
			$wancfg['subnet'] = $_POST['subnet'];
356 588a183b Scott Ullrich
			$config['interfaces']['wan']['gateway'] = $_POST['gateway'];
357 a23d7248 Scott Ullrich
			if (isset($wancfg['ispointtopoint']))
358
				$wancfg['pointtopoint'] = $_POST['pointtopoint'];
359 5b237745 Scott Ullrich
		} else if ($_POST['type'] == "DHCP") {
360
			$wancfg['ipaddr'] = "dhcp";
361
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
362
		} else if ($_POST['type'] == "PPPoE") {
363
			$wancfg['ipaddr'] = "pppoe";
364
			$config['pppoe']['username'] = $_POST['username'];
365
			$config['pppoe']['password'] = $_POST['password'];
366
			$config['pppoe']['provider'] = $_POST['provider'];
367 a23d7248 Scott Ullrich
			$config['pppoe']['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
368 5b237745 Scott Ullrich
			$config['pppoe']['timeout'] = $_POST['pppoe_idletimeout'];
369 58af5941 Scott Ullrich
      
370
      /* perform a periodic reset? */
371
      if (isset($_POST['pppoe_preset'])) {
372
        if (! is_array($config['cron']['item'])) { $config['cron']['item'] = array(); }
373
374
        $itemhash = getMPDCRONSettings();
375
        $item = $itemhash['ITEM'];
376
377
        if (empty($item)) {
378
          $item = array();
379
        }
380
381
        if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] == "custom") {
382
          $wancfg['pppoe']['pppoe-reset-type'] = "custom";
383
          $pconfig['pppoe_pr_custom'] = true;
384
385
          $item['minute'] = $_POST['pppoe_resetminute'];
386
          $item['hour'] = $_POST['pppoe_resethour'];
387
388
          if (isset($_POST['pppoe_resetdate']) && 
389
              $_POST['pppoe_resetdate'] <> "" && 
390
              strlen($_POST['pppoe_resetdate']) == 10) {
391
            $date = explode("/", $_POST['pppoe_resetdate']);
392
393
            $item['mday'] = $date[1];
394
            $item['month'] = $date[0];
395
          } else {
396
            $item['mday'] = "*";
397
            $item['month'] = "*";
398
          }
399
400
          $item['wday'] = "*";
401
          $item['who'] = "root";
402
          $item['command'] = CRON_PPPOE_CMD_FILE;
403
        } else if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] = "preset") {
404
          $wancfg['pppoe']['pppoe-reset-type'] = "preset";
405
          $pconfig['pppoe_pr_preset'] = true;
406
407
          switch ($_POST['pppoe_pr_preset_val']) {
408
            case "monthly":
409
              $item['minute'] = "0";
410
              $item['hour'] = "0";
411
              $item['mday'] = "1";
412
              $item['month'] = "*";
413
              $item['wday'] = "*";
414
              $item['who'] = "root";
415
              $item['command'] = CRON_PPPOE_CMD_FILE;
416
              break;
417
            case "weekly":
418
              $item['minute'] = "0";
419
              $item['hour'] = "0";
420
              $item['mday'] = "*";
421
              $item['month'] = "*";
422
              $item['wday'] = "0";
423
              $item['who'] = "root";
424
              $item['command'] = CRON_PPPOE_CMD_FILE;
425
              break;
426
            case "daily":
427
              $item['minute'] = "0";
428
              $item['hour'] = "0";
429
              $item['mday'] = "*";
430
              $item['month'] = "*";
431
              $item['wday'] = "*";
432
              $item['who'] = "root";
433
              $item['command'] = CRON_PPPOE_CMD_FILE;
434
              break;
435
            case "hourly":
436
              $item['minute'] = "0";
437
              $item['hour'] = "*";
438
              $item['mday'] = "*";
439
              $item['month'] = "*";
440
              $item['wday'] = "*";
441
              $item['who'] = "root";
442
              $item['command'] = CRON_PPPOE_CMD_FILE;
443
              break;
444
          } // end switch
445
        } // end if
446
447
        if (isset($itemhash['ID'])) {
448
          $config['cron']['item'][$itemhash['ID']] = $item;
449
        } else {
450
          $config['cron']['item'][] = $item;
451
        }
452
      } // end if
453 5b237745 Scott Ullrich
		} else if ($_POST['type'] == "PPTP") {
454
			$wancfg['ipaddr'] = "pptp";
455
			$config['pptp']['username'] = $_POST['pptp_username'];
456
			$config['pptp']['password'] = $_POST['pptp_password'];
457
			$config['pptp']['local'] = $_POST['pptp_local'];
458
			$config['pptp']['subnet'] = $_POST['pptp_subnet'];
459
			$config['pptp']['remote'] = $_POST['pptp_remote'];
460 a23d7248 Scott Ullrich
			$config['pptp']['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
461 5b237745 Scott Ullrich
			$config['pptp']['timeout'] = $_POST['pptp_idletimeout'];
462
		} else if ($_POST['type'] == "BigPond") {
463
			$wancfg['ipaddr'] = "bigpond";
464
			$config['bigpond']['username'] = $_POST['bigpond_username'];
465
			$config['bigpond']['password'] = $_POST['bigpond_password'];
466
			$config['bigpond']['authserver'] = $_POST['bigpond_authserver'];
467
			$config['bigpond']['authdomain'] = $_POST['bigpond_authdomain'];
468
			$config['bigpond']['minheartbeatinterval'] = $_POST['bigpond_minheartbeatinterval'];
469
		}
470 58af5941 Scott Ullrich
    
471
    /* reset cron items if necessary */
472
    if (empty($_POST['pppoe_preset'])) {
473
      /* test whether a cron item exists and unset() it if necessary */
474
      $itemhash = getMPDCRONSettings();
475
      $item = $itemhash['ITEM'];
476
477
      if (isset($item)) { unset($config['cron']['item'][$itemhash['ID']]); }
478
    }
479 e2cd32df Scott Ullrich
480 90ebf755 Scott Ullrich
		if($_POST['blockpriv'] == "yes")
481
			$wancfg['blockpriv'] = true;
482
		else
483 42a58cb9 Scott Ullrich
			unset($wancfg['blockpriv']);
484 b1c525ee Scott Ullrich
485 90ebf755 Scott Ullrich
		if($_POST['blockbogons'] == "yes")
486
			$wancfg['blockbogons'] = true;
487
		else
488
			unset($wancfg['blockbogons']);
489 b1c525ee Scott Ullrich
490 5b237745 Scott Ullrich
		$wancfg['spoofmac'] = $_POST['spoofmac'];
491
		$wancfg['mtu'] = $_POST['mtu'];
492 e2cd32df Scott Ullrich
493 5b237745 Scott Ullrich
		write_config();
494 58af5941 Scott Ullrich
    
495
		/* finally install the pppoerestart file */
496
		if (isset($_POST['pppoe_preset'])) {
497
      config_lock();
498
      conf_mount_rw();
499
      
500
      if (! file_exists(CRON_PPPOE_CMD_FILE)) {
501
        file_put_contents(CRON_PPPOE_CMD_FILE, CRON_PPPOE_CMD);
502
        chmod(CRON_PPPOE_CMD_FILE, 0700);
503
      }
504
      
505
      /* regenerate cron settings/crontab file */
506
      configure_cron();
507
      sigkillbypid("{$g['varrun_path']}/cron.pid", "HUP");
508
      
509
      conf_mount_ro();
510
      config_unlock();
511
		}
512 e2cd32df Scott Ullrich
513 276a350f Scott Ullrich
514 5b237745 Scott Ullrich
		$retval = 0;
515 11a4b1a0 Scott Ullrich
516 824edb6c Scott Ullrich
		$savemsg = get_std_save_message($retval);
517 5b237745 Scott Ullrich
	}
518
}
519 7f43ca88 Scott Ullrich
520
$pgtitle = "Interfaces: WAN";
521 58af5941 Scott Ullrich
$closehead = false;
522 7f43ca88 Scott Ullrich
include("head.inc");
523
524 5b237745 Scott Ullrich
?>
525 7f43ca88 Scott Ullrich
526 58af5941 Scott Ullrich
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
527
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
528
529
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
530
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css" />
531
532
<script type="text/javascript" src="/javascript/scriptaculous/prototype.js"></script>
533
<script type="text/javascript" src="/javascript/scriptaculous/scriptaculous.js"></script>
534
535
<script type="text/javascript">
536 5b237745 Scott Ullrich
<!--
537
function enable_change(enable_change) {
538
	if (document.iform.pppoe_dialondemand.checked || enable_change) {
539
		document.iform.pppoe_idletimeout.disabled = 0;
540
	} else {
541
		document.iform.pppoe_idletimeout.disabled = 1;
542
	}
543
}
544
545
function enable_change_pptp(enable_change_pptp) {
546
	if (document.iform.pptp_dialondemand.checked || enable_change_pptp) {
547
		document.iform.pptp_idletimeout.disabled = 0;
548
		document.iform.pptp_local.disabled = 0;
549
		document.iform.pptp_remote.disabled = 0;
550
	} else {
551
		document.iform.pptp_idletimeout.disabled = 1;
552
	}
553
}
554
555
function type_change(enable_change,enable_change_pptp) {
556
	switch (document.iform.type.selectedIndex) {
557
		case 0:
558
			document.iform.username.disabled = 1;
559
			document.iform.password.disabled = 1;
560
			document.iform.provider.disabled = 1;
561
			document.iform.pppoe_dialondemand.disabled = 1;
562
			document.iform.pppoe_idletimeout.disabled = 1;
563 58af5941 Scott Ullrich
      document.iform.pppoe_preset.disabled = 1;
564
      document.iform.pppoe_preset.checked = 0;
565
      Effect.Fade('presetwrap', { duration: 1.0 });
566 5b237745 Scott Ullrich
			document.iform.ipaddr.disabled = 0;
567
			document.iform.subnet.disabled = 0;
568
			document.iform.gateway.disabled = 0;
569
			document.iform.pptp_username.disabled = 1;
570
			document.iform.pptp_password.disabled = 1;
571
			document.iform.pptp_local.disabled = 1;
572
			document.iform.pptp_subnet.disabled = 1;
573
			document.iform.pptp_remote.disabled = 1;
574
			document.iform.pptp_dialondemand.disabled = 1;
575
			document.iform.pptp_idletimeout.disabled = 1;
576
			document.iform.bigpond_username.disabled = 1;
577
			document.iform.bigpond_password.disabled = 1;
578
			document.iform.bigpond_authserver.disabled = 1;
579
			document.iform.bigpond_authdomain.disabled = 1;
580
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
581
			document.iform.dhcphostname.disabled = 1;
582
			break;
583
		case 1:
584
			document.iform.username.disabled = 1;
585
			document.iform.password.disabled = 1;
586
			document.iform.provider.disabled = 1;
587
			document.iform.pppoe_dialondemand.disabled = 1;
588
			document.iform.pppoe_idletimeout.disabled = 1;
589 58af5941 Scott Ullrich
      document.iform.pppoe_preset.disabled = 1;
590
      document.iform.pppoe_preset.checked = 0;
591
      Effect.Fade('presetwrap', { duration: 1.0 });
592 5b237745 Scott Ullrich
			document.iform.ipaddr.disabled = 1;
593
			document.iform.subnet.disabled = 1;
594
			document.iform.gateway.disabled = 1;
595
			document.iform.pptp_username.disabled = 1;
596
			document.iform.pptp_password.disabled = 1;
597
			document.iform.pptp_local.disabled = 1;
598
			document.iform.pptp_subnet.disabled = 1;
599
			document.iform.pptp_remote.disabled = 1;
600
			document.iform.pptp_dialondemand.disabled = 1;
601
			document.iform.pptp_idletimeout.disabled = 1;
602
			document.iform.bigpond_username.disabled = 1;
603
			document.iform.bigpond_password.disabled = 1;
604
			document.iform.bigpond_authserver.disabled = 1;
605
			document.iform.bigpond_authdomain.disabled = 1;
606
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
607
			document.iform.dhcphostname.disabled = 0;
608
			break;
609
		case 2:
610
			document.iform.username.disabled = 0;
611
			document.iform.password.disabled = 0;
612
			document.iform.provider.disabled = 0;
613
			document.iform.pppoe_dialondemand.disabled = 0;
614
			if (document.iform.pppoe_dialondemand.checked || enable_change) {
615
				document.iform.pppoe_idletimeout.disabled = 0;
616
			} else {
617
				document.iform.pppoe_idletimeout.disabled = 1;
618
			}
619 58af5941 Scott Ullrich
      document.iform.pppoe_preset.disabled = 0;
620 5b237745 Scott Ullrich
			document.iform.ipaddr.disabled = 1;
621
			document.iform.subnet.disabled = 1;
622
			document.iform.gateway.disabled = 1;
623
			document.iform.pptp_username.disabled = 1;
624
			document.iform.pptp_password.disabled = 1;
625
			document.iform.pptp_local.disabled = 1;
626
			document.iform.pptp_subnet.disabled = 1;
627
			document.iform.pptp_remote.disabled = 1;
628
			document.iform.pptp_dialondemand.disabled = 1;
629
			document.iform.pptp_idletimeout.disabled = 1;
630
			document.iform.bigpond_username.disabled = 1;
631
			document.iform.bigpond_password.disabled = 1;
632
			document.iform.bigpond_authserver.disabled = 1;
633
			document.iform.bigpond_authdomain.disabled = 1;
634
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
635
			document.iform.dhcphostname.disabled = 1;
636
			break;
637
		case 3:
638
			document.iform.username.disabled = 1;
639
			document.iform.password.disabled = 1;
640
			document.iform.provider.disabled = 1;
641
			document.iform.pppoe_dialondemand.disabled = 1;
642
			document.iform.pppoe_idletimeout.disabled = 1;
643 58af5941 Scott Ullrich
      document.iform.pppoe_preset.disabled = 1;
644
      document.iform.pppoe_preset.checked = 0;
645
      Effect.Fade('presetwrap', { duration: 1.0 });			
646 5b237745 Scott Ullrich
			document.iform.ipaddr.disabled = 1;
647
			document.iform.subnet.disabled = 1;
648
			document.iform.gateway.disabled = 1;
649
			document.iform.pptp_username.disabled = 0;
650
			document.iform.pptp_password.disabled = 0;
651
			document.iform.pptp_local.disabled = 0;
652
			document.iform.pptp_subnet.disabled = 0;
653
			document.iform.pptp_remote.disabled = 0;
654
			document.iform.pptp_dialondemand.disabled = 0;
655
			if (document.iform.pptp_dialondemand.checked || enable_change_pptp) {
656
				document.iform.pptp_idletimeout.disabled = 0;
657
			} else {
658
				document.iform.pptp_idletimeout.disabled = 1;
659
			}
660
			document.iform.bigpond_username.disabled = 1;
661
			document.iform.bigpond_password.disabled = 1;
662
			document.iform.bigpond_authserver.disabled = 1;
663
			document.iform.bigpond_authdomain.disabled = 1;
664
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
665
			document.iform.dhcphostname.disabled = 1;
666
			break;
667
		case 4:
668
			document.iform.username.disabled = 1;
669
			document.iform.password.disabled = 1;
670
			document.iform.provider.disabled = 1;
671
			document.iform.pppoe_dialondemand.disabled = 1;
672
			document.iform.pppoe_idletimeout.disabled = 1;
673 58af5941 Scott Ullrich
      document.iform.pppoe_preset.disabled = 1;
674
      document.iform.pppoe_preset.checked = 0;
675
      Effect.Fade('presetwrap', { duration: 1.0 });
676 5b237745 Scott Ullrich
			document.iform.ipaddr.disabled = 1;
677
			document.iform.subnet.disabled = 1;
678
			document.iform.gateway.disabled = 1;
679
			document.iform.pptp_username.disabled = 1;
680
			document.iform.pptp_password.disabled = 1;
681
			document.iform.pptp_local.disabled = 1;
682
			document.iform.pptp_subnet.disabled = 1;
683
			document.iform.pptp_remote.disabled = 1;
684
			document.iform.pptp_dialondemand.disabled = 1;
685
			document.iform.pptp_idletimeout.disabled = 1;
686
			document.iform.bigpond_username.disabled = 0;
687
			document.iform.bigpond_password.disabled = 0;
688
			document.iform.bigpond_authserver.disabled = 0;
689
			document.iform.bigpond_authdomain.disabled = 0;
690
			document.iform.bigpond_minheartbeatinterval.disabled = 0;
691
			document.iform.dhcphostname.disabled = 1;
692
			break;
693
	}
694
}
695
//-->
696
</script>
697 58af5941 Scott Ullrich
</head>
698 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
699
<?php include("fbegin.inc"); ?>
700 931066a8 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
701 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
702
<?php if ($savemsg) print_info_box($savemsg); ?>
703
            <form action="interfaces_wan.php" method="post" name="iform" id="iform">
704
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
705 e2cd32df Scott Ullrich
                <tr>
706 8fdc8744 Bill Marquette
                  <td colspan="2" valign="top" class="listtopic">General configuration</td>
707
                </tr>
708
                <tr>
709
                  <td valign="middle" class="vncell"><strong>Type</strong></td>
710
                  <td class="vtable"> <select name="type" class="formfld" id="type" onchange="type_change()">
711 5b237745 Scott Ullrich
                      <?php $opts = split(" ", "Static DHCP PPPoE PPTP BigPond");
712
				foreach ($opts as $opt): ?>
713 e2cd32df Scott Ullrich
                      <option <?php if ($opt == $pconfig['type']) echo "selected";?>>
714 5b237745 Scott Ullrich
                      <?=htmlspecialchars($opt);?>
715
                      </option>
716
                      <?php endforeach; ?>
717
                    </select></td>
718
                </tr>
719 e2cd32df Scott Ullrich
                <tr>
720 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">MAC address</td>
721 e2cd32df Scott Ullrich
                  <td class="vtable"> <input name="spoofmac" type="text" class="formfld" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
722 1e694bee Scott Ullrich
		    <?php
723
			$ip = getenv('REMOTE_ADDR');
724
			$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
725
			$mac = str_replace("\n","",$mac);
726
		    ?>
727 b1c525ee Scott Ullrich
		    <a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#">Copy my MAC address</a>
728 1e694bee Scott Ullrich
		    <br>
729 e2cd32df Scott Ullrich
                    This field can be used to modify (&quot;spoof&quot;) the MAC
730 5b237745 Scott Ullrich
                    address of the WAN interface<br>
731
                    (may be required with some cable connections)<br>
732 e2cd32df Scott Ullrich
                    Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx
733 5b237745 Scott Ullrich
                    or leave blank</td>
734
                </tr>
735 e2cd32df Scott Ullrich
                <tr>
736 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">MTU</td>
737 e2cd32df Scott Ullrich
                  <td class="vtable"> <input name="mtu" type="text" class="formfld" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
738 5b237745 Scott Ullrich
                    <br>
739 e2cd32df Scott Ullrich
                    If you enter a value in this field, then MSS clamping for
740
                    TCP connections to the value entered above minus 40 (TCP/IP
741
                    header size) will be in effect. If you leave this field blank,
742
                    an MTU of 1492 bytes for PPPoE and 1500 bytes for all other
743 5b237745 Scott Ullrich
                    connection types will be assumed.</td>
744
                </tr>
745 e2cd32df Scott Ullrich
                <tr>
746 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
747
                </tr>
748 e2cd32df Scott Ullrich
                <tr>
749 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">Static IP configuration</td>
750 5b237745 Scott Ullrich
                </tr>
751 e2cd32df Scott Ullrich
                <tr>
752 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">IP address</td>
753
                  <td class="vtable"> <input name="ipaddr" type="text" class="formfld" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
754 e2cd32df Scott Ullrich
                    /
755 5b237745 Scott Ullrich
                    <select name="subnet" class="formfld" id="subnet">
756 fa3b333d Scott Ullrich
			<?php
757
			for ($i = 32; $i > 0; $i--) {
758
				if($i <> 31) {
759
					echo "<option value=\"{$i}\" ";
760
					if ($i == $pconfig['subnet']) echo "selected";
761
					echo ">" . $i . "</option>";
762
				}
763
			}
764
			?>
765 5b237745 Scott Ullrich
                    </select></td>
766 a23d7248 Scott Ullrich
                </tr><?php if (isset($wancfg['ispointtopoint'])): ?>
767 7f5b4824 Scott Ullrich
                <tr>
768 a23d7248 Scott Ullrich
                  <td valign="top" class="vncellreq">Point-to-point IP address </td>
769
                  <td class="vtable">
770
                    <input name="pointtopoint" type="text" class="formfld" id="pointtopoint" size="20" value="<?=htmlspecialchars($pconfig['pointtopoint']);?>">
771
                  </td>
772
                </tr><?php endif; ?>
773 e2cd32df Scott Ullrich
                <tr>
774 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Gateway</td>
775 e2cd32df Scott Ullrich
                  <td class="vtable"> <input name="gateway" type="text" class="formfld" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>">
776 5b237745 Scott Ullrich
                  </td>
777
                </tr>
778 e2cd32df Scott Ullrich
                <tr>
779 73c38fa2 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
780
                </tr>
781 e2cd32df Scott Ullrich
                <tr>
782 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">DHCP client configuration</td>
783 5b237745 Scott Ullrich
                </tr>
784 e2cd32df Scott Ullrich
                <tr>
785 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Hostname</td>
786
                  <td class="vtable"> <input name="dhcphostname" type="text" class="formfld" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
787
                    <br>
788 e2cd32df Scott Ullrich
                    The value in this field is sent as the DHCP client identifier
789
                    and hostname when requesting a DHCP lease. Some ISPs may require
790 5b237745 Scott Ullrich
                    this (for client identification).</td>
791
                </tr>
792 e2cd32df Scott Ullrich
                <tr>
793 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
794
                </tr>
795 e2cd32df Scott Ullrich
                <tr>
796 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">PPPoE configuration</td>
797 5b237745 Scott Ullrich
                </tr>
798 e2cd32df Scott Ullrich
                <tr>
799 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Username</td>
800 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="username" type="text" class="formfld" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
801 5b237745 Scott Ullrich
                  </td>
802
                </tr>
803 e2cd32df Scott Ullrich
                <tr>
804 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Password</td>
805 8ea9996c Scott Ullrich
                  <td class="vtable"><input name="password" type="password" class="formfld" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
806 5b237745 Scott Ullrich
                  </td>
807
                </tr>
808 e2cd32df Scott Ullrich
                <tr>
809 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Service name</td>
810 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="provider" type="text" class="formfld" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
811
                    <br> <span class="vexpl">Hint: this field can usually be left
812 5b237745 Scott Ullrich
                    empty</span></td>
813
                </tr>
814 e2cd32df Scott Ullrich
                <tr>
815 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Dial on demand</td>
816 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)" >
817 5b237745 Scott Ullrich
                    <strong>Enable Dial-On-Demand mode</strong><br>
818
		    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>
819
                </tr>
820
                <tr>
821
                  <td valign="top" class="vncell">Idle timeout</td>
822
                  <td class="vtable">
823 fa3b333d Scott Ullrich
                    <input name="pppoe_idletimeout" type="text" class="formfld" id="pppoe_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pppoe_idletimeout']);?>"> 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>
824 5b237745 Scott Ullrich
                </tr>
825 58af5941 Scott Ullrich
                <tr>
826
                  <td valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
827
                  <td class="vtable">
828
                    <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 });" />
829
                    <?= gettext("enable periodic PPPoE resets"); ?>
830
                    <br />
831
                    <?php if ($pconfig['pppoe_preset']): ?>
832
                    <table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
833
                    <?php else: ?>
834
                    <table id="presetwrap" cellspacing="0" cellpadding="0" width="100%" style="display: none;">
835
                    <?php endif; ?>
836
                      <tr>
837
                        <td align="left" valign="top">
838
                          <p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
839
                            <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 }); }" /> 
840
                            <?= gettext("provide a custom reset time"); ?>
841
                            <br />
842
                            <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 }); }" /> 
843
                            <?= gettext("select reset time from a preset"); ?>
844
                          </p>
845
                          <?php if ($pconfig['pppoe_pr_custom']): ?>
846
                          <p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
847
                          <?php else: ?>
848
                          <p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
849
                          <?php endif; ?>
850
                            <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" /> 
851
                            <?= gettext("hour (0-23)"); ?><br />
852
                            <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" /> 
853
                            <?= gettext("minute (0-59)"); ?><br />
854
                            <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']);?>" /> 
855
                            <?= gettext("reset at a specific date (mm/dd/yyyy)"); ?>
856
                            <br />&nbsp;<br />
857
                            <span class="red"><strong>Note: </strong></span>
858
                            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.
859
                          </p>
860
                          <?php if ($pconfig['pppoe_pr_preset']): ?>
861
                          <p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
862
                          <?php else: ?>
863
                          <p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
864
                          <?php endif; ?>
865
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> /> 
866
                            <?= gettext("reset at each month ('0 0 1 * *')"); ?>
867
                            <br />
868
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> /> 
869
                            <?= gettext("reset at each week ('0 0 * * 0')"); ?>
870
                            <br />
871
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> /> 
872
                            <?= gettext("reset at each day ('0 0 * * *')"); ?>
873
                            <br />
874
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> /> 
875
                            <?= gettext("reset at each hour ('0 * * * *')"); ?>
876
                          </p>
877
                        </td>
878
                      </tr>
879
                    </table>
880
                  </td>
881
                </tr>                
882 e2cd32df Scott Ullrich
                <tr>
883 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
884
                </tr>
885 e2cd32df Scott Ullrich
                <tr>
886 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">PPTP configuration</td>
887 5b237745 Scott Ullrich
                </tr>
888 e2cd32df Scott Ullrich
                <tr>
889 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Username</td>
890 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="pptp_username" type="text" class="formfld" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
891 5b237745 Scott Ullrich
                  </td>
892
                </tr>
893 e2cd32df Scott Ullrich
                <tr>
894 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Password</td>
895 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="pptp_password" type="text" class="formfld" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
896 5b237745 Scott Ullrich
                  </td>
897
                </tr>
898 e2cd32df Scott Ullrich
                <tr>
899 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">Local IP address</td>
900
                  <td class="vtable"> <input name="pptp_local" type="text" class="formfld" id="pptp_local" size="20" value="<?=htmlspecialchars($pconfig['pptp_local']);?>">
901 e2cd32df Scott Ullrich
                    /
902 5b237745 Scott Ullrich
                    <select name="pptp_subnet" class="formfld" id="pptp_subnet">
903 a23d7248 Scott Ullrich
                      <?php for ($i = 31; $i > 0; $i--): ?>
904 e2cd32df Scott Ullrich
                      <option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet']) echo "selected"; ?>>
905 5b237745 Scott Ullrich
                      <?=$i;?>
906
                      </option>
907
                      <?php endfor; ?>
908
                    </select></td>
909
                </tr>
910 e2cd32df Scott Ullrich
                <tr>
911 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">Remote IP address</td>
912 e2cd32df Scott Ullrich
                  <td class="vtable"> <input name="pptp_remote" type="text" class="formfld" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote']);?>">
913 5b237745 Scott Ullrich
                  </td>
914
                </tr>
915 e2cd32df Scott Ullrich
                <tr>
916 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Dial on demand</td>
917 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)" >
918 5b237745 Scott Ullrich
                    <strong>Enable Dial-On-Demand mode</strong><br>
919
		    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>
920
                </tr>
921
                <tr>
922
                  <td valign="top" class="vncell">Idle timeout</td>
923
                  <td class="vtable">
924 fa3b333d Scott Ullrich
                    <input name="pptp_idletimeout" type="text" class="formfld" id="pptp_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pptp_idletimeout']);?>"> 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>
925 5b237745 Scott Ullrich
                </tr>
926 e2cd32df Scott Ullrich
                <tr>
927 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
928
                </tr>
929 e2cd32df Scott Ullrich
                <tr>
930 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">BigPond Cable configuration</td>
931 5b237745 Scott Ullrich
                </tr>
932 e2cd32df Scott Ullrich
                <tr>
933 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Username</td>
934 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="bigpond_username" type="text" class="formfld" id="bigpond_username" size="20" value="<?=htmlspecialchars($pconfig['bigpond_username']);?>">
935 5b237745 Scott Ullrich
                  </td>
936
                </tr>
937 e2cd32df Scott Ullrich
                <tr>
938 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Password</td>
939 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="bigpond_password" type="text" class="formfld" id="bigpond_password" size="20" value="<?=htmlspecialchars($pconfig['bigpond_password']);?>">
940 5b237745 Scott Ullrich
                  </td>
941
                </tr>
942 e2cd32df Scott Ullrich
                <tr>
943 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Authentication server</td>
944
                  <td class="vtable"><input name="bigpond_authserver" type="text" class="formfld" id="bigpond_authserver" size="20" value="<?=htmlspecialchars($pconfig['bigpond_authserver']);?>">
945
                    <br>
946
                  <span class="vexpl">If this field is left empty, the default (&quot;dce-server&quot;) is used. </span></td>
947
                </tr>
948 e2cd32df Scott Ullrich
                <tr>
949 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Authentication domain</td>
950
                  <td class="vtable"><input name="bigpond_authdomain" type="text" class="formfld" id="bigpond_authdomain" size="20" value="<?=htmlspecialchars($pconfig['bigpond_authdomain']);?>">
951
                    <br>
952
                  <span class="vexpl">If this field is left empty, the domain name assigned via DHCP will be used.<br>
953
                  <br>
954
                  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>
955
                </tr>
956
                <tr>
957
                  <td valign="top" class="vncell">Min. heartbeat interval</td>
958
                  <td class="vtable">
959 fa3b333d Scott Ullrich
                    <input name="bigpond_minheartbeatinterval" type="text" class="formfld" 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>
960 5b237745 Scott Ullrich
                </tr>
961 da56c4d7 Scott Ullrich
                <tr>
962
                  <td colspan="2" valign="top" height="16"></td>
963
                </tr>
964
                <tr>
965
                  <td colspan="2" valign="top" class="listtopic">FTP Helper</td>
966 b1c525ee Scott Ullrich
                </tr>
967 da56c4d7 Scott Ullrich
		<tr>
968
			<td width="22%" valign="top" class="vncell">FTP Helper</td>
969
			<td width="78%" class="vtable">
970 0135299b Scott Ullrich
				<input name="disableftpproxy" type="checkbox" id="disableftpproxy" value="yes" <?php if ($pconfig['disableftpproxy']) echo "checked"; ?> onclick="enable_change(false)" />
971 da56c4d7 Scott Ullrich
				<strong>Disable the userland FTP-Proxy application</strong>
972
				<br />
973
			</td>
974
		</tr>
975 fa3b333d Scott Ullrich
		        <?php
976
				/* Wireless interface? */
977 b7f01f59 Bill Marquette
				if (isset($wancfg['wireless']))
978 5b237745 Scott Ullrich
					wireless_config_print();
979 fa3b333d Scott Ullrich
			?>
980 e2cd32df Scott Ullrich
                <tr>
981 5b237745 Scott Ullrich
                  <td height="16" colspan="2" valign="top"></td>
982
                </tr>
983 e2cd32df Scott Ullrich
                <tr>
984 5b237745 Scott Ullrich
                  <td valign="middle">&nbsp;</td>
985 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"; ?>>
986 5b237745 Scott Ullrich
                    <strong>Block private networks</strong><br>
987 e2cd32df Scott Ullrich
                    When set, this option blocks traffic from IP addresses that
988 5b237745 Scott Ullrich
                    are reserved for private<br>
989 e2cd32df Scott Ullrich
                    networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as
990 5b237745 Scott Ullrich
                    well as loopback addresses<br>
991 e2cd32df Scott Ullrich
                    (127/8). You should generally leave this option turned on,
992 5b237745 Scott Ullrich
                    unless your WAN network<br>
993
                    lies in such a private address space, too.</td>
994
                </tr>
995 ff1955ee Bill Marquette
                <tr>
996
                  <td valign="middle">&nbsp;</td>
997
                  <td class="vtable"> <input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
998
                    <strong>Block bogon networks</strong><br>
999
                    When set, this option blocks traffic from IP addresses that
1000
                    are reserved (but not RFC 1918) or not yet assigned by IANA.<br>
1001
                    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>
1002 c1ec2c2f Scott Ullrich
		</tr>
1003 b1c525ee Scott Ullrich
1004 e2cd32df Scott Ullrich
                <tr>
1005 5b237745 Scott Ullrich
                  <td width="100" valign="top">&nbsp;</td>
1006 e2cd32df Scott Ullrich
                  <td> &nbsp;<br> <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change_pptp(true)&&enable_change(true)">
1007 5b237745 Scott Ullrich
                  </td>
1008
                </tr>
1009
              </table>
1010
</form>
1011
<script language="JavaScript">
1012
<!--
1013
type_change();
1014
//-->
1015
</script>
1016
<?php include("fend.inc"); ?>
1017
</body>
1018
</html>
1019 e4e8c30f Scott Ullrich
1020
1021
<?php
1022
1023
if ($_POST) {
1024
1025
	if (!$input_errors) {
1026 b1c525ee Scott Ullrich
1027
		unlink_if_exists("{$g['tmp_path']}/config.cache");
1028
1029 2e70a096 Scott Ullrich
		ob_flush();
1030
		flush();
1031 b1c525ee Scott Ullrich
		sleep(1);
1032
1033 e4e8c30f Scott Ullrich
		interfaces_wan_configure();
1034 b1c525ee Scott Ullrich
1035 610b1136 Scott Ullrich
		reset_carp();
1036 b1c525ee Scott Ullrich
1037 e4e8c30f Scott Ullrich
		/* sync filter configuration */
1038
		filter_configure();
1039 276a350f Scott Ullrich
1040
 		/* set up static routes */
1041
		system_routing_configure();
1042
1043 e4e8c30f Scott Ullrich
	}
1044
}
1045
1046 276a350f Scott Ullrich
?>