Project

General

Profile

Download (4.02 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/usr/local/bin/php
2 4d875b4f Scott Ullrich
<?php
3 5b237745 Scott Ullrich
/*
4
	diag_logs_vpn.php
5 4d875b4f Scott Ullrich
	Copyright (C) 2004 Scott Ullrich
6
	All rights reserved.
7
8
	originially part of m0n0wall (http://m0n0.ch/wall)
9 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11 4d875b4f Scott Ullrich
12 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14 4d875b4f Scott Ullrich
15 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17 4d875b4f Scott Ullrich
18 5b237745 Scott Ullrich
	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 4d875b4f Scott Ullrich
22 5b237745 Scott Ullrich
	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 4d875b4f Scott Ullrich
51 5b237745 Scott Ullrich
	foreach ($logarr as $logent) {
52
		$logent = preg_split("/\s+/", $logent, 6);
53
		$llent = explode(",", $logent[5]);
54 4d875b4f Scott Ullrich
55 5b237745 Scott Ullrich
		echo "<tr>\n";
56
		echo "<td class=\"listlr\" nowrap>" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n";
57 4d875b4f Scott Ullrich
58 5b237745 Scott Ullrich
		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 4d875b4f Scott Ullrich
63 5b237745 Scott Ullrich
		echo "<td class=\"listr\">" . htmlspecialchars($llent[3]) . "</td>\n";
64
		echo "<td class=\"listr\">" . htmlspecialchars($llent[2]) . "&nbsp;</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 9a4bda51 Scott Ullrich
    <li class="tabinact"><a href="diag_logs_ipsec.php">IPSEC Vpn</a></li>
86 5b237745 Scott Ullrich
    <li class="tabinact"><a href="diag_logs_filter.php">Firewall</a></li>
87
    <li class="tabinact"><a href="diag_logs_dhcp.php">DHCP</a></li>
88 3f2b92d2 Scott Ullrich
    <li class="tabinact"><a href="diag_logs_auth.php">Portal Auth</a></li>
89 5b237745 Scott Ullrich
    <li class="tabact">PPTP VPN</li>
90
    <li class="tabinact"><a href="diag_logs_settings.php">Settings</a></li>
91
  </ul>
92
  </td></tr>
93
  <tr>
94
    <td class="tabcont">
95
		<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>
96 4d875b4f Scott Ullrich
		  <td colspan="4" class="listtopic">
97 5b237745 Scott Ullrich
			    Last <?=$nentries;?> firewall log entries</td>
98
			</tr>
99
			<tr>
100
			  <td class="listhdrr">Time</td>
101
			  <td class="listhdrr">Action</td>
102
			  <td class="listhdrr">User</td>
103
			  <td class="listhdrr">IP address</td>
104
			</tr>
105
			<?php dump_clog("/var/log/vpn.log", $nentries); ?>
106
          </table>
107
		<br><form action="diag_logs_vpn.php" method="post">
108
<input name="clear" type="submit" class="formbtn" value="Clear log">
109
</form>
110
	</td>
111
  </tr>
112
</table>
113
<?php include("fend.inc"); ?>
114
</body>
115
</html>