Project

General

Profile

Download (5.66 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
require("guiconfig.inc");
35

    
36
if (!is_array($config['ppps']['ppp']))
37
	$config['ppps']['ppp'] = array();
38

    
39
$a_ppps = &$config['ppps']['ppp'];
40

    
41

    
42
$id = $_GET['id'];
43
if (isset($_POST['id']))
44
	$id = $_POST['id'];
45

    
46
if (isset($id) && $a_ppps[$id]) {
47
	$pconfig['if'] = $a_ppps[$id]['if'];
48
	$pconfig['initstr'] = $a_ppps[$id]['initstr'];
49
	$pconfig['phone'] = $a_ppps[$id]['phone'];
50
	$pconfig['linespeed'] = $a_ppps[$id]['linespeed'];
51
	$pconfig['descr'] = $a_ppps[$id]['descr'];
52
}
53

    
54
if ($_POST) {
55

    
56
	unset($input_errors);
57
	$pconfig = $_POST;
58

    
59
	/* input validation */
60
	$reqdfields = explode(" ", "port");
61
	$reqdfieldsn = explode(",", "Serial Port");
62

    
63
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
64

    
65
	foreach ($a_ppps as $ppp) {
66
		if (isset($id) && ($a_ppps[$id]) && ($a_ppps[$id] === $ppp))
67
			continue;
68

    
69
		if ($ppp['port'] == $_POST['port']) {
70
			$input_errors[] = "Port is in use";
71
			break;
72
		}
73
	}
74

    
75
	if (!$input_errors) {
76
		$ppp = array();
77
		$ppp['port'] = $_POST['port'];
78
		$ppp['initstr'] = $_POST['initstr'];
79
		$ppp['phone'] = $_POST['phone'];
80
		$ppp['linespeed'] = $_POST['linespeed'];
81
		$ppp['descr'] = $_POST['descr'];
82

    
83
		if (isset($id) && $a_ppps[$id])
84
			$a_ppps[$id] = $ppp;
85
		else
86
			$a_ppps[] = $ppp;
87

    
88
		write_config();
89

    
90
		interfaces_configure();
91

    
92
		header("Location: interfaces_ppp.php");
93
		exit;
94
	}
95
}
96

    
97
$pgtitle = "Interfaces: PPP: Edit";
98
include("head.inc");
99

    
100
?>
101

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

    
145
		<tr>
146
                  <td width="22%" valign="top" class="vncell">Description</td>
147
                  <td width="78%" class="vtable">
148
                    <input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
149
                    <br> <span class="vexpl">You may enter a description here
150
                    for your reference (not parsed).</span></td>
151
                </tr>
152
                <tr>
153
                  <td width="22%" valign="top">&nbsp;</td>
154
                  <td width="78%">
155
                    <input name="Submit" type="submit" class="formbtn" value="Save"> <input type="button" value="Cancel" onclick="history.back()">
156
                    <?php if (isset($id) && $a_ppps[$id]): ?>
157
                    <input name="id" type="hidden" value="<?=$id;?>">
158
                    <?php endif; ?>
159
                  </td>
160
                </tr>
161
              </table>
162
</form>
163
<?php include("fend.inc"); ?>
164
</body>
165
</html>
(79-79/200)