A lot of changes (that shouldn't, hopefully be breaking)
This commit is contained in:
@@ -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 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 token, 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 = $row2['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->bind_param("s", $user_id);
|
||||
$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 token = ? AND id = ?");
|
||||
$stmt->bind_param("si", $token, $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();
|
||||
@@ -33,7 +32,7 @@ if ($result2->num_rows != 1) {
|
||||
}
|
||||
|
||||
$updateStmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ? WHERE token = ? AND id = ?");
|
||||
$updateStmt->bind_param("isi", $request_score, $request_session, $request_uid);
|
||||
$updateStmt->bind_param("isi", $high_score, $token, $user_id);
|
||||
$updateStmt->execute();
|
||||
$updateStmt->close();
|
||||
|
||||
|
||||
@@ -4,36 +4,33 @@ $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 ORDER BY legacy_high_score DESC 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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ $stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$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 = ? AND token = ? LIMIT 1");
|
||||
$stmt->bind_param("is", $id, $token);
|
||||
$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";
|
||||
|
||||
@@ -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 = $conn0->prepare("SELECT id FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $request_userName);
|
||||
$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 token = ? AND id = ?");
|
||||
$stmt->bind_param("si", $request_gameSession, $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 token = ? AND id = ?");
|
||||
$stmt->bind_param("issi", $request_highScore, $savedata, $request_gameSession, $request_uid);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
echo "1";
|
||||
@@ -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();
|
||||
$stmt = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $userId);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt2->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);
|
||||
|
||||
@@ -13,9 +13,9 @@ $stmt = $conn->prepare("SELECT id FROM userdata 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);
|
||||
|
||||
@@ -8,59 +8,53 @@ $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 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 token, 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 = $row2['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();
|
||||
$stmt = $conn1->prepare("UPDATE userdata SET token = ? WHERE id = ?");
|
||||
$stmt->bind_param("si", $token, $id);
|
||||
$stmt->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();
|
||||
@@ -19,10 +19,11 @@ $overlayColor = [$overlayR, $overlayG, $overlayB];
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt = $conn0->prepare("SELECT id FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
echo encrypt("-1");
|
||||
@@ -34,10 +35,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 = ? AND token = ?");
|
||||
$stmt->bind_param("is", $id, $token);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
echo encrypt("-1");
|
||||
@@ -53,15 +55,15 @@ $savedata['bird']['overlay'] = $overlay;
|
||||
$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 = ? AND token = ?");
|
||||
$stmt->bind_param("isis",
|
||||
$highScore,
|
||||
$savedata,
|
||||
$id,
|
||||
$token
|
||||
);
|
||||
$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.8.2" || 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"]));
|
||||
@@ -13,14 +13,16 @@ $stmt = $conn0->prepare("SELECT * 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" => 'User info not found']));
|
||||
$row = $result->fetch_assoc();
|
||||
$user_id = $row["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 * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt->bind_param("si", $token, $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();
|
||||
|
||||
@@ -29,6 +31,7 @@ $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]));
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ $stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? LIMIT 1");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row = $result->fetch_assoc();
|
||||
if ($result->num_rows != 1) exit;
|
||||
$stmt->close();
|
||||
|
||||
$user_id = $row["id"];
|
||||
|
||||
@@ -24,8 +24,8 @@ $stmt = $conn1->prepare("SELECT 1 FROM userdata WHERE token = ? AND id = ? LIMIT
|
||||
$stmt->bind_param("si", $token, $user_id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
if ($result2->num_rows != 1) exit;
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) exit;
|
||||
|
||||
$time = time();
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ $stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) exit;
|
||||
$stmt->close();
|
||||
|
||||
$user_id = $row["id"];
|
||||
|
||||
@@ -27,9 +27,9 @@ $stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt2->bind_param("si", $token, $user_id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt->close();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
if (!$row2) exit;
|
||||
$stmt2->close();
|
||||
|
||||
$content = base64_encode($content);
|
||||
|
||||
|
||||
@@ -12,14 +12,16 @@ $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);
|
||||
@@ -55,6 +57,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();
|
||||
|
||||
@@ -47,9 +48,9 @@ foreach ($rows as $row) {
|
||||
$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();
|
||||
@@ -69,22 +69,20 @@ $sql = "
|
||||
";
|
||||
|
||||
$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 [
|
||||
|
||||
@@ -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,7 +61,7 @@ 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;
|
||||
|
||||
@@ -76,9 +72,9 @@ foreach ($rows as $row) {
|
||||
$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();
|
||||
@@ -24,6 +24,7 @@ $stmt = $conn0->prepare("SELECT id, username FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$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, token FROM userdata WHERE id = ? AND token = ?");
|
||||
$stmt->bind_param("is", $id, $token);
|
||||
$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"]));
|
||||
|
||||
@@ -31,44 +31,36 @@ $stmt = $conn0->prepare("SELECT id, username, password 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();
|
||||
$id = $row['id'];
|
||||
|
||||
if (!password_verify($password, $user["password"])) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
|
||||
}
|
||||
$stmt = $conn1->prepare("SELECT token 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, "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'];
|
||||
$token = $result2->fetch_assoc()['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();
|
||||
$stmt = $conn1->prepare("UPDATE userdata SET token = ? WHERE id = ?");
|
||||
$stmt->bind_param("si", $token, $id);
|
||||
$stmt->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"]));
|
||||
@@ -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();
|
||||
@@ -44,6 +44,7 @@ $stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$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"]));
|
||||
@@ -59,6 +60,7 @@ $stmt = $conn1->prepare("SELECT id FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt->bind_param("si", $token, $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 token = ? AND id = ?");
|
||||
$stmt->bind_param("ssi", $savedata, $token, $id);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
echo encrypt(json_encode(["success" => true]));
|
||||
|
||||
$conn0->close();
|
||||
|
||||
@@ -22,19 +22,19 @@ $stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$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 = ? AND token = ?");
|
||||
$stmt->bind_param("is", $id, $token);
|
||||
$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();
|
||||
|
||||
@@ -18,14 +18,16 @@ $stmt = $conn0->prepare("SELECT * 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]));
|
||||
$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 token = ? AND id = ?");
|
||||
$stmt->bind_param("si", $token, $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) exitWithMessage(json_encode(["success" => false]));
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
|
||||
@@ -28,18 +28,18 @@ $stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$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 token = ? AND id = ?");
|
||||
$stmt2->bind_param("si", $token, $id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt = $conn1->prepare("SELECT * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt->bind_param("si", $token, $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();
|
||||
|
||||
$time = time();
|
||||
$hash = hash('sha512', base64_decode($filecontent));
|
||||
@@ -48,19 +48,18 @@ $stmt = $conn1->prepare("SELECT id FROM marketplaceicons WHERE hash = ?");
|
||||
$stmt->bind_param("s", $hash);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
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();
|
||||
$insertId = $conn1->insert_id;
|
||||
|
||||
echo encrypt(json_encode(["success" => true, "message" => "Icon uploaded successfully! It will be reviewed and accepted or denied soon"]));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user