/** * Update the cache headers for the page * * @param int $maxAge: The number of seconds * @param string $privacy: The privacy of the cache * * @return null * * @since 1.0.0 */ function cache_control($maxAge = -1, $privacy = "public") { header("Cache-Control: " . $privacy . ",max-age=" . $maxAge); header("Expires: " . getGMT(time() + $maxAge)); header("Last-Modified: " . getGMT()); }
*/ if (!isset($_GET["token"])) { die("Invalid token"); } $token = $_GET["token"]; $data = encrypt_decrypt("decrypt", $token); if (!$data) { die("Invalid token"); } // TODO: Add validation $pieces = explode("-", $data); $userid = $pieces[0]; $expirationTime = $pieces[1]; if (time() > $expirationTime) { die("Token expired, please reauthenticate"); } $user = new \StdClass(); $user->last_modified = getGMT(time()); if ($userid == 1) { $user->userid = 1; $user->username = "******"; } else { if ($userid == 2) { $user->userid = 2; $user->username = "******"; } else { die("Invalid token"); } } header("Content-type: application/json"); echo json_encode($user);