コード例 #1
0
ファイル: restpurgeticket.php プロジェクト: dg-wfk/dl
function purgeticket($msg, $id = null)
{
    global $db, $auth;
    // check id validity
    if (empty($id) || !isTicketId($id)) {
        return array('httpBadRequest', 'bad parameters');
    }
    // fetch the ticket id
    $sql = "SELECT * FROM ticket WHERE id = " . $db->quote($id);
    $DATA = $db->query($sql)->fetch();
    if ($DATA === false || isTicketExpired($DATA)) {
        return array('httpNotFound', 'not found');
    }
    // check for permissions
    if (!$auth["admin"] && $DATA["user_id"] != $auth["id"]) {
        return array('httpUnauthorized', 'not authorized');
    }
    // actually purge the ticket
    ticketPurge($DATA, false);
    return array(false, false);
}
コード例 #2
0
ファイル: admfuncs.php プロジェクト: dg-wfk/dl
function runGc()
{
    global $db, $gcLimit;
    $now = time();
    $sql = "SELECT * FROM ticket WHERE expire < {$now}";
    $sql .= " OR (last_stamp + last_time) < {$now}";
    $sql .= " OR expire_dln <= downloads";
    if ($gcLimit) {
        $sql .= " LIMIT {$gcLimit}";
    }
    foreach ($db->query($sql)->fetchAll() as $DATA) {
        ticketPurge($DATA);
    }
    // expire grants
    $sql = "SELECT * FROM \"grant\" WHERE grant_expire < {$now}";
    if ($gcLimit) {
        $sql .= " LIMIT {$gcLimit}";
    }
    foreach ($db->query($sql)->fetchAll() as $DATA) {
        grantPurge($DATA);
    }
}
コード例 #3
0
ファイル: ticketla.php プロジェクト: dg-wfk/dl
    if (!is_array($sel)) {
        $sel = array($sel);
    }
    // purge immediately
    foreach ($sel as $id) {
        if (!isTicketId($id)) {
            continue;
        }
        $sql = "SELECT * FROM ticket WHERE id = " . $db->quote($id);
        $DATA = $db->query($sql)->fetch();
        if ($DATA === false) {
            continue;
        }
        // actually purge the ticket
        $list[] = htmlEntUTF8(ticketStr($DATA));
        ticketPurge($DATA, false);
    }
    if (count($list)) {
        infoMessage(T_("Purged"), $list);
    }
}
// list active tickets
$totalSize = 0;
$sql = 'SELECT t.*, u.name AS "user" FROM ticket t' . ' LEFT JOIN "user" u ON u.id = t.user_id' . ' ORDER BY time DESC';
?>
<form action="<?php 
echo $ref;
?>
" method="post">
  <table class="sortable" id="alltickets">
    <thead>
コード例 #4
0
ファイル: ticketr.php プロジェクト: beuss/dl
// contents
$left = $size;
fseek($fd, $range[1]);
while ($left) {
    $data = fread($fd, 16384);
    $left -= strlen($data);
    print $data;
    flush();
}
fclose($fd);
if ($last && !connection_aborted()) {
    ++$DATA["downloads"];
    reconnectDB();
    // set default locale for notifications
    switchLocale($defLocale);
    // trigger download hooks
    onTicketDownload($DATA);
    // check for validity after download
    if (isTicketExpired($DATA)) {
        ticketPurge($DATA);
    } else {
        // update download count
        $now = time();
        $sql = "UPDATE ticket SET last_stamp = {$now}" . ", downloads = downloads + 1 WHERE id = " . $db->quote($id);
        $db->exec($sql);
    }
    // kill the session ASAP
    if ($auth === false) {
        session_destroy();
    }
}