Project

General

Profile

Download (37.3 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
$portlist = get_interface_list();
58
$portlist = array_merge($portlist, get_configured_interface_with_descr());
59

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

    
157
if ($_POST) {
158

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

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

    
244
/*
245
	foreach ($a_ppps as $ppp) {
246
		if (isset($id) && ($a_ppps[$id]) && ($a_ppps[$id] === $ppp))
247
			continue;
248

    
249
		if ($ppp['serialport'] == $_POST['serialport']) {
250
			$input_errors[] = "Serial port is in use";
251
			break;
252
		}
253
	}
254
*/	
255

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

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

    
372
$closehead = false;
373
$pgtitle = array(gettext("Interfaces"),gettext("PPPs"),gettext("Edit"));
374
include("head.inc");
375

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

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

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

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

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

    
665
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
666
			<td colspan="2" valign="top" height="16"></td>
667
		</tr>
668
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
669
			<td colspan="2" valign="top" class="listtopic"><?= gettext("Advanced Options"); ?></td>
670
		</tr>
671
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
672
		<td valign="top" class="vncell"><?= gettext("Dial On Demand"); ?></td>
673
			<td class="vtable">
674
				<input type="checkbox" value="on" id="ondemand" name="ondemand" <?php if (isset($pconfig['ondemand'])) echo "checked"; ?>> <?= gettext("Enable Dial-on-Demand mode"); ?> 
675
				<br/> <span class="vexpl"><?= gettext("This option causes the interface to operate in dial-on-demand mode, allowing you to have a virtual full time connection. " .  
676
				"The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected."); ?> </span>
677
			</td>
678
		</tr>
679
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
680
			<td valign="top" class="vncell"><?= gettext("Idle Timeout"); ?></td>
681
			<td class="vtable">
682
				<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."); ?>
683
				<br/> <span class="vexpl"><?= gettext("If no incoming or outgoing packets are transmitted for the entered number of seconds the connection is brought down.");?>
684
				<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>
685
			</td>
686
		</tr>
687
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
688
			<td width="22%" valign="top" class="vncell"><?= gettext("Compression"); ?></td>
689
			<td width="78%" class="vtable">
690
				<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)."); ?>
691
				<br/> <span class="vexpl"><?=gettext("This option enables Van Jacobson TCP header compression, which saves several bytes per TCP data packet. " .
692
				"You almost always want this option. This compression ineffective for TCP connections with enabled modern extensions like time " .
693
				"stamping or SACK, which modify TCP options between sequential packets.");?></span>
694
			</td>
695
		</tr>
696
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
697
			<td width="22%" valign="top" class="vncell"><?= gettext("TCPmssFix"); ?></td>
698
			<td width="78%" class="vtable">
699
				<input type="checkbox" value="on" id="tcpmssfix" name="tcpmssfix" <?php if (isset($pconfig['tcpmssfix'])) echo "checked"; ?>>&nbsp;<?= gettext("Disable tcpmssfix (enabled by default)."); ?>
700
				<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 ". 
701
				"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, ".
702
				"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, ".
703
				"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 ".
704
				"gets to discover that it must reduce the fragment size or drop the IP Don't Fragment option from its outgoing data.");?></span>
705
			</td>
706
		</tr>
707
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
708
			<td width="22%" valign="top" class="vncell"><?=gettext("ShortSeq");?></td>
709
			<td width="78%" class="vtable">
710
				<input type="checkbox" value="on" id="shortseq" name="shortseq" <?php if (isset($pconfig['shortseq'])) echo "checked"; ?>>&nbsp;<?= gettext("Disable shortseq (auto-negotiated by default)."); ?>
711
				<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. " .
712
				"It is not necessary to disable this for connections that are not multi-link."); ?></span>
713
			</td>
714
		</tr>
715
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
716
			<td width="22%" valign="top" class="vncell"><?=gettext("ACFComp"); ?></td>
717
			<td width="78%" class="vtable">
718
				<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)."); ?>
719
				<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>
720
			</td>
721
		</tr>
722
		<tr style="display:none" id="advanced_<?=$k;?>" name="advanced_<?=$k;$k++;?>">
723
			<td width="22%" valign="top" class="vncell"><?=gettext("ProtoComp"); ?></td>
724
			<td width="78%" class="vtable">
725
				<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)."); ?>
726
				<br/> <span class="vexpl"><?= gettext("Protocol field compression. This option saves one byte per frame for most frames."); ?></span>
727
			</td>
728
		</tr>
729
		<tr id="advanced_" name="advanced_">
730
			<td>&nbsp;</td>
731
			<td>
732
			<p><input type="button" onClick="show_advanced(1)" value="<?=gettext("Show advanced options"); ?>"></p>
733
			</td>
734
			<td style="display:none" id="adv_rows" name="adv_rows"><?=$k;?></td>
735
			<td style="display:none" id="adv_show" name="adv_show">0</td>
736
		</tr>
737
		<tr>
738
		<?php for($i=0; $i < $port_count; $i++) : ?>
739
		<tr style="display:none" id="link<?=$i;?>">
740
			<td width="22%" valign="top" id="linklabel<?=$i;?>" class="vncell"> <?=gettext("Link Parameters");?></td>
741
			<td class="vtable">
742
				<table name="link_parameters" border="0" cellpadding="6" cellspacing="0">
743
					<tr>
744
						<td width="22%" id="bwlabel<?=$i;?>" valign="top"class="vncell"> <?=gettext("Bandwidth");?></td>
745
						<td width="78%" class="vtable">
746
						<br/><input name="bandwidth[]" id="bandwidth<?=$i;?>" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['bandwidth'][$i]);?>">
747
						<br/> <span class="vexpl"><?=gettext("Set Bandwidth for each link ONLY for MLPPP connections and ONLY when links have different bandwidths.");?></span>
748
					  </td>
749
					</tr>
750
					<tr>
751
					  <td width="22%" id="mtulabel<?=$i;?>" valign="top" class="vncell"> <?=gettext("MTU"); ?></td>
752
					  <td width="78%" class="vtable">
753
						<input name="mtu[]" id="mtu<?=$i;?>" type="text" class="formfld unknown" size="6" value="<?=htmlspecialchars($pconfig['mtu'][$i]);?>">
754
						<br> <span class="vexpl"><?=gettext("MTU will default to 1492.");?></span>
755
					  </td>
756
					</tr>
757
					<tr>
758
					  <td width="22%" id="mrulabel<?=$i;?>" valign="top" class="vncell"> <?=gettext("MRU"); ?></td>
759
					  <td width="78%" class="vtable">
760
						<input name="mru[]" id="mru<?=$i;?>" type="text" class="formfld unknown" size="6" value="<?=htmlspecialchars($pconfig['mru'][$i]);?>">
761
						<br> <span class="vexpl"><?=gettext("MRU will default to 1492.");?></span>
762
					  </td>
763
					</tr>
764
				</table
765
			</td>
766
		</tr><?php endfor; ?>
767
		<tr>
768
			<td width="22%" valign="top">&nbsp;</td>
769
			<td width="78%">
770
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
771
				<input type="button" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
772
				<input name="ptpid" type="hidden" value="<?=htmlspecialchars($pconfig['ptpid']);?>">
773
				<?php if (isset($id) && $a_ppps[$id]): ?>
774
					<input name="id" type="hidden" value="<?=$id;?>">
775
				<?php endif; ?>
776
			</td>
777
		</tr>
778
	</table>
779
</form>
780
<?php include("fend.inc"); ?>
781
</body>
782
</html>
(95-95/222)