2024-11-26 11:38:28 -05:00
|
|
|
<?php
|
|
|
|
require("../libs/test_secret.php");
|
|
|
|
|
|
|
|
function auth($token) {
|
2024-11-27 00:13:33 -05:00
|
|
|
if (is_null($token)) return null;
|
2024-11-26 11:38:28 -05:00
|
|
|
|
|
|
|
global $db;
|
|
|
|
|
2024-11-26 23:37:16 -05:00
|
|
|
$stmt = $db->prepare("SELECT * FROM main.token WHERE token = ?");
|
2024-11-26 11:38:28 -05:00
|
|
|
$stmt->execute([$token]);
|
|
|
|
|
|
|
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
2024-11-27 00:13:33 -05:00
|
|
|
if (!$result) return null;
|
2024-11-26 11:38:28 -05:00
|
|
|
|
|
|
|
$username = $result['username'];
|
|
|
|
|
2024-11-26 23:37:16 -05:00
|
|
|
$stmt = $db->prepare("SELECT * FROM main.auth WHERE username = ?");
|
2024-11-26 11:38:28 -05:00
|
|
|
$stmt->execute([$username]);
|
|
|
|
|
|
|
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
2024-11-27 00:13:33 -05:00
|
|
|
if (!$result) return null;
|
2024-11-26 11:38:28 -05:00
|
|
|
|
|
|
|
return $username;
|
|
|
|
}
|
|
|
|
|
|
|
|
$username = auth($_COOKIE['token']);
|
|
|
|
?>
|