Project

General

Profile

Download (8.91 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
	
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
##|+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
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
	$pconfig['port'] = $a_ppps[$id]['port'];
56
	$pconfig['ap'] = $a_ppps[$id]['ap'];
57
	$pconfig['pppif'] = $a_ppps[$id]['pppif'];
58
	$pconfig['initstr'] = $a_ppps[$id]['initstr'];
59
	$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
	$pconfig['phone'] = $a_ppps[$id]['phone'];
64
	$pconfig['connect-max-attempts'] = $a_ppps[$id]['connect-max-attempts'];
65
	$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
		$ppp['ap'] = $_POST['ap'];
95
		$ppp['phone'] = $_POST['phone'];
96
		$ppp['username'] = $_POST['username'];
97
		$ppp['password'] = $_POST['password'];
98
		$ppp['localip'] = $_POST['localip'];
99
		$ppp['gateway'] = $_POST['gateway'];
100
		$ppp['linespeed'] = $_POST['linespeed'];
101
		$ppp['connect-max-attempts'] = $_POST['connect-max-attempts'];
102
		$ppp['descr'] = $_POST['descr'];
103
		$ppp['pppif'] = $_POST['pppif'];
104
		$ppp['pppif'] = interface_ppp_configure($ppp);
105
                if ($ppp['pppif'] == "" || !stristr($ppp['pppif'], "ppp"))
106
                        $input_errors[] = "Error occurred creating PPP interface. Check System log for details";
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
	}
119
}
120

    
121
$pgtitle = "Interfaces: PPP: Edit";
122
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
					<td colspan="2" valign="top" class="listtopic">PPP configuration</td>
133
				</tr>
134
				<tr>
135
                  <td width="22%" valign="top" class="vncellreq">Parent interface</td>
136
                  <td width="78%" class="vtable">
137
                    <select name="port" id="port" class="formselect">
138
                      <?php
139
			 	$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
                    </select>
150
                </tr>
151
                <tr>
152
                  <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
 		<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
                  <td width="78%" class="vtable">
172
			<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="localip" type="text" class="formfld unknown" id="localip" size="40" value="<?=htmlspecialchars($pconfig['localip']);?>">
185
			<span><p>Note: Enter your IP address here if it is not automatically assigned.</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="gateway" type="text" class="formfld unknown" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>">
192
			<span><p>Note: Enter the remote IP here if not automatically assigned. This
193
			is where the packets will be routed, equivalent to the gateway.</span>
194
                  </td>
195
                </tr>
196
		<tr>
197
                  <td width="22%" valign="top" class="vncell">Line Speed</td>
198
                  <td width="78%" class="vtable">
199
                    <input name="linespeed" type="text" class="formfld unknown" id="linespeed" size="40" value="<?=htmlspecialchars($pconfig['linespeed']);?>">
200
                  </td>
201
                </tr>
202
                <tr>
203
                  <td width="22%" valign="top" class="vncell">Maximum connection retry</td>
204
                  <td width="78%" class="vtable">
205
                    <input name="connect-max-attempts" type="text" class="formfld unknown" id="connect-max-attempts" size="2" value="<?=htmlspecialchars($pconfig['connect-max-attempts']);?>">
206
                  </td>
207
                </tr>
208
		<tr>
209
                  <td width="22%" valign="top" class="vncell">Description</td>
210
                  <td width="78%" class="vtable">
211
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
212
                    <br> <span class="vexpl">You may enter a description here
213
                    for your reference (not parsed).</span></td>
214
                </tr>
215
                <tr>
216
                  <td width="22%" valign="top">&nbsp;</td>
217
                  <td width="78%">
218
                  	<input name="Submit" type="submit" class="formbtn" value="Save"> 
219
			<input type="button" value="Cancel" onclick="history.back()">
220
                    <?php if (isset($id) && $a_ppps[$id]): ?>
221
                    <input name="id" type="hidden" value="<?=$id;?>">
222
		    <input name="pppif" id="pppif" type="hidden" value="<?=$pconfig['pppif'];?>">
223
                    <?php endif; ?>
224
                  </td>
225
                </tr>
226
              </table>
227
</form>
228
<?php include("fend.inc"); ?>
229
</body>
230
</html>
(90-90/210)