Project

General

Profile

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