Project

General

Profile

Download (38.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	interfaces_ppps_edit.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9
	Copyright (C) 2010 Gabriel B. <gnoahb@gmail.com>.
10
	All rights reserved.
11

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

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

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

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

    
37
##|+PRIV
38
##|*IDENT=page-interfaces-ppps-edit
39
##|*NAME=Interfaces: PPPs: Edit page
40
##|*DESCR=Allow access to the 'Interfaces: PPPs: Edit' page.
41
##|*MATCH=interfaces_ppps_edit.php*
42
##|-PRIV
43

    
44
require("guiconfig.inc");
45
require("functions.inc");
46

    
47
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
48
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
49
define("CRON_DAILY_PATTERN", "0 0 * * *");
50
define("CRON_HOURLY_PATTERN", "0 * * * *");
51

    
52
if (!is_array($config['ppps']['ppp']))
53
	$config['ppps']['ppp'] = array();
54

    
55
$a_ppps = &$config['ppps']['ppp'];
56

    
57
$iflist = get_configured_interface_with_descr();
58
$portlist = get_interface_list();
59
$portlist = array_merge($portlist, $iflist);
60

    
61
$id = $_GET['id'];
62
if (isset($_POST['id']))
63
	$id = $_POST['id'];
64
	
65
if (isset($id) && $a_ppps[$id]) {
66
	$pconfig['ptpid'] = $a_ppps[$id]['ptpid'];
67
	$pconfig['type'] = $a_ppps[$id]['type'];
68
	//$pconfig['if'] = $a_ppps[$id]['if'];
69
	$pconfig['interfaces'] = $a_ppps[$id]['ports'];
70
	$pconfig['username'] = $a_ppps[$id]['username'];
71
	$pconfig['password'] = base64_decode($a_ppps[$id]['password']);
72
	if (isset($a_ppps[$id]['ondemand']))
73
		$pconfig['ondemand'] = true;
74
	$pconfig['idletimeout'] = $a_ppps[$id]['idletimeout'];
75
	$pconfig['uptime'] = $a_ppps[$id]['uptime'];
76
	$pconfig['descr'] = $a_ppps[$id]['descr'];
77
	$pconfig['bandwidth'] = explode(",",$a_ppps[$id]['bandwidth']);
78
	$pconfig['mtu'] = explode(",",$a_ppps[$id]['mtu']);
79
	$pconfig['mru'] = explode(",",$a_ppps[$id]['mru']);
80
	$pconfig['mrru'] = explode(",",$a_ppps[$id]['mrru']);
81
	if (isset($a_ppps[$id]['shortseq']))
82
		$pconfig['shortseq'] = true;
83
	if (isset($a_ppps[$id]['acfcomp']))
84
		$pconfig['acfcomp'] = true;
85
	if (isset($a_ppps[$id]['protocomp']))
86
		$pconfig['protocomp'] = true;
87
	if (isset($a_ppps[$id]['vjcomp']))
88
		$pconfig['vjcomp'] = true;
89
	if (isset($a_ppps[$id]['tcpmssfix']))
90
		$pconfig['tcpmssfix'] = true;
91
	switch($a_ppps[$id]['type']) {
92
		case "ppp":
93
			$pconfig['initstr'] = base64_decode($a_ppps[$id]['initstr']);
94
			$pconfig['simpin'] = $a_ppps[$id]['simpin'];
95
			$pconfig['pin-wait'] = $a_ppps[$id]['pin-wait'];
96
			$pconfig['apn'] = $a_ppps[$id]['apn'];
97
			$pconfig['apnum'] = $a_ppps[$id]['apnum'];
98
			$pconfig['phone'] = $a_ppps[$id]['phone'];
99
			$pconfig['connect-timeout'] = $a_ppps[$id]['connect-timeout'];
100
			$pconfig['localip'] = explode(",",$a_ppps[$id]['localip']);
101
			$pconfig['gateway'] = explode(",",$a_ppps[$id]['gateway']);
102
			break;
103
		case "l2tp":
104
		case "pptp":
105
			$pconfig['localip'] = explode(",",$a_ppps[$id]['localip']);
106
			$pconfig['subnet'] = explode(",",$a_ppps[$id]['subnet']);
107
			$pconfig['gateway'] = explode(",",$a_ppps[$id]['gateway']);
108
		case "pppoe":
109
			$pconfig['provider'] = $a_ppps[$id]['provider'];
110
			if (isset($a_ppps[$id]['provider']) and empty($a_ppps[$id]['provider']))
111
				$pconfig['null_service'] = true;
112
			/* ================================================ */
113
			/* = force a connection reset at a specific time? = */
114
			/* ================================================ */
115
			
116
			if (isset($a_ppps[$id]['pppoe-reset-type'])) {
117
				$pconfig['pppoe-reset-type'] = $a_ppps[$id]['pppoe-reset-type'];
118
				$itemhash = getMPDCRONSettings($a_ppps[$id]['if']);
119
				$cronitem = $itemhash['ITEM'];
120
				if (isset($cronitem)) {
121
					$resetTime = "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
122
				} else {
123
					$resetTime = NULL;
124
				}
125
				
126
				if ($a_ppps[$id]['pppoe-reset-type'] == "custom") {
127
					$resetTime_a = explode(" ", $resetTime);
128
					$pconfig['pppoe_pr_custom'] = true;
129
					$pconfig['pppoe_resetminute'] = $resetTime_a[0];
130
					$pconfig['pppoe_resethour'] = $resetTime_a[1];
131
					/*  just initialize $pconfig['pppoe_resetdate'] if the
132
					 *  coresponding item contains appropriate numeric values.
133
					 */
134
					if ($resetTime_a[2] <> "*" && $resetTime_a[3] <> "*") 
135
						$pconfig['pppoe_resetdate'] = "{$resetTime_a[3]}/{$resetTime_a[2]}/" . date("Y");
136
				} else if ($a_ppps[$id]['pppoe-reset-type'] == "preset") {
137
					$pconfig['pppoe_pr_preset'] = true;
138
					switch ($resetTime) {
139
						case CRON_MONTHLY_PATTERN:
140
							$pconfig['pppoe_monthly'] = true;
141
							break;
142
						case CRON_WEEKLY_PATTERN:
143
							$pconfig['pppoe_weekly'] = true;
144
							break;
145
						case CRON_DAILY_PATTERN:
146
							$pconfig['pppoe_daily'] = true;
147
							break;
148
						case CRON_HOURLY_PATTERN:
149
							$pconfig['pppoe_hourly'] = true;
150
							break;
151
					}
152
				}
153
			}
154
			break;
155
	}
156
	
157
} else
158
	$pconfig['ptpid'] = interfaces_ptpid_next();
159

    
160
if ($_POST) {
161

    
162
	unset($input_errors);
163
	$pconfig = $_POST;
164
	
165
	/* okay first of all, cause we are just hiding the PPPoE HTML
166
	 * fields releated to PPPoE resets, we are going to unset $_POST
167
	 * vars, if the reset feature should not be used. Otherwise the
168
	 * data validation procedure below, may trigger a false error
169
	 * message.
170
	 */
171
	if (empty($_POST['pppoe-reset-type'])) {               
172
		unset($_POST['pppoe_resethour']);
173
		unset($_POST['pppoe_resetminute']);
174
		unset($_POST['pppoe_resetdate']);
175
		unset($_POST['pppoe_pr_preset_val']);
176
	}
177

    
178
	/* input validation */		
179
	switch($_POST['type']) {
180
		case "ppp":
181
			$reqdfields = explode(" ", "interfaces phone");
182
			$reqdfieldsn = array(gettext("Link Interface(s)"),gettext("Phone Number"));
183
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
184
			break;
185
		case "pppoe":
186
			if ($_POST['ondemand']) {
187
				$reqdfields = explode(" ", "interfaces username password ondemand idletimeout");
188
				$reqdfieldsn = array(gettext("Link Interface(s)"),gettext("Username"),gettext("Password"),gettext("Dial on demand"),gettext("Idle timeout value"));
189
			} else {
190
				$reqdfields = explode(" ", "interfaces username password");
191
				$reqdfieldsn = array(gettext("Link Interface(s)"),gettext("Username"),gettext("Password"));
192
			}
193
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
194
			break;
195
		case "l2tp":
196
		case "pptp":
197
			if ($_POST['ondemand']) {
198
				$reqdfields = explode(" ", "interfaces username password localip subnet gateway ondemand idletimeout");
199
				$reqdfieldsn = array(gettext("Link Interface(s)"),gettext("Username"),gettext("Password"),gettext("Local IP address"),gettext("Subnet"),gettext("Remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
200
			} else {
201
				$reqdfields = explode(" ", "interfaces username password localip subnet gateway");
202
				$reqdfieldsn = array(gettext("Link Interface(s)"),gettext("Username"),gettext("Password"),gettext("Local IP address"),gettext("Subnet"),gettext("Remote IP address"));
203
			}
204
			do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
205
			break;
206
		default:
207
			$input_errors[] = gettext("Please choose a Link Type.");
208
			break;
209
	}
210
	if ($_POST['type'] == "ppp" && count($_POST['interfaces']) > 1)
211
		$input_errors[] = gettext("Multilink connections (MLPPP) using the PPP link type is not currently supported. Please select only one Link Interface.");
212
	if ($_POST['provider'] && !is_domain($_POST['provider']))
213
		$input_errors[] = gettext("The Service name contains invalid characters.");
214
	if ($_POST['provider'] && $_POST['null_service'])
215
		$input_errors[] = gettext("Do not specify both a Service name and a NULL Service name.");
216
	if (($_POST['idletimeout'] != "") && !is_numericint($_POST['idletimeout'])) 
217
		$input_errors[] = gettext("The idle timeout value must be an integer.");
218
	if ($_POST['pppoe-reset-type'] == "custom" && $_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) && 
219
		$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) 
220
		$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
221
	if ($_POST['pppoe-reset-type'] == "custom" && $_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) && 
222
		$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) 
223
		$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
224
	if ($_POST['pppoe-reset-type'] == "custom" && $_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) 
225
		$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
226
	if ($_POST['pppoe-reset-type'] == "custom" && $_POST['pppoe_resetdate'] <> "" && is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))){
227
		$date_nums = explode("/",$_POST['pppoe_resetdate']);
228
		if ($date_nums[0] < 1 || $date_nums[0] > 12)
229
			$input_errors[] = gettext("A valid PPPoE reset month must be specified (1-12) in the Custom PPPoE Periodic reset fields.");
230
		if ($date_nums[1] < 1 || $date_nums[1] > 31)
231
			$input_errors[] = gettext("A valid PPPoE reset day of month must be specified (1-31) in the Custom PPPoE Periodic reset fields. No checks are done on valid # of days per month");
232
		if ($date_nums[2] < date("Y"))
233
			$input_errors[] = gettext("A valid PPPoE reset year must be specified. Don't select a year in the past!");
234
	}
