Uncompleted backport code and more
This commit is contained in:
@@ -14,7 +14,7 @@ if ($result->num_rows > 0) {
|
||||
$updateStmt = $conn->prepare("UPDATE users SET legacy_high_score = ? WHERE token = ? AND id = ?");
|
||||
$updateStmt->bind_param("isi", $request_score, $request_session, $request_uid);
|
||||
$updateStmt->execute();
|
||||
echo 1;
|
||||
echo "1";
|
||||
$updateStmt->close();
|
||||
} else {
|
||||
echo "-3";
|
||||
|
||||
45
database/backported/1.21/registerAccount.php
Normal file
45
database/backported/1.21/registerAccount.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
$conn = newConnection();
|
||||
|
||||
$username = $_POST['username'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
$email = $_POST['email'] ?? '';
|
||||
|
||||
if (empty($username) || empty($password) || empty($email)) {
|
||||
exit("-2");
|
||||
}
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9]{3,16}$/', $username)) {
|
||||
exit("-3");
|
||||
}
|
||||
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
exit("-4");
|
||||
}
|
||||
|
||||
if (!preg_match('/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!@#$%^&*()_\-+=]{8,}$/', $password)) {
|
||||
exit("-5");
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT id FROM users WHERE username = ? OR email = ?");
|
||||
$stmt->bind_param("ss", $username, $email);
|
||||
$stmt->execute();
|
||||
$res = $stmt->get_result();
|
||||
|
||||
if ($res->num_rows > 0) {
|
||||
exit("-8");
|
||||
}
|
||||
|
||||
$hashed = password_hash($password, PASSWORD_DEFAULT);
|
||||
$token = bin2hex(random_bytes(256));
|
||||
$ip = getIPAddress();
|
||||
$time = time();
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO users (token, username, password, email, register_time, latest_ip) VALUES (?, ?, ?, ?, ?, ?)");
|
||||
$stmt->bind_param("ssssis", $token, $username, $hashed, $email, $time, $ip);
|
||||
$stmt->execute();
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
echo '1';
|
||||
52
database/backported/1.3-beta1/changeAccountUsername.php
Normal file
52
database/backported/1.3-beta1/changeAccountUsername.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
$conn = newConnection();
|
||||
|
||||
$userID = isset($_POST['userID']) ? $_POST['userID'] : '';
|
||||
$current_password = isset($_POST['currentPassword']) ? $_POST['currentPassword'] : '';
|
||||
$new_username = isset($_POST['newUsername']) ? $_POST['newUsername'] : '';
|
||||
|
||||
if (empty($userID) || empty($new_username) || empty($current_password)) {
|
||||
die("-2");
|
||||
}
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9]{3,16}$/', $new_username)) {
|
||||
die("-3");
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE id = ?");
|
||||
$stmt->bind_param("s", $userID);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$user = $result->fetch_assoc();
|
||||
if (!password_verify($current_password, $user['password'])) {
|
||||
die("-4");
|
||||
}
|
||||
} else {
|
||||
die("-5");
|
||||
}
|
||||
|
||||
$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("-6");
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET username = ? WHERE id = ?");
|
||||
$stmt->bind_param("ss", $new_username, $userID);
|
||||
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
echo '1';
|
||||
|
||||
?>
|
||||
48
database/backported/1.3-beta2/getTopPlayers.php
Normal file
48
database/backported/1.3-beta2/getTopPlayers.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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;
|
||||
|
||||
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[] = $row["username"] . ":" . $row["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $row["id"];
|
||||
}
|
||||
|
||||
$output = implode("::", $topPlayers);
|
||||
|
||||
echo $output;
|
||||
} else {
|
||||
echo -2;
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -1,6 +1,12 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.3-beta1") {
|
||||
require __DIR__ . '/backported/1.3-beta1/changeAccountUsername.php';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if ($_SERVER['HTTP_REQUESTER'] == 'BerryDashLauncher') {
|
||||
$request_type = '0';
|
||||
} else {
|
||||
checkClientDatabaseVersion();
|
||||
$post = getPostData();
|
||||
$request_type = $post['type'] ?? '';
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.3-beta2") {
|
||||
require __DIR__ . '/backported/1.3-beta2/getTopPlayers.php';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if ($_SERVER['HTTP_REQUESTER'] != 'BerryDashLauncher') {
|
||||
checkClientDatabaseVersion();
|
||||
}
|
||||
$post = getPostData();
|
||||
$request_type = $post['type'] ?? '';
|
||||
$conn = newConnection();
|
||||
|
||||
$request_value = "";
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
require __DIR__ . '/../incl/general.php';
|
||||
setPlainHeader();
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.2-beta2") {
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.2-beta2/loginAccount.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -2,10 +2,18 @@
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.2-beta2") {
|
||||
if (getClientVersion() == "1.2-beta2" || getClientVersion() == "1.2") {
|
||||
require __DIR__ . '/backported/1.2-beta2/registerAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.21/registerAccount.php';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
|
||||
@@ -2,7 +2,13 @@
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.2-beta2") {
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.2-beta2/syncAccount.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user