Project

General

Profile

Download (41.7 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 6b07c15a Matthew Grooms
##|+PRIV
35
##|*IDENT=page-interfaces-wan
36
##|*NAME=Interfaces: WAN page
37
##|*DESCR=Allow access to the 'Interfaces: WAN' page.
38
##|*MATCH=interfaces_wan.php*
39
##|-PRIV
40
41 bd58d230 Scott Ullrich
if ($_REQUEST['if'])
42
	$if = $_REQUEST['if'];
43
else
44
	$if = "wan";
45 6b07c15a Matthew Grooms
46 58af5941 Scott Ullrich
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
47
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
48
define("CRON_DAILY_PATTERN", "0 0 * * *");
49
define("CRON_HOURLY_PATTERN", "0 * * * *");
50
define("CRON_PPPOE_CMD_FILE", "/etc/pppoerestart");
51 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");
52 58af5941 Scott Ullrich
53
function getMPDCRONSettings() {
54
  global $config;
55
56
  if (is_array($config['cron']['item'])) {
57
    for ($i = 0; $i < count($config['cron']['item']); $i++) {
58
      $item =& $config['cron']['item'][$i];
59
60
      if (strpos($item['command'], CRON_PPPOE_CMD_FILE) !== false) {
61
        return array("ID" => $i, "ITEM" => $item);
62
      }
63
    }
64
  }
65
66
  return NULL;
67
}
68
69
function getMPDResetTimeFromConfig() {
70
  $itemhash = getMPDCRONSettings();
71
  $cronitem = $itemhash['ITEM'];
72
73
  if (isset($cronitem)) {
74
75
    return "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
76
  } else {
77
    return NULL;
78
  }
79
}
80
81 f1f60c92 Ermal Luçi
function remove_bad_chars($string) {
82
        return preg_replace('/[^a-z|_|0-9]/i','',$string);
83
}
84
85 5b237745 Scott Ullrich
require("guiconfig.inc");
86
87 d173230c Seth Mos
if (!is_array($config['gateways']['gateway_item']))
88
	$config['gateways']['gateway_item'] = array();
89
$a_gateways = &$config['gateways']['gateway_item'];
90
91 f1f60c92 Ermal Luçi
$wancfg = &$config['interfaces'][$if];
92 5b237745 Scott Ullrich
93 3f425cda Ermal Luçi
$pconfig['pppoe_username'] = $wancfg['pppoe_username'];
94
$pconfig['pppoe_password'] = $wancfg['pppoe_password'];
95 f1f60c92 Ermal Luçi
$pconfig['provider'] = $wancfg['provider'];
96
$pconfig['pppoe_dialondemand'] = isset($wancfg['ondemand']);
97
$pconfig['pppoe_idletimeout'] = $wancfg['timeout'];
98 5b237745 Scott Ullrich
99 58af5941 Scott Ullrich
/* ================================================ */
100
/* = force a connection reset at a specific time? = */
101
/* ================================================ */
102
103
if (isset($wancfg['pppoe']['pppoe-reset-type'])) {
104
  $resetTime = getMPDResetTimeFromConfig();  
105
  $pconfig['pppoe_preset'] = true;
106
  
107
  if ($wancfg['pppoe']['pppoe-reset-type'] == "custom") {
108
    $resetTime_a = split(" ", $resetTime);
109
    $pconfig['pppoe_pr_custom'] = true;
110
    $pconfig['pppoe_resetminute'] = $resetTime_a[0];
111
    $pconfig['pppoe_resethour'] = $resetTime_a[1];
112
113
    /* just initialize $pconfig['pppoe_resetdate'] if the
114
     * coresponding item contains appropriate numeric values.
115
     */
116
    if ($resetTime_a[2] <> "*" && $resetTime_a[3] <> "*") {
117
      $pconfig['pppoe_resetdate'] = "{$resetTime_a[3]}/{$resetTime_a[2]}/" . date("Y");
118
    }
119
  } else if ($wancfg['pppoe']['pppoe-reset-type'] == "preset") {
120
    $pconfig['pppoe_pr_preset'] = true;
121
    
122
    switch ($resetTime) {
123
      case CRON_MONTHLY_PATTERN:
124
        $pconfig['pppoe_monthly'] = true;
125
        break;
126
      case CRON_WEEKLY_PATTERN:
127
        $pconfig['pppoe_weekly'] = true;
128
        break;
129
      case CRON_DAILY_PATTERN:
130
        $pconfig['pppoe_daily'] = true;
131
        break;
132
      case CRON_HOURLY_PATTERN:
133
        $pconfig['pppoe_hourly'] = true;
134
        break;
135
    }
136
  }
137
}
138
139 3f425cda Ermal Luçi
$pconfig['pptp_username'] = $wancfg['pptp_username'];
140
$pconfig['pptp_password'] = $wancfg['pptp_password'];
141 f1f60c92 Ermal Luçi
$pconfig['pptp_local'] = $wancfg['local'];
142
$pconfig['pptp_subnet'] = $wancfg['subnet'];
143
$pconfig['pptp_remote'] = $wancfg['remote'];
144
$pconfig['pptp_dialondemand'] = isset($wancfg['ondemand']);
145
$pconfig['pptp_idletimeout'] = $wancfg['timeout'];
146 5b237745 Scott Ullrich
147 c1ec2c2f Scott Ullrich
$pconfig['disableftpproxy'] = isset($wancfg['disableftpproxy']);
148
149 5b237745 Scott Ullrich
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
150 bc40d758 Seth Mos
$pconfig['alias-address'] = $wancfg['alias-address'];
151
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
152 f1f60c92 Ermal Luçi
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
153 4476d447 Ermal Luçi
if ($if == "wan" || $if == "lan")
154
	$pconfig['enable'] = true;
155
else
156
	$pconfig['enable'] = isset($wancfg['enable']);
157 f1f60c92 Ermal Luçi
158
if (is_array($config['aliases']['alias']))
159
foreach($config['aliases']['alias'] as $alias)
160
        if($alias['name'] == $wancfg['descr'])
161
                $input_errors[] = gettext("Sorry, an alias with the name {$wancfg['descr']} a
162
lready exists.");
163 5b237745 Scott Ullrich
164
if ($wancfg['ipaddr'] == "dhcp") {
165 4d579760 Ermal Luçi
	$pconfig['type'] = "dhcp";
166 d8948db4 Scott Ullrich
} else if ($wancfg['ipaddr'] == "carpdev-dhcp") {
167 4d579760 Ermal Luçi
	$pconfig['type'] = "carpdev-dhcp";
168 f1f60c92 Ermal Luçi
	$pconfig['ipaddr'] = "";	    
169 5b237745 Scott Ullrich
} else if ($wancfg['ipaddr'] == "pppoe") {
170 4d579760 Ermal Luçi
	$pconfig['type'] = "pppoe";
171 5b237745 Scott Ullrich
} else if ($wancfg['ipaddr'] == "pptp") {
172 4d579760 Ermal Luçi
	$pconfig['type'] = "pptp";
173
} else if ($wancfg['ipaddr'] != "") {
174
	$pconfig['type'] = "static";
175 5b237745 Scott Ullrich
	$pconfig['ipaddr'] = $wancfg['ipaddr'];
176
	$pconfig['subnet'] = $wancfg['subnet'];
177 f1f60c92 Ermal Luçi
	$pconfig['gateway'] = $wancfg['gateway'];
178 a23d7248 Scott Ullrich
	$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
179 4d579760 Ermal Luçi
} else
180
	$pconfig['type'] = "none";
181 5b237745 Scott Ullrich
182
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
183 ff1955ee Bill Marquette
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
184 5b237745 Scott Ullrich
$pconfig['spoofmac'] = $wancfg['spoofmac'];
185
$pconfig['mtu'] = $wancfg['mtu'];
186
187
/* Wireless interface? */
188 b7f01f59 Bill Marquette
if (isset($wancfg['wireless'])) {
189 5b237745 Scott Ullrich
	require("interfaces_wlan.inc");
190 45335fc4 Ermal Luçi
	wireless_config_init($wancfg);
191 5b237745 Scott Ullrich
}
192
193
if ($_POST) {
194
195
	unset($input_errors);
196 4476d447 Ermal Luçi
	$pconfig = $_POST;
197 58af5941 Scott Ullrich
  
198 f1f60c92 Ermal Luçi
	/* filter out spaces from descriptions  */
199
        $_POST['descr'] = remove_bad_chars($_POST['descr']);
200
201 4476d447 Ermal Luçi
	if ($_POST['enable'] || $if == "wan" || $if = "lan") {
202 f1f60c92 Ermal Luçi
		/* optional interface if list */
203
                $iflist = get_configured_interface_with_descr(true);
204
205
                /* description unique? */
206
                foreach ($iflist as $ifent => $ifdescr) {
207
                        if ($if != $ifent && $ifdescr == $_POST['descr'])
208
                                $input_errors[] = "An interface with the specified descriptio
209
n already exists.";
210
                }
211
212 15aea4cb Seth Mos
	/* okay first of all, cause we are just hidding the PPPoE HTML
213
	 * fields releated to PPPoE resets, we are going to unset $_POST
214
	 * vars, if the reset feature should not be used. Otherwise the
215
	 * data validation procedure below, may trigger a false error
216
	 * message.
217
	 */
218
	if (empty($_POST['pppoe_preset'])) {
219
		unset($_POST['pppoe_pr_type']);
220
		unset($_POST['pppoe_resethour']);
221
		unset($_POST['pppoe_resetminute']);
222
		unset($_POST['pppoe_resetdate']);
223
		unset($_POST['pppoe_pr_preset_val']);
224
		unlink_if_exists(CRON_PPPOE_CMD_FILE);
225
	}
226 5b237745 Scott Ullrich
227
	/* input validation */
228 4d579760 Ermal Luçi
	if ($_POST['type'] == "static") {
229 f1f60c92 Ermal Luçi
		if ($if == "wan") {
230
			$reqdfields = explode(" ", "ipaddr subnet gateway");
231
			$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
232
		} else  {
233
			$reqdfields = explode(" ", "ipaddr subnet");
234
                        $reqdfieldsn = explode(",", "IP address,Subnet bit count");
235
		}
236 5b237745 Scott Ullrich
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
237
	} else if ($_POST['type'] == "PPPoE") {
238
		if ($_POST['pppoe_dialondemand']) {
239 3f425cda Ermal Luçi
			$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
240 5b237745 Scott Ullrich
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password,Dial on demand,Idle timeout value");
241
		} else {
242 3f425cda Ermal Luçi
			$reqdfields = explode(" ", "pppoe_username pppoe_password");
243 5b237745 Scott Ullrich
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password");
244
		}
245
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
246
	} else if ($_POST['type'] == "PPTP") {
247
		if ($_POST['pptp_dialondemand']) {
248
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
249
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address,Dial on demand,Idle timeout value");
250
		} else {
251
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
252
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address");
253
		}
254
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
255
	}
256 e2cd32df Scott Ullrich
257 ad60dd49 Scott Ullrich
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
258
	$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
259 4f3401e0 Bill Marquette
260 5b237745 Scott Ullrich
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
261
		$input_errors[] = "A valid IP address must be specified.";
262
	}
263
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
264
		$input_errors[] = "A valid subnet bit count must be specified.";
265
	}
266 bc40d758 Seth Mos
	if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) {
267
		$input_errors[] = "A valid alias IP address must be specified.";
268
	}
269
	if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) {
270
		$input_errors[] = "A valid alias subnet bit count must be specified.";
271
	}
