Project

General

Profile

Download (8.87 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
	
9
	Copyright (C) 2004-2008 BSD Perimeter LLC.
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 6b07c15a Matthew Grooms
##|+PRIV
35
##|*IDENT=page-interfaces-ppp-edit
36
##|*NAME=Interfaces: PPP: Edit page
37
##|*DESCR=Allow access to the 'Interfaces: PPP: Edit' page.
38
##|*MATCH=interfaces_ppp_edit.php*
39
##|-PRIV
40
41
42 860c4e80 Chris Buechler
require("guiconfig.inc");
43
44
if (!is_array($config['ppps']['ppp']))
45
	$config['ppps']['ppp'] = array();
46
47
$a_ppps = &$config['ppps']['ppp'];
48
49
50
$id = $_GET['id'];
51
if (isset($_POST['id']))
52
	$id = $_POST['id'];
53
54
if (isset($id) && $a_ppps[$id]) {
55 5d41713c Ermal Luçi
	$pconfig['port'] = $a_ppps[$id]['port'];
56 f4758c47 Ermal Luçi
	$pconfig['ap'] = $a_ppps[$id]['ap'];
57 5d41713c Ermal Luçi
	$pconfig['pppif'] = $a_ppps[$id]['pppif'];
58 860c4e80 Chris Buechler
	$pconfig['initstr'] = $a_ppps[$id]['initstr'];
59 f4758c47 Ermal Luçi
	$pconfig['username'] = $a_ppps[$id]['username'];
60
	$pconfig['password'] = $a_ppps[$id]['password'];
61
	$pconfig['gateway'] = $a_ppps[$id]['gateway'];
62
	$pconfig['localip'] = $a_ppps[$id]['localip'];
63 860c4e80 Chris Buechler
	$pconfig['phone'] = $a_ppps[$id]['phone'];
64 f4758c47 Ermal Luçi
	$pconfig['connect-max-attempts'] = $a_ppps[$id]['connect-max-attempts'];
65 860c4e80 Chris Buechler
	$pconfig['linespeed'] = $a_ppps[$id]['linespeed'];
66
	$pconfig['descr'] = $a_ppps[$id]['descr'];
67
}
68
69
if ($_POST) {
70
71
	unset($input_errors);
72
	$pconfig = $_POST;
73
74
	/* input validation */
75
	$reqdfields = explode(" ", "port");
76
	$reqdfieldsn = explode(",", "Serial Port");
77
78
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
79
80
	foreach ($a_ppps as $ppp) {
81
		if (isset($id) && ($a_ppps[$id]) && ($a_ppps[$id] === $ppp))
82
			continue;
83
84
		if ($ppp['port'] == $_POST['port']) {
85
			$input_errors[] = "Port is in use";
86
			break;
87
		}
88
	}
89
90
	if (!$input_errors) {
91
		$ppp = array();
92
		$ppp['port'] = $_POST['port'];
93
		$ppp['initstr'] = $_POST['initstr'];
94 f4758c47 Ermal Luçi
		$ppp['ap'] = $_POST['ap'];
95 860c4e80 Chris Buechler
		$ppp['phone'] = $_POST['phone'];
96 f4758c47 Ermal Luçi
		$ppp['username'] = $_POST['username'];
97
		$ppp['password'] = $_POST['password'];
98
		$ppp['localip'] = $_POST['localip'];
99
		$ppp['gateway'] = $_POST['gateway'];
100 860c4e80 Chris Buechler
		$ppp['linespeed'] = $_POST['linespeed'];
101 f4758c47 Ermal Luçi
		$ppp['connect-max-attempts'] = $_POST['connect-max-attempts'];
102 860c4e80 Chris Buechler
		$ppp['descr'] = $_POST['descr'];
103 f4758c47 Ermal Luçi
		$ppp['pppif'] = $_POST['pppif'];
104 5d41713c Ermal Luçi
		$ppp['pppif'] = interface_ppp_configure($ppp);
105
                if ($ppp['pppif'] == "" || !stristr($ppp['pppif'], "ppp"))
106
                        $input_errors[] = "Error occured creating interface, please retry.";
107
                else {
108
			if (isset($id) && $a_ppps[$id])
109
				$a_ppps[$id] = $ppp;
110
			else
111
				$a_ppps[] = $ppp;
112
113
			write_config();
114
115
			header("Location: interfaces_ppp.php");
116
			exit;
117
		}
118 860c4e80 Chris Buechler
	}
119
}
120
121 06a22f6d Chris Buechler
$pgtitle = "Interfaces: PPP: Edit";
122 860c4e80 Chris Buechler
include("head.inc");
123
124
?>
125
126
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
127
<?php include("fbegin.inc"); ?>
128
<?php if ($input_errors) print_input_errors($input_errors); ?>
129
            <form action="interfaces_ppp_edit.php" method="post" name="iform" id="iform">
130
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
131
				<tr>
132 478e3e65 Scott Ullrich
					<td colspan="2" valign="top" class="listtopic">PPP configuration</td>
133
				</tr>
134
				<tr>
135 860c4e80 Chris Buechler
                  <td width="22%" valign="top" class="vncellreq">Parent interface</td>
136
                  <td width="78%" class="vtable">
137 f4758c47 Ermal Luçi
                    <select name="port" id="port" class="formselect">
138 860c4e80 Chris Buechler
                      <?php
139 f4758c47 Ermal Luçi
			 	$portlist = glob("/dev/cua*");
140
			 	foreach ($portlist as $port) {
141
					if(preg_match("/\.(lock|init)$/", $port))
142
						continue;
143
					echo "<option value=\"".trim($port)."\"";
144
					if ($pconfig['port'] == $port)
145
						echo "selected";
146
					echo ">{$port}</option>";
147
				}
148
		    	?>
149 860c4e80 Chris Buechler
                    </select>
150
                </tr>
151 f4758c47 Ermal Luçi
                <tr>
152 860c4e80 Chris Buechler
                  <td width="22%" valign="top" class="vncell">Init String</td>
153
                  <td width="78%" class="vtable">
154
                    <textarea name="initstr"><?=htmlspecialchars($pconfig['initstr']);?></textarea>
155
                    <br> <span class="vexpl">Enter the modem initialization string here</span></td>
156
                </tr>
157 f4758c47 Ermal Luçi
 		<tr>
158
 		  <td width="22%" valign="top" class="vncell">AP Hostname</td>
159
 		  <td width="78%" class="vtable">
160
 		    <input name="ap" type="text" class="formfld unknown" id="ap" size="40" value="<?=htmlspecialchars($pconfig['ap']);?>">
161
 		</td>
162
 		</tr>
163
 		<tr>
164
 		  <td width="22%" valign="top" class="vncell">Phone Number</td>
165
 		  <td width="78%" class="vtable">
166
 		    <input name="phone" type="text" class="formfld unknown" id="phone" size="40" value="<?=htmlspecialchars($pconfig['phone']);?>">
167
 		  </td>
168
 		</tr>
169
                <tr>
170
                  <td width="22%" valign="top" class="vncell">Username</td>
171 860c4e80 Chris Buechler
                  <td width="78%" class="vtable">
172 f4758c47 Ermal Luçi
			<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
173
                  </td>
174
                </tr>
175
                <tr>
176
                  <td width="22%" valign="top" class="vncell">Password</td>
177
                  <td width="78%" class="vtable">
178
			<input name="password" type="password" class="formfld pwd" id="password" value="<?=htmlspecialchars($pconfig['password']);?>">
179
                  </td>
180
		</tr>
181
 		<tr>
182
 		  <td width="22%" valign="top" class="vncell">Local IP</td>
183
 		  <td width="78%" class="vtable">
184
 		    <input name="gateway" type="text" class="formfld unknown" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>">
185
			<span><p>Note: This is needed if you connect to a private system and are given a static ip.</span>
186
 		  </td>
187
                </tr>
188
                <tr>
189
                  <td width="22%" valign="top" class="vncell">Remote IP</td>
190
                  <td width="78%" class="vtable">
191
                    <input name="localip" type="text" class="formfld unknown" id="localip" size="40" value="<?=htmlspecialchars($pconfig['localip']);?>">
192
			<span><p>Note: This is where the packets will be routed, aka gateway on normal ip routing.</span>
193 860c4e80 Chris Buechler
                  </td>
194
                </tr>
195
		<tr>
196
                  <td width="22%" valign="top" class="vncell">Line Speed</td>
197
                  <td width="78%" class="vtable">
198 f4758c47 Ermal Luçi
                    <input name="linespeed" type="text" class="formfld unknown" id="linespeed" size="40" value="<?=htmlspecialchars($pconfig['linespeed']);?>">
199
                  </td>
200
                </tr>
201
                <tr>
202
                  <td width="22%" valign="top" class="vncell">Maximum connection retry</td>
203
                  <td width="78%" class="vtable">
204
                    <input name="connect-max-attempts" type="text" class="formfld unknown" id="connect-max-attempts" size="2" value="<?=htmlspecialchars($pconfig['connect-max-attempts']);?>">
205 860c4e80 Chris Buechler
                  </td>
206
                </tr>
207
		<tr>
208
                  <td width="22%" valign="top" class="vncell">Description</td>
209
                  <td width="78%" class="vtable">
210 f4758c47 Ermal Luçi
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
211 860c4e80 Chris Buechler
                    <br> <span class="vexpl">You may enter a description here
212
                    for your reference (not parsed).</span></td>
213
                </tr>
214
                <tr>
215
                  <td width="22%" valign="top">&nbsp;</td>
216
                  <td width="78%">
217 f4758c47 Ermal Luçi
                  	<input name="Submit" type="submit" class="formbtn" value="Save"> 
218
			<input type="button" value="Cancel" onclick="history.back()">
219 860c4e80 Chris Buechler
                    <?php if (isset($id) && $a_ppps[$id]): ?>
220
                    <input name="id" type="hidden" value="<?=$id;?>">
221 f4758c47 Ermal Luçi
		    <input name="pppif" id="pppif" type="hidden" value="<?=$pconfig['pppif'];?>">
222 860c4e80 Chris Buechler
                    <?php endif; ?>
223
                  </td>
224
                </tr>
225
              </table>
226
</form>
227
<?php include("fend.inc"); ?>
228
</body>
229
</html>