Example #1
0
@set_time_limit(0);
/* Remove errors. */
@error_reporting(0);
$link_name = $_GET['h'];
if (!preg_match('/[0-9a-zA-Z_-]+$/', $link_name)) {
    require Pingouin_ROOT . 'lib/template/header.php';
    echo '<div class="error"><p>' . t('Sorry, the requested file is not found') . '</p></div>';
    require Pingouin_ROOT . 'lib/template/footer.php';
    exit;
}
$link = Pingouin_get_link($link_name);
if (count($link) == 0) {
    /* Try alias. */
    $alias = Pingouin_get_alias(md5($link_name));
    if (count($alias) > 0) {
        $link = Pingouin_get_link($alias["destination"]);
    }
}
if (count($link) == 0) {
    require Pingouin_ROOT . 'lib/template/header.php';
    echo '<div class="error"><p>' . t('Sorry, the requested file is not found') . '</p></div>';
    require Pingouin_ROOT . 'lib/template/footer.php';
    exit;
}
$delete_code = '';
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'];
Example #2
0
/** Update an alias.
 * @param $alias alias to update
 * @param $destination reference of the new destination
 * @param $password password to protect alias
 * @param $new_password optional new password to protect alias
 * @param $ip client's IP
 * @return "Ok" or "Error" string
 */
function Pingouin_alias_update($alias, $destination, $password, $new_password, $ip)
{
    $alias = md5($alias);
    /* Check that alias exits. */
    $a = Pingouin_get_alias($alias);
    if (!count($a)) {
        return 'Error';
    }
    /* Check that destination exists. */
    $l = Pingouin_get_link($a["destination"]);
    if (!count($l)) {
        return 'Error';
    }
    /* Check password. */
    if ($a["md5_password"] != md5($password)) {
        return 'Error';
    }
    $p = $a['md5_password'];
    if (strlen($new_password) >= 8 && strlen($new_password) <= 32) {
        $p = md5($new_password);
    } else {
        if (strlen($new_password) > 0) {
            return 'Error';
        }
    }
    /* Rewrite informations. */
    $p = VAR_ALIAS . s2p($alias) . $alias;
    $handle = fopen($p, 'w');
    fwrite($handle, $p . NL . $ip . NL . date('U') . NL . $destination . NL);
    fclose($handle);
    return 'Ok';
}
Example #3
0
    echo urlencode($res['crypt_key']);
} elseif (isset($_GET['h'])) {
    $link_name = $_GET['h'];
    $key = '';
    if (isset($_POST['key'])) {
        $key = $_POST['key'];
    }
    $d = '';
    if (isset($_GET['d'])) {
        $d = $_GET['d'];
    }
    if (!preg_match('/[0-9a-zA-Z_-]+$/', $link_name)) {
        echo 'Error';
        exit;
    }
    $link = Pingouin_get_link($link_name);
    if (count($link) == 0) {
        echo 'Error';
        exit;
    }
    if (strlen($d) > 0 && $d == $link['link_code']) {
        Pingouin_delete_link($link_name);
        echo "Ok";
        exit;
    }
    if ($link['time'] != Pingouin_INFINITY && time() > $link['time']) {
        Pingouin_delete_link($link_name);
        echo 'Error';
        exit;
    }
    if (strlen($link['key']) > 0 && md5($key) != $link['key']) {
Example #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';