1
|
#!/usr/local/bin/php
|
2
|
<?php
|
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
|
|
31
|
require("guiconfig.inc");
|
32
|
require("xmlparse_pkg.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 262144 {$system_logfile}");
|
40
|
}
|
41
|
|
42
|
?>
|
43
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
44
|
<html>
|
45
|
<head>
|
46
|
<title><?=gentitle("Diagnostics: Package logs");?></title>
|
47
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
48
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
49
|
</head>
|
50
|
|
51
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
52
|
<?php include("fbegin.inc"); ?>
|
53
|
<p class="pgtitle">Diagnostics: Package logs</p>
|
54
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
55
|
<tr><td>
|
56
|
<ul id="tabnav">
|
57
|
<?php
|
58
|
$i = 0;
|
59
|
$apkg = $_POST['pkg'];
|
60
|
if(!isset($_POST['pkg'])) $apkg = false;
|
61
|
foreach($config['installedpackages']['package'] as $package) {
|
62
|
$pkgname = $package['name'];
|
63
|
$pkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $package['configurationfile'], "packagegui");
|
64
|
if(is_array($pkg_config['logging'])) {
|
65
|
if($apkg == false) $apkg = $pkgname;
|
66
|
$logtab = $pkg_config['logging']['logtab'];
|
67
|
if(!isset($pkg_config['logging']['logtab'])) $logtab = $pkgname;
|
68
|
if($apkg == $pkgname) { ?>
|
69
|
<li class="tabact"><?= $pkg_config['name']; ?></li>
|
70
|
<?php
|
71
|
} else { ?>
|
72
|
<li class="tabinact"><a href="diag_pkglogs.php?pkg=<?= $pkgname; ?>"><?= $logtab; ?></a></li>
|
73
|
<?php
|
74
|
}
|
75
|
}
|
76
|
$i++;
|
77
|
}
|
78
|
?>
|
79
|
</ul>
|
80
|
</td></tr>
|
81
|
<tr>
|
82
|
<td class="tabcont">
|
83
|
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
84
|
<tr>
|
85
|
<td colspan="2" class="listtopic">
|
86
|
Last <?=$nentries;?> <?=$apkg;?> entries</td>
|
87
|
</tr>
|
88
|
<?php
|
89
|
$apkgid = get_pkg_id($apkg);
|
90
|
$apkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $config['installedpackages']['package'][$apkgid]['configurationfile'], "packagegui");
|
91
|
if(isset($apkg_config['logging']['logfile'])) {
|
92
|
$logfile = $apkg_config['logging']['logfile'];
|
93
|
} else {
|
94
|
$logfile = "{$g['varlog_path']}/system.log";
|
95
|
}
|
96
|
if(isset($apkg_config['logging']['grepfor']) and isset($apkg_config['logging']['invertgrep'])) {
|
97
|
dump_clog($logfile, $nentries, $apkg_config['logging']['grepfor'], true);
|
98
|
} elseif(isset($apkg_config['logging']['grepfor'])) {
|
99
|
dump_clog($logfile, $nentries, $apkg_config['logging']['grepfor']);
|
100
|
} else {
|
101
|
dump_clog($logfile, $nentries);
|
102
|
}
|
103
|
?>
|
104
|
</table>
|
105
|
<br><form action="diag_logs.php" method="post">
|
106
|
<input name="clear" type="submit" class="formbtn" value="Clear log">
|
107
|
</form>
|
108
|
</td>
|
109
|
</tr>
|
110
|
</table>
|
111
|
<?php include("fend.inc"); ?>
|
112
|
</body>
|
113
|
</html>
|