1
|
<?php
|
2
|
/*
|
3
|
* status_pkglogs.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7
|
* Copyright (c) 2005 Colin Smith
|
8
|
* All rights reserved.
|
9
|
*
|
10
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
* you may not use this file except in compliance with the License.
|
12
|
* You may obtain a copy of the License at
|
13
|
*
|
14
|
* http://www.apache.org/licenses/LICENSE-2.0
|
15
|
*
|
16
|
* Unless required by applicable law or agreed to in writing, software
|
17
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
* See the License for the specific language governing permissions and
|
20
|
* limitations under the License.
|
21
|
*/
|
22
|
|
23
|
/*
|
24
|
<logging>
|
25
|
<logtab>arpwatch</logtab>
|
26
|
<grepfor>arpwatch</logtab>
|
27
|
</logging>
|
28
|
|
29
|
<invertgrep/>
|
30
|
<logfile>/var/log/arpwatch.log</logfile>
|
31
|
|
32
|
*/
|
33
|
|
34
|
##|+PRIV
|
35
|
##|*IDENT=page-status-packagelogs
|
36
|
##|*NAME=Status: Package logs
|
37
|
##|*DESCR=Allow access to the 'Status: Package logs' page.
|
38
|
##|*MATCH=status_pkglogs.php*
|
39
|
##|-PRIV
|
40
|
|
41
|
require_once("guiconfig.inc");
|
42
|
require_once("pkg-utils.inc");
|
43
|
|
44
|
if (!($nentries = $config['syslog']['nentries'])) {
|
45
|
$nentries = 50;
|
46
|
}
|
47
|
|
48
|
$i = 0;
|
49
|
$pkgwithlogging = false;
|
50
|
$apkg = $_REQUEST['pkg'];
|
51
|
if (!$apkg) { // If we aren't looking for a specific package, locate the first package that handles logging.
|
52
|
if (isset($config['installedpackages']['package'])) {
|
53
|
foreach ($config['installedpackages']['package'] as $package) {
|
54
|
if (isset($package['logging']['logfilename']) && $package['logging']['logfilename'] != '') {
|
55
|
$pkgwithlogging = true;
|
56
|
$apkg = $package['name'];
|
57
|
$apkgid = $i;
|
58
|
break;
|
59
|
}
|
60
|
$i++;
|
61
|
}
|
62
|
}
|
63
|
} elseif ($apkg) {
|
64
|
$apkgid = get_package_id($apkg);
|
65
|
if ($apkgid != -1) {
|
66
|
$pkgwithlogging = true;
|
67
|
$i = $apkgid;
|
68
|
}
|
69
|
}
|
70
|
|
71
|
$pgtitle = array(gettext("Status"), gettext("Package Logs"));
|
72
|
$pglinks = array("", "status_pkglogs.php");
|
73
|
|
74
|
if ($pkgwithlogging && !empty($apkg)) {
|
75
|
$pgtitle[] = $apkg;
|
76
|
$pglinks[] = "@self";
|
77
|
}
|
78
|
include("head.inc");
|
79
|
|
80
|
if ($pkgwithlogging == false) {
|
81
|
print_info_box(gettext("No packages with logging facilities are currently installed."));
|
82
|
} else {
|
83
|
$tab_array = array();
|
84
|
foreach ($config['installedpackages']['package'] as $package) {
|
85
|
if (is_array($package['logging'])) {
|
86
|
if (!($logtab = $package['logging']['logtab'])) {
|
87
|
$logtab = $package['name'];
|
88
|
}
|
89
|
|
90
|
if ($apkg == $package['name']) {
|
91
|
$curtab = $logtab;
|
92
|
$tab_array[] = array(sprintf(gettext("%s"), $logtab), true, "status_pkglogs.php?pkg=".$package['name']);
|
93
|
} else {
|
94
|
$tab_array[] = array(sprintf(gettext("%s"), $logtab), false, "status_pkglogs.php?pkg=".$package['name']);
|
95
|
}
|
96
|
}
|
97
|
}
|
98
|
display_top_tabs($tab_array);
|
99
|
?>
|
100
|
|
101
|
<div class="panel panel-default">
|
102
|
<div class="panel-heading"><h2 class="panel-title"><?=sprintf(gettext('Last %1$s %2$s Log Entries'), $nentries, $curtab)?></h2></div>
|
103
|
<div class="panel-body">
|
104
|
<pre>
|
105
|
<?php
|
106
|
$package = $config['installedpackages']['package'][$apkgid];
|
107
|
dump_clog_no_table($g['varlog_path'] . '/' . $package['logging']['logfilename'], $nentries, true, array());
|
108
|
?>
|
109
|
</pre>
|
110
|
</div>
|
111
|
</div>
|
112
|
|
113
|
<?php }
|
114
|
|
115
|
include("foot.inc"); ?>
|