fixed explicit time check for token validity

This commit is contained in:
xisi 2014-01-18 22:21:33 -05:00
parent a987878c8e
commit 97835f33ca

View File

@ -48,8 +48,14 @@ class Token Extends Base {
$checktime = $ctimedata->getTimestamp() + $expiretime; $checktime = $ctimedata->getTimestamp() + $expiretime;
$now = time(); $now = time();
if ($checktime >= $now && $checkTimeExplicitly || !$checkTimeExplicitly) { if ($checktime >= $now && $checkTimeExplicitly || !$checkTimeExplicitly) {
$stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE account_id = ? AND token = ? AND type = ? LIMIT 1"); if ($checkTimeExplicitly) {
if ($stmt && $stmt->bind_param('isi', $account_id, $token, $type) && $stmt->execute()) $stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE account_id = ? AND token = ? AND type = ? AND ? >= UNIX_TIMESTAMP() LIMIT 1");
$stmt->bind_param('isii', $account_id, $token, $type, $checktime);
} else {
$stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE account_id = ? AND token = ? AND type = ? LIMIT 1");
$stmt->bind_param('isi', $account_id, $token, $type);
}
if ($stmt->execute())
$res = $stmt->get_result(); $res = $stmt->get_result();
return $res->num_rows; return $res->num_rows;
return $this->sqlError(); return $this->sqlError();