272 d173230c Seth Mos
	if ($_POST['gateway']) {
273
		$match = false;
274
		foreach($a_gateways as $gateway) {
275
			if(in_array($_POST['gateway'], $gateway)) {
276
				$match = true;
277
			}
278
		}
279
		if(!$match)
280
			$input_errors[] = "A valid gateway must be specified.";
281 5b237745 Scott Ullrich
	}
282 a23d7248 Scott Ullrich
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) {
283
		$input_errors[] = "A valid point-to-point IP address must be specified.";
284
	}
285 5b237745 Scott Ullrich
	if (($_POST['provider'] && !is_domain($_POST['provider']))) {
286
		$input_errors[] = "The service name contains invalid characters.";
287
	}
288 a23d7248 Scott Ullrich
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
289 5b237745 Scott Ullrich
		$input_errors[] = "The idle timeout value must be an integer.";
290
	}
291 15aea4cb Seth Mos
	if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) && 
292
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) {
293
		$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
294
	}
295
	if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) && 
296
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) {
297
		$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
298
	}
299
	if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) {
300
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
301
	}
302 5b237745 Scott Ullrich
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) {
303
		$input_errors[] = "A valid PPTP local IP address must be specified.";
304
	}
305
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) {
306
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
307
	}
308
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) {
309
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
310
	}
