Project

General

Profile

Download (46.1 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces_wan.php
5
        Copyright (C) 2007 Scott Ullrich
6
	All rights reserved.
7

    
8
	originally part of m0n0wall (http://m0n0.ch/wall)
9
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11

    
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14

    
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17

    
18
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21

    
22
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33

    
34
##|+PRIV
35
##|*IDENT=page-interfaces-wan
36
##|*NAME=Interfaces: WAN page
37
##|*DESCR=Allow access to the 'Interfaces: WAN' page.
38
##|*MATCH=interfaces_wan.php*
39
##|-PRIV
40

    
41
if ($_REQUEST['if'])
42
	$if = $_REQUEST['if'];
43
else
44
	$if = "wan";
45

    
46
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
47
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
48
define("CRON_DAILY_PATTERN", "0 0 * * *");
49
define("CRON_HOURLY_PATTERN", "0 * * * *");
50
define("CRON_PPPOE_CMD_FILE", "/etc/pppoerestart");
51
define("CRON_PPPOE_CMD", "#!/bin/sh\necho '<?php require(\"interfaces.inc\"); interfaces_wan_pppoe_restart($if); services_dyndns_reset($if); ?>' | /usr/local/bin/php -q");
52

    
53
function getMPDCRONSettings() {
54
  global $config;
55

    
56
  if (is_array($config['cron']['item'])) {
57
    for ($i = 0; $i < count($config['cron']['item']); $i++) {
58
      $item =& $config['cron']['item'][$i];
59

    
60
      if (strpos($item['command'], CRON_PPPOE_CMD_FILE) !== false) {
61
        return array("ID" => $i, "ITEM" => $item);
62
      }
63
    }
64
  }
65

    
66
  return NULL;
67
}
68

    
69
function getMPDResetTimeFromConfig() {
70
  $itemhash = getMPDCRONSettings();
71
  $cronitem = $itemhash['ITEM'];
72

    
73
  if (isset($cronitem)) {
74

    
75
    return "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
76
  } else {
77
    return NULL;
78
  }
79
}
80

    
81
function remove_bad_chars($string) {
82
        return preg_replace('/[^a-z|_|0-9]/i','',$string);
83
}
84

    
85
require("guiconfig.inc");
86

    
87
if (!is_array($config['gateways']['gateway_item']))
88
	$config['gateways']['gateway_item'] = array();
89
$a_gateways = &$config['gateways']['gateway_item'];
90

    
91
$wancfg = &$config['interfaces'][$if];
92

    
93
$pconfig['username'] = $wancfg['username'];
94
$pconfig['password'] = $wancfg['password'];
95
$pconfig['provider'] = $wancfg['provider'];
96
$pconfig['pppoe_dialondemand'] = isset($wancfg['ondemand']);
97
$pconfig['pppoe_idletimeout'] = $wancfg['timeout'];
98

    
99
/* ================================================ */
100
/* = force a connection reset at a specific time? = */
101
/* ================================================ */
102

    
103
if (isset($wancfg['pppoe']['pppoe-reset-type'])) {
104
  $resetTime = getMPDResetTimeFromConfig();  
105
  $pconfig['pppoe_preset'] = true;
106
  
107
  if ($wancfg['pppoe']['pppoe-reset-type'] == "custom") {
108
    $resetTime_a = split(" ", $resetTime);
109
    $pconfig['pppoe_pr_custom'] = true;
110
    $pconfig['pppoe_resetminute'] = $resetTime_a[0];
111
    $pconfig['pppoe_resethour'] = $resetTime_a[1];
112

    
113
    /* just initialize $pconfig['pppoe_resetdate'] if the
114
     * coresponding item contains appropriate numeric values.
115
     */
116
    if ($resetTime_a[2] <> "*" && $resetTime_a[3] <> "*") {
117
      $pconfig['pppoe_resetdate'] = "{$resetTime_a[3]}/{$resetTime_a[2]}/" . date("Y");
118
    }
119
  } else if ($wancfg['pppoe']['pppoe-reset-type'] == "preset") {
120
    $pconfig['pppoe_pr_preset'] = true;
121
    
122
    switch ($resetTime) {
123
      case CRON_MONTHLY_PATTERN:
124
        $pconfig['pppoe_monthly'] = true;
125
        break;
126
      case CRON_WEEKLY_PATTERN:
127
        $pconfig['pppoe_weekly'] = true;
128
        break;
129
      case CRON_DAILY_PATTERN:
130
        $pconfig['pppoe_daily'] = true;
131
        break;
132
      case CRON_HOURLY_PATTERN:
133
        $pconfig['pppoe_hourly'] = true;
134
        break;
135
    }
136
  }
137
}
138

    
139
$pconfig['pptp_username'] = $wancfg['username'];
140
$pconfig['pptp_password'] = $wancfg['password'];
141
$pconfig['pptp_local'] = $wancfg['local'];
142
$pconfig['pptp_subnet'] = $wancfg['subnet'];
143
$pconfig['pptp_remote'] = $wancfg['remote'];
144
$pconfig['pptp_dialondemand'] = isset($wancfg['ondemand']);
145
$pconfig['pptp_idletimeout'] = $wancfg['timeout'];
146

    
147
$pconfig['disableftpproxy'] = isset($wancfg['disableftpproxy']);
148

    
149
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
150
$pconfig['alias-address'] = $wancfg['alias-address'];
151
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
152
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
153
$pconfig['enable'] = isset($wancfg['enable']);
154

    
155
if (is_array($config['aliases']['alias']))
156
foreach($config['aliases']['alias'] as $alias)
157
        if($alias['name'] == $wancfg['descr'])
158
                $input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} a
159
lready exists.");
160

    
161
if ($wancfg['ipaddr'] == "dhcp") {
162
	$pconfig['type'] = "DHCP";
163
} else if ($wancfg['ipaddr'] == "carpdev-dhcp") {
164
	$pconfig['type'] = "CarpDEV-DHCP";
165
	$pconfig['ipaddr'] = "";	    
166
} else if ($wancfg['ipaddr'] == "pppoe") {
167
	$pconfig['type'] = "PPPoE";
168
} else if ($wancfg['ipaddr'] == "pptp") {
169
	$pconfig['type'] = "PPTP";
170
} else {
171
	$pconfig['type'] = "Static";
172
	$pconfig['ipaddr'] = $wancfg['ipaddr'];
173
	$pconfig['subnet'] = $wancfg['subnet'];
174
	$pconfig['gateway'] = $wancfg['gateway'];
175
	$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
176
}
177

    
178
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
179
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
180
$pconfig['spoofmac'] = $wancfg['spoofmac'];
181
$pconfig['mtu'] = $wancfg['mtu'];
182

    
183
/* Wireless interface? */
184
if (isset($wancfg['wireless'])) {
185
	require("interfaces_wlan.inc");
186
	wireless_config_init($wancfg);
187
}
188

    
189
if ($_POST) {
190

    
191
	unset($input_errors);
192
	$pconfig = $_POST;
193
  
194
	/* filter out spaces from descriptions  */
195
        $_POST['descr'] = remove_bad_chars($_POST['descr']);
196

    
197
	if ($_POST['enable'] || $if == "wan") {
198
		/* optional interface if list */
199
                $iflist = get_configured_interface_with_descr(true);
200

    
201
                /* description unique? */
202
                foreach ($iflist as $ifent => $ifdescr) {
203
                        if ($if != $ifent && $ifdescr == $_POST['descr'])
204
                                $input_errors[] = "An interface with the specified descriptio
205
n already exists.";
206
                }
207

    
208
	/* okay first of all, cause we are just hidding the PPPoE HTML
209
	 * fields releated to PPPoE resets, we are going to unset $_POST
210
	 * vars, if the reset feature should not be used. Otherwise the
211
	 * data validation procedure below, may trigger a false error
212
	 * message.
213
	 */
214
	if (empty($_POST['pppoe_preset'])) {
215
		unset($_POST['pppoe_pr_type']);
216
		unset($_POST['pppoe_resethour']);
217
		unset($_POST['pppoe_resetminute']);
218
		unset($_POST['pppoe_resetdate']);
219
		unset($_POST['pppoe_pr_preset_val']);
220
		unlink_if_exists(CRON_PPPOE_CMD_FILE);
221
	}
222

    
223
	if($_POST['gateway'] and $pconfig['gateway'] <> $_POST['gateway']) {
224
		/* enumerate slbd gateways and make sure we are not creating a route loop */
225
		if(is_array($config['load_balancer']['lbpool'])) {
226
			foreach($config['load_balancer']['lbpool'] as $lbpool) {
227
				if($lbpool['type'] == "gateway") {
228
				    foreach ((array) $lbpool['servers'] as $server) {
229
			            $svr = split("\|", $server);
230
			            if($svr[1] == $pconfig['gateway'])  {
231
			            		$_POST['gateway']  = $pconfig['gateway'];
232
			            		$input_errors[] = "Cannot change {$svr[1]} gateway.  It is currently referenced by the load balancer pools.";
233
			            }
234
					}
235
				}
236
			}
237
			foreach($config['filter']['rule'] as $rule) {
238
				if($rule['gateway'] == $pconfig['gateway']) {
239
	            		$_POST['gateway']  = $pconfig['gateway'];
240
	            		$input_errors[] = "Cannot change {$svr[1]} gateway.  It is currently referenced by the filter rules via policy based routing.";
241
				}
242
			}
243
		}
244
	}
245

    
246
	/* input validation */
247
	if ($_POST['type'] == "Static") {
248
		if ($if == "wan") {
249
			$reqdfields = explode(" ", "ipaddr subnet gateway");
250
			$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
251
		} else  {
252
			$reqdfields = explode(" ", "ipaddr subnet");
253
                        $reqdfieldsn = explode(",", "IP address,Subnet bit count");
254
		}
255
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
256
	} else if ($_POST['type'] == "PPPoE") {
257
		if ($_POST['pppoe_dialondemand']) {
258
			$reqdfields = explode(" ", "username password pppoe_dialondemand pppoe_idletimeout");
259
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password,Dial on demand,Idle timeout value");
260
		} else {
261
			$reqdfields = explode(" ", "username password");
262
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password");
263
		}
264
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
265
	} else if ($_POST['type'] == "PPTP") {
266
		if ($_POST['pptp_dialondemand']) {
267
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
268
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address,Dial on demand,Idle timeout value");
269
		} else {
270
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
271
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address");
272
		}
273
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
274
	}
275

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

    
279
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
280
		$input_errors[] = "A valid IP address must be specified.";
281
	}
282
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
283
		$input_errors[] = "A valid subnet bit count must be specified.";
284
	}
285
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) {
286
		$input_errors[] = "A valid alias IP address must be specified.";
287
	}