235
	
236
	foreach($_POST['interfaces'] as $iface){
237
		if ($_POST['localip'][$iface] && !is_ipaddr($_POST['localip'][$iface]))
238
			$input_errors[] = sprintf(gettext("A valid local IP address must be specified for %s."),$iface);
239
		if ($_POST['gateway'][$iface] && !is_ipaddr($_POST['gateway'][$iface]) && !is_hostname($_POST['gateway'][$iface])) 
240
			$input_errors[] = sprintf(gettext("A valid gateway IP address OR hostname must be specified for %s."),$iface);
241
		if ($_POST['bandwidth'][$iface] && !is_numericint($_POST['bandwidth'][$iface])) 
242
			$input_errors[] = sprintf(gettext("The bandwidth value for %s must be an integer."),$iface);
243
		if ($_POST['mtu'][$iface] && ($_POST['mtu'][$iface] < 576)) 
244
			$input_errors[] = sprintf(gettext("The MTU for %s must be greater than 576 bytes."),$iface);
245
		if ($_POST['mru'][$iface] && ($_POST['mru'][$iface] < 576)) 
246
			$input_errors[] = sprintf(gettext("The MRU for %s must be greater than 576 bytes."),$iface);
247
	}
248

    
249
/*
250
	foreach ($a_ppps as $ppp) {
251
		if (isset($id) && ($a_ppps[$id]) && ($a_ppps[$id] === $ppp))
252
			continue;
253

    
254
		if ($ppp['serialport'] == $_POST['serialport']) {
255
			$input_errors[] = "Serial port is in use";
256
			break;
257
		}
258
	}
259
*/	
260

    
261
	if (!$input_errors) {
262
		$ppp = array();
263
		$ppp['ptpid'] = $_POST['ptpid'];
264
		$ppp['type'] = $_POST['type'];
265
		$ppp['if'] = $ppp['type'].$ppp['ptpid'];
266
		$ppp['ports'] = implode(',',$_POST['interfaces']);
267
		$ppp['username'] = $_POST['username'];
268
		$ppp['password'] = base64_encode($_POST['password']);
269
		$ppp['ondemand'] = $_POST['ondemand'] ? true : false;
270
		if (!empty($_POST['idletimeout']))
271
			$ppp['idletimeout'] = $_POST['idletimeout'];
272
		else
273
			unset($ppp['idletimeout']);
274
		$ppp['uptime'] = $_POST['uptime'] ? true : false;
275
		if (!empty($_POST['descr']))
276
			$ppp['descr'] = $_POST['descr'];
277
		else
278
			unset($ppp['descr']);
279

    
280
		// Loop through fields associated with a individual link/port and make an array of the data
281
		$port_fields = array("localip", "gateway", "subnet", "bandwidth", "mtu", "mru", "mrru");
282
		foreach($_POST['interfaces'] as $iface){
283
			foreach($port_fields as $field_label){
284
				if (isset($_POST[$field_label][$iface]))
285
					$port_data[$field_label][] = $_POST[$field_label][$iface];
286
			}
287
		}		
288
				
289
		switch($_POST['type']) {
290
			case "ppp":
291
				if (!empty($_POST['initstr']))
292
					$ppp['initstr'] = base64_encode($_POST['initstr']);
293
				else
294
					unset($ppp['initstr']);
295
				if (!empty($_POST['simpin'])) {
296
					$ppp['simpin'] = $_POST['simpin'];
297
					$ppp['pin-wait'] = $_POST['pin-wait'];
298
				} else {
299
					unset($ppp['simpin']);
300
					unset($ppp['pin-wait']);
301
				}
302
				
303
				if (!empty($_POST['apn'])){
304
					$ppp['apn'] = $_POST['apn'];
305
					$ppp['apnum'] = $_POST['apnum'];
306
				} else {
307
					unset($ppp['apn']);
308
					unset($ppp['apnum']);
309
				}
310
				$ppp['phone'] = $_POST['phone'];
311
				$ppp['localip'] = implode(',',$port_data['localip']);
312
				$ppp['gateway'] = implode(',',$port_data['gateway']);
313
				if (!empty($_POST['connect-timeout']))
314
					$ppp['connect-timeout'] = $_POST['connect-timeout'];
315
				else
316
					unset($ppp['connect-timeout']);
317
				break;
318
			case "pppoe":
319
				if (!empty($_POST['provider']))
320
					$ppp['provider'] = $_POST['provider'];
321
				else{
322
					unset($ppp['provider']);
323
					$ppp['provider'] = $_POST['null_service'] ? true : false;
324
				}
325
				if (!empty($_POST['pppoe-reset-type']))
326
					$ppp['pppoe-reset-type'] = $_POST['pppoe-reset-type'];
327
				else
328
					unset($ppp['pppoe-reset-type']);
329
				
330
				break;
331
			case "pptp":
332
			case "l2tp":
333
				$ppp['localip'] = implode(',',$port_data['localip']);
334
				$ppp['subnet'] = implode(',',$port_data['subnet']);
335
				$ppp['gateway'] = implode(',',$port_data['gateway']);
336
				break;
337
			default:
338
				break;
339
			
340
		}
341
		
342
		$ppp['shortseq'] = $_POST['shortseq'] ? true : false;
343
		$ppp['acfcomp'] = $_POST['acfcomp'] ? true : false;
344
		$ppp['protocomp'] = $_POST['protocomp'] ? true : false;
345
		$ppp['vjcomp'] = $_POST['vjcomp'] ? true : false;
346
		$ppp['tcpmssfix'] = $_POST['tcpmssfix'] ? true : false;
347
		$ppp['bandwidth'] = implode(',', $port_data['bandwidth']);
348
		if (is_array($port_data['mtu']))
349
			$ppp['mtu'] = implode(',', $port_data['mtu']);
350
		if (is_array($port_data['mru']))
351
			$ppp['mru'] = implode(',', $port_data['mru']);
352
		if (is_array($port_data['mrru']))
353
			$ppp['mrru'] = implode(',', $port_data['mrru']);
354
		
355
		/* handle_pppoe_reset is called here because if user changes Link Type from PPPoE to another type we 
356
		must be able to clear the config data in the <cron> section of config.xml if it exists
357
		*/
358
		handle_pppoe_reset($_POST);
359

    
360
		if (isset($id) && $a_ppps[$id])
361
			$a_ppps[$id] = $ppp;
362
		else
363
			$a_ppps[] = $ppp;
364

    
365
		write_config();
366
		configure_cron();
367

    
368
		foreach ($iflist as $pppif => $ifdescr) {
369
			if ($config['interfaces'][$if]['if'] == $ppp['if'])
370
				interface_ppps_configure($pppif);
371
		}
372
		header("Location: interfaces_ppps.php");
373
		exit;
374
	}
