1
|
<?php
|
2
|
/*
|
3
|
interfaces_ppp_edit.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
|
Additions by Scott Ullrich <sullrich@pfsense.org>
|
9
|
|
10
|
Copyright (C) 2004-2009 BSD Perimeter LLC.
|
11
|
Copyright (C) 2009 Scott Ullrich
|
12
|
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
|
/*
|
36
|
pfSense_MODULE: interfaces
|
37
|
*/
|
38
|
|
39
|
##|+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
|
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
|
$pconfig['port'] = $a_ppps[$id]['port'];
|
59
|
$pconfig['ap'] = $a_ppps[$id]['ap'];
|
60
|
$pconfig['initstr'] = $a_ppps[$id]['initstr'];
|
61
|
$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
|
if (isset($a_ppps[$id]['defaultgw']))
|
66
|
$pconfig['defaultgw'] = true;
|
67
|
$pconfig['phone'] = $a_ppps[$id]['phone'];
|
68
|
$pconfig['dialcmd'] = base64_decode($a_ppps[$id]['dialcmd']);
|
69
|
$pconfig['connect-max-attempts'] = $a_ppps[$id]['connect-max-attempts'];
|
70
|
$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
|
$ppp['ap'] = $_POST['ap'];
|
100
|
$ppp['phone'] = $_POST['phone'];
|
101
|
$ppp['dialcmd'] = base64_encode($_POST['dialcmd']);
|
102
|
$ppp['username'] = $_POST['username'];
|
103
|
$ppp['password'] = $_POST['password'];
|
104
|
$ppp['localip'] = $_POST['localip'];
|
105
|
$ppp['gateway'] = $_POST['gateway'];
|
106
|
if ($_POST['defaultgw'] == "on")
|
107
|
$ppp['defaultgw'] = true;
|
108
|
else
|
109
|
unset($ppp['defaultgw']);
|
110
|
$ppp['linespeed'] = $_POST['linespeed'];
|
111
|
$ppp['connect-max-attempts'] = $_POST['connect-max-attempts'];
|
112
|
$ppp['descr'] = $_POST['descr'];
|
113
|
|
114
|
|
115
|
if (isset($id) && $a_ppps[$id])
|
116
|
$a_ppps[$id] = $ppp;
|
117
|
else
|
118
|
$a_ppps[] = $ppp;
|
119
|
|
120
|
write_config();
|
121
|
|
122
|
interfaces_ppp_configure();
|
123
|
|
124
|
header("Location: interfaces_ppp.php");
|
125
|
exit;
|
126
|
}
|
127
|
}
|
128
|
|
129
|
$pgtitle = "Interfaces: PPP: Edit";
|
130
|
include("head.inc");
|
131
|
|
132
|
?>
|
133
|
|
134
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
135
|
<?php include("fbegin.inc"); ?>
|
136
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
137
|
<form action="interfaces_ppp_edit.php" method="post" name="iform" id="iform">
|
138
|
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript">
|
139
|
</script>
|
140
|
<script type="text/javascript">
|
141
|
function prefill_att() {
|
142
|
$('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"';
|
143
|
$('phone').value = "*99#";
|
144
|
$('username').value = "att";
|
145
|
$('password').value = "att";
|
146
|
$('linespeed').value = "921600";
|
147
|
}
|
148
|
function prefill_sprint() {
|
149
|
$('dialcmd').value = '"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\"\\" AT OK-AT-OK ATE1Q0 OK \\\\dATDT\\\\T TIMEOUT 40 CONNECT"';
|
150
|
$('phone').value = "#777";
|
151
|
$('username').value = "sprint";
|
152
|
$('password').value = "sprint";
|
153
|
$('linespeed').value = "921600";
|
154
|
}
|
155
|
function prefill_vzw() {
|
156
|
$('dialcmd').value = '"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\"\\" AT OK-AT-OK ATE1Q0s7=60 OK \\\\dATDT\\\\T TIMEOUT 40 CONNECT"';
|
157
|
$('phone').value = "#777";
|
158
|
$('username').value = "123@vzw3g.com";
|
159
|
$('password').value = "vzw";
|
160
|
$('linespeed').value = "921600";
|
161
|
}
|
162
|
</script>
|
163
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
164
|
<tr>
|
165
|
<td colspan="2" valign="top" class="listtopic">PPP configuration</td>
|
166
|
</tr>
|
167
|
<tr>
|
168
|
<td width="22%" valign="top" class="vncellreq">Parent interface</td>
|
169
|
<td width="78%" class="vtable">
|
170
|
<select name="port" id="port" class="formselect">
|
171
|
<?php
|
172
|
$portlist = glob("/dev/cua*");
|
173
|
$modems = glob("/dev/modem*");
|
174
|
$portlist = array_merge($portlist, $modems);
|
175
|
foreach ($portlist as $port) {
|
176
|
if(preg_match("/\.(lock|init)$/", $port))
|
177
|
continue;
|
178
|
echo "<option value=\"".trim($port)."\"";
|
179
|
if ($pconfig['port'] == $port)
|
180
|
echo "selected";
|
181
|
echo ">{$port}</option>";
|
182
|
}
|
183
|
?>
|
184
|
</select>
|
185
|
<p/>
|
186
|
Pre-fill connection information:
|
187
|
<a href='#' onClick='javascript:prefill_att();'>ATT</A>
|
188
|
<a href='#' onClick='javascript:prefill_sprint();'>Sprint</A>
|
189
|
<a href='#' onClick='javascript:prefill_vzw();'>Verizon</A>
|
190
|
</td>
|
191
|
</tr>
|
192
|
<tr>
|
193
|
<td width="22%" valign="top" class="vncell">Link Type</td>
|
194
|
<td width="78%" class="vtable">
|
195
|
<input type="checkbox" value="on" id="defaultgw" name="defaultgw" <?php if (isset($pconfig['defaultgw'])) echo "checked"; ?>>This link will be used as default gateway.
|
196
|
</td>
|
197
|
</tr>
|
198
|
<tr>
|
199
|
<td width="22%" valign="top" class="vncell">Init String</td>
|
200
|
<td width="78%" class="vtable">
|
201
|
<textarea id="initstr" name="initstr"><?=htmlspecialchars($pconfig['initstr']);?></textarea>
|
202
|
<br><span class="vexpl">Enter the modem initialization string here</span>
|
203
|
</td>
|
204
|
</tr>
|
205
|
<tr>
|
206
|
<td width="22%" valign="top" class="vncell">AP Hostname</td>
|
207
|
<td width="78%" class="vtable">
|
208
|
<input name="ap" type="text" class="formfld unknown" id="ap" size="40" value="<?=htmlspecialchars($pconfig['ap']);?>">
|
209
|
</td>
|
210
|
</tr>
|
211
|
<tr>
|
212
|
<td width="22%" valign="top" class="vncell">Dial command</td>
|
213
|
<td width="78%" class="vtable">
|
214
|
<textarea rows="4" cols="65" name="dialcmd" id="dialcmd"><?=htmlspecialchars($pconfig['dialcmd']);?></textarea>
|
215
|
</td>
|
216
|
</tr>
|
217
|
<tr>
|
218
|
<td width="22%" valign="top" class="vncell">Phone Number</td>
|
219
|
<td width="78%" class="vtable">
|
220
|
<input name="phone" type="text" class="formfld unknown" id="phone" size="40" value="<?=htmlspecialchars($pconfig['phone']);?>">
|
221
|
</td>
|
222
|
</tr>
|
223
|
<tr>
|
224
|
<td width="22%" valign="top" class="vncell">Username</td>
|
225
|
<td width="78%" class="vtable">
|
226
|
<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
|
227
|
</td>
|
228
|
</tr>
|
229
|
<tr>
|
230
|
<td width="22%" valign="top" class="vncell">Password</td>
|
231
|
<td width="78%" class="vtable">
|
232
|
<input name="password" type="password" class="formfld pwd" id="password" value="<?=htmlspecialchars($pconfig['password']);?>">
|
233
|
</td>
|
234
|
</tr>
|
235
|
<tr>
|
236
|
<td width="22%" valign="top" class="vncell">Local IP</td>
|
237
|
<td width="78%" class="vtable">
|
238
|
<input name="localip" type="text" class="formfld unknown" id="localip" size="40" value="<?=htmlspecialchars($pconfig['localip']);?>">
|
239
|
<span><p>Note: Enter your IP address here if it is not automatically assigned.</span>
|
240
|
</td>
|
241
|
</tr>
|
242
|
<tr>
|
243
|
<td width="22%" valign="top" class="vncell">Remote IP</td>
|
244
|
<td width="78%" class="vtable">
|
245
|
<input name="gateway" type="text" class="formfld unknown" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>">
|
246
|
<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>
|
247
|
</td>
|
248
|
</tr>
|
249
|
<tr>
|
250
|
<td width="22%" valign="top" class="vncell">Line Speed</td>
|
251
|
<td width="78%" class="vtable">
|
252
|
<input name="linespeed" type="text" class="formfld unknown" id="linespeed" size="40" value="<?=htmlspecialchars($pconfig['linespeed']);?>">
|
253
|
</td>
|
254
|
</tr>
|
255
|
<tr>
|
256
|
<td width="22%" valign="top" class="vncell">Maximum connection retry</td>
|
257
|
<td width="78%" class="vtable">
|
258
|
<input name="connect-max-attempts" type="text" class="formfld unknown" id="connect-max-attempts" size="2" value="<?=htmlspecialchars($pconfig['connect-max-attempts']);?>">
|
259
|
</td>
|
260
|
</tr>
|
261
|
<tr>
|
262
|
<td width="22%" valign="top" class="vncell">Description</td>
|
263
|
<td width="78%" class="vtable">
|
264
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
|
265
|
<br> <span class="vexpl">You may enter a description here for your reference (not parsed).</span>
|
266
|
</td>
|
267
|
</tr>
|
268
|
<tr>
|
269
|
<td width="22%" valign="top"> </td>
|
270
|
<td width="78%">
|
271
|
<input name="Submit" type="submit" class="formbtn" value="Save">
|
272
|
<input type="button" value="Cancel" onclick="history.back()">
|
273
|
<?php if (isset($id) && $a_ppps[$id]): ?>
|
274
|
<input name="id" type="hidden" value="<?=$id;?>">
|
275
|
<?php endif; ?>
|
276
|
</td>
|
277
|
</tr>
|
278
|
</table>
|
279
|
</form>
|
280
|
<?php include("fend.inc"); ?>
|
281
|
</body>
|
282
|
</html>
|