1 |
df01982a
|
Colin Smith
|
<?php
|
2 |
|
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* status_pkglogs.php
|
4 |
fd9ebcd5
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
81299b5c
|
Renato Botelho
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* Copyright (c) 2005 Colin Smith
|
8 |
|
|
* All rights reserved.
|
9 |
fd9ebcd5
|
Stephen Beaver
|
*
|
10 |
b12ea3fb
|
Renato Botelho
|
* 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 |
fd9ebcd5
|
Stephen Beaver
|
*
|
14 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
15 |
fd9ebcd5
|
Stephen Beaver
|
*
|
16 |
b12ea3fb
|
Renato Botelho
|
* 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 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
22 |
c5d81585
|
Renato Botelho
|
|
23 |
fd9ebcd5
|
Stephen Beaver
|
/*
|
24 |
825275fa
|
Colin Smith
|
<logging>
|
25 |
|
|
<logtab>arpwatch</logtab>
|
26 |
|
|
<grepfor>arpwatch</logtab>
|
27 |
|
|
</logging>
|
28 |
|
|
|
29 |
|
|
<invertgrep/>
|
30 |
|
|
<logfile>/var/log/arpwatch.log</logfile>
|
31 |
|
|
|
32 |
df01982a
|
Colin Smith
|
*/
|
33 |
|
|
|
34 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
35 |
|
|
##|*IDENT=page-status-packagelogs
|
36 |
5230f468
|
jim-p
|
##|*NAME=Status: Package logs
|
37 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Status: Package logs' page.
|
38 |
1af5edbf
|
Stephen Beaver
|
##|*MATCH=status_pkglogs.php*
|
39 |
6b07c15a
|
Matthew Grooms
|
##|-PRIV
|
40 |
|
|
|
41 |
c81ef6e2
|
Phil Davis
|
require_once("guiconfig.inc");
|
42 |
|
|
require_once("pkg-utils.inc");
|
43 |
df01982a
|
Colin Smith
|
|
44 |
5f601060
|
Phil Davis
|
if (!($nentries = $config['syslog']['nentries'])) {
|
45 |
|
|
$nentries = 50;
|
46 |
|
|
}
|
47 |
df01982a
|
Colin Smith
|
|
48 |
2eb4178b
|
Colin Smith
|
$i = 0;
|
49 |
9fc0d646
|
Colin Smith
|
$pkgwithlogging = false;
|
50 |
1a8b6554
|
Steve Beaver
|
$apkg = $_REQUEST['pkg'];
|
51 |
5f601060
|
Phil Davis
|
if (!$apkg) { // If we aren't looking for a specific package, locate the first package that handles logging.
|
52 |
ab31acb9
|
k-paulius
|
if (isset($config['installedpackages']['package'])) {
|
53 |
5f601060
|
Phil Davis
|
foreach ($config['installedpackages']['package'] as $package) {
|
54 |
b2836666
|
k-paulius
|
if (isset($package['logging']['logfilename']) && $package['logging']['logfilename'] != '') {
|
55 |
9fc0d646
|
Colin Smith
|
$pkgwithlogging = true;
|
56 |
c2eb36d9
|
Scott Ullrich
|
$apkg = $package['name'];
|
57 |
|
|
$apkgid = $i;
|
58 |
|
|
break;
|
59 |
|
|
}
|
60 |
|
|
$i++;
|
61 |
2eb4178b
|
Colin Smith
|
}
|
62 |
42e72ab3
|
Scott Ullrich
|
}
|
63 |
5f601060
|
Phil Davis
|
} elseif ($apkg) {
|
64 |
af5d93f6
|
Renato Botelho
|
$apkgid = get_package_id($apkg);
|
65 |
b67cdd05
|
Matt Smith
|
if ($apkgid != -1) {
|
66 |
|
|
$pkgwithlogging = true;
|
67 |
|
|
$i = $apkgid;
|
68 |
|
|
}
|
69 |
2eb4178b
|
Colin Smith
|
}
|
70 |
df01982a
|
Colin Smith
|
|
71 |
f990294f
|
k-paulius
|
$pgtitle = array(gettext("Status"), gettext("Package Logs"));
|
72 |
edcd7535
|
Phil Davis
|
$pglinks = array("", "status_pkglogs.php");
|
73 |
550d7d8b
|
k-paulius
|
|
74 |
|
|
if ($pkgwithlogging && !empty($apkg)) {
|
75 |
|
|
$pgtitle[] = $apkg;
|
76 |
edcd7535
|
Phil Davis
|
$pglinks[] = "@self";
|
77 |
550d7d8b
|
k-paulius
|
}
|
78 |
b63695db
|
Scott Ullrich
|
include("head.inc");
|
79 |
|
|
|
80 |
288a2a0f
|
Phil Davis
|
if ($pkgwithlogging == false) {
|
81 |
3c2c32b3
|
sbeaver
|
print_info_box(gettext("No packages with logging facilities are currently installed."));
|
82 |
|
|
} else {
|
83 |
41fafd53
|
Warren Baker
|
$tab_array = array();
|
84 |
288a2a0f
|
Phil Davis
|
foreach ($config['installedpackages']['package'] as $package) {
|
85 |
|
|
if (is_array($package['logging'])) {
|
86 |
abe98adb
|
Phil Davis
|
if (!($logtab = $package['logging']['logtab'])) {
|
87 |
3c2c32b3
|
sbeaver
|
$logtab = $package['name'];
|
88 |
abe98adb
|
Phil Davis
|
}
|
89 |
3c2c32b3
|
sbeaver
|
|
90 |
288a2a0f
|
Phil Davis
|
if ($apkg == $package['name']) {
|
91 |
af811174
|
Colin Smith
|
$curtab = $logtab;
|
92 |
1af5edbf
|
Stephen Beaver
|
$tab_array[] = array(sprintf(gettext("%s"), $logtab), true, "status_pkglogs.php?pkg=".$package['name']);
|
93 |
af811174
|
Colin Smith
|
} else {
|
94 |
1af5edbf
|
Stephen Beaver
|
$tab_array[] = array(sprintf(gettext("%s"), $logtab), false, "status_pkglogs.php?pkg=".$package['name']);
|
95 |
df01982a
|
Colin Smith
|
}
|
96 |
af811174
|
Colin Smith
|
}
|
97 |
3c2c32b3
|
sbeaver
|
}
|
98 |
41fafd53
|
Warren Baker
|
display_top_tabs($tab_array);
|
99 |
3c2c32b3
|
sbeaver
|
?>
|
100 |
|
|
|
101 |
|
|
<div class="panel panel-default">
|
102 |
9b277ab8
|
NewEraCracker
|
<div class="panel-heading"><h2 class="panel-title"><?=sprintf(gettext('Last %1$s %2$s Log Entries'), $nentries, $curtab)?></h2></div>
|
103 |
15461290
|
Phil Davis
|
<div class="panel-body">
|
104 |
59efb129
|
sbeaver
|
<pre>
|
105 |
3c2c32b3
|
sbeaver
|
<?php
|
106 |
59efb129
|
sbeaver
|
$package = $config['installedpackages']['package'][$apkgid];
|
107 |
|
|
dump_clog_no_table($g['varlog_path'] . '/' . $package['logging']['logfilename'], $nentries, true, array());
|
108 |
3c2c32b3
|
sbeaver
|
?>
|
109 |
59efb129
|
sbeaver
|
</pre>
|
110 |
|
|
</div>
|
111 |
3c2c32b3
|
sbeaver
|
</div>
|
112 |
|
|
|
113 |
|
|
<?php }
|
114 |
|
|
|
115 |
c10cb196
|
Stephen Beaver
|
include("foot.inc"); ?>
|