<?php 

 ini_set('display_errors', 1);
 ini_set('display_startup_errors', 1);
 error_reporting(E_ALL);

function taillog() {
 $logfile="../log.pandabot.log";
 
 if (!file_exists($logfile)) {
  echo "<b>logfile not exits, if bot running?</b>";
  exit;
 }
 
 if (filesize($logfile)<=5048) {
  echo "<b>logfile loading...</b>";
  exit;
 }
 
 $fp=fopen($logfile, "r"); 
 $pos=-1; // bugfix?.... \n ??? 
 $t=" "; 
 $c=1;
 $lastlines=50;
 $out="";
 $outarray=array();

 while ($c < $lastlines) { 
  fseek($fp, $pos, SEEK_END); 
  $t=fgetc($fp); 
  $out=$t.$out;
  $pos=$pos - 1; 
  
  if ($t=="\n") {
   $c++;
   $outarray[]=$out; // if string length $out != 0 
   $out="";
  }	// if ($t=="\n") 
 } // while ($c < $lastlines)
 
 fclose($fp); 

 foreach(array_reverse($outarray) as $line){
  echo $line;
 } // foreach(array_reverse($outarray) as $line)
} // function end 

?>