Project

General

Profile

Download (9.09 KB) Statistics
| Branch: | Tag: | Revision:
1
<?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
	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
	$pconfig['phone'] = $a_ppps[$id]['phone'];
66
	$pconfig['dialcmd'] = $a_ppps[$id]['dialcmd'];
67
	$pconfig['connect-max-attempts'] = $a_ppps[$id]['connect-max-attempts'];
68
	$pconfig['linespeed'] = $a_ppps[$id]['linespeed'];
69
	$pconfig['descr'] = $a_ppps[$id]['descr'];
70
}
71

    
72
if ($_POST) {
73

    
74
	unset($input_errors);
75
	$pconfig = $_POST;
76

    
77
	/* input validation */
78
	$reqdfields = explode(" ", "port");
79
	$reqdfieldsn = explode(",", "Serial Port");
80

    
81
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
82

    
83
	foreach ($a_ppps as $ppp) {
84
		if (isset($id) && ($a_ppps[$id]) && ($a_ppps[$id] === $ppp))
85
			continue;
86

    
87
		if ($ppp['port'] == $_POST['port']) {
88
			$input_errors[] = "Port is in use";
89
			break;
90
		}
91
	}
92

    
93
	if (!$input_errors) {
94
		$ppp = array();
95
		$ppp['port'] = $_POST['port'];
96
		$ppp['initstr'] = $_POST['initstr'];
97
		$ppp['ap'] = $_POST['ap'];
98
		$ppp['phone'] = $_POST['phone'];
99
		$ppp['dialcmd'] = $_POST['dialcmd'];
100
		$ppp['username'] = $_POST['username'];
101
		$ppp['password'] = $_POST['password'];
102
		$ppp['localip'] = $_POST['localip'];
103
		$ppp['gateway'] = $_POST['gateway'];
104
		$ppp['linespeed'] = $_POST['linespeed'];
105
		$ppp['connect-max-attempts'] = $_POST['connect-max-attempts'];
106
		$ppp['descr'] = $_POST['descr'];
107

    
108
		interfaces_ppp_configure();
109

    
110
		if (isset($id) && $a_ppps[$id])
111
			$a_ppps[$id] = $ppp;
112
		else
113
			$a_ppps[] = $ppp;
114

    
115
		write_config();
116

    
117
		header("Location: interfaces_ppp.php");
118
		exit;
119
	}
120
}
121

    
122
$pgtitle = "Interfaces: PPP: Edit";
123
include("head.inc");
124

    
125
?>
126

    
127
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
128
<?php include("fbegin.inc"); ?>
129
<?php if ($input_errors) print_input_errors($input_errors); ?>
130
<form action="interfaces_ppp_edit.php" method="post" name="iform" id="iform">
131
	<script src="/javascript/scriptaculous/prototype.js" type="text/javascript">
132
	</script>
133
	<script type="text/javascript">