311 a23d7248 Scott Ullrich
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) {
312 5b237745 Scott Ullrich
		$input_errors[] = "The idle timeout value must be an integer.";
313
	}
314
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) {
315
		$input_errors[] = "A valid MAC address must be specified.";
316
	}
317 c33e18c2 Ermal Luçi
	if ($_POST['mtu'] && ($_POST['mtu'] < 576)) {
318
		$input_errors[] = "The MTU must be greater than 576 bytes.";
319 5b237745 Scott Ullrich
	}
320 f1f60c92 Ermal Luçi
	}
321 e2cd32df Scott Ullrich
322 5b237745 Scott Ullrich
	/* Wireless interface? */
323 b7f01f59 Bill Marquette
	if (isset($wancfg['wireless'])) {
324 45335fc4 Ermal Luçi
		$wi_input_errors = wireless_config_post($wancfg);
325 4d579760 Ermal Luçi
		if (!is_array($input_errors))
326
			$input_errors = array();
327
		if (is_array($wi_input_errors)) {
328 5b237745 Scott Ullrich
			$input_errors = array_merge($input_errors, $wi_input_errors);
329
		}
330
	}
331
332
	if (!$input_errors) {
333 e2cd32df Scott Ullrich
334 5b237745 Scott Ullrich
		unset($wancfg['ipaddr']);
335
		unset($wancfg['subnet']);
336 f1f60c92 Ermal Luçi
		unset($wancfg['gateway']);
337 a23d7248 Scott Ullrich
		unset($wancfg['pointtopoint']);
338 5b237745 Scott Ullrich
		unset($wancfg['dhcphostname']);
339 3f425cda Ermal Luçi
		unset($wancfg['pppoe_username']);
340
		unset($wancfg['pppoe_password']);
341
		unset($wancfg['pptp_username']);
342
		unset($wancfg['pptp_password']);
343 f1f60c92 Ermal Luçi
		unset($wancfg['provider']);
344
		unset($wancfg['ondemand']);
345
		unset($wancfg['timeout']);
346 67473d80 Ermal Luçi
		if ($wancfg['pppoe']['pppoe-reset-type'])
347
			unset($wancfg['pppoe']['pppoe-reset-type']);
348 f1f60c92 Ermal Luçi
		unset($wancfg['local']);
349
		unset($wancfg['subnet']);
350
		unset($wancfg['remote']);
351 c1ec2c2f Scott Ullrich
		unset($wancfg['disableftpproxy']);
352 b1c525ee Scott Ullrich
353 c1ec2c2f Scott Ullrich
		/* per interface pftpx helper */
354
		if($_POST['disableftpproxy'] == "yes") {
355
			$wancfg['disableftpproxy'] = true;
356
			system_start_ftp_helpers();
357 b1c525ee Scott Ullrich
		} else {
358 c1ec2c2f Scott Ullrich
			system_start_ftp_helpers();
359
		}
360 e2cd32df Scott Ullrich
361 f1f60c92 Ermal Luçi
		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
362 4476d447 Ermal Luçi
		if ($if == "wan" || $if == "lan")
363
			$wancfg['enable'] = true;
364
		else
365
			$wancfg['enable'] =  $_POST['enable'] ? true : false;
366 f1f60c92 Ermal Luçi
367 4d579760 Ermal Luçi
		if ($_POST['type'] == "static") {
368 5b237745 Scott Ullrich
			$wancfg['ipaddr'] = $_POST['ipaddr'];
369
			$wancfg['subnet'] = $_POST['subnet'];
370 f1f60c92 Ermal Luçi
			$wancfg['gateway'] = $_POST['gateway'];
371 a23d7248 Scott Ullrich
			if (isset($wancfg['ispointtopoint']))
372
				$wancfg['pointtopoint'] = $_POST['pointtopoint'];
373 4d579760 Ermal Luçi
		} else if ($_POST['type'] == "dhcp") {
374 5b237745 Scott Ullrich
			$wancfg['ipaddr'] = "dhcp";
375
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
376 bc40d758 Seth Mos
			$wancfg['alias-address'] = $_POST['alias-address'];
377
			$wancfg['alias-subnet'] = $_POST['alias-subnet'];
378 4d579760 Ermal Luçi
		} else if ($_POST['type'] == "carpdev-dhcp") {
379 d5d00b83 Scott Ullrich
			$wancfg['ipaddr'] = "carpdev-dhcp";
380
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
381
			$wancfg['alias-address'] = $_POST['alias-address'];
382
			$wancfg['alias-subnet'] = $_POST['alias-subnet'];			
383 4d579760 Ermal Luçi
		} else if ($_POST['type'] == "pppoe") {
384 5b237745 Scott Ullrich
			$wancfg['ipaddr'] = "pppoe";
385 3f425cda Ermal Luçi
			$wancfg['pppoe_username'] = $_POST['pppoe_username'];
386
			$wancfg['pppoe_password'] = $_POST['pppoe_password'];
387 f1f60c92 Ermal Luçi
			$wancfg['provider'] = $_POST['provider'];
388
			$wancfg['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
389
			$wancfg['timeout'] = $_POST['pppoe_idletimeout'];
390 58af5941 Scott Ullrich
      
391 15aea4cb Seth Mos
			/* perform a periodic reset? */
392
			if (isset($_POST['pppoe_preset'])) {
393
				if (! is_array($config['cron']['item'])) { $config['cron']['item'] = array(); }
394
395
					$itemhash = getMPDCRONSettings();
396
					$item = $itemhash['ITEM'];
397
398
					if (empty($item)) {
399
						$item = array();
400
					}
401
402
					if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] == "custom") {
403
						$wancfg['pppoe']['pppoe-reset-type'] = "custom";
404
						$pconfig['pppoe_pr_custom'] = true;
405
406
						$item['minute'] = $_POST['pppoe_resetminute'];
407
						$item['hour'] = $_POST['pppoe_resethour'];
408
409
						if (isset($_POST['pppoe_resetdate']) && 
410
							$_POST['pppoe_resetdate'] <> "" && 
411
							strlen($_POST['pppoe_resetdate']) == 10) {
412
							$date = explode("/", $_POST['pppoe_resetdate']);
413
							$item['mday'] = $date[1];
414
							$item['month'] = $date[0];
415
						} else {
416
							$item['mday'] = "*";
417
							$item['month'] = "*";
418
						}
419
						$item['wday'] = "*";
420
						$item['who'] = "root";
421
						$item['command'] = CRON_PPPOE_CMD_FILE;
422
					} else if (isset($_POST['pppoe_pr_type']) && $_POST['pppoe_pr_type'] = "preset") {
423
						$wancfg['pppoe']['pppoe-reset-type'] = "preset";
424
						$pconfig['pppoe_pr_preset'] = true;
425
426
						switch ($_POST['pppoe_pr_preset_val']) {
427
							case "monthly":
428
								$item['minute'] = "0";
429
								$item['hour'] = "0";
430
								$item['mday'] = "1";
431
								$item['month'] = "*";
432
								$item['wday'] = "*";
433
								$item['who'] = "root";
434
								$item['command'] = CRON_PPPOE_CMD_FILE;
435
								break;
436
					        	case "weekly":
437
								$item['minute'] = "0";
438
								$item['hour'] = "0";
439
								$item['mday'] = "*";
440
								$item['month'] = "*";
441
								$item['wday'] = "0";
442
								$item['who'] = "root";
443
								$item['command'] = CRON_PPPOE_CMD_FILE;
444
								break;
445
							case "daily":
446
								$item['minute'] = "0";
447
								$item['hour'] = "0";
448
								$item['mday'] = "*";
449
								$item['month'] = "*";
450
								$item['wday'] = "*";
451
								$item['who'] = "root";
452
								$item['command'] = CRON_PPPOE_CMD_FILE;
453
								break;
454
							case "hourly":
455
								$item['minute'] = "0";
456
								$item['hour'] = "*";
457
								$item['mday'] = "*";
458
								$item['month'] = "*";
459
								$item['wday'] = "*";
460
								$item['who'] = "root";
461
								$item['command'] = CRON_PPPOE_CMD_FILE;
462
								break;
463
						} // end switch
464
					} // end if
465
				if (isset($itemhash['ID'])) {
466
					$config['cron']['item'][$itemhash['ID']] = $item;
467
				} else {
468
					$config['cron']['item'][] = $item;
469
				}
470
			} // end if
471 4d579760 Ermal Luçi
		} else if ($_POST['type'] == "pptp") {
472 5b237745 Scott Ullrich
			$wancfg['ipaddr'] = "pptp";
473 3f425cda Ermal Luçi
			$wancfg['pptp_username'] = $_POST['pptp_username'];
474
			$wancfg['pptp_password'] = $_POST['pptp_password'];
475 f1f60c92 Ermal Luçi
			$wancfg['local'] = $_POST['pptp_local'];
476
			$wancfg['subnet'] = $_POST['pptp_subnet'];
477
			$wancfg['remote'] = $_POST['pptp_remote'];
478
			$wancfg['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
479
			$wancfg['timeout'] = $_POST['pptp_idletimeout'];
480 5b237745 Scott Ullrich
		}
481 58af5941 Scott Ullrich
    
482 15aea4cb Seth Mos
		/* reset cron items if necessary */
483
		if (empty($_POST['pppoe_preset'])) {
484
			/* test whether a cron item exists and unset() it if necessary */
485
			$itemhash = getMPDCRONSettings();
486
			$item = $itemhash['ITEM'];
487
			if (isset($item)) { unset($config['cron']['item'][$itemhash['ID']]); }
488
		}
489 e2cd32df Scott Ullrich
490 90ebf755 Scott Ullrich
		if($_POST['blockpriv'] == "yes")
491
			$wancfg['blockpriv'] = true;
492
		else
493 42a58cb9 Scott Ullrich
			unset($wancfg['blockpriv']);
494 b1c525ee Scott Ullrich
495 90ebf755 Scott Ullrich
		if($_POST['blockbogons'] == "yes")
496
			$wancfg['blockbogons'] = true;
497
		else
498
			unset($wancfg['blockbogons']);
499 b1c525ee Scott Ullrich
500 5b237745 Scott Ullrich
		$wancfg['spoofmac'] = $_POST['spoofmac'];
501
		$wancfg['mtu'] = $_POST['mtu'];
502 e2cd32df Scott Ullrich
503 5b237745 Scott Ullrich
		write_config();
504 4476d447 Ermal Luçi
	
505 3f425cda Ermal Luçi
		if ($if = "lan") {
506
			/* restart snmp so that it binds to correct address */
507
                	services_snmpd_configure();
508
			$savemsg = "The changes have been applied.  You may need to correct your web browser's IP address.";
509
		}
510 58af5941 Scott Ullrich
    
511
		/* finally install the pppoerestart file */
512
		if (isset($_POST['pppoe_preset'])) {
513 15aea4cb Seth Mos
		config_lock();
514
		conf_mount_rw();
515 58af5941 Scott Ullrich
      
516 15aea4cb Seth Mos
		if (! file_exists(CRON_PPPOE_CMD_FILE)) {
517
			file_put_contents(CRON_PPPOE_CMD_FILE, CRON_PPPOE_CMD);
518
			chmod(CRON_PPPOE_CMD_FILE, 0700);
519
		}
520 58af5941 Scott Ullrich
      
521 15aea4cb Seth Mos
		/* regenerate cron settings/crontab file */
522
		configure_cron();
523
		sigkillbypid("{$g['varrun_path']}/cron.pid", "HUP");
524 58af5941 Scott Ullrich
      
525 15aea4cb Seth Mos
		conf_mount_ro();
526
		config_unlock();
527 58af5941 Scott Ullrich
		}
528 e2cd32df Scott Ullrich
529 5b237745 Scott Ullrich
		$retval = 0;
530 824edb6c Scott Ullrich
		$savemsg = get_std_save_message($retval);
531 5b237745 Scott Ullrich
	}