375
} // end if($_POST)
376

    
377
$closehead = false;
378
$pgtitle = array(gettext("Interfaces"),gettext("PPPs"),gettext("Edit"));
379
include("head.inc");
380

    
381
$types = array("select" => gettext("Select"), "ppp" => "PPP", "pppoe" => "PPPoE", "pptp" => "PPTP",  "l2tp" => "L2TP"/*, "tcp" => "TCP", "udp" => "UDP"*/  ); 
382

    
383
?>
384
	<script type="text/javascript" src="/javascript/numericupdown/js/numericupdown.js"></script>
385
	<link href="/javascript/numericupdown/css/numericupdown.css" rel="stylesheet" type="text/css" />
386
	<script type="text/javascript" src="/javascript/datepicker/js/datepicker.js"></script>
387
	<link href="/javascript/datepicker/css/datepicker.css" rel="stylesheet" type="text/css"/>
388
	<script type="text/javascript" >
389
		jQuery(document).ready(function() { updateType(<?php echo "'{$pconfig['type']}'";?>); });
390
	</script>
391
</head>
392
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" >
393
<?php include("fbegin.inc"); ?>
394
<?php if ($input_errors) print_input_errors($input_errors); ?>
395
	<form action="interfaces_ppps_edit.php" method="post" name="iform" id="iform">
