Project

General

Profile

Download (4.71 KB) Statistics
| Branch: | Tag: | Revision:
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
 * 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
18
 *    the documentation and/or other materials provided with the
19
 *    distribution.
20
 *
21
 * 3. All advertising materials mentioning features or use of this software
22
 *    must display the following acknowledgment:
23
 *    "This product includes software developed by the pfSense Project
24
 *    for use in the pfSense® software distribution. (http://www.pfsense.org/).
25
 *
26
 * 4. The names "pfSense" and "pfSense Project" must not be used to
27
 *    endorse or promote products derived from this software without
28
 *    prior written permission. For written permission, please contact
29
 *    coreteam@pfsense.org.
30
 *
31
 * 5. Products derived from this software may not be called "pfSense"
32
 *    nor may "pfSense" appear in their names without prior written
33
 *    permission of the Electric Sheep Fencing, LLC.
34
 *
35
 * 6. Redistributions of any form whatsoever must retain the following
36
 *    acknowledgment:
37
 *
38
 * "This product includes software developed by the pfSense Project
39
 * for use in the pfSense software distribution (http://www.pfsense.org/).
40
 *
41
 * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
42
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
44
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
45
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
50
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52
 * OF THE POSSIBILITY OF SUCH DAMAGE.
53
 */
54

    
55
/*
56
	<logging>
57
		<logtab>arpwatch</logtab>
58
		<grepfor>arpwatch</logtab>
59
	</logging>
60

    
61
		<invertgrep/>
62
		<logfile>/var/log/arpwatch.log</logfile>
63

    
64
*/
65

    
66
##|+PRIV
67
##|*IDENT=page-status-packagelogs
68
##|*NAME=Status: Package logs
69
##|*DESCR=Allow access to the 'Status: Package logs' page.
70
##|*MATCH=status_pkglogs.php*
71
##|-PRIV
72

    
73
require_once("guiconfig.inc");
74
require_once("pkg-utils.inc");
75

    
76
if (!($nentries = $config['syslog']['nentries'])) {
77
	$nentries = 50;
78
}
79

    
80
$i = 0;
81
$pkgwithlogging = false;
82
$apkg = $_GET['pkg'];
83
if (!$apkg) { // If we aren't looking for a specific package, locate the first package that handles logging.
84
	if (isset($config['installedpackages']['package'])) {
85
		foreach ($config['installedpackages']['package'] as $package) {
86
			if (isset($package['logging']['logfilename']) && $package['logging']['logfilename'] != '') {
87
				$pkgwithlogging = true;
88
				$apkg = $package['name'];
89
				$apkgid = $i;
90
				break;
91
			}
92
			$i++;
93
		}
94
	}
95
} elseif ($apkg) {
96
	$apkgid = get_package_id($apkg);
97
	if ($apkgid != -1) {
98
		$pkgwithlogging = true;
99
		$i = $apkgid;
100
	}
101
}
102

    
103
$pgtitle = array(gettext("Status"), gettext("Package Logs"));
104

    
105
if ($pkgwithlogging && !empty($apkg)) {
106
	$pgtitle[] = $apkg;
107
}
108
include("head.inc");
109

    
110
if ($pkgwithlogging == false) {
111
	print_info_box(gettext("No packages with logging facilities are currently installed."));
112
} else {
113
	$tab_array = array();
114
	foreach ($config['installedpackages']['package'] as $package) {
115
		if (is_array($package['logging'])) {
116
			if (!($logtab = $package['logging']['logtab'])) {
117
				$logtab = $package['name'];
118
			}
119

    
120
			if ($apkg == $package['name']) {
121
				$curtab = $logtab;
122
				$tab_array[] = array(sprintf(gettext("%s"), $logtab), true, "status_pkglogs.php?pkg=".$package['name']);
123
			} else {
124
				$tab_array[] = array(sprintf(gettext("%s"), $logtab), false, "status_pkglogs.php?pkg=".$package['name']);
125
			}
126
		}
127
	}
128
	display_top_tabs($tab_array);
129
?>
130

    
131
	<div class="panel panel-default">
132
		<div class="panel-heading"><h2 class="panel-title"><?=sprintf(gettext('Last %1$s %2$s Log Entries'), $nentries, $curtab)?></h2></div>
133
		<div class="panel-body">
134
			<pre>
135
<?php
136
			$package = $config['installedpackages']['package'][$apkgid];
137
			dump_clog_no_table($g['varlog_path'] . '/' . $package['logging']['logfilename'], $nentries, true, array());
138
?>
139
			</pre>
140
		</div>
141
	</div>
142

    
143
<?php }
144

    
145
include("foot.inc"); ?>
(181-181/227)