$file_array) { ksort($file_array); } $filename = $log; $title = substr($log, (strrpos($log, '/')+1)); ?> Logs viewer

The last '. $lines. ' lines of '. basename($filename) . '': ''; ?>
  1. ', $output);
    	echo $output;
    } else{
    ?>
            	
$value){ $path = realpath($dir.DIRECTORY_SEPARATOR.$value); if(!is_dir($path)) { $files_list[] = $path; } elseif ($value != "." && $value != "..") { $dirs_list[] = $path; } } foreach ($files_list as $path) { preg_match("/^.*\/(\S+)$/", $path, $matches); $name = $matches[1]; $results[$dir][$name] = array('name' => $name, 'path' => $path); } if(count($dirs_list)>0){ foreach ($dirs_list as $path) { get_log_files($path, $results); } } return $results; } return false; } function tail($filename, $lines = 50, $buffer = 4096){ // Open the file if(!is_file($filename)){ return false; } $f = fopen($filename, "rb"); if(!$f){ return false; } // Jump to last character fseek($f, -1, SEEK_END); // Read it and adjust line number if necessary // (Otherwise the result would be wrong if file doesn't end with a blank line) if(fread($f, 1) != "\n") $lines -= 1; // Start reading $output = ''; $chunk = ''; // While we would like more while(ftell($f) > 0 && $lines >= 0) { // Figure out how far back we should jump $seek = min(ftell($f), $buffer); // Do the jump (backwards, relative to where we are) fseek($f, -$seek, SEEK_CUR); // Read a chunk and prepend it to our output $output = ($chunk = fread($f, $seek)).$output; // Jump back to where we started reading fseek($f, -mb_strlen($chunk, '8bit'), SEEK_CUR); // Decrease our line counter $lines -= substr_count($chunk, "\n"); } // While we have too many lines // (Because of buffer size we might have read too many) while($lines++ < 0) { // Find first newline and remove all text before that $output = substr($output, strpos($output, "\n") + 1); } // Close file and return fclose($f); return $output; } function show_list_of_files($files, $lines = 50){ if(empty($files)){ return false; } // Generate a menu foreach ($files as $dir => $files_array) { //echo '
  • '.dirname($dir).'
  • '; echo ''; } }