Exemple #1
0
 static function getFile($stat, $file, $lines = null)
 {
     if (!lfile_exists($file)) {
         $stat['not_full_size'] = 'off';
         $stat['content'] = null;
         return $stat;
     }
     $size = lxfile_size($file);
     if ($size > 1000 * 1000) {
         $lines = 20;
     }
     if ($lines) {
         $getsize = $lines * 1000;
         $stat['not_full_size'] = 'on';
         $stat['content'] = lxfile_tail($file, $getsize);
         $stat['numlines'] = $lines;
     } else {
         $stat['not_full_size'] = 'off';
         $stat['content'] = lfile_get_contents($file);
     }
     return $stat;
 }
function lxfile_getfile($file, $bytes = null)
{
    $file = expand_real_root($file);
    $stat = stat($file);
    if ($stat['size'] > 5 * 1000 * 1000) {
        dprint("File size too high. Taking only the last 200 lines\n");
        $lines = 200;
    }
    if ($lines === 'download') {
        throw new lxException('cannot_download_here', '');
        $lines = null;
    }
    if (!$lines) {
        $data = file_get_contents($file);
    } else {
        $data = lxfile_tail($file, $bytes);
    }
    return $data;
}