Revision df01982a
Added by Colin Smith over 20 years ago
usr/local/www/diag_pkglogs.php | ||
---|---|---|
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']) and isset($pkg_config['logging']['logtab'])) { |
|
65 |
if($apkg == false) $apkg = $pkgname; |
|
66 |
if($apkg == $pkgname) { ?> |
|
67 |
<li class="tabact"><?= $pkg_config['name']; ?></li> |
|
68 |
<?php |
|
69 |
} else { ?> |
|
70 |
<li class="tabinact"><a href="diag_pkglogs.php?pkg=<?= $pkgname; ?>"><?= $pkg_config['logging']['logtab']; ?></a></li> |
|
71 |
<?php |
|
72 |
} |
|
73 |
} |
|
74 |
$i++; |
|
75 |
} |
|
76 |
?> |
|
77 |
</ul> |
|
78 |
</td></tr> |
|
79 |
<tr> |
|
80 |
<td class="tabcont"> |
|
81 |
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
|
82 |
<tr> |
|
83 |
<td colspan="2" class="listtopic"> |
|
84 |
Last <?=$nentries;?> <?=$apkg;?> entries</td> |
|
85 |
</tr> |
|
86 |
<?php |
|
87 |
$apkgid = get_pkg_id($apkg); |
|
88 |
$apkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $config['installedpackages']['package'][$apkgid]['configurationfile'], "packagegui"); |
|
89 |
if(isset($apkg_config['logging']['logfile'])) { |
|
90 |
$logfile = $apkg_config['logging']['logfile']; |
|
91 |
} else { |
|
92 |
$logfile = "{$g['varlog_path']}/system.log"; |
|
93 |
} |
|
94 |
if(isset($apkg_config['logging']['grepfor']) and isset($apkg_config['logging']['invertgrep'])) { |
|
95 |
dump_clog($logfile, $nentries, $apkg_config['logging']['grepfor'], true); |
|
96 |
} elseif(isset($apkg_config['logging']['grepfor'])) { |
|
97 |
dump_clog($logfile, $nentries, $apkg_config['logging']['grepfor']); |
|
98 |
} else { |
|
99 |
dump_clog($logfile, $nentries); |
|
100 |
} |
|
101 |
?> |
|
102 |
</table> |
|
103 |
<br><form action="diag_logs.php" method="post"> |
|
104 |
<input name="clear" type="submit" class="formbtn" value="Clear log"> |
|
105 |
</form> |
|
106 |
</td> |
|
107 |
</tr> |
|
108 |
</table> |
|
109 |
<?php include("fend.inc"); ?> |
|
110 |
</body> |
|
111 |
</html> |
Also available in: Unified diff
Add dynamic package logging. I'm new to PHP integration with actual HTML, so that in particular could likely be optimized.