1
|
<?php
|
2
|
/*
|
3
|
vpn_pppoe.php
|
4
|
Copyright (C) 2010 Ermal Luçi
|
5
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
6
|
All rights reserved.
|
7
|
|
8
|
Redistribution and use in source and binary forms, with or without
|
9
|
modification, are permitted provided that the following conditions are met:
|
10
|
|
11
|
1. Redistributions of source code must retain the above copyright notice,
|
12
|
this list of conditions and the following disclaimer.
|
13
|
|
14
|
2. Redistributions in binary form must reproduce the above copyright
|
15
|
notice, this list of conditions and the following disclaimer in the
|
16
|
documentation and/or other materials provided with the distribution.
|
17
|
|
18
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
POSSIBILITY OF SUCH DAMAGE.
|
28
|
*/
|
29
|
/*
|
30
|
pfSense_MODULE: pppoe
|
31
|
*/
|
32
|
|
33
|
##|+PRIV
|
34
|
##|*IDENT=page-services-pppoeserver
|
35
|
##|*NAME=Services: PPPoE Server page
|
36
|
##|*DESCR=Allow access to the 'Services: PPPoE Server' page.
|
37
|
##|*MATCH=vpn_pppoe.php*
|
38
|
##|-PRIV
|
39
|
|
40
|
require_once("guiconfig.inc");
|
41
|
require_once("filter.inc");
|
42
|
require_once("vpn.inc");
|
43
|
|
44
|
if (!is_array($config['pppoes']['pppoe'])) {
|
45
|
$config['pppoes']['pppoe'] = array();
|
46
|
}
|
47
|
|
48
|
$a_pppoes = &$config['pppoes']['pppoe'];
|
49
|
|
50
|
if ($_POST) {
|
51
|
$pconfig = $_POST;
|
52
|
|
53
|
if ($_POST['apply']) {
|
54
|
if (file_exists("{$g['tmp_path']}/.vpn_pppoe.apply")) {
|
55
|
$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.vpn_pppoe.apply"));
|
56
|
foreach ($toapplylist as $pppoeid) {
|
57
|
if (!is_numeric($pppoeid)) {
|
58
|
continue;
|
59
|
}
|
60
|
if (is_array($config['pppoes']['pppoe'])) {
|
61
|
foreach ($config['pppoes']['pppoe'] as $pppoe) {
|
62
|
if ($pppoe['pppoeid'] == $pppoeid) {
|
63
|
vpn_pppoe_configure($pppoe);
|
64
|
break;
|
65
|
}
|
66
|
}
|
67
|
}
|
68
|
}
|
69
|
@unlink("{$g['tmp_path']}/.vpn_pppoe.apply");
|
70
|
}
|
71
|
$retval = 0;
|
72
|
$retval |= filter_configure();
|
73
|
$savemsg = get_std_save_message($retval);
|
74
|
clear_subsystem_dirty('vpnpppoe');
|
75
|
}
|
76
|
}
|
77
|
|
78
|
if ($_GET['act'] == "del") {
|
79
|
if ($a_pppoes[$_GET['id']]) {
|
80
|
if ("{$g['varrun_path']}/pppoe" . $a_pppoes[$_GET['id']]['pppoeid'] . "-vpn.pid") {
|
81
|
killbypid("{$g['varrun_path']}/pppoe" . $a_pppoes[$_GET['id']]['pppoeid'] . "-vpn.pid");
|
82
|
}
|
83
|
if (is_dir("{$g['varetc_path']}/pppoe" . $a_pppoes[$_GET['id']]['pppoeid'])) {
|
84
|
mwexec("/bin/rm -r {$g['varetc_path']}/pppoe" . $a_pppoes[$_GET['id']]['pppoeid']);
|
85
|
}
|
86
|
unset($a_pppoes[$_GET['id']]);
|
87
|
write_config();
|
88
|
header("Location: vpn_pppoe.php");
|
89
|
exit;
|
90
|
}
|
91
|
}
|
92
|
|
93
|
$pgtitle = array(gettext("VPN"), gettext("PPPoE"));
|
94
|
$shortcut_section = "pppoes";
|
95
|
include("head.inc");
|
96
|
|
97
|
if ($savemsg)
|
98
|
print_info_box($savemsg, 'success');
|
99
|
|
100
|
if (is_subsystem_dirty('vpnpppoe'))
|
101
|
print_info_box_np(gettext('The PPPoE entry list has been changed') . '.<br />' . gettext('You must apply the changes in order for them to take effect.'));
|
102
|
?>
|
103
|
|
104
|
<div class="table-responsive">
|
105
|
<table class="table table-striped table-hover table-condensed">
|
106
|
<thead>
|
107
|
<tr>
|
108
|
<th><?=gettext("Interface")?></th>
|
109
|
<th><?=gettext("Local IP")?></th>
|
110
|
<th><?=gettext("Number of users")?></th>
|
111
|
<th><?=gettext("Description")?></th>
|
112
|
<th><!-- Action buttons --></th>
|
113
|
</tr>
|
114
|
</thead>
|
115
|
<tbody>
|
116
|
<?php
|
117
|
$i = 0;
|
118
|
foreach ($a_pppoes as $pppoe):
|
119
|
?>
|
120
|
<tr>
|
121
|
<td>
|
122
|
<?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($pppoe['interface']))?>
|
123
|
</td>
|
124
|
<td>
|
125
|
<?=htmlspecialchars($pppoe['localip'])?>
|
126
|
</td>
|
127
|
<td>
|
128
|
<?=htmlspecialchars($pppoe['n_pppoe_units'])?>
|
129
|
</td>
|
130
|
<td>
|
131
|
<?=htmlspecialchars($pppoe['descr'])?>
|
132
|
</td>
|
133
|
<td>
|
134
|
<a href="vpn_pppoe_edit.php?id=<?=$i?>" class="btn btn-xs btn-info"><?=gettext('Edit')?></a>
|
135
|
<a href="vpn_pppoe.php?act=del&id=<?=$i?>" class="btn btn-xs btn-danger"><?=gettext('Delete')?></a>
|
136
|
</td>
|
137
|
</tr>
|
138
|
<?php
|
139
|
$i++;
|
140
|
endforeach;
|
141
|
?>
|
142
|
</tbody>
|
143
|
</table>
|
144
|
</div>
|
145
|
|
146
|
<nav class="action-buttons">
|
147
|
<a href="vpn_pppoe_edit.php" class="btn btn-success"><?=gettext("Add")?></a>
|
148
|
</nav>
|
149
|
|
150
|
<?php
|
151
|
include("foot.inc");
|