532
}
533 7f43ca88 Scott Ullrich
534 bd58d230 Scott Ullrich
// Populate page descr if it does not exist.
535
if($if == "wan" && !$wancfg['descr'])
536
	$wancfg['descr'] = "WAN";
537 4476d447 Ermal Luçi
else if ($if == "lan" && !$wancfg['descr'])
538
	$wancfg['descr'] = "LAN";
539 bd58d230 Scott Ullrich
	
540 f1f60c92 Ermal Luçi
$pgtitle = array("Interfaces", $wancfg['descr']);
541 58af5941 Scott Ullrich
$closehead = false;
542 7f43ca88 Scott Ullrich
include("head.inc");
543
544 4d579760 Ermal Luçi
        $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" => "PPPoE", "pptp" => "PPTP" /* , "carpdev-dhcp" => "CarpDev"*/); 
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
559 4d579760 Ermal Luçi
function updateType(t){
560
        switch(t) {
561
<?php
562
        /* OK, so this is sick using php to generate javascript, but it needed to be done */
563
        foreach ($types as $key => $val) {
564
                echo "          case \"{$key}\": {\n";
565
                $t = $types;
566
                foreach ($t as $k => $v) {
567
                        if ($k != $key) {
568
                                echo "                  $('{$k}').hide();\n";
569
                        }
570
                }
571
                echo "          }\n";
572
        }
573
?>
574
        }
575
        $(t).appear();
576 5b237745 Scott Ullrich
}
577
578 4d579760 Ermal Luçi
function show_allcfg(obj) {
579
	if (obj.checked)
580
		$('allcfg').appear();
581
	else
582
		$('allcfg').hide();
583 5b237745 Scott Ullrich
}
584 15aea4cb Seth Mos
585
function show_mon_config() {
586
	document.getElementById("showmonbox").innerHTML='';
587
	aodiv = document.getElementById('showmon');
588
	aodiv.style.display = "block";
589
}
590
591 5b237745 Scott Ullrich
//-->
592
</script>
593 58af5941 Scott Ullrich
</head>
594 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
595
<?php include("fbegin.inc"); ?>
596
<?php if ($input_errors) print_input_errors($input_errors); ?>
597 4476d447 Ermal Luçi
598 5b237745 Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
599 3f425cda Ermal Luçi
            <form action="interfaces_wan.php?if=<?php echo "{$if}";?>" method="post" name="iform" id="iform">
