function renderdir($rootdir, $dir) { global $ignore; $ret = ''; $r = $fnlist = $dirlist = array(); $r['index'] = null; if (($dir = safepath($rootdir, $dir)) === false) { redirect('index.php'); } $r['dir'] = $dir; $list = (array) uscandir(pathjoin($rootdir, $dir)); if ($list === false) { redirect('index.php?base=' . $_GET['base']); } foreach ($list as $e) { if ($e == '.' || $e == '..' || in_array(strtolower($e), $ignore)) { continue; } if (uis_dir(pathjoin($rootdir, $dir, $e))) { $dirlist[] = $e; } else { $fnlist[] = $e; } } $index_file = tryindex($fnlist, $dir); if (!empty($index_file)) { $r['index'] = pathjoin($rootdir, $dir, $index_file); } natsort($dirlist); natsort($fnlist); foreach ($dirlist as $e) { $cfg = loadcfg(pathjoin($rootdir, $dir, $e)); if (isset($cfg['index'])) { $idx = pathjoin($dir, $e, upath($cfg['index'])); $ahref = urlenc(pathjoin($rootdir, $idx)); $img = 'thumb.php?base=' . $_GET['base'] . '&file=' . urlencode($idx); } else { $ahref = 'index.php?base=' . $_GET['base'] . '&dir=' . urlencode(pathjoin($dir, $e)); $img = 'images/dir.gif'; } if (isset($cfg['icon'])) { $img = 'thumb.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e, upath($cfg['icon']))); } $ret .= mkitem($e, $e, $e, '<a href="' . $ahref . '"' . ($cfg['target'] == '_blank' ? ' target="_blank"' : '') . '>', $img, istoday(pathjoin($rootdir, $dir, $e)), ($dz = udirsize(pathjoin($rootdir, $dir, $e))) > 0 ? '<br /><a name="pack" style="visibility: hidden; float:right;" href="pack.php?base=' . $_GET['base'] . '&dir=' . urlencode(pathjoin($dir, $e)) . '"><img alt="Download" title="Download - ' . fsize($dz) . '" src="images/pack.gif" /></a>' : ''); } foreach ($fnlist as $e) { if (isvideo($e) || isaudio($e)) { $ahref = '<a href="flowplayer.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">'; } elseif (isimage($e)) { $ahref = '<a href="image.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">'; } elseif (isweb($e)) { $ahref = '<a href="' . urlenc(pathjoin($rootdir, $dir, $e)) . '">'; } elseif (isdocument($e)) { $ahref = '<a href="document.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">'; } elseif (iscode($e)) { $ahref = '<a href="code.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">'; } else { $ahref = '<a href="' . urlenc(pathjoin($rootdir, $dir, $e)) . '">'; } # echo $dir.$e."\t".urlencode($dir.$e)."\n"; $ret .= mkitem($e, $e, $e . ' - (' . fsize(ufilesize(pathjoin($rootdir, $dir, $e))) . ')', $ahref, 'thumb.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)), istoday(pathjoin($rootdir, $dir, $e)), null); } $r['html'] = $ret; return $r; }
} if (ufile_exists($CFG['tempdir'] . $thash . '.jpg')) { ucopy($CFG['tempdir'] . $thash . '.jpg', $CFG['cachedir'] . $hash . '_' . $size . '.jpg'); uunlink($CFG['tempdir'] . $thash . '.jpg'); } elseif (ufile_exists($CFG['tempdir'] . $thash . '-0.jpg')) { ucopy($CFG['tempdir'] . $thash . '-0.jpg', $CFG['cachedir'] . $hash . '_' . $size . '.jpg'); $i = 0; while (ufile_exists($CFG['tempdir'] . $thash . '-' . $i . '.jpg')) { unlink($CFG['tempdir'] . $thash . '-' . $i . '.jpg'); ++$i; } } touch($CFG['cachedir'] . $hash . '_' . $size . '.jpg', ufiletime($rootdir . $file), $_now); myunlock($thash); } } elseif (isdocument($file)) { if (newer($rootdir . $file, $CFG['cachedir'] . $hash . '.pdf') || newer($rootdir . $file, $CFG['cachedir'] . $hash . '_' . $size . '.jpg')) { mylock($thash) || exit; if (!ufile_exists($CFG['tempdir'] . $thash . '.bmp')) { $tfile = $CFG['tempdir'] . $thash . '.' . getext($file); if (getext($file) == 'txt') { $cmd = $CFG['enca'] . ' -L ' . $RTI['locale'] . ' -x UTF-8 < ' . escapeshellarg($rootdir . $file) . ' > ' . escapeshellarg($tfile); exe($cmd); } else { ucopy($rootdir . $file, $tfile); } $pdf = $CFG['tempdir'] . $thash . '.pdf'; if (!ufile_exists($pdf)) { $cmd = $CFG['libreoffice'] . ' -norestore -convert-to pdf -outdir ' . escapeshellarg($CFG['tempdir']) . ' ' . escapeshellarg($tfile); exe($cmd); }
function thumb_able($file) { return isvideo($file) || isimage($file) || isdocument($file) || isweb($file); }
$t1 = $CFG['cachedir'] . $hash . '.mp4'; $t2 = $CFG['cachedir'] . $hash . '_L.jpg'; $t3 = $CFG['cachedir'] . $hash . '_' . $size . '.jpg'; if (!(newer($fp, $t1) || newer($fp, $t2) || newer($fp, $t3))) { touch($t1, filemtime($t1), $_now); touch($t2, filemtime($t2), $_now); touch($t3, filemtime($t3), $_now); continue; } } elseif (isaudio($fp)) { $t1 = $CFG['cachedir'] . $hash . '.mp3'; if (!newer($fp, $t1)) { touch($t1, filemtime($t1), $_now); continue; } } elseif (isdocument($fp)) { $t1 = $CFG['cachedir'] . $hash . '.pdf'; $t2 = $CFG['cachedir'] . $hash . '_' . $size . '.jpg'; if (!(newer($fp, $t1) || newer($fp, $t2))) { touch($t1, filemtime($t1), $_now); touch($t2, filemtime($t2), $_now); continue; } } else { continue; } $job = array('base' => $b, 'file' => $p, 'size' => $size); $s = serialize($job); echo $s; echo "\n"; $gmc->doLowBackground("webnautilus", $s);