Add the old api chatroom & leaderboard endpoints back

This commit is contained in:
2025-07-12 15:56:47 -07:00
parent cd7bafdfe4
commit 2362cc6a07
2 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
<?php
require __DIR__ . '/../incl/util.php';
header("Content-Type: application/json");
$conn = newConnection();
$stmt = $conn->prepare("
SELECT c.id, c.content, u.username
FROM chats c
JOIN users u ON c.userId = u.uid
WHERE u.banned = 0 AND c.deleted = 0
ORDER BY c.id ASC LIMIT 50
");
$stmt->execute();
$result = $stmt->get_result();
echo json_encode(array_map(fn($row) => ['username' => $row['username'], 'content' => base64_decode($row['content']), 'contentRaw' => $row['content'], 'messageId' => $row['id']], $result->fetch_all(MYSQLI_ASSOC)), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
$conn->close();

View File

@@ -0,0 +1,13 @@
<?php
require __DIR__ . '/../incl/util.php';
header("Content-Type: application/json");
$conn = newConnection();
$stmt = $conn->prepare("SELECT username, highScore FROM users WHERE highScore != 0 AND banned = 0 AND leaderboardsBanned = 0 ORDER BY highScore DESC LIMIT 500");
$stmt->execute();
$result = $stmt->get_result();
echo json_encode(array_map(fn($row) => ['username' => $row['username'], 'score' => $row['highScore'], 'scoreFormatted' => number_format($row['highScore'])], $result->fetch_all(MYSQLI_ASSOC)), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
$conn->close();