<HTML>
<!-- Written By A.McCaig added odd even and created logfile reader T.A. Moore 11/9/1999 -->
<HEAD>
<!-- <META HTTP-EQUIV="Refresh" CONTENT=50> -->
<TITLE> Apache Log files </TITLE>
</HEAD>
<BODY>
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0">
<?
// put your logfile location here
$mylogfile = "/home/tropical/logs/access_log";
// function declaration for even
function even($nr) {
if ($nr % 2) { // % = modulus - ex. 2 % 2 = 0 3 % 2 = 1
$result = 0;
} else {
$result = 1;
}
return $result;
} // end of function even()
/*
* Execute the -tail command
*/
exec("tail -200 $mylogfile", $pslist);
/*
* Plough through all lines
*/
for($i=0; $i < count($pslist); $i++)
{
/*
* Make sure each word is seperated by one space
*/
$pslist[$i] = ereg_replace(" +"," ",$pslist[$i]);
/*
* Seperate the elements up
*/
$item[0] = strtok($pslist[$i]," ");
for($s=1 ; $s < 11; $s++)
{
$item[$s] = strtok(" ");
}
/*
* Now display them
*/
echo "<TR>\n";
for($p=0; $p < 11; $p++)
{
echo " <TD ";
/*
* If first line make title stand out
*/
if ($i==0){ echo "BGCOLOR=\"green\""; }
if (even($i)) {echo "BGCOLOR=\"#C0C0C0\"";} // silver
if (!even($i)) {echo "BGCOLOR=\"#808080\"";}// gray
echo ">$item[$p]</TD>\n";
}// end of for each line
echo "</TR>\n";
}