288
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) {
289
		$input_errors[] = "A valid alias subnet bit count must be specified.";
290
	}
291
	if ($_POST['gateway']) {
292
		$match = false;
293
		foreach($a_gateways as $gateway) {
294
			if(in_array($_POST['gateway'], $gateway)) {
295
				$match = true;
296
			}
297
		}
298
		if(!$match)
299
			$input_errors[] = "A valid gateway must be specified.";
300
	}
301
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) {
302
		$input_errors[] = "A valid point-to-point IP address must be specified.";
303
	}
304
	if (($_POST['provider'] && !is_domain($_POST['provider']))) {
305
		$input_errors[] = "The service name contains invalid characters.";
306
	}
307
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
308
		$input_errors[] = "The idle timeout value must be an integer.";
309
	}
310
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) && 
311
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) {
312
		$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
313
	}
314
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) && 
315
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) {
316
		$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
317
	}
318
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) {
319
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
320
	}
321
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) {
322
		$input_errors[] = "A valid PPTP local IP address must be specified.";
323
	}
324
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) {
325
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
326
	}
327
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) {
328
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
329
	}
330
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) {
331
		$input_errors[] = "The idle timeout value must be an integer.";
332
	}
333
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) {
334
		$input_errors[] = "A valid MAC address must be specified.";
335
	}
