Project

General

Profile

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

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

    
29
require_once("guiconfig.inc");
30
require_once("filter.inc");
31
require_once("vpn.inc");
32

    
33
if (!is_array($config['pppoes'])) {
34
	$config['pppoes'] = array();
35
}
36

    
37
if (!is_array($config['pppoes']['pppoe'])) {
38
	$config['pppoes']['pppoe'] = array();
39
}
40

    
41
$a_pppoes = &$config['pppoes']['pppoe'];
42

    
43

    
44
if ($_POST['apply']) {
45
	if (file_exists("{$g['tmp_path']}/.vpn_pppoe.apply")) {
46
		$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.vpn_pppoe.apply"));
47
		foreach ($toapplylist as $pppoeid) {
48
			if (!is_numeric($pppoeid)) {
49
				continue;
50
			}
51
			if (is_array($config['pppoes']['pppoe'])) {
52
				foreach ($config['pppoes']['pppoe'] as $pppoe) {
53
					if ($pppoe['pppoeid'] == $pppoeid) {
54
						vpn_pppoe_configure($pppoe);
55
						break;
56
					}
57
				}
58
			}
59
		}
60
		@unlink("{$g['tmp_path']}/.vpn_pppoe.apply");
61
	}
62
	$retval = 0;
63
	$retval |= filter_configure();
64
	clear_subsystem_dirty('vpnpppoe');
65
}
66

    
67
if ($_POST['act'] == "del") {
68
	if ($a_pppoes[$_POST['id']]) {
69
		if ("{$g['varrun_path']}/pppoe" . $a_pppoes[$_POST['id']]['pppoeid'] . "-vpn.pid") {
70
			killbypid("{$g['varrun_path']}/pppoe" . $a_pppoes[$_POST['id']]['pppoeid'] . "-vpn.pid");
71
		}
72
		if (is_dir("{$g['varetc_path']}/pppoe" . $a_pppoes[$_POST['id']]['pppoeid'])) {
73
			mwexec("/bin/rm -r {$g['varetc_path']}/pppoe" . $a_pppoes[$_POST['id']]['pppoeid']);
74
		}
75
		unset($a_pppoes[$_POST['id']]);
76
		write_config();
77
		header("Location: services_pppoe.php");
78
		exit;
79
	}
80
}
81

    
82
$pgtitle = array(gettext("Services"), gettext("PPPoE Server"));
83
$shortcut_section = "pppoes";
84
include("head.inc");
85

    
86
if ($_POST['apply']) {
87
	print_apply_result_box($retval);
88
}
89

    
90
if (is_subsystem_dirty('vpnpppoe')) {
91
	print_apply_box(gettext('The PPPoE entry list has been changed.') . '<br />' . gettext('The changes must be applied for them to take effect.'));
92
}
93
?>
94

    
95
<div class="panel panel-default">
96
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('PPPoE Server')?></h2></div>
97
	<div class="panel-body">
98

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

    
141
	</div>
142
</div>
143

    
144
<nav class="action-buttons">
145
	<a href="services_pppoe_edit.php" class="btn btn-success">
146
		<i class="fa fa-plus icon-embed-btn"></i>
147
		<?=gettext("Add")?>
148
	</a>
149
</nav>
150

    
151
<?php
152
include("foot.inc");
(141-141/234)