<?php

if (isset($_SERVER['REMOTE_ADDR'])) header('Content-Type: text/plain');

$fp fopen('/tmp/tail-f.txt''r');
#$fp = fopen('/usr/local/apache/logs/access_log', 'r');
if ($fp === false) exit;

fseek($fp, -1000SEEK_END);
fgets($fp); // drop the first line


$runtime 60;
$exittime time() + $runtime;
while ( 
time() < $exittime ) {
  
$line fgets($fp);
  if (
strlen($line) > 0) {
    
$end substr($line, -1);
    if (
$end == "\n" || $end == "\r") {
      
#echo '<br>', $line;
      
echo $line;
      
flush();
    } else {
      
// rewind the pointer
      
fseek($fpstrlen($line), SEEK_CUR);
    }
  } else
    
fseek($fp0SEEK_CUR);
  
usleep(10000);
}

?>