600 5b237745 Scott Ullrich
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
601 e2cd32df Scott Ullrich
                <tr>
602 8fdc8744 Bill Marquette
                  <td colspan="2" valign="top" class="listtopic">General configuration</td>
603
                </tr>
604 4476d447 Ermal Luçi
<?php if ($if != "wan" || $if != "lan"): ?>
605 f1f60c92 Ermal Luçi
                <tr>
606
                  <td width="22%" valign="top" class="vtable">&nbsp;</td>
607
                  <td width="78%" class="vtable">
608 4d579760 Ermal Luçi
                        <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="show_allcfg(this);">
609 39571a23 Ermal Luçi
                    <strong>Enable Interface</strong></td>
610 f1f60c92 Ermal Luçi
                </tr>
611
<?php endif; ?>
612 4d579760 Ermal Luçi
		<tr style="display:none;" name="allcfg" id="allcfg">
613
		<td colspan="2"> 
614
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
615 f1f60c92 Ermal Luçi
                <tr>
616
                  <td width="22%" valign="top" class="vncell">Description</td>
617
                  <td width="78%" class="vtable">
618 96e00c2f Bill Marquette
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="30" value="<?=htmlspecialchars($pconfig['descr']);?>">
619 14b3a55b Bill Marquette
                                        <br> <span class="vexpl">Enter a description (name) for the interface here.</span>
620 f1f60c92 Ermal Luçi
                  </td>
621
                </tr>
622 8fdc8744 Bill Marquette
                <tr>
623
                  <td valign="middle" class="vncell"><strong>Type</strong></td>
624 9573a419 Ermal Luçi
                  <td class="vtable"> <select name="type" onChange="updateType(this.value);" class="formselect" id="type">
625 4d579760 Ermal Luçi
                      <?php 
626
			foreach ($types as $key => $opt) { 
627
	                      echo "<option onClick=\"updateType('{$key}');\"";
628
			      if ($key == $pconfig['type']) 
629
				echo " selected";
630
			      echo " value=\"{$key}\" >" . htmlspecialchars($opt);
631
	                      echo "</option>";
632
                      } ?>
633 5b237745 Scott Ullrich
                    </select></td>
634
                </tr>
635 e2cd32df Scott Ullrich
                <tr>
636 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">MAC address</td>
637 b5c78501 Seth Mos
                  <td class="vtable"> <input name="spoofmac" type="text" class="formfld unknown" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
638 1e694bee Scott Ullrich
		    <?php
639
			$ip = getenv('REMOTE_ADDR');
640
			$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
641
			$mac = str_replace("\n","",$mac);
642
		    ?>
643 b1c525ee Scott Ullrich
		    <a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#">Copy my MAC address</a>
644 1e694bee Scott Ullrich
		    <br>
645 e2cd32df Scott Ullrich
                    This field can be used to modify (&quot;spoof&quot;) the MAC
646 5b237745 Scott Ullrich
                    address of the WAN interface<br>
647
                    (may be required with some cable connections)<br>
648 e2cd32df Scott Ullrich
                    Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx
649 5b237745 Scott Ullrich
                    or leave blank</td>
650
                </tr>
651 e2cd32df Scott Ullrich
                <tr>
