Project

General

Profile

Download (4.04 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	$Id$
4

    
5
	diag_pkglogs.php
6
	Copyright (C) 2005 Colin Smith
7
	All rights reserved.
8

    
9
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
10
	All rights reserved.
11

    
12
	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

    
33
	<logging>
34
		<logtab>arpwatch</logtab>
35
		<grepfor>arpwatch</logtab>
36
	</logging>
37

    
38
		<invertgrep/>
39
		<logfile>/var/log/arpwatch.log</logfile>
40

    
41
*/
42

    
43
/*
44
	pfSense_BUILDER_BINARIES:	/usr/bin/netstat	
45
	pfSense_MODULE:	pkgs
46
*/
47

    
48
##|+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
require("guiconfig.inc");
56
require("pkg-utils.inc");
57

    
58
if(!($nentries = $config['syslog']['nentries'])) $nentries = 50;
59

    
60
//if ($_POST['clear']) 
61
//	clear_log_file($logfile);
62

    
63
$i = 0;
64
$pkgwithlogging = false;
65
$apkg = $_GET['pkg'];
66
if(!$apkg) { // If we aren't looking for a specific package, locate the first package that handles logging.
67
	if($config['installedpackages']['package'] <> "") {
68
		foreach($config['installedpackages']['package'] as $package) {
69
			if(is_array($package['logging'])) {
70
				$pkgwithlogging = true;
71
				$apkg = $package['name'];
72
				$apkgid = $i;
73
				break;
74
			}
75
			$i++;
76
		}
77
	}
78
} elseif($apkg) {
79
	$apkgid = get_pkg_id($apkg);
80
	if ($apkgid != -1) {
81
		$pkgwithlogging = true;
82
		$i = $apkgid;
83
	}
84
}
85

    
86
$pgtitle = array(gettext("Status"),gettext("Package logs"));
87
include("head.inc");
88

    
89
?>
90
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
91
<?php include("fbegin.inc"); ?>
92
<table width="100%" border="0" cellpadding="0" cellspacing="0">
93
  <tr>
94
	<td>
95
    <?php
96
	if($pkgwithlogging == false) {
97
		print_info_box(gettext("No packages with logging facilities are currently installed."));
98
		echo '</ul></td></tr></table>';
99
		include("fend.inc");
100
		exit;
101
	}
102
	$tab_array = array();
103
	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
				$tab_array[] = array(sprintf(gettext("%s"),$logtab), true, "diag_pkglogs.php?pkg=".$package['name']);
109
			} else {
110
				$tab_array[] = array(sprintf(gettext("%s"),$logtab), false, "diag_pkglogs.php?pkg=".$package['name']);
111
			}
112
		}
113
       	 }
114
	display_top_tabs($tab_array);
115
    ?> 
116
  </td></tr>
117
  <tr>
118
    <td>
119
	<div id="mainarea">
120
		<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
121
		  <tr>
122
			<td colspan="2" class="listtopic">
123
			  <?php printf(gettext('Last %1$s %2$s log entries'),$nentries,$curtab); ?></td>
124
		  </tr>
125
		  <?php
126
			$package =& $config['installedpackages']['package'][$apkgid];
127
			dump_clog($g['varlog_path'] . '/' . $package['logging']['logfilename'], $nentries);
128
		?>
129
		</table>
130
<!--
131
<form action="diag_pkglogs.php" method="post">
132
<input name="clear" type="submit" class="formbtn" value="Clear log">
133
</form>
134
-->
135
		</div>
136
	</td>
137
  </tr>
138
</table>
139
<?php include("fend.inc"); ?>
140
</body>
141
</html>
(32-32/241)