// default rows to view is overridable via url variable
if (!isset($_GET['rowstoview'])) {
$rowstoview=5;
}
else {
$rowstoview=$_GET['rowstoview'];
}
//Get the proper directory
$tmp_dir=split("/",$HTTP_SERVER_VARS['DOCUMENT_ROOT']);
$tmp_dir2=array_pop($tmp_dir);
$current_dir=join("/",$tmp_dir);
$current_dir=$current_dir."/Logs/";
//go through the directory and add to an array for sorting
$dir=opendir($current_dir);
while($file=readdir($dir)) {
//only look at files that start with 'error'
if(substr($file,0,5)=='error') {
$filearray[filemtime("$current_dir$file")]=$file;
}
}
closedir($dir);
//sort the array and take the top one as the latest
krsort($filearray);
$filetoopen= current($filearray);
?>
//open the file and convert to an array
$thefile=$current_dir.$filetoopen;
echo "Error log file:".$thefile."
";
$logdata=file($thefile);
echo "
";
echo "";
//$rowstoview rows or the number of rows in file, whichever is less
$rowcount=min($rowstoview,count($logdata));
//last $rowstoview loop
for ($i=(count($logdata)-$rowcount);$i";
echo "
";
//}
?>