1
|
#!/usr/local/bin/php
|
2
|
<?php
|
3
|
/*
|
4
|
diag_logs_dhcp.php
|
5
|
part of m0n0wall (http://m0n0.ch/wall)
|
6
|
|
7
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
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
|
|
20
|
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
|
require("guiconfig.inc");
|
33
|
|
34
|
$nentries = $config['syslog']['nentries'];
|
35
|
if (!$nentries)
|
36
|
$nentries = 50;
|
37
|
|
38
|
if ($_POST['clear']) {
|
39
|
exec("/usr/sbin/clog -i -s 32768 /var/log/dhcpd.log");
|
40
|
}
|
41
|
|
42
|
function dump_clog($logfile, $tail, $withorig = true) {
|
43
|
global $g, $config;
|
44
|
|
45
|
$sor = isset($config['syslog']['reverse']) ? "-r" : "";
|
46
|
|
47
|
exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
|
48
|
|
49
|
foreach ($logarr as $logent) {
|
50
|
$logent = preg_split("/\s+/", $logent, 6);
|
51
|
echo "<tr valign=\"top\">\n";
|
52
|
|
53
|
if ($withorig) {
|
54
|
echo "<td class=\"listlr\" nowrap>" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n";
|
55
|
echo "<td class=\"listr\">" . htmlspecialchars($logent[4] . " " . $logent[5]) . "</td>\n";
|
56
|
} else {
|
57
|
echo "<td class=\"listlr\" colspan=\"2\">" . htmlspecialchars($logent[5]) . "</td>\n";
|
58
|
}
|
59
|
echo "</tr>\n";
|
60
|
}
|
61
|
}
|
62
|
|
63
|
?>
|
64
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
65
|
<html>
|
66
|
<head>
|
67
|
<title><?=gentitle("Diagnostics: System logs");?></title>
|
68
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
69
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
70
|
</head>
|
71
|
|
72
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
73
|
<?php include("fbegin.inc"); ?>
|
74
|
<p class="pgtitle">Diagnostics: System logs</p>
|
75
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
76
|
<tr><td>
|
77
|
<ul id="tabnav">
|
78
|
<li class="tabinact"><a href="diag_logs.php">System</a></li>
|
79
|
<li class="tabinact"><a href="diag_logs_filter.php">Firewall</a></li>
|
80
|
<li class="tabact">DHCP</li>
|
81
|
<li class="tabinact"><a href="diag_logs_vpn.php">PPTP VPN</a></li>
|
82
|
<li class="tabinact"><a href="diag_logs_settings.php">Settings</a></li>
|
83
|
</ul>
|
84
|
</td></tr>
|
85
|
<tr>
|
86
|
<td class="tabcont">
|
87
|
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
88
|
<tr>
|
89
|
<td colspan="2" class="listtopic">
|
90
|
Last <?=$nentries;?> DHCP service log entries</td>
|
91
|
</tr>
|
92
|
<?php dump_clog("/var/log/dhcpd.log", $nentries); ?>
|
93
|
</table>
|
94
|
<br><form action="diag_logs_dhcp.php" method="post">
|
95
|
<input name="clear" type="submit" class="formbtn" value="Clear log">
|
96
|
</form>
|
97
|
</td>
|
98
|
</tr>
|
99
|
</table>
|
100
|
<?php include("fend.inc"); ?>
|
101
|
</body>
|
102
|
</html>
|
103
|
|