Project

General

Profile

Download (46 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

    
42
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
43
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
44
define("CRON_DAILY_PATTERN", "0 0 * * *");
45
define("CRON_HOURLY_PATTERN", "0 * * * *");
46
define("CRON_PPPOE_CMD_FILE", "/etc/pppoerestart");
47
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");
48

    
49
function getMPDCRONSettings() {
50
  global $config;
51

    
52
  if (is_array($config['cron']['item'])) {
53
    for ($i = 0; $i < count($config['cron']['item']); $i++) {
54
      $item =& $config['cron']['item'][$i];
55

    
56
      if (strpos($item['command'], CRON_PPPOE_CMD_FILE) !== false) {
57
        return array("ID" => $i, "ITEM" => $item);
58
      }
59
    }
60
  }
61

    
62
  return NULL;
63
}
64

    
65
function getMPDResetTimeFromConfig() {
66
  $itemhash = getMPDCRONSettings();
67
  $cronitem = $itemhash['ITEM'];
68

    
69
  if (isset($cronitem)) {
70

    
71
    return "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
72
  } else {
73
    return NULL;
74
  }
75
}
76

    
77
function remove_bad_chars($string) {
78
        return preg_replace('/[^a-z|_|0-9]/i','',$string);
79
}
80

    
81
require("guiconfig.inc");
82

    
83
unset($if);
84
if ($_GET['if'])
85
        $if = $_GET['if'];
86
else if ($_POST['if'])
87
        $if = $_POST['if'];
88

    
89
if (!$if)
90
        $if = "wan";
91

    
92
if (!is_array($config['gateways']['gateway_item']))
93
	$config['gateways']['gateway_item'] = array();
94
$a_gateways = &$config['gateways']['gateway_item'];
95

    
96
$wancfg = &$config['interfaces'][$if];
97

    
98
$pconfig['username'] = $wancfg['username'];
99
$pconfig['password'] = $wancfg['password'];
100
$pconfig['provider'] = $wancfg['provider'];
101
$pconfig['pppoe_dialondemand'] = isset($wancfg['ondemand']);
102
$pconfig['pppoe_idletimeout'] = $wancfg['timeout'];
103

    
104
/* ================================================ */
105
/* = force a connection reset at a specific time? = */
106
/* ================================================ */
107

    
108
if (isset($wancfg['pppoe']['pppoe-reset-type'])) {
109
  $resetTime = getMPDResetTimeFromConfig();  
110
  $pconfig['pppoe_preset'] = true;
111
  
112
  if ($wancfg['pppoe']['pppoe-reset-type'] == "custom") {
113
    $resetTime_a = split(" ", $resetTime);
114
    $pconfig['pppoe_pr_custom'] = true;
115
    $pconfig['pppoe_resetminute'] = $resetTime_a[0];
116
    $pconfig['pppoe_resethour'] = $resetTime_a[1];
117

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

    
144
$pconfig['pptp_username'] = $wancfg['username'];
145
$pconfig['pptp_password'] = $wancfg['password'];
146
$pconfig['pptp_local'] = $wancfg['local'];
147
$pconfig['pptp_subnet'] = $wancfg['subnet'];
148
$pconfig['pptp_remote'] = $wancfg['remote'];
149
$pconfig['pptp_dialondemand'] = isset($wancfg['ondemand']);
150
$pconfig['pptp_idletimeout'] = $wancfg['timeout'];
151

    
152
$pconfig['disableftpproxy'] = isset($wancfg['disableftpproxy']);
153

    
154
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
155
$pconfig['alias-address'] = $wancfg['alias-address'];
156
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
157
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
158
$pconfig['enable'] = isset($wancfg['enable']);
159

    
160
if (is_array($config['aliases']['alias']))
161
foreach($config['aliases']['alias'] as $alias)
162
        if($alias['name'] == $wancfg['descr'])
163
                $input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} a
164
lready exists.");
165

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

    
183
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
184
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
185
$pconfig['spoofmac'] = $wancfg['spoofmac'];
186
$pconfig['mtu'] = $wancfg['mtu'];
187

    
188
/* Wireless interface? */
189
if (isset($wancfg['wireless'])) {
190
	require("interfaces_wlan.inc");
191
	wireless_config_init();
192
}
193

    
194
if ($_POST) {
195

    
196
	unset($input_errors);
197
	$pconfig = $_POST;
198
  
199
	/* filter out spaces from descriptions  */
200
        $_POST['descr'] = remove_bad_chars($_POST['descr']);
201

    
202
	if ($_POST['enable'] || $if == "wan") {
203
		/* optional interface if list */
204
                $iflist = get_configured_interface_with_descr(true);
205

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

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

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

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

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

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

    
346
	/* Wireless interface? */
347
	if (isset($wancfg['wireless'])) {
348
		$wi_input_errors = wireless_config_post();
349
		if ($wi_input_errors) {
350
			$input_errors = array_merge($input_errors, $wi_input_errors);
351
		}
352
	}
353

    
354
	if (!$input_errors) {
355

    
356
		unset($wancfg['ipaddr']);
357
		unset($wancfg['subnet']);
358
		unset($wancfg['gateway']);
359
		unset($wancfg['pointtopoint']);
360
		unset($wancfg['dhcphostname']);
361
		unset($wancfg['username']);
362
		unset($wancfg['password']);
363
		unset($wancfg['provider']);
364
		unset($wancfg['ondemand']);
365
		unset($wancfg['timeout']);
366
		unset($wancfg['pppoe']['pppoe-reset-type']);
367
		unset($wancfg['local']);
368
		unset($wancfg['subnet']);
369
		unset($wancfg['remote']);
370
		unset($wancfg['disableftpproxy']);
371

    
372
		/* per interface pftpx helper */
373
		if($_POST['disableftpproxy'] == "yes") {
374
			$wancfg['disableftpproxy'] = true;
375
			system_start_ftp_helpers();
376
		} else {
377
			system_start_ftp_helpers();
378
		}
379

    
380
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
381
		$wancfg['enable'] = $if == "wan" ? true : $_POST['enable'] ? true : false;
382

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

    
411
					$itemhash = getMPDCRONSettings();
412
					$item = $itemhash['ITEM'];
413

    
414
					if (empty($item)) {
415
						$item = array();
416
					}
417

    
418
					if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] == "custom") {
419
						$wancfg['pppoe']['pppoe-reset-type'] = "custom";
420
						$pconfig['pppoe_pr_custom'] = true;
421

    
422
						$item['minute'] = $_POST['pppoe_resetminute'];
423
						$item['hour'] = $_POST['pppoe_resethour'];
424

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

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

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

    
511
		if($_POST['blockbogons'] == "yes")
512
			$wancfg['blockbogons'] = true;
513
		else
514
			unset($wancfg['blockbogons']);
515

    
516
		$wancfg['spoofmac'] = $_POST['spoofmac'];
517
		$wancfg['mtu'] = $_POST['mtu'];
518

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

    
539
		$retval = 0;
540
		$savemsg = get_std_save_message($retval);
541
	}
542
}
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();
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
?>
(90-90/214)