Source for file GuiLogtail.php
Documentation is available at GuiLogtail.php
* Show log files in the web GUI
* @author Sean Boran/Thomas Dagonnier (FreeNAC Core Team)
* @copyright 2008 FreeNAC
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License Version 3
* @link http://freenac.net
// See also WebCommon and Common
function __construct($filename, $length=
10, $pattern=
"vmpsd|postconnect")
parent::__construct(); // See also WebCommon and Common
$this->logger->setDebugLevel(3);
if ($_SESSION['nac_rights']>=
1) {
echo
$this->logtail($filename, $length, $pattern);
echo
"<h1>ACCESS DENIED</h1>";
echo
"<p>Please verify the nac_rights for username: <" .
$_SESSION['username']
$this->logger->logit("ACCESS DENIED: verify the nac_rights for username: <" .
$_SESSION['username'] .
">.</p>");
function logtail($filename, $length=
10, $pattern=
'')
$logfile =
fopen($filename,'r');
// TBD: catch error if file cannot be read, or non existant.
$cmd=
"/usr/bin/tail -n $length $filename | egrep \"$pattern\"";
$cmd=
"/usr/bin/tail -n $length $filename ";
exec($cmd, $logtext, $error);
$text =
"<h2>The last $length lines in the log $filename :</h2>";
$text .=
"Tail Error: ($cmd) $error\n";
$this->logger->logit("Tail Error: ($cmd) $error");
//$text .= "\n<p>\n<pre>\n";
$text .=
"\n<p class='logtext'>";
foreach ($logtext as $logline) {
//$text .= $logline."\n";
$text .=
$logline .
"<br/>\n";
public function query($q)
$conn=
$this->getConnection(); // make sure we have a DB connection
$output=
"<table id='t2' width='1000' border='0' class='text14'>";
#$limit=$this->real_escape_string1($limit, $conn);
$this->debug("query() $q", 2);
// Title: Grab the list of field names
$fields=
$res->fetch_fields();
while (($row =
$res->fetch_assoc()) !==
NULL) {
foreach ($fields as $field) {
$output.=
"<tr><td>$fname</td><td>{$row[$fname]}</td></tr>";
$output.=
"<tr><td>Date printed</td><td>" .
date("F j, Y, g:i a") .
"</td></tr>";
// Inform the user if no data was returned
$output.=
"<br/><tr><td colspan='4' align='center' class='text16red'>The report is empty</td></tr><tr></tr><br/>";
#if ($in_db_conn === NULL and isset($conn))
// close table, send back text
Documentation generated on Mon, 17 Nov 2008 01:10:37 +0100 by phpDocumentor 1.4.0