Backport login account to 1.2-beta2

This commit is contained in:
2025-08-28 11:06:25 -07:00
parent 8f1f6098e3
commit 024ce2fb57
3 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$conn = newConnection();
$request_username = $_POST['username'];
$request_password = $_POST['password'];
$stmt = $conn->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'];
$savedata = json_decode($row['save_data'], true);
$highscore = $savedata['gameStore']['highScore'];
$token = $row['token'];
$stmt = $conn->prepare("UPDATE users SET latest_ip = ? WHERE id = ?");
$stmt->bind_param("si", $login_ip, $uid);
$stmt->execute();
echo "$token:$uid:$highscore";
} else {
$stmt->close();
$conn->close();
exit("-2");
}
}
} else {
$stmt->close();
$conn->close();
exit("-2");
}
$stmt->close();
$conn->close();
?>

View File

@@ -1,6 +1,10 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
if (getClientVersion() == "1.2-beta2") {
require __DIR__ . '/backported/12beta2-loginAccount.php';
exit;
}
checkClientDatabaseVersion(); checkClientDatabaseVersion();
$conn = newConnection(); $conn = newConnection();

View File

@@ -48,6 +48,7 @@ function exitWithMessage($message, $encrypt = true) {
} }
exit; exit;
} }
function getClientVersion() { function getClientVersion() {
return $_SERVER['HTTP_CLIENTVERSION']; return $_SERVER['HTTP_CLIENTVERSION'];
} }