652 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">MTU</td>
653 b5c78501 Seth Mos
                  <td class="vtable"> <input name="mtu" type="text" class="formfld unknown" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
654 5b237745 Scott Ullrich
                    <br>
655 e2cd32df Scott Ullrich
                    If you enter a value in this field, then MSS clamping for
656
                    TCP connections to the value entered above minus 40 (TCP/IP
657
                    header size) will be in effect. If you leave this field blank,
658
                    an MTU of 1492 bytes for PPPoE and 1500 bytes for all other
659 5b237745 Scott Ullrich
                    connection types will be assumed.</td>
660
                </tr>
661 4d579760 Ermal Luçi
		<tr style="display:none;" name="none" id="none">
662
		</tr>
663
		<tr style="display:none;" name="static" id="static">
664
		<td colspan="2">
665
        <table width="100%" border="0" cellpadding="6" cellspacing="0">
666
		<tr>
667 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">Static IP configuration</td>
668 5b237745 Scott Ullrich
                </tr>
669 e2cd32df Scott Ullrich
                <tr>
670 4d579760 Ermal Luçi
                  <td width="22%" valign="top" class="vncellreq">IP address</td>
671
                  <td width="78%" class="vtable"> <input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
672 e2cd32df Scott Ullrich
                    /
673 b5c78501 Seth Mos
                    <select name="subnet" class="formselect" id="subnet">
674 fa3b333d Scott Ullrich
			<?php
675
			for ($i = 32; $i > 0; $i--) {
676
				if($i <> 31) {
677
					echo "<option value=\"{$i}\" ";
678
					if ($i == $pconfig['subnet']) echo "selected";
679
					echo ">" . $i . "</option>";
680
				}
681
			}
682
			?>
683 5b237745 Scott Ullrich
                    </select></td>
684 a23d7248 Scott Ullrich
                </tr><?php if (isset($wancfg['ispointtopoint'])): ?>
685 7f5b4824 Scott Ullrich
                <tr>
686 4d579760 Ermal Luçi
                  <td width="22%" valign="top" class="vncellreq">Point-to-point IP address </td>
687
                  <td width"78%" class="vtable">
688 b5c78501 Seth Mos
                    <input name="pointtopoint" type="text" class="formfld unknown" id="pointtopoint" size="20" value="<?=htmlspecialchars($pconfig['pointtopoint']);?>">
689 a23d7248 Scott Ullrich
                  </td>
690
                </tr><?php endif; ?>
691 e2cd32df Scott Ullrich
                <tr>
692 4d579760 Ermal Luçi
                  <td width="22%" valign="top" class="vncellreq">Gateway</td>
693
                  <td width="78%" class="vtable"><select name="gateway" class="formselect" id="gateway">
694 d173230c Seth Mos
			<?php
695 2be84cfa Seth Mos
			if(count($a_gateways) > 0) {
696
				foreach ($a_gateways as $gateway) {
697 f1f60c92 Ermal Luçi
					if($gateway['interface'] == $if) {
698 d173230c Seth Mos
			?>
699
					<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
700
					<?=htmlspecialchars($gateway['name']);?>
701
					</option>
702
			<?php
703 2be84cfa Seth Mos
					}
704 d173230c Seth Mos
				}
705
			}
706
			?>
707 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>
708 5b237745 Scott Ullrich
                  </td>
709
                </tr>
710 4d579760 Ermal Luçi
	</table>
711
	</td>
712
	</tr>
713
		<tr style="display:none;" name="dhcp" id="dhcp">
714
		<td colspan="2">
715
        <table width="100%" border="0" cellpadding="6" cellspacing="0">
716 e2cd32df Scott Ullrich
                <tr>
717 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">DHCP client configuration</td>
718 5b237745 Scott Ullrich
                </tr>
719 e2cd32df Scott Ullrich
                <tr>
720 4d579760 Ermal Luçi
                  <td width="22%" valign="top" class="vncell">Hostname</td>
721
                  <td width="78%" class="vtable"> <input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
722 5b237745 Scott Ullrich
                    <br>
723 e2cd32df Scott Ullrich
                    The value in this field is sent as the DHCP client identifier
724
                    and hostname when requesting a DHCP lease. Some ISPs may require
725 5b237745 Scott Ullrich
                    this (for client identification).</td>
726
                </tr>
727 bc40d758 Seth Mos
                <tr>
728 4d579760 Ermal Luçi
                  <td width="22%" valign="top" class="vncellreq">Alias IP address</td>
729
                  <td width="78%" class="vtable"> <input name="alias-address" type="text" class="formfld unknown" id="alias-address" size="20" value="<?=htmlspecialchars($pconfig['alias-address']);?>">
730 bc40d758 Seth Mos
                    <select name="alias-subnet" class="formselect" id="alias-subnet">
731
			<?php
732
			for ($i = 32; $i > 0; $i--) {
733
				if($i <> 31) {
734
					echo "<option value=\"{$i}\" ";
735
					if ($i == $pconfig['alias-subnet']) echo "selected";
736
					echo ">" . $i . "</option>";
737
				}
738
			}
739
			?>
740
                    </select>
741
                    The value in this field is used as a fixed alias IP address by the
742
		    DHCP client.</td>
743
                </tr>
744 4d579760 Ermal Luçi
	</table>
745
	</td>
746
	</tr>
747
                <tr style="display:none;" name="pppoe" id="pppoe">
748
		<td colspan="2">
749
	<table width="100%" border="0" cellpadding="6" cellspacing="0">
750 e2cd32df Scott Ullrich
                <tr>
751 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">PPPoE configuration</td>
752 5b237745 Scott Ullrich
                </tr>
753 4d579760 Ermal Luçi
		<tr>
754
                  <td width="22%" valign="top" class="vncellreq">Username</td>
755 3f425cda Ermal Luçi
                  <td width="78%" class="vtable"><input name="pppoe_username" type="text" class="formfld user" id="pppoe_username" size="20" value="<?=htmlspecialchars($pconfig['pppoe_username']);?>">
756 5b237745 Scott Ullrich
                  </td>
757
                </tr>
758 e2cd32df Scott Ullrich
                <tr>
