Added UI elements for managing sessions
This commit is contained in:
@ -208,7 +208,7 @@ function purgeTokens(int $userID, int $maximumTokenAge) {
|
||||
$pdoQuery->execute(array_merge($defunctTokens, $expiredTokens));
|
||||
|
||||
if ($settings->Debug['LogToFile']) {
|
||||
file_put_contents('../purgeToken.log', (new DateTime())->format('Y-m-d\TH:i:s.u') . ' --- Garbage collection succeeded (' . $userID . ' => ' . $pdoQuery->rowCount() . ')' . PHP_EOL, FILE_APPEND);
|
||||
file_put_contents('../purgeToken.log', (new DateTime())->format('Y-m-d\TH:i:s.u') . ' --- Garbage collection succeeded (' . $userID . ' => #' . $pdoQuery->rowCount() . ')' . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
|
||||
return [
|
||||
@ -224,4 +224,35 @@ function purgeTokens(int $userID, int $maximumTokenAge) {
|
||||
}
|
||||
}
|
||||
|
||||
function deleteToken(array $tokenIDs, int $userID) {
|
||||
try {
|
||||
// Sadly, PDO does not support named parameters in constructions like 'IN ( :array )'
|
||||
// instead, the supported syntax is unnamed placeholders like 'IN (?, ?, ?, ...)'
|
||||
$pdoQuery = $pdoDB->prepare('
|
||||
DELETE FROM SecureToken
|
||||
WHERE SecureToken.Id IN (' . implode( ',', array_fill(0, count($tokenIDs), '?')) . ')
|
||||
AND SecureToken.UserId = :userid
|
||||
');
|
||||
$pdoQuery->execute($tokenIDs,[
|
||||
':userid' => (int) $userID
|
||||
]);
|
||||
|
||||
if ($settings->Debug['LogToFile']) {
|
||||
file_put_contents('../deleteToken.log', (new DateTime())->format('Y-m-d\TH:i:s.u') . ' --- Successfully deleted specific token(s) (' . $userID . ' => #' . $pdoQuery->rowCount() . ')' . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'Success',
|
||||
'amount' => $pdoQuery->rowCount()
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
if ($settings->Debug['LogToFile']) {
|
||||
file_put_contents('../deleteToken.log', (new DateTime())->format('Y-m-d\TH:i:s.u') . ' --- Failed deleting specific token(s) (' . $userID . ' => ' . $e . ')' . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
|
||||
return ['status' => 'Fail', 'reason' => $e];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user