336
	if ($_POST['mtu'] && ($_POST['mtu'] < 576)) {
337
		$input_errors[] = "The MTU must be greater than 576 bytes.";
338
	}
339
	}
340

    
341
	/* Wireless interface? */
342
	if (isset($wancfg['wireless'])) {
343
		$wi_input_errors = wireless_config_post($wancfg);
344
		if ($wi_input_errors) {
345
			$input_errors = array_merge($input_errors, $wi_input_errors);
346
		}
347
	}
348

    
349
	if (!$input_errors) {
350

    
351
		unset($wancfg['ipaddr']);
352
		unset($wancfg['subnet']);
353
		unset($wancfg['gateway']);
354
		unset($wancfg['pointtopoint']);
355
		unset($wancfg['dhcphostname']);
356
		unset($wancfg['username']);
357
		unset($wancfg['password']);
358
		unset($wancfg['provider']);
359
		unset($wancfg['ondemand']);
360
		unset($wancfg['timeout']);
361
		if ($wancfg['pppoe']['pppoe-reset-type'])
362
			unset($wancfg['pppoe']['pppoe-reset-type']);
363
		unset($wancfg['local']);
364
		unset($wancfg['subnet']);
365
		unset($wancfg['remote']);
366
		unset($wancfg['disableftpproxy']);
367

    
368
		/* per interface pftpx helper */
369
		if($_POST['disableftpproxy'] == "yes") {
370
			$wancfg['disableftpproxy'] = true;
371
			system_start_ftp_helpers();
372
		} else {
373
			system_start_ftp_helpers();
374
		}
375

    
376
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
377
		$wancfg['enable'] = $if == "wan" ? true : $_POST['enable'] ? true : false;
378

    
379
		if ($_POST['type'] == "Static") {
380
			$wancfg['ipaddr'] = $_POST['ipaddr'];
381
			$wancfg['subnet'] = $_POST['subnet'];
382
			$wancfg['gateway'] = $_POST['gateway'];
383
			if (isset($wancfg['ispointtopoint']))
384
				$wancfg['pointtopoint'] = $_POST['pointtopoint'];
385
		} else if ($_POST['type'] == "DHCP") {
386
			$wancfg['ipaddr'] = "dhcp";
387
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
388
			$wancfg['alias-address'] = $_POST['alias-address'];
389
			$wancfg['alias-subnet'] = $_POST['alias-subnet'];
390
		} else if ($_POST['type'] == "CarpDEV-DHCP") {
391
			$wancfg['ipaddr'] = "carpdev-dhcp";
392
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
393
			$wancfg['alias-address'] = $_POST['alias-address'];
394
			$wancfg['alias-subnet'] = $_POST['alias-subnet'];			
395
		} else if ($_POST['type'] == "PPPoE") {
396
			$wancfg['ipaddr'] = "pppoe";
397
			$wancfg['username'] = $_POST['username'];
398
			$wancfg['password'] = $_POST['password'];
399
			$wancfg['provider'] = $_POST['provider'];
400
			$wancfg['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
401
			$wancfg['timeout'] = $_POST['pppoe_idletimeout'];
402
      
403
			/* perform a periodic reset? */
404
			if (isset($_POST['pppoe_preset'])) {
405
				if (! is_array($config['cron']['item'])) { $config['cron']['item'] = array(); }
406

    
407
					$itemhash = getMPDCRONSettings();
408
					$item = $itemhash['ITEM'];
409

    
410
					if (empty($item)) {
411
						$item = array();
412
					}
413

    
414
					if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] == "custom") {
415
						$wancfg['pppoe']['pppoe-reset-type'] = "custom";
416
						$pconfig['pppoe_pr_custom'] = true;
417

    
418
						$item['minute'] = $_POST['pppoe_resetminute'];
419
						$item['hour'] = $_POST['pppoe_resethour'];
420

    
421
						if (isset($_POST['pppoe_resetdate']) && 
422
							$_POST['pppoe_resetdate'] <> "" && 
423
							strlen($_POST['pppoe_resetdate']) == 10) {
424
							$date = explode("/", $_POST['pppoe_resetdate']);
425
							$item['mday'] = $date[1];
426
							$item['month'] = $date[0];
427
						} else {
428
							$item['mday'] = "*";
429
							$item['month'] = "*";
430
						}
431
						$item['wday'] = "*";
432
						$item['who'] = "root";
433
						$item['command'] = CRON_PPPOE_CMD_FILE;
434
					} else if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] = "preset") {
435
						$wancfg['pppoe']['pppoe-reset-type'] = "preset";
436
						$pconfig['pppoe_pr_preset'] = true;
437

    
438
						switch ($_POST['pppoe_pr_preset_val']) {
439
							case "monthly":
440
								$item['minute'] = "0";
441
								$item['hour'] = "0";
442
								$item['mday'] = "1";
443
								$item['month'] = "*";
444
								$item['wday'] = "*";
445
								$item['who'] = "root";
446
								$item['command'] = CRON_PPPOE_CMD_FILE;
447
								break;
448
					        	case "weekly":
449
								$item['minute'] = "0";
450
								$item['hour'] = "0";
451
								$item['mday'] = "*";
452
								$item['month'] = "*";
453
								$item['wday'] = "0";
454
								$item['who'] = "root";
455
								$item['command'] = CRON_PPPOE_CMD_FILE;
456
								break;
457
							case "daily":
458
								$item['minute'] = "0";
459
								$item['hour'] = "0";
460
								$item['mday'] = "*";
461
								$item['month'] = "*";
462
								$item['wday'] = "*";
463
								$item['who'] = "root";
464
								$item['command'] = CRON_PPPOE_CMD_FILE;
465
								break;
466
							case "hourly":
467
								$item['minute'] = "0";
468
								$item['hour'] = "*";
469
								$item['mday'] = "*";
470
								$item['month'] = "*";
471
								$item['wday'] = "*";
472
								$item['who'] = "root";
473
								$item['command'] = CRON_PPPOE_CMD_FILE;
474
								break;
475
						} // end switch
476
					} // end if
