Project

General

Profile

Download (4.74 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * interfaces_ppps.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * originally based on m0n0wall (http://m0n0.ch/wall)
12
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
13
 * All rights reserved.
14
 *
15
 * Licensed under the Apache License, Version 2.0 (the "License");
16
 * you may not use this file except in compliance with the License.
17
 * You may obtain a copy of the License at
18
 *
19
 * http://www.apache.org/licenses/LICENSE-2.0
20
 *
21
 * Unless required by applicable law or agreed to in writing, software
22
 * distributed under the License is distributed on an "AS IS" BASIS,
23
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
 * See the License for the specific language governing permissions and
25
 * limitations under the License.
26
 */
27

    
28
##|+PRIV
29
##|*IDENT=page-interfaces-ppps
30
##|*NAME=Interfaces: PPPs
31
##|*DESCR=Allow access to the 'Interfaces: PPPs' page.
32
##|*MATCH=interfaces_ppps.php*
33
##|-PRIV
34

    
35
require_once("guiconfig.inc");
36
require_once("functions.inc");
37

    
38
function ppp_inuse($num) {
39
	global $config, $g;
40

    
41
	$iflist = get_configured_interface_list(true);
42
	if (!is_array($config['ppps']['ppp'])) {
43
		return false;
44
	}
45

    
46
	foreach ($iflist as $if) {
47
		if ($config['interfaces'][$if]['if'] == $config['ppps']['ppp'][$num]['if']) {
48
			return true;
49
		}
50
	}
51

    
52
	return false;
53
}
54

    
55
if ($_POST['act'] == "del") {
56
	/* check if still in use */
57
	if (ppp_inuse($_POST['id'])) {
58
		$input_errors[] = gettext("This point-to-point link cannot be deleted because it is still being used as an interface.");
59
	} elseif (is_array($config['ppps']['ppp']) && is_array($config['ppps']['ppp'][$_POST['id']])) {
60

    
61
		unset($config['ppps']['ppp'][$_POST['id']]['pppoe-reset-type']);
62
		handle_pppoe_reset($config['ppps']['ppp'][$_POST['id']]);
63
		unset($config['ppps']['ppp'][$_POST['id']]);
64
		write_config("PPP interface deleted");
65
		header("Location: interfaces_ppps.php");
66
		exit;
67
	}
68
}
69

    
70
if (!is_array($config['ppps'])) {
71
	$config['ppps'] = array();
72
}
73

    
74
if (!is_array($config['ppps']['ppp'])) {
75
	$config['ppps']['ppp'] = array();
76
}
77

    
78
$a_ppps = $config['ppps']['ppp'];
79

    
80
$pgtitle = array(gettext("Interfaces"), gettext("PPPs"));
81
$shortcut_section = "interfaces";
82
include("head.inc");
83

    
84
if ($input_errors) {
85
	print_input_errors($input_errors);
86
}
87

    
88
$tab_array = array();
89
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
90
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
91
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
92
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
93
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
94
$tab_array[] = array(gettext("PPPs"), true, "interfaces_ppps.php");
95
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
96
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
97
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
98
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
99
display_top_tabs($tab_array);
100
?>
101
<div class="panel panel-default">
102
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('PPP Interfaces')?></h2></div>
103
	<div class="panel-body">
104
		<div class="table-responsive">
105
			<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
106
				<thead>
107
					<tr>
108
						<th><?=gettext("Interface"); ?></th>
109
						<th><?=gettext("Interface(s)/Port(s)"); ?></th>
110
						<th><?=gettext("Description"); ?></th>
111
						<th><?=gettext("Actions")?></th>
112
					</tr>
113
				</thead>
114
				<tbody>
115
<?php
116

    
117
$i = 0;
118

    
119

    
120
if (is_array($a_ppps)) {
121
	foreach ($a_ppps as $id => $ppp) {
122
?>
123
					<tr>
124
						<td>
125
							<?=htmlspecialchars($ppp['if'])?>
126
						</td>
127
						<td>
128
<?php
129
	$portlist = explode(",", $ppp['ports']);
130
	foreach ($portlist as $portid => $port) {
131
		if ($port != get_real_interface($port) && $ppp['type'] != "ppp") {
132
			$portlist[$portid] = convert_friendly_interface_to_friendly_descr($port);
133
		}
134
	}
135
							echo htmlspecialchars(implode(",", $portlist));
136
?>
137
						</td>
138
						<td>
139
							<?=htmlspecialchars($ppp['descr'])?>
140
						</td>
141
						<td>
142
							<a class="fa fa-pencil"	title="<?=gettext('Edit PPP interface')?>"	href="interfaces_ppps_edit.php?id=<?=$i?>"></a>
143
							<a class="fa fa-trash"	title="<?=gettext('Delete PPP interface')?>"	href="interfaces_ppps.php?act=del&amp;id=<?=$i?>" usepost></a>
144
						</td>
145
					</tr>
146
<?php
147
	$i++;
148
	}
149
}
150
?>
151
				</tbody>
152
			</table>
153
		</div>
154
	</div>
155
</div>
156

    
157
<nav class="action-buttons">
158
	<a href="interfaces_ppps_edit.php" class="btn btn-success btn-sm">
159
		<i class="fa fa-plus icon-embed-btn"></i>
160
		<?=gettext("Add")?>
161
	</a>
162
</nav>
163

    
164
<?php
165
include("foot.inc");
(83-83/228)