Skip to content

Commit

Permalink
Always use gmt
Browse files Browse the repository at this point in the history
  • Loading branch information
RetGal committed Feb 21, 2024
1 parent 453037e commit e9cfe71
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions ext/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ function computeToken($length) {

function insertToken($token, $address, $port, $pdo) {
$sql = "INSERT INTO tokens (token,assistant,port,ts) VALUES (:token,:address,:port,:ts)";
$date = new DateTime();
$ts = $date->getTimestamp();
$ts = time();
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':token', $token, PDO::PARAM_STR, 7);
$stmt->bindParam(':address', $address, PDO::PARAM_STR);
Expand All @@ -87,8 +86,7 @@ function insertToken($token, $address, $port, $pdo) {
}

function removeOldTokens($pdo) {
$date = new DateTime();
$ts = $date->getTimestamp();
$ts = time();
$delete = "DELETE FROM tokens WHERE ts < ?";
$stmt = $pdo->prepare($delete);
$stmt->execute(array($ts-TOKEN_LIFETIME));
Expand All @@ -108,8 +106,7 @@ function readToken($token, $pdo) {

function updateToken($token, $address, $pdo) {
$sql = "UPDATE tokens SET assisted = :address,ts = :ts WHERE token = :token";
$date = new DateTime();
$ts = $date->getTimestamp();
$ts = time();
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':address', $address, PDO::PARAM_STR);
$stmt->bindParam(':ts', $ts, PDO::PARAM_INT);
Expand Down

0 comments on commit e9cfe71

Please sign in to comment.