Project

General

Profile

Download (6.58 KB) Statistics
| Branch: | Tag: | Revision:
1 5d98aeb1 Scott Ullrich
#!/usr/local/bin/php
2 18330d38 Scott Ullrich
<?php
3 5b237745 Scott Ullrich
/*
4
	diag_logs_vpn.php
5 5d98aeb1 Scott Ullrich
	part of m0n0wall (http://m0n0.ch/wall)
6 18330d38 Scott Ullrich
7 5d98aeb1 Scott Ullrich
	Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
8 5b237745 Scott Ullrich
	All rights reserved.
9 18330d38 Scott Ullrich
10 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12 18330d38 Scott Ullrich
13 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15 18330d38 Scott Ullrich
16 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19 18330d38 Scott Ullrich
20 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
32 13d193c2 Scott Ullrich
/*	
33
	pfSense_BUILDER_BINARIES:	/usr/sbin/fifolog_reader	/usr/sbin/clog
34
	pfSense_MODULE:	vpn
35
*/
36
37 6b07c15a Matthew Grooms
##|+PRIV
38
##|*IDENT=page-diagnostics-logs-pptpvpn
39 328efaba Ermal
##|*NAME=Diagnostics: Logs: VPN page
40
##|*DESCR=Allow access to the 'Diagnostics: Logs: VPN' page.
41 6b07c15a Matthew Grooms
##|*MATCH=diag_logs_vpn.php*
42
##|-PRIV
43
44 77f43ea4 Renato Botelho
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("VPN"));
45 5b237745 Scott Ullrich
require("guiconfig.inc");
46 483e6de8 Scott Ullrich
require_once("vpn.inc");
47 5b237745 Scott Ullrich
48
$nentries = $config['syslog']['nentries'];
49
if (!$nentries)
50
	$nentries = 50;
51
52 43a68abc jim-p
if (htmlspecialchars($_POST['vpntype']))
53
	$vpntype = htmlspecialchars($_POST['vpntype']);
54
elseif (htmlspecialchars($_GET['vpntype']))
55
	$vpntype = htmlspecialchars($_GET['vpntype']);
56
else
57
	$vpntype = "pptp";
58
59
if (htmlspecialchars($_POST['mode']))
60
	$mode = htmlspecialchars($_POST['mode']);
61
elseif (htmlspecialchars($_GET['mode']))
62
	$mode = htmlspecialchars($_GET['mode']);
63
else
64
	$mode = "login";
