Project

General

Profile

Download (6.27 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 daab67a1 Scott Ullrich
$vpntype = (htmlspecialchars($_GET['vpntype'])) ? htmlspecialchars($_GET['vpntype']) : "pptp";
53
$mode = (htmlspecialchars($_GET['mode'])) ? htmlspecialchars($_GET['mode']) : "login";
54 328efaba Ermal
55 d6abaa18 Scott Ullrich
if ($_POST['clear']) 
56 14905d9f jim-p
	clear_log_file("/var/log/vpn.log");
57 5d98aeb1 Scott Ullrich
58
function dump_clog_vpn($logfile, $tail) {
59 14905d9f jim-p
	global $g, $config, $vpntype;
60 5d98aeb1 Scott Ullrich
61
	$sor = isset($config['syslog']['reverse']) ? "-r" : "";
62
63 ba8ee067 Scott Ullrich
	$logarr = "";
64 568f30c2 Scott Ullrich
	
65
	if(isset($config['system']['usefifolog'])) 
66
		exec("/usr/sbin/fifolog_reader " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
67
	else 
68 b2b61308 jim-p
		exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
69 18330d38 Scott Ullrich
70 5d98aeb1 Scott Ullrich
	foreach ($logarr as $logent) {
71
		$logent = preg_split("/\s+/", $logent, 6);
72
		$llent = explode(",", $logent[5]);
73 874e5f2c jim-p
		$iftype = substr($llent[1], 0, 4);
74
		if ($iftype != $vpntype)
75 14905d9f jim-p
			continue;
76 5d98aeb1 Scott Ullrich
		echo "<tr>\n";
77
		echo "<td class=\"listlr\" nowrap>" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n";
78 18330d38 Scott Ullrich
79 874e5f2c jim-p
		if ($llent[0] == "login")
80 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";
81 5d98aeb1 Scott Ullrich
		else
82 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";
83 18330d38 Scott Ullrich
84 874e5f2c jim-p
		echo "<td class=\"listr\">" . htmlspecialchars($llent[3]) . "</td>\n";
85
		echo "<td class=\"listr\">" . htmlspecialchars($llent[2]) . "&nbsp;</td>\n";
86 5d98aeb1 Scott Ullrich
		echo "</tr>\n";
87
	}
88 5b237745 Scott Ullrich
}
89
90 b63695db Scott Ullrich
include("head.inc");
91
92 5b237745 Scott Ullrich
?>
93
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
94
<?php include("fbegin.inc"); ?>
95
<table width="100%" border="0" cellpadding="0" cellspacing="0">
96 5d98aeb1 Scott Ullrich
  <tr><td class="tabnavtbl">
97 b63695db Scott Ullrich
<?php
98
	$tab_array = array();
99 77f43ea4 Renato Botelho
	$tab_array[] = array(gettext("System"), false, "diag_logs.php");
100
	$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php");
101
	$tab_array[] = array(gettext("DHCP"), false, "diag_logs_dhcp.php");
102
	$tab_array[] = array(gettext("Portal Auth"), false, "diag_logs_auth.php");
103
	$tab_array[] = array(gettext("IPsec"), false, "diag_logs_ipsec.php");
104
	$tab_array[] = array(gettext("PPP"), false, "diag_logs_ppp.php");
105
	$tab_array[] = array(gettext("VPN"), true, "diag_logs_vpn.php");
106
	$tab_array[] = array(gettext("Load Balancer"), false, "diag_logs_relayd.php");
107
	$tab_array[] = array(gettext("OpenVPN"), false, "diag_logs_openvpn.php");
108
	$tab_array[] = array(gettext("OpenNTPD"), false, "diag_logs_ntpd.php");
109
	$tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php");
110 b63695db Scott Ullrich
	display_top_tabs($tab_array);
111 b2b61308 jim-p
?>
112
  </td></tr>
113
  <tr><td class="tabnavtbl">
114
<?php
115
	$tab_array = array();
116
	$tab_array[] = array(gettext("PPTP Logins"),
117
				(($vpntype == "pptp") && ($mode != "raw")),
118
				"/diag_logs_vpn.php?vpntype=pptp");
119
	$tab_array[] = array(gettext("PPTP Raw"),
120
				(($vpntype == "pptp") && ($mode == "raw")),
121
				"/diag_logs_vpn.php?vpntype=pptp&mode=raw");
122
	$tab_array[] = array(gettext("PPPoE Logins"),
123
				(($vpntype == "poes") && ($mode != "raw")),
124
				"/diag_logs_vpn.php?vpntype=poes");
125
	$tab_array[] = array(gettext("PPPoE Raw"),
126
				(($vpntype == "poes") && ($mode == "raw")),
127
				"/diag_logs_vpn.php?vpntype=poes&mode=raw");
128
	$tab_array[] = array(gettext("L2TP Logins"),
129
				(($vpntype == "l2tp") && ($mode != "raw")),
130
				"/diag_logs_vpn.php?vpntype=l2tp");
131
	$tab_array[] = array(gettext("L2TP Raw"),
132
				(($vpntype == "l2tp") && ($mode == "raw")),
133
				"/diag_logs_vpn.php?vpntype=l2tp&mode=raw");
134
	display_top_tabs($tab_array);
135 b63695db Scott Ullrich
?>
136 5b237745 Scott Ullrich
  </td></tr>
137
  <tr>
138 5d98aeb1 Scott Ullrich
    <td class="tabcont">
139 b2b61308 jim-p
	<form action="diag_logs_vpn.php" method="post">
140
	<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>
141
		<tr>
142
		<td colspan="4" class="listtopic">
143
			<?php printf(gettext('Last %1$s %2$s VPN log entries'),$nentries,$vpns[$vpntype]);?></td>
144
		</tr>
145
		<?php if ($mode != "raw"): ?>
146
		<tr>
147
			<td class="listhdrr"><?=gettext("Time");?></td>
148
			<td class="listhdrr"><?=gettext("Action");?></td>
149
			<td class="listhdrr"><?=gettext("User");?></td>
150
			<td class="listhdrr"><?=gettext("IP address");?></td>
151
		</tr>
152 14905d9f jim-p
			<?php dump_clog_vpn("/var/log/vpn.log", $nentries); ?>
153 a6607b5f jim-p
		<?php else: 
154
			switch ($vpntype) {
155
				case 'pptp':
156
					$logname = "pptps";
157
					break;
158
				case 'poes':
159
					$logname = "poes";
160
					break;
161
				case 'l2tp':
162
					$logname = "l2tps";
163
					break;
164
			}
165
			dump_clog("/var/log/{$logname}.log", $nentries);
166
		      endif; ?>
167 b2b61308 jim-p
	</table>
168
	<br />
169
	<input type="hidden" name="vpntype" id="vpntype" value="<?=$vpntype;?>">
170
	<input name="clear" type="submit" class="formbtn" value="<?=gettext("Clear log"); ?>">
171
	</form>
172 5b237745 Scott Ullrich
	</td>
173
  </tr>
174
</table>
175
<?php include("fend.inc"); ?>