759 4d579760 Ermal Luçi
                  <td width="22%" valign="top" class="vncellreq">Password</td>
760 3f425cda Ermal Luçi
                  <td width="78%" class="vtable"><input name="pppoe_password" type="password" class="formfld pwd" id="pppoe_password" size="20" value="<?=htmlspecialchars($pconfig['pppoe_password']);?>">
761 5b237745 Scott Ullrich
                  </td>
762
                </tr>
763 e2cd32df Scott Ullrich
                <tr>
764 4d579760 Ermal Luçi
                  <td width="22%" valign="top" class="vncell">Service name</td>
765
                  <td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
766 e2cd32df Scott Ullrich
                    <br> <span class="vexpl">Hint: this field can usually be left
767 5b237745 Scott Ullrich
                    empty</span></td>
768
                </tr>
769 e2cd32df Scott Ullrich
                <tr>
770 4d579760 Ermal Luçi
                  <td width="22%" valign="top" class="vncell">Dial on demand</td>
771
                  <td width="78%" class="vtable"><input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?>" >
772 5b237745 Scott Ullrich
                    <strong>Enable Dial-On-Demand mode</strong><br>
773
		    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>
774
                </tr>
775
                <tr>
776 4d579760 Ermal Luçi
                  <td width="22%" valign="top" class="vncell">Idle timeout</td>
777
                  <td width="78%" class="vtable">
778 b5c78501 Seth Mos
                    <input name="pppoe_idletimeout" type="text" class="formfld unknown" id="pppoe_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pppoe_idletimeout']);?>"> 
779
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>
780 5b237745 Scott Ullrich
                </tr>
781 58af5941 Scott Ullrich
                <tr>
782 4d579760 Ermal Luçi
                  <td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
783
                  <td width="78%" class="vtable">
784 58af5941 Scott Ullrich
                    <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 });" />
785
                    <?= gettext("enable periodic PPPoE resets"); ?>
786
                    <br />
787
                    <?php if ($pconfig['pppoe_preset']): ?>
788
                    <table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
789
                    <?php else: ?>
790
                    <table id="presetwrap" cellspacing="0" cellpadding="0" width="100%" style="display: none;">
791
                    <?php endif; ?>
792
                      <tr>
793
                        <td align="left" valign="top">
794
                          <p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
795
                            <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 }); }" /> 
796
                            <?= gettext("provide a custom reset time"); ?>
797
                            <br />
798
                            <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 }); }" /> 
799
                            <?= gettext("select reset time from a preset"); ?>
800
                          </p>
801
                          <?php if ($pconfig['pppoe_pr_custom']): ?>
802
                          <p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
803
                          <?php else: ?>
804
                          <p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
805
                          <?php endif; ?>
806
                            <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" /> 
807
                            <?= gettext("hour (0-23)"); ?><br />
808
                            <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" /> 
809
                            <?= gettext("minute (0-59)"); ?><br />
810
                            <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']);?>" /> 
811
                            <?= gettext("reset at a specific date (mm/dd/yyyy)"); ?>
812
                            <br />&nbsp;<br />
813
                            <span class="red"><strong>Note: </strong></span>
814
                            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.
815
                          </p>
816
                          <?php if ($pconfig['pppoe_pr_preset']): ?>
817
                          <p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
818
                          <?php else: ?>
819
                          <p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
820
                          <?php endif; ?>
821
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> /> 
822
                            <?= gettext("reset at each month ('0 0 1 * *')"); ?>
823
                            <br />
824
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> /> 
825
                            <?= gettext("reset at each week ('0 0 * * 0')"); ?>
826
                            <br />
827
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> /> 
828
                            <?= gettext("reset at each day ('0 0 * * *')"); ?>
829
                            <br />
830
                            <input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> /> 
831
                            <?= gettext("reset at each hour ('0 * * * *')"); ?>
832
                          </p>
833
                        </td>
834
                      </tr>
835
                    </table>
836
                  </td>
837
                </tr>                
838 4d579760 Ermal Luçi
	</table>
839
		</td>
840
		</tr>
841
		<tr style="display:none;" name="pptp" id="pptp">
842
		<td colspan="2">
843
        <table width="100%" border="0" cellpadding="6" cellspacing="0">
844 e2cd32df Scott Ullrich
                <tr>
845 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">PPTP configuration</td>
846 5b237745 Scott Ullrich
                </tr>
847 e2cd32df Scott Ullrich
                <tr>
848 4d579760 Ermal Luçi
                  <td width="22%" valign="top" class="vncellreq">Username</td>
849
                  <td width="78%" class="vtable"><input name="pptp_username" type="text" class="formfld user" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
850 5b237745 Scott Ullrich
                  </td>
851
                </tr>
852 e2cd32df Scott Ullrich
                <tr>
853 4d579760 Ermal Luçi
                  <td width="22%" valign="top" class="vncellreq">Password</td>
854
                  <td width="78%" class="vtable"><input name="pptp_password" type="text" class="formfld pwd" id="pptp_password" size="20" 
855 b5c78501 Seth Mos
value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
856 5b237745 Scott Ullrich
                  </td>
857
                </tr>
858 e2cd32df Scott Ullrich
                <tr>
859 4d579760 Ermal Luçi
                  <td width="22%" width="100" valign="top" class="vncellreq">Local IP address</td>
860
                  <td width="78%" class="vtable"> <input name="pptp_local" type="text" class="formfld unknown" id="pptp_local" size="20" 
861 b5c78501 Seth Mos
value="<?=htmlspecialchars($pconfig['pptp_local']);?>">
862 e2cd32df Scott Ullrich
                    /
863 b5c78501 Seth Mos
                    <select name="pptp_subnet" class="formselect" id="pptp_subnet">
864 a23d7248 Scott Ullrich
                      <?php for ($i = 31; $i > 0; $i--): ?>
865 e2cd32df Scott Ullrich
                      <option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet']) echo "selected"; ?>>
866 5b237745 Scott Ullrich
                      <?=$i;?>
867
                      </option>
868
                      <?php endfor; ?>
869
                    </select></td>
870
                </tr>
