Fix 1.5.x getChatroomMessages.php and sendChatroomMessage.php

This commit is contained in:
2026-01-02 20:00:53 -07:00
parent 4269f91653
commit abf62a6df6
2 changed files with 30 additions and 14 deletions

View File

@@ -1,31 +1,46 @@
<?php <?php
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$stmt = $conn->prepare(" $stmt = $conn1 ->prepare("
SELECT c.id AS chat_id, c.content, u.username, u.id AS user_id, u.save_data SELECT id, content, userId
FROM chats c FROM chats
JOIN users u ON c.userId = u.id WHERE deleted_at = 0
WHERE u.banned = 0 AND c.deleted_at = 0 ORDER BY id DESC LIMIT 50
ORDER BY c.id DESC LIMIT 50
"); ");
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$rows = []; $rows = [];
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
$savedata = json_decode($row['save_data'], true); $userId = $row["userId"];
$stmt2 = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ? LIMIT 1");
$stmt2->bind_param("i", $userId);
$stmt2->execute();
$result2 = $stmt2->get_result();
if ($result2->num_rows != 1) continue;
$row2 = $result2->fetch_assoc();
$stmt3 = $conn0->prepare("SELECT username FROM users WHERE id = ? LIMIT 1");
$stmt3->bind_param("i", $userId);
$stmt3->execute();
$result3 = $stmt3->get_result();
if ($result3->num_rows != 1) continue;
$row3 = $result3->fetch_assoc();
$savedata = json_decode($row2['save_data'], true);
$icon = $savedata['bird']['icon'] ?? 1; $icon = $savedata['bird']['icon'] ?? 1;
$overlay = $savedata['bird']['overlay'] ?? 0; $overlay = $savedata['bird']['overlay'] ?? 0;
$birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255]; $birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255];
$overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255]; $overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255];
$rows[] = implode(";", [ $rows[] = implode(";", [
$row['chat_id'], $row['id'],
base64_encode($row['username']), base64_encode($row3['username']),
$row['content'], $row['content'],
$icon, $icon,
$overlay, $overlay,
$row['user_id'], $userId,
$birdColor[0], $birdColor[0],
$birdColor[1], $birdColor[1],
$birdColor[2], $birdColor[2],
@@ -37,4 +52,5 @@ while ($row = $result->fetch_assoc()) {
echo encrypt("1" . ":" . implode("|", array_reverse($rows))); echo encrypt("1" . ":" . implode("|", array_reverse($rows)));
$conn->close(); $conn0->close();
$conn1->close();

View File

@@ -7,9 +7,9 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
exitWithMessage("-1"); exitWithMessage("-1");
} }
$conn = newConnection(); $conn = newConnection(1);
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ?"); $stmt = $conn->prepare("SELECT id FROM userdata WHERE token = ?");
$stmt->bind_param("s", $token); $stmt->bind_param("s", $token);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();