site presence interval ping

This commit is contained in:
Austin 2021-11-04 05:04:36 -04:00
parent df734b0ba3
commit c9d7d3b3bf
2 changed files with 20 additions and 3 deletions

View File

@ -6400,6 +6400,15 @@ function createSession($userID) {
}
}
function updateLastSeen($userID) {
$updateLastSeen = $GLOBALS['pdo']->prepare("UPDATE users SET lastseen = UNIX_TIMESTAMP() WHERE id = :id");
$updateLastSeen->bindParam(":id", $userID, PDO::PARAM_INT);
if ($updateLastSeen->execute()) {
return true;
}
return false;
}
function logoutAllSessions($userID) {
$sessions = $GLOBALS['pdo']->prepare("UPDATE sessions SET valid = 0 WHERE uid = :uid");
$sessions->bindParam(":uid", $userID, PDO::PARAM_INT);
@ -6769,7 +6778,11 @@ function getNav()
'.$announcement.'
'.$thumbnailerstatus.'
'.$gameserverstatus.'
</header><br />';
</header>
<script>
setInterval(function(){ getJSONCDS("https://api.alphaland.cc/sitepresence/ping"); }, 90000); //ping every 1.5 minutes
</script>
<br/>';
}
return '
<header>

View File

@ -4,9 +4,13 @@
Alphaland 2021
*/
//headers
header("Access-Control-Allow-Origin: https://www.alphaland.cc");
header("access-control-allow-credentials: true");
header('Content-Type: application/json');
$success = false;
if (updateLastSeen($GLOBALS['user']->id)) {
$success = true;
}
die(json_encode(["success" => $success]));