Project

General

Profile

Download (46 KB) Statistics
| Branch: | Tag: | Revision:
1 e2cd32df Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	interfaces_wan.php
5 15aea4cb Seth Mos
        Copyright (C) 2007 Scott Ullrich
6 c3b3cd36 Scott Ullrich
	All rights reserved.
7 b1c525ee Scott Ullrich
8 c3b3cd36 Scott Ullrich
	originally part of m0n0wall (http://m0n0.ch/wall)
9 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11 e2cd32df Scott Ullrich
12 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14 e2cd32df Scott Ullrich
15 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17 e2cd32df Scott Ullrich
18 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21 e2cd32df Scott Ullrich
22 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33
34 58af5941 Scott Ullrich
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
35
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
36
define("CRON_DAILY_PATTERN", "0 0 * * *");
37
define("CRON_HOURLY_PATTERN", "0 * * * *");
38
define("CRON_PPPOE_CMD_FILE", "/etc/pppoerestart");
39 f1f60c92 Ermal Luçi
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 58af5941 Scott Ullrich
41
function getMPDCRONSettings() {
42
  global $config;
43
44
  if (is_array($config['cron']['item'])) {
45
    for ($i = 0; $i < count($config['cron']['item']); $i++) {
46
      $item =& $config['cron']['item'][$i];
47
48
      if (strpos($item['command'], CRON_PPPOE_CMD_FILE) !== false) {
49
        return array("ID" => $i, "ITEM" => $item);
50
      }
51
    }
52
  }
53
54
  return NULL;
55
}
56
57
function getMPDResetTimeFromConfig() {
58
  $itemhash = getMPDCRONSettings();
59
  $cronitem = $itemhash['ITEM'];
60
61
  if (isset($cronitem)) {
62
63
    return "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
64
  } else {
65
    return NULL;
66
  }
67
}
68
69 f1f60c92 Ermal Luçi
function remove_bad_chars($string) {
70
        return preg_replace('/[^a-z|_|0-9]/i','',$string);
71
}
72
73 5b237745 Scott Ullrich
require("guiconfig.inc");
74
75 f1f60c92 Ermal Luçi
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 d173230c Seth Mos
if (!is_array($config['gateways']['gateway_item']))
85
	$config['gateways']['gateway_item'] = array();
86
$a_gateways = &$config['gateways']['gateway_item'];
87
88 f1f60c92 Ermal Luçi
$wancfg = &$config['interfaces'][$if];
89 5b237745 Scott Ullrich
90 f1f60c92 Ermal Luçi
$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 5b237745 Scott Ullrich
96 58af5941 Scott Ullrich
/* ================================================ */
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 f1f60c92 Ermal Luçi
$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 5b237745 Scott Ullrich
144 c1ec2c2f Scott Ullrich
$pconfig['disableftpproxy'] = isset($wancfg['disableftpproxy']);
145
146 5b237745 Scott Ullrich
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
147 bc40d758 Seth Mos
$pconfig['alias-address'] = $wancfg['alias-address'];
148
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
149 f1f60c92 Ermal Luçi
$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 5b237745 Scott Ullrich
158
if ($wancfg['ipaddr'] == "dhcp") {
159
	$pconfig['type'] = "DHCP";
160 d8948db4 Scott Ullrich
} else if ($wancfg['ipaddr'] == "carpdev-dhcp") {
161 f1f60c92 Ermal Luçi
	$pconfig['type'] = "CarpDEV-DHCP";
162
	$pconfig['ipaddr'] = "";	    
163 5b237745 Scott Ullrich
} 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 f1f60c92 Ermal Luçi
	$pconfig['gateway'] = $wancfg['gateway'];
172 a23d7248 Scott Ullrich
	$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
173 5b237745 Scott Ullrich
}
174
175
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
176 ff1955ee Bill Marquette
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
177 5b237745 Scott Ullrich
$pconfig['spoofmac'] = $wancfg['spoofmac'];
178
$pconfig['mtu'] = $wancfg['mtu'];
179
180
/* Wireless interface? */
181 b7f01f59 Bill Marquette
if (isset($wancfg['wireless'])) {
182 5b237745 Scott Ullrich
	require("interfaces_wlan.inc");
183
	wireless_config_init();
184
}
185
186
if ($_POST) {
187
188
	unset($input_errors);
189
	$pconfig = $_POST;
190 58af5941 Scott Ullrich
  
191 f1f60c92 Ermal Luçi
	/* 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 15aea4cb Seth Mos
	/* 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 5b237745 Scott Ullrich
220 ee968e4f Scott Ullrich
	if($_POST['gateway'] and $pconfig['gateway'] <> $_POST['gateway']) {
221 6fc5bf35 Scott Ullrich
		/* 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 8bddc5b7 Scott Ullrich
			            if($svr[1] == $pconfig['gateway'])  {
228
			            		$_POST['gateway']  = $pconfig['gateway'];
229 de42a08e Scott Ullrich
			            		$input_errors[] = "Cannot change {$svr[1]} gateway.  It is currently referenced by the load balancer pools.";
230 8bddc5b7 Scott Ullrich
			            }
231 6fc5bf35 Scott Ullrich
					}
232
				}
233 8bddc5b7 Scott Ullrich
			}
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 6fc5bf35 Scott Ullrich
		}
241
	}
242
243 5b237745 Scott Ullrich
	/* input validation */
244
	if ($_POST['type'] == "Static") {
245 f1f60c92 Ermal Luçi
		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 5b237745 Scott Ullrich
		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 e2cd32df Scott Ullrich
273 ad60dd49 Scott Ullrich
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
274
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
275 4f3401e0 Bill Marquette
276 5b237745 Scott Ullrich
	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 bc40d758 Seth Mos
	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 d173230c Seth Mos
	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 5b237745 Scott Ullrich
	}
298 a23d7248 Scott Ullrich
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) {
299
		$input_errors[] = "A valid point-to-point IP address must be specified.";
300
	}
