site presence interval ping
This commit is contained in:
parent
df734b0ba3
commit
c9d7d3b3bf
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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]));
|
||||
Loading…
Reference in New Issue