Project

General

Profile

Download (4.08 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * services_pppoe.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-2024 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * Licensed under the Apache License, Version 2.0 (the "License");
12
 * you may not use this file except in compliance with the License.
13
 * You may obtain a copy of the License at
14
 *
15
 * http://www.apache.org/licenses/LICENSE-2.0
16
 *
17
 * Unless required by applicable law or agreed to in writing, software
18
 * distributed under the License is distributed on an "AS IS" BASIS,
19
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
 * See the License for the specific language governing permissions and
21
 * limitations under the License.
22
 */
23

    
24
##|+PRIV
25
##|*IDENT=page-services-pppoeserver
26
##|*NAME=Services: PPPoE Server
27
##|*DESCR=Allow access to the 'Services: PPPoE Server' page.
28
##|*MATCH=services_pppoe.php*
29
##|-PRIV
30

    
31
require_once("guiconfig.inc");
32
require_once("filter.inc");
33
require_once("vpn.inc");
34

    
35
config_init_path('pppoes/pppoe');
36

    
37

    
38
if ($_POST['apply']) {
39
	if (file_exists("{$g['tmp_path']}/.vpn_pppoe.apply")) {
40
		$toapplylist = unserialize_data(file_get_contents("{$g['tmp_path']}/.vpn_pppoe.apply"), []);
41
		foreach ($toapplylist as $pppoeid) {
42
			if (!is_numeric($pppoeid)) {
43
				continue;
44
			}
45
			foreach (config_get_path('pppoes/pppoe', []) as $pppoe) {
46
				if ($pppoe['pppoeid'] == $pppoeid) {
47
					vpn_pppoe_configure($pppoe);
48
					break;
49
				}
50
			}
51
		}
52
		@unlink("{$g['tmp_path']}/.vpn_pppoe.apply");
53
	}
54
	$retval = 0;
55
	$retval |= filter_configure();
56
	clear_subsystem_dirty('vpnpppoe');
57
}
58

    
59
$this_pppoe_config = isset($_POST['id']) ? config_get_path("pppoes/pppoe/{$_POST['id']}") : null;
60
if ($_POST['act'] == "del") {
61
	if ($this_pppoe_config) {
62
		if ("{$g['varrun_path']}/pppoe" . $this_pppoe_config['pppoeid'] . "-vpn.pid") {
63
			killbypid("{$g['varrun_path']}/pppoe" . $this_pppoe_config['pppoeid'] . "-vpn.pid");
64
		}
65
		if (is_dir("{$g['varetc_path']}/pppoe{$this_pppoe_config['pppoeid']}-vpn")) {
66
			rmdir_recursive("{$g['varetc_path']}/pppoe{$this_pppoe_config['pppoeid']}-vpn");
67
		}
68
		config_del_path("pppoes/pppoe/{$_POST['id']}");
69
		write_config("PPPoE Server deleted");
70
		header("Location: services_pppoe.php");
71
		exit;
72
	}
73
}
74

    
75
$pgtitle = array(gettext("Services"), gettext("PPPoE Server"));
76
$shortcut_section = "pppoes";
77
include("head.inc");
78

    
79
if ($_POST['apply']) {
80
	print_apply_result_box($retval);
81
}
82

    
83
if (is_subsystem_dirty('vpnpppoe')) {
84
	print_apply_box(gettext('The PPPoE entry list has been changed.') . '<br />' . gettext('The changes must be applied for them to take effect.'));
85
}
86
?>
87

    
88
<div class="panel panel-default">
89
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('PPPoE Server')?></h2></div>
90
	<div class="panel-body">
91

    
92
	<div class="table-responsive">
93
	<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
94
		<thead>
95
			<tr>
96
				<th><?=gettext("Interface")?></th>
97
				<th><?=gettext("Local IP")?></th>
98
				<th><?=gettext("Number of users")?></th>
99
				<th><?=gettext("Description")?></th>
100
				<th><?=gettext("Actions")?></th>
101
			</tr>
102
		</thead>
103
		<tbody>
104
<?php
105
$i = 0;
106
foreach (config_get_path('pppoes/pppoe', []) as $pppoe):
107
?>
108
			<tr>
109
				<td>
110
					<?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($pppoe['interface']))?>
111
				</td>
112
				<td>
113
					<?=htmlspecialchars($pppoe['localip'])?>
114
				</td>
115
				<td>
116
					<?=htmlspecialchars($pppoe['n_pppoe_units'])?>
117
				</td>
118
				<td>
119
					<?=htmlspecialchars($pppoe['descr'])?>
120
				</td>
121
				<td>
122
					<a class="fa-solid fa-pencil"	title="<?=gettext('Edit PPPoE instance')?>"	href="services_pppoe_edit.php?id=<?=$i?>"></a>
123
					<a class="fa-solid fa-trash-can" title="<?=gettext('Delete PPPoE instance')?>" href="services_pppoe.php?act=del&amp;id=<?=$i?>" usepost></a>
124
				</td>
125
			</tr>
126
<?php
127
	$i++;
128
endforeach;
129
?>
130
		</tbody>
131
	</table>
132
</div>
133

    
134
	</div>
135
</div>
136

    
137
<nav class="action-buttons">
138
	<a href="services_pppoe_edit.php" class="btn btn-success">
139
		<i class="fa-solid fa-plus icon-embed-btn"></i>
140
		<?=gettext("Add")?>
141
	</a>
142
</nav>
143

    
144
<?php
145
include("foot.inc");
(139-139/232)