1.4.x backport
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
$conn = newConnection();
|
||||
|
||||
$request_showamount = isset($_POST['showAmount']) ? $_POST['showAmount'] : 0;
|
||||
|
||||
43
database/backported/1.4.0-beta1/getTopPlayers.php
Normal file
43
database/backported/1.4.0-beta1/getTopPlayers.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
$conn = newConnection();
|
||||
|
||||
$request_showamount = isset($_POST['showAmount']) ? $_POST['showAmount'] : 0;
|
||||
|
||||
switch ($request_showamount) {
|
||||
case 1:
|
||||
$request_limit = 100;
|
||||
break;
|
||||
case 2:
|
||||
$request_limit = 250;
|
||||
break;
|
||||
case 3:
|
||||
$request_limit = 500;
|
||||
break;
|
||||
default:
|
||||
$request_limit = 50;
|
||||
break;
|
||||
}
|
||||
|
||||
$stmt = $conn->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[] = base64_encode($row["username"]) . ":" . $row["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $row["id"];
|
||||
}
|
||||
|
||||
echo implode(";", $topPlayers);
|
||||
} else {
|
||||
echo "-1";
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
23
database/backported/1.4.0-beta1/loadAccount.php
Normal file
23
database/backported/1.4.0-beta1/loadAccount.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
$token = $_POST['gameSession'] ?? '';
|
||||
$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();
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$icon = $savedata['bird']['icon'] ?? 1;
|
||||
$overlay = $savedata['bird']['overlay'] ?? 0;
|
||||
echo "1:" . $row['legacy_high_score'] . ":" . $icon . ":" . $overlay;
|
||||
} else {
|
||||
echo "-1";
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
47
database/backported/1.4.0-beta1/loginAccount.php
Normal file
47
database/backported/1.4.0-beta1/loginAccount.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
$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'];
|
||||
$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 "1:$token:$username:$uid:$highscore:$icon:$overlay";
|
||||
} else {
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
exit("-2");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
exit("-2");
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
?>
|
||||
33
database/backported/1.4.0-beta1/saveAccount.php
Normal file
33
database/backported/1.4.0-beta1/saveAccount.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
$conn = newConnection();
|
||||
|
||||
$request_userName = $_POST['userName'] ?? 0;
|
||||
$request_gameSession = $_POST['gameSession'] ?? '';
|
||||
$request_highScore = $_POST['highScore'] ?? 0;
|
||||
$request_icon = $_POST['icon'] ?? 0;
|
||||
$request_overlay = $_POST['overlay'] ?? 0;
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $request_gameSession, $request_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'] = $request_icon;
|
||||
$savedata['bird']['overlay'] = $request_overlay;
|
||||
$savedata = json_encode($savedata);
|
||||
|
||||
$updateStmt = $conn->prepare("UPDATE users SET legacy_high_score = ?, save_data = ? WHERE token = ? AND username = ?");
|
||||
$updateStmt->bind_param("isss", $request_highScore, $savedata, $request_gameSession, $request_userName);
|
||||
$updateStmt->execute();
|
||||
echo "1";
|
||||
$updateStmt->close();
|
||||
} else {
|
||||
echo "-3";
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -4,9 +4,12 @@ require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
|
||||
$clientVersion = $_SERVER['HTTP_CLIENTVERSION'] ?? "0";
|
||||
if (($_SERVER['HTTP_REQUESTER'] ?? "0") != "BerryDashClient" && ($_SERVER['HTTP_USER_AGENT'] ?? "0") != "BerryDashClient" && ($clientVersion == "1.4.1" || $clientVersion == "1.4.0")) {
|
||||
if (($_SERVER['HTTP_REQUESTER'] ?? "0") != "BerryDashClient" && ($_SERVER['HTTP_USER_AGENT'] ?? "0") != "BerryDashClient" && ($clientVersion == "1.4.1" || $clientVersion == "1.4.0" || $clientVersion == "1.4.0-beta1")) {
|
||||
exitWithMessage("-1", false);
|
||||
}
|
||||
if (isAllowedVersion($clientVersion) && $clientVersion == "1.4.0-beta1") {
|
||||
exitWithMessage("1", false);
|
||||
}
|
||||
if (isLatestVersion($clientVersion)) {
|
||||
echo "1";
|
||||
} else if (isBetaVersion($clientVersion)) {
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (getClientVersion() == "0" && isAllowedDatabaseVersion("1.4.0-beta1") && isAllowedDatabaseVersion("1.4.0") && isAllowedDatabaseVersion("1.4.1")) {
|
||||
require __DIR__ . '/backported/1.4.0-beta1/getTopPlayers.php';
|
||||
exit;
|
||||
}
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
require __DIR__ . '/backported/1.3-beta2/getTopPlayers.php';
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.4.0-beta1") {
|
||||
require __DIR__ . '/backported/1.4.0-beta1/loadAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5/loadAccount.php';
|
||||
exit;
|
||||
|
||||
@@ -15,6 +15,10 @@ if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
require __DIR__ . '/backported/1.3-beta2/loginAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.4.0-beta1") {
|
||||
require __DIR__ . '/backported/1.4.0-beta1/loginAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5/loginAccount.php';
|
||||
exit;
|
||||
|
||||
@@ -14,6 +14,10 @@ if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
require __DIR__ . '/backported/1.2-beta2/syncAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.4.0-beta1") {
|
||||
require __DIR__ . '/backported/1.4.0-beta1/saveAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5/saveAccount.php';
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user