396
	  <table id="interfacetable" width="100%" border="0" cellpadding="6" cellspacing="0">
397
		<tr>
398
			<td colspan="2" valign="top" class="listtopic"><?= gettext("PPPs configuration"); ?></td>
399
		</tr>
400
		<tr>
401
			<td valign="middle" class="vncell"><strong><?= gettext("Link Type"); ?></strong></td>
402
			<td class="vtable"> 
403
				<select name="type" onChange="updateType(this.value);" class="formselect" id="type">
404
				<?php 
405
					foreach ($types as $key => $opt) { 
406
						echo "<option onClick=\"updateType('{$key}');\"";
407
						if ($key == $pconfig['type']) 
408
							echo " selected";
409
						echo " value=\"{$key}\" >" . htmlspecialchars($opt) . "</option>";
410
					} 
411
				?>
412
				</select> 
413
			</td>
414
		</tr>
415
		<tr name="interface" id="interface" >
416
			<td width="22%" valign="top" class="vncellreq"><?= gettext("Link interface(s)"); ?></td>
417
			<td width="78%" class="vtable">
418
				<select valign="top" name="interfaces[]" multiple="true" class="formselect" size="4" onChange="show_hide_linkfields(this.options);">
419
					<option></option>
420
				</select>
421

    
422
				<br/><span class="vexpl"><?= gettext("Select at least two interfaces for Multilink (MLPPP) connections."); ?></span>
423
			</td>
424
		</tr>
425
		<tr style="display:none" name="portlists" id="portlists">
426
			<td id="serialports"><?php
427
				$selected_ports = explode(',',$pconfig['interfaces']);
428
				if (!is_dir("/var/spool/lock"))
429
					mwexec("/bin/mkdir -p /var/spool/lock");
430
				$serialports = pfSense_get_modem_devices();
431
				$serport_count = 0;
432
				foreach ($serialports as $port) {
433
					$serport_count++;
434
					echo $port.",".trim($port);
435
					if (in_array($port,$selected_ports))
436
						echo ",1|";
437
					else
438
						echo ",|";
439
				}
440
				echo $serport_count;
441
			?></td>
442
			<td id="ports"><?php
443
				$port_count = 0;
