diff --git a/database/getChatroomMessages.php b/database/getChatroomMessages.php index 451c11f..03f1bd0 100644 --- a/database/getChatroomMessages.php +++ b/database/getChatroomMessages.php @@ -18,9 +18,24 @@ $result = $stmt->get_result(); $rows = $result->fetch_all(MYSQLI_ASSOC); $mapped = []; +$icons = []; foreach ($rows as $row) { $savedata = json_decode($row['save_data'], true); + $customIcon = $savedata['bird']['customIcon']['selected'] ?? null; + + if ($customIcon != null && strlen($customIcon) == 36 && $icons[$customIcon] == null) { + $stmt = $conn->prepare("SELECT data FROM marketplaceicons WHERE uuid = ?"); + $stmt->bind_param("s", $customIcon); + $stmt->execute(); + $result = $stmt->get_result(); + $rowData = $result->fetch_assoc(); + if ($rowData) { + $stmt->close(); + $icons[$customIcon] = $rowData["data"]; + } + } + $mapped[] = [ 'username' => $row['username'], 'userid' => $row['user_id'], @@ -31,9 +46,10 @@ foreach ($rows as $row) { 'overlay' => $savedata['bird']['overlay'] ?? 0, 'birdColor' => $savedata['settings']['colors']['icon'] ?? [255,255,255], 'overlayColor' => $savedata['settings']['colors']['overlay'] ?? [255,255,255], + 'customIcon' => $customIcon, ]; } -echo encrypt(json_encode(array_reverse($mapped))); +echo encrypt(json_encode(["messages" => array_reverse($mapped), "customIcons" => $icons])); $conn->close(); \ No newline at end of file diff --git a/database/getTopPlayers.php b/database/getTopPlayers.php index 6607d25..6f06eb4 100644 --- a/database/getTopPlayers.php +++ b/database/getTopPlayers.php @@ -35,6 +35,7 @@ $result = $stmt->get_result(); $rows = $result->fetch_all(MYSQLI_ASSOC); $mapped = []; +$icons = []; foreach ($rows as $row) { $savedata = json_decode($row['save_data'], true); if (!$savedata) continue; @@ -42,6 +43,20 @@ foreach ($rows as $row) { $value = $savedata['gameStore'][$request_value] ?? 0; if ($value <= 0) continue; + $customIcon = $savedata['bird']['customIcon']['selected'] ?? null; + + if ($customIcon != null && strlen($customIcon) == 36 && $icons[$customIcon] == null) { + $stmt = $conn->prepare("SELECT data FROM marketplaceicons WHERE uuid = ?"); + $stmt->bind_param("s", $customIcon); + $stmt->execute(); + $result = $stmt->get_result(); + $rowData = $result->fetch_assoc(); + if ($rowData) { + $stmt->close(); + $icons[$customIcon] = $rowData["data"]; + } + } + $mapped[] = [ 'username' => $row['username'], 'userid' => $row['id'], @@ -50,12 +65,13 @@ foreach ($rows as $row) { 'overlay' => $savedata['bird']['overlay'] ?? 0, 'birdColor' => $savedata['settings']['colors']['icon'] ?? [255,255,255], 'overlayColor' => $savedata['settings']['colors']['overlay'] ?? [255,255,255], + 'customIcon' => $customIcon ]; } usort($mapped, fn($a,$b) => $b['value'] <=> $a['value']); $limited = array_slice($mapped, 0, 500); -echo encrypt(json_encode($limited)); +echo encrypt(json_encode(["entries" => $limited, "customIcons" => $icons])); $conn->close(); \ No newline at end of file