From cfcb0c9d39cb84ad4885b3ad9819874398490f2c Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Sat, 12 Jul 2025 16:59:55 -0700 Subject: [PATCH] Get chatroom messages endpoint --- database/getChatroomMessages.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 database/getChatroomMessages.php diff --git a/database/getChatroomMessages.php b/database/getChatroomMessages.php new file mode 100644 index 0000000..7b47423 --- /dev/null +++ b/database/getChatroomMessages.php @@ -0,0 +1,19 @@ +prepare(" + SELECT c.id, c.content, u.username, u.icon, u.overlay, u.id, u.birdR, u.birdG, u.birdB, u.overlayR, u.overlayG, u.overlayB + FROM chats c + JOIN users u ON c.userId = u.id + WHERE u.banned = 0 AND c.deleted = 0 + ORDER BY c.id ASC LIMIT 50 +"); +$stmt->execute(); +$result = $stmt->get_result(); + +echo encrypt(json_encode(array_map(fn($row) => ['username' => $row['username'], 'userid' => $row['id'], 'content' => $row['content'], 'id' => $row['id'], 'icon' => $row['icon'], 'overlay' => $row['overlay'], 'birdColor' => [$row['birdR'], $row['birdG'], $row['birdB']], 'overlayColor' => [$row['overlayR'], $row['overlayG'], $row['overlayB']]], $result->fetch_all(MYSQLI_ASSOC)), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + +$conn->close(); \ No newline at end of file