コード例 #1
0
ファイル: admfuncs.php プロジェクト: dg-wfk/dl
function genGrantId()
{
    global $db, $maxUUTries;
    $q = $db->prepare('SELECT id FROM "grant" WHERE id = :id');
    $tries = $maxUUTries;
    do {
        $id = randomToken();
        $q->closeCursor();
        $q->execute(array(':id' => $id));
    } while ($q->fetch() !== FALSE && --$tries);
    if (!$tries) {
        logError("cannot generate unique grant ID");
        httpInternalError();
    }
    return $id;
}
コード例 #2
0
ファイル: ticketr.php プロジェクト: beuss/dl
        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;
// update the record for the next query