diff --git a/database/getChatroomMessagesAPI.php b/database/getChatroomMessagesAPI.php new file mode 100644 index 0000000..8e65155 --- /dev/null +++ b/database/getChatroomMessagesAPI.php @@ -0,0 +1,18 @@ +prepare(" + SELECT c.id, c.content, u.username + FROM chats c + JOIN users u ON c.userId = u.uid + WHERE u.banned = 0 AND c.deleted = 0 + ORDER BY c.id ASC LIMIT 50 +"); +$stmt->execute(); +$result = $stmt->get_result(); + +echo json_encode(array_map(fn($row) => ['username' => $row['username'], 'content' => base64_decode($row['content']), 'contentRaw' => $row['content'], 'messageId' => $row['id']], $result->fetch_all(MYSQLI_ASSOC)), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); + +$conn->close(); \ No newline at end of file diff --git a/database/getTopPlayersAPI.php b/database/getTopPlayersAPI.php new file mode 100644 index 0000000..507d06d --- /dev/null +++ b/database/getTopPlayersAPI.php @@ -0,0 +1,13 @@ +prepare("SELECT username, highScore FROM users WHERE highScore != 0 AND banned = 0 AND leaderboardsBanned = 0 ORDER BY highScore DESC LIMIT 500"); +$stmt->execute(); + +$result = $stmt->get_result(); + +echo json_encode(array_map(fn($row) => ['username' => $row['username'], 'score' => $row['highScore'], 'scoreFormatted' => number_format($row['highScore'])], $result->fetch_all(MYSQLI_ASSOC)), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); + +$conn->close(); \ No newline at end of file