Example #1
0
File: hooks.php Project: dg-wfk/dl
function onTicketPurge($DATA, $auto)
{
    global $fromAddr;
    // log
    $reason = $auto ? "automatically" : "manually";
    logTicketEvent($DATA, "purged {$reason} after " . $DATA["downloads"] . " downloads");
    // notify if requested
    if (!empty($DATA["notify_email"])) {
        logTicketEvent($DATA, "sending notification to " . $DATA["notify_email"]);
        withLocale($DATA['locale'], $auto ? 'msgTicketExpire' : 'msgTicketPurge', array($DATA, &$subject, &$body));
        mailUTF8($DATA["notify_email"], $subject, $body, "From: {$fromAddr}");
    }
}
Example #2
0
File: ticketr.php Project: beuss/dl
    if ($DATA === false) {
        logEvent("unknown ticket requested");
    } else {
        logTicketEvent($DATA, "expired ticket requested");
    }
    httpNotFound();
}
// check for password
if (hasPassHash($DATA) && !isset($_SESSION['t'][$id])) {
    logTicketEvent($DATA, "missing credentials", LOG_ERR);
    httpBadRequest();
}
// open the file first
$fd = fopen($DATA["path"], "r");
if ($fd === false) {
    logTicketEvent($DATA, "data file " . $DATA["path"] . " is missing!", LOG_ERR);
    httpInternalError();
}
// update range parameters
if (!empty($_SERVER["HTTP_RANGE"])) {
    preg_match("/^bytes=(\\d*)-(\\d*)/", $_SERVER["HTTP_RANGE"], $range);
}
if (empty($range[1]) || $range[1] < 0 || $range[1] >= $DATA["size"]) {
    $range[1] = 0;
}
if (empty($rage[2]) || $range[2] < $range[1] || $range[2] >= $DATA["size"]) {
    $range[2] = $DATA["size"] - 1;
}
$size = max(0, $range[2] - $range[1] + 1);
$complete = $size == $DATA["size"];
$last = $range[2] == $DATA["size"] - 1;