Backported 1.5 save account
This commit is contained in:
47
database/backported/1.5/saveAccount.php
Normal file
47
database/backported/1.5/saveAccount.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
$post = getPostData();
|
||||
$token = $post['gameSession'] ?? '';
|
||||
$username = $post['userName'] ?? '';
|
||||
$highScore = (int)$post['highScore'] ?? 0;
|
||||
$icon = (int)$post['icon'] ?? 1;
|
||||
$overlay = (int)$post['overlay'] ?? 0;
|
||||
$birdR = (int)$post['birdR'] ?? 255;
|
||||
$birdG = (int)$post['birdG'] ?? 255;
|
||||
$birdB = (int)$post['birdB'] ?? 255;
|
||||
$overlayR = (int)$post['overlayR'] ?? 255;
|
||||
$overlayG = (int)$post['overlayG'] ?? 255;
|
||||
$overlayB = (int)$post['overlayB'] ?? 255;
|
||||
$birdColor = [$birdR, $birdG, $birdB];
|
||||
$overlayColor = [$overlayR, $overlayG, $overlayB];
|
||||
|
||||
$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();
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$savedata['bird']['icon'] = $icon;
|
||||
$savedata['bird']['overlay'] = $overlay;
|
||||
$savedata['settings']['colors']['icon'] = $birdColor;
|
||||
$savedata['settings']['colors']['overlay'] = $overlayColor;
|
||||
$savedata = json_encode($savedata);
|
||||
$updateStmt = $conn->prepare("UPDATE users SET legacy_high_score = ?, save_data = ? WHERE token = ? AND username = ?");
|
||||
$updateStmt->bind_param("isss",
|
||||
$highScore,
|
||||
$savedata,
|
||||
$token,
|
||||
$username
|
||||
);
|
||||
$updateStmt->execute();
|
||||
$updateStmt->close();
|
||||
echo encrypt("1");
|
||||
} else {
|
||||
echo encrypt("-1");
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
@@ -12,6 +12,10 @@ if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
require __DIR__ . '/backported/1.2-beta2/syncAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5/saveAccount.php';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user