Project

General

Profile

Download (4.37 KB) Statistics
| Branch: | Tag: | Revision:
1 3818935a Scott Ullrich
<?php
2
/*
3 ce77a9c4 Phil Davis
	vpn_pppoe.php
4 d98a2e6a Jose Luis Duran
	Copyright (C) 2010 Ermal Luçi
5 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
6 3818935a Scott Ullrich
	All rights reserved.
7 0e642c78 Ermal
8 3818935a Scott Ullrich
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10 0e642c78 Ermal
11 3818935a Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13 0e642c78 Ermal
14 3818935a Scott Ullrich
	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 0e642c78 Ermal
18 3818935a Scott Ullrich
	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 0e642c78 Ermal
/*
30 4c8c4fc2 sbeaver
	pfSense_MODULE: pppoe
31 0e642c78 Ermal
*/
32 3818935a Scott Ullrich
33 6b07c15a Matthew Grooms
##|+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 0e642c78 Ermal
require_once("guiconfig.inc");
41
require_once("filter.inc");
42 483e6de8 Scott Ullrich
require_once("vpn.inc");
43 3818935a Scott Ullrich
44 b7856e58 Phil Davis
if (!is_array($config['pppoes']['pppoe'])) {
45 0e642c78 Ermal
	$config['pppoes']['pppoe'] = array();
46 b7856e58 Phil Davis
}
47 c8c416db Scott Ullrich
48 0e642c78 Ermal
$a_pppoes = &$config['pppoes']['pppoe'];
49 3818935a Scott Ullrich
50
if ($_POST) {
51 4c8c4fc2 sbeaver
	$pconfig = $_POST;
52 0e642c78 Ermal
53 4c8c4fc2 sbeaver
	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 b7856e58 Phil Davis
				if (!is_numeric($pppoeid)) {
58 0e642c78 Ermal
					continue;
59 b7856e58 Phil Davis
				}
60 0e642c78 Ermal
				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 4c8c4fc2 sbeaver
			}
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 0e642c78 Ermal
}
77 3818935a Scott Ullrich
78 0e642c78 Ermal
if ($_GET['act'] == "del") {
79
	if ($a_pppoes[$_GET['id']]) {
80 b7856e58 Phil Davis
		if ("{$g['varrun_path']}/pppoe" . $a_pppoes[$_GET['id']]['pppoeid'] . "-vpn.pid") {
81 0e642c78 Ermal
			killbypid("{$g['varrun_path']}/pppoe" . $a_pppoes[$_GET['id']]['pppoeid'] . "-vpn.pid");
82 b7856e58 Phil Davis
		}
83
		if (is_dir("{$g['varetc_path']}/pppoe" . $a_pppoes[$_GET['id']]['pppoeid'])) {
84 61223023 Ermal
			mwexec("/bin/rm -r {$g['varetc_path']}/pppoe" . $a_pppoes[$_GET['id']]['pppoeid']);
85 b7856e58 Phil Davis
		}
86 0e642c78 Ermal
		unset($a_pppoes[$_GET['id']]);
87 3818935a Scott Ullrich
		write_config();
88 0e642c78 Ermal
		header("Location: vpn_pppoe.php");
89
		exit;
90 3818935a Scott Ullrich
	}
91
}
92
93 6c07db48 Phil Davis
$pgtitle = array(gettext("VPN"), gettext("PPPoE"));
94 b32dd0a6 jim-p
$shortcut_section = "pppoes";
95 3818935a Scott Ullrich
include("head.inc");
96
97 4c8c4fc2 sbeaver
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 3818935a Scott Ullrich
?>
103
104 66bbb1b5 Sjon Hortensius
<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 4c8c4fc2 sbeaver
<?php
117
$i = 0;
118
foreach ($a_pppoes as $pppoe):
119
?>
120 66bbb1b5 Sjon Hortensius
			<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&amp;id=<?=$i?>" class="btn btn-xs btn-danger"><?=gettext('Delete')?></a>
136
				</td>
137
			</tr>
138 4c8c4fc2 sbeaver
<?php
139
	$i++;
140
endforeach;
141
?>
142 66bbb1b5 Sjon Hortensius
		</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 4c8c4fc2 sbeaver
<?php
151
include("foot.inc");