Beispiel #1
0
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 {
    echo 'images/noimage.gif';
}
Beispiel #2
0
        $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);
}
Beispiel #3
0
function newer($a, $b)
{
    $a = r($a);
    $b = r($b);
    if (!file_exists($b) || !file_exists($a)) {
        return true;
    }
    $at = filetime($a);
    $bt = filetime($b);
    if ($at != $bt) {
        return true;
    }
    if (is_dir($a)) {
        $dp = opendir($a);
        while (false !== ($e = readdir($dp))) {
            if ($e == '.' || $e == '..') {
                continue;
            }
            if (newer(pathjoin($a, $e), $b)) {
                closedir($dp);
                return true;
            }
        }
        closedir($dp);
    }
    return false;
}
Beispiel #4
0
 function install($path, $type, $package, $from = 0, $upgrade = false)
 {
     $file = $path . '/Packages/' . $type . '-' . $package . '.info.txt';
     $info = $this->readconf($file);
     $conf['_SERVER'] = $_SERVER;
     if (isset($info['configuration']) and count($info['configuration'])) {
         if (is_file($path . '/Installed/' . $type . '-' . $package . '.conf.txt')) {
             $conf = $this->readconf($path . '/Installed/' . $type . '-' . $package . '.conf.txt');
         } else {
             global $smarty;
             if (isset($info['configuration help']) and count($info['configuration help'])) {
                 $smarty->assign('help', implode("<br />\n", $info['configuration help']));
             } else {
                 $smarty->assign('help', '');
             }
             for ($i = 0; $i < count($info['configuration']); $i++) {
                 $info['configuration'][$i][2] = preg_replace('/\\$([_A-Z]*)/e', '$conf[\'_SERVER\'][\'\\1\']', $info['configuration'][$i][2]);
             }
             $smarty->assign('type', $type);
             $smarty->assign('package', $package);
             $smarty->assign('info', $info);
             $smarty->assign('mid', 'tiki-mods_config.tpl');
             $smarty->display('tiki.tpl');
             die;
         }
     }
     if ($upgrade and isset($info['sql-upgrade']) and count($info['sql-upgrade'])) {
         uksort($info['sql-upgrade'], 'newer');
         global $tikilib;
         foreach ($info['sql-upgrade'] as $v => $vv) {
             if (newer($from, $v) < 0) {
                 foreach ($vv as $sql) {
                     if (count($conf) and strpos($sql, '$')) {
                         $sql = preg_replace('/\\$([_a-zA-Z0-9]*)/e', '$conf[\'\\1\'][0]', $sql);
                     }
                     $this->feedback[] = array('num' => 1, 'mes' => "{$from} -> {$v} : {$sql}");
                     $tikilib->query($sql, array());
                 }
             }
         }
     } elseif (isset($info['sql-install']) and count($info['sql-install'])) {
         global $tikilib;
         foreach ($info['sql-install'] as $sql) {
             if (count($conf) and strpos($sql, '$')) {
                 $sql = preg_replace('/\\$([_a-zA-Z0-9]*)/e', '$conf[\'\\1\'][0]', $sql);
             }
             $tikilib->query($sql, array());
         }
     }
     if (isset($info['files']) and count($info['files'])) {
         foreach ($info['files'] as $f) {
             $this->prepare_dir(dirname($f[1]));
             if (is_file($f[1])) {
                 if (is_file($f[1] . '.orig.' . $info['revision'][0])) {
                     @unlink($f[1] . '.orig.' . $info['revision'][0]);
                 }
                 rename($f[1], $f[1] . '.orig.' . $info['revision'][0]);
             }
             if (substr(basename($f[0]), 0, 7) == "sample:") {
                 $text = implode('', file($path . $f[0]));
                 $text = preg_replace('/\\[:::\\[([^\\]]*)\\]:::\\]/e', '$conf[\'\\1\'][0]', $text);
                 $f[0] = str_replace('sample:', '', $f[0]);
                 $fp = fopen($path . '/' . $f[0], "w");
                 fputs($fp, $text);
                 fclose($fp);
                 if (!(rename($path . '/' . $f[0], $f[1]) && chmod($f[1], 0644))) {
                     die("{$f['0']} to {$f['1']} impossible to copy");
                 }
             } else {
                 if (!(copy($path . '/' . $f[0], $f[1]) && chmod($f[1], 0644))) {
                     die("{$f['0']} to {$f['1']} impossible to copy");
                 }
                 //
             }
         }
     }
     copy($file, $path . '/Installed/' . basename($file));
     $this->rebuild_list($path . '/Installed/');
 }