Backported 1.5.1 chatroom message fetching

This commit is contained in:
2025-09-12 08:24:12 -07:00
parent f0b6bd617a
commit 1c99ab2912
2 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
<?php
$conn = newConnection();
$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
");
$stmt->execute();
$result = $stmt->get_result();
$rows = [];
while ($row = $result->fetch_assoc()) {
$savedata = json_decode($row['save_data'], true);
$icon = $savedata['bird']['icon'] ?? 1;
$overlay = $savedata['bird']['overlay'] ?? 0;
$birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255];
$overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255];
$rows[] = implode(";", [
$row['chat_id'],
base64_encode($row['username']),
$row['content'],
$icon,
$overlay,
$row['user_id'],
$birdColor[0],
$birdColor[1],
$birdColor[2],
$overlayColor[0],
$overlayColor[1],
$overlayColor[2]
]);
}
echo encrypt("1" . ":" . implode("|", $rows));
$conn->close();

View File

@@ -1,6 +1,12 @@
<?php
require __DIR__ . '/../incl/util.php';
setPlainHeader();
if (isAllowedDatabaseVersion(getClientVersion())) {
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
require __DIR__ . '/backported/1.5.1/getChatroomMessages.php';
exit;
}
}
checkClientDatabaseVersion();
$conn = newConnection();