Add the old api chatroom & leaderboard endpoints back
This commit is contained in:
18
database/getChatroomMessagesAPI.php
Normal file
18
database/getChatroomMessagesAPI.php
Normal 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();
|
||||
13
database/getTopPlayersAPI.php
Normal file
13
database/getTopPlayersAPI.php
Normal 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();
|
||||
Reference in New Issue
Block a user