134
	function prefill_att() {
135
		$('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"';
136
		$('phone').value = "*99#";
137
		$('username').value = "att";
138
		$('password').value = "att";
139
		$('linespeed').value = "921600";
140
	}
141
	function prefill_sprint() {
142
		$('dialcmd').value = '"ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \\"\" AT OK-AT-OK ATE1Q0 OK \\dATDT\\T TIMEOUT 40 CONNECT"';
143
		$('phone').value = "#777";
144
		$('username').value = "sprint";
145
		$('password').value = "sprint";
146
		$('linespeed').value = "921600";
147
	}
148
	</script>
149
	<table width="100%" border="0" cellpadding="6" cellspacing="0">
150
		<tr>
151
			<td colspan="2" valign="top" class="listtopic">PPP configuration</td>
152
		</tr>
153
		<tr>
154
			<td width="22%" valign="top" class="vncellreq">Parent interface</td>
155
			<td width="78%" class="vtable">
156
				<select name="port" id="port" class="formselect">
157
				<?php
158
					$portlist = glob("/dev/cua*");
159
					foreach ($portlist as $port) {
160
						if(preg_match("/\.(lock|init)$/", $port))
161
							continue;
162
						echo "<option value=\"".trim($port)."\"";
163
						if ($pconfig['port'] == $port)
164
							echo "selected";
165
						echo ">{$port}</option>";
166
					}
167
				?>
168
				</select>
169
				<p/>
170
				Pre-fill connection information: 
171
				<a href='#' onClick='javascript:prefill_att();'>ATT</A>
172
				<a href='#' onClick='javascript:prefill_sprint();'>Sprint</A>
173
			</td>
174
		</tr>
175
		<tr>
176
			<td width="22%" valign="top" class="vncell">Init String</td>
177
			<td width="78%" class="vtable">
178
				<textarea id="initstr" name="initstr"><?=htmlspecialchars($pconfig['initstr']);?></textarea>
179
				<br><span class="vexpl">Enter the modem initialization string here</span>
180
			</td>
181
		</tr>
182
 		<tr>
183
 		  <td width="22%" valign="top" class="vncell">AP Hostname</td>
184
 		  <td width="78%" class="vtable">
185
 		    <input name="ap" type="text" class="formfld unknown" id="ap" size="40" value="<?=htmlspecialchars($pconfig['ap']);?>">
186
 		</td>
187
 		</tr>
188
 		<tr>
189
 		  <td width="22%" valign="top" class="vncell">Dial command</td>
190
 		  <td width="78%" class="vtable">
191
			<textarea rows="4" cols="65" name="dialcmd" id="dialcmd"><?=htmlspecialchars($pconfig['dialcmd']);?></textarea>
192
 		  </td>
193
 		</tr>
194
 		<tr>
195
 		  <td width="22%" valign="top" class="vncell">Phone Number</td>
196
 		  <td width="78%" class="vtable">
197
 		    <input name="phone" type="text" class="formfld unknown" id="phone" size="40" value="<?=htmlspecialchars($pconfig['phone']);?>">
198
 		  </td>
199
 		</tr>
200
		<tr>
201
			<td width="22%" valign="top" class="vncell">Username</td>
202
			<td width="78%" class="vtable">
203
				<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
204
			</td>
205
		</tr>
206
		<tr>
207
			<td width="22%" valign="top" class="vncell">Password</td>
208
			<td width="78%" class="vtable">
209
				<input name="password" type="password" class="formfld pwd" id="password" value="<?=htmlspecialchars($pconfig['password']);?>">
210
			</td>
211
		</tr>
212
 		<tr>
213
 		  <td width="22%" valign="top" class="vncell">Local IP</td>
214
 		  <td width="78%" class="vtable">
215
			<input name="localip" type="text" class="formfld unknown" id="localip" size="40" value="<?=htmlspecialchars($pconfig['localip']);?>">
216
			<span><p>Note: Enter your IP address here if it is not automatically assigned.</span>
217
 		  </td>
218
		</tr>
219
		<tr>
220
			<td width="22%" valign="top" class="vncell">Remote IP</td>
221
			<td width="78%" class="vtable">
222
				<input name="gateway" type="text" class="formfld unknown" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>">
223
				<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>
224
			</td>
225
		</tr>
226
		<tr>
227
			<td width="22%" valign="top" class="vncell">Line Speed</td>
228
			<td width="78%" class="vtable">
229
				<input name="linespeed" type="text" class="formfld unknown" id="linespeed" size="40" value="<?=htmlspecialchars($pconfig['linespeed']);?>">
230
			</td>
231
		</tr>
232
		<tr>
233
			<td width="22%" valign="top" class="vncell">Maximum connection retry</td>
234
			<td width="78%" class="vtable">
235
				<input name="connect-max-attempts" type="text" class="formfld unknown" id="connect-max-attempts" size="2" value="<?=htmlspecialchars($pconfig['connect-max-attempts']);?>">
236
			</td>
237
		</tr>
238
		<tr>
239
			<td width="22%" valign="top" class="vncell">Description</td>
240
			<td width="78%" class="vtable">
241
				<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
242
				<br> <span class="vexpl">You may enter a description here for your reference (not parsed).</span>
243
			</td>
244
		</tr>
245
		<tr>
246
			<td width="22%" valign="top">&nbsp;</td>
247
			<td width="78%">
248
				<input name="Submit" type="submit" class="formbtn" value="Save"> 
249
				<input type="button" value="Cancel" onclick="history.back()">
250
				<?php if (isset($id) && $a_ppps[$id]): ?>
251
					<input name="id" type="hidden" value="<?=$id;?>">
252
				<?php endif; ?>
253
			</td>
254
		</tr>
255
	</table>
256
</form>
257
<?php include("fend.inc"); ?>
258
</body>
259
</html>
(91-91/214)