Exemplo n.º 1
0
/**
 * Clean expired files.
 * @return number of cleaned files.
 */
function jirafeau_admin_clean()
{
    $count = 0;
    /* Get all links files. */
    $stack = array(VAR_LINKS);
    while (($d = array_shift($stack)) && $d != NULL) {
        $dir = scandir($d);
        foreach ($dir as $node) {
            if (strcmp($node, '.') == 0 || strcmp($node, '..') == 0 || preg_match('/\\.tmp/i', "{$node}")) {
                continue;
            }
            if (is_dir($d . $node)) {
                /* Push new found directory. */
                $stack[] = $d . $node . '/';
            } elseif (is_file($d . $node)) {
                /* Read link informations. */
                $l = jirafeau_get_link(basename($node));
                if (!count($l)) {
                    continue;
                }
                $p = s2p($l['md5']);
                if ($l['time'] > 0 && $l['time'] < time() || !file_exists(VAR_FILES . $p . $l['md5']) || !file_exists(VAR_FILES . $p . $l['md5'] . '_count')) {
                    jirafeau_delete_link($node);
                    $count++;
                }
            }
        }
    }
    return $count;
}
Exemplo n.º 2
0
if ($link['crypted']) {
    /* Init module */
    $m = mcrypt_module_open('rijndael-256', '', 'ofb', '');
    /* Extract key and iv. */
    $md5_key = md5($crypt_key);
    $iv = jirafeau_crypt_create_iv($md5_key, mcrypt_enc_get_iv_size($m));
    /* Init module. */
    mcrypt_generic_init($m, $md5_key, $iv);
    /* Decrypt file. */
    $r = fopen(VAR_FILES . $p . $link['md5'], 'r');
    while (!feof($r)) {
        $dec = mdecrypt_generic($m, fread($r, 1024));
        print $dec;
        ob_flush();
    }
    fclose($r);
    /* Cleanup. */
    mcrypt_generic_deinit($m);
    mcrypt_module_close($m);
} else {
    $r = fopen(VAR_FILES . $p . $link['md5'], 'r');
    while (!feof($r)) {
        print fread($r, 1024);
        ob_flush();
    }
    fclose($r);
}
if ($link['onetime'] == 'O') {
    jirafeau_delete_link($link_name);
}
exit;
Exemplo n.º 3
0
 } elseif (strcmp($_POST['action'], 'clean_async') == 0) {
     $total = jirafeau_admin_clean_async();
     echo '<div class="message">' . NL;
     echo '<p>';
     echo t('Number of cleaned files') . ' : ' . $total;
     echo '</p></div>';
 } elseif (strcmp($_POST['action'], 'list') == 0) {
     jirafeau_admin_list("", "", "");
 } elseif (strcmp($_POST['action'], 'search_by_name') == 0) {
     jirafeau_admin_list($_POST['name'], "", "");
 } elseif (strcmp($_POST['action'], 'search_by_file_hash') == 0) {
     jirafeau_admin_list("", $_POST['hash'], "");
 } elseif (strcmp($_POST['action'], 'search_link') == 0) {
     jirafeau_admin_list("", "", $_POST['link']);
 } elseif (strcmp($_POST['action'], 'delete_link') == 0) {
     jirafeau_delete_link($_POST['link']);
     echo '<div class="message">' . NL;
     echo '<p>' . t('Link deleted') . '</p></div>';
 } elseif (strcmp($_POST['action'], 'delete_file') == 0) {
     $count = jirafeau_delete_file($_POST['md5']);
     echo '<div class="message">' . NL;
     echo '<p>' . t('Deleted links') . ' : ' . $count . '</p></div>';
 } elseif (strcmp($_POST['action'], 'download') == 0) {
     $l = jirafeau_get_link($_POST['link']);
     if (!count($l)) {
         return;
     }
     $p = s2p($l['md5']);
     header('Content-Length: ' . $l['file_size']);
     header('Content-Type: ' . $l['mime_type']);
     header('Content-Disposition: attachment; filename="' . $l['file_name'] . '"');