65
66
switch ($vpntype) {
67
	case 'pptp':
68
		$logname = "pptps";
69
		break;
70
	case 'poes':
71
		$logname = "poes";
72
		break;
73
	case 'l2tp':
74
		$logname = "l2tps";
75
		break;
76
}
77 328efaba Ermal
78 43a68abc jim-p
if ($_POST['clear']) {
79
	if ($mode != "raw")
80
		clear_log_file("/var/log/vpn.log");
81
	else
82
		clear_log_file("/var/log/{$logname}.log");
83
}
84 5d98aeb1 Scott Ullrich
85
function dump_clog_vpn($logfile, $tail) {
86 14905d9f jim-p
	global $g, $config, $vpntype;
87 5d98aeb1 Scott Ullrich
88
	$sor = isset($config['syslog']['reverse']) ? "-r" : "";
89
90 ba8ee067 Scott Ullrich
	$logarr = "";
91 568f30c2 Scott Ullrich
	
92
	if(isset($config['system']['usefifolog'])) 
93
		exec("/usr/sbin/fifolog_reader " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
94
	else 
95 b2b61308 jim-p
		exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
96 18330d38 Scott Ullrich
97 5d98aeb1 Scott Ullrich
	foreach ($logarr as $logent) {
98
		$logent = preg_split("/\s+/", $logent, 6);
99
		$llent = explode(",", $logent[5]);
100 874e5f2c jim-p
		$iftype = substr($llent[1], 0, 4);
101
		if ($iftype != $vpntype)
102 14905d9f jim-p
			continue;
103 5d98aeb1 Scott Ullrich
		echo "<tr>\n";
104
		echo "<td class=\"listlr\" nowrap>" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n";
105 18330d38 Scott Ullrich
106 874e5f2c jim-p
		if ($llent[0] == "login")
107 88d26bcb Scott Ullrich
			echo "<td class=\"listr\"><img src=\"/themes/{$g['theme']}/images/icons/icon_in.gif\" width=\"11\" height=\"11\" title=\"login\"></td>\n";
108 5d98aeb1 Scott Ullrich
		else
109 88d26bcb Scott Ullrich
			echo "<td class=\"listr\"><img src=\"/themes/{$g['theme']}/images/icons/icon_out.gif\" width=\"11\" height=\"11\" title=\"logout\"></td>\n";
110 18330d38 Scott Ullrich
111 874e5f2c jim-p
		echo "<td class=\"listr\">" . htmlspecialchars($llent[3]) . "</td>\n";
112
		echo "<td class=\"listr\">" . htmlspecialchars($llent[2]) . "&nbsp;</td>\n";
113 5d98aeb1 Scott Ullrich
		echo "</tr>\n";
114
	}
115 5b237745 Scott Ullrich
}
116
117 b63695db Scott Ullrich
include("head.inc");
118
119 5b237745 Scott Ullrich
?>
120
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
121
<?php include("fbegin.inc"); ?>
122
<table width="100%" border="0" cellpadding="0" cellspacing="0">
123 5d98aeb1 Scott Ullrich
  <tr><td class="tabnavtbl">
124 b63695db Scott Ullrich
<?php
125
	$tab_array = array();
126 77f43ea4 Renato Botelho
	$tab_array[] = array(gettext("System"), false, "diag_logs.php");
127
	$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php");
128
	$tab_array[] = array(gettext("DHCP"), false, "diag_logs_dhcp.php");
129
	$tab_array[] = array(gettext("Portal Auth"), false, "diag_logs_auth.php");
130
	$tab_array[] = array(gettext("IPsec"), false, "diag_logs_ipsec.php");
131
	$tab_array[] = array(gettext("PPP"), false, "diag_logs_ppp.php");
132
	$tab_array[] = array(gettext("VPN"), true, "diag_logs_vpn.php");
133
	$tab_array[] = array(gettext("Load Balancer"), false, "diag_logs_relayd.php");
134
	$tab_array[] = array(gettext("OpenVPN"), false, "diag_logs_openvpn.php");
135 ae2c143a jim-p
	$tab_array[] = array(gettext("NTP"), false, "diag_logs_ntpd.php");
136 77f43ea4 Renato Botelho
	$tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php");
137 b63695db Scott Ullrich
	display_top_tabs($tab_array);
138 b2b61308 jim-p
?>
139
  </td></tr>
140
  <tr><td class="tabnavtbl">
141
<?php
142
	$tab_array = array();
143
	$tab_array[] = array(gettext("PPTP Logins"),
144
				(($vpntype == "pptp") && ($mode != "raw")),
145
				"/diag_logs_vpn.php?vpntype=pptp");
146
	$tab_array[] = array(gettext("PPTP Raw"),
147
				(($vpntype == "pptp") && ($mode == "raw")),
148
				"/diag_logs_vpn.php?vpntype=pptp&mode=raw");
149
	$tab_array[] = array(gettext("PPPoE Logins"),
150
				(($vpntype == "poes") && ($mode != "raw")),
151
				"/diag_logs_vpn.php?vpntype=poes");
152
	$tab_array[] = array(gettext("PPPoE Raw"),
153
				(($vpntype == "poes") && ($mode == "raw")),
154
				"/diag_logs_vpn.php?vpntype=poes&mode=raw");
155
	$tab_array[] = array(gettext("L2TP Logins"),
156
				(($vpntype == "l2tp") && ($mode != "raw")),
157
				"/diag_logs_vpn.php?vpntype=l2tp");
158
	$tab_array[] = array(gettext("L2TP Raw"),
159
				(($vpntype == "l2tp") && ($mode == "raw")),
160
				"/diag_logs_vpn.php?vpntype=l2tp&mode=raw");
161
	display_top_tabs($tab_array);
162 b63695db Scott Ullrich
?>
163 5b237745 Scott Ullrich
  </td></tr>
164
  <tr>
165 5d98aeb1 Scott Ullrich
    <td class="tabcont">
166 b2b61308 jim-p
	<form action="diag_logs_vpn.php" method="post">
167
	<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>
168
		<tr>
169
		<td colspan="4" class="listtopic">
170
			<?php printf(gettext('Last %1$s %2$s VPN log entries'),$nentries,$vpns[$vpntype]);?></td>
171
		</tr>
172
		<?php if ($mode != "raw"): ?>
173
		<tr>
174
			<td class="listhdrr"><?=gettext("Time");?></td>
175
			<td class="listhdrr"><?=gettext("Action");?></td>
176
			<td class="listhdrr"><?=gettext("User");?></td>
177
			<td class="listhdrr"><?=gettext("IP address");?></td>
178
		</tr>
179 14905d9f jim-p
			<?php dump_clog_vpn("/var/log/vpn.log", $nentries); ?>
180 a6607b5f jim-p
		<?php else: 
181
			dump_clog("/var/log/{$logname}.log", $nentries);
182
		      endif; ?>
183 b2b61308 jim-p
	</table>
184
	<br />
185
	<input type="hidden" name="vpntype" id="vpntype" value="<?=$vpntype;?>">
186 43a68abc jim-p
	<input type="hidden" name="mode" id="mode" value="<?=$mode;?>">
187 b2b61308 jim-p
	<input name="clear" type="submit" class="formbtn" value="<?=gettext("Clear log"); ?>">
188
	</form>
189 5b237745 Scott Ullrich
	</td>
190
  </tr>
191
</table>
192
<?php include("fend.inc"); ?>