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
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
35
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
36
define("CRON_DAILY_PATTERN", "0 0 * * *");
37
define("CRON_HOURLY_PATTERN", "0 * * * *");
38
define("CRON_PPPOE_CMD_FILE", "/etc/pppoerestart");
39
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");
40

    
41
function getMPDCRONSettings() {
42
  global $config;
43

    
44
  if (is_array($config['cron']['item'])) {
45
    for ($i = 0; $i < count($config['cron']['item']); $i++) {
46
      $item =& $config['cron']['item'][$i];
47

    
48
      if (strpos($item['command'], CRON_PPPOE_CMD_FILE) !== false) {
49
        return array("ID" => $i, "ITEM" => $item);
50
      }
51
    }
52
  }
53

    
54
  return NULL;
55
}
56

    
57
function getMPDResetTimeFromConfig() {
58
  $itemhash = getMPDCRONSettings();
59
  $cronitem = $itemhash['ITEM'];
60

    
61
  if (isset($cronitem)) {
62

    
63
    return "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
64
  } else {
65
    return NULL;
66
  }
67
}
68

    
69
function remove_bad_chars($string) {
70
        return preg_replace('/[^a-z|_|0-9]/i','',$string);
71
}
72

    
73
require("guiconfig.inc");
74

    
75
unset($if);
76
if ($_GET['if'])
77
        $if = $_GET['if'];
78
else if ($_POST['if'])
79
        $if = $_POST['if'];
80

    
81
if (!$if)
82
        $if = "wan";
83

    
84
if (!is_array($config['gateways']['gateway_item']))
85
	$config['gateways']['gateway_item'] = array();
86
$a_gateways = &$config['gateways']['gateway_item'];
87

    
88
$wancfg = &$config['interfaces'][$if];
89

    
90
$pconfig['username'] = $wancfg['username'];
91
$pconfig['password'] = $wancfg['password'];
92
$pconfig['provider'] = $wancfg['provider'];
93
$pconfig['pppoe_dialondemand'] = isset($wancfg['ondemand']);
94
$pconfig['pppoe_idletimeout'] = $wancfg['timeout'];
95

    
96
/* ================================================ */
97
/* = force a connection reset at a specific time? = */
98
/* ================================================ */
99

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

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

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

    
144
$pconfig['disableftpproxy'] = isset($wancfg['disableftpproxy']);
145

    
146
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
147
$pconfig['alias-address'] = $wancfg['alias-address'];
148
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
149
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
150
$pconfig['enable'] = isset($wancfg['enable']);
151

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

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

    
175
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
176
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
177
$pconfig['spoofmac'] = $wancfg['spoofmac'];
178
$pconfig['mtu'] = $wancfg['mtu'];
179

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

    
186
if ($_POST) {
187

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

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

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

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

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

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

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

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

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

    
346
	if (!$input_errors) {
347

    
348
		$bridge = discover_bridge($wancfg['if'], filter_translate_type_to_real_interface($wancfg['bridge']));
349
		if($bridge <> "-1") {
350
			destroy_bridge($bridge);
351
		}
352

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
541
$pgtitle = array("Interfaces", $wancfg['descr']);
542
$closehead = false;
543
include("head.inc");
544

    
545
?>
546

    
547
<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
548
<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
549

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

    
553
<script type="text/javascript" src="/javascript/scriptaculous/prototype.js"></script>
554
<script type="text/javascript" src="/javascript/scriptaculous/scriptaculous.js"></script>
555

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

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

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

    
711
	}
712
}
713

    
714
function show_mon_config() {
715
	document.getElementById("showmonbox").innerHTML='';
716
	aodiv = document.getElementById('showmon');
717
	aodiv.style.display = "block";
718
}
719

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

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

    
1062

    
1063
<?php
1064

    
1065
if ($_POST) {
1066

    
1067
	if (!$input_errors) {
1068

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

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

    
1075
		interfaces_wan_configure($if);
1076

    
1077
		reset_carp();
1078

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

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

    
1085
	}
1086
}
1087

    
1088
?>
(82-82/200)