444
				foreach ($portlist as $ifn => $ifinfo){
445
				$port_count++;
446
					$string = "";
447
					if (is_array($ifinfo)) {
448
						$string .= $ifn;
449
						if ($ifinfo['mac'])
450
						$string .= " ({$ifinfo['mac']})";	
451
					} else
452
						$string .= $ifinfo;
453
					$string .= ",{$ifn}";
454
					echo htmlspecialchars($string);
455
					if (in_array($ifn,$selected_ports))
456
						echo ",1|";
457
					else
458
						echo ",|";
459
				}
460
				echo $port_count;
461
				if($serport_count > $port_count)
462
					$port_count=$serport_count;
463
			?></td>
464
			<td style="display:none" name="port_count" id="port_count"><?=htmlspecialchars($port_count);?></td>
465
		</tr>
466
		<tr>
467
			<td width="22%" valign="top" class="vncell"><?= gettext("Description"); ?></td>
468
			<td width="78%" class="vtable">
469
				<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
470
				<br/> <span class="vexpl"><?= gettext("You may enter a description here for your reference. Description will appear in the \"Interfaces Assign\" select lists."); ?></span>
471
			</td>
472
		</tr>	
473
		<tr style="display:none" name="select" id="select"></tr>
474
		
475
		<?php $k=0; ?>
476
		
477
		<tr style="display:none" name="ppp_provider" id="ppp_provider">
478
			<td width="22%" valign="top" class="vncell"><?= gettext("Service Provider"); ?></td>
479
			<td width="78%" class="vtable">
480
				<table border="0" cellpadding="0" cellspacing="0">
481
					<tr id="trcountry" style="display:none">
482
						<td><?= gettext("Country:"); ?> &nbsp;&nbsp;</td>
483
						<td>
484
							<select class="formselect" name="country" id="country" onChange="providers_list()">
485
								<option></option>
486
							</select>
487
						</td>
488
					</tr>
489
					<tr id="trprovider" style="display:none">
490
						<td><?= gettext("Provider:"); ?> &nbsp;&nbsp;</td>
491
						<td>
492
							<select class="formselect" name="provider" id="provider" onChange="providerplan_list()">
493
								<option></option>
494
							</select>
495
						</td>
496
					</tr>
497
					<tr id="trproviderplan" style="display:none">
498
						<td><?= gettext("Plan:"); ?> &nbsp;&nbsp;</td>
499
						<td>
500
							<select class="formselect" name="providerplan" id="providerplan" onChange="prefill_provider()">
501
								<option></option>
502
							</select>
503
						</td>
504
					</tr>
505
				</table>
506
				<br/><span class="vexpl"><?= gettext("Select to fill in data for your service provider."); ?></span>
507
			</td>
508
		</tr>
509
		<tr>
510
			<td width="22%" valign="top" class="vncell"><?= gettext("Username"); ?></td>
511
			<td width="78%" class="vtable">
512
			<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
513
			</td>
514
		</tr>
515
		<tr>
516
			<td width="22%" valign="top" class="vncell"><?= gettext("Password"); ?></td>
517
			<td width="78%" class="vtable">
518
			<input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
519
			</td>
520
		</tr>
521

    
522
		<tr style="display:none" name="phone_num" id="phone_num">
523
			<td width="22%" valign="top" class="vncell"><?= gettext("Phone Number"); ?></td>
524
			<td width="78%" class="vtable">
525
				<input name="phone" type="text" class="formfld unknown" id="phone" size="40" value="<?=htmlspecialchars($pconfig['phone']);?>">
526
				<br/><span class="vexpl"><?= gettext("Note: Typically *99# for GSM networks and #777 for CDMA networks"); ?></span>
527
			</td>
528
		</tr>
529
		<tr style="display:none" name="apn_" id="apn_">
530
			<td width="22%" valign="top" class="vncell"><?= gettext("Access Point Name (APN)"); ?></td>
531
			<td width="78%" class="vtable">
532
				<input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
533
			</td>
534
		</tr>
535
		
536
		<tr style="display:none" name="ppp" id="ppp">
537
			<td colspan="2" style="padding:0px;">
538
				<table width="100%" border="0" cellpadding="6" cellspacing="0">		
539
					<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
540
						<td width="22%" valign="top" class="vncell"><?= gettext("APN number (optional)"); ?></td>
541
						<td width="78%" class="vtable">
542
							<input name="apnum" type="text" class="formfld unknown" id="apnum" size="2" value="<?=htmlspecialchars($pconfig['apnum']);?>">
543
							<br/><span class="vexpl"><?= gettext("Note: Defaults to 1 if you set APN above. Ignored if you set no APN above."); ?></span>
544
						</td>
545
					</tr>
546
					<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
547
						<td width="22%" valign="top" class="vncell"><?= gettext("SIM PIN"); ?></td>
548
						<td width="78%" class="vtable">
549
							<input name="simpin" type="text" class="formfld unknown" id="simpin" size="12" value="<?=htmlspecialchars($pconfig['simpin']);?>">
550
						</td>
551
					</tr>
552
			
553
					<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
554
						<td width="22%" valign="top" class="vncell"><?= gettext("SIM PIN wait"); ?></td>
555
						<td width="78%" class="vtable">
556
							<input name="pin-wait" type="text" class="formfld unknown" id="pin-wait" size="2" value="<?=htmlspecialchars($pconfig['pin-wait']);?>">
557
							<br/><span class="vexpl"><?= gettext("Note: Time to wait for SIM to discover network after PIN is sent to SIM (seconds)."); ?></span>
558
						</td>
559
					</tr>
560
					<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
