Project

General

Profile

Download (4.04 KB) Statistics
| Branch: | Tag: | Revision:
1 df01982a Colin Smith
<?php
2
/*
3 2eb4178b Colin Smith
	$Id$
4
5 df01982a Colin Smith
	diag_pkglogs.php
6
	Copyright (C) 2005 Colin Smith
7
	All rights reserved.
8
9 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
10 29aef6c4 Jim Thompson
	All rights reserved.
11
12 df01982a Colin Smith
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17
18
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21
22
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32 825275fa Colin Smith
33
	<logging>
34
		<logtab>arpwatch</logtab>
35
		<grepfor>arpwatch</logtab>
36
	</logging>
37
38
		<invertgrep/>
39
		<logfile>/var/log/arpwatch.log</logfile>
40
41 df01982a Colin Smith
*/
42
43 13d193c2 Scott Ullrich
/*
44
	pfSense_BUILDER_BINARIES:	/usr/bin/netstat	
45
	pfSense_MODULE:	pkgs
46
*/
47
48 6b07c15a Matthew Grooms
##|+PRIV
49
##|*IDENT=page-status-packagelogs
50
##|*NAME=Status: Package logs page
51
##|*DESCR=Allow access to the 'Status: Package logs' page.
52
##|*MATCH=diag_pkglogs.php*
53
##|-PRIV
54
55 df01982a Colin Smith
require("guiconfig.inc");
56 41fafd53 Warren Baker
require("pkg-utils.inc");
57 df01982a Colin Smith
58 af811174 Colin Smith
if(!($nentries = $config['syslog']['nentries'])) $nentries = 50;
59 df01982a Colin Smith
60 d6abaa18 Scott Ullrich
//if ($_POST['clear']) 
61
//	clear_log_file($logfile);
62
63 2eb4178b Colin Smith
$i = 0;
64 9fc0d646 Colin Smith
$pkgwithlogging = false;
65 41fafd53 Warren Baker
$apkg = $_GET['pkg'];
66 af811174 Colin Smith
if(!$apkg) { // If we aren't looking for a specific package, locate the first package that handles logging.
67 52da2110 Colin Smith
	if($config['installedpackages']['package'] <> "") {
68 c2eb36d9 Scott Ullrich
		foreach($config['installedpackages']['package'] as $package) {
69 0187cf2a Colin Smith
			if(is_array($package['logging'])) {
70 9fc0d646 Colin Smith
				$pkgwithlogging = true;
71 c2eb36d9 Scott Ullrich
				$apkg = $package['name'];
72
				$apkgid = $i;
73
				break;
74
			}
75
			$i++;
76 2eb4178b Colin Smith
		}
77 42e72ab3 Scott Ullrich
	}
78 af811174 Colin Smith
} elseif($apkg) {
79 2eb4178b Colin Smith
	$apkgid = get_pkg_id($apkg);
80 b67cdd05 Matt Smith
	if ($apkgid != -1) {
81
		$pkgwithlogging = true;
82
		$i = $apkgid;
83
	}
84 2eb4178b Colin Smith
}
85 df01982a Colin Smith
86 0da88d50 cadu
$pgtitle = array(gettext("Status"),gettext("Package logs"));
87 b63695db Scott Ullrich
include("head.inc");
88
89
?>
90 df01982a Colin Smith
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
91
<?php include("fbegin.inc"); ?>
92
<table width="100%" border="0" cellpadding="0" cellspacing="0">
93 41fafd53 Warren Baker
  <tr>
94
	<td>
95 df01982a Colin Smith
    <?php
96 af811174 Colin Smith
	if($pkgwithlogging == false) {
97 0da88d50 cadu
		print_info_box(gettext("No packages with logging facilities are currently installed."));
98 af811174 Colin Smith
		echo '</ul></td></tr></table>';
99 42e72ab3 Scott Ullrich
		include("fend.inc");
100 52da2110 Colin Smith
		exit;
101 42e72ab3 Scott Ullrich
	}
102 41fafd53 Warren Baker
	$tab_array = array();
103 af811174 Colin Smith
	foreach($config['installedpackages']['package'] as $package) {
104
		if(is_array($package['logging'])) {
105
			if(!($logtab = $package['logging']['logtab'])) $logtab = $package['name'];
106
			if($apkg == $package['name']) { 
107
				$curtab = $logtab;
108 41fafd53 Warren Baker
				$tab_array[] = array(sprintf(gettext("%s"),$logtab), true, "diag_pkglogs.php?pkg=".$package['name']);
109 af811174 Colin Smith
			} else {
110 41fafd53 Warren Baker
				$tab_array[] = array(sprintf(gettext("%s"),$logtab), false, "diag_pkglogs.php?pkg=".$package['name']);
111 df01982a Colin Smith
			}
112 af811174 Colin Smith
		}
113
       	 }
114 41fafd53 Warren Baker
	display_top_tabs($tab_array);
115 df01982a Colin Smith
    ?> 
116
  </td></tr>
117
  <tr>
118 41fafd53 Warren Baker
    <td>
119
	<div id="mainarea">
120
		<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
121 df01982a Colin Smith
		  <tr>
122
			<td colspan="2" class="listtopic">
123 ddc55e12 Erik Fonnesbeck
			  <?php printf(gettext('Last %1$s %2$s log entries'),$nentries,$curtab); ?></td>
124 df01982a Colin Smith
		  </tr>
125
		  <?php
126 af811174 Colin Smith
			$package =& $config['installedpackages']['package'][$apkgid];
127
			dump_clog($g['varlog_path'] . '/' . $package['logging']['logfilename'], $nentries);
128 df01982a Colin Smith
		?>
129
		</table>
130 52da2110 Colin Smith
<!--
131
<form action="diag_pkglogs.php" method="post">
132 df01982a Colin Smith
<input name="clear" type="submit" class="formbtn" value="Clear log">
133
</form>
134 52da2110 Colin Smith
-->
135 41fafd53 Warren Baker
		</div>
136 df01982a Colin Smith
	</td>
137
  </tr>
138
</table>
139
<?php include("fend.inc"); ?>
140
</body>
141
</html>