Exemple #1
0
if (isset($_GET['d']) && !empty($_GET['d']) && $_GET['d'] != '1') {
    $delete_code = $_GET['d'];
}
$crypt_key = '';
if (isset($_GET['k']) && !empty($_GET['k'])) {
    $crypt_key = $_GET['k'];
}
$do_download = false;
if (isset($_GET['d']) && $_GET['d'] == '1') {
    $do_download = true;
}
$do_preview = false;
if (isset($_GET['p']) && !empty($_GET['p'])) {
    $do_preview = true;
}
$p = s2p($link['md5']);
if (!file_exists(VAR_FILES . $p . $link['md5'])) {
    jirafeau_delete_link($link_name);
    require JIRAFEAU_ROOT . 'lib/template/header.php';
    echo '<div class="error"><p>' . t('File not available.') . '</p></div>';
    require JIRAFEAU_ROOT . 'lib/template/footer.php';
    exit;
}
if (!empty($delete_code) && $delete_code == $link['link_code']) {
    jirafeau_delete_link($link_name);
    require JIRAFEAU_ROOT . 'lib/template/header.php';
    echo '<div class="message"><p>' . t('File has been deleted.') . '</p></div>';
    require JIRAFEAU_ROOT . 'lib/template/footer.php';
    exit;
}
if ($link['time'] != JIRAFEAU_INFINITY && time() > $link['time']) {
Exemple #2
0
/**
 * Finalyze an asynchronous upload.
 * @param $ref asynchronous upload reference
 * @param $code client code for this operation
 * @param $crypt boolean asking to crypt or not
 * @param $link_name_length link name length
 * @return  a string containing the download reference followed by a delete code or the string "Error"
 */
function jirafeau_async_end($ref, $code, $crypt, $link_name_length)
{
    /* Get async infos. */
    $a = jirafeau_get_async_ref($ref);
    if (count($a) == 0 || $a['next_code'] != "{$code}") {
        return "Error";
    }
    /* Generate link infos. */
    $p = VAR_ASYNC . s2p($ref) . $ref . "_data";
    if (!file_exists($p)) {
        return "Error";
    }
    $crypted = false;
    $crypt_key = '';
    if ($crypt == true && extension_loaded('mcrypt') == true) {
        $crypt_key = jirafeau_encrypt_file($p, $p);
        if (strlen($crypt_key) > 0) {
            $crypted = true;
        }
    }
    $md5 = md5_file($p);
    $size = filesize($p);
    $np = s2p($md5);
    $delete_link_code = jirafeau_gen_random(5);
    /* File already exist ? */
    if (!file_exists(VAR_FILES . $np)) {
        @mkdir(VAR_FILES . $np, 0755, true);
    }
    if (!file_exists(VAR_FILES . $np . $md5)) {
        rename($p, VAR_FILES . $np . $md5);
    }
    /* Increment or create count file. */
    $counter = 0;
    if (file_exists(VAR_FILES . $np . $md5 . '_count')) {
        $content = file(VAR_FILES . $np . $md5 . '_count');
        $counter = trim($content[0]);
    }
    $counter++;
    $handle = fopen(VAR_FILES . $np . $md5 . '_count', 'w');
    fwrite($handle, $counter);
    fclose($handle);
    /* Create link. */
    $link_tmp_name = VAR_LINKS . $md5 . rand(0, 10000) . '.tmp';
    $handle = fopen($link_tmp_name, 'w');
    fwrite($handle, $a['file_name'] . NL . $a['mime_type'] . NL . $size . NL . $a['key'] . NL . $a['time'] . NL . $md5 . NL . $a['onetime'] . NL . date('U') . NL . $a['ip'] . NL . $delete_link_code . NL . ($crypted ? 'C' : 'O'));
    fclose($handle);
    $md5_link = substr(base_16_to_64(md5_file($link_tmp_name)), 0, $link_name_length);
    $l = s2p("{$md5_link}");
    if (!@mkdir(VAR_LINKS . $l, 0755, true) || !rename($link_tmp_name, VAR_LINKS . $l . $md5_link)) {
        echo "Error";
    }
    /* Clean async upload. */
    jirafeau_async_delete($ref);
    return $md5_link . NL . $delete_link_code . NL . urlencode($crypt_key);
}
Exemple #3
0
function Pingouin_clean_rm_alias($alias)
{
    $p = s2p("{$alias}");
    if (file_exists(VAR_ALIAS . $p . $alias)) {
        unlink(VAR_ALIAS . $p . $alias);
    }
    $parse = VAR_ALIAS . $p;
    $scan = array();
    while (file_exists($parse) && ($scan = scandir($parse)) && count($scan) == 2 && basename($parse) != basename(VAR_ALIAS)) {
        rmdir($parse);
        $parse = substr($parse, 0, strlen($parse) - strlen(basename($parse)) - 1);
    }
}
Exemple #4
0
        Pingouin_admin_list("", "", "");
    } elseif (strcmp($_POST['action'], 'search_by_name') == 0) {
        Pingouin_admin_list($_POST['name'], "", "");
    } elseif (strcmp($_POST['action'], 'search_by_file_hash') == 0) {
        Pingouin_admin_list("", $_POST['hash'], "");
    } elseif (strcmp($_POST['action'], 'search_link') == 0) {
        Pingouin_admin_list("", "", $_POST['link']);
    } elseif (strcmp($_POST['action'], 'delete_link') == 0) {
        Pingouin_delete_link($_POST['link']);
        echo '<div class="message">' . NL;
        echo '<p>' . t('Link deleted') . '</p></div>';
    } elseif (strcmp($_POST['action'], 'delete_file') == 0) {
        $count = Pingouin_delete_file($_POST['md5']);
        echo '<div class="message">' . NL;
        echo '<p>' . t('Deleted links') . ' : ' . $count . '</p></div>';
    } elseif (strcmp($_POST['action'], 'download') == 0) {
        $l = Pingouin_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'] . '"');
        if (file_exists(VAR_FILES . $p . $l['md5'])) {
            readfile(VAR_FILES . $p . $l['md5']);
        }
        exit;
    }
}
require Pingouin_ROOT . 'lib/template/footer.php';