301 5b237745 Scott Ullrich
	if (($_POST['provider'] && !is_domain($_POST['provider']))) {
302
		$input_errors[] = "The service name contains invalid characters.";
303
	}
304 a23d7248 Scott Ullrich
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
305 5b237745 Scott Ullrich
		$input_errors[] = "The idle timeout value must be an integer.";
306
	}
307 15aea4cb Seth Mos
	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 5b237745 Scott Ullrich
	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 a23d7248 Scott Ullrich
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) {
328 5b237745 Scott Ullrich
		$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 f1f60c92 Ermal Luçi
	}
337 e2cd32df Scott Ullrich
338 5b237745 Scott Ullrich
	/* Wireless interface? */
339 b7f01f59 Bill Marquette
	if (isset($wancfg['wireless'])) {
340 5b237745 Scott Ullrich
		$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 e2cd32df Scott Ullrich
348 9a6757a1 Scott Ullrich
		$bridge = discover_bridge($wancfg['if'], filter_translate_type_to_real_interface($wancfg['bridge']));
349 0d429e43 Scott Ullrich
		if($bridge <> "-1") {
350 1665e79c Scott Ullrich
			destroy_bridge($bridge);
351 91e8aab2 Scott Ullrich
		}
352 b1c525ee Scott Ullrich
353 5b237745 Scott Ullrich
		unset($wancfg['ipaddr']);
354
		unset($wancfg['subnet']);
355 f1f60c92 Ermal Luçi
		unset($wancfg['gateway']);
356 a23d7248 Scott Ullrich
		unset($wancfg['pointtopoint']);
357 5b237745 Scott Ullrich
		unset($wancfg['dhcphostname']);
358 f1f60c92 Ermal Luçi
		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 c1ec2c2f Scott Ullrich
		unset($wancfg['disableftpproxy']);
368 b1c525ee Scott Ullrich
369 c1ec2c2f Scott Ullrich
		/* per interface pftpx helper */
370
		if($_POST['disableftpproxy'] == "yes") {
371
			$wancfg['disableftpproxy'] = true;
372
			system_start_ftp_helpers();
373 b1c525ee Scott Ullrich
		} else {
374 c1ec2c2f Scott Ullrich
			system_start_ftp_helpers();
375
		}
376 e2cd32df Scott Ullrich
377 f1f60c92 Ermal Luçi
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
378
		$wancfg['enable'] = $if == "wan" ? true : $_POST['enable'] ? true : false;
379
380 5b237745 Scott Ullrich
		if ($_POST['type'] == "Static") {
381
			$wancfg['ipaddr'] = $_POST['ipaddr'];
382
			$wancfg['subnet'] = $_POST['subnet'];
383 f1f60c92 Ermal Luçi
			$wancfg['gateway'] = $_POST['gateway'];
384 a23d7248 Scott Ullrich
			if (isset($wancfg['ispointtopoint']))
385
				$wancfg['pointtopoint'] = $_POST['pointtopoint'];
386 5b237745 Scott Ullrich
		} else if ($_POST['type'] == "DHCP") {
387
			$wancfg['ipaddr'] = "dhcp";
388
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
389 bc40d758 Seth Mos
			$wancfg['alias-address'] = $_POST['alias-address'];
390
			$wancfg['alias-subnet'] = $_POST['alias-subnet'];
391 d5d00b83 Scott Ullrich
		} 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 5b237745 Scott Ullrich
		} else if ($_POST['type'] == "PPPoE") {
397
			$wancfg['ipaddr'] = "pppoe";
398 f1f60c92 Ermal Luçi
			$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 58af5941 Scott Ullrich
      
404 15aea4cb Seth Mos
			/* 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 5b237745 Scott Ullrich
		} else if ($_POST['type'] == "PPTP") {
485
			$wancfg['ipaddr'] = "pptp";
486 f1f60c92 Ermal Luçi
			$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 5b237745 Scott Ullrich
		}
494 58af5941 Scott Ullrich
    
495 15aea4cb Seth Mos
		/* 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 e2cd32df Scott Ullrich
503 90ebf755 Scott Ullrich
		if($_POST['blockpriv'] == "yes")
504
			$wancfg['blockpriv'] = true;
505
		else
506 42a58cb9 Scott Ullrich
			unset($wancfg['blockpriv']);
507 b1c525ee Scott Ullrich
508 90ebf755 Scott Ullrich
		if($_POST['blockbogons'] == "yes")
509
			$wancfg['blockbogons'] = true;
510
		else
511
			unset($wancfg['blockbogons']);
512 b1c525ee Scott Ullrich
513 5b237745 Scott Ullrich
		$wancfg['spoofmac'] = $_POST['spoofmac'];
514
		$wancfg['mtu'] = $_POST['mtu'];
515 e2cd32df Scott Ullrich
516 5b237745 Scott Ullrich
		write_config();
517 58af5941 Scott Ullrich
    
518
		/* finally install the pppoerestart file */
519
		if (isset($_POST['pppoe_preset'])) {
520 15aea4cb Seth Mos
		config_lock();
521
		conf_mount_rw();
522 58af5941 Scott Ullrich
      
523 15aea4cb Seth Mos
		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 58af5941 Scott Ullrich
      
528 15aea4cb Seth Mos
		/* regenerate cron settings/crontab file */
529
		configure_cron();
530
		sigkillbypid("{$g['varrun_path']}/cron.pid", "HUP");
531 58af5941 Scott Ullrich
      
532 15aea4cb Seth Mos
		conf_mount_ro();
533
		config_unlock();
534 58af5941 Scott Ullrich
		}
535 e2cd32df Scott Ullrich
536 5b237745 Scott Ullrich
		$retval = 0;
537 824edb6c Scott Ullrich
		$savemsg = get_std_save_message($retval);
538 5b237745 Scott Ullrich
	}