561
						<td width="22%" valign="top" class="vncell"><?= gettext("Init String"); ?></td>
562
						<td width="78%" class="vtable">
563
							<input type="text" size="40" class="formfld unknown" id="initstr" name="initstr" value="<?=htmlspecialchars($pconfig['initstr']);?>">
564
							<br/><span class="vexpl"><?= gettext("Note: Enter the modem initialization string here. Do NOT include the \"AT\"" . 
565
							" string at the beginning of the command. Many modern USB 3G modems don't need an initialization string."); ?></span>
566
						</td>
567
					</tr>
568
					<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
569
						<td width="22%" valign="top" class="vncell"><?= gettext("Connection Timeout"); ?></td>
570
						<td width="78%" class="vtable">
571
							<input name="connect-timeout" type="text" class="formfld unknown" id="connect-timeout" size="2" value="<?=htmlspecialchars($pconfig['connect-timeout']);?>">
572
							<br/><span class="vexpl"><?= gettext("Note: Enter timeout in seconds for connection to be established (sec.) Default is 45 sec."); ?></span>
573
						</td>
574
					</tr>
575
					<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
576
						<td valign="top" class="vncell"><?= gettext("Uptime Logging"); ?></td>
577
						<td class="vtable">
578
							<input type="checkbox" value="on" id="uptime" name="uptime" <?php if (isset($pconfig['uptime'])) echo "checked"; ?>> <?= gettext("Enable persistent logging of connection uptime."); ?> 
579
							<br/> <span class="vexpl"><?= gettext("This option causes cumulative uptime to be recorded and displayed on the Status Interfaces page."); ?></span>
580
						</td>
581
					</tr>
582
				</table>
583
			</td>
584
		</tr>
585
		<tr style="display:none" name="pppoe" id="pppoe">
586
			<td colspan="2" style="padding:0px;">
587
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
588
					<tr>
589
						<td width="22%" valign="top" class="vncell"><?= gettext("Service name"); ?></td>
590
						<td width="78%" class="vtable"><input name="provider" type="text" class="formfld unknown" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">&nbsp;&nbsp;
591
						<input type="checkbox" value="on" id="null_service" name="null_service" <?php if (isset($pconfig['null_service'])) echo "checked"; ?>> <?= gettext("Configure a NULL Service name"); ?> 
592
							<br/> <span class="vexpl"><?= gettext("Hint: this field can usually be left empty. Service name will not be configured if this field is empty. Check the \"Configure NULL\" box to configure a blank Service name."); ?></span>
593
						</td>
594
					</tr>
595
					<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
596
						<td width="22%" valign="top" class="vncell"><?=gettext("Periodic reset");?></td>
597
						<td width="78%" class="vtable">
598
							<table id="presetwrap" cellspacing="0" cellpadding="0" width="100%">
599
								<tr>
600
									<td align="left" valign="top">
601
										<p style="margin: 4px; padding: 4px 0 4px 0; width: 94%;">
602
										<select valign="top" id="reset_type" name="pppoe-reset-type" class="formselect" onChange="show_reset_settings(this.value);">
603
											<option value = ""><?= gettext("Disabled"); ?></option>
604
											<option value="custom" <?php if ($pconfig['pppoe-reset-type'] == "custom") echo "selected"; ?>><?= gettext("Custom"); ?></option>
605
											<option value="preset" <?php if ($pconfig['pppoe-reset-type'] == "preset") echo "selected"; ?>><?= gettext("Pre-Set"); ?></option>
606
										</select> <?= gettext("Select a reset timing type"); ?>
607
										</p>
608
										<?php if ($pconfig['pppoe_pr_custom']): ?>
609
											<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoecustomwrap">
610
										<?php else: ?>
611
											<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoecustomwrap">
612
										<?php endif; ?>
613
										<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" /> 
614
										<?= gettext("hour (0-23)"); ?><br />
615
										<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" /> 
616
										<?= gettext("minute (0-59)"); ?><br />
617
										<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']);?>" /> 
618
										<?= gettext("reset at a specific date (mm/dd/yyyy)"); ?>
619
										<br />&nbsp;<br />
620
										<span class="red"><strong><?=gettext("Note:");?></strong></span>
621
										<?= gettext("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."); ?>
622
										</p>
623
										<?php if ($pconfig['pppoe_pr_preset']): ?>
624
											<p style="margin: 2px; padding: 4px; width: 94%;" id="pppoepresetwrap">
625
										<?php else: ?>
626
											<p style="margin: 2px; padding: 4px; width: 94%; display: none;" id="pppoepresetwrap">
627
										<?php endif; ?>
628
										<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?php if ($pconfig['pppoe_monthly']) echo "checked=\"checked\""; ?> /> 
629
										<?= gettext("reset at each month ('0 0 1 * *')"); ?>
630
										<br />
631
										<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?php if ($pconfig['pppoe_weekly']) echo "checked=\"checked\""; ?> /> 
632
										<?= gettext("reset at each week ('0 0 * * 0')"); ?>
633
										<br />
634
										<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?php if ($pconfig['pppoe_daily']) echo "checked=\"checked\""; ?> /> 
635
										<?= gettext("reset at each day ('0 0 * * *')"); ?>
636
										<br />
637
										<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?php if ($pconfig['pppoe_hourly']) echo "checked=\"checked\""; ?> /> 
638
										<?= gettext("reset at each hour ('0 * * * *')"); ?>
639
										</p>
640
									</td>
