Compare commits
2
Commits
6bd3adc8f8
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc0b612225
|
||
|
|
92534f959b
|
No files matched your search
@@ -631,7 +631,7 @@ to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
Berry Dash Server Code Copyright (C) 2026 Lncvrt
|
||||
Berry Dash Server Code Copyright (C) 2025 Lncvrt
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -651,7 +651,7 @@ Also add information on how to contact you by electronic and paper mail.
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
Berry Dash Server Code Copyright (C) 2026 Lncvrt
|
||||
Berry Dash Server Code Copyright (C) 2025 Lncvrt
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
@@ -1,8 +1,39 @@
|
||||
# Berry Dash Server
|
||||
|
||||
> [!CAUTION]
|
||||
> This project has been discarded and a new API is under the Lncvrt Games originization.
|
||||
> This project has moved to the Lncvrt Games organization.
|
||||
>
|
||||
> You can find the new server API [here](https://github.com/Lncvrt-Games/api).
|
||||
> You can find the new server API [here](https://git.lncvrt.xyz/Lncvrt-Games/api).
|
||||
|
||||
Legacy Server Source Code
|
||||
---
|
||||
|
||||
This is the source code for Berry Dash.
|
||||
|
||||
## Setup
|
||||
|
||||
> [!CAUTION]
|
||||
> Do not share any keys with anybody, and store them safely on your computer.
|
||||
> Encryption keys are meant to increase the security of the game and prevent cheaters.
|
||||
|
||||
1. Upload the files on a webserver
|
||||
2. Import database.sql into a MySQL/MariaDB database
|
||||
3. Configure everything in `config/` folder (use `python3 genkeys.py` for `encryption.php`)
|
||||
4. Use `git clone https://github.com/BerryDash/source.git` to clone the client and configure `Assets/Scripts/SensitiveInfo.cs`
|
||||
|
||||
**Note:**
|
||||
|
||||
When configuring keys in the client, `SERVER_RECEIVE_TRANSFER_KEY` will the key `SERVER_SEND_TRANSFER_KEY` from the server, and the other way around too.
|
||||
|
||||
If this isn't configured properly, you will not be able to make requests to the server you have setup.
|
||||
|
||||
Example:
|
||||
|
||||
```cs
|
||||
public static readonly string SERVER_DATABASE_PREFIX = "https://berrydash.lncvrt.xyz/database/";
|
||||
public static readonly string SERVER_RECEIVE_TRANSFER_KEY = "02b3c624552588ba0929e43fbad36221"; // This would be `SERVER_SEND_TRANSFER_KEY` from the server
|
||||
public static readonly string SERVER_SEND_TRANSFER_KEY = "d4269db023de05fd59bf05378fa57324"; // This would be `SERVER_RECEIVE_TRANSFER_KEY` from the server
|
||||
public static readonly string BAZOOKA_MANAGER_KEY = "19387a0e6b861e79d38657d0059bce8c";
|
||||
public static readonly string BAZOOKA_MANAGER_FILE_KEY = "7fb47db04d9babf42ee3713289516208";
|
||||
```
|
||||
|
||||
In conclusion: `SERVER_RECEIVE_TRANSFER_KEY` and `SERVER_SEND_TRANSFER_KEY` are swapped between client and server. This may be changed in the future.
|
||||
@@ -1 +0,0 @@
|
||||
Require all denied
|
||||
+5
-10
@@ -1,11 +1,6 @@
|
||||
<?php
|
||||
$games_db_host = "localhost";
|
||||
$games_db_port = 3306;
|
||||
$games_db_user = "";
|
||||
$games_db_pass = "";
|
||||
$games_db_name = "";
|
||||
$bd_db_host = "localhost";
|
||||
$bd_db_port = 3306;
|
||||
$bd_db_user = "";
|
||||
$bd_db_pass = "";
|
||||
$bd_db_name = "";
|
||||
$db_host = "localhost";
|
||||
$db_port = 3306;
|
||||
$db_user = "";
|
||||
$db_pass = "";
|
||||
$db_name = "";
|
||||
@@ -1,3 +1,5 @@
|
||||
<?php
|
||||
$SERVER_RECEIVE_TRANSFER_KEY_SPECIFIC = ["1.5.0" => "67bafe2be3940d1f713b96b3ca4fb852", "1.5.1" => "67bafe2be3940d1f713b96b3ca4fb852", "1.5.2" => "474111bd6b6e16a044f50e464029def6", "1.6" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.6.1" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.6.2" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.6.3" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.7" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.7.1" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.8" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.8.1" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.8.2" => "7bedd0bfd2ea5d4629ea2426b284c0cc"];
|
||||
$SERVER_SEND_TRANSFER_KEY_SPECIFIC = ["1.5.0" => "00490b14efea6a20a1395aa6b83a83c0", "1.5.1" => "00490b14efea6a20a1395aa6b83a83c0", "1.5.2" => "7c734d6f1ea37dc1e1157f8d9c8b588f", "1.6" => "779a4cff3d144649324133495f136b0f", "1.6.1" => "779a4cff3d144649324133495f136b0f", "1.6.2" => "779a4cff3d144649324133495f136b0f", "1.6.3" => "779a4cff3d144649324133495f136b0f", "1.7" => "779a4cff3d144649324133495f136b0f", "1.7.1" => "779a4cff3d144649324133495f136b0f", "1.8" => "779a4cff3d144649324133495f136b0f", "1.8.1" => "779a4cff3d144649324133495f136b0f", "1.8.2" => "dd82c15dc4cfa03f9a06ecffe19cc525"];
|
||||
$SERVER_RECEIVE_TRANSFER_KEY = ""; //SERVER_SEND_TRANSFER_KEY on the client
|
||||
$SERVER_SEND_TRANSFER_KEY = ""; //SERVER_RECEIVE_TRANSFER_KEY on the client
|
||||
$SERVER_RECEIVE_TRANSFER_KEY_SPECIFIC = [];
|
||||
$SERVER_SEND_TRANSFER_KEY_SPECIFIC = [];
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$latestVersion = "1.8.2";
|
||||
$latestBetaVersion = $latestVersion;
|
||||
$latestLauncherVersion = "1.1.0";
|
||||
$allowedVersions = [$latestVersion, $latestBetaVersion, "1.8.1", "1.8", "1.7.1", "1.7", "1.6.3", "1.6.2", "1.6.1", "1.6", "1.5.2", "1.5.1", "1.5.0", "1.4.1", "1.4.0", "1.4.0-beta1"];
|
||||
$allowedDatabaseVersions = [$latestVersion, $latestBetaVersion, "1.8.1", "1.8", "1.7.1", "1.7", "1.6.3", "1.6.2", "1.6.1", "1.6", "1.5.2", "1.5.1", "1.5.0", "1.4.1", "1.4.0", "1.4.0-beta1", "1.33", "1.3", "1.3-beta2", "1.3-beta1", "1.21", "1.2", "1.2-beta2"];
|
||||
+305
@@ -0,0 +1,305 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 5.2.2
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1:3306
|
||||
-- Generation Time: Oct 04, 2025 at 10:18 PM
|
||||
-- Server version: 11.8.3-MariaDB-ubu2404
|
||||
-- PHP Version: 8.1.33
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Database: `berrydashdatabase`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `chatroom_reports`
|
||||
--
|
||||
|
||||
CREATE TABLE `chatroom_reports` (
|
||||
`id` int(11) NOT NULL,
|
||||
`chatId` int(11) NOT NULL,
|
||||
`userId` int(11) NOT NULL,
|
||||
`reason` longtext NOT NULL,
|
||||
`timestamp` bigint(20) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `chats`
|
||||
--
|
||||
|
||||
CREATE TABLE `chats` (
|
||||
`id` int(11) NOT NULL,
|
||||
`userId` int(11) NOT NULL,
|
||||
`content` longtext NOT NULL,
|
||||
`timestamp` bigint(20) NOT NULL,
|
||||
`deleted_at` bigint(1) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `launchercategories`
|
||||
--
|
||||
|
||||
CREATE TABLE `launchercategories` (
|
||||
`id` int(11) NOT NULL,
|
||||
`name` text NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `launcherversions`
|
||||
--
|
||||
|
||||
CREATE TABLE `launcherversions` (
|
||||
`id` int(11) NOT NULL,
|
||||
`version` text NOT NULL,
|
||||
`displayName` text DEFAULT NULL,
|
||||
`releaseDate` bigint(20) NOT NULL,
|
||||
`downloadUrls` text NOT NULL,
|
||||
`platforms` text NOT NULL,
|
||||
`executables` text NOT NULL,
|
||||
`hidden` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`category` int(11) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `marketplaceicons`
|
||||
--
|
||||
|
||||
CREATE TABLE `marketplaceicons` (
|
||||
`id` int(11) NOT NULL,
|
||||
`uuid` text DEFAULT NULL,
|
||||
`userId` int(11) NOT NULL,
|
||||
`data` longtext NOT NULL,
|
||||
`hash` varchar(128) NOT NULL,
|
||||
`timestamp` bigint(20) NOT NULL,
|
||||
`state` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`price` int(11) NOT NULL DEFAULT 0,
|
||||
`name` text NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `presets`
|
||||
--
|
||||
|
||||
CREATE TABLE `presets` (
|
||||
`id` int(11) NOT NULL,
|
||||
`uuid` text DEFAULT NULL,
|
||||
`userId` int(11) NOT NULL,
|
||||
`data` longtext NOT NULL,
|
||||
`timestamp` bigint(20) NOT NULL,
|
||||
`name` text NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `userposts`
|
||||
--
|
||||
|
||||
CREATE TABLE `userposts` (
|
||||
`id` int(11) NOT NULL,
|
||||
`userId` int(11) NOT NULL,
|
||||
`content` text NOT NULL,
|
||||
`timestamp` int(11) NOT NULL,
|
||||
`likes` bigint(20) NOT NULL DEFAULT 0,
|
||||
`deleted_at` int(11) NOT NULL DEFAULT 0,
|
||||
`votes` text NOT NULL DEFAULT '[]'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `users`
|
||||
--
|
||||
|
||||
CREATE TABLE `users` (
|
||||
`id` int(11) NOT NULL,
|
||||
`username` varchar(255) DEFAULT NULL,
|
||||
`password` varchar(60) DEFAULT NULL,
|
||||
`email` varchar(255) DEFAULT NULL,
|
||||
`token` varchar(512) NOT NULL,
|
||||
`latest_ip` varchar(255) DEFAULT NULL,
|
||||
`register_time` int(11) DEFAULT NULL,
|
||||
`banned` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`leaderboardsBanned` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`save_data` longtext NOT NULL DEFAULT '\'{}\'',
|
||||
`legacy_high_score` bigint(20) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED;
|
||||
|
||||
--
|
||||
-- Indexes for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Indexes for table `chatroom_reports`
|
||||
--
|
||||
ALTER TABLE `chatroom_reports`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `userId` (`userId`),
|
||||
ADD KEY `chatId` (`chatId`);
|
||||
|
||||
--
|
||||
-- Indexes for table `chats`
|
||||
--
|
||||
ALTER TABLE `chats`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `fk_userId` (`userId`);
|
||||
|
||||
--
|
||||
-- Indexes for table `launchercategories`
|
||||
--
|
||||
ALTER TABLE `launchercategories`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `launcherversions`
|
||||
--
|
||||
ALTER TABLE `launcherversions`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `fk_category` (`category`);
|
||||
|
||||
--
|
||||
-- Indexes for table `marketplaceicons`
|
||||
--
|
||||
ALTER TABLE `marketplaceicons`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `fk_userId` (`userId`);
|
||||
|
||||
--
|
||||
-- Indexes for table `presets`
|
||||
--
|
||||
ALTER TABLE `presets`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `fk_userId` (`userId`);
|
||||
|
||||
--
|
||||
-- Indexes for table `userposts`
|
||||
--
|
||||
ALTER TABLE `userposts`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `fk_userposts_userId` (`userId`);
|
||||
|
||||
--
|
||||
-- Indexes for table `users`
|
||||
--
|
||||
ALTER TABLE `users`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `chatroom_reports`
|
||||
--
|
||||
ALTER TABLE `chatroom_reports`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `chats`
|
||||
--
|
||||
ALTER TABLE `chats`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `launchercategories`
|
||||
--
|
||||
ALTER TABLE `launchercategories`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `launcherversions`
|
||||
--
|
||||
ALTER TABLE `launcherversions`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `marketplaceicons`
|
||||
--
|
||||
ALTER TABLE `marketplaceicons`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `presets`
|
||||
--
|
||||
ALTER TABLE `presets`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `userposts`
|
||||
--
|
||||
ALTER TABLE `userposts`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `users`
|
||||
--
|
||||
ALTER TABLE `users`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- Constraints for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Constraints for table `chatroom_reports`
|
||||
--
|
||||
ALTER TABLE `chatroom_reports`
|
||||
ADD CONSTRAINT `chatId` FOREIGN KEY (`chatId`) REFERENCES `chats` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `userId` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `chats`
|
||||
--
|
||||
ALTER TABLE `chats`
|
||||
ADD CONSTRAINT `fk_userId` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `launcherversions`
|
||||
--
|
||||
ALTER TABLE `launcherversions`
|
||||
ADD CONSTRAINT `fk_category` FOREIGN KEY (`category`) REFERENCES `launchercategories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `marketplaceicons`
|
||||
--
|
||||
ALTER TABLE `marketplaceicons`
|
||||
ADD CONSTRAINT `fk_marketplaceicons_userId` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `presets`
|
||||
--
|
||||
ALTER TABLE `presets`
|
||||
ADD CONSTRAINT `fk_presets_userId` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `userposts`
|
||||
--
|
||||
ALTER TABLE `userposts`
|
||||
ADD CONSTRAINT `fk_userposts_userId` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
@@ -1 +0,0 @@
|
||||
Require all denied
|
||||
@@ -1,65 +1,44 @@
|
||||
<?php
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$request_username = $_POST['username'];
|
||||
$request_password = $_POST['password'];
|
||||
|
||||
$stmt = $conn0->prepare("SELECT id, username, password, token FROM users WHERE username = ?");
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $request_username);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
if (password_verify($request_password, $row['password'])) {
|
||||
$login_ip = getIPAddress();
|
||||
$login_time = time();
|
||||
$uid = $row['id'];
|
||||
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'];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $uid);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) exitWithMessage("-1", false);
|
||||
$row2 = $result2->fetch_assoc();
|
||||
$stmt = $conn->prepare("UPDATE users SET latest_ip = ? WHERE id = ?");
|
||||
$stmt->bind_param("si", $login_ip, $uid);
|
||||
$stmt->execute();
|
||||
|
||||
$username = $row['username'];
|
||||
$highscore = $row2['legacy_high_score'];
|
||||
$token = $row['token'];
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
$icon = $savedata['bird']['icon'] ?? 1;
|
||||
$overlay = $savedata['bird']['overlay'] ?? 0;
|
||||
|
||||
$stmt = $conn0->prepare("UPDATE users SET latest_ip = ? WHERE id = ?");
|
||||
$stmt->bind_param("si", $login_ip, $uid);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1"
|
||||
) {
|
||||
echo "$token:$uid:$highscore";
|
||||
} else if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
echo "$token:$uid:$highscore:$icon:$overlay";
|
||||
} else if (getClientVersion() == "1.4.0-beta1" || getClientVersion() == "1.4.0" || getClientVersion() == "1.4.1") {
|
||||
echo "1:$token:$username:$uid:$highscore:$icon:$overlay";
|
||||
} else {
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
exit("-2");
|
||||
}
|
||||
} else {
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exitWithMessage("-2", false);
|
||||
}
|
||||
} else {
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exitWithMessage("-2", false);
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
exit("-2");
|
||||
}
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
?>
|
||||
@@ -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("-7");
|
||||
}
|
||||
|
||||
$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';
|
||||
@@ -1,39 +1,25 @@
|
||||
<?php
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$user_id = $_POST['userID'] ?? 0;
|
||||
$token = $_POST['gameSession'] ?? '';
|
||||
$high_score = $_POST['highScore'] ?? 0;
|
||||
$request_uid = $_POST['userID'] ?? 0;
|
||||
$request_session = $_POST['gameSession'] ?? '';
|
||||
$request_score = $_POST['highScore'] ?? 0;
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE id = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $user_id, $token);
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND id = ?");
|
||||
$stmt->bind_param("ss", $request_session, $request_uid);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
if ($result->num_rows != 1) {
|
||||
echo (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") ? "-2" : "-3";
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
}
|
||||
$stmt->close();
|
||||
$user_id = $result->fetch_assoc()["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT * FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $user_id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) {
|
||||
echo (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") ? "-2" : "-3";
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
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";
|
||||
$updateStmt->close();
|
||||
} else {
|
||||
echo "-3";
|
||||
}
|
||||
|
||||
$updateStmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ? WHERE id = ?");
|
||||
$updateStmt->bind_param("ii", $high_score, $user_id);
|
||||
$updateStmt->execute();
|
||||
$updateStmt->close();
|
||||
|
||||
echo "1";
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -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';
|
||||
@@ -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';
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
$conn = newConnection();
|
||||
|
||||
$username = isset($_POST['username']) ? $_POST['username'] : '';
|
||||
$current_password = isset($_POST['currentPassword']) ? $_POST['currentPassword'] : '';
|
||||
$new_username = isset($_POST['newUsername']) ? $_POST['newUsername'] : '';
|
||||
|
||||
if (empty($username) || 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 username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$user = $result->fetch_assoc();
|
||||
if (!password_verify($current_password, $user['password'])) {
|
||||
die("-6");
|
||||
}
|
||||
} else {
|
||||
die("-7");
|
||||
}
|
||||
|
||||
$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("-8");
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET username = ? WHERE username = ?");
|
||||
$stmt->bind_param("ss", $new_username, $username);
|
||||
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
echo '1';
|
||||
|
||||
?>
|
||||
@@ -1,60 +1,45 @@
|
||||
<?php
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn0->prepare("SELECT username, id FROM users WHERE leaderboards_banned = 0");
|
||||
$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();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$topPlayers = [];
|
||||
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$id = $row["id"];
|
||||
$stmt = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? AND legacy_high_score > 0 LIMIT 1");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) continue;
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$icon = $savedata['bird']['icon'] ?? 1;
|
||||
$overlay = $savedata['bird']['overlay'] ?? 0;
|
||||
if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
$topPlayers[] = $row["username"] . ":" . $row2["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $id;
|
||||
} else if (getClientVersion() == "0") {
|
||||
$topPlayers[] = base64_encode($row["username"]) . ":" . $row2["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $id;
|
||||
} else if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
$birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255];
|
||||
$overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255];
|
||||
$topPlayers[] = base64_encode($row["username"]) . ":" . $row2["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $id . ":" . $birdColor[0] . ":" . $birdColor[1] . ":" . $birdColor[2] . ":" . $overlayColor[0] . ":" . $overlayColor[1] . ":" . $overlayColor[2];
|
||||
}
|
||||
$topPlayers[] = $row["username"] . ":" . $row["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $row["id"];
|
||||
}
|
||||
|
||||
usort($topPlayers, function ($a, $b) {
|
||||
$aScore = (int)explode(":", $a)[1];
|
||||
$bScore = (int)explode(":", $b)[1];
|
||||
return $bScore <=> $aScore;
|
||||
});
|
||||
if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
echo implode("::", $topPlayers);
|
||||
} else if (getClientVersion() == "0") {
|
||||
echo implode(";", $topPlayers);
|
||||
} else if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
echo encrypt(implode(";", $topPlayers));
|
||||
}
|
||||
$output = implode("::", $topPlayers);
|
||||
|
||||
echo $output;
|
||||
} else {
|
||||
if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
echo "-2";
|
||||
} else if (getClientVersion() == "0") {
|
||||
echo "-1";
|
||||
} else if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
echo encrypt("-1");
|
||||
}
|
||||
echo -2;
|
||||
}
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -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 "$token:$uid:$highscore:$icon:$overlay";
|
||||
} else {
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
exit("-2");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
exit("-2");
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
?>
|
||||
@@ -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();
|
||||
?>
|
||||
@@ -1,61 +1,23 @@
|
||||
<?php
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
$post = getPostData();
|
||||
$token = $post['gameSession'] ?? '';
|
||||
$username = $post['userName'] ?? '';
|
||||
} else {
|
||||
$token = $_POST['gameSession'] ?? '';
|
||||
$username = $_POST['userName'] ?? '';
|
||||
}
|
||||
$token = $_POST['gameSession'] ?? '';
|
||||
$username = $_POST['userName'] ?? '';
|
||||
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
echo (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") ? encrypt("-1") : "-1";
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT save_data, legacy_high_score FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
echo (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") ? encrypt("-1") : "-1";
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$user2 = $result2->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($user2['save_data'], true);
|
||||
$icon = $savedata['bird']['icon'] ?? 1;
|
||||
$overlay = $savedata['bird']['overlay'] ?? 0;
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
$birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255];
|
||||
$msg = "1:" . $user2['legacy_high_score'] . ":" . $icon . ":" . $overlay . ":0:0:0:0:0:0::" . $birdColor[0] . ":" . $birdColor[1] . ":" . $birdColor[2];
|
||||
if (getClientVersion() == "1.5.2") {
|
||||
$overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255];
|
||||
$msg .= ":" . $overlayColor[0] . ":" . $overlayColor[1] . ":" . $overlayColor[2];
|
||||
}
|
||||
echo encrypt($msg);
|
||||
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:" . $user2['legacy_high_score'] . ":" . $icon . ":" . $overlay;
|
||||
echo "-1";
|
||||
}
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
@@ -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();
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$request_userName = $_POST['userName'] ?? 0;
|
||||
$request_gameSession = $_POST['gameSession'] ?? '';
|
||||
@@ -8,44 +7,27 @@ $request_highScore = $_POST['highScore'] ?? 0;
|
||||
$request_icon = $_POST['icon'] ?? 0;
|
||||
$request_overlay = $_POST['overlay'] ?? 0;
|
||||
|
||||
$stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $request_userName, $request_gameSession);
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $request_gameSession, $request_userName);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
echo "-2";
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
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";
|
||||
}
|
||||
|
||||
$request_uid = $result->fetch_assoc()["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $request_uid);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
echo (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") ? "-2" : "-3";
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
$savedata['bird']['icon'] = $request_icon;
|
||||
$savedata['bird']['overlay'] = $request_overlay;
|
||||
$savedata = json_encode($savedata);
|
||||
|
||||
$stmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ?, save_data = ? WHERE id = ?");
|
||||
$stmt->bind_param("isi", $request_highScore, $savedata, $request_uid);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
echo "1";
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -1,48 +1,31 @@
|
||||
<?php
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn1 ->prepare("
|
||||
SELECT id, content, userId
|
||||
FROM chats
|
||||
WHERE deleted_at = 0
|
||||
ORDER BY id DESC LIMIT 49
|
||||
$stmt = $conn->prepare("
|
||||
SELECT c.id AS chat_id, c.content, u.username, u.id AS user_id, u.save_data
|
||||
FROM chats c
|
||||
JOIN users u ON c.userId = u.id
|
||||
WHERE u.banned = 0 AND c.deleted_at = 0
|
||||
ORDER BY c.id DESC LIMIT 50
|
||||
");
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
$rows = [];
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$userId = $row["userId"];
|
||||
$stmt = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $userId);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) continue;
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$stmt = $conn0->prepare("SELECT username FROM users WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $userId);
|
||||
$stmt->execute();
|
||||
$result3 = $stmt->get_result();
|
||||
if ($result3->num_rows != 1) continue;
|
||||
$stmt->close();
|
||||
$row3 = $result3->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$icon = $savedata['bird']['icon'] ?? 1;
|
||||
$overlay = $savedata['bird']['overlay'] ?? 0;
|
||||
$birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255];
|
||||
$overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255];
|
||||
|
||||
$rows[] = implode(";", [
|
||||
$row['id'],
|
||||
base64_encode($row3['username']),
|
||||
$row['chat_id'],
|
||||
base64_encode($row['username']),
|
||||
$row['content'],
|
||||
$icon,
|
||||
$overlay,
|
||||
$userId,
|
||||
$row['user_id'],
|
||||
$birdColor[0],
|
||||
$birdColor[1],
|
||||
$birdColor[2],
|
||||
@@ -52,7 +35,6 @@ while ($row = $result->fetch_assoc()) {
|
||||
]);
|
||||
}
|
||||
|
||||
echo encrypt("1:" . implode("|", array_reverse($rows)));
|
||||
echo encrypt("1" . ":" . implode("|", array_reverse($rows)));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
@@ -7,27 +7,25 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
|
||||
exitWithMessage("-1");
|
||||
}
|
||||
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn0->prepare("SELECT id FROM users WHERE token = ?");
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ?");
|
||||
$stmt->bind_param("s", $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) exitWithMessage("-1");
|
||||
$stmt->close();
|
||||
|
||||
$id = $row["id"];
|
||||
$content = base64_encode($request_content);
|
||||
$time = time();
|
||||
|
||||
$stmt = $conn1->prepare("INSERT INTO chats (userId, content, timestamp) VALUES (?, ?, ?)");
|
||||
$stmt = $conn->prepare("INSERT INTO chats (userId, content, timestamp) VALUES (?, ?, ?)");
|
||||
$stmt->bind_param("isi", $id, $content, $time);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt("1");
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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;
|
||||
$birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255];
|
||||
$overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255];
|
||||
$topPlayers[] = base64_encode($row["username"]) . ":" . $row["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $row["id"] . ":" . $birdColor[0] . ":" . $birdColor[1] . ":" . $birdColor[2] . ":" . $overlayColor[0] . ":" . $overlayColor[1] . ":" . $overlayColor[2];
|
||||
}
|
||||
|
||||
$output = implode(";", $topPlayers);
|
||||
|
||||
echo encrypt($output);
|
||||
} else {
|
||||
echo encrypt("-1");
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
$post = getPostData();
|
||||
$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;
|
||||
$birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255];
|
||||
$overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255];
|
||||
echo encrypt("1" . ":" . $row['legacy_high_score'] . ":" . $icon . ":" . $overlay . ":0:0:0:0:0:0:" . ":" . $birdColor[0] . ":" . $birdColor[1] . ":" . $birdColor[2] . ":" . $overlayColor[0] . ":" . $overlayColor[1] . ":" . $overlayColor[2]);
|
||||
} else {
|
||||
echo encrypt("-1");
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$post = getPostData();
|
||||
$username = $post['username'];
|
||||
@@ -8,49 +7,44 @@ $password = $post['password'];
|
||||
$currentHighScore = $post['currentHighScore'] ?? 0;
|
||||
$loginType = $post['loginType'] ?? '0';
|
||||
|
||||
$stmt = $conn0->prepare("SELECT id, username, password, token FROM users WHERE username = ?");
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result->num_rows != 1) exitWithMessage("-1");
|
||||
$row = $result->fetch_assoc();
|
||||
|
||||
if (!password_verify($password, $row["password"])) exitWithMessage("-1");
|
||||
|
||||
$id = $row['id'];
|
||||
$stmt = $conn1->prepare("SELECT legacy_high_score FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) exitWithMessage("-1");
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$token = $row['token'];
|
||||
$ip = getIPAddress();
|
||||
|
||||
$stmt = $conn0->prepare("UPDATE users SET latest_ip = ?, token = ? WHERE id = ?");
|
||||
$stmt->bind_param("ssi", $ip, $token, $id);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
if ($currentHighScore > $row2['legacy_high_score']) {
|
||||
$stmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ? WHERE id = ?");
|
||||
$stmt->bind_param("ii", $currentHighScore, $id);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
$row2['legacy_high_score'] = $currentHighScore;
|
||||
if ($result->num_rows === 0) {
|
||||
exitWithMessage("-1");
|
||||
}
|
||||
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$user = $result->fetch_assoc();
|
||||
|
||||
if (!password_verify($password, $user["password"])) {
|
||||
exitWithMessage("-1");
|
||||
}
|
||||
|
||||
$id = $user['id'];
|
||||
$token = $user['token'];
|
||||
$ip = getIPAddress();
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET latest_ip = ?, token = ? WHERE id = ?");
|
||||
$stmt->bind_param("ssi", $ip, $token, $id);
|
||||
$stmt->execute();
|
||||
|
||||
if ($currentHighScore > $user['legacy_high_score']) {
|
||||
$stmt = $conn->prepare("UPDATE users SET legacy_high_score = ? WHERE id = ?");
|
||||
$stmt->bind_param("ii", $currentHighScore, $id);
|
||||
$stmt->execute();
|
||||
$user['legacy_high_score'] = $currentHighScore;
|
||||
}
|
||||
|
||||
$savedata = json_decode($user['save_data'], true);
|
||||
$birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255];
|
||||
$overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255];
|
||||
|
||||
if ($loginType === "0") {
|
||||
echo encrypt("1:" . $token . ":" . $row['username'] . ":" . $id . ":" . $row2['legacy_high_score'] . ":" . ($savedata['bird']['icon'] ?? 1) . ":" . ($savedata['bird']['overlay'] ?? 0) . ":0:0:0:0:0::" . $birdColor[0] . ":" . $birdColor[1] . ":" . $birdColor[2] . ":" . $overlayColor[0] . ":" . $overlayColor[1] . ":" . $overlayColor[2]);
|
||||
echo encrypt("1" . ":" . $token . ":" . $user['username'] . ":" . $id . ":" . $user['legacy_high_score'] . ":" . ($savedata['bird']['icon'] ?? 1) . ":" . ($savedata['bird']['overlay'] ?? 0) . ":0:0:0:0:0:" . ":" . $birdColor[0] . ":" . $birdColor[1] . ":" . $birdColor[2] . ":" . $overlayColor[0] . ":" . $overlayColor[1] . ":" . $overlayColor[2]);
|
||||
} elseif ($loginType === "1") {
|
||||
echo encrypt("1:" . $token . ":" . $row['username'] . ":" . $id);
|
||||
echo encrypt("1" . ":" . $token . ":" . $user['username'] . ":" . $id);
|
||||
}
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
$conn = newConnection();
|
||||
|
||||
$post = getPostData();
|
||||
$username = $post['username'] ?? '';
|
||||
$password = $post['password'] ?? '';
|
||||
$email = $post['email'] ?? '';
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9]{3,16}$/', $username)) {
|
||||
exitWithMessage("-1");
|
||||
}
|
||||
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
exitWithMessage("-2");
|
||||
}
|
||||
|
||||
if (!preg_match('/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!@#$%^&*()_\-+=]{8,}$/', $password)) {
|
||||
exitWithMessage("-3");
|
||||
}
|
||||
|
||||
$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) {
|
||||
exitWithMessage("-4");
|
||||
}
|
||||
|
||||
$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 encrypt("1");
|
||||
@@ -5,66 +5,43 @@ $username = $post['userName'] ?? '';
|
||||
$highScore = (int)$post['highScore'] ?? 0;
|
||||
$icon = (int)$post['icon'] ?? 1;
|
||||
$overlay = (int)$post['overlay'] ?? 0;
|
||||
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
$birdR = (int)$post['birdR'] ?? 255;
|
||||
$birdG = (int)$post['birdG'] ?? 255;
|
||||
$birdB = (int)$post['birdB'] ?? 255;
|
||||
$birdColor = [$birdR, $birdG, $birdB];
|
||||
}
|
||||
if (getClientVersion() == "1.5.2") {
|
||||
$overlayR = (int)$post['overlayR'] ?? 255;
|
||||
$overlayG = (int)$post['overlayG'] ?? 255;
|
||||
$overlayB = (int)$post['overlayB'] ?? 255;
|
||||
$overlayColor = [$overlayR, $overlayG, $overlayB];
|
||||
}
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$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];
|
||||
|
||||
$stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
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");
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
echo encrypt("-1");
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$row2 = $result2->fetch_assoc();
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
$savedata['bird']['icon'] = $icon;
|
||||
$savedata['bird']['overlay'] = $overlay;
|
||||
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") $savedata['settings']['colors']['icon'] = $birdColor;
|
||||
if (getClientVersion() == "1.5.2") $savedata['settings']['colors']['overlay'] = $overlayColor;
|
||||
$savedata = json_encode($savedata);
|
||||
$stmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ?, save_data = ? WHERE id = ?");
|
||||
$stmt->bind_param("isi",
|
||||
$highScore,
|
||||
$savedata,
|
||||
$id
|
||||
);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
echo encrypt("1");
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
@@ -1,4 +1,23 @@
|
||||
<?php
|
||||
require __DIR__ . '/../config/general.php';
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
echo getClientVersion() == "1.4.0-beta1" ? "1" : "2";
|
||||
|
||||
$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" || $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)) {
|
||||
echo "4";
|
||||
} else if (isAllowedVersion($clientVersion) && isAllowedDatabaseVersion($clientVersion)) {
|
||||
echo "2";
|
||||
} else if (isAllowedVersion($clientVersion)) {
|
||||
echo "3";
|
||||
} else {
|
||||
echo "-1";
|
||||
}
|
||||
@@ -1,22 +1,45 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3" ||
|
||||
getClientVersion() == "1.33" ||
|
||||
getClientVersion() == "1.4.0-beta1" ||
|
||||
getClientVersion() == "1.4.0" ||
|
||||
getClientVersion() == "1.4.1" ||
|
||||
getClientVersion() == "1.5.0" ||
|
||||
getClientVersion() == "1.5.1" ||
|
||||
getClientVersion() == "1.5.2"
|
||||
) {
|
||||
exitWithMessage("-1", getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2");
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
|
||||
$post = getPostData();
|
||||
$oldpassword = $post['oldpassword'] ?? '';
|
||||
$newpassword = $post['newpassword'] ?? '';
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
|
||||
if (!preg_match('/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!@#$%^&*()_\-+=]{8,}$/', $newpassword)) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "New password must be at least 8 characters with at least one letter and one number"]));
|
||||
}
|
||||
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to change your password in game"]));
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$user = $result->fetch_assoc();
|
||||
if (!password_verify($oldpassword, $user['password'])) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Old password is incorrect"]));
|
||||
}
|
||||
if (password_verify($newpassword, $user['password'])) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "New password cannot be the same as the old password"]));
|
||||
}
|
||||
$id = $user['id'];
|
||||
} else {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
}
|
||||
|
||||
$hashednewpassword = password_hash($newpassword, PASSWORD_DEFAULT);
|
||||
$token = bin2hex(random_bytes(256));
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET token = ?, password = ? WHERE id = ?");
|
||||
$stmt->bind_param("sss", $token, $hashednewpassword, $id);
|
||||
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
echo encrypt(json_encode(["success" => true, "token" => $token]));
|
||||
@@ -1,22 +1,53 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3" ||
|
||||
getClientVersion() == "1.33" ||
|
||||
getClientVersion() == "1.4.0-beta1" ||
|
||||
getClientVersion() == "1.4.0" ||
|
||||
getClientVersion() == "1.4.1" ||
|
||||
getClientVersion() == "1.5.0" ||
|
||||
getClientVersion() == "1.5.1" ||
|
||||
getClientVersion() == "1.5.2"
|
||||
) {
|
||||
exitWithMessage("-1", getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2");
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.3-beta1") {
|
||||
require __DIR__ . '/backported/1.3-beta1/changeAccountUsername.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
require __DIR__ . '/backported/1.3-beta2/changeAccountUsername.php';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
|
||||
$post = getPostData();
|
||||
$oldusername = $post['oldusername'] ?? '';
|
||||
$newusername = $post['newusername'] ?? '';
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9]{3,16}$/', $newusername)) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "New username must be 3-16 characters, letters and numbers only"]));
|
||||
}
|
||||
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to change your username in game"]));
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $newusername);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "New username already exists"]));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $oldusername, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows === 0) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid old username"]));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET username = ? WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("sss", $newusername, $username, $token);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->affected_rows === 0) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
}
|
||||
|
||||
echo encrypt(json_encode(["success" => true]));
|
||||
@@ -1,37 +1,35 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
|
||||
$post = getPostData();
|
||||
$targetId = (int)$post['targetId'] ?? 0;
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
|
||||
$stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) {
|
||||
echo encrypt(json_encode(["success" => false, "message" => 'User info not found']));
|
||||
exit;
|
||||
}
|
||||
$stmt->close();
|
||||
if ($result->num_rows != 1) exitWithMessage(json_encode(["success" => false, "message" => 'User info not found']));
|
||||
$user_id = $result->fetch_assoc()["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT 1 FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $user_id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) exitWithMessage(json_encode(["success" => false, "message" => 'User info not found']));
|
||||
|
||||
$user_id = $row["id"];
|
||||
$time = time();
|
||||
|
||||
$stmt = $conn1->prepare("UPDATE userposts SET deleted_at = ? WHERE id = ? AND userId = ? AND deleted_at = 0");
|
||||
$stmt = $conn->prepare("UPDATE userposts SET deleted_at = ? WHERE id = ? AND userId = ? AND deleted_at = 0");
|
||||
$stmt->bind_param("iii", $time, $targetId, $user_id);
|
||||
$stmt->execute();
|
||||
|
||||
$success = $stmt->affected_rows > 0;
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt(json_encode(["success" => $stmt->affected_rows > 0]));
|
||||
echo encrypt(json_encode(["success" => $success]));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
@@ -1,38 +1,29 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$id = $post['id'] ?? '';
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? AND token = ? LIMIT 1");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row = $result->fetch_assoc();
|
||||
if ($result->num_rows != 1) exit;
|
||||
if (!$row) exit;
|
||||
$stmt->close();
|
||||
|
||||
$user_id = $row["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT 1 FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $user_id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) exit;
|
||||
|
||||
$time = time();
|
||||
|
||||
$stmt = $conn1->prepare("UPDATE chats SET deleted_at = ? WHERE userId = ? AND id = ?");
|
||||
$stmt = $conn->prepare("UPDATE chats SET deleted_at = ? WHERE userId = ? AND id = ?");
|
||||
$stmt->bind_param("iii", $time, $user_id, $id);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$id = $post['id'] ?? '';
|
||||
@@ -10,33 +11,22 @@ $username = $post['username'] ?? '';
|
||||
|
||||
if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~]+$/', $content)) exit;
|
||||
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) exit;
|
||||
$stmt->close();
|
||||
|
||||
$user_id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT 1 FROM userdata WHERE id = ?");
|
||||
$stmt2->bind_param("i", $user_id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$stmt->close();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
if (!$row2) exit;
|
||||
|
||||
$content = base64_encode($content);
|
||||
|
||||
$stmt = $conn1->prepare("UPDATE chats SET content = ? WHERE userId = ? AND id = ?");
|
||||
$stmt = $conn->prepare("UPDATE chats SET content = ? WHERE userId = ? AND id = ?");
|
||||
$stmt->bind_param("sii", $content, $user_id, $id);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
@@ -1,47 +1,31 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$uesrId = $post['uesrId'] ?? '';
|
||||
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn0->prepare("SELECT username, id FROM users WHERE id = ?");
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE id = ?");
|
||||
$stmt->bind_param("i", $uesrId);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
|
||||
$stmt = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $row['id']);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
$custom = isset($savedata['bird']['customIcon']['selected']) ?? null;
|
||||
|
||||
$customIcon = $savedata['bird']['customIcon']['selected'] ?? null;
|
||||
$icon = null;
|
||||
|
||||
if ($customIcon != null && strlen($customIcon) == 36) {
|
||||
$stmt = $conn1->prepare("SELECT data FROM marketplaceicons WHERE id = ?");
|
||||
$stmt->bind_param("s", $customIcon);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$rowData = $result->fetch_assoc();
|
||||
if ($rowData) {
|
||||
$icon = $rowData["data"];
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$custom = null;
|
||||
if (isset($savedata['bird']['customIcon']['selected'])) {
|
||||
$selected = $savedata['bird']['customIcon']['selected'];
|
||||
foreach ($savedata['bird']['customIcon']['data'] as $entry) {
|
||||
if (isset($entry['uuid']) && $entry['uuid'] === $selected) {
|
||||
$custom = $entry['data'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo encrypt(json_encode([
|
||||
"success" => true,
|
||||
"totalNormalBerries" => $savedata['gameStore']['totalNormalBerries'] ?? 0,
|
||||
@@ -56,7 +40,7 @@ if ($result->num_rows > 0) {
|
||||
"name" => $row['username'],
|
||||
"icon" => $savedata['bird']['icon'] ?? 1,
|
||||
"overlay" => $savedata['bird']['overlay'] ?? 0,
|
||||
"customIcon" => $icon,
|
||||
"customIcon" => $custom,
|
||||
"playerIconColor" => $savedata['settings']['colors']['icon'] ?? [255,255,255],
|
||||
"playerOverlayColor" => $savedata['settings']['colors']['overlay'] ?? [255,255,255]
|
||||
]));
|
||||
@@ -64,5 +48,5 @@ if ($result->num_rows > 0) {
|
||||
echo encrypt(json_encode(["success" => false]));
|
||||
}
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
@@ -1,36 +1,23 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
|
||||
$post = getPostData();
|
||||
$targetId = (int)$post['targetId'] ?? 0;
|
||||
|
||||
$stmt = $conn->prepare("
|
||||
SELECT id, content, timestamp, votes, userId
|
||||
FROM userposts
|
||||
WHERE userId = ? AND deleted_at = 0
|
||||
ORDER BY id DESC
|
||||
SELECT p.id, p.content, p.timestamp, p.likes, u.id as userId
|
||||
FROM userposts p
|
||||
JOIN users u ON p.userId = u.id
|
||||
WHERE u.id = ? AND p.deleted_at = 0
|
||||
ORDER BY p.id DESC
|
||||
");
|
||||
$stmt->bind_param("i", $targetId);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt(json_encode(array_map(
|
||||
function ($row) {
|
||||
$votes = json_decode($row['votes'], true);
|
||||
$likes = is_array($votes) ? array_sum(array_map(fn($v) => $v === true ? 1 : -1, $votes)) : 0;
|
||||
|
||||
return [
|
||||
'id' => $row['id'],
|
||||
'userId' => $row['userId'],
|
||||
'content' => $row['content'],
|
||||
'timestamp' => genTimestamp($row['timestamp']) . " ago",
|
||||
'likes' => $likes
|
||||
];
|
||||
},
|
||||
$result->fetch_all(MYSQLI_ASSOC)
|
||||
)));
|
||||
echo encrypt(json_encode(array_map(fn($row) => ['id' => $row['id'], 'userId' => $row['userId'], 'content' => $row['content'], 'timestamp' => genTimestamp($row['timestamp']) . " ago", 'likes' => $row['likes']], $result->fetch_all(MYSQLI_ASSOC))));
|
||||
|
||||
$conn->close();
|
||||
@@ -1,66 +1,53 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5.1/getChatroomMessages.php';
|
||||
exit;
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5.1/getChatroomMessages.php';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn1->prepare("
|
||||
SELECT id, content, deleted_at, userId
|
||||
FROM chats
|
||||
WHERE deleted_at = 0
|
||||
ORDER BY id DESC
|
||||
$stmt = $conn->prepare("
|
||||
SELECT c.id AS chat_id, c.content, c.deleted_at, u.id AS user_id, u.username, u.save_data
|
||||
FROM chats c
|
||||
JOIN users u ON c.userId = u.id
|
||||
WHERE u.banned = 0 AND c.deleted_at = 0
|
||||
ORDER BY c.id DESC
|
||||
LIMIT 50
|
||||
");
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$rows = $result->fetch_all(MYSQLI_ASSOC);
|
||||
|
||||
$mapped = [];
|
||||
$icons = [];
|
||||
foreach ($result->fetch_all(mode: MYSQLI_ASSOC) as $row) {
|
||||
$userId = $row["userId"];
|
||||
$stmt = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $userId);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) continue;
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$stmt = $conn0->prepare("SELECT username FROM users WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $userId);
|
||||
$stmt->execute();
|
||||
$result3 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result3->num_rows != 1) continue;
|
||||
$row3 = $result3->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
foreach ($rows as $row) {
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
|
||||
$customIcon = $savedata['bird']['customIcon']['selected'] ?? null;
|
||||
|
||||
if ($customIcon != null && strlen($customIcon) == 36 && $icons[$customIcon] == null) {
|
||||
$stmt = $conn1->prepare("SELECT data FROM marketplaceicons WHERE id = ?");
|
||||
$stmt = $conn->prepare("SELECT data FROM marketplaceicons WHERE uuid = ?");
|
||||
$stmt->bind_param("s", $customIcon);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$rowData = $result->fetch_assoc();
|
||||
if ($rowData) {
|
||||
$stmt->close();
|
||||
$icons[$customIcon] = $rowData["data"];
|
||||
}
|
||||
}
|
||||
|
||||
$mapped[] = [
|
||||
'username' => $row3['username'],
|
||||
'userid' => $row['userId'],
|
||||
'username' => $row['username'],
|
||||
'userid' => $row['user_id'],
|
||||
'content' => (int)$row['deleted_at'] == 0 ? $row['content'] : null,
|
||||
'deleted' => (int)$row['deleted_at'] != 0,
|
||||
'id' => $row['id'],
|
||||
'id' => $row['chat_id'],
|
||||
'icon' => $savedata['bird']['icon'] ?? 1,
|
||||
'overlay' => $savedata['bird']['overlay'] ?? 0,
|
||||
'birdColor' => $savedata['settings']['colors']['icon'] ?? [255,255,255],
|
||||
@@ -70,7 +57,10 @@ foreach ($result->fetch_all(mode: MYSQLI_ASSOC) as $row) {
|
||||
}
|
||||
|
||||
|
||||
echo encrypt(json_encode(getClientVersion() == "1.6" ? $mapped : ["messages" => array_reverse($mapped), "customIcons" => $icons == [] ? new stdClass() : $icons]));
|
||||
if (getClientVersion() == "1.6") {
|
||||
echo encrypt(json_encode($mapped));
|
||||
} else {
|
||||
echo encrypt(json_encode(["messages" => array_reverse($mapped), "customIcons" => $icons == [] ? new stdClass() : $icons]));
|
||||
}
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setJsonHeader();
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn->prepare("
|
||||
SELECT c.id, c.content, u.username
|
||||
FROM chats c
|
||||
JOIN users u ON c.userId = u.id
|
||||
WHERE u.banned = 0 AND c.deleted_at = 0
|
||||
ORDER BY c.id ASC LIMIT 50
|
||||
");
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
echo json_encode(array_map(fn($row) => ['username' => $row['username'], 'content' => base64_decode($row['content']), 'contentRaw' => $row['content'], 'messageId' => $row['id']], $result->fetch_all(MYSQLI_ASSOC)), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
|
||||
$conn->close();
|
||||
@@ -1,14 +1,5 @@
|
||||
<?php
|
||||
require __DIR__ . '/../config/general.php';
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
|
||||
$conn0 = newConnection(0);
|
||||
|
||||
$stmt = $conn0->prepare("SELECT downloadUrlVersion FROM launcherversionmanifest WHERE HIDDEN = 0 AND game = 1 ORDER BY place DESC LIMIT 1");
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row = $result->fetch_assoc();
|
||||
$conn0->close();
|
||||
|
||||
echo $row["downloadUrlVersion"] ?? 'N/A';
|
||||
echo $latestVersion;
|
||||
@@ -1,101 +1,83 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
|
||||
$post = getPostData();
|
||||
$userId = (int) $post['userId'] ?? 0;
|
||||
$sortBy = (int) $post['sortBy'] ?? 2;
|
||||
$priceRangeEnabled = isset($post['priceRangeEnabled']) ? (string) $post['priceRangeEnabled'] == 'False' ? false : true : false;
|
||||
$priceRangeMin = (int) $post['priceRangeMin'] ?? 10;
|
||||
$priceRangeMax = (int) $post['priceRangeMax'] ?? 250;
|
||||
$searchForEnabled = isset($post['searchForEnabled']) ? (string) $post['searchForEnabled'] == 'False' ? false : true : false;
|
||||
$searchForValue = (string) $post['searchForValue'] ?? '';
|
||||
$onlyShowEnabled = isset($post['onlyShowEnabled']) ? (string) $post['onlyShowEnabled'] == 'False' ? false : true : false;
|
||||
$onlyShowValue = (string) $post['onlyShowValue'] ?? '';
|
||||
$currentIcons = json_decode(base64_decode((string) ($post['currentIcons'] ?? 'W10K')));
|
||||
$userId = (int)$post['userId'] ?? 0;
|
||||
$sortBy = (int)$post['sortBy'] ?? 2;
|
||||
$priceRangeEnabled = isset($post['priceRangeEnabled']) ? (string)$post['priceRangeEnabled'] == 'False' ? false : true : false;
|
||||
$priceRangeMin = (int)$post['priceRangeMin'] ?? 10;
|
||||
$priceRangeMax = (int)$post['priceRangeMax'] ?? 250;
|
||||
$searchForEnabled = isset($post['searchForEnabled']) ? (string)$post['searchForEnabled'] == 'False' ? false : true : false;
|
||||
$searchForValue = (string)$post['searchForValue'] ?? '';
|
||||
$onlyShowEnabled = isset($post['onlyShowEnabled']) ? (string)$post['onlyShowEnabled'] == 'False' ? false : true : false;
|
||||
$onlyShowValue = (string)$post['onlyShowValue'] ?? '';
|
||||
$currentIcons = json_decode(base64_decode((string)($post['currentIcons'] ?? 'W10K')));
|
||||
|
||||
$where = ["state = 1"];
|
||||
$where = ["u.banned = 0", "(c.state = 1 OR c.state = 2)"];
|
||||
$params = [];
|
||||
$types = "";
|
||||
$order = match ($sortBy) {
|
||||
1 => "ORDER BY price ASC",
|
||||
2 => "ORDER BY id ASC",
|
||||
3 => "ORDER BY id DESC",
|
||||
default => "ORDER BY price DESC",
|
||||
$order = match($sortBy) {
|
||||
1 => "ORDER BY c.price ASC",
|
||||
2 => "ORDER BY c.id ASC",
|
||||
3 => "ORDER BY c.id DESC",
|
||||
default => "ORDER BY c.price DESC",
|
||||
};
|
||||
|
||||
if ($priceRangeEnabled) {
|
||||
$where[] = "price BETWEEN ? AND ?";
|
||||
$where[] = "c.price BETWEEN ? AND ?";
|
||||
$params[] = $priceRangeMin;
|
||||
$params[] = $priceRangeMax;
|
||||
$types .= "ii";
|
||||
}
|
||||
|
||||
if ($searchForEnabled && $searchForValue !== '') {
|
||||
$where[] = "FROM_BASE64(name) LIKE ?";
|
||||
$where[] = "FROM_BASE64(c.name) LIKE ?";
|
||||
$params[] = "%$searchForValue%";
|
||||
$types .= "s";
|
||||
}
|
||||
|
||||
if ($onlyShowEnabled) {
|
||||
if ($onlyShowValue === '0') {
|
||||
$where[] = "userId = ?";
|
||||
$where[] = "c.userId = ?";
|
||||
$params[] = $userId;
|
||||
$types .= "i";
|
||||
} elseif ($onlyShowValue === '1') {
|
||||
$where[] = "userId != ?";
|
||||
$where[] = "c.userId != ?";
|
||||
$params[] = $userId;
|
||||
$types .= "i";
|
||||
} elseif ($onlyShowValue === '2') {
|
||||
$placeholders = implode(',', array_fill(0, count($currentIcons), '?'));
|
||||
$where[] = "uuid IN ($placeholders)";
|
||||
$where[] = "c.uuid IN ($placeholders)";
|
||||
$params = array_merge($params, $currentIcons);
|
||||
$types .= str_repeat('s', count($currentIcons));
|
||||
} elseif ($onlyShowValue === '3') {
|
||||
$placeholders = implode(',', array_fill(0, count($currentIcons), '?'));
|
||||
$where[] = "uuid NOT IN ($placeholders)";
|
||||
$where[] = "c.uuid NOT IN ($placeholders)";
|
||||
$params = array_merge($params, $currentIcons);
|
||||
$types .= str_repeat('s', count($currentIcons));
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT data, price, name, id, state, userId
|
||||
FROM marketplaceicons
|
||||
SELECT c.data, u.username, u.id, c.price, c.name, c.uuid, c.state
|
||||
FROM marketplaceicons c
|
||||
JOIN users u ON c.userId = u.id
|
||||
WHERE " . implode(" AND ", $where) . "
|
||||
$order
|
||||
";
|
||||
|
||||
$stmt = $conn1->prepare($sql);
|
||||
if (!empty($params)) $stmt->bind_param($types, ...$params);
|
||||
$stmt = $conn->prepare($sql);
|
||||
|
||||
if (!empty($params)) {
|
||||
$stmt->bind_param($types, ...$params);
|
||||
}
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt(json_encode(array_map(
|
||||
function ($row) {
|
||||
global $conn0;
|
||||
echo encrypt(json_encode(array_map(fn($row) => ['username' => $row['username'], 'userid' => $row['id'], 'data' => $row['data'], 'uuid' => $row['uuid'], 'price' => (int)$row['state'] == 2 ? 100000000 : $row['price'], 'name' => base64_decode($row['name'])], $result->fetch_all(MYSQLI_ASSOC))));
|
||||
|
||||
$stmt = $conn0->prepare("SELECT username FROM users WHERE id = ?");
|
||||
$stmt->bind_param("i", $row['userId']);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
return [
|
||||
'username' => $row2['username'] ?? 'Unknown',
|
||||
'userid' => $row['userId'],
|
||||
'data' => $row['data'],
|
||||
'uuid' => $row['id'],
|
||||
'price' => (int) $row['state'] == 2 ? 100000000 : $row['price'],
|
||||
'name' => base64_decode($row['name'])
|
||||
];
|
||||
},
|
||||
$result->fetch_all(MYSQLI_ASSOC)
|
||||
)));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
+29
-32
@@ -1,22 +1,26 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3" ||
|
||||
getClientVersion() == "1.33" ||
|
||||
getClientVersion() == "0" || // 1.4.x
|
||||
getClientVersion() == "1.5.0" ||
|
||||
getClientVersion() == "1.5.1" ||
|
||||
getClientVersion() == "1.5.2"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.3-beta2/getTopPlayers.php';
|
||||
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';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5/getTopPlayers.php';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if ($_SERVER['HTTP_REQUESTER'] != 'BerryDashLauncher') {
|
||||
checkClientDatabaseVersion();
|
||||
}
|
||||
$post = getPostData();
|
||||
$request_type = $post['type'] ?? '';
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$request_value = "";
|
||||
if ($request_type === "0") {
|
||||
@@ -36,24 +40,18 @@ if ($request_type === "0") {
|
||||
exitWithMessage(json_encode([]));
|
||||
}
|
||||
|
||||
$stmt = $conn0->prepare("SELECT username, id FROM users WHERE leaderboards_banned = 0");
|
||||
$stmt = $conn->prepare("SELECT username, id, save_data, legacy_high_score
|
||||
FROM users
|
||||
WHERE banned = 0 AND leaderboardsBanned = 0");
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$rows = $result->fetch_all(MYSQLI_ASSOC);
|
||||
|
||||
$mapped = [];
|
||||
$icons = [];
|
||||
foreach ($result->fetch_all(mode: MYSQLI_ASSOC) as $row) {
|
||||
$id = $row["id"];
|
||||
$stmt = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) continue;
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
foreach ($rows as $row) {
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
if (!$savedata) continue;
|
||||
|
||||
if ($request_type == "4") {
|
||||
@@ -61,27 +59,27 @@ foreach ($result->fetch_all(mode: MYSQLI_ASSOC) as $row) {
|
||||
$value = 0;
|
||||
foreach ($berries as $b) $value += (int)($savedata['gameStore'][$b] ?? 0);
|
||||
} else {
|
||||
$value = $request_type != 2 ? $request_type != 3 ? ($savedata['gameStore'][$request_value] ?? 0) : ($row2['legacy_high_score'] ?? 0) : ($savedata['bird']['customIcon']['balance'] ?? 0);
|
||||
$value = $request_type != 2 ? $request_type != 3 ? ($savedata['gameStore'][$request_value] ?? 0) : ($row['legacy_high_score'] ?? 0) : ($savedata['bird']['customIcon']['balance'] ?? 0);
|
||||
}
|
||||
if ($value <= 0) continue;
|
||||
|
||||
$customIcon = $savedata['bird']['customIcon']['selected'] ?? null;
|
||||
|
||||
if ($customIcon && strlen($customIcon) == 36 && empty($icons[$customIcon])) {
|
||||
$stmt = $conn1->prepare("SELECT data FROM marketplaceicons WHERE id = ?");
|
||||
if ($customIcon != null && strlen($customIcon) == 36 && $icons[$customIcon] == null) {
|
||||
$stmt = $conn->prepare("SELECT data FROM marketplaceicons WHERE uuid = ?");
|
||||
$stmt->bind_param("s", $customIcon);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$rowData = $result->fetch_assoc();
|
||||
if ($rowData) {
|
||||
$stmt->close();
|
||||
$icons[$customIcon] = $rowData["data"];
|
||||
}
|
||||
}
|
||||
|
||||
$mapped[] = [
|
||||
'username' => $row['username'],
|
||||
'userid' => $id,
|
||||
'userid' => $row['id'],
|
||||
'value' => $value,
|
||||
'icon' => $savedata['bird']['icon'] ?? 1,
|
||||
'overlay' => $savedata['bird']['overlay'] ?? 0,
|
||||
@@ -100,5 +98,4 @@ if (getClientVersion() == "1.6" || (getClientVersion() == "1.6.1" && $request_ty
|
||||
echo encrypt(json_encode(["entries" => $limited, "customIcons" => $icons == [] ? new stdClass() : $icons]));
|
||||
}
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setJsonHeader();
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn->prepare("SELECT username, id, save_data
|
||||
FROM users
|
||||
WHERE banned = 0 AND leaderboardsBanned = 0");
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
$rows = $result->fetch_all(MYSQLI_ASSOC);
|
||||
|
||||
$mapped = [];
|
||||
foreach ($rows as $row) {
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
if (!$savedata) continue;
|
||||
|
||||
$value = $savedata['gameStore']['highScore'] ?? 0;
|
||||
if ($value <= 0) continue;
|
||||
|
||||
$mapped[] = [
|
||||
'username' => $row['username'],
|
||||
'score' => (int)$value,
|
||||
'scoreFormatted' => number_format($value)
|
||||
];
|
||||
}
|
||||
|
||||
usort($mapped, fn($a,$b) => $b['score'] <=> $a['score']);
|
||||
$limited = array_slice($mapped, 0, 500);
|
||||
|
||||
echo json_encode($limited);
|
||||
|
||||
$conn->close();
|
||||
Regular → Executable
+2
-1
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require __DIR__ . '/../../incl/util.php';
|
||||
require __DIR__ . '/../../config/general.php';
|
||||
setPlainHeader();
|
||||
echo "-1";
|
||||
echo $latestLauncherVersion;
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
require __DIR__ . '/../../incl/util.php';
|
||||
setJsonHeader();
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM launcherversions WHERE hidden = 0 ORDER BY id DESC");
|
||||
$stmt->execute();
|
||||
|
||||
$result_versions = $stmt->get_result();
|
||||
$versions = array_map(fn($row) => ['id' => $row['id'], 'version' => $row['version'], 'releaseDate' => $row['releaseDate'], 'displayName' => empty($row['displayName']) ? $row['version'] : $row['displayName'], 'platforms' => json_decode($row['platforms']), 'downloadUrls' => json_decode($row['downloadUrls']), 'executables' => json_decode($row['executables']), 'category' => $row['category']], $result_versions->fetch_all(MYSQLI_ASSOC));
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM launchercategories ORDER BY id DESC");
|
||||
$stmt->execute();
|
||||
|
||||
$result_categories = $stmt->get_result();
|
||||
$rows = $result_categories->fetch_all(MYSQLI_ASSOC);
|
||||
|
||||
$categories = [];
|
||||
foreach ($rows as $row) {
|
||||
$categories[$row['id']] = $row['name'];
|
||||
}
|
||||
|
||||
echo json_encode(["versions" => $versions, "categories" => $categories]);
|
||||
|
||||
$conn->close();
|
||||
+25
-84
@@ -1,101 +1,42 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (
|
||||
getClientVersion() == "1.4.0-beta1" ||
|
||||
getClientVersion() == "1.4.0" ||
|
||||
getClientVersion() == "1.4.1" ||
|
||||
getClientVersion() == "1.5.0" ||
|
||||
getClientVersion() == "1.5.1" ||
|
||||
getClientVersion() == "1.5.2"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.4.0-beta1/loadAccount.php';
|
||||
exit;
|
||||
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;
|
||||
}
|
||||
}
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn0->prepare("SELECT id, username FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$savedata['account']['id'] = $row['id'];
|
||||
$savedata['account']['name'] = $row['username'];
|
||||
$savedata['account']['session'] = $row['token'];
|
||||
echo encrypt(json_encode([
|
||||
"success" => true,
|
||||
"data" => $savedata
|
||||
]));
|
||||
} else {
|
||||
echo encrypt(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
echo encrypt(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
$savedata['account']['id'] = $id;
|
||||
$savedata['account']['name'] = $row['username'];
|
||||
$savedata['account']['session'] = $token;
|
||||
if ($savedata['version'] !== '0') {
|
||||
$savedata['version'] = '0';
|
||||
if (isset($savedata["bird"]["customIcon"]["purchased"]))
|
||||
{
|
||||
$purchased = $savedata["bird"]["customIcon"]["purchased"];
|
||||
unset($savedata["bird"]["customIcon"]["purchased"]);
|
||||
$data = [];
|
||||
foreach ($purchased as $icon) {
|
||||
$stmt2 = $conn1->prepare("SELECT userId, data, price, name FROM marketplaceicons WHERE id = ?");
|
||||
$stmt2->bind_param("s", $icon);
|
||||
$stmt2->execute();
|
||||
$result3 = $stmt2->get_result();
|
||||
$stmt2->close();
|
||||
if ($result3->num_rows != 1) continue;
|
||||
$row3 = $result3->fetch_assoc();
|
||||
$uid = $row3['userId'];
|
||||
|
||||
$stmt3 = $conn0->prepare("SELECT username FROM users WHERE id = ?");
|
||||
$stmt3->bind_param("i", $uid);
|
||||
$stmt3->execute();
|
||||
$result4 = $stmt3->get_result();
|
||||
$stmt3->close();
|
||||
if ($result4->num_rows != 1) continue;
|
||||
$row4 = $result4->fetch_assoc();
|
||||
|
||||
$data[] = [
|
||||
"username" => $row4["username"],
|
||||
"userid" => $row3["userId"],
|
||||
"data" => $row3["data"],
|
||||
"uuid" => $icon,
|
||||
"price" => $row3["price"],
|
||||
"name" => base64_decode($row3["name"])
|
||||
];
|
||||
}
|
||||
$savedata["bird"]["customIcon"]["data"] = $data;
|
||||
}
|
||||
}
|
||||
echo encrypt(json_encode([
|
||||
"success" => true,
|
||||
"data" => $savedata
|
||||
]));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
+41
-33
@@ -1,54 +1,62 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3" ||
|
||||
getClientVersion() == "1.33" ||
|
||||
getClientVersion() == "1.4.0-beta1" ||
|
||||
getClientVersion() == "1.4.0" ||
|
||||
getClientVersion() == "1.4.1"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.2-beta2/loginAccount.php';
|
||||
exit;
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.2-beta2/loginAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5/loginAccount.php';
|
||||
exit;
|
||||
}
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
|
||||
$post = getPostData();
|
||||
$username = $post['username'];
|
||||
$password = $post['password'];
|
||||
|
||||
$stmt = $conn0->prepare("SELECT id, username, password, token FROM users WHERE username = ?");
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
|
||||
$row = $result->fetch_assoc();
|
||||
if (!password_verify($password, $row["password"])) exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
|
||||
if ($result->num_rows === 0) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
|
||||
}
|
||||
|
||||
$id = $row['id'];
|
||||
$token = $row['token'];
|
||||
$user = $result->fetch_assoc();
|
||||
|
||||
if (!password_verify($password, $user["password"])) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
|
||||
}
|
||||
|
||||
$id = $user['id'];
|
||||
$token = $user['token'];
|
||||
$ip = getIPAddress();
|
||||
|
||||
$stmt = $conn0->prepare("UPDATE users SET latest_ip = ? WHERE id = ?");
|
||||
$stmt->bind_param("si", $ip, $id);
|
||||
$stmt = $conn->prepare("UPDATE users SET latest_ip = ?, token = ? WHERE id = ?");
|
||||
$stmt->bind_param("ssi", $ip, $token, $id);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
$data = ["session" => $token, "username" => $row['username'], "userid" => $id];
|
||||
$data = ["session" => $token, "username" => $user['username'], "userid" => $id];
|
||||
|
||||
echo encrypt(json_encode(["success" => true, "data" => $data]));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
@@ -1,22 +1,64 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3" ||
|
||||
getClientVersion() == "1.33" ||
|
||||
getClientVersion() == "1.4.0-beta1" ||
|
||||
getClientVersion() == "1.4.0" ||
|
||||
getClientVersion() == "1.4.1" ||
|
||||
getClientVersion() == "1.5.0" ||
|
||||
getClientVersion() == "1.5.1" ||
|
||||
getClientVersion() == "1.5.2"
|
||||
) {
|
||||
exitWithMessage("-1", getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2");
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
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" ||
|
||||
getClientVersion() == "1.3"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.21/registerAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5/registerAccount.php';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
|
||||
$post = getPostData();
|
||||
$username = $post['username'] ?? '';
|
||||
$password = $post['password'] ?? '';
|
||||
$email = $post['email'] ?? '';
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9]{3,16}$/', $username)) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Username must be 3-16 characters, letters and numbers only"]));
|
||||
}
|
||||
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to register an account in game"]));
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Email is invalid"]));
|
||||
}
|
||||
|
||||
if (!preg_match('/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!@#$%^&*()_\-+=]{8,}$/', $password)) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Password must be at least 8 characters with at least one letter and one number"]));
|
||||
}
|
||||
|
||||
$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) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Username or email already taken"]));
|
||||
}
|
||||
|
||||
$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 encrypt(json_encode(["success" => true]));
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$id = $post['id'] ?? '';
|
||||
@@ -8,30 +9,23 @@ $reason = $post['reason'] ?? '';
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
|
||||
if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~]+$/', $reason)) exit;
|
||||
if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~]+$/', $reason)) {
|
||||
exitWithMessage(json_encode(["success" => false]));
|
||||
}
|
||||
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ? LIMIT 1");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
if ($result->num_rows != 1) exit;
|
||||
if (!$row) exit;
|
||||
$stmt->close();
|
||||
|
||||
$user_id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt2->bind_param("i", $user_id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
if ($result2->num_rows != 1) exit;
|
||||
$stmt2->close();
|
||||
|
||||
$stmt = $conn1->prepare("SELECT id FROM chats WHERE userId != ? AND deleted_at = 0 AND id = ? LIMIT 1");
|
||||
$stmt = $conn->prepare("SELECT id FROM chats WHERE userId != ? AND deleted_at = 0 AND id = ? LIMIT 1");
|
||||
$stmt->bind_param("ii", $user_id, $id);
|
||||
$stmt->execute();
|
||||
$res = $stmt->get_result();
|
||||
@@ -39,7 +33,7 @@ $stmt->close();
|
||||
|
||||
if ($res->num_rows < 0) exit;
|
||||
|
||||
$stmt = $conn1->prepare("SELECT id FROM chatroom_reports WHERE chatId = ? AND userId = ? LIMIT 1");
|
||||
$stmt = $conn->prepare("SELECT id FROM chatroom_reports WHERE chatId = ? AND userId = ? LIMIT 1");
|
||||
$stmt->bind_param("ii", $id, $user_id);
|
||||
$stmt->execute();
|
||||
$res = $stmt->get_result();
|
||||
@@ -50,10 +44,8 @@ if ($res->num_rows > 0) exit;
|
||||
$time = time();
|
||||
$reason = base64_encode($reason);
|
||||
|
||||
$stmt = $conn1->prepare("INSERT INTO chatroom_reports (chatid, userId, reason, timestamp) VALUES (?, ?, ?, ?)");
|
||||
$stmt = $conn->prepare("INSERT INTO chatroom_reports (chatid, userId, reason, timestamp) VALUES (?, ?, ?, ?)");
|
||||
$stmt->bind_param("iisi", $id, $user_id, $reason, $time);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
+33
-51
@@ -1,26 +1,29 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3" ||
|
||||
getClientVersion() == "1.33"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.2-beta2/syncAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.4.0-beta1" || getClientVersion() == "1.4.0" || getClientVersion() == "1.4.1") {
|
||||
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;
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3" ||
|
||||
getClientVersion() == "1.33"
|
||||
) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$token = $post['token'] ?? '';
|
||||
@@ -37,43 +40,22 @@ try {
|
||||
echo encrypt(json_encode(["success" => false, "message" => "Couldn't parse save data"]));
|
||||
}
|
||||
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
if ($result->num_rows > 0) {
|
||||
$updateStmt = $conn->prepare("UPDATE users SET save_data = ? WHERE token = ? AND username = ?");
|
||||
$updateStmt->bind_param("sss", $savedata, $token, $username);
|
||||
$updateStmt->execute();
|
||||
$updateStmt->close();
|
||||
echo encrypt(json_encode(["success" => true]));
|
||||
} else {
|
||||
echo encrypt(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT id FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
|
||||
if ($result->num_rows != 1) {
|
||||
echo encrypt(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $conn1->prepare("UPDATE userdata SET save_data = ? WHERE id = ?");
|
||||
$stmt->bind_param("si", $savedata, $id);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
echo encrypt(json_encode(["success" => true]));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
@@ -1,10 +1,13 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5.1/sendChatroomMessage.php';
|
||||
exit;
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5.1/sendChatroomMessage.php';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$request_content = $post['content'] ?? '';
|
||||
@@ -15,36 +18,25 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid content recieved"]));
|
||||
}
|
||||
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
$stmt->close();
|
||||
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT * FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
$stmt->close();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
if (!$row2) exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
|
||||
$content = base64_encode($request_content);
|
||||
$time = time();
|
||||
|
||||
$stmt = $conn1->prepare("INSERT INTO chats (userId, content, timestamp) VALUES (?, ?, ?)");
|
||||
$stmt = $conn->prepare("INSERT INTO chats (userId, content, timestamp) VALUES (?, ?, ?)");
|
||||
$stmt->bind_param("isi", $id, $content, $time);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt(json_encode(["success" => true]));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$request_content = $post['content'] ?? '';
|
||||
@@ -11,35 +12,25 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
|
||||
exitWithMessage(json_encode(["success" => false]));
|
||||
}
|
||||
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$stmt->close();
|
||||
if ($result->num_rows != 1) exitWithMessage(json_encode(["success" => false]));
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT * FROM userdata WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
if (!$row) exitWithMessage(json_encode(["success" => false]));
|
||||
$stmt->close();
|
||||
if ($result2->num_rows != 1) exitWithMessage(json_encode(["success" => false]));
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$id = $row["id"];
|
||||
$content = base64_encode($request_content);
|
||||
$time = time();
|
||||
|
||||
$stmt = $conn1->prepare("INSERT INTO userposts (userId, content, timestamp) VALUES (?, ?, ?)");
|
||||
$stmt = $conn->prepare("INSERT INTO userposts (userId, content, timestamp) VALUES (?, ?, ?)");
|
||||
$stmt->bind_param("isi", $id, $content, $time);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt(json_encode(["success" => true]));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
@@ -1,4 +1,59 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to upload a marketplace icon"]));
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
$price = (int)$post['price'] ?? 0;
|
||||
$name = $post['name'] ?? '';
|
||||
$name = base64_encode($name);
|
||||
$filecontent = $post['filecontent'] ?? '';
|
||||
|
||||
if ($price < 10) exitWithMessage(json_encode(["success" => false, "message" => "Price cannot be be under 10 coins"]));
|
||||
if (!preg_match('/^[a-zA-Z0-9 ]+$/', base64_decode($name))) exitWithMessage(json_encode(["success" => false, "message" => "Name is invalid"]));
|
||||
if (!$filecontent) exitWithMessage(json_encode(["success" => false, "message" => "Invalid image uploaded"]));
|
||||
$decoded = base64_decode($filecontent, true);
|
||||
if (!$decoded) exitWithMessage(json_encode(["success" => false, "message" => "Invalid image uploaded"]));
|
||||
if (strlen($decoded) > 1024 * 1024) exitWithMessage(json_encode(["success" => false, "message" => "File size exceeds 1 MB limit"]));
|
||||
$info = getimagesizefromstring($decoded);
|
||||
if (!$info) exitWithMessage(json_encode(["success" => false, "message" => "Invalid image uploaded"]));
|
||||
if ($info[2] !== IMAGETYPE_PNG) exitWithMessage(json_encode(["success" => false, "message" => "Image must be a PNG"]));
|
||||
if ($info[0] !== 128 || $info[1] !== 128) exitWithMessage(json_encode(["success" => false, "message" => "Invalid has to be 128x128"]));
|
||||
|
||||
$conn = newConnection();
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
$stmt->close();
|
||||
|
||||
$id = $row["id"];
|
||||
$time = time();
|
||||
$hash = hash('sha512', base64_decode($filecontent));
|
||||
|
||||
$stmt = $conn->prepare("SELECT id FROM marketplaceicons WHERE hash = ?");
|
||||
$stmt->bind_param("s", $hash);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
if ($result->fetch_assoc()) {
|
||||
$stmt->close();
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "This icon already exists in the marketplace"]));
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
$uuid = uuidv4();
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO marketplaceicons (uuid, userId, data, hash, price, name, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt->bind_param("sissisi", $uuid, $id, $filecontent, $hash, $price, $name, $time);
|
||||
$stmt->execute();
|
||||
$insertId = $conn->insert_id;
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt(json_encode(["success" => true, "message" => "Icon uploaded successfully! It will be reviewed and accepted or denied soon"]));
|
||||
|
||||
$conn->close();
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
|
||||
$post = getPostData();
|
||||
$targetId = (int)$post['targetId'] ?? 0;
|
||||
@@ -14,8 +14,8 @@ if ($liked !== 0 && $liked !== 1) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
@@ -27,7 +27,7 @@ $stmt->close();
|
||||
|
||||
$user_id = $row["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT votes FROM userposts WHERE id = ?");
|
||||
$stmt = $conn->prepare("SELECT votes, likes FROM userposts WHERE id = ?");
|
||||
$stmt->bind_param("i", $targetId);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
@@ -39,6 +39,7 @@ if (!$row) {
|
||||
$stmt->close();
|
||||
|
||||
$votes = json_decode($row["votes"], true) ?? [];
|
||||
$likes = (int)$row["likes"];
|
||||
if (isset($votes[$user_id])) {
|
||||
echo encrypt(json_encode(["success" => false, "message" => 'You have already voted']));
|
||||
exit;
|
||||
@@ -48,12 +49,11 @@ $votes[$user_id] = $liked === 0 ? false : true;
|
||||
$likes += $liked ? 1 : -1;
|
||||
$votes = json_encode($votes);
|
||||
|
||||
$stmt = $conn1->prepare("UPDATE userposts SET likes = ?, votes = ? WHERE id = ?");
|
||||
$stmt = $conn->prepare("UPDATE userposts SET likes = ?, votes = ? WHERE id = ?");
|
||||
$stmt->bind_param("isi", $likes, $votes, $targetId);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt(json_encode(["success" => true, "likes" => $likes]));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
$conn->close();
|
||||
@@ -0,0 +1,6 @@
|
||||
import os
|
||||
|
||||
keys_needed = ["SERVER_RECEIVE_TRANSFER_KEY", "SERVER_SEND_TRANSFER_KEY", "BAZOOKA_MANAGER_KEY", "BAZOOKA_MANAGER_FILE_KEY"]
|
||||
|
||||
for key_needed in keys_needed:
|
||||
print("Key for \"" + key_needed + "\": " + os.urandom(16).hex())
|
||||
@@ -1 +0,0 @@
|
||||
Require all denied
|
||||
+44
-18
@@ -3,24 +3,22 @@ function setPlainHeader() {
|
||||
header("Content-Type: text/plain");
|
||||
}
|
||||
|
||||
function getIPAddress() {
|
||||
return $_SERVER['REMOTE_ADDR'];
|
||||
function setJsonHeader() {
|
||||
header("Content-Type: application/json");
|
||||
}
|
||||
|
||||
function newConnection($type = 1) {
|
||||
include __DIR__.'/../config/connection.php';
|
||||
function getIPAddress() {
|
||||
return $_SERVER['HTTP_CF_CONNECTING_IP'];
|
||||
}
|
||||
|
||||
function newConnection() {
|
||||
include __DIR__.'/../config/connection.php';
|
||||
try {
|
||||
return new mysqli(
|
||||
$type === 0 ? $games_db_host : $bd_db_host,
|
||||
$type === 0 ? $games_db_user : $bd_db_user,
|
||||
$type === 0 ? $games_db_pass : $bd_db_pass,
|
||||
$type === 0 ? $games_db_name : $bd_db_name,
|
||||
$type === 0 ? $games_db_port : $bd_db_port
|
||||
);
|
||||
$conn = new mysqli($db_host, $db_user, $db_pass, $db_name, $db_port);
|
||||
} catch (mysqli_sql_exception $e) {
|
||||
exitWithMessage("-999");
|
||||
}
|
||||
return $conn;
|
||||
}
|
||||
|
||||
function getClientVersion() {
|
||||
@@ -29,21 +27,17 @@ function getClientVersion() {
|
||||
|
||||
function encrypt($plainText) {
|
||||
include __DIR__.'/../config/encryption.php';
|
||||
$key = $SERVER_SEND_TRANSFER_KEY_SPECIFIC[getClientVersion()];
|
||||
if ($key == null) return;
|
||||
$iv = random_bytes(16);
|
||||
$cipher = openssl_encrypt($plainText, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
|
||||
$cipher = openssl_encrypt($plainText, 'aes-256-cbc', $SERVER_SEND_TRANSFER_KEY_SPECIFIC[getClientVersion()] ?? $SERVER_SEND_TRANSFER_KEY, OPENSSL_RAW_DATA, $iv);
|
||||
return base64_encode($iv . $cipher);
|
||||
}
|
||||
|
||||
function decrypt($dataB64) {
|
||||
include __DIR__.'/../config/encryption.php';
|
||||
$key = $SERVER_RECEIVE_TRANSFER_KEY_SPECIFIC[getClientVersion()];
|
||||
if ($key == null) return;
|
||||
$data = base64_decode($dataB64);
|
||||
$iv = substr($data, 0, 16);
|
||||
$cipher = substr($data, 16);
|
||||
$decrypted = openssl_decrypt($cipher, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
|
||||
$decrypted = openssl_decrypt($cipher, 'aes-256-cbc', $SERVER_RECEIVE_TRANSFER_KEY_SPECIFIC[getClientVersion()] ?? $SERVER_RECEIVE_TRANSFER_KEY, OPENSSL_RAW_DATA, $iv);
|
||||
if ($decrypted === false) {
|
||||
exit(encrypt('-997'));
|
||||
}
|
||||
@@ -59,13 +53,45 @@ function exitWithMessage($message, $encrypt = true) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function isLatestVersion($version) {
|
||||
global $latestVersion;
|
||||
if (!isset($latestVersion)) require __DIR__ . '/../config/general.php';
|
||||
return $version === $latestVersion;
|
||||
}
|
||||
|
||||
function isBetaVersion($version) {
|
||||
global $latestBetaVersion;
|
||||
if (!isset($latestBetaVersion)) require __DIR__ . '/../config/general.php';
|
||||
return $version === $latestBetaVersion;
|
||||
}
|
||||
|
||||
function isAllowedVersion($version) {
|
||||
global $allowedVersions;
|
||||
if (!isset($allowedVersions)) require __DIR__ . '/../config/general.php';
|
||||
return in_array($version, $allowedVersions);
|
||||
}
|
||||
|
||||
function isAllowedDatabaseVersion($version) {
|
||||
global $allowedDatabaseVersions;
|
||||
if (!isset($allowedDatabaseVersions)) require __DIR__ . '/../config/general.php';
|
||||
return in_array($version, $allowedDatabaseVersions);
|
||||
}
|
||||
|
||||
function checkClientDatabaseVersion() {
|
||||
global $allowedDatabaseVersions;
|
||||
if (!isset($allowedDatabaseVersions)) require __DIR__ . '/../config/general.php';
|
||||
if (!isset($_SERVER['HTTP_REQUESTER'])) exitWithMessage("-998");
|
||||
if ($_SERVER['HTTP_REQUESTER'] != "BerryDashClient") exitWithMessage("-998");
|
||||
if (!in_array($_SERVER['HTTP_CLIENTVERSION'] ?? '', $allowedDatabaseVersions)) exitWithMessage("-998");
|
||||
}
|
||||
|
||||
function getPostData() {
|
||||
$raw = file_get_contents("php://input");
|
||||
parse_str($raw, $postData);
|
||||
|
||||
$decrypted = [];
|
||||
foreach ($postData as $k => $v) {
|
||||
$decKey = (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1") ? $k : decrypt($k);
|
||||
$decKey = decrypt($k);
|
||||
$decValue = decrypt($v);
|
||||
$decrypted[$decKey] = $decValue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user