539
}
540 7f43ca88 Scott Ullrich
541 f1f60c92 Ermal Luçi
$pgtitle = array("Interfaces", $wancfg['descr']);
542 58af5941 Scott Ullrich
$closehead = false;
543 7f43ca88 Scott Ullrich
include("head.inc");
544
545 5b237745 Scott Ullrich
?>
546 7f43ca88 Scott Ullrich
547 58af5941 Scott Ullrich
<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 5b237745 Scott Ullrich
<!--
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 15aea4cb Seth Mos
			document.iform.pppoe_preset.disabled = 1;
585
			document.iform.pppoe_preset.checked = 0;
586
			Effect.Fade('presetwrap', { duration: 1.0 });
587 5b237745 Scott Ullrich
			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 15aea4cb Seth Mos
			document.iform.pppoe_preset.disabled = 1;
606
			document.iform.pppoe_preset.checked = 0;
607
			Effect.Fade('presetwrap', { duration: 1.0 });
608 5b237745 Scott Ullrich
			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 15aea4cb Seth Mos
			document.iform.pppoe_preset.disabled = 0;
631 5b237745 Scott Ullrich
			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 15aea4cb Seth Mos
			document.iform.pppoe_preset.disabled = 1;
650
			document.iform.pppoe_preset.checked = 0;
651
			Effect.Fade('presetwrap', { duration: 1.0 });			
652 5b237745 Scott Ullrich
			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 15aea4cb Seth Mos
			document.iform.pppoe_preset.disabled = 1;
675
			document.iform.pppoe_preset.checked = 0;
676
			Effect.Fade('presetwrap', { duration: 1.0 });
