From 507152c577e568c2ee87ace06c9d41d93ee92f77 Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Sun, 5 Oct 2025 08:54:34 -0700 Subject: [PATCH] 1.3.x almost finished backport --- config/general.php | 2 +- .../1.3-beta2/changeAccountUsername.php | 52 +++++++++++++++++++ .../backported/1.3-beta2/loginAccount.php | 47 +++++++++++++++++ database/changeAccountUsername.php | 4 ++ database/getTopPlayers.php | 2 +- database/loginAccount.php | 7 ++- database/registerAccount.php | 3 +- database/saveAccount.php | 3 +- 8 files changed, 114 insertions(+), 6 deletions(-) create mode 100644 database/backported/1.3-beta2/changeAccountUsername.php create mode 100644 database/backported/1.3-beta2/loginAccount.php diff --git a/config/general.php b/config/general.php index 78870d8..008f754 100644 --- a/config/general.php +++ b/config/general.php @@ -3,4 +3,4 @@ $latestVersion = "1.8.1"; $latestBetaVersion = $latestVersion; $latestLauncherVersion = "1.1.0"; $allowedVersions = [$latestVersion, $latestBetaVersion, "1.8", "1.7.1", "1.7", "1.6.3", "1.6.2", "1.6.1", "1.6", "1.5.2", "1.5.1", "1.5.0", "1.4.1", "1.4.0"]; -$allowedDatabaseVersions = [$latestVersion, $latestBetaVersion, "1.8", "1.7.1", "1.7", "1.6.3", "1.6.2", "1.6.1", "1.6", "1.5.2", "1.5.1", "1.5.0", "1.4.1", "1.4.0", "1.3-beta2", "1.3-beta1", "1.21", "1.2", "1.2-beta2"]; \ No newline at end of file +$allowedDatabaseVersions = [$latestVersion, $latestBetaVersion, "1.8", "1.7.1", "1.7", "1.6.3", "1.6.2", "1.6.1", "1.6", "1.5.2", "1.5.1", "1.5.0", "1.4.1", "1.4.0", "1.33", "1.3", "1.3-beta2", "1.3-beta1", "1.21", "1.2", "1.2-beta2"]; \ No newline at end of file diff --git a/database/backported/1.3-beta2/changeAccountUsername.php b/database/backported/1.3-beta2/changeAccountUsername.php new file mode 100644 index 0000000..6a52588 --- /dev/null +++ b/database/backported/1.3-beta2/changeAccountUsername.php @@ -0,0 +1,52 @@ +prepare("SELECT * FROM users WHERE username = ?"); +$stmt->bind_param("s", $username); + +$stmt->execute(); + +$result = $stmt->get_result(); + +if ($result->num_rows > 0) { + $user = $result->fetch_assoc(); + if (!password_verify($current_password, $user['password'])) { + die("-6"); + } +} else { + die("-7"); +} + +$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("-8"); +} + +$stmt = $conn->prepare("UPDATE users SET username = ? WHERE username = ?"); +$stmt->bind_param("ss", $new_username, $username); + +$stmt->execute(); +$stmt->close(); +$conn->close(); + +echo '1'; + +?> \ No newline at end of file diff --git a/database/backported/1.3-beta2/loginAccount.php b/database/backported/1.3-beta2/loginAccount.php new file mode 100644 index 0000000..82399f3 --- /dev/null +++ b/database/backported/1.3-beta2/loginAccount.php @@ -0,0 +1,47 @@ +prepare("SELECT * FROM users WHERE username = ?"); +$stmt->bind_param("s", $request_username); + +$stmt->execute(); + +$result = $stmt->get_result(); + +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']; + $username = $row['username']; + $highscore = $row['legacy_high_score']; + $token = $row['token']; + $savedata = json_decode($row['save_data'], true); + $icon = $savedata['bird']['icon'] ?? 1; + $overlay = $savedata['bird']['overlay'] ?? 0; + + $stmt = $conn->prepare("UPDATE users SET latest_ip = ? WHERE id = ?"); + $stmt->bind_param("si", $login_ip, $uid); + $stmt->execute(); + + echo "$token:$uid:$highscore:$icon:$overlay"; + } else { + $stmt->close(); + $conn->close(); + exit("-2"); + } + } +} else { + $stmt->close(); + $conn->close(); + exit("-2"); +} + +$stmt->close(); +$conn->close(); + +?> \ No newline at end of file diff --git a/database/changeAccountUsername.php b/database/changeAccountUsername.php index ed3d618..6d0cb89 100644 --- a/database/changeAccountUsername.php +++ b/database/changeAccountUsername.php @@ -6,6 +6,10 @@ if (isAllowedDatabaseVersion(getClientVersion())) { require __DIR__ . '/backported/1.3-beta1/changeAccountUsername.php'; exit; } + if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3") { + require __DIR__ . '/backported/1.3-beta2/changeAccountUsername.php'; + exit; + } } checkClientDatabaseVersion(); $conn = newConnection(); diff --git a/database/getTopPlayers.php b/database/getTopPlayers.php index 0dba29c..126499f 100644 --- a/database/getTopPlayers.php +++ b/database/getTopPlayers.php @@ -2,7 +2,7 @@ require __DIR__ . '/../incl/util.php'; setPlainHeader(); if (isAllowedDatabaseVersion(getClientVersion())) { - if (getClientVersion() == "1.3-beta2") { + if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3") { require __DIR__ . '/backported/1.3-beta2/getTopPlayers.php'; exit; } diff --git a/database/loginAccount.php b/database/loginAccount.php index a797893..33f71a0 100644 --- a/database/loginAccount.php +++ b/database/loginAccount.php @@ -6,12 +6,15 @@ if (isAllowedDatabaseVersion(getClientVersion())) { getClientVersion() == "1.2-beta2" || getClientVersion() == "1.2" || getClientVersion() == "1.21" || - getClientVersion() == "1.3-beta1" || - getClientVersion() == "1.3-beta2" + getClientVersion() == "1.3-beta1" ) { require __DIR__ . '/backported/1.2-beta2/loginAccount.php'; exit; } + if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3") { + require __DIR__ . '/backported/1.3-beta2/loginAccount.php'; + exit; + } if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") { require __DIR__ . '/backported/1.5/loginAccount.php'; exit; diff --git a/database/registerAccount.php b/database/registerAccount.php index 0ffd330..adb3ab7 100644 --- a/database/registerAccount.php +++ b/database/registerAccount.php @@ -9,7 +9,8 @@ if (isAllowedDatabaseVersion(getClientVersion())) { if ( getClientVersion() == "1.21" || getClientVersion() == "1.3-beta1" || - getClientVersion() == "1.3-beta2" + getClientVersion() == "1.3-beta2" || + getClientVersion() == "1.3" ) { require __DIR__ . '/backported/1.21/registerAccount.php'; exit; diff --git a/database/saveAccount.php b/database/saveAccount.php index 554f500..dccdeaf 100644 --- a/database/saveAccount.php +++ b/database/saveAccount.php @@ -7,7 +7,8 @@ if (isAllowedDatabaseVersion(getClientVersion())) { getClientVersion() == "1.2" || getClientVersion() == "1.21" || getClientVersion() == "1.3-beta1" || - getClientVersion() == "1.3-beta2" + getClientVersion() == "1.3-beta2" || + getClientVersion() == "1.3" ) { require __DIR__ . '/backported/1.2-beta2/syncAccount.php'; exit;