1
|
<?php
|
2
|
/*
|
3
|
$Id$
|
4
|
|
5
|
diag_pkglogs.php
|
6
|
Copyright (C) 2005 Colin Smith
|
7
|
All rights reserved.
|
8
|
|
9
|
Redistribution and use in source and binary forms, with or without
|
10
|
modification, are permitted provided that the following conditions are met:
|
11
|
|
12
|
1. Redistributions of source code must retain the above copyright notice,
|
13
|
this list of conditions and the following disclaimer.
|
14
|
|
15
|
2. Redistributions in binary form must reproduce the above copyright
|
16
|
notice, this list of conditions and the following disclaimer in the
|
17
|
documentation and/or other materials provided with the distribution.
|
18
|
|
19
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
POSSIBILITY OF SUCH DAMAGE.
|
29
|
|
30
|
<logging>
|
31
|
<logtab>arpwatch</logtab>
|
32
|
<grepfor>arpwatch</logtab>
|
33
|
</logging>
|
34
|
|
35
|
<invertgrep/>
|
36
|
<logfile>/var/log/arpwatch.log</logfile>
|
37
|
|
38
|
*/
|
39
|
|
40
|
##|+PRIV
|
41
|
##|*IDENT=page-status-packagelogs
|
42
|
##|*NAME=Status: Package logs page
|
43
|
##|*DESCR=Allow access to the 'Status: Package logs' page.
|
44
|
##|*MATCH=diag_pkglogs.php*
|
45
|
##|-PRIV
|
46
|
|
47
|
|
48
|
require("guiconfig.inc");
|
49
|
//require_once("pkg-utils.inc");
|
50
|
|
51
|
if(!($nentries = $config['syslog']['nentries'])) $nentries = 50;
|
52
|
|
53
|
//if ($_POST['clear'])
|
54
|
// clear_log_file($logfile);
|
55
|
|
56
|
$i = 0;
|
57
|
$pkgwithlogging = false;
|
58
|
$apkg = $_POST['pkg'];
|
59
|
if(!$apkg) { // If we aren't looking for a specific package, locate the first package that handles logging.
|
60
|
if($config['installedpackages']['package'] <> "") {
|
61
|
foreach($config['installedpackages']['package'] as $package) {
|
62
|
if(is_array($package['logging'])) {
|
63
|
$pkgwithlogging = true;
|
64
|
$apkg = $package['name'];
|
65
|
$apkgid = $i;
|
66
|
break;
|
67
|
}
|
68
|
$i++;
|
69
|
}
|
70
|
}
|
71
|
} elseif($apkg) {
|
72
|
$pkgwithlogging = true;
|
73
|
$apkgid = get_pkg_id($apkg);
|
74
|
$i = $apkgid;
|
75
|
}
|
76
|
|
77
|
$pgtitle = array("Status","Package logs");
|
78
|
include("head.inc");
|
79
|
|
80
|
?>
|
81
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
82
|
<?php include("fbegin.inc"); ?>
|
83
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
84
|
<tr><td>
|
85
|
<ul id="tabnav">
|
86
|
<?php
|
87
|
if($pkgwithlogging == false) {
|
88
|
print_info_box("No packages with logging facilities are currently installed.");
|
89
|
echo '</ul></td></tr></table>';
|
90
|
include("fend.inc");
|
91
|
exit;
|
92
|
}
|
93
|
foreach($config['installedpackages']['package'] as $package) {
|
94
|
if(is_array($package['logging'])) {
|
95
|
if(!($logtab = $package['logging']['logtab'])) $logtab = $package['name'];
|
96
|
if($apkg == $package['name']) {
|
97
|
$curtab = $logtab;
|
98
|
echo '<li class="tabact">' . $logtab . '</li>';
|
99
|
} else {
|
100
|
Echo '<li class="tabinact"><a href="diag_pkglogs.php?pkg=' . htmlspecialchars($package['name']) . '">' . $logtab . '</a></li>';
|
101
|
}
|
102
|
}
|
103
|
}
|
104
|
?>
|
105
|
</ul>
|
106
|
</td></tr>
|
107
|
<tr>
|
108
|
<td class="tabcont">
|
109
|
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
110
|
<tr>
|
111
|
<td colspan="2" class="listtopic">
|
112
|
Last <?= $nentries ?> <?= $curtab ?> log entries</td>
|
113
|
</tr>
|
114
|
<?php
|
115
|
$package =& $config['installedpackages']['package'][$apkgid];
|
116
|
dump_clog($g['varlog_path'] . '/' . $package['logging']['logfilename'], $nentries);
|
117
|
?>
|
118
|
</table>
|
119
|
<br>
|
120
|
<!--
|
121
|
<form action="diag_pkglogs.php" method="post">
|
122
|
<input name="clear" type="submit" class="formbtn" value="Clear log">
|
123
|
</form>
|
124
|
-->
|
125
|
</td>
|
126
|
</tr>
|
127
|
</table>
|
128
|
<?php include("fend.inc"); ?>
|
129
|
</body>
|
130
|
</html>
|