677 5b237745 Scott Ullrich
			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 d5d00b83 Scott Ullrich
		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 5b237745 Scott Ullrich
	}
712
}
713 15aea4cb Seth Mos
714
function show_mon_config() {
715
	document.getElementById("showmonbox").innerHTML='';
716
	aodiv = document.getElementById('showmon');
717
	aodiv.style.display = "block";
718
}
719
720 5b237745 Scott Ullrich
//-->
721
</script>
722 58af5941 Scott Ullrich
</head>
723 5b237745 Scott Ullrich
<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 e2cd32df Scott Ullrich
                <tr>
730 8fdc8744 Bill Marquette
                  <td colspan="2" valign="top" class="listtopic">General configuration</td>
731
                </tr>
732 f1f60c92 Ermal Luçi
<?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 39571a23 Ermal Luçi
                    <strong>Enable Interface</strong></td>
738 f1f60c92 Ermal Luçi
                </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 8fdc8744 Bill Marquette
                <tr>
750
                  <td valign="middle" class="vncell"><strong>Type</strong></td>
751 b5c78501 Seth Mos
                  <td class="vtable"> <select name="type" class="formselect" id="type" onchange="type_change()">
752 f1f60c92 Ermal Luçi
                      <?php $opts = split(" ", "Static DHCP PPPoE PPTP"); // CarpDEV-DHCP");
753 d5d00b83 Scott Ullrich
					  foreach ($opts as $opt): ?>
754
	                      <option <?php if ($opt == $pconfig['type']) echo "selected";?>>
755
	                      <?=htmlspecialchars($opt);?>
756
	                      </option>
757 5b237745 Scott Ullrich
                      <?php endforeach; ?>
758
                    </select></td>
759
                </tr>
760 e2cd32df Scott Ullrich
                <tr>
761 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">MAC address</td>
762 b5c78501 Seth Mos
                  <td class="vtable"> <input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
763 1e694bee Scott Ullrich
		    <?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 b1c525ee Scott Ullrich
		    <a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#">Copy my MAC address</a>
769 1e694bee Scott Ullrich
		    <br>
770 e2cd32df Scott Ullrich
                    This field can be used to modify (&quot;spoof&quot;) the MAC
771 5b237745 Scott Ullrich
                    address of the WAN interface<br>
772
                    (may be required with some cable connections)<br>
773 e2cd32df Scott Ullrich
                    Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx
774 5b237745 Scott Ullrich
                    or leave blank</td>
775
                </tr>
776 e2cd32df Scott Ullrich
                <tr>
777 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">MTU</td>
778 b5c78501 Seth Mos
                  <td class="vtable"> <input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
779 5b237745 Scott Ullrich
                    <br>
780 e2cd32df Scott Ullrich
                    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 5b237745 Scott Ullrich
                    connection types will be assumed.</td>
785
                </tr>
786 e2cd32df Scott Ullrich
                <tr>
787 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
788
                </tr>
789 e2cd32df Scott Ullrich
                <tr>
790 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">Static IP configuration</td>
791 5b237745 Scott Ullrich
                </tr>
792 e2cd32df Scott Ullrich
                <tr>
793 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">IP address</td>
794 b5c78501 Seth Mos
                  <td class="vtable"> <input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
795 e2cd32df Scott Ullrich
                    /
796 b5c78501 Seth Mos
                    <select name="subnet" class="formselect" id="subnet">
797 fa3b333d Scott Ullrich
			<?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 5b237745 Scott Ullrich
                    </select></td>
807 a23d7248 Scott Ullrich
                </tr><?php if (isset($wancfg['ispointtopoint'])): ?>
808 7f5b4824 Scott Ullrich
                <tr>
809 a23d7248 Scott Ullrich
                  <td valign="top" class="vncellreq">Point-to-point IP address </td>
810
                  <td class="vtable">
811 b5c78501 Seth Mos
                    <input name="pointtopoint" type="text" class="formfld unknown" id="pointtopoint" size="20" value="<?=htmlspecialchars($pconfig['pointtopoint']);?>">
812 a23d7248 Scott Ullrich
                  </td>
813
                </tr><?php endif; ?>
814 e2cd32df Scott Ullrich
                <tr>
815 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Gateway</td>
816 d173230c Seth Mos
                  <td class="vtable"><select name="gateway" class="formselect" id="gateway">
817
			<?php
