Project

General

Profile

Download (10 KB) Statistics
| Branch: | Tag: | Revision:
1 860c4e80 Chris Buechler
<?php
2
/*
3
	interfaces_lan.php
4
	part of pfSense(http://pfsense.org)
5
6
	Originally written by Adam Lebsack <adam at holonyx dot com>
7
	Changes by Chris Buechler <cmb at pfsense dot org> 
8 4aca19b3 Scott Ullrich
	Additions by Scott Ullrich <sullrich@pfsense.org>
9 860c4e80 Chris Buechler
	
10 4aca19b3 Scott Ullrich
	Copyright (C) 2004-2009 BSD Perimeter LLC.
11
	Copyright (C) 2009 Scott Ullrich
12 860c4e80 Chris Buechler
	All rights reserved.
13
14
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16
17
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19
20
	2. Redistributions in binary form must reproduce the above copyright
21
	   notice, this list of conditions and the following disclaimer in the
22
	   documentation and/or other materials provided with the distribution.
23
24
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
	POSSIBILITY OF SUCH DAMAGE.
34
*/
35 7ac5a4cb Scott Ullrich
/*
36
	pfSense_MODULE:	interfaces
37
*/
38 860c4e80 Chris Buechler
39 6b07c15a Matthew Grooms
##|+PRIV
40
##|*IDENT=page-interfaces-ppp-edit
41
##|*NAME=Interfaces: PPP: Edit page
42
##|*DESCR=Allow access to the 'Interfaces: PPP: Edit' page.
43
##|*MATCH=interfaces_ppp_edit.php*
44
##|-PRIV
45
46 860c4e80 Chris Buechler
require("guiconfig.inc");
47
48
if (!is_array($config['ppps']['ppp']))
49
	$config['ppps']['ppp'] = array();
50
51
$a_ppps = &$config['ppps']['ppp'];
52
53
$id = $_GET['id'];
54
if (isset($_POST['id']))
55
	$id = $_POST['id'];
56
57
if (isset($id) && $a_ppps[$id]) {
58 5d41713c Ermal Luçi
	$pconfig['port'] = $a_ppps[$id]['port'];
59 f4758c47 Ermal Luçi
	$pconfig['ap'] = $a_ppps[$id]['ap'];
60 860c4e80 Chris Buechler
	$pconfig['initstr'] = $a_ppps[$id]['initstr'];
61 f4758c47 Ermal Luçi
	$pconfig['username'] = $a_ppps[$id]['username'];
62
	$pconfig['password'] = $a_ppps[$id]['password'];
63
	$pconfig['gateway'] = $a_ppps[$id]['gateway'];
64
	$pconfig['localip'] = $a_ppps[$id]['localip'];
65 daf8594a Ermal Lu?i
	if (isset($a_ppps[$id]['defaultgw']))
66
		$pconfig['defaultgw'] = true;
67 860c4e80 Chris Buechler
	$pconfig['phone'] = $a_ppps[$id]['phone'];
68 46022016 Scott Ullrich
	$pconfig['dialcmd'] = base64_decode($a_ppps[$id]['dialcmd']);
69 f4758c47 Ermal Luçi
	$pconfig['connect-max-attempts'] = $a_ppps[$id]['connect-max-attempts'];
70 860c4e80 Chris Buechler
	$pconfig['linespeed'] = $a_ppps[$id]['linespeed'];
71
	$pconfig['descr'] = $a_ppps[$id]['descr'];
72
}
73
74
if ($_POST) {
75
76
	unset($input_errors);
77
	$pconfig = $_POST;
78
79
	/* input validation */
80
	$reqdfields = explode(" ", "port");
81
	$reqdfieldsn = explode(",", "Serial Port");
82
83
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
84
85
	foreach ($a_ppps as $ppp) {
86
		if (isset($id) && ($a_ppps[$id]) && ($a_ppps[$id] === $ppp))
87
			continue;
88
89
		if ($ppp['port'] == $_POST['port']) {
90
			$input_errors[] = "Port is in use";
91
			break;
92
		}
93
	}
94
95
	if (!$input_errors) {
96
		$ppp = array();
97
		$ppp['port'] = $_POST['port'];
98
		$ppp['initstr'] = $_POST['initstr'];
99 f4758c47 Ermal Luçi
		$ppp['ap'] = $_POST['ap'];
100 860c4e80 Chris Buechler
		$ppp['phone'] = $_POST['phone'];
101 46022016 Scott Ullrich
		$ppp['dialcmd'] = base64_encode($_POST['dialcmd']);
102 f4758c47 Ermal Luçi
		$ppp['username'] = $_POST['username'];
103
		$ppp['password'] = $_POST['password'];
104
		$ppp['localip'] = $_POST['localip'];
105
		$ppp['gateway'] = $_POST['gateway'];
106 daf8594a Ermal Lu?i
		if ($_POST['defaultgw'] == "on")
107
			$ppp['defaultgw'] = true;
108
		else
109
			unset($ppp['defaultgw']);
110 860c4e80 Chris Buechler
		$ppp['linespeed'] = $_POST['linespeed'];
111 f4758c47 Ermal Luçi
		$ppp['connect-max-attempts'] = $_POST['connect-max-attempts'];
112 860c4e80 Chris Buechler
		$ppp['descr'] = $_POST['descr'];
113 4aca19b3 Scott Ullrich
114
		interfaces_ppp_configure();
115
116
		if (isset($id) && $a_ppps[$id])
117
			$a_ppps[$id] = $ppp;
118
		else
119
			$a_ppps[] = $ppp;
120
121
		write_config();
122
123
		header("Location: interfaces_ppp.php");
124
		exit;
125 860c4e80 Chris Buechler
	}
126
}
127
128 06a22f6d Chris Buechler
$pgtitle = "Interfaces: PPP: Edit";
129 860c4e80 Chris Buechler
include("head.inc");
130
131
?>
132
133
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
134
<?php include("fbegin.inc"); ?>
135
<?php if ($input_errors) print_input_errors($input_errors); ?>
136 4aca19b3 Scott Ullrich
<form action="interfaces_ppp_edit.php" method="post" name="iform" id="iform">
137 46c3f09a Scott Ullrich
	<script src="/javascript/scriptaculous/prototype.js" type="text/javascript">
