示例#1
0
function tryindex($fs, $dir)
{
    global $CFG, $RTI;
    $bdir = basedir($dir);
    $index_file = '';
    $ifile = pathjoin($CFG['cachedir'], $RTI['base'], sha1($dir) . '.idx');
    if (isarchive() && ($index_file = @file_get_contents($ifile)) !== false) {
        return $index_file;
    } else {
        foreach ($fs as $f) {
            if (!isweb($f)) {
                continue;
            }
            if (empty($index_file)) {
                $index_file = $f;
            } elseif (preg_match('/^index/i', $f)) {
                if (preg_match('/^index/i', $index_file)) {
                    if (strlen(getname($f)) < strlen(getname($index_file))) {
                        $index_file = $f;
                    }
                } else {
                    $index_file = $f;
                }
            } elseif (preg_match('/^default/i', $f)) {
                if (preg_match('/^default/i', $index_file)) {
                    if (strlen(getname($f)) < strlen(getname($index_file))) {
                        $index_file = $f;
                    }
                } elseif (!preg_match('/^index/i', $index_file)) {
                    $index_file = $f;
                }
            } elseif (levenshtein($bdir, $f) < levenshtein($bdir, $index_file) && !preg_match('/^index/i', $index_file) && !preg_match('/^default/i', $index_file)) {
                $index_file = $f;
            }
        }
        if (isarchive()) {
            if (!ufile_exists($CFG['cachedir'] . $RTI['base'])) {
                umkdir($CFG['cachedir'] . $RTI['base']);
            }
            file_put_contents($ifile, $index_file);
        }
        return $index_file;
    }
}
示例#2
0
ignore_user_abort(true);
set_time_limit(0);
include 'func.php';
$job = file_get_contents('php://stdin');
$job = unserialize($job);
$rootdir = getbase($job['base']);
$file = $job['file'];
$hash = mkhash($rootdir . $file);
$thash = $job['base'] . '-' . $hash;
$hash = $job['base'] . '/' . $hash;
$size = $job['size'];
if (mylocked($thash)) {
    exit;
}
if (!ufile_exists($CFG['cachedir'] . $job['base'])) {
    umkdir($CFG['cachedir'] . $job['base']);
}
if (isvideo($file)) {
    if (newer($rootdir . $file, $CFG['cachedir'] . $hash . '.mp4') || newer($rootdir . $file, $CFG['cachedir'] . $hash . '_L.jpg') || newer($rootdir . $file, $CFG['cachedir'] . $hash . '_' . $size . '.jpg')) {
        mylock($thash) || exit;
        if (newer($rootdir . $file, $CFG['cachedir'] . $hash . '.mp4')) {
            $cmd1 = $CFG['ffmpeg'] . ' -y -i ' . escapeshellarg(r($rootdir . $file)) . ' -acodec libfaac -ab 96 -bufsize 500k -maxrate 500k -vcodec libx264 -vpre fast -crf 22 -threads 0 ' . escapeshellarg($CFG['tempdir'] . $thash . '.mp4');
            exe($cmd1);
            rmtry($CFG['cachedir'] . $hash . '.mp4');
            rmtry($CFG['cachedir'] . $hash . '_L.jpg');
            rmtry($CFG['cachedir'] . $hash . '_' . $size . '.jpg');
            $cmd2 = $CFG['yamdi'] . ' -i ' . escapeshellarg($CFG['tempdir'] . $thash . '.mp4') . ' -o ' . escapeshellarg($CFG['cachedir'] . $hash . '.mp4');
            exe($cmd2);
            if (!file_exists($CFG['cachedir'] . $hash . '.mp4')) {
                copy($CFG['tempdir'] . $thash . '.mp4', $CFG['cachedir'] . $hash . '.mp4');
            }