818 2be84cfa Seth Mos
			if(count($a_gateways) > 0) {
819
				foreach ($a_gateways as $gateway) {
820 f1f60c92 Ermal Luçi
					if($gateway['interface'] == $if) {
821 d173230c Seth Mos
			?>
822
					<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
823
					<?=htmlspecialchars($gateway['name']);?>
824
					</option>
825
			<?php
826 2be84cfa Seth Mos
					}
827 d173230c Seth Mos
				}
828
			}
829
			?>
830 2be84cfa Seth Mos
			</select>Select a existing Gateway from the list or add one on the <a href="/system_gateways.php">Gateways</a> page<br>
831 5b237745 Scott Ullrich
                  </td>
832
                </tr>
833 e2cd32df Scott Ullrich
                <tr>
834 73c38fa2 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
835
                </tr>
836 e2cd32df Scott Ullrich
                <tr>
837 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">DHCP client configuration</td>
838 5b237745 Scott Ullrich
                </tr>
839 e2cd32df Scott Ullrich
                <tr>
840 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Hostname</td>
841 b5c78501 Seth Mos
                  <td class="vtable"> <input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
842 5b237745 Scott Ullrich
                    <br>
843 e2cd32df Scott Ullrich
                    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 5b237745 Scott Ullrich
                    this (for client identification).</td>
846
                </tr>
847 bc40d758 Seth Mos
                <tr>
848
                  <td width="100" valign="top" class="vncellreq">Alias IP address</td>
849 b5c78501 Seth Mos
                  <td class="vtable"> <input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
850 bc40d758 Seth Mos
                    <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 e2cd32df Scott Ullrich
                <tr>
865 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
866
                </tr>
867 e2cd32df Scott Ullrich
                <tr>
868 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">PPPoE configuration</td>
869 5b237745 Scott Ullrich
                </tr>
870 e2cd32df Scott Ullrich
                <tr>
871 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Username</td>
872 b5c78501 Seth Mos
                  <td class="vtable"><input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
873 5b237745 Scott Ullrich
                  </td>
874
                </tr>
875 e2cd32df Scott Ullrich
                <tr>
876 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Password</td>
877 239b93b3 Scott Ullrich
                  <td class="vtable"><input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
878 5b237745 Scott Ullrich
                  </td>
879
                </tr>
880 e2cd32df Scott Ullrich
                <tr>
881 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Service name</td>
882 b5c78501 Seth Mos
                  <td class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
883 e2cd32df Scott Ullrich
                    <br> <span class="vexpl">Hint: this field can usually be left
884 5b237745 Scott Ullrich
                    empty</span></td>
885
                </tr>
886 e2cd32df Scott Ullrich
                <tr>
887 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Dial on demand</td>
888 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?> onClick="enable_change(false)" >
889 5b237745 Scott Ullrich
                    <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 b5c78501 Seth Mos
                    <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 5b237745 Scott Ullrich
                </tr>
898 58af5941 Scott Ullrich
                <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 e2cd32df Scott Ullrich
                <tr>
956 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
957
                </tr>
958 e2cd32df Scott Ullrich
                <tr>
959 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">PPTP configuration</td>
960 5b237745 Scott Ullrich
                </tr>
961 e2cd32df Scott Ullrich
                <tr>
962 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Username</td>
963 b5c78501 Seth Mos
                  <td class="vtable"><input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
964 5b237745 Scott Ullrich
                  </td>
965
                </tr>
966 e2cd32df Scott Ullrich
                <tr>
967 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Password</td>
968 b5c78501 Seth Mos
                  <td class="vtable"><input name="pptp_password" type="text" class="formfld pwd" id="pptp_password" size="20" 
969
value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
970 5b237745 Scott Ullrich
                  </td>
971
                </tr>
972 e2cd32df Scott Ullrich
                <tr>
973 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">Local IP address</td>
974 b5c78501 Seth Mos
                  <td class="vtable"> <input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20" 
975
value="<?=htmlspecialchars($pconfig['pptp_local']);?>">
976 e2cd32df Scott Ullrich
                    /
977 b5c78501 Seth Mos
                    <select name="pptp_subnet" class="formselect" id="pptp_subnet">
978 a23d7248 Scott Ullrich
                      <?php for ($i = 31; $i > 0; $i--): ?>
979 e2cd32df Scott Ullrich
                      <option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet']) echo "selected"; ?>>
980 5b237745 Scott Ullrich
                      <?=$i;?>
981
                      </option>
982
                      <?php endfor; ?>
983
                    </select></td>
984
                </tr>
985 e2cd32df Scott Ullrich
                <tr>
