WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : apache access_log will show apache log file and color odd and even lines in talbe uses tail -200 command unix
Categories : Update Picture
Terry Moore
Date : Nov 09th 1999
Grade : Be the 1st to grade this Code Example
Viewed : 3262
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Terry Moore
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 


<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";
}

?>
</TABLE>