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
|
/*
|
41
|
pfSense_BUILDER_BINARIES: /usr/bin/netstat
|
42
|
pfSense_MODULE: pkgs
|
43
|
*/
|
44
|
|
45
|
##|+PRIV
|
46
|
##|*IDENT=page-status-packagelogs
|
47
|
##|*NAME=Status: Package logs page
|
48
|
##|*DESCR=Allow access to the 'Status: Package logs' page.
|
49
|
##|*MATCH=diag_pkglogs.php*
|
50
|
##|-PRIV
|
51
|
|
52
|
require("guiconfig.inc");
|
53
|
require("pkg-utils.inc");
|
54
|
|
55
|
if(!($nentries = $config['syslog']['nentries'])) $nentries = 50;
|
56
|
|
57
|
//if ($_POST['clear'])
|
58
|
// clear_log_file($logfile);
|
59
|
|
60
|
$i = 0;
|
61
|
$pkgwithlogging = false;
|
62
|
$apkg = $_GET['pkg'];
|
63
|
if(!$apkg) { // If we aren't looking for a specific package, locate the first package that handles logging.
|
64
|
if($config['installedpackages']['package'] <> "") {
|
65
|
foreach($config['installedpackages']['package'] as $package) {
|
66
|
if(is_array($package['logging'])) {
|
67
|
$pkgwithlogging = true;
|
68
|
$apkg = $package['name'];
|
69
|
$apkgid = $i;
|
70
|
break;
|
71
|
}
|
72
|
$i++;
|
73
|
}
|
74
|
}
|
75
|
} elseif($apkg) {
|
76
|
$apkgid = get_pkg_id($apkg);
|
77
|
if ($apkgid != -1) {
|
78
|
$pkgwithlogging = true;
|
79
|
$i = $apkgid;
|
80
|
}
|
81
|
}
|
82
|
|
83
|
$pgtitle = array(gettext("Status"),gettext("Package logs"));
|
84
|
include("head.inc");
|
85
|
|
86
|
?>
|
87
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
88
|
<?php include("fbegin.inc"); ?>
|
89
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
90
|
<tr>
|
91
|
<td>
|
92
|
<?php
|
93
|
if($pkgwithlogging == false) {
|
94
|
print_info_box(gettext("No packages with logging facilities are currently installed."));
|
95
|
echo '</ul></td></tr></table>';
|
96
|
include("fend.inc");
|
97
|
exit;
|
98
|
}
|
99
|
$tab_array = array();
|
100
|
foreach($config['installedpackages']['package'] as $package) {
|
101
|
if(is_array($package['logging'])) {
|
102
|
if(!($logtab = $package['logging']['logtab'])) $logtab = $package['name'];
|
103
|
if($apkg == $package['name']) {
|
104
|
$curtab = $logtab;
|
105
|
$tab_array[] = array(sprintf(gettext("%s"),$logtab), true, "diag_pkglogs.php?pkg=".$package['name']);
|
106
|
} else {
|
107
|
$tab_array[] = array(sprintf(gettext("%s"),$logtab), false, "diag_pkglogs.php?pkg=".$package['name']);
|
108
|
}
|
109
|
}
|
110
|
}
|
111
|
display_top_tabs($tab_array);
|
112
|
?>
|
113
|
</td></tr>
|
114
|
<tr>
|
115
|
<td>
|
116
|
<div id="mainarea">
|
117
|
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
|
118
|
<tr>
|
119
|
<td colspan="2" class="listtopic">
|
120
|
<?php printf(gettext('Last %1$s %2$s log entries'),$nentries,$curtab); ?></td>
|
121
|
</tr>
|
122
|
<?php
|
123
|
$package =& $config['installedpackages']['package'][$apkgid];
|
124
|
dump_clog($g['varlog_path'] . '/' . $package['logging']['logfilename'], $nentries);
|
125
|
?>
|
126
|
</table>
|
127
|
<!--
|
128
|
<form action="diag_pkglogs.php" method="post">
|
129
|
<input name="clear" type="submit" class="formbtn" value="Clear log">
|
130
|
</form>
|
131
|
-->
|
132
|
</div>
|
133
|
</td>
|
134
|
</tr>
|
135
|
</table>
|
136
|
<?php include("fend.inc"); ?>
|
137
|
</body>
|
138
|
</html>
|