138
	</script>
139
	<script type="text/javascript">
140
	function prefill_att() {
141 12105004 Scott Ullrich
		$('dialcmd').value = '"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\"\\" AT OK-AT-OK ATQ0V1E1S0=0&C1&D2+FCLASS=0 OK \AT+CGDCONT=1,\\\\\\"IP\\\\\\",\\\\\\"ISP.CINGULAR\\\\\\" OK \\\\dATDT\\\\T \TIMEOUT 40 CONNECT"';
142 46c3f09a Scott Ullrich
		$('phone').value = "*99#";
143
		$('username').value = "att";
144
		$('password').value = "att";
145 9694e102 Scott Ullrich
		$('linespeed').value = "921600";
146 46c3f09a Scott Ullrich
	}
147
	function prefill_sprint() {
148 8f3f7729 Ermal Lu?i
		$('dialcmd').value = '"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\"\\" AT OK-AT-OK ATE1Q0 OK \\\\dATDT\\\\T TIMEOUT 40 CONNECT"';
149 46c3f09a Scott Ullrich
		$('phone').value = "#777";
150
		$('username').value = "sprint";
151 9694e102 Scott Ullrich
		$('password').value = "sprint";
152
		$('linespeed').value = "921600";
153 46c3f09a Scott Ullrich
	}
154 7c8dcff2 Chris Buechler
	function prefill_vzw() {
155 8f3f7729 Ermal Lu?i
		$('dialcmd').value = '"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\"\\" AT OK-AT-OK ATE1Q0s7=60 OK \\\\dATDT\\\\T TIMEOUT 40 CONNECT"';
156 7c8dcff2 Chris Buechler
		$('phone').value = "#777";
157
		$('username').value = "123@vzw3g.com";
158
		$('password').value = "vzw";
159
		$('linespeed').value = "921600";
160
	}
161 46c3f09a Scott Ullrich
	</script>
162 4aca19b3 Scott Ullrich
	<table width="100%" border="0" cellpadding="6" cellspacing="0">
163
		<tr>
164
			<td colspan="2" valign="top" class="listtopic">PPP configuration</td>
165
		</tr>
166
		<tr>
167
			<td width="22%" valign="top" class="vncellreq">Parent interface</td>
168
			<td width="78%" class="vtable">
169
				<select name="port" id="port" class="formselect">
170
				<?php
171
					$portlist = glob("/dev/cua*");
172 1de43d91 Ermal Lu?i
					$modems = glob("/dev/modem*");
173
					$portlist = array_merge($portlist, $modems);
174 4aca19b3 Scott Ullrich
					foreach ($portlist as $port) {
175
						if(preg_match("/\.(lock|init)$/", $port))
176
							continue;
177
						echo "<option value=\"".trim($port)."\"";
178
						if ($pconfig['port'] == $port)
179
							echo "selected";
180
						echo ">{$port}</option>";
181
					}
182
				?>
183
				</select>
184 46c3f09a Scott Ullrich
				<p/>
185
				Pre-fill connection information: 
186
				<a href='#' onClick='javascript:prefill_att();'>ATT</A>
187
				<a href='#' onClick='javascript:prefill_sprint();'>Sprint</A>
188 7c8dcff2 Chris Buechler
				<a href='#' onClick='javascript:prefill_vzw();'>Verizon</A>
189 4aca19b3 Scott Ullrich
			</td>
190
		</tr>
191 daf8594a Ermal Lu?i
		<tr>
192
			<td width="22%" valign="top" class="vncell">Link Type</td>
193
			<td width="78%" class="vtable">
194
				<input type="checkbox" value="on" id="defaultgw" name="defaultgw" <?php if (isset($pconfig['defaultgw'])) "echo checked"; ?>>This link will be used as default gateway.
