From 4516cd4fae08f71004383401d2388cd4fa2e655c Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Fri, 12 Sep 2025 08:41:27 -0700 Subject: [PATCH] Finish chatroom backporting for 1.5.1 --- .../backported/1.5.1/getChatroomMessages.php | 6 ++-- .../backported/1.5.1/sendChatroomMessage.php | 31 +++++++++++++++++++ database/getChatroomMessages.php | 10 +++--- database/sendChatroomMessage.php | 6 ++++ 4 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 database/backported/1.5.1/sendChatroomMessage.php diff --git a/database/backported/1.5.1/getChatroomMessages.php b/database/backported/1.5.1/getChatroomMessages.php index 1ce21c3..6577cf5 100644 --- a/database/backported/1.5.1/getChatroomMessages.php +++ b/database/backported/1.5.1/getChatroomMessages.php @@ -5,8 +5,8 @@ $stmt = $conn->prepare(" SELECT c.id AS chat_id, c.content, u.username, u.id AS user_id, u.save_data FROM chats c JOIN users u ON c.userId = u.id - WHERE u.banned = 0 - ORDER BY c.id ASC LIMIT 50 + WHERE u.banned = 0 AND c.deleted_at = 0 + ORDER BY c.id DESC LIMIT 50 "); $stmt->execute(); $result = $stmt->get_result(); @@ -35,6 +35,6 @@ while ($row = $result->fetch_assoc()) { ]); } -echo encrypt("1" . ":" . implode("|", $rows)); +echo encrypt("1" . ":" . implode("|", array_reverse($rows))); $conn->close(); \ No newline at end of file diff --git a/database/backported/1.5.1/sendChatroomMessage.php b/database/backported/1.5.1/sendChatroomMessage.php new file mode 100644 index 0000000..59958e3 --- /dev/null +++ b/database/backported/1.5.1/sendChatroomMessage.php @@ -0,0 +1,31 @@ +\/\?\\\\|`~]+$/', $request_content)) { + exitWithMessage("-1"); +} + +$conn = newConnection(); + +$stmt = $conn->prepare("SELECT * FROM users WHERE token = ?"); +$stmt->bind_param("s", $token); +$stmt->execute(); +$result = $stmt->get_result(); +$row = $result->fetch_assoc(); +if (!$row) exitWithMessage("-1"); +$stmt->close(); + +$id = $row["id"]; +$content = base64_encode($request_content); +$time = time(); + +$stmt = $conn->prepare("INSERT INTO chats (userId, content, timestamp) VALUES (?, ?, ?)"); +$stmt->bind_param("isi", $id, $content, $time); +$stmt->execute(); +$stmt->close(); + +echo encrypt("1"); + +$conn->close(); \ No newline at end of file diff --git a/database/getChatroomMessages.php b/database/getChatroomMessages.php index ee7d71e..b0caa71 100644 --- a/database/getChatroomMessages.php +++ b/database/getChatroomMessages.php @@ -1,12 +1,12 @@ prepare(" SELECT c.id AS chat_id, c.content, c.deleted_at, u.id AS user_id, u.username, u.save_data FROM chats c JOIN users u ON c.userId = u.id - WHERE u.banned = 0 + WHERE u.banned = 0 AND c.deleted_at = 0 ORDER BY c.id DESC LIMIT 50 "); diff --git a/database/sendChatroomMessage.php b/database/sendChatroomMessage.php index 4684adc..f4e73b5 100644 --- a/database/sendChatroomMessage.php +++ b/database/sendChatroomMessage.php @@ -1,6 +1,12 @@