Project

General

Profile

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