Project

General

Profile

Download (5.08 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
function ppp_inuse($num) {
42
	global $config, $g;
43

    
44
	if ($config['interfaces']['lan']['if'] == "ppp{$num}")
45
		return true;
46
	if ($config['interfaces']['wan']['if'] == "ppp{$num}")
47
		return true;
48

    
49
	for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
50
		if ($config['interfaces']['opt' . $i]['if'] == "ppp{$num}")
51
			return true;
52
	}
53

    
54
	return false;
55
}
56

    
57
function renumber_ppp($if, $delppp) {
58
	if (!preg_match("/^ppp/", $if))
59
		return $if;
60

    
61
	$ppp = substr($if, 4);
62
	if ($ppp > $delppp)
63
		return "ppp" . ($ppp - 1);
64
	else
65
		return $if;
66
}
67

    
68
if ($_GET['act'] == "del") {
69
	/* check if still in use */
70
	if (ppp_inuse($_GET['id'])) {
71
		$input_errors[] = "This PPP interface cannot be deleted because it is still being used as an interface.";
72
	} else {
73
		unset($a_ppps[$_GET['id']]);
74

    
75
		/* renumber all interfaces that use PPP */
76
		$config['interfaces']['lan']['if'] = renumber_ppp($config['interfaces']['lan']['if'], $_GET['id']);
77
		$config['interfaces']['wan']['if'] = renumber_ppp($config['interfaces']['wan']['if'], $_GET['id']);
78
		for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++)
79
			$config['interfaces']['opt' . $i]['if'] = renumber_ppp($config['interfaces']['opt' . $i]['if'], $_GET['id']);
80

    
81
		write_config();
82

    
83
		interfaces_optional_configure();
84

    
85
		header("Location: interfaces_ppp.php");
86
		exit;
87
	}
88
}
89

    
90

    
91
$pgtitle = "Interfaces: PPP";
92
include("head.inc");
93

    
94
?>
95

    
96
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
97
<?php include("fbegin.inc"); ?>
98
<?php if ($input_errors) print_input_errors($input_errors); ?>
99
<table width="100%" border="0" cellpadding="0" cellspacing="0">
100
  <tr><td>
101
<?php
102
	$tab_array = array();
103
	$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
104
	$tab_array[1] = array("VLANs", false, "interfaces_vlan.php");
105
	$tab_array[2] = array("PPP", true, "interfaces_ppp.php");
106
	display_top_tabs($tab_array);
107
?>
108
  </td></tr>
109
  <tr>
110
    <td>
111
	<div id="mainarea">
112
	<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
113
                <tr>
114
                  <td width="20%" class="listhdrr">Interface</td>
115
                  <td width="20%" class="listhdrr">Serial Port</td>
116
                  <td width="50%" class="listhdr">Description</td>
117
                  <td width="10%" class="list"></td>
118
				</tr>
119
			  <?php $i = 0; foreach ($a_ppps as $id => $ppp): ?>
120
                <tr>
121
                  <td class="listlr">
122
					ppp<?=htmlspecialchars($id);?>
123
                  </td>
124
                  <td class="listr">
125
					<?=htmlspecialchars($ppp['port']);?>
126
                  </td>
127
                  <td class="listbg">
128
		    <font color="white">
129
                    <?=htmlspecialchars($ppp['descr']);?>&nbsp;
130
		    </font>
131
                  </td>
132
                  <td valign="middle" nowrap class="list"> <a href="interfaces_ppp_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
133
                     &nbsp;<a href="interfaces_ppp.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this PPP interface?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
134
				</tr>
135
			  <?php $i++; endforeach; ?>
136
                <tr>
137
                  <td class="list" colspan="3">&nbsp;</td>
138
                  <td class="list"> <a href="interfaces_ppp_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
139
				</tr>
140
              </table>
141
	      </div>
142
	</td>
143
	</tr>
144
</table>
145
<?php include("fend.inc"); ?>
146
</body>
147
</html>
(77-77/193)