1
|
#!/usr/local/bin/php
|
2
|
<?php
|
3
|
/*
|
4
|
diag_logs_vpn.php
|
5
|
Copyright (C) 2004 Scott Ullrich
|
6
|
All rights reserved.
|
7
|
|
8
|
originially part of m0n0wall (http://m0n0.ch/wall)
|
9
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
10
|
All rights reserved.
|
11
|
|
12
|
Redistribution and use in source and binary forms, with or without
|
13
|
modification, are permitted provided that the following conditions are met:
|
14
|
|
15
|
1. Redistributions of source code must retain the above copyright notice,
|
16
|
this list of conditions and the following disclaimer.
|
17
|
|
18
|
2. Redistributions in binary form must reproduce the above copyright
|
19
|
notice, this list of conditions and the following disclaimer in the
|
20
|
documentation and/or other materials provided with the distribution.
|
21
|
|
22
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
23
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
24
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
25
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
26
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31
|
POSSIBILITY OF SUCH DAMAGE.
|
32
|
*/
|
33
|
|
34
|
require("guiconfig.inc");
|
35
|
|
36
|
$nentries = $config['syslog']['nentries'];
|
37
|
if (!$nentries)
|
38
|
$nentries = 50;
|
39
|
|
40
|
if ($_POST['clear']) {
|
41
|
exec("/usr/sbin/clog -i -s 65536 /var/log/vpn.log");
|
42
|
}
|
43
|
|
44
|
function dump_clog($logfile, $tail) {
|
45
|
global $g, $config;
|
46
|
|
47
|
$sor = isset($config['syslog']['reverse']) ? "-r" : "";
|
48
|
|
49
|
exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
|
50
|
|
51
|
foreach ($logarr as $logent) {
|
52
|
$logent = preg_split("/\s+/", $logent, 6);
|
53
|
$llent = explode(",", $logent[5]);
|
54
|
|
55
|
echo "<tr>\n";
|
56
|
echo "<td class=\"listlr\" nowrap>" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n";
|
57
|
|
58
|
if ($llent[0] == "login")
|
59
|
echo "<td class=\"listr\"><img src=\"in.gif\" width=\"11\" height=\"11\" title=\"login\"></td>\n";
|
60
|
else
|
61
|
echo "<td class=\"listr\"><img src=\"out.gif\" width=\"11\" height=\"11\" title=\"logout\"></td>\n";
|
62
|
|
63
|
echo "<td class=\"listr\">" . htmlspecialchars($llent[3]) . "</td>\n";
|
64
|
echo "<td class=\"listr\">" . htmlspecialchars($llent[2]) . " </td>\n";
|
65
|
echo "</tr>\n";
|
66
|
}
|
67
|
}
|
68
|
|
69
|
?>
|
70
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
71
|
<html>
|
72
|
<head>
|
73
|
<title><?=gentitle("Diagnostics: System logs");?></title>
|
74
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
75
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
76
|
</head>
|
77
|
|
78
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
79
|
<?php include("fbegin.inc"); ?>
|
80
|
<p class="pgtitle">Diagnostics: System logs</p>
|
81
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
82
|
<tr><td>
|
83
|
<ul id="tabnav">
|
84
|
<li class="tabinact"><a href="diag_logs.php">System</a></li>
|
85
|
<li class="tabinact"><a href="diag_logs_filter.php">Firewall</a></li>
|
86
|
<li class="tabinact"><a href="diag_logs_dhcp.php">DHCP</a></li>
|
87
|
<li class="tabinact"><a href="diag_logs_auth.php">Portal Auth</a></li>
|
88
|
<li class="tabact">PPTP VPN</li>
|
89
|
<li class="tabinact"><a href="diag_logs_settings.php">Settings</a></li>
|
90
|
</ul>
|
91
|
</td></tr>
|
92
|
<tr>
|
93
|
<td class="tabcont">
|
94
|
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>
|
95
|
<td colspan="4" class="listtopic">
|
96
|
Last <?=$nentries;?> firewall log entries</td>
|
97
|
</tr>
|
98
|
<tr>
|
99
|
<td class="listhdrr">Time</td>
|
100
|
<td class="listhdrr">Action</td>
|
101
|
<td class="listhdrr">User</td>
|
102
|
<td class="listhdrr">IP address</td>
|
103
|
</tr>
|
104
|
<?php dump_clog("/var/log/vpn.log", $nentries); ?>
|
105
|
</table>
|
106
|
<br><form action="diag_logs_vpn.php" method="post">
|
107
|
<input name="clear" type="submit" class="formbtn" value="Clear log">
|
108
|
</form>
|
109
|
</td>
|
110
|
</tr>
|
111
|
</table>
|
112
|
<?php include("fend.inc"); ?>
|
113
|
</body>
|
114
|
</html>
|