641
								</tr>
642
							</table>
643
						</td>
644
					</tr>
645
				</table>
646
			</td>
647
		</tr>
648

    
649
		<?php for($j=0; $j < $port_count; $j++) : ?>
650
		
651
		<tr style="display:none" id="gw_fields<?=$j;?>">
652
			<td width="22%" id="localiplabel<?=$j;?>" valign="top" class="vncell"><?= gettext("Local IP"); ?></td>
653
			<td width="78%" class="vtable"> 
654
				<input name="localip[]" type="text" class="formfld unknown" id="localip<?=$j;?>" size="20"  value="<?=htmlspecialchars($pconfig['localip'][$j]);?>">
655
				/
656
				<select name="subnet[]" class="formselect" id="subnet<?=$j;?>" disabled="true">
657
				<?php for ($i = 31; $i > 0; $i--): ?>
658
					<option value="<?=$i;?>"<?php if ($i == $pconfig['subnet'][$j]) echo " selected"; ?>><?=$i;?></option>
659
				<?php endfor; ?>
660
				</select> <?= gettext("IP Address"); ?>
661
				
662
			</td>
663
		</tr>
664
		<tr style="display:none" id="ip_fields<?=$j;?>">
665
			<td width="22%" id="gatewaylabel<?=$j;?>" valign="top" class="vncell"></td>
666
			<td width="78%" class="vtable">
667
				<input name="gateway[]" type="text" class="formfld unknown" id="gateway<?=$j;?>" size="20" value="<?=htmlspecialchars($pconfig['gateway'][$j]);?>"><?= gettext("IP Address OR Hostname"); ?>
668
			</td>
669
		</tr><?php endfor; ?>
670

    
671
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
672
			<td colspan="2" valign="top" height="16"></td>
673
		</tr>
674
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
675
			<td colspan="2" valign="top" class="listtopic"><?= gettext("Advanced Options"); ?></td>
676
		</tr>
677
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
678
		<td valign="top" class="vncell"><?= gettext("Dial On Demand"); ?></td>
679
			<td class="vtable">
680
				<input type="checkbox" value="on" id="ondemand" name="ondemand" <?php if (isset($pconfig['ondemand'])) echo "checked"; ?>> <?= gettext("Enable Dial-on-Demand mode"); ?> 
681
				<br/> <span class="vexpl"><?= gettext("This option causes the interface to operate in dial-on-demand mode. Do NOT enable if you want your link to be always up. " .  
682
				"The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected."); ?> </span>
683
			</td>
684
		</tr>
685
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
686
			<td valign="top" class="vncell"><?= gettext("Idle Timeout"); ?></td>
687
			<td class="vtable">
688
				<input name="idletimeout" type="text" class="formfld unknown" id="idletimeout" size="12" value="<?=htmlspecialchars($pconfig['idletimeout']);?>"> <?= gettext("(seconds) Default is 0, which disables the timeout feature."); ?>
689
				<br/> <span class="vexpl"><?= gettext("If no incoming or outgoing packets are transmitted for the entered number of seconds the connection is brought down.");?>
690
				<br/><?=gettext("When the idle timeout occurs, if the dial-on-demand option is enabled, mpd goes back into dial-on-demand mode. Otherwise, the interface is brought down and all associated routes removed."); ?></span>
691
			</td>
692
		</tr>
693
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
694
			<td width="22%" valign="top" class="vncell"><?= gettext("Compression"); ?></td>
695
			<td width="78%" class="vtable">
696
				<input type="checkbox" value="on" id="vjcomp" name="vjcomp" <?php if (isset($pconfig['vjcomp'])) echo "checked"; ?>>&nbsp;<?= gettext("Disable vjcomp(compression) (auto-negotiated by default)."); ?>
697
				<br/> <span class="vexpl"><?=gettext("This option enables Van Jacobson TCP header compression, which saves several bytes per TCP data packet. " .
698
				"You almost always want this option. This compression ineffective for TCP connections with enabled modern extensions like time " .
699
				"stamping or SACK, which modify TCP options between sequential packets.");?></span>
700
			</td>
701
		</tr>
702
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
703
			<td width="22%" valign="top" class="vncell"><?= gettext("TCPmssFix"); ?></td>
704
			<td width="78%" class="vtable">
705
				<input type="checkbox" value="on" id="tcpmssfix" name="tcpmssfix" <?php if (isset($pconfig['tcpmssfix'])) echo "checked"; ?>>&nbsp;<?= gettext("Disable tcpmssfix (enabled by default)."); ?>
706
				<br/> <span class="vexpl"><?=gettext("This option causes mpd to adjust incoming and outgoing TCP SYN segments so that the requested maximum segment size is not greater than the amount ". 
707
				"allowed by the interface MTU. This is necessary in many setups to avoid problems caused by routers that drop ICMP Datagram Too Big messages. Without these messages, ".
708
				"the originating machine sends data, it passes the rogue router then hits a machine that has an MTU that is not big enough for the data. Because the IP Don't Fragment option is set, ".
709
				"this machine sends an ICMP Datagram Too Big message back to the originator and drops the packet. The rogue router drops the ICMP message and the originator never ".
710
				"gets to discover that it must reduce the fragment size or drop the IP Don't Fragment option from its outgoing data.");?></span>
711
			</td>
712
		</tr>
713
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
714
			<td width="22%" valign="top" class="vncell"><?=gettext("ShortSeq");?></td>