477
				if (isset($itemhash['ID'])) {
478
					$config['cron']['item'][$itemhash['ID']] = $item;
479
				} else {
480
					$config['cron']['item'][] = $item;
481
				}
482
			} // end if
483
		} else if ($_POST['type'] == "PPTP") {
484
			$wancfg['ipaddr'] = "pptp";
485
			$wancfg['username'] = $_POST['pptp_username'];
486
			$wancfg['password'] = $_POST['pptp_password'];
487
			$wancfg['local'] = $_POST['pptp_local'];
488
			$wancfg['subnet'] = $_POST['pptp_subnet'];
489
			$wancfg['remote'] = $_POST['pptp_remote'];
490
			$wancfg['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
491
			$wancfg['timeout'] = $_POST['pptp_idletimeout'];
492
		}
493
    
494
		/* reset cron items if necessary */
495
		if (empty($_POST['pppoe_preset'])) {
496
			/* test whether a cron item exists and unset() it if necessary */
497
			$itemhash = getMPDCRONSettings();
498
			$item = $itemhash['ITEM'];
499
			if (isset($item)) { unset($config['cron']['item'][$itemhash['ID']]); }
500
		}
501

    
502
		if($_POST['blockpriv'] == "yes")
503
			$wancfg['blockpriv'] = true;
504
		else
505
			unset($wancfg['blockpriv']);
506

    
507
		if($_POST['blockbogons'] == "yes")
508
			$wancfg['blockbogons'] = true;
509
		else
510
			unset($wancfg['blockbogons']);
511

    
512
		$wancfg['spoofmac'] = $_POST['spoofmac'];
513
		$wancfg['mtu'] = $_POST['mtu'];
514

    
515
		write_config();
516
    
517
		/* finally install the pppoerestart file */
518
		if (isset($_POST['pppoe_preset'])) {
519
		config_lock();
520
		conf_mount_rw();
521
      
522
		if (! file_exists(CRON_PPPOE_CMD_FILE)) {
523
			file_put_contents(CRON_PPPOE_CMD_FILE, CRON_PPPOE_CMD);
524
			chmod(CRON_PPPOE_CMD_FILE, 0700);
525
		}
526
      
527
		/* regenerate cron settings/crontab file */
528
		configure_cron();
529
		sigkillbypid("{$g['varrun_path']}/cron.pid", "HUP");
530
      
531
		conf_mount_ro();
532
		config_unlock();
533
		}
534

    
535
		$retval = 0;
536
		$savemsg = get_std_save_message($retval);
537
	}