195
			</td>
196
		</tr>
197 4aca19b3 Scott Ullrich
		<tr>
198
			<td width="22%" valign="top" class="vncell">Init String</td>
199
			<td width="78%" class="vtable">
200 46c3f09a Scott Ullrich
				<textarea id="initstr" name="initstr"><?=htmlspecialchars($pconfig['initstr']);?></textarea>
201 4aca19b3 Scott Ullrich
				<br><span class="vexpl">Enter the modem initialization string here</span>
202
			</td>
203
		</tr>
204 f4758c47 Ermal Luçi
 		<tr>
205
 		  <td width="22%" valign="top" class="vncell">AP Hostname</td>
206
 		  <td width="78%" class="vtable">
207
 		    <input name="ap" type="text" class="formfld unknown" id="ap" size="40" value="<?=htmlspecialchars($pconfig['ap']);?>">
208
 		</td>
209
 		</tr>
210 4aca19b3 Scott Ullrich
 		<tr>
211
 		  <td width="22%" valign="top" class="vncell">Dial command</td>
212
 		  <td width="78%" class="vtable">
213
			<textarea rows="4" cols="65" name="dialcmd" id="dialcmd"><?=htmlspecialchars($pconfig['dialcmd']);?></textarea>
214
 		  </td>
215
 		</tr>
216 f4758c47 Ermal Luçi
 		<tr>
217
 		  <td width="22%" valign="top" class="vncell">Phone Number</td>
218
 		  <td width="78%" class="vtable">
219
 		    <input name="phone" type="text" class="formfld unknown" id="phone" size="40" value="<?=htmlspecialchars($pconfig['phone']);?>">
220
 		  </td>
221
 		</tr>
222 4aca19b3 Scott Ullrich
		<tr>
223
			<td width="22%" valign="top" class="vncell">Username</td>
224
			<td width="78%" class="vtable">
225
				<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
226
			</td>
227
		</tr>
228
		<tr>
229
			<td width="22%" valign="top" class="vncell">Password</td>
230
			<td width="78%" class="vtable">
231
				<input name="password" type="password" class="formfld pwd" id="password" value="<?=htmlspecialchars($pconfig['password']);?>">
232
			</td>
233 f4758c47 Ermal Luçi
		</tr>
234
 		<tr>
235
 		  <td width="22%" valign="top" class="vncell">Local IP</td>
236
 		  <td width="78%" class="vtable">
237 ca010769 Chris Buechler
			<input name="localip" type="text" class="formfld unknown" id="localip" size="40" value="<?=htmlspecialchars($pconfig['localip']);?>">
238
			<span><p>Note: Enter your IP address here if it is not automatically assigned.</span>
239 f4758c47 Ermal Luçi
 		  </td>
240 4aca19b3 Scott Ullrich
		</tr>
241 860c4e80 Chris Buechler
		<tr>
242 4aca19b3 Scott Ullrich
			<td width="22%" valign="top" class="vncell">Remote IP</td>
243
			<td width="78%" class="vtable">
244
				<input name="gateway" type="text" class="formfld unknown" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>">
245
				<span><p>Note: Enter the remote IP here if not automatically assigned. This is where the packets will be routed, equivalent to the gateway.</span>
246
			</td>
247
		</tr>
248 860c4e80 Chris Buechler
		<tr>
249 4aca19b3 Scott Ullrich
			<td width="22%" valign="top" class="vncell">Line Speed</td>
250
			<td width="78%" class="vtable">
251
				<input name="linespeed" type="text" class="formfld unknown" id="linespeed" size="40" value="<?=htmlspecialchars($pconfig['linespeed']);?>">
252
			</td>
253
		</tr>
254
		<tr>
255
			<td width="22%" valign="top" class="vncell">Maximum connection retry</td>
256
			<td width="78%" class="vtable">
257
				<input name="connect-max-attempts" type="text" class="formfld unknown" id="connect-max-attempts" size="2" value="<?=htmlspecialchars($pconfig['connect-max-attempts']);?>">
258
			</td>
259
		</tr>
260
		<tr>
261
			<td width="22%" valign="top" class="vncell">Description</td>
262
			<td width="78%" class="vtable">
263
				<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
264
				<br> <span class="vexpl">You may enter a description here for your reference (not parsed).</span>
265
			</td>
266
		</tr>
267
		<tr>
268
			<td width="22%" valign="top">&nbsp;</td>
269
			<td width="78%">
270
				<input name="Submit" type="submit" class="formbtn" value="Save"> 
271
				<input type="button" value="Cancel" onclick="history.back()">
272
				<?php if (isset($id) && $a_ppps[$id]): ?>
273
					<input name="id" type="hidden" value="<?=$id;?>">
274
				<?php endif; ?>
275
			</td>
276
		</tr>
277
	</table>
278 860c4e80 Chris Buechler
</form>
279
<?php include("fend.inc"); ?>
280
</body>
281
</html>