Project

General

Profile

Download (4.96 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

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

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

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