Yes. It broke something

This reverts commit a2f1748ff6.
This commit is contained in:
2025-09-29 13:28:57 -07:00
parent a2f1748ff6
commit 4022e96a15
9 changed files with 10 additions and 87 deletions

View File

@@ -28,7 +28,7 @@ $stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$topPlayers = new stdClass();
$topPlayers = [];
while ($row = $result->fetch_assoc()) {
$savedata = json_decode($row['save_data'], true);

View File

@@ -11,7 +11,7 @@ $stmt = $conn->prepare("
$stmt->execute();
$result = $stmt->get_result();
$rows = new stdClass();
$rows = [];
while ($row = $result->fetch_assoc()) {
$savedata = json_decode($row['save_data'], true);
$icon = $savedata['bird']['icon'] ?? 1;

View File

@@ -25,7 +25,7 @@ $stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$topPlayers = new stdClass();
$topPlayers = [];
while ($row = $result->fetch_assoc()) {
$savedata = json_decode($row['save_data'], true);

View File

@@ -23,8 +23,8 @@ $stmt->execute();
$result = $stmt->get_result();
$rows = $result->fetch_all(MYSQLI_ASSOC);
$mapped = new stdClass();
$icons = new stdClass();
$mapped = [];
$icons = [];
foreach ($rows as $row) {
$savedata = json_decode($row['save_data'], true);

View File

@@ -17,7 +17,7 @@ $onlyShowValue = (string)$post['onlyShowValue'] ?? '';
$currentIcons = json_decode(base64_decode((string)($post['currentIcons'] ?? 'W10K')));
$where = ["u.banned = 0", "(c.state = 1 OR c.state = 2)"];
$params = new stdClass();
$params = [];
$types = "";
$order = match($sortBy) {
1 => "ORDER BY c.price ASC",

View File

@@ -1,77 +0,0 @@
<?php
require __DIR__ . '/../incl/util.php';
setPlainHeader();
checkClientDatabaseVersion();
$conn = newConnection();
$post = getPostData();
$type = (int)$post['type'] ?? -1;
$userId = (int)$post['userId'] ?? 0;
$sortBy = (int)$post['sortBy'] ?? 2;
$searchForEnabled = isset($post['searchForEnabled']) ? (string)$post['searchForEnabled'] == 'False' ? false : true : false;
$searchForValue = (string)$post['searchForValue'] ?? '';
$onlyShowEnabled = isset($post['onlyShowEnabled']) ? (string)$post['onlyShowEnabled'] == 'False' ? false : true : false;
$onlyShowValue = (string)$post['onlyShowValue'] ?? '';
$currentIcons = json_decode(base64_decode((string)($post['currentIcons'] ?? 'W10K')));
if ($type != 0 && $type != 1) {
exit;
}
$where = ["u.banned = 0"];
$params = new stdClass();
$types = "";
$order = match($sortBy) {
2 => "ORDER BY c.id ASC",
3 => "ORDER BY c.id DESC",
default => "",
};
if ($searchForEnabled && $searchForValue !== '') {
$where[] = "FROM_BASE64(c.name) LIKE ?";
$params[] = "%$searchForValue%";
$types .= "s";
}
if ($onlyShowEnabled) {
if ($onlyShowValue === '0') {
$where[] = "c.userId = ?";
$params[] = $userId;
$types .= "i";
} elseif ($onlyShowValue === '1') {
$where[] = "c.userId != ?";
$params[] = $userId;
$types .= "i";
} elseif ($onlyShowValue === '2') {
$placeholders = implode(',', array_fill(0, count($currentIcons), '?'));
$where[] = "c.uuid IN ($placeholders)";
$params = array_merge($params, $currentIcons);
$types .= str_repeat('s', count($currentIcons));
} elseif ($onlyShowValue === '3') {
$placeholders = implode(',', array_fill(0, count($currentIcons), '?'));
$where[] = "c.uuid NOT IN ($placeholders)";
$params = array_merge($params, $currentIcons);
$types .= str_repeat('s', count($currentIcons));
}
}
$sql = "
SELECT c.data, u.username, u.id, c.name, c.uuid
FROM presets c
JOIN users u ON c.userId = u.id
WHERE " . implode(" AND ", $where) . "
$order
";
$stmt = $conn->prepare($sql);
if (!empty($params)) {
$stmt->bind_param($types, ...$params);
}
$stmt->execute();
$result = $stmt->get_result();
echo encrypt(json_encode(array_map(fn($row) => ['username' => $row['username'], 'userid' => $row['id'], 'data' => $row['data'], 'uuid' => $row['uuid'], 'name' => base64_decode($row['name'])], $result->fetch_all(MYSQLI_ASSOC))));
$conn->close();

View File

@@ -44,8 +44,8 @@ $stmt->execute();
$result = $stmt->get_result();
$rows = $result->fetch_all(MYSQLI_ASSOC);
$mapped = new stdClass();
$icons = new stdClass();
$mapped = [];
$icons = [];
foreach ($rows as $row) {
$savedata = json_decode($row['save_data'], true);
if (!$savedata) continue;

View File

@@ -11,7 +11,7 @@ $stmt->execute();
$result = $stmt->get_result();
$rows = $result->fetch_all(MYSQLI_ASSOC);
$mapped = new stdClass();
$mapped = [];
foreach ($rows as $row) {
$savedata = json_decode($row['save_data'], true);
if (!$savedata) continue;