Example #1
0
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);
}
Example #2
0
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);
    }
}
Example #3
0
    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>
Example #4
0
File: ticketr.php Project: 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();
    }
}