538
}
539

    
540
// Populate page descr if it does not exist.
541
if($if == "wan" && !$wancfg['descr'])
542
	$wancfg['descr'] = "WAN";
543
	
544
$pgtitle = array("Interfaces", $wancfg['descr']);
545
$closehead = false;
546
include("head.inc");
547

    
548
?>
549

    
550
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
551
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
552

    
553
<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
554
<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css" />
555

    
556
<script type="text/javascript" src="/javascript/scriptaculous/prototype.js"></script>
557
<script type="text/javascript" src="/javascript/scriptaculous/scriptaculous.js"></script>
558

    
559
<script type="text/javascript">
560
<!--
561
function enable_change(enable_change) {
562
	if (document.iform.pppoe_dialondemand.checked || enable_change) {
563
		document.iform.pppoe_idletimeout.disabled = 0;
564
	} else {
565
		document.iform.pppoe_idletimeout.disabled = 1;
566
	}
567
}
568

    
569
function enable_change_pptp(enable_change_pptp) {
570
	if (document.iform.pptp_dialondemand.checked || enable_change_pptp) {
571
		document.iform.pptp_idletimeout.disabled = 0;
572
		document.iform.pptp_local.disabled = 0;
573
		document.iform.pptp_remote.disabled = 0;
574
	} else {
575
		document.iform.pptp_idletimeout.disabled = 1;
576
	}
577
}
578

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

    
714
	}
