Project

General

Profile

Download (4.99 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
	$Id$
5

    
6
	diag_pkglogs.php
7
	Copyright (C) 2005 Colin Smith
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
	<logging>
32
		<logtab>arpwatch</logtab>
33
		<grepfor>arpwatch</logtab>
34
	</logging>
35

    
36
		<invertgrep/>
37
		<logfile>/var/log/arpwatch.log</logfile>
38

    
39
*/
40

    
41
require("guiconfig.inc");
42
require("xmlparse_pkg.inc");
43

    
44
$nentries = $config['syslog']['nentries'];
45
if (!$nentries)
46
	$nentries = 50;
47

    
48
if ($_POST['clear']) {
49
	exec("/usr/sbin/clog -i -s 262144 {$system_logfile}");
50
}
51

    
52
$i = 0;
53
$pkgwithlogging = false;
54
$apkg = $_POST['pkg'];
55
if(!isset($_POST['pkg'])) { // If we aren't looking for a specific package, locate the first package that handles logging.
56
	if($config['installedpackages']['package'] <> "") {
57
		foreach($config['installedpackages']['package'] as $package) {
58
			$pkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $package['configurationfile'], "packagegui");
59
			if(is_array($pkg_config['logging'])) {
60
				$pkgwithlogging = true;
61
				$apkg = $package['name'];
62
				$apkgid = $i;
63
				break;
64
			}
65
			$i++;
66
		}
67
	}
68
} else {
69
	$pkgwithlogging = true;
70
	$apkgid = get_pkg_id($apkg);
71
	$i = $apkgid;
72
}
73
?>
74
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
75
<html>
76
<head>
77
<title><?=gentitle("Diagnostics: Package logs");?></title>
78
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
79
<link href="gui.css" rel="stylesheet" type="text/css">
80
</head>
81

    
82
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
83
<?php include("fbegin.inc"); ?>
84
<p class="pgtitle">Diagnostics: Package logs</p>
85
<table width="100%" border="0" cellpadding="0" cellspacing="0">
86
  <tr><td>
87
  <ul id="tabnav">
88
    <?php
89
	if($config['installedpackages']['package'] == "" or $pkgwithlogging == false) {
90
		print_info_box("No packages with logging facilities are currently installed.");
91
	?>
92
		</ul></td></tr></table>
93
	<?php
94
		include("fend.inc");
95
		exit;
96
	}
97
	if($config['installedpackages']['package'] <> "") {
98
		foreach($config['installedpackages']['package'] as $package) {
99
        		$pkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $package['configurationfile'], "packagegui");
100
			if(is_array($pkg_config['logging'])) {
101
				$pkgname = $package['name'];
102
				$logtab = $pkg_config['logging']['logtab'];
103
				if(!isset($pkg_config['logging']['logtab'])) $logtab = $pkgname;
104
				if($apkg == $pkgname) { ?>
105
					<li class="tabact"><?= $pkg_config['name']; ?></li>
106
    <?php
107
				} else { ?>
108
					<li class="tabinact"><a href="diag_pkglogs.php?pkg=<?= $pkgname; ?>"><?= $logtab; ?></a></li>
109
    <?php
110
				}
111
			}
112
       		 }
113
	}
114
    ?> 
115
  </ul>
116
  </td></tr>
117
  <tr>
118
    <td class="tabcont">
119
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
120
		  <tr>
121
			<td colspan="2" class="listtopic">
122
			  Last <?=$nentries;?> <?=$apkg;?> log entries</td>
123
		  </tr>
124
		  <?php
125
			$apkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $config['installedpackages']['package'][$apkgid]['configurationfile'], "packagegui");
126
			if(isset($apkg_config['logging']['logfile'])) {
127
				$logfile = $apkg_config['logging']['logfile'];
128
			} else {
129
				$logfile = "{$g['varlog_path']}/system.log";
130
			}
131
			if(isset($apkg_config['logging']['custom_php_logging_command'])) {
132
				eval($apkg_config['custom_php_global_functions']);
133
				eval($apkg_config['logging']['custom_php_logging_command']);
134
			} elseif(isset($apkg_config['logging']['grepfor']) and isset($apkg_config['logging']['invertgrep'])) {
135
				dump_clog($logfile, $nentries, $apkg_config['logging']['grepfor'], true, true, false);
136
			} elseif(isset($apkg_config['logging']['grepfor'])) {
137
				dump_clog($logfile, $nentries, $apkg_config['logging']['grepfor'], "", true, false);
138
			} else {
139
				dump_clog($logfile, $nentries, "", "", true, false);
140
			}
141
		?>
142
		</table>
143
		<br>
144
<!--
145
<form action="diag_pkglogs.php" method="post">
146
<input name="clear" type="submit" class="formbtn" value="Clear log">
147
</form>
148
-->
149
	</td>
150
  </tr>
151
</table>
152
<?php include("fend.inc"); ?>
153
</body>
154
</html>
(17-17/115)