Exemple #1
0
<?php

ignore_user_abort(true);
include 'func.php';
$rootdir = getbase($_GET['base']);
if (($file = safepath($rootdir, $_GET['file'])) === false) {
    die;
}
$hash = mkhash($rootdir . $file);
$thash = $_GET['base'] . '-' . $hash;
$hash = $_GET['base'] . '/' . $hash;
if (preg_match('/^[0-9]+x[0-9]+$/', $_GET['size'])) {
    $size = $_GET['size'];
} else {
    $size = $CFG['thumb_size'];
}
$extmap = array('zip' => 'archive.gif', 'rar' => 'archive.gif', '7z' => 'archive.gif', '7zip' => 'archive.gif', 'txz' => 'archive.gif', 'xz' => 'archive.gif', 'tgz' => 'archive.gif', 'gz' => 'archive.gif', 'tar' => 'archive.gif', 'xls' => 'xls.gif', 'doc' => 'doc.gif', 'ppt' => 'ppt.gif', 'txt' => 'txt.gif', 'kmz' => 'ge.gif', 'kml' => 'ge.gif', 'htm' => 'html.gif', 'html' => 'html.gif', 'mht' => 'html.gif', 'wav' => 'audio.gif', 'mp3' => 'audio.gif', 'wma' => 'audio.gif', 'mid' => 'audio.gif', 'ogg' => 'audio.gif', 'flac' => 'audio.gif', 'swf' => 'swf.gif', 'fla' => 'fla.gif', 'aac' => 'aac.gif', 'ace' => 'ace.gif', 'aiff' => 'aiff.gif', 'arj' => 'arj.gif', 'cab' => 'cab.gif', 'mpc' => 'mpc.gif', 'pdf' => 'pdf.gif', 'vqf' => 'vqf.gif', 'xml' => 'xml.gif');
if (thumb_able($file)) {
    if (!newer($rootdir . $file, $CFG['cachedir'] . $hash . '_' . $size . '.jpg')) {
        echo $CFG['cacheurl'] . $hash . '_' . $size . '.jpg';
        exit;
    }
    $job = array('base' => $_GET['base'], 'file' => $file, 'size' => $size);
    $gmc = new Gearmanclient();
    $gmc->addServer();
    $gmc->doBackground("webnautilus", serialize($job));
    header('HTTP/1.1 491');
    exit;
} elseif (isset($extmap[getext($file)])) {
    echo 'images/' . $extmap[getext($file)];
} else {
Exemple #2
0
<?php

set_time_limit(0);
include 'func.php';
$rootdir = getbase($_GET['base']);
if (($dir = safepath($rootdir, $_GET['dir'])) === false) {
    redirect('index.php');
}
$hash = mkhash($rootdir . $dir);
$thash = $_GET['base'] . '-' . $hash;
$hash = $_GET['base'] . '/' . $hash;
$path = rtrim(joinpath($rootdir, $dir), '/');
$apath = explode('/', $path);
$bdir = array_pop($apath);
chdir(r(implode('/', $apath)));
$zfile = $bdir . '.7z';
#header('Content-type: application/x-zip-compressed');
#header('Content-Disposition: attachment; filename*=utf-8"'.preg_replace('![\\/?]!i','',$zfile).'"');
$cmd = $CFG['sevenzip'] . ' a -t7z ' . escapeshellarg($CFG['cachedir'] . $zfile) . ' ' . escapeshellarg(r($bdir));
exe($cmd);
redirect($CFG['cacheurl'] . $zfile);
#passthru($cmd);
Exemple #3
0
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;
}