715
}
716

    
717
function show_mon_config() {
718
	document.getElementById("showmonbox").innerHTML='';
719
	aodiv = document.getElementById('showmon');
720
	aodiv.style.display = "block";
721
}
722

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

    
1046
                <tr>
1047
                  <td width="100" valign="top">&nbsp;</td>
1048
                  <td> &nbsp;<br> <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change_pptp(true)&&enable_change(true)">
1049
			<input name="if" type="hidden" id="if" value="<?=$if;?>">
1050
                  </td>
1051
                </tr>
1052
              </table>
1053
</form>
1054
<script language="JavaScript">
1055
<!--
1056
type_change();
1057
//-->
1058
</script>
1059
<?php include("fend.inc"); ?>
1060
</body>
1061
</html>
1062

    
1063

    
1064
<?php
1065

    
1066
if ($_POST) {
1067

    
1068
	if (!$input_errors) {
1069

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

    
1072
		ob_flush();
1073
		flush();
1074
		sleep(1);
1075

    
1076
		interfaces_wan_configure($if);
1077

    
1078
		reset_carp();
1079

    
1080
		/* sync filter configuration */
1081
		filter_configure();
1082

    
1083
 		/* set up static routes */
1084
		system_routing_configure();
1085

    
1086
	}
1087
}
1088

    
1089
?>
(88-88/211)