871 e2cd32df Scott Ullrich
                <tr>
872 4d579760 Ermal Luçi
                  <td width="22%" width="100" valign="top" class="vncellreq">Remote IP address</td>
873
                  <td width="78%" class="vtable"> <input name="pptp_remote" type="text" class="formfld unknown" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote']);?>">
874 5b237745 Scott Ullrich
                  </td>
875
                </tr>
876 e2cd32df Scott Ullrich
                <tr>
877 4d579760 Ermal Luçi
                  <td width="22%" valign="top" class="vncell">Dial on demand</td>
878
                  <td width="78%" class="vtable"><input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?>" >
879 5b237745 Scott Ullrich
                    <strong>Enable Dial-On-Demand mode</strong><br>
880
		    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>
881
                </tr>
882
                <tr>
883 4d579760 Ermal Luçi
                  <td width="22%" valign="top" class="vncell">Idle timeout</td>
884
                  <td width="78%" class="vtable">
885 b5c78501 Seth Mos
                    <input name="pptp_idletimeout" type="text" class="formfld unknown" id="pptp_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pptp_idletimeout']);?>"> 
886
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>
887 5b237745 Scott Ullrich
                </tr>
888 4d579760 Ermal Luçi
	</table>
889
	</td>
890
	</tr>
891
	<tr>
892
                  <td width="100" valign="top"></td>
893
                  <td> <input name="Submit" type="submit" class="formbtn" value="Save"></td>
894
	</tr>
895
		<tr>
896
			<td colspan="2" valign="top" height="10"></td>
897
		</tr>
898 da56c4d7 Scott Ullrich
                <tr>
899 15aea4cb Seth Mos
                  <td colspan="2" valign="top" class="listtopic">Other</td>
900 b1c525ee Scott Ullrich
                </tr>
901 da56c4d7 Scott Ullrich
		<tr>
902
			<td width="22%" valign="top" class="vncell">FTP Helper</td>
903
			<td width="78%" class="vtable">
904 4d579760 Ermal Luçi
				<input name="disableftpproxy" type="checkbox" id="disableftpproxy" value="yes" <?php if ($pconfig['disableftpproxy']) echo "checked"; ?> />
905 da56c4d7 Scott Ullrich
				<strong>Disable the userland FTP-Proxy application</strong>
906
				<br />
907
			</td>
908
		</tr>
909 fa3b333d Scott Ullrich
		        <?php
910
				/* Wireless interface? */
911 b7f01f59 Bill Marquette
				if (isset($wancfg['wireless']))
912 45335fc4 Ermal Luçi
					wireless_config_print($wancfg);
913 fa3b333d Scott Ullrich
			?>
914 e2cd32df Scott Ullrich
                <tr>
915 5b237745 Scott Ullrich
                  <td height="16" colspan="2" valign="top"></td>
916
                </tr>
917 e2cd32df Scott Ullrich
                <tr>
918 5b237745 Scott Ullrich
                  <td valign="middle">&nbsp;</td>
919 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"; ?>>
920 5b237745 Scott Ullrich
                    <strong>Block private networks</strong><br>
921 e2cd32df Scott Ullrich
                    When set, this option blocks traffic from IP addresses that
922 5b237745 Scott Ullrich
                    are reserved for private<br>
923 e2cd32df Scott Ullrich
                    networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as
924 5b237745 Scott Ullrich
                    well as loopback addresses<br>
925 e2cd32df Scott Ullrich
                    (127/8). You should generally leave this option turned on,
926 5b237745 Scott Ullrich
                    unless your WAN network<br>
927
                    lies in such a private address space, too.</td>
928
                </tr>
929 ff1955ee Bill Marquette
                <tr>
930
                  <td valign="middle">&nbsp;</td>
931
                  <td class="vtable"> <input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
932
                    <strong>Block bogon networks</strong><br>
933
                    When set, this option blocks traffic from IP addresses that
934
                    are reserved (but not RFC 1918) or not yet assigned by IANA.<br>
935
                    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>
936 c1ec2c2f Scott Ullrich
		</tr>
937 4d579760 Ermal Luçi
        </table>
938
        </td>
939
        </tr>
940 e2cd32df Scott Ullrich
                <tr>
941 5b237745 Scott Ullrich
                  <td width="100" valign="top">&nbsp;</td>
942 4d579760 Ermal Luçi
                  <td> &nbsp;<br> <input name="Submit" type="submit" class="formbtn" value="Save">
943 f1f60c92 Ermal Luçi
			<input name="if" type="hidden" id="if" value="<?=$if;?>">
944 5b237745 Scott Ullrich
                  </td>
945
                </tr>
946
              </table>
947
</form>
948
<script language="JavaScript">
949
<!--
950 4d579760 Ermal Luçi
<?php
951 4476d447 Ermal Luçi
if ($if == "wan" || $if = "lan")
952 4d579760 Ermal Luçi
	echo "\$('allcfg').appear();";
953
else
954
	echo "show_allcfg(document.iform.enable);";
955
echo "updateType('{$pconfig['type']}')";
956
?>
957 5b237745 Scott Ullrich
//-->
958
</script>
959
<?php include("fend.inc"); ?>
960
</body>
961
</html>
962 e4e8c30f Scott Ullrich
963
964
<?php
965
966
if ($_POST) {
967
968
	if (!$input_errors) {
969 b1c525ee Scott Ullrich
970
		unlink_if_exists("{$g['tmp_path']}/config.cache");
971
972 2e70a096 Scott Ullrich
		ob_flush();
973
		flush();
974 b1c525ee Scott Ullrich
		sleep(1);
975
976 f1f60c92 Ermal Luçi
		interfaces_wan_configure($if);
977 b1c525ee Scott Ullrich
978 610b1136 Scott Ullrich
		reset_carp();
979 b1c525ee Scott Ullrich
980 e4e8c30f Scott Ullrich
		/* sync filter configuration */
981
		filter_configure();
982 8e11b23f Scott Ullrich
983
 		/* set up static routes */
984
		system_routing_configure();
985
986 e4e8c30f Scott Ullrich
	}
987
}
988
989 f1f60c92 Ermal Luçi
?>