Project

General

Profile

Download (5.93 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['if'] = $a_ppps[$id]['if'];
56
	$pconfig['initstr'] = $a_ppps[$id]['initstr'];
57
	$pconfig['phone'] = $a_ppps[$id]['phone'];
58
	$pconfig['linespeed'] = $a_ppps[$id]['linespeed'];
59
	$pconfig['descr'] = $a_ppps[$id]['descr'];
60
}
61

    
62
if ($_POST) {
63

    
64
	unset($input_errors);
65
	$pconfig = $_POST;
66

    
67
	/* input validation */
68
	$reqdfields = explode(" ", "port");
69
	$reqdfieldsn = explode(",", "Serial Port");
70

    
71
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
72

    
73
	foreach ($a_ppps as $ppp) {
74
		if (isset($id) && ($a_ppps[$id]) && ($a_ppps[$id] === $ppp))
75
			continue;
76

    
77
		if ($ppp['port'] == $_POST['port']) {
78
			$input_errors[] = "Port is in use";
79
			break;
80
		}
81
	}
82

    
83
	if (!$input_errors) {
84
		$ppp = array();
85
		$ppp['port'] = $_POST['port'];
86
		$ppp['initstr'] = $_POST['initstr'];
87
		$ppp['phone'] = $_POST['phone'];
88
		$ppp['linespeed'] = $_POST['linespeed'];
89
		$ppp['descr'] = $_POST['descr'];
90

    
91
		if (isset($id) && $a_ppps[$id])
92
			$a_ppps[$id] = $ppp;
93
		else
94
			$a_ppps[] = $ppp;
95

    
96
		write_config();
97

    
98
		interfaces_configure();
99

    
100
		header("Location: interfaces_ppp.php");
101
		exit;
102
	}
103
}
104

    
105
$pgtitle = "Interfaces: PPP: Edit";
106
include("head.inc");
107

    
108
?>
109

    
110
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
111
<?php include("fbegin.inc"); ?>
112
<?php if ($input_errors) print_input_errors($input_errors); ?>
113
            <form action="interfaces_ppp_edit.php" method="post" name="iform" id="iform">
114
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
115
				<tr>
116
					<td colspan="2" valign="top" class="listtopic">PPP configuration</td>
117
				</tr>
118
				<tr>
119
                  <td width="22%" valign="top" class="vncellreq">Parent interface</td>
120
                  <td width="78%" class="vtable">
121
                    <select name="port" class="formfld">
122
                      <?php
123
					 	$portlist = glob("/dev/cua*");
124
					 	foreach ($portlist as $port) {
125
							if(preg_match("/\.(lock|init)$/", $port))
126
								continue;
127
							echo "<option value=\"{$port}\"";
128
							if (false)
129
								echo "selected";
130
							echo ">";
131
                      		echo $port;
132
                    		echo "</option>";
133
						}
134
		      			?>
135
                    </select>
136
                </tr>
137
				<tr>
138
                  <td width="22%" valign="top" class="vncell">Init String</td>
139
                  <td width="78%" class="vtable">
140
                    <textarea name="initstr"><?=htmlspecialchars($pconfig['initstr']);?></textarea>
141
                    <br> <span class="vexpl">Enter the modem initialization string here</span></td>
142
                </tr>
143
		<tr>
144
                  <td width="22%" valign="top" class="vncell">Phone Number</td>
145
                  <td width="78%" class="vtable">
146
                    <input name="phone" type="text" class="formfld" id="phone" size="40" value="<?=htmlspecialchars($pconfig['phone']);?>">
147
                  </td>
148
                </tr>
149
		<tr>
150
                  <td width="22%" valign="top" class="vncell">Line Speed</td>
151
                  <td width="78%" class="vtable">
152
                    <input name="linespeed" type="text" class="formfld" id="linespeed" size="40" value="<?=htmlspecialchars($pconfig['linespeed']);?>">
153
                  </td>
154
                </tr>
155

    
156
		<tr>
157
                  <td width="22%" valign="top" class="vncell">Description</td>
158
                  <td width="78%" class="vtable">
159
                    <input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
160
                    <br> <span class="vexpl">You may enter a description here
161
                    for your reference (not parsed).</span></td>
162
                </tr>
163
                <tr>
164
                  <td width="22%" valign="top">&nbsp;</td>
165
                  <td width="78%">
166
                    <input name="Submit" type="submit" class="formbtn" value="Save"> <input type="button" value="Cancel" onclick="history.back()">
167
                    <?php if (isset($id) && $a_ppps[$id]): ?>
168
                    <input name="id" type="hidden" value="<?=$id;?>">
169
                    <?php endif; ?>
170
                  </td>
171
                </tr>
172
              </table>
173
</form>
174
<?php include("fend.inc"); ?>
175
</body>
176
</html>
(85-85/211)