Load & save & fix to login

This commit is contained in:
2025-07-12 21:13:42 -07:00
parent 97c6f5a2f8
commit 25184e1556
3 changed files with 98 additions and 3 deletions

38
database/loadAccount.php Normal file
View File

@@ -0,0 +1,38 @@
<?php
require __DIR__ . '/../incl/util.php';
setJsonHeader();
checkClientDatabaseVersion();
$post = getPostData();
$token = $post['token'] ?? '';
$username = $post['username'] ?? '';
$conn = newConnection();
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
$stmt->bind_param("ss", $token, $username);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
echo encrypt(json_encode([
"success" => true,
"highscore" => (string)$row['highScore'],
"icon" => (int)$row['icon'],
"overlay" => (int)$row['overlay'],
"totalNormalBerries" => (string)$row['totalNormalBerries'],
"totalPoisonBerries" => (string)$row['totalPoisonBerries'],
"totalSlowBerries" => (string)$row['totalSlowBerries'],
"totalUltraBerries" => (string)$row['totalUltraBerries'],
"totalSpeedyBerries" => (string)$row['totalSpeedyBerries'],
"totalAttempts" => (string)$row['totalAttempts'],
"birdColor" => json_decode((string)$row['birdColor']),
"overlayColor" => json_decode((string)$row['overlayColor'])
]));
} else {
echo encrypt(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
}
$stmt->close();
$conn->close();