Project

General

Profile

Download (4.77 KB) Statistics
| Branch: | Tag: | Revision:
1 df01982a Colin Smith
<?php
2
/*
3 aaec5634 Renato Botelho
 * status_pkglogs.php
4 fd9ebcd5 Stephen Beaver
 *
5 aaec5634 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 2a2396a6 Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 aaec5634 Renato Botelho
 * Copyright (c) 2005 Colin Smith
8
 * All rights reserved.
9 fd9ebcd5 Stephen Beaver
 *
10 aaec5634 Renato Botelho
 * Redistribution and use in source and binary forms, with or without
11
 * modification, are permitted provided that the following conditions are met:
12 fd9ebcd5 Stephen Beaver
 *
13 aaec5634 Renato Botelho
 * 1. Redistributions of source code must retain the above copyright notice,
14
 *    this list of conditions and the following disclaimer.
15 fd9ebcd5 Stephen Beaver
 *
16 aaec5634 Renato Botelho
 * 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 fd9ebcd5 Stephen Beaver
 *
21 aaec5634 Renato Botelho
 * 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 fd9ebcd5 Stephen Beaver
 *
26 aaec5634 Renato Botelho
 * 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 fd9ebcd5 Stephen Beaver
 *
31 aaec5634 Renato Botelho
 * 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 fd9ebcd5 Stephen Beaver
 *
35 aaec5634 Renato Botelho
 * 6. Redistributions of any form whatsoever must retain the following
36
 *    acknowledgment:
37 fd9ebcd5 Stephen Beaver
 *
38 aaec5634 Renato Botelho
 * "This product includes software developed by the pfSense Project
39
 * for use in the pfSense software distribution (http://www.pfsense.org/).
40 fd9ebcd5 Stephen Beaver
 *
41 aaec5634 Renato Botelho
 * 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 fd9ebcd5 Stephen Beaver
 */
54 aaec5634 Renato Botelho
55 fd9ebcd5 Stephen Beaver
/*
56 825275fa Colin Smith
	<logging>
57
		<logtab>arpwatch</logtab>
58
		<grepfor>arpwatch</logtab>
59
	</logging>
60
61
		<invertgrep/>
62
		<logfile>/var/log/arpwatch.log</logfile>
63
64 df01982a Colin Smith
*/
65
66 6b07c15a Matthew Grooms
##|+PRIV
67
##|*IDENT=page-status-packagelogs
68 5230f468 jim-p
##|*NAME=Status: Package logs
69 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Status: Package logs' page.
70 1af5edbf Stephen Beaver
##|*MATCH=status_pkglogs.php*
71 6b07c15a Matthew Grooms
##|-PRIV
72
73 aceaf18c Phil Davis
require_once("guiconfig.inc");
74
require_once("pkg-utils.inc");
75 df01982a Colin Smith
76 5f601060 Phil Davis
if (!($nentries = $config['syslog']['nentries'])) {
77
	$nentries = 50;
78
}
79 df01982a Colin Smith
80 2eb4178b Colin Smith
$i = 0;
81 9fc0d646 Colin Smith
$pkgwithlogging = false;
82 41fafd53 Warren Baker
$apkg = $_GET['pkg'];
83 5f601060 Phil Davis
if (!$apkg) { // If we aren't looking for a specific package, locate the first package that handles logging.
84 7066f0cc k-paulius
	if (isset($config['installedpackages']['package'])) {
85 5f601060 Phil Davis
		foreach ($config['installedpackages']['package'] as $package) {
86 4d09ffde k-paulius
			if (isset($package['logging']['logfilename']) && $package['logging']['logfilename'] != '') {
87 9fc0d646 Colin Smith
				$pkgwithlogging = true;
88 c2eb36d9 Scott Ullrich
				$apkg = $package['name'];
89
				$apkgid = $i;
90
				break;
91
			}
92
			$i++;
93 2eb4178b Colin Smith
		}
94 42e72ab3 Scott Ullrich
	}
95 5f601060 Phil Davis
} elseif ($apkg) {
96 af5d93f6 Renato Botelho
	$apkgid = get_package_id($apkg);
97 b67cdd05 Matt Smith
	if ($apkgid != -1) {
98
		$pkgwithlogging = true;
99
		$i = $apkgid;
100
	}
101 2eb4178b Colin Smith
}
102 df01982a Colin Smith
103 f990294f k-paulius
$pgtitle = array(gettext("Status"), gettext("Package Logs"));
104 de02dc29 Phil Davis
$pglinks = array("", "status_pkglogs.php");
105 550d7d8b k-paulius
106
if ($pkgwithlogging && !empty($apkg)) {
107
	$pgtitle[] = $apkg;
108 de02dc29 Phil Davis
	$pglinks[] = "@self";
109 550d7d8b k-paulius
}
110 b63695db Scott Ullrich
include("head.inc");
111
112 288a2a0f Phil Davis
if ($pkgwithlogging == false) {
113 3c2c32b3 sbeaver
	print_info_box(gettext("No packages with logging facilities are currently installed."));
114
} else {
115 41fafd53 Warren Baker
	$tab_array = array();
116 288a2a0f Phil Davis
	foreach ($config['installedpackages']['package'] as $package) {
117
		if (is_array($package['logging'])) {
118 abe98adb Phil Davis
			if (!($logtab = $package['logging']['logtab'])) {
119 3c2c32b3 sbeaver
				$logtab = $package['name'];
120 abe98adb Phil Davis
			}
121 3c2c32b3 sbeaver
122 288a2a0f Phil Davis
			if ($apkg == $package['name']) {
123 af811174 Colin Smith
				$curtab = $logtab;
124 1af5edbf Stephen Beaver
				$tab_array[] = array(sprintf(gettext("%s"), $logtab), true, "status_pkglogs.php?pkg=".$package['name']);
125 af811174 Colin Smith
			} else {
126 1af5edbf Stephen Beaver
				$tab_array[] = array(sprintf(gettext("%s"), $logtab), false, "status_pkglogs.php?pkg=".$package['name']);
127 df01982a Colin Smith
			}
128 af811174 Colin Smith
		}
129 3c2c32b3 sbeaver
	}
130 41fafd53 Warren Baker
	display_top_tabs($tab_array);
131 3c2c32b3 sbeaver
?>
132
133
	<div class="panel panel-default">
134 9b277ab8 NewEraCracker
		<div class="panel-heading"><h2 class="panel-title"><?=sprintf(gettext('Last %1$s %2$s Log Entries'), $nentries, $curtab)?></h2></div>
135 15461290 Phil Davis
		<div class="panel-body">
136 59efb129 sbeaver
			<pre>
137 3c2c32b3 sbeaver
<?php
138 59efb129 sbeaver
			$package = $config['installedpackages']['package'][$apkgid];
139
			dump_clog_no_table($g['varlog_path'] . '/' . $package['logging']['logfilename'], $nentries, true, array());
140 3c2c32b3 sbeaver
?>
141 59efb129 sbeaver
			</pre>
142
		</div>
143 3c2c32b3 sbeaver
	</div>
144
145
<?php }
146
147 c10cb196 Stephen Beaver
include("foot.inc"); ?>