Example #1
0
<?php

include 'func.php';
$rootdir = getbase($_GET['base']);
if (($file = safepath($rootdir, $_GET['file'])) === false) {
    die;
}
$hash = $_GET['base'] . '/' . mkhash($rootdir . $file);
if (ufile_exists($CFG['cachedir'] . $hash . '.pdf')) {
    redirect('http://docs.google.com/viewer?url=' . urlencode($CFG['url'] . $CFG['cacheurl'] . $hash . '.pdf?time=' . ufiletime($CFG['cachedir'] . $hash . '.pdf')));
}
Example #2
0
                $cmd = $CFG['libreoffice'] . ' -norestore -convert-to pdf -outdir ' . escapeshellarg($CFG['tempdir']) . ' ' . escapeshellarg($tfile);
                exe($cmd);
            }
            copy($pdf, $CFG['cachedir'] . $hash . '.pdf');
            touch($CFG['cachedir'] . $hash . '.pdf', ufiletime($rootdir . $file), $_now);
            $cmd = $CFG['ghostscript'] . ' -dNOPAUSE -dBATCH -dFirstPage=1 -dLastPage=1 -sDEVICE=bmp16 -sOutputFile=' . $CFG['tempdir'] . $thash . '.bmp ' . escapeshellarg($pdf);
            exe($cmd);
            rmtry($tfile);
            rmtry($pdf);
        }
        $cmd = $CFG['imagemagick_convert'] . ' -quality 70 -geometry ' . $size . ' ' . escapeshellarg($CFG['tempdir'] . $thash . '.bmp') . ' ' . escapeshellarg($CFG['tempdir'] . $thash . '.jpg');
        exe($cmd);
        rmtry($CFG['tempdir'] . $thash . '.bmp');
        if (ufile_exists($CFG['tempdir'] . $thash . '.jpg')) {
            ucopy($CFG['tempdir'] . $thash . '.jpg', $CFG['cachedir'] . $hash . '_' . $size . '.jpg');
            touch($CFG['cachedir'] . $hash . '_' . $size . '.jpg', ufiletime($rootdir . $file), $_now);
            uunlink($CFG['tempdir'] . $thash . '.jpg');
        }
        myunlock($thash);
    }
} elseif (isweb($file)) {
    if (newer($rootdir . $file, $CFG['cachedir'] . $hash . '_' . $size . '.jpg')) {
        mylock($thash) || exit;
        if (!ufile_exists($CFG['tempdir'] . $thash . '.png')) {
            while (ufile_exists($CFG['tempdir'] . 'firefox.lock')) {
                sleep(rand(5, 15));
            }
            utouch($CFG['tempdir'] . 'firefox' . '.lock');
            file_put_contents($CFG['tempdir'] . 'firefox' . '.lock', $thash);
            $cmd = $firefox . ' -no-remote -profile ' . escapeshellarg($ffprofile) . ' -saveimage ' . escapeshellarg('file:///' . r(urealpath($rootdir . $file))) . ' -savedelay 100 -witdh 1024';
            #logger($cmd);