715
			<td width="78%" class="vtable">
716
				<input type="checkbox" value="on" id="shortseq" name="shortseq" <?php if (isset($pconfig['shortseq'])) echo "checked"; ?>>&nbsp;<?= gettext("Disable shortseq (auto-negotiated by default)."); ?>
717
				<br/> <span class="vexpl"><?= gettext("This option is only meaningful if multi-link PPP is negotiated. It proscribes shorter multi-link fragment headers, saving two bytes on every frame. " .
718
				"It is not necessary to disable this for connections that are not multi-link."); ?></span>
719
			</td>
720
		</tr>
721
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
722
			<td width="22%" valign="top" class="vncell"><?=gettext("ACFComp"); ?></td>
723
			<td width="78%" class="vtable">
724
				<input type="checkbox" value="on" id="acfcomp" name="acfcomp" <?php if (isset($pconfig['acfcomp'])) echo "checked"; ?>>&nbsp;<?= gettext("Disable acfcomp (compression) (auto-negotiated by default)."); ?>
725
				<br/> <span class="vexpl"><?= gettext("Address and control field compression. This option only applies to asynchronous link types. It saves two bytes per frame."); ?></span>
726
			</td>
727
		</tr>
728
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
729
			<td width="22%" valign="top" class="vncell"><?=gettext("ProtoComp"); ?></td>
730
			<td width="78%" class="vtable">
731
				<input type="checkbox" value="on" id="protocomp" name="protocomp" <?php if (isset($pconfig['protocomp'])) echo "checked"; ?>>&nbsp;<?= gettext("Disable protocomp (compression) (auto-negotiated by default)."); ?>
732
				<br/> <span class="vexpl"><?= gettext("Protocol field compression. This option saves one byte per frame for most frames."); ?></span>
733
			</td>
734
		</tr>
735
		<tr id="advanced_" name="advanced_">
736
			<td>&nbsp;</td>
737
			<td>
738
			<p><input type="button" onClick="show_advanced(1)" value="<?=gettext("Show advanced options"); ?>"></p>
739
			</td>
740
			<td style="display:none" id="adv_rows" name="adv_rows"><?=$k;?></td>
741
			<td style="display:none" id="adv_show" name="adv_show">0</td>
742
		</tr>
743
		<tr>
744
		<?php for($i=0; $i < $port_count; $i++) : ?>
745
		<tr style="display:none" id="link<?=$i;?>">
746
			<td width="22%" valign="top" id="linklabel<?=$i;?>" class="vncell"> <?=gettext("Link Parameters");?></td>
747
			<td class="vtable">
748
				<table name="link_parameters" border="0" cellpadding="6" cellspacing="0">
749
					<tr>
750
						<td width="22%" id="bwlabel<?=$i;?>" valign="top"class="vncell"> <?=gettext("Bandwidth");?></td>
751
						<td width="78%" class="vtable">
752
						<br/><input name="bandwidth[]" id="bandwidth<?=$i;?>" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['bandwidth'][$i]);?>">
753
						<br/> <span class="vexpl"><?=gettext("Set ONLY for MLPPP connections and ONLY when links have different bandwidths.");?></span>
754
					  </td>
755
					</tr>
756
					<tr>
757
					  <td width="22%" id="mtulabel<?=$i;?>" valign="top" class="vncell"> <?=gettext("MTU"); ?></td>
758
					  <td width="78%" class="vtable">
759
						<input name="mtu[]" id="mtu<?=$i;?>" type="text" class="formfld unknown" size="6" value="<?=htmlspecialchars($pconfig['mtu'][$i]);?>">
760
						<br> <span class="vexpl"><?=gettext("MTU will default to 1492.");?></span>
761
					  </td>
762
					</tr>
763
					<tr>
764
					  <td width="22%" id="mrulabel<?=$i;?>" valign="top" class="vncell"> <?=gettext("MRU"); ?></td>
765
					  <td width="78%" class="vtable">
766
						<input name="mru[]" id="mru<?=$i;?>" type="text" class="formfld unknown" size="6" value="<?=htmlspecialchars($pconfig['mru'][$i]);?>">
767
						<br> <span class="vexpl">MRU <?=gettext("will be auto-negotiated by default.");?></span>
768
					  </td>
769
					</tr>
770
					<tr>
771
					  <td width="22%" id="mrrulabel<?=$i;?>" valign="top" class="vncell"> <?=gettext("MRRU"); ?></td>
772
					  <td width="78%" class="vtable">
773
						<input name="mrru[]" id="mrru<?=$i;?>" type="text" class="formfld unknown" size="6" value="<?=htmlspecialchars($pconfig['mrru'][$i]);?>">
774
						<br> <span class="vexpl"><?=gettext("Set ONLY for MLPPP connections.");?> MRRU <?=gettext("will be auto-negotiated by default.");?></span>
775
					  </td>
776
					</tr>
777
				</table>
778
			</td>
779
		</tr><?php endfor; ?>
780
		<tr>
781
			<td width="22%" valign="top">&nbsp;</td>
782
			<td width="78%">
783
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
784
				<input type="button" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
785
				<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
786
				<?php if (isset($id) && $a_ppps[$id]): ?>
787
					<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>">
788
				<?php endif; ?>
789
			</td>
790
		</tr>
791
	</table>
792
</form>
793
<?php include("fend.inc"); ?>
794
</body>
795
</html>
(104-104/245)