diff --git a/config/general.php b/config/general.php index 76ffa3b..77b4efa 100644 --- a/config/general.php +++ b/config/general.php @@ -1,6 +1,6 @@ num_rows > 0) { $updateStmt = $conn->prepare("UPDATE users SET legacy_high_score = ? WHERE token = ? AND id = ?"); $updateStmt->bind_param("isi", $request_score, $request_session, $request_uid); $updateStmt->execute(); - echo 1; + echo "1"; $updateStmt->close(); } else { echo "-3"; diff --git a/database/backported/1.21/registerAccount.php b/database/backported/1.21/registerAccount.php new file mode 100644 index 0000000..4681917 --- /dev/null +++ b/database/backported/1.21/registerAccount.php @@ -0,0 +1,45 @@ +prepare("SELECT id FROM users WHERE username = ? OR email = ?"); +$stmt->bind_param("ss", $username, $email); +$stmt->execute(); +$res = $stmt->get_result(); + +if ($res->num_rows > 0) { + exit("-8"); +} + +$hashed = password_hash($password, PASSWORD_DEFAULT); +$token = bin2hex(random_bytes(256)); +$ip = getIPAddress(); +$time = time(); + +$stmt = $conn->prepare("INSERT INTO users (token, username, password, email, register_time, latest_ip) VALUES (?, ?, ?, ?, ?, ?)"); +$stmt->bind_param("ssssis", $token, $username, $hashed, $email, $time, $ip); +$stmt->execute(); + +$stmt->close(); +$conn->close(); + +echo '1'; \ No newline at end of file diff --git a/database/backported/1.3-beta1/changeAccountUsername.php b/database/backported/1.3-beta1/changeAccountUsername.php new file mode 100644 index 0000000..e81acba --- /dev/null +++ b/database/backported/1.3-beta1/changeAccountUsername.php @@ -0,0 +1,52 @@ +prepare("SELECT * FROM users WHERE id = ?"); +$stmt->bind_param("s", $userID); + +$stmt->execute(); + +$result = $stmt->get_result(); + +if ($result->num_rows > 0) { + $user = $result->fetch_assoc(); + if (!password_verify($current_password, $user['password'])) { + die("-4"); + } +} else { + die("-5"); +} + +$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?"); +$stmt->bind_param("s", $new_username); + +$stmt->execute(); + +$result = $stmt->get_result(); + +if ($result->num_rows > 0) { + die("-6"); +} + +$stmt = $conn->prepare("UPDATE users SET username = ? WHERE id = ?"); +$stmt->bind_param("ss", $new_username, $userID); + +$stmt->execute(); +$stmt->close(); +$conn->close(); + +echo '1'; + +?> \ No newline at end of file diff --git a/database/backported/1.3-beta2/getTopPlayers.php b/database/backported/1.3-beta2/getTopPlayers.php new file mode 100644 index 0000000..af6ca4d --- /dev/null +++ b/database/backported/1.3-beta2/getTopPlayers.php @@ -0,0 +1,48 @@ +prepare("SELECT username, legacy_high_score, id, save_data FROM users WHERE legacy_high_score > 0 AND banned = 0 AND leaderboardsBanned = 0 ORDER BY legacy_high_score DESC LIMIT ?"); +$stmt->bind_param("i", $request_limit); +$stmt->execute(); + +$result = $stmt->get_result(); + +if ($result->num_rows > 0) { + $topPlayers = []; + + while ($row = $result->fetch_assoc()) { + $savedata = json_decode($row['save_data'], true); + $icon = $savedata['bird']['icon'] ?? 1; + $overlay = $savedata['bird']['overlay'] ?? 0; + $topPlayers[] = $row["username"] . ":" . $row["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $row["id"]; + } + + $output = implode("::", $topPlayers); + + echo $output; +} else { + echo -2; +} + +$conn->close(); +?> \ No newline at end of file diff --git a/database/changeAccountUsername.php b/database/changeAccountUsername.php index 17efbb5..ed3d618 100644 --- a/database/changeAccountUsername.php +++ b/database/changeAccountUsername.php @@ -1,6 +1,12 @@