986 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">Remote IP address</td>
987 b5c78501 Seth Mos
                  <td class="vtable"> <input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote']);?>">
988 5b237745 Scott Ullrich
                  </td>
989
                </tr>
990 e2cd32df Scott Ullrich
                <tr>
991 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Dial on demand</td>
992 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?> onClick="enable_change_pptp(false)" >
993 5b237745 Scott Ullrich
                    <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 b5c78501 Seth Mos
                    <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 5b237745 Scott Ullrich
                </tr>
1002 e2cd32df Scott Ullrich
                <tr>
1003 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
1004
                </tr>
1005 da56c4d7 Scott Ullrich
                <tr>
1006 15aea4cb Seth Mos
                  <td colspan="2" valign="top" class="listtopic">Other</td>
1007 b1c525ee Scott Ullrich
                </tr>
1008 da56c4d7 Scott Ullrich
		<tr>
1009
			<td width="22%" valign="top" class="vncell">FTP Helper</td>
1010
			<td width="78%" class="vtable">
1011 0135299b Scott Ullrich
				<input name="disableftpproxy" type="checkbox" id="disableftpproxy" value="yes" <?php if ($pconfig['disableftpproxy']) echo "checked"; ?> onclick="enable_change(false)" />
1012 da56c4d7 Scott Ullrich
				<strong>Disable the userland FTP-Proxy application</strong>
1013
				<br />
1014
			</td>
1015
		</tr>
1016 fa3b333d Scott Ullrich
		        <?php
1017
				/* Wireless interface? */
1018 b7f01f59 Bill Marquette
				if (isset($wancfg['wireless']))
1019 5b237745 Scott Ullrich
					wireless_config_print();
1020 fa3b333d Scott Ullrich
			?>
1021 e2cd32df Scott Ullrich
                <tr>
1022 5b237745 Scott Ullrich
                  <td height="16" colspan="2" valign="top"></td>
1023
                </tr>
1024 e2cd32df Scott Ullrich
                <tr>
1025 5b237745 Scott Ullrich
                  <td valign="middle">&nbsp;</td>
1026 d9eeccbd Scott Ullrich
                  <td class="vtable"><a name="rfc1918"></a> <input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
1027 5b237745 Scott Ullrich
                    <strong>Block private networks</strong><br>
1028 e2cd32df Scott Ullrich
                    When set, this option blocks traffic from IP addresses that
1029 5b237745 Scott Ullrich
                    are reserved for private<br>
1030 e2cd32df Scott Ullrich
                    networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as
1031 5b237745 Scott Ullrich
                    well as loopback addresses<br>
1032 e2cd32df Scott Ullrich
                    (127/8). You should generally leave this option turned on,
1033 5b237745 Scott Ullrich
                    unless your WAN network<br>
1034
                    lies in such a private address space, too.</td>
1035
                </tr>
1036 ff1955ee Bill Marquette
                <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 c1ec2c2f Scott Ullrich
		</tr>
1044 b1c525ee Scott Ullrich
1045 e2cd32df Scott Ullrich
                <tr>
1046 5b237745 Scott Ullrich
                  <td width="100" valign="top">&nbsp;</td>
1047 e2cd32df Scott Ullrich
                  <td> &nbsp;<br> <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change_pptp(true)&&enable_change(true)">
1048 f1f60c92 Ermal Luçi
			<input name="if" type="hidden" id="if" value="<?=$if;?>">
1049 5b237745 Scott Ullrich
                  </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 e4e8c30f Scott Ullrich
1062
1063
<?php
1064
1065
if ($_POST) {
1066
1067
	if (!$input_errors) {
1068 b1c525ee Scott Ullrich
1069
		unlink_if_exists("{$g['tmp_path']}/config.cache");
1070
1071 2e70a096 Scott Ullrich
		ob_flush();
1072
		flush();
1073 b1c525ee Scott Ullrich
		sleep(1);
1074
1075 f1f60c92 Ermal Luçi
		interfaces_wan_configure($if);
1076 b1c525ee Scott Ullrich
1077 610b1136 Scott Ullrich
		reset_carp();
1078 b1c525ee Scott Ullrich
1079 e4e8c30f Scott Ullrich
		/* sync filter configuration */
1080
		filter_configure();
1081 8e11b23f Scott Ullrich
1082
 		/* set up static routes */
1083
		system_routing_configure();
1084
1085 e4e8c30f Scott Ullrich
	}
1086
}
1087
1088 f1f60c92 Ermal Luçi
?>