Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bd3adc8f8
|
||
|
|
3cf62a6896
|
||
|
|
739eadae51
|
||
|
|
9f9a65a6be
|
||
|
|
baca4c55e0
|
||
|
|
9b06f966f1
|
||
|
|
e6c045e1e1
|
||
|
|
594e924ad4
|
||
|
|
8e6a9ef156
|
||
|
|
b2c28e229d
|
No files matched your search
@@ -1,14 +1,8 @@
|
||||
# Berry Dash Server
|
||||
|
||||
> [!CAUTION]
|
||||
> This project has moved to the Lncvrt Games originization.
|
||||
> This project has been discarded and a new API is under the Lncvrt Games originization.
|
||||
>
|
||||
> You can find the new server API [here](https://github.com/Lncvrt-Games/api).
|
||||
>
|
||||
> NOTE: This is also the branch that is being modified so it can continue to work for 1.8.2 and lower.
|
||||
>
|
||||
> Find old branch [here](https://github.com/BerryDash/server/tree/main)
|
||||
|
||||
---
|
||||
|
||||
This is the source code for Berry Dash.
|
||||
Legacy Server Source Code
|
||||
@@ -5,68 +5,61 @@ $conn1 = newConnection(1);
|
||||
$request_username = $_POST['username'];
|
||||
$request_password = $_POST['password'];
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt = $conn0->prepare("SELECT id, username, password, token FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $request_username);
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
if (password_verify($request_password, $row["password"])) {
|
||||
$login_ip = getIPAddress();
|
||||
$login_time = time();
|
||||
$uid = $row['id'];
|
||||
$row = $result->fetch_assoc();
|
||||
if (password_verify($request_password, $row['password'])) {
|
||||
$login_ip = getIPAddress();
|
||||
$login_time = time();
|
||||
$uid = $row['id'];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE id = ?");
|
||||
$stmt2->bind_param("i", $uid);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $uid);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) exitWithMessage("-1", false);
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
echo '-1';
|
||||
exit;
|
||||
}
|
||||
$username = $row['username'];
|
||||
$highscore = $row2['legacy_high_score'];
|
||||
$token = $row['token'];
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
$icon = $savedata['bird']['icon'] ?? 1;
|
||||
$overlay = $savedata['bird']['overlay'] ?? 0;
|
||||
|
||||
$user2 = $result2->fetch_assoc();
|
||||
$stmt = $conn0->prepare("UPDATE users SET latest_ip = ? WHERE id = ?");
|
||||
$stmt->bind_param("si", $login_ip, $uid);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
$username = $row['username'];
|
||||
$highscore = $user2['legacy_high_score'];
|
||||
$token = $user2['token'];
|
||||
$savedata = json_decode($user2['save_data'], true);
|
||||
$icon = $savedata['bird']['icon'] ?? 1;
|
||||
$overlay = $savedata['bird']['overlay'] ?? 0;
|
||||
|
||||
$stmt = $conn0->prepare("UPDATE users SET latest_ip = ? WHERE id = ?");
|
||||
$stmt->bind_param("si", $login_ip, $uid);
|
||||
$stmt->execute();
|
||||
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1"
|
||||
) {
|
||||
echo "$token:$uid:$highscore";
|
||||
} else if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
echo "$token:$uid:$highscore:$icon:$overlay";
|
||||
} else if (getClientVersion() == "1.4.0-beta1" || getClientVersion() == "1.4.0" || getClientVersion() == "1.4.1") {
|
||||
echo "1:$token:$username:$uid:$highscore:$icon:$overlay";
|
||||
}
|
||||
} else {
|
||||
$stmt->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit("-2");
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1"
|
||||
) {
|
||||
echo "$token:$uid:$highscore";
|
||||
} else if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
echo "$token:$uid:$highscore:$icon:$overlay";
|
||||
} else if (getClientVersion() == "1.4.0-beta1" || getClientVersion() == "1.4.0" || getClientVersion() == "1.4.1") {
|
||||
echo "1:$token:$username:$uid:$highscore:$icon:$overlay";
|
||||
}
|
||||
} else {
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exitWithMessage("-2", false);
|
||||
}
|
||||
} else {
|
||||
$stmt->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit("-2");
|
||||
exitWithMessage("-2", false);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -2,29 +2,28 @@
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$request_uid = $_POST['userID'] ?? 0;
|
||||
$request_session = $_POST['gameSession'] ?? '';
|
||||
$request_score = $_POST['highScore'] ?? 0;
|
||||
$user_id = $_POST['userID'] ?? 0;
|
||||
$token = $_POST['gameSession'] ?? '';
|
||||
$high_score = $_POST['highScore'] ?? 0;
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE id = ?");
|
||||
$stmt->bind_param("s", $request_uid);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE id = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $user_id, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
echo (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") ? "-2" : "-3";
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
}
|
||||
$stmt->close();
|
||||
$user_id = $result->fetch_assoc()["id"];
|
||||
|
||||
$request_uid = $result->fetch_assoc()["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt2->bind_param("si", $request_session, $request_uid);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
|
||||
$stmt = $conn1->prepare("SELECT * FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $user_id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) {
|
||||
echo (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") ? "-2" : "-3";
|
||||
$conn0->close();
|
||||
@@ -32,8 +31,8 @@ if ($result2->num_rows != 1) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$updateStmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ? WHERE token = ? AND id = ?");
|
||||
$updateStmt->bind_param("isi", $request_score, $request_session, $request_uid);
|
||||
$updateStmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ? WHERE id = ?");
|
||||
$updateStmt->bind_param("ii", $high_score, $user_id);
|
||||
$updateStmt->execute();
|
||||
$updateStmt->close();
|
||||
|
||||
|
||||
@@ -4,39 +4,41 @@ $conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn0->prepare("SELECT username, id FROM users WHERE leaderboards_banned = 0");
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$topPlayers = [];
|
||||
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$id = $row["id"];
|
||||
$stmt2 = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? AND legacy_high_score > 0 ORDER BY legacy_high_score DESC LIMIT 1");
|
||||
$stmt2->bind_param("i", $id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? AND legacy_high_score > 0 LIMIT 1");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) continue;
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$user2 = $result2->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($user2['save_data'], true);
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
$icon = $savedata['bird']['icon'] ?? 1;
|
||||
$overlay = $savedata['bird']['overlay'] ?? 0;
|
||||
if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
$topPlayers[] = $row["username"] . ":" . $user2["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $id;
|
||||
$topPlayers[] = $row["username"] . ":" . $row2["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $id;
|
||||
} else if (getClientVersion() == "0") {
|
||||
$topPlayers[] = base64_encode($row["username"]) . ":" . $user2["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $id;
|
||||
$topPlayers[] = base64_encode($row["username"]) . ":" . $row2["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $id;
|
||||
} else if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
$birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255];
|
||||
$overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255];
|
||||
$topPlayers[] = base64_encode($row["username"]) . ":" . $user2["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $id . ":" . $birdColor[0] . ":" . $birdColor[1] . ":" . $birdColor[2] . ":" . $overlayColor[0] . ":" . $overlayColor[1] . ":" . $overlayColor[2];
|
||||
$topPlayers[] = base64_encode($row["username"]) . ":" . $row2["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $id . ":" . $birdColor[0] . ":" . $birdColor[1] . ":" . $birdColor[2] . ":" . $overlayColor[0] . ":" . $overlayColor[1] . ":" . $overlayColor[2];
|
||||
}
|
||||
}
|
||||
|
||||
usort($topPlayers, function ($a, $b) {
|
||||
$aScore = (int)explode(":", $a)[1];
|
||||
$bScore = (int)explode(":", $b)[1];
|
||||
return $bScore <=> $aScore;
|
||||
});
|
||||
if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
echo implode("::", $topPlayers);
|
||||
} else if (getClientVersion() == "0") {
|
||||
|
||||
@@ -11,10 +11,11 @@ if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientV
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
echo (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") ? encrypt("-1") : "-1";
|
||||
@@ -26,10 +27,11 @@ if ($result->num_rows != 1) {
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT save_data, legacy_high_score FROM userdata WHERE id = ? AND token = ? LIMIT 1");
|
||||
$stmt2->bind_param("is", $id, $token);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt = $conn1->prepare("SELECT save_data, legacy_high_score FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
echo (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") ? encrypt("-1") : "-1";
|
||||
@@ -45,7 +47,7 @@ $icon = $savedata['bird']['icon'] ?? 1;
|
||||
$overlay = $savedata['bird']['overlay'] ?? 0;
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
$birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255];
|
||||
$msg = "1:" . $user2['legacy_high_score'] . ":" . $icon . ":" . $overlay . ":0:0:0:0:0:0:" . ":" . $birdColor[0] . ":" . $birdColor[1] . ":" . $birdColor[2];
|
||||
$msg = "1:" . $user2['legacy_high_score'] . ":" . $icon . ":" . $overlay . ":0:0:0:0:0:0::" . $birdColor[0] . ":" . $birdColor[1] . ":" . $birdColor[2];
|
||||
if (getClientVersion() == "1.5.2") {
|
||||
$overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255];
|
||||
$msg .= ":" . $overlayColor[0] . ":" . $overlayColor[1] . ":" . $overlayColor[2];
|
||||
|
||||
@@ -8,10 +8,11 @@ $request_highScore = $_POST['highScore'] ?? 0;
|
||||
$request_icon = $_POST['icon'] ?? 0;
|
||||
$request_overlay = $_POST['overlay'] ?? 0;
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $request_userName);
|
||||
$stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $request_userName, $request_gameSession);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
echo "-2";
|
||||
@@ -22,10 +23,11 @@ if ($result->num_rows != 1) {
|
||||
|
||||
$request_uid = $result->fetch_assoc()["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt2->bind_param("si", $request_gameSession, $request_uid);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $request_uid);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
echo (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") ? "-2" : "-3";
|
||||
@@ -41,9 +43,9 @@ $savedata['bird']['icon'] = $request_icon;
|
||||
$savedata['bird']['overlay'] = $request_overlay;
|
||||
$savedata = json_encode($savedata);
|
||||
|
||||
$updateStmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ?, save_data = ? WHERE token = ? AND id = ?");
|
||||
$updateStmt->bind_param("issi", $request_highScore, $savedata, $request_gameSession, $request_uid);
|
||||
$updateStmt->execute();
|
||||
$updateStmt->close();
|
||||
$stmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ?, save_data = ? WHERE id = ?");
|
||||
$stmt->bind_param("isi", $request_highScore, $savedata, $request_uid);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
echo "1";
|
||||
@@ -6,7 +6,7 @@ $stmt = $conn1 ->prepare("
|
||||
SELECT id, content, userId
|
||||
FROM chats
|
||||
WHERE deleted_at = 0
|
||||
ORDER BY id DESC LIMIT 50
|
||||
ORDER BY id DESC LIMIT 49
|
||||
");
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
@@ -14,18 +14,20 @@ $result = $stmt->get_result();
|
||||
$rows = [];
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$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();
|
||||
$stmt = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $userId);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
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();
|
||||
$stmt = $conn0->prepare("SELECT username FROM users WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $userId);
|
||||
$stmt->execute();
|
||||
$result3 = $stmt->get_result();
|
||||
if ($result3->num_rows != 1) continue;
|
||||
$stmt->close();
|
||||
$row3 = $result3->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
@@ -50,7 +52,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
]);
|
||||
}
|
||||
|
||||
echo encrypt("1" . ":" . implode("|", array_reverse($rows)));
|
||||
echo encrypt("1:" . implode("|", array_reverse($rows)));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -7,25 +7,27 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
|
||||
exitWithMessage("-1");
|
||||
}
|
||||
|
||||
$conn = newConnection(1);
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn->prepare("SELECT id FROM userdata WHERE token = ?");
|
||||
$stmt = $conn0->prepare("SELECT id FROM users WHERE token = ?");
|
||||
$stmt->bind_param("s", $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) exitWithMessage("-1");
|
||||
$stmt->close();
|
||||
|
||||
$id = $row["id"];
|
||||
$content = base64_encode($request_content);
|
||||
$time = time();
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO chats (userId, content, timestamp) VALUES (?, ?, ?)");
|
||||
$stmt = $conn1->prepare("INSERT INTO chats (userId, content, timestamp) VALUES (?, ?, ?)");
|
||||
$stmt->bind_param("isi", $id, $content, $time);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt("1");
|
||||
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -8,59 +8,49 @@ $password = $post['password'];
|
||||
$currentHighScore = $post['currentHighScore'] ?? 0;
|
||||
$loginType = $post['loginType'] ?? '0';
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt = $conn0->prepare("SELECT id, username, password, token FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result->num_rows != 1) exitWithMessage("-1");
|
||||
$row = $result->fetch_assoc();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
exitWithMessage("-1");
|
||||
}
|
||||
if (!password_verify($password, $row["password"])) exitWithMessage("-1");
|
||||
|
||||
$user = $result->fetch_assoc();
|
||||
$id = $row['id'];
|
||||
$stmt = $conn1->prepare("SELECT legacy_high_score FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) exitWithMessage("-1");
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
if (!password_verify($password, $user["password"])) {
|
||||
exitWithMessage("-1");
|
||||
}
|
||||
|
||||
$id = $user['id'];
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE id = ?");
|
||||
$stmt2->bind_param("i", $id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
exitWithMessage("-1");
|
||||
}
|
||||
|
||||
$user2 = $result2->fetch_assoc();
|
||||
|
||||
$token = $user2['token'];
|
||||
$token = $row['token'];
|
||||
$ip = getIPAddress();
|
||||
|
||||
$stmt = $conn0->prepare("UPDATE users SET latest_ip = ? WHERE id = ?");
|
||||
$stmt->bind_param("si", $ip, $id);
|
||||
$stmt = $conn0->prepare("UPDATE users SET latest_ip = ?, token = ? WHERE id = ?");
|
||||
$stmt->bind_param("ssi", $ip, $token, $id);
|
||||
$stmt->execute();
|
||||
$stmt2 = $conn1->prepare("UPDATE userdata SET token = ? WHERE id = ?");
|
||||
$stmt2->bind_param("si", $token, $id);
|
||||
$stmt2->execute();
|
||||
$stmt->close();
|
||||
|
||||
if ($currentHighScore > $user['legacy_high_score']) {
|
||||
if ($currentHighScore > $row2['legacy_high_score']) {
|
||||
$stmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ? WHERE id = ?");
|
||||
$stmt->bind_param("ii", $currentHighScore, $id);
|
||||
$stmt->execute();
|
||||
$user['legacy_high_score'] = $currentHighScore;
|
||||
$stmt->close();
|
||||
$row2['legacy_high_score'] = $currentHighScore;
|
||||
}
|
||||
|
||||
$savedata = json_decode($user['save_data'], true);
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255];
|
||||
$overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255];
|
||||
|
||||
if ($loginType === "0") {
|
||||
echo encrypt("1" . ":" . $token . ":" . $user['username'] . ":" . $id . ":" . $user['legacy_high_score'] . ":" . ($savedata['bird']['icon'] ?? 1) . ":" . ($savedata['bird']['overlay'] ?? 0) . ":0:0:0:0:0:" . ":" . $birdColor[0] . ":" . $birdColor[1] . ":" . $birdColor[2] . ":" . $overlayColor[0] . ":" . $overlayColor[1] . ":" . $overlayColor[2]);
|
||||
echo encrypt("1:" . $token . ":" . $row['username'] . ":" . $id . ":" . $row2['legacy_high_score'] . ":" . ($savedata['bird']['icon'] ?? 1) . ":" . ($savedata['bird']['overlay'] ?? 0) . ":0:0:0:0:0::" . $birdColor[0] . ":" . $birdColor[1] . ":" . $birdColor[2] . ":" . $overlayColor[0] . ":" . $overlayColor[1] . ":" . $overlayColor[2]);
|
||||
} elseif ($loginType === "1") {
|
||||
echo encrypt("1" . ":" . $token . ":" . $user['username'] . ":" . $id);
|
||||
echo encrypt("1:" . $token . ":" . $row['username'] . ":" . $id);
|
||||
}
|
||||
$stmt->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -5,24 +5,26 @@ $username = $post['userName'] ?? '';
|
||||
$highScore = (int)$post['highScore'] ?? 0;
|
||||
$icon = (int)$post['icon'] ?? 1;
|
||||
$overlay = (int)$post['overlay'] ?? 0;
|
||||
$birdR = (int)$post['birdR'] ?? 255;
|
||||
$birdG = (int)$post['birdG'] ?? 255;
|
||||
$birdB = (int)$post['birdB'] ?? 255;
|
||||
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
$birdR = (int)$post['birdR'] ?? 255;
|
||||
$birdG = (int)$post['birdG'] ?? 255;
|
||||
$birdB = (int)$post['birdB'] ?? 255;
|
||||
$birdColor = [$birdR, $birdG, $birdB];
|
||||
}
|
||||
if (getClientVersion() == "1.5.2") {
|
||||
$overlayR = (int)$post['overlayR'] ?? 255;
|
||||
$overlayG = (int)$post['overlayG'] ?? 255;
|
||||
$overlayB = (int)$post['overlayB'] ?? 255;
|
||||
$overlayColor = [$overlayR, $overlayG, $overlayB];
|
||||
}
|
||||
$birdColor = [$birdR, $birdG, $birdB];
|
||||
$overlayColor = [$overlayR, $overlayG, $overlayB];
|
||||
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
echo encrypt("-1");
|
||||
@@ -34,10 +36,11 @@ if ($result->num_rows != 1) {
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE id = ? AND token = ?");
|
||||
$stmt2->bind_param("is", $id, $token);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
echo encrypt("-1");
|
||||
@@ -50,18 +53,17 @@ $row2 = $result2->fetch_assoc();
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
$savedata['bird']['icon'] = $icon;
|
||||
$savedata['bird']['overlay'] = $overlay;
|
||||
$savedata['settings']['colors']['icon'] = $birdColor;
|
||||
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") $savedata['settings']['colors']['icon'] = $birdColor;
|
||||
if (getClientVersion() == "1.5.2") $savedata['settings']['colors']['overlay'] = $overlayColor;
|
||||
$savedata = json_encode($savedata);
|
||||
$updateStmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ?, save_data = ? WHERE id = ? AND token = ?");
|
||||
$updateStmt->bind_param("isis",
|
||||
$stmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ?, save_data = ? WHERE id = ?");
|
||||
$stmt->bind_param("isi",
|
||||
$highScore,
|
||||
$savedata,
|
||||
$id,
|
||||
$token
|
||||
$id
|
||||
);
|
||||
$updateStmt->execute();
|
||||
$updateStmt->close();
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
echo encrypt("1");
|
||||
|
||||
$conn0->close();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
echo '1';
|
||||
echo getClientVersion() == "1.4.0-beta1" ? "1" : "2";
|
||||
@@ -11,14 +11,12 @@ if (
|
||||
getClientVersion() == "1.33" ||
|
||||
getClientVersion() == "1.4.0-beta1" ||
|
||||
getClientVersion() == "1.4.0" ||
|
||||
getClientVersion() == "1.4.1"
|
||||
getClientVersion() == "1.4.1" ||
|
||||
getClientVersion() == "1.5.0" ||
|
||||
getClientVersion() == "1.5.1" ||
|
||||
getClientVersion() == "1.5.2"
|
||||
) {
|
||||
echo "-1";
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
exitWithMessage("-1");
|
||||
exit;
|
||||
exitWithMessage("-1", getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2");
|
||||
}
|
||||
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to register an account in game"]));
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to change your password in game"]));
|
||||
@@ -11,14 +11,12 @@ if (
|
||||
getClientVersion() == "1.33" ||
|
||||
getClientVersion() == "1.4.0-beta1" ||
|
||||
getClientVersion() == "1.4.0" ||
|
||||
getClientVersion() == "1.4.1"
|
||||
getClientVersion() == "1.4.1" ||
|
||||
getClientVersion() == "1.5.0" ||
|
||||
getClientVersion() == "1.5.1" ||
|
||||
getClientVersion() == "1.5.2"
|
||||
) {
|
||||
echo "-1";
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
exitWithMessage("-1");
|
||||
exit;
|
||||
exitWithMessage("-1", getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2");
|
||||
}
|
||||
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to register an account in game"]));
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to change your username in game"]));
|
||||
@@ -9,26 +9,27 @@ $targetId = (int)$post['targetId'] ?? 0;
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result->num_rows != 1) exitWithMessage(json_encode(["success" => false, "message" => 'User info not found']));
|
||||
$row = $result->fetch_assoc();
|
||||
$user_id = $row["id"];
|
||||
$user_id = $result->fetch_assoc()["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt2->bind_param("si", $token, $user_id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt = $conn1->prepare("SELECT 1 FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $user_id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) exitWithMessage(json_encode(["success" => false, "message" => 'User info not found']));
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$time = time();
|
||||
|
||||
$stmt = $conn1->prepare("UPDATE userposts SET deleted_at = ? WHERE id = ? AND userId = ? AND deleted_at = 0");
|
||||
$stmt->bind_param("iii", $time, $targetId, $user_id);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt(json_encode(["success" => $stmt->affected_rows > 0]));
|
||||
|
||||
|
||||
@@ -7,22 +7,32 @@ $id = $post['id'] ?? '';
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? AND token = ? LIMIT 1");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) exit;
|
||||
$stmt->close();
|
||||
$row = $result->fetch_assoc();
|
||||
if ($result->num_rows != 1) exit;
|
||||
|
||||
$user_id = $row["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT 1 FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $user_id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) exit;
|
||||
|
||||
$time = time();
|
||||
|
||||
$stmt = $conn->prepare("UPDATE chats SET deleted_at = ? WHERE userId = ? AND id = ?");
|
||||
$stmt = $conn1->prepare("UPDATE chats SET deleted_at = ? WHERE userId = ? AND id = ?");
|
||||
$stmt->bind_param("iii", $time, $user_id, $id);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -13,23 +13,23 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) exit;
|
||||
$stmt->close();
|
||||
|
||||
$user_id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt2->bind_param("si", $token, $user_id);
|
||||
$stmt2 = $conn1->prepare("SELECT 1 FROM userdata WHERE id = ?");
|
||||
$stmt2->bind_param("i", $user_id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt->close();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
if (!$row2) exit;
|
||||
$stmt2->close();
|
||||
|
||||
$content = base64_encode($content);
|
||||
|
||||
|
||||
@@ -12,27 +12,36 @@ $stmt = $conn0->prepare("SELECT username, id FROM users WHERE id = ?");
|
||||
$stmt->bind_param("i", $uesrId);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ?");
|
||||
$stmt2->bind_param("i", $row['id']);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $row['id']);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
$custom = null;
|
||||
if (isset($savedata['bird']['customIcon']['selected'])) {
|
||||
$selected = $savedata['bird']['customIcon']['selected'];
|
||||
foreach ($savedata['bird']['customIcon']['data'] as $entry) {
|
||||
if (isset($entry['uuid']) && $entry['uuid'] === $selected) {
|
||||
$custom = $entry['data'];
|
||||
break;
|
||||
}
|
||||
$custom = isset($savedata['bird']['customIcon']['selected']) ?? null;
|
||||
|
||||
$customIcon = $savedata['bird']['customIcon']['selected'] ?? null;
|
||||
$icon = null;
|
||||
|
||||
if ($customIcon != null && strlen($customIcon) == 36) {
|
||||
$stmt = $conn1->prepare("SELECT data FROM marketplaceicons WHERE id = ?");
|
||||
$stmt->bind_param("s", $customIcon);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$rowData = $result->fetch_assoc();
|
||||
if ($rowData) {
|
||||
$icon = $rowData["data"];
|
||||
}
|
||||
}
|
||||
|
||||
echo encrypt(json_encode([
|
||||
"success" => true,
|
||||
"totalNormalBerries" => $savedata['gameStore']['totalNormalBerries'] ?? 0,
|
||||
@@ -47,7 +56,7 @@ if ($result->num_rows > 0) {
|
||||
"name" => $row['username'],
|
||||
"icon" => $savedata['bird']['icon'] ?? 1,
|
||||
"overlay" => $savedata['bird']['overlay'] ?? 0,
|
||||
"customIcon" => $custom,
|
||||
"customIcon" => $icon,
|
||||
"playerIconColor" => $savedata['settings']['colors']['icon'] ?? [255,255,255],
|
||||
"playerOverlayColor" => $savedata['settings']['colors']['overlay'] ?? [255,255,255]
|
||||
]));
|
||||
@@ -55,6 +64,5 @@ if ($result->num_rows > 0) {
|
||||
echo encrypt(json_encode(["success" => false]));
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -15,6 +15,7 @@ $stmt = $conn->prepare("
|
||||
$stmt->bind_param("i", $targetId);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt(json_encode(array_map(
|
||||
function ($row) {
|
||||
|
||||
@@ -16,25 +16,26 @@ $stmt = $conn1->prepare("
|
||||
LIMIT 50
|
||||
");
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
$rows = $result->fetch_all(MYSQLI_ASSOC);
|
||||
$stmt->close();
|
||||
|
||||
$mapped = [];
|
||||
$icons = [];
|
||||
foreach ($rows as $row) {
|
||||
foreach ($result->fetch_all(mode: MYSQLI_ASSOC) as $row) {
|
||||
$userId = $row["userId"];
|
||||
$stmt2 = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt2->bind_param("i", $userId);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $userId);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
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();
|
||||
$stmt = $conn0->prepare("SELECT username FROM users WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $userId);
|
||||
$stmt->execute();
|
||||
$result3 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result3->num_rows != 1) continue;
|
||||
$row3 = $result3->fetch_assoc();
|
||||
|
||||
@@ -43,13 +44,13 @@ foreach ($rows as $row) {
|
||||
$customIcon = $savedata['bird']['customIcon']['selected'] ?? null;
|
||||
|
||||
if ($customIcon != null && strlen($customIcon) == 36 && $icons[$customIcon] == null) {
|
||||
$stmt = $conn1->prepare("SELECT data FROM marketplaceicons WHERE uuid = ?");
|
||||
$stmt = $conn1->prepare("SELECT data FROM marketplaceicons WHERE id = ?");
|
||||
$stmt->bind_param("s", $customIcon);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$rowData = $result->fetch_assoc();
|
||||
if ($rowData) {
|
||||
$stmt->close();
|
||||
$icons[$customIcon] = $rowData["data"];
|
||||
}
|
||||
}
|
||||
@@ -69,11 +70,7 @@ foreach ($rows as $row) {
|
||||
}
|
||||
|
||||
|
||||
if (getClientVersion() == "1.6") {
|
||||
echo encrypt(json_encode($mapped));
|
||||
} else {
|
||||
echo encrypt(json_encode(["messages" => array_reverse($mapped), "customIcons" => $icons == [] ? new stdClass() : $icons]));
|
||||
}
|
||||
echo encrypt(json_encode(getClientVersion() == "1.6" ? $mapped : ["messages" => array_reverse($mapped), "customIcons" => $icons == [] ? new stdClass() : $icons]));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -1,4 +1,14 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
echo "1.8.2";
|
||||
|
||||
$conn0 = newConnection(0);
|
||||
|
||||
$stmt = $conn0->prepare("SELECT downloadUrlVersion FROM launcherversionmanifest WHERE HIDDEN = 0 AND game = 1 ORDER BY place DESC LIMIT 1");
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row = $result->fetch_assoc();
|
||||
$conn0->close();
|
||||
|
||||
echo $row["downloadUrlVersion"] ?? 'N/A';
|
||||
@@ -16,7 +16,7 @@ $onlyShowEnabled = isset($post['onlyShowEnabled']) ? (string) $post['onlyShowEna
|
||||
$onlyShowValue = (string) $post['onlyShowValue'] ?? '';
|
||||
$currentIcons = json_decode(base64_decode((string) ($post['currentIcons'] ?? 'W10K')));
|
||||
|
||||
$where = ["(state = 1 OR state = 2)"];
|
||||
$where = ["state = 1"];
|
||||
$params = [];
|
||||
$types = "";
|
||||
$order = match ($sortBy) {
|
||||
@@ -62,36 +62,34 @@ if ($onlyShowEnabled) {
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT data, price, name, uuid, state, userId
|
||||
SELECT data, price, name, id, state, userId
|
||||
FROM marketplaceicons
|
||||
WHERE " . implode(" AND ", $where) . "
|
||||
$order
|
||||
";
|
||||
|
||||
$stmt = $conn1->prepare($sql);
|
||||
|
||||
if (!empty($params)) {
|
||||
$stmt->bind_param($types, ...$params);
|
||||
}
|
||||
|
||||
if (!empty($params)) $stmt->bind_param($types, ...$params);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt(json_encode(array_map(
|
||||
function ($row) {
|
||||
global $conn0;
|
||||
|
||||
$stmt2 = $conn0->prepare("SELECT username FROM users WHERE id = ?");
|
||||
$stmt2->bind_param("i", $row['userId']);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt = $conn0->prepare("SELECT username FROM users WHERE id = ?");
|
||||
$stmt->bind_param("i", $row['userId']);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
return [
|
||||
'username' => $row2['username'] ?? 'Unknown',
|
||||
'userid' => $row['userId'],
|
||||
'data' => $row['data'],
|
||||
'uuid' => $row['uuid'],
|
||||
'uuid' => $row['id'],
|
||||
'price' => (int) $row['state'] == 2 ? 100000000 : $row['price'],
|
||||
'name' => base64_decode($row['name'])
|
||||
];
|
||||
|
||||
+14
-18
@@ -38,26 +38,22 @@ if ($request_type === "0") {
|
||||
|
||||
$stmt = $conn0->prepare("SELECT username, id FROM users WHERE leaderboards_banned = 0");
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
$rows = $result->fetch_all(MYSQLI_ASSOC);
|
||||
$stmt->close();
|
||||
|
||||
$mapped = [];
|
||||
$icons = [];
|
||||
foreach ($rows as $row) {
|
||||
foreach ($result->fetch_all(mode: MYSQLI_ASSOC) as $row) {
|
||||
$id = $row["id"];
|
||||
$stmt2 = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt2->bind_param("i", $id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) continue;
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$user2 = $result2->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($user2['save_data'], true);
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
if (!$savedata) continue;
|
||||
|
||||
if ($request_type == "4") {
|
||||
@@ -65,20 +61,20 @@ foreach ($rows as $row) {
|
||||
$value = 0;
|
||||
foreach ($berries as $b) $value += (int)($savedata['gameStore'][$b] ?? 0);
|
||||
} else {
|
||||
$value = $request_type != 2 ? $request_type != 3 ? ($savedata['gameStore'][$request_value] ?? 0) : ($user2['legacy_high_score'] ?? 0) : ($savedata['bird']['customIcon']['balance'] ?? 0);
|
||||
$value = $request_type != 2 ? $request_type != 3 ? ($savedata['gameStore'][$request_value] ?? 0) : ($row2['legacy_high_score'] ?? 0) : ($savedata['bird']['customIcon']['balance'] ?? 0);
|
||||
}
|
||||
if ($value <= 0) continue;
|
||||
|
||||
$customIcon = $savedata['bird']['customIcon']['selected'] ?? null;
|
||||
|
||||
if ($customIcon != null && strlen($customIcon) == 36 && $icons[$customIcon] == null) {
|
||||
$stmt = $conn1->prepare("SELECT data FROM marketplaceicons WHERE uuid = ?");
|
||||
if ($customIcon && strlen($customIcon) == 36 && empty($icons[$customIcon])) {
|
||||
$stmt = $conn1->prepare("SELECT data FROM marketplaceicons WHERE id = ?");
|
||||
$stmt->bind_param("s", $customIcon);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$rowData = $result->fetch_assoc();
|
||||
if ($rowData) {
|
||||
$stmt->close();
|
||||
$icons[$customIcon] = $rowData["data"];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
require __DIR__ . '/../../incl/util.php';
|
||||
setJsonHeader();
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM launcherversions WHERE hidden = 0 ORDER BY id DESC");
|
||||
$stmt->execute();
|
||||
|
||||
$result_versions = $stmt->get_result();
|
||||
$versions = array_map(fn($row) => ['id' => $row['id'], 'version' => $row['version'], 'releaseDate' => $row['releaseDate'], 'displayName' => empty($row['displayName']) ? $row['version'] : $row['displayName'], 'platforms' => json_decode($row['platforms']), 'downloadUrls' => json_decode($row['downloadUrls']), 'executables' => json_decode($row['executables']), 'category' => $row['category']], $result_versions->fetch_all(MYSQLI_ASSOC));
|
||||
|
||||
echo json_encode($versions);
|
||||
|
||||
$conn->close();
|
||||
@@ -20,10 +20,11 @@ $username = $post['username'] ?? '';
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn0->prepare("SELECT id, username FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt = $conn0->prepare("SELECT id, username FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
echo encrypt(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
@@ -35,10 +36,11 @@ if ($result->num_rows != 1) {
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT save_data, token FROM userdata WHERE id = ? AND token = ?");
|
||||
$stmt2->bind_param("is", $id, $token);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
echo encrypt(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
@@ -52,7 +54,44 @@ $row2 = $result2->fetch_assoc();
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
$savedata['account']['id'] = $id;
|
||||
$savedata['account']['name'] = $row['username'];
|
||||
$savedata['account']['session'] = $row2['token'];
|
||||
$savedata['account']['session'] = $token;
|
||||
if ($savedata['version'] !== '0') {
|
||||
$savedata['version'] = '0';
|
||||
if (isset($savedata["bird"]["customIcon"]["purchased"]))
|
||||
{
|
||||
$purchased = $savedata["bird"]["customIcon"]["purchased"];
|
||||
unset($savedata["bird"]["customIcon"]["purchased"]);
|
||||
$data = [];
|
||||
foreach ($purchased as $icon) {
|
||||
$stmt2 = $conn1->prepare("SELECT userId, data, price, name FROM marketplaceicons WHERE id = ?");
|
||||
$stmt2->bind_param("s", $icon);
|
||||
$stmt2->execute();
|
||||
$result3 = $stmt2->get_result();
|
||||
$stmt2->close();
|
||||
if ($result3->num_rows != 1) continue;
|
||||
$row3 = $result3->fetch_assoc();
|
||||
$uid = $row3['userId'];
|
||||
|
||||
$stmt3 = $conn0->prepare("SELECT username FROM users WHERE id = ?");
|
||||
$stmt3->bind_param("i", $uid);
|
||||
$stmt3->execute();
|
||||
$result4 = $stmt3->get_result();
|
||||
$stmt3->close();
|
||||
if ($result4->num_rows != 1) continue;
|
||||
$row4 = $result4->fetch_assoc();
|
||||
|
||||
$data[] = [
|
||||
"username" => $row4["username"],
|
||||
"userid" => $row3["userId"],
|
||||
"data" => $row3["data"],
|
||||
"uuid" => $icon,
|
||||
"price" => $row3["price"],
|
||||
"name" => base64_decode($row3["name"])
|
||||
];
|
||||
}
|
||||
$savedata["bird"]["customIcon"]["data"] = $data;
|
||||
}
|
||||
}
|
||||
echo encrypt(json_encode([
|
||||
"success" => true,
|
||||
"data" => $savedata
|
||||
|
||||
@@ -27,48 +27,28 @@ $post = getPostData();
|
||||
$username = $post['username'];
|
||||
$password = $post['password'];
|
||||
|
||||
$stmt = $conn0->prepare("SELECT id, username, password FROM users WHERE username = ?");
|
||||
$stmt = $conn0->prepare("SELECT id, username, password, token FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
|
||||
}
|
||||
if ($result->num_rows != 1) exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
|
||||
$row = $result->fetch_assoc();
|
||||
if (!password_verify($password, $row["password"])) exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
|
||||
|
||||
$user = $result->fetch_assoc();
|
||||
|
||||
if (!password_verify($password, $user["password"])) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
|
||||
}
|
||||
|
||||
$id = $user['id'];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT token FROM userdata WHERE id = ?");
|
||||
$stmt2->bind_param("i", $id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
|
||||
}
|
||||
|
||||
$user2 = $result2->fetch_assoc();
|
||||
|
||||
$token = $user2['token'];
|
||||
$id = $row['id'];
|
||||
$token = $row['token'];
|
||||
$ip = getIPAddress();
|
||||
|
||||
$stmt = $conn0->prepare("UPDATE users SET latest_ip = ? WHERE id = ?");
|
||||
$stmt->bind_param("si", $ip, $id);
|
||||
$stmt->execute();
|
||||
$stmt2 = $conn1->prepare("UPDATE userdata SET token = ? WHERE id = ?");
|
||||
$stmt2->bind_param("si", $token, $id);
|
||||
$stmt2->execute();
|
||||
$stmt->close();
|
||||
|
||||
$data = ["session" => $token, "username" => $user['username'], "userid" => $id];
|
||||
$data = ["session" => $token, "username" => $row['username'], "userid" => $id];
|
||||
|
||||
echo encrypt(json_encode(["success" => true, "data" => $data]));
|
||||
|
||||
$stmt->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -11,14 +11,12 @@ if (
|
||||
getClientVersion() == "1.33" ||
|
||||
getClientVersion() == "1.4.0-beta1" ||
|
||||
getClientVersion() == "1.4.0" ||
|
||||
getClientVersion() == "1.4.1"
|
||||
getClientVersion() == "1.4.1" ||
|
||||
getClientVersion() == "1.5.0" ||
|
||||
getClientVersion() == "1.5.1" ||
|
||||
getClientVersion() == "1.5.2"
|
||||
) {
|
||||
echo "-1";
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
exitWithMessage("-1");
|
||||
exit;
|
||||
exitWithMessage("-1", getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2");
|
||||
}
|
||||
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to register an account in game"]));
|
||||
@@ -13,8 +13,8 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? LIMIT 1");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ? LIMIT 1");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
@@ -23,8 +23,8 @@ $stmt->close();
|
||||
|
||||
$user_id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE id = ? AND token = ? LIMIT 1");
|
||||
$stmt2->bind_param("is", $user_id, $token);
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt2->bind_param("i", $user_id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
@@ -53,6 +53,7 @@ $reason = base64_encode($reason);
|
||||
$stmt = $conn1->prepare("INSERT INTO chatroom_reports (chatid, userId, reason, timestamp) VALUES (?, ?, ?, ?)");
|
||||
$stmt->bind_param("iisi", $id, $user_id, $reason, $time);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -40,10 +40,11 @@ try {
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
echo encrypt(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
@@ -55,10 +56,11 @@ if ($result->num_rows != 1) {
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT id FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt->bind_param("si", $token, $id);
|
||||
$stmt = $conn1->prepare("SELECT id FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
echo encrypt(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
@@ -67,10 +69,10 @@ if ($result->num_rows != 1) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$updateStmt = $conn1->prepare("UPDATE userdata SET save_data = ? WHERE token = ? AND id = ?");
|
||||
$updateStmt->bind_param("ssi", $savedata, $token, $id);
|
||||
$updateStmt->execute();
|
||||
$updateStmt->close();
|
||||
$stmt = $conn1->prepare("UPDATE userdata SET save_data = ? WHERE id = ?");
|
||||
$stmt->bind_param("si", $savedata, $id);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
echo encrypt(json_encode(["success" => true]));
|
||||
|
||||
$conn0->close();
|
||||
|
||||
@@ -18,23 +18,23 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
$stmt->close();
|
||||
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE id = ? AND token = ?");
|
||||
$stmt2->bind_param("is", $id, $token);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt = $conn1->prepare("SELECT * FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
if (!$row2) exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
$stmt2->close();
|
||||
|
||||
$content = base64_encode($request_content);
|
||||
$time = time();
|
||||
|
||||
@@ -14,18 +14,20 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result->num_rows != 1) exitWithMessage(json_encode(["success" => false]));
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt2->bind_param("si", $token, $id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt = $conn1->prepare("SELECT * FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) exitWithMessage(json_encode(["success" => false]));
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
|
||||
@@ -1,68 +1,4 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
|
||||
$post = getPostData();
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
$price = (int)$post['price'] ?? 0;
|
||||
$name = $post['name'] ?? '';
|
||||
$name = base64_encode($name);
|
||||
$filecontent = $post['filecontent'] ?? '';
|
||||
|
||||
if ($price < 10) exitWithMessage(json_encode(["success" => false, "message" => "Price cannot be be under 10 coins"]));
|
||||
if (!preg_match('/^[a-zA-Z0-9 ]+$/', base64_decode($name))) exitWithMessage(json_encode(["success" => false, "message" => "Name is invalid"]));
|
||||
if (!$filecontent) exitWithMessage(json_encode(["success" => false, "message" => "Invalid image uploaded"]));
|
||||
$decoded = base64_decode($filecontent, true);
|
||||
if (!$decoded) exitWithMessage(json_encode(["success" => false, "message" => "Invalid image uploaded"]));
|
||||
if (strlen($decoded) > 1024 * 1024) exitWithMessage(json_encode(["success" => false, "message" => "File size exceeds 1 MB limit"]));
|
||||
$info = getimagesizefromstring($decoded);
|
||||
if (!$info) exitWithMessage(json_encode(["success" => false, "message" => "Invalid image uploaded"]));
|
||||
if ($info[2] !== IMAGETYPE_PNG) exitWithMessage(json_encode(["success" => false, "message" => "Image must be a PNG"]));
|
||||
if ($info[0] !== 128 || $info[1] !== 128) exitWithMessage(json_encode(["success" => false, "message" => "Image has to be 128x128"]));
|
||||
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
$stmt->close();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt2->bind_param("si", $token, $id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
if (!$row2) exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
$stmt2->close();
|
||||
|
||||
$time = time();
|
||||
$hash = hash('sha512', base64_decode($filecontent));
|
||||
|
||||
$stmt = $conn1->prepare("SELECT id FROM marketplaceicons WHERE hash = ?");
|
||||
$stmt->bind_param("s", $hash);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
if ($result->fetch_assoc()) {
|
||||
$stmt->close();
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "This icon already exists in the marketplace"]));
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
$uuid = uuidv4();
|
||||
|
||||
$stmt = $conn1->prepare("INSERT INTO marketplaceicons (uuid, userId, data, hash, price, name, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt->bind_param("sissisi", $uuid, $id, $filecontent, $hash, $price, $name, $time);
|
||||
$stmt->execute();
|
||||
$insertId = $conn1->insert_id;
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt(json_encode(["success" => true, "message" => "Icon uploaded successfully! It will be reviewed and accepted or denied soon"]));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to upload a marketplace icon"]));
|
||||
@@ -14,8 +14,8 @@ if ($liked !== 0 && $liked !== 1) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
@@ -27,7 +27,7 @@ $stmt->close();
|
||||
|
||||
$user_id = $row["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT votes, likes FROM userposts WHERE id = ?");
|
||||
$stmt = $conn1->prepare("SELECT votes FROM userposts WHERE id = ?");
|
||||
$stmt->bind_param("i", $targetId);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
@@ -39,7 +39,6 @@ if (!$row) {
|
||||
$stmt->close();
|
||||
|
||||
$votes = json_decode($row["votes"], true) ?? [];
|
||||
$likes = (int)$row["likes"];
|
||||
if (isset($votes[$user_id])) {
|
||||
echo encrypt(json_encode(["success" => false, "message" => 'You have already voted']));
|
||||
exit;
|
||||
|
||||
@@ -3,10 +3,6 @@ function setPlainHeader() {
|
||||
header("Content-Type: text/plain");
|
||||
}
|
||||
|
||||
function setJsonHeader() {
|
||||
header("Content-Type: application/json");
|
||||
}
|
||||
|
||||
function getIPAddress() {
|
||||
return $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user