Compare commits

...
52 Commits
Author SHA1 Message Date
Lncvrt 8efad9cf1b Update CDN link 2026-09-24 10:08:36 -07:00
Lncvrt f2fc143c03 fix 3 2026-04-18 12:57:12 -07:00
Lncvrt cc1174f9c7 fix 2 2026-03-24 12:48:13 -07:00
Lncvrt 3088dc63ac fix 2026-03-24 12:44:42 -07:00
Lncvrt 4e02f110cd Revert "yep"
This reverts commit 2e392bdf87.
2026-03-24 12:43:41 -07:00
Lncvrt 2e392bdf87 yep 2026-03-13 12:59:54 -07:00
Lncvrt 9553bb9c61 fix leaderboards 2026-03-03 09:18:00 -07:00
Lncvrt 5ee2dcf2db Update to v2 manifest 2026-02-27 19:21:39 -07:00
Lncvrt d6ad9a01a0 Fix 2026-02-27 18:51:35 -07:00
Lncvrt e259567c62 Oops 2026-02-16 22:45:11 -07:00
Lncvrt 94051c6b55 Make berry dash launcher leaderboards work 2026-02-16 22:43:58 -07:00
Lncvrt 876b1bce08 Make Berry Dash Launcher work again (not supported still) 2026-02-16 22:07:45 -07:00
Lncvrt 65d860e6cb Fix readme 2026-02-16 13:21:47 -07:00
Lncvrt 6bd3adc8f8 26.1 beta 1 is out 2026-02-10 13:29:11 -07:00
Lncvrt 3cf62a6896 Add support for loading 26.1 or higher savefile 2026-01-31 15:27:34 -07:00
Lncvrt 739eadae51 Only allow state 1 2026-01-31 00:50:39 -07:00
Lncvrt 9f9a65a6be Fixes 2026-01-29 21:33:15 -07:00
Lncvrt baca4c55e0 Update readme 2026-01-29 21:24:54 -07:00
Lncvrt 9b06f966f1 Use new token location 2026-01-29 21:07:19 -07:00
Lncvrt e6c045e1e1 Fixes 2026-01-25 21:32:13 -07:00
Lncvrt 594e924ad4 Fix leaderboards 2026-01-19 17:47:17 -07:00
Lncvrt 8e6a9ef156 A lot of changes (that shouldn't, hopefully be breaking) 2026-01-02 20:56:24 -07:00
Lncvrt b2c28e229d Make deleteChatroomMessage.php work with new db method - Finished 2026-01-02 20:26:01 -07:00
Lncvrt f99c8a42f3 Make editChatroomMessage.php work with new db method 2026-01-02 20:22:03 -07:00
Lncvrt 5be2bbf796 Remove newline at end of files that is unneeded 2026-01-02 20:16:27 -07:00
Lncvrt abf62a6df6 Fix 1.5.x getChatroomMessages.php and sendChatroomMessage.php 2026-01-02 20:00:53 -07:00
Lncvrt 4269f91653 Make reportChatroomMessage.php work with new db method 2026-01-02 19:51:30 -07:00
Lncvrt fec71aa736 Make sendChatroomMessage.php work with new db method 2026-01-02 19:41:51 -07:00
Lncvrt b3858a2e85 Make voteAccountProfileMessage.php work with new db method 2026-01-02 19:32:17 -07:00
Lncvrt e8243db62a Why did I do this 2026-01-01 00:45:38 -07:00
Lncvrt 680da8414a Make getMarketplaceIcons.php and uploadMarketplaceIcon.php work with new db method 2026-01-01 00:26:24 -07:00
Lncvrt a5f98cd7c4 Make deleteAccountProfileMessage.php work with new db method 2026-01-01 00:09:27 -07:00
Lncvrt 07c437d05e Use new method to get likes 2026-01-01 00:09:01 -07:00
Lncvrt 2728fc6e83 Could've been bad lmao 2025-12-31 23:48:25 -07:00
Lncvrt 7cc6afeca6 oops 2025-12-31 23:47:48 -07:00
Lncvrt 8ac41d660a make uploadAccountProfileMessage.php work with new db method 2025-12-31 23:41:27 -07:00
Lncvrt 1d29f5da84 Make getChatroomMessages.php work with new db method 2025-12-31 23:36:00 -07:00
Lncvrt 34328de9b6 Make getAccountProfile.php and getAccountProfileMessages.php work with new db method 2025-12-31 23:31:52 -07:00
Lncvrt 2d78565f77 Make saveAccount.php work with new db method 2025-12-31 21:13:34 -07:00
Lncvrt 1cee054cd7 Make 1.5.0/1.5.1 decrypting data work 2025-12-31 19:25:44 -07:00
Lncvrt f511da6f21 Make loadAccount.php work with new db method 2025-12-31 19:21:50 -07:00
Lncvrt 9b499e35f4 Make leaderboards script work with new db stuff 2025-12-31 18:32:42 -07:00
Lncvrt b292e4b58f Remove unneeded script 2025-12-31 18:26:42 -07:00
Lncvrt 9f26fc103f Update license 2025-12-31 18:26:33 -07:00
Lncvrt 1b93f152a2 Make login script work on all versions 2025-12-31 17:56:43 -07:00
Lncvrt 7da7eb90c6 Fix util 2025-12-31 17:15:50 -07:00
Lncvrt 56f92948fa Hopefully this works, switching to the new way that the servers are used (not ported yet, just the newconnection() func was changed) 2025-12-31 16:55:10 -07:00
Lncvrt 12c5b431cb Remove ability to change account password or username or register on 1.8.2 and below 2025-12-31 16:46:54 -07:00
Lncvrt 87e595b420 Forgot about these lmao 2025-12-31 16:36:44 -07:00
Lncvrt cf6c0eff73 Change readme 2025-12-31 16:12:35 -07:00
Lncvrt b4884362fe Forgot to commit this 2025-12-31 16:11:11 -07:00
Lncvrt 85fff884ec Update to current files 2025-12-31 16:08:48 -07:00
55 changed files with 953 additions and 1615 deletions

No files matched your search

+2 -2
View File
@@ -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 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. the "copyright" line and a pointer to where the full notice is found.
Berry Dash Server Code Copyright (C) 2025 Lncvrt Berry Dash Server Code Copyright (C) 2026 Lncvrt
This program is free software: you can redistribute it and/or modify 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 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 If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode: notice like this when it starts in an interactive mode:
Berry Dash Server Code Copyright (C) 2025 Lncvrt Berry Dash Server Code Copyright (C) 2026 Lncvrt
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details. under certain conditions; type `show c' for details.
+4 -34
View File
@@ -1,38 +1,8 @@
# Berry Dash Server # Berry Dash Server
> [!CAUTION] > [!CAUTION]
> This project has moved to the Lncvrt Games originization. > This project has been discarded and a new API is under the Lncvrt Games organization.
> You can find the new repository [here](https://github.com/Lncvrt-Games/servers) >
> You can find the new server API [here](https://git.lncvrt.xyz/Lncvrt-Games/api).
--- Legacy Server Source Code
This is the new rewritten server 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
View File
@@ -0,0 +1 @@
Require all denied
+10 -5
View File
@@ -1,6 +1,11 @@
<?php <?php
$db_host = "localhost"; $games_db_host = "localhost";
$db_port = 3306; $games_db_port = 3306;
$db_user = ""; $games_db_user = "";
$db_pass = ""; $games_db_pass = "";
$db_name = ""; $games_db_name = "";
$bd_db_host = "localhost";
$bd_db_port = 3306;
$bd_db_user = "";
$bd_db_pass = "";
$bd_db_name = "";
+2 -4
View File
@@ -1,5 +1,3 @@
<?php <?php
$SERVER_RECEIVE_TRANSFER_KEY = ""; //SERVER_SEND_TRANSFER_KEY on the client $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 = ""; //SERVER_RECEIVE_TRANSFER_KEY on the client $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_SPECIFIC = [];
$SERVER_SEND_TRANSFER_KEY_SPECIFIC = [];
-6
View File
@@ -1,6 +0,0 @@
<?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
View File
@@ -1,305 +0,0 @@
-- 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
View File
@@ -0,0 +1 @@
Require all denied
+48 -27
View File
@@ -1,44 +1,65 @@
<?php <?php
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$request_username = $_POST['username']; $request_username = $_POST['username'];
$request_password = $_POST['password']; $request_password = $_POST['password'];
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?"); $stmt = $conn0->prepare("SELECT id, username, password, token FROM users WHERE username = ?");
$stmt->bind_param("s", $request_username); $stmt->bind_param("s", $request_username);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
if ($result->num_rows > 0) { if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) { $row = $result->fetch_assoc();
if (password_verify($request_password, $row["password"])) { if (password_verify($request_password, $row['password'])) {
$login_ip = getIPAddress(); $login_ip = getIPAddress();
$login_time = time(); $login_time = time();
$uid = $row['id']; $uid = $row['id'];
$username = $row['username'];
$highscore = $row['legacy_high_score'];
$token = $row['token'];
$stmt = $conn->prepare("UPDATE users SET latest_ip = ? WHERE id = ?"); $stmt = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? LIMIT 1");
$stmt->bind_param("si", $login_ip, $uid); $stmt->bind_param("i", $uid);
$stmt->execute(); $stmt->execute();
$result2 = $stmt->get_result();
$stmt->close();
if ($result2->num_rows != 1) exitWithMessage("-1", false);
$row2 = $result2->fetch_assoc();
$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"; echo "$token:$uid:$highscore";
} else { } else if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
$stmt->close(); echo "$token:$uid:$highscore:$icon:$overlay";
$conn->close(); } else if (getClientVersion() == "1.4.0-beta1" || getClientVersion() == "1.4.0" || getClientVersion() == "1.4.1") {
exit("-2"); echo "1:$token:$username:$uid:$highscore:$icon:$overlay";
} }
} else {
$conn0->close();
$conn1->close();
exitWithMessage("-2", false);
} }
} else { } else {
$stmt->close(); $conn0->close();
$conn->close(); $conn1->close();
exit("-2"); exitWithMessage("-2", false);
} }
$stmt->close(); $conn0->close();
$conn->close(); $conn1->close();
?>
@@ -1,45 +0,0 @@
<?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';
+31 -17
View File
@@ -1,25 +1,39 @@
<?php <?php
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$request_uid = $_POST['userID'] ?? 0; $user_id = $_POST['userID'] ?? 0;
$request_session = $_POST['gameSession'] ?? ''; $token = $_POST['gameSession'] ?? '';
$request_score = $_POST['highScore'] ?? 0; $high_score = $_POST['highScore'] ?? 0;
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND id = ?"); $stmt = $conn0->prepare("SELECT * FROM users WHERE id = ? AND token = ?");
$stmt->bind_param("ss", $request_session, $request_uid); $stmt->bind_param("ss", $user_id, $token);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $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"];
if ($result->num_rows > 0) { $stmt = $conn1->prepare("SELECT * FROM userdata WHERE id = ?");
$updateStmt = $conn->prepare("UPDATE users SET legacy_high_score = ? WHERE token = ? AND id = ?"); $stmt->bind_param("i", $user_id);
$updateStmt->bind_param("isi", $request_score, $request_session, $request_uid); $stmt->execute();
$updateStmt->execute(); $result2 = $stmt->get_result();
echo "1"; $stmt->close();
$updateStmt->close(); if ($result2->num_rows != 1) {
} else { echo (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") ? "-2" : "-3";
echo "-3"; $conn0->close();
$conn1->close();
exit;
} }
$stmt->close(); $updateStmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ? WHERE id = ?");
$conn->close(); $updateStmt->bind_param("ii", $high_score, $user_id);
?> $updateStmt->execute();
$updateStmt->close();
echo "1";
@@ -1,45 +0,0 @@
<?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';
@@ -1,52 +0,0 @@
<?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';
?>
@@ -1,52 +0,0 @@
<?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';
?>
+46 -31
View File
@@ -1,45 +1,60 @@
<?php <?php
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$request_showamount = isset($_POST['showAmount']) ? $_POST['showAmount'] : 0; $stmt = $conn0->prepare("SELECT username, id FROM users WHERE leaderboards_banned = 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(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
if ($result->num_rows > 0) { if ($result->num_rows > 0) {
$topPlayers = []; $topPlayers = [];
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
$savedata = json_decode($row['save_data'], true); $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);
$icon = $savedata['bird']['icon'] ?? 1; $icon = $savedata['bird']['icon'] ?? 1;
$overlay = $savedata['bird']['overlay'] ?? 0; $overlay = $savedata['bird']['overlay'] ?? 0;
$topPlayers[] = $row["username"] . ":" . $row["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $row["id"]; 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];
}
}
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 { } else {
echo -2; 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");
}
} }
$conn->close(); $conn0->close();
?> $conn1->close();
@@ -1,47 +0,0 @@
<?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();
?>
@@ -1,43 +0,0 @@
<?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();
?>
+56 -18
View File
@@ -1,23 +1,61 @@
<?php <?php
$token = $_POST['gameSession'] ?? ''; if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
$username = $_POST['userName'] ?? ''; $post = getPostData();
$token = $post['gameSession'] ?? '';
$conn = newConnection(); $username = $post['userName'] ?? '';
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
$stmt->bind_param("ss", $token, $username);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$savedata = json_decode($row['save_data'], true);
$icon = $savedata['bird']['icon'] ?? 1;
$overlay = $savedata['bird']['overlay'] ?? 0;
echo "1:" . $row['legacy_high_score'] . ":" . $icon . ":" . $overlay;
} else { } else {
echo "-1"; $token = $_POST['gameSession'] ?? '';
$username = $_POST['userName'] ?? '';
} }
$conn0 = newConnection(0);
$conn1 = newConnection(1);
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
$stmt->bind_param("ss", $username, $token);
$stmt->execute();
$result = $stmt->get_result();
$stmt->close(); $stmt->close();
$conn->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);
} else {
echo "1:" . $user2['legacy_high_score'] . ":" . $icon . ":" . $overlay;
}
$conn0->close();
$conn1->close();
@@ -1,47 +0,0 @@
<?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();
?>
+37 -19
View File
@@ -1,5 +1,6 @@
<?php <?php
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$request_userName = $_POST['userName'] ?? 0; $request_userName = $_POST['userName'] ?? 0;
$request_gameSession = $_POST['gameSession'] ?? ''; $request_gameSession = $_POST['gameSession'] ?? '';
@@ -7,27 +8,44 @@ $request_highScore = $_POST['highScore'] ?? 0;
$request_icon = $_POST['icon'] ?? 0; $request_icon = $_POST['icon'] ?? 0;
$request_overlay = $_POST['overlay'] ?? 0; $request_overlay = $_POST['overlay'] ?? 0;
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?"); $stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? AND token = ?");
$stmt->bind_param("ss", $request_gameSession, $request_userName); $stmt->bind_param("ss", $request_userName, $request_gameSession);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
if ($result->num_rows > 0) { if ($result->num_rows != 1) {
$row = $result->fetch_assoc(); echo "-2";
$savedata = json_decode($row['save_data'], true); $conn0->close();
$savedata['bird']['icon'] = $request_icon; $conn1->close();
$savedata['bird']['overlay'] = $request_overlay; exit;
$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(); $stmt->close();
$conn->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";
@@ -1,31 +1,48 @@
<?php <?php
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$stmt = $conn->prepare(" $stmt = $conn1 ->prepare("
SELECT c.id AS chat_id, c.content, u.username, u.id AS user_id, u.save_data SELECT id, content, userId
FROM chats c FROM chats
JOIN users u ON c.userId = u.id WHERE deleted_at = 0
WHERE u.banned = 0 AND c.deleted_at = 0 ORDER BY id DESC LIMIT 49
ORDER BY c.id DESC LIMIT 50
"); ");
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$rows = []; $rows = [];
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
$savedata = json_decode($row['save_data'], true); $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);
$icon = $savedata['bird']['icon'] ?? 1; $icon = $savedata['bird']['icon'] ?? 1;
$overlay = $savedata['bird']['overlay'] ?? 0; $overlay = $savedata['bird']['overlay'] ?? 0;
$birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255]; $birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255];
$overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255]; $overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255];
$rows[] = implode(";", [ $rows[] = implode(";", [
$row['chat_id'], $row['id'],
base64_encode($row['username']), base64_encode($row3['username']),
$row['content'], $row['content'],
$icon, $icon,
$overlay, $overlay,
$row['user_id'], $userId,
$birdColor[0], $birdColor[0],
$birdColor[1], $birdColor[1],
$birdColor[2], $birdColor[2],
@@ -35,6 +52,7 @@ while ($row = $result->fetch_assoc()) {
]); ]);
} }
echo encrypt("1" . ":" . implode("|", array_reverse($rows))); echo encrypt("1:" . implode("|", array_reverse($rows)));
$conn->close(); $conn0->close();
$conn1->close();
@@ -7,25 +7,27 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
exitWithMessage("-1"); exitWithMessage("-1");
} }
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ?"); $stmt = $conn0->prepare("SELECT id FROM users WHERE token = ?");
$stmt->bind_param("s", $token); $stmt->bind_param("s", $token);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
$row = $result->fetch_assoc(); $row = $result->fetch_assoc();
if (!$row) exitWithMessage("-1"); if (!$row) exitWithMessage("-1");
$stmt->close();
$id = $row["id"]; $id = $row["id"];
$content = base64_encode($request_content); $content = base64_encode($request_content);
$time = time(); $time = time();
$stmt = $conn->prepare("INSERT INTO chats (userId, content, timestamp) VALUES (?, ?, ?)"); $stmt = $conn1->prepare("INSERT INTO chats (userId, content, timestamp) VALUES (?, ?, ?)");
$stmt->bind_param("isi", $id, $content, $time); $stmt->bind_param("isi", $id, $content, $time);
$stmt->execute(); $stmt->execute();
$stmt->close(); $stmt->close();
echo encrypt("1"); echo encrypt("1");
$conn->close(); $conn0->close();
$conn1->close();
-47
View File
@@ -1,47 +0,0 @@
<?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();
?>
-26
View File
@@ -1,26 +0,0 @@
<?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();
+27 -21
View File
@@ -1,5 +1,6 @@
<?php <?php
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$post = getPostData(); $post = getPostData();
$username = $post['username']; $username = $post['username'];
@@ -7,44 +8,49 @@ $password = $post['password'];
$currentHighScore = $post['currentHighScore'] ?? 0; $currentHighScore = $post['currentHighScore'] ?? 0;
$loginType = $post['loginType'] ?? '0'; $loginType = $post['loginType'] ?? '0';
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?"); $stmt = $conn0->prepare("SELECT id, username, password, token FROM users WHERE username = ?");
$stmt->bind_param("s", $username); $stmt->bind_param("s", $username);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
if ($result->num_rows != 1) exitWithMessage("-1");
$row = $result->fetch_assoc();
if ($result->num_rows === 0) { if (!password_verify($password, $row["password"])) exitWithMessage("-1");
exitWithMessage("-1");
}
$user = $result->fetch_assoc(); $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();
if (!password_verify($password, $user["password"])) { $token = $row['token'];
exitWithMessage("-1");
}
$id = $user['id'];
$token = $user['token'];
$ip = getIPAddress(); $ip = getIPAddress();
$stmt = $conn->prepare("UPDATE users SET latest_ip = ?, token = ? WHERE id = ?"); $stmt = $conn0->prepare("UPDATE users SET latest_ip = ?, token = ? WHERE id = ?");
$stmt->bind_param("ssi", $ip, $token, $id); $stmt->bind_param("ssi", $ip, $token, $id);
$stmt->execute(); $stmt->execute();
$stmt->close();
if ($currentHighScore > $user['legacy_high_score']) { if ($currentHighScore > $row2['legacy_high_score']) {
$stmt = $conn->prepare("UPDATE users SET legacy_high_score = ? WHERE id = ?"); $stmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ? WHERE id = ?");
$stmt->bind_param("ii", $currentHighScore, $id); $stmt->bind_param("ii", $currentHighScore, $id);
$stmt->execute(); $stmt->execute();
$user['legacy_high_score'] = $currentHighScore; $stmt->close();
$row2['legacy_high_score'] = $currentHighScore;
} }
$savedata = json_decode($user['save_data'], true); $savedata = json_decode($row['save_data'], true);
$birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255]; $birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255];
$overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255]; $overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255];
if ($loginType === "0") { if ($loginType === "0") {
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]); 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]);
} elseif ($loginType === "1") { } elseif ($loginType === "1") {
echo encrypt("1" . ":" . $token . ":" . $user['username'] . ":" . $id); echo encrypt("1:" . $token . ":" . $row['username'] . ":" . $id);
} }
$stmt->close(); $conn0->close();
$conn->close(); $conn1->close();
@@ -1,42 +0,0 @@
<?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");
+55 -32
View File
@@ -5,43 +5,66 @@ $username = $post['userName'] ?? '';
$highScore = (int)$post['highScore'] ?? 0; $highScore = (int)$post['highScore'] ?? 0;
$icon = (int)$post['icon'] ?? 1; $icon = (int)$post['icon'] ?? 1;
$overlay = (int)$post['overlay'] ?? 0; $overlay = (int)$post['overlay'] ?? 0;
$birdR = (int)$post['birdR'] ?? 255; if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
$birdG = (int)$post['birdG'] ?? 255; $birdR = (int)$post['birdR'] ?? 255;
$birdB = (int)$post['birdB'] ?? 255; $birdG = (int)$post['birdG'] ?? 255;
$overlayR = (int)$post['overlayR'] ?? 255; $birdB = (int)$post['birdB'] ?? 255;
$overlayG = (int)$post['overlayG'] ?? 255; $birdColor = [$birdR, $birdG, $birdB];
$overlayB = (int)$post['overlayB'] ?? 255; }
$birdColor = [$birdR, $birdG, $birdB]; if (getClientVersion() == "1.5.2") {
$overlayColor = [$overlayR, $overlayG, $overlayB]; $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);
$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(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
if ($result->num_rows > 0) { if ($result->num_rows != 1) {
$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"); 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(); $stmt->close();
$conn->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();
+1 -20
View File
@@ -1,23 +1,4 @@
<?php <?php
require __DIR__ . '/../config/general.php';
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); 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";
}
+17 -40
View File
@@ -1,45 +1,22 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
checkClientDatabaseVersion(); if (
$conn = newConnection(); getClientVersion() == "1.2-beta2" ||
getClientVersion() == "1.2" ||
$post = getPostData(); getClientVersion() == "1.21" ||
$oldpassword = $post['oldpassword'] ?? ''; getClientVersion() == "1.3-beta1" ||
$newpassword = $post['newpassword'] ?? ''; getClientVersion() == "1.3-beta2" ||
$token = $post['token'] ?? ''; getClientVersion() == "1.3" ||
$username = $post['username'] ?? ''; getClientVersion() == "1.33" ||
getClientVersion() == "1.4.0-beta1" ||
if (!preg_match('/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!@#$%^&*()_\-+=]{8,}$/', $newpassword)) { getClientVersion() == "1.4.0" ||
exitWithMessage(json_encode(["success" => false, "message" => "New password must be at least 8 characters with at least one letter and one number"])); 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");
} }
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ? AND token = ?"); exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to change your password in game"]));
$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]));
+17 -48
View File
@@ -1,53 +1,22 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
if (isAllowedDatabaseVersion(getClientVersion())) { if (
if (getClientVersion() == "1.3-beta1") { getClientVersion() == "1.2-beta2" ||
require __DIR__ . '/backported/1.3-beta1/changeAccountUsername.php'; getClientVersion() == "1.2" ||
exit; getClientVersion() == "1.21" ||
} getClientVersion() == "1.3-beta1" ||
if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") { getClientVersion() == "1.3-beta2" ||
require __DIR__ . '/backported/1.3-beta2/changeAccountUsername.php'; getClientVersion() == "1.3" ||
exit; getClientVersion() == "1.33" ||
} getClientVersion() == "1.4.0-beta1" ||
} getClientVersion() == "1.4.0" ||
checkClientDatabaseVersion(); getClientVersion() == "1.4.1" ||
$conn = newConnection(); getClientVersion() == "1.5.0" ||
getClientVersion() == "1.5.1" ||
$post = getPostData(); getClientVersion() == "1.5.2"
$oldusername = $post['oldusername'] ?? ''; ) {
$newusername = $post['newusername'] ?? ''; exitWithMessage("-1", getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2");
$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"]));
} }
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?"); exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to change your username in game"]));
$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]));
+17 -15
View File
@@ -1,35 +1,37 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
checkClientDatabaseVersion(); $conn0 = newConnection(0);
$conn = newConnection(); $conn1 = newConnection(1);
$post = getPostData(); $post = getPostData();
$targetId = (int)$post['targetId'] ?? 0; $targetId = (int)$post['targetId'] ?? 0;
$token = $post['token'] ?? ''; $token = $post['token'] ?? '';
$username = $post['username'] ?? ''; $username = $post['username'] ?? '';
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?"); $stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? AND token = ?");
$stmt->bind_param("ss", $token, $username); $stmt->bind_param("ss", $username, $token);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$row = $result->fetch_assoc();
if (!$row) {
echo encrypt(json_encode(["success" => false, "message" => 'User info not found']));
exit;
}
$stmt->close(); $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(); $time = time();
$stmt = $conn->prepare("UPDATE userposts SET deleted_at = ? WHERE id = ? AND userId = ? AND deleted_at = 0"); $stmt = $conn1->prepare("UPDATE userposts SET deleted_at = ? WHERE id = ? AND userId = ? AND deleted_at = 0");
$stmt->bind_param("iii", $time, $targetId, $user_id); $stmt->bind_param("iii", $time, $targetId, $user_id);
$stmt->execute(); $stmt->execute();
$success = $stmt->affected_rows > 0;
$stmt->close(); $stmt->close();
echo encrypt(json_encode(["success" => $success])); echo encrypt(json_encode(["success" => $stmt->affected_rows > 0]));
$conn->close(); $conn0->close();
$conn1->close();
+18 -9
View File
@@ -1,29 +1,38 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
checkClientDatabaseVersion();
$post = getPostData(); $post = getPostData();
$id = $post['id'] ?? ''; $id = $post['id'] ?? '';
$token = $post['token'] ?? ''; $token = $post['token'] ?? '';
$username = $post['username'] ?? ''; $username = $post['username'] ?? '';
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?"); $stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? AND token = ? LIMIT 1");
$stmt->bind_param("ss", $token, $username); $stmt->bind_param("ss", $username, $token);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$row = $result->fetch_assoc();
if (!$row) exit;
$stmt->close(); $stmt->close();
$row = $result->fetch_assoc();
if ($result->num_rows != 1) exit;
$user_id = $row["id"]; $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(); $time = time();
$stmt = $conn->prepare("UPDATE chats SET deleted_at = ? WHERE userId = ? AND id = ?"); $stmt = $conn1->prepare("UPDATE chats SET deleted_at = ? WHERE userId = ? AND id = ?");
$stmt->bind_param("iii", $time, $user_id, $id); $stmt->bind_param("iii", $time, $user_id, $id);
$stmt->execute(); $stmt->execute();
$stmt->close(); $stmt->close();
$conn->close(); $conn0->close();
$conn1->close();
+17 -7
View File
@@ -1,7 +1,6 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
checkClientDatabaseVersion();
$post = getPostData(); $post = getPostData();
$id = $post['id'] ?? ''; $id = $post['id'] ?? '';
@@ -11,22 +10,33 @@ $username = $post['username'] ?? '';
if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~]+$/', $content)) exit; if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~]+$/', $content)) exit;
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?"); $stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? AND token = ?");
$stmt->bind_param("ss", $token, $username); $stmt->bind_param("ss", $username, $token);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
$row = $result->fetch_assoc(); $row = $result->fetch_assoc();
if (!$row) exit; if (!$row) exit;
$stmt->close();
$user_id = $row["id"]; $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); $content = base64_encode($content);
$stmt = $conn->prepare("UPDATE chats SET content = ? WHERE userId = ? AND id = ?"); $stmt = $conn1->prepare("UPDATE chats SET content = ? WHERE userId = ? AND id = ?");
$stmt->bind_param("sii", $content, $user_id, $id); $stmt->bind_param("sii", $content, $user_id, $id);
$stmt->execute(); $stmt->execute();
$stmt->close(); $stmt->close();
$conn->close(); $conn0->close();
$conn1->close();
+31 -15
View File
@@ -1,31 +1,47 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
checkClientDatabaseVersion();
$post = getPostData(); $post = getPostData();
$uesrId = $post['uesrId'] ?? ''; $uesrId = $post['uesrId'] ?? '';
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$stmt = $conn->prepare("SELECT * FROM users WHERE id = ?"); $stmt = $conn0->prepare("SELECT username, id FROM users WHERE id = ?");
$stmt->bind_param("i", $uesrId); $stmt->bind_param("i", $uesrId);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
if ($result->num_rows > 0) { if ($result->num_rows > 0) {
$row = $result->fetch_assoc(); $row = $result->fetch_assoc();
$savedata = json_decode($row['save_data'], true);
$custom = null; $stmt = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ?");
if (isset($savedata['bird']['customIcon']['selected'])) { $stmt->bind_param("i", $row['id']);
$selected = $savedata['bird']['customIcon']['selected']; $stmt->execute();
foreach ($savedata['bird']['customIcon']['data'] as $entry) { $result2 = $stmt->get_result();
if (isset($entry['uuid']) && $entry['uuid'] === $selected) { $stmt->close();
$custom = $entry['data']; $row2 = $result2->fetch_assoc();
break;
} $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"];
} }
} }
echo encrypt(json_encode([ echo encrypt(json_encode([
"success" => true, "success" => true,
"totalNormalBerries" => $savedata['gameStore']['totalNormalBerries'] ?? 0, "totalNormalBerries" => $savedata['gameStore']['totalNormalBerries'] ?? 0,
@@ -40,7 +56,7 @@ if ($result->num_rows > 0) {
"name" => $row['username'], "name" => $row['username'],
"icon" => $savedata['bird']['icon'] ?? 1, "icon" => $savedata['bird']['icon'] ?? 1,
"overlay" => $savedata['bird']['overlay'] ?? 0, "overlay" => $savedata['bird']['overlay'] ?? 0,
"customIcon" => $custom, "customIcon" => $icon,
"playerIconColor" => $savedata['settings']['colors']['icon'] ?? [255,255,255], "playerIconColor" => $savedata['settings']['colors']['icon'] ?? [255,255,255],
"playerOverlayColor" => $savedata['settings']['colors']['overlay'] ?? [255,255,255] "playerOverlayColor" => $savedata['settings']['colors']['overlay'] ?? [255,255,255]
])); ]));
@@ -48,5 +64,5 @@ if ($result->num_rows > 0) {
echo encrypt(json_encode(["success" => false])); echo encrypt(json_encode(["success" => false]));
} }
$stmt->close(); $conn0->close();
$conn->close(); $conn1->close();
+20 -7
View File
@@ -1,23 +1,36 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
checkClientDatabaseVersion();
$conn = newConnection(); $conn = newConnection();
$post = getPostData(); $post = getPostData();
$targetId = (int)$post['targetId'] ?? 0; $targetId = (int)$post['targetId'] ?? 0;
$stmt = $conn->prepare(" $stmt = $conn->prepare("
SELECT p.id, p.content, p.timestamp, p.likes, u.id as userId SELECT id, content, timestamp, votes, userId
FROM userposts p FROM userposts
JOIN users u ON p.userId = u.id WHERE userId = ? AND deleted_at = 0
WHERE u.id = ? AND p.deleted_at = 0 ORDER BY id DESC
ORDER BY p.id DESC
"); ");
$stmt->bind_param("i", $targetId); $stmt->bind_param("i", $targetId);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
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)))); 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)
)));
$conn->close(); $conn->close();
+38 -28
View File
@@ -1,53 +1,66 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
if (isAllowedDatabaseVersion(getClientVersion())) { if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") { require __DIR__ . '/backported/1.5.1/getChatroomMessages.php';
require __DIR__ . '/backported/1.5.1/getChatroomMessages.php'; exit;
exit;
}
} }
checkClientDatabaseVersion(); $conn0 = newConnection(0);
$conn = newConnection(); $conn1 = newConnection(1);
$stmt = $conn->prepare(" $stmt = $conn1->prepare("
SELECT c.id AS chat_id, c.content, c.deleted_at, u.id AS user_id, u.username, u.save_data SELECT id, content, deleted_at, userId
FROM chats c FROM chats
JOIN users u ON c.userId = u.id WHERE deleted_at = 0
WHERE u.banned = 0 AND c.deleted_at = 0 ORDER BY id DESC
ORDER BY c.id DESC
LIMIT 50 LIMIT 50
"); ");
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$rows = $result->fetch_all(MYSQLI_ASSOC); $stmt->close();
$mapped = []; $mapped = [];
$icons = []; $icons = [];
foreach ($rows as $row) { foreach ($result->fetch_all(mode: MYSQLI_ASSOC) as $row) {
$savedata = json_decode($row['save_data'], true); $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);
$customIcon = $savedata['bird']['customIcon']['selected'] ?? null; $customIcon = $savedata['bird']['customIcon']['selected'] ?? null;
if ($customIcon != null && strlen($customIcon) == 36 && $icons[$customIcon] == null) { if ($customIcon != null && strlen($customIcon) == 36 && $icons[$customIcon] == null) {
$stmt = $conn->prepare("SELECT data FROM marketplaceicons WHERE uuid = ?"); $stmt = $conn1->prepare("SELECT data FROM marketplaceicons WHERE id = ?");
$stmt->bind_param("s", $customIcon); $stmt->bind_param("s", $customIcon);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
$rowData = $result->fetch_assoc(); $rowData = $result->fetch_assoc();
if ($rowData) { if ($rowData) {
$stmt->close();
$icons[$customIcon] = $rowData["data"]; $icons[$customIcon] = $rowData["data"];
} }
} }
$mapped[] = [ $mapped[] = [
'username' => $row['username'], 'username' => $row3['username'],
'userid' => $row['user_id'], 'userid' => $row['userId'],
'content' => (int)$row['deleted_at'] == 0 ? $row['content'] : null, 'content' => (int)$row['deleted_at'] == 0 ? $row['content'] : null,
'deleted' => (int)$row['deleted_at'] != 0, 'deleted' => (int)$row['deleted_at'] != 0,
'id' => $row['chat_id'], 'id' => $row['id'],
'icon' => $savedata['bird']['icon'] ?? 1, 'icon' => $savedata['bird']['icon'] ?? 1,
'overlay' => $savedata['bird']['overlay'] ?? 0, 'overlay' => $savedata['bird']['overlay'] ?? 0,
'birdColor' => $savedata['settings']['colors']['icon'] ?? [255,255,255], 'birdColor' => $savedata['settings']['colors']['icon'] ?? [255,255,255],
@@ -57,10 +70,7 @@ foreach ($rows as $row) {
} }
if (getClientVersion() == "1.6") { echo encrypt(json_encode(getClientVersion() == "1.6" ? $mapped : ["messages" => array_reverse($mapped), "customIcons" => $icons == [] ? new stdClass() : $icons]));
echo encrypt(json_encode($mapped));
} else {
echo encrypt(json_encode(["messages" => array_reverse($mapped), "customIcons" => $icons == [] ? new stdClass() : $icons]));
}
$conn->close(); $conn0->close();
$conn1->close();
-18
View File
@@ -1,18 +0,0 @@
<?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();
+11 -2
View File
@@ -1,5 +1,14 @@
<?php <?php
require __DIR__ . '/../config/general.php';
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
echo $latestVersion;
$conn0 = newConnection(0);
$stmt = $conn0->prepare("SELECT versionName 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["versionName"] ?? 'N/A';
+53 -35
View File
@@ -1,83 +1,101 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
checkClientDatabaseVersion(); $conn0 = newConnection(0);
$conn = newConnection(); $conn1 = newConnection(1);
$post = getPostData(); $post = getPostData();
$userId = (int)$post['userId'] ?? 0; $userId = (int) $post['userId'] ?? 0;
$sortBy = (int)$post['sortBy'] ?? 2; $sortBy = (int) $post['sortBy'] ?? 2;
$priceRangeEnabled = isset($post['priceRangeEnabled']) ? (string)$post['priceRangeEnabled'] == 'False' ? false : true : false; $priceRangeEnabled = isset($post['priceRangeEnabled']) ? (string) $post['priceRangeEnabled'] == 'False' ? false : true : false;
$priceRangeMin = (int)$post['priceRangeMin'] ?? 10; $priceRangeMin = (int) $post['priceRangeMin'] ?? 10;
$priceRangeMax = (int)$post['priceRangeMax'] ?? 250; $priceRangeMax = (int) $post['priceRangeMax'] ?? 250;
$searchForEnabled = isset($post['searchForEnabled']) ? (string)$post['searchForEnabled'] == 'False' ? false : true : false; $searchForEnabled = isset($post['searchForEnabled']) ? (string) $post['searchForEnabled'] == 'False' ? false : true : false;
$searchForValue = (string)$post['searchForValue'] ?? ''; $searchForValue = (string) $post['searchForValue'] ?? '';
$onlyShowEnabled = isset($post['onlyShowEnabled']) ? (string)$post['onlyShowEnabled'] == 'False' ? false : true : false; $onlyShowEnabled = isset($post['onlyShowEnabled']) ? (string) $post['onlyShowEnabled'] == 'False' ? false : true : false;
$onlyShowValue = (string)$post['onlyShowValue'] ?? ''; $onlyShowValue = (string) $post['onlyShowValue'] ?? '';
$currentIcons = json_decode(base64_decode((string)($post['currentIcons'] ?? 'W10K'))); $currentIcons = json_decode(base64_decode((string) ($post['currentIcons'] ?? 'W10K')));
$where = ["u.banned = 0", "(c.state = 1 OR c.state = 2)"]; $where = ["state = 1"];
$params = []; $params = [];
$types = ""; $types = "";
$order = match($sortBy) { $order = match ($sortBy) {
1 => "ORDER BY c.price ASC", 1 => "ORDER BY price ASC",
2 => "ORDER BY c.id ASC", 2 => "ORDER BY id ASC",
3 => "ORDER BY c.id DESC", 3 => "ORDER BY id DESC",
default => "ORDER BY c.price DESC", default => "ORDER BY price DESC",
}; };
if ($priceRangeEnabled) { if ($priceRangeEnabled) {
$where[] = "c.price BETWEEN ? AND ?"; $where[] = "price BETWEEN ? AND ?";
$params[] = $priceRangeMin; $params[] = $priceRangeMin;
$params[] = $priceRangeMax; $params[] = $priceRangeMax;
$types .= "ii"; $types .= "ii";
} }
if ($searchForEnabled && $searchForValue !== '') { if ($searchForEnabled && $searchForValue !== '') {
$where[] = "FROM_BASE64(c.name) LIKE ?"; $where[] = "FROM_BASE64(name) LIKE ?";
$params[] = "%$searchForValue%"; $params[] = "%$searchForValue%";
$types .= "s"; $types .= "s";
} }
if ($onlyShowEnabled) { if ($onlyShowEnabled) {
if ($onlyShowValue === '0') { if ($onlyShowValue === '0') {
$where[] = "c.userId = ?"; $where[] = "userId = ?";
$params[] = $userId; $params[] = $userId;
$types .= "i"; $types .= "i";
} elseif ($onlyShowValue === '1') { } elseif ($onlyShowValue === '1') {
$where[] = "c.userId != ?"; $where[] = "userId != ?";
$params[] = $userId; $params[] = $userId;
$types .= "i"; $types .= "i";
} elseif ($onlyShowValue === '2') { } elseif ($onlyShowValue === '2') {
$placeholders = implode(',', array_fill(0, count($currentIcons), '?')); $placeholders = implode(',', array_fill(0, count($currentIcons), '?'));
$where[] = "c.uuid IN ($placeholders)"; $where[] = "uuid IN ($placeholders)";
$params = array_merge($params, $currentIcons); $params = array_merge($params, $currentIcons);
$types .= str_repeat('s', count($currentIcons)); $types .= str_repeat('s', count($currentIcons));
} elseif ($onlyShowValue === '3') { } elseif ($onlyShowValue === '3') {
$placeholders = implode(',', array_fill(0, count($currentIcons), '?')); $placeholders = implode(',', array_fill(0, count($currentIcons), '?'));
$where[] = "c.uuid NOT IN ($placeholders)"; $where[] = "uuid NOT IN ($placeholders)";
$params = array_merge($params, $currentIcons); $params = array_merge($params, $currentIcons);
$types .= str_repeat('s', count($currentIcons)); $types .= str_repeat('s', count($currentIcons));
} }
} }
$sql = " $sql = "
SELECT c.data, u.username, u.id, c.price, c.name, c.uuid, c.state SELECT data, price, name, id, state, userId
FROM marketplaceicons c FROM marketplaceicons
JOIN users u ON c.userId = u.id
WHERE " . implode(" AND ", $where) . " WHERE " . implode(" AND ", $where) . "
$order $order
"; ";
$stmt = $conn->prepare($sql); $stmt = $conn1->prepare($sql);
if (!empty($params)) $stmt->bind_param($types, ...$params);
if (!empty($params)) {
$stmt->bind_param($types, ...$params);
}
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
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)))); echo encrypt(json_encode(array_map(
function ($row) {
global $conn0;
$conn->close(); $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();
+36 -33
View File
@@ -1,31 +1,27 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
if (getClientVersion() == "0" && isAllowedDatabaseVersion("1.4.0-beta1") && isAllowedDatabaseVersion("1.4.0") && isAllowedDatabaseVersion("1.4.1")) { if (
require __DIR__ . '/backported/1.4.0-beta1/getTopPlayers.php'; 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';
exit; 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(); $post = getPostData();
$request_type = $post['type'] ?? ''; $request_type = $post['type'] ?? (isLauncher() ? '0' : '');
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$request_value = ""; $request_value = "";
if ($request_type === "0") { if ($request_type == "0") {
$request_value = "highScore"; $request_value = "highScore";
} else if ($request_type === "1") { } else if ($request_type == "1") {
$request_value = match((int)$post['showType'] ?? 0) { $request_value = match((int)$post['showType'] ?? 0) {
1 => "totalPoisonBerries", 1 => "totalPoisonBerries",
2 => "totalSlowBerries", 2 => "totalSlowBerries",
@@ -36,22 +32,28 @@ if ($request_type === "0") {
7 => "totalAntiBerries", 7 => "totalAntiBerries",
default => "totalNormalBerries" default => "totalNormalBerries"
}; };
} else if ($request_type !== "2" && $request_type !== "3" && $request_type !== "4") { } else if ($request_type != "2" && $request_type != "3" && $request_type != "4") {
exitWithMessage(json_encode([])); exitWithMessage(json_encode([]));
} }
$stmt = $conn->prepare("SELECT username, id, save_data, legacy_high_score $stmt = $conn0->prepare("SELECT username, id FROM users WHERE leaderboards_banned = 0");
FROM users
WHERE banned = 0 AND leaderboardsBanned = 0");
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$rows = $result->fetch_all(MYSQLI_ASSOC); $stmt->close();
$mapped = []; $mapped = [];
$icons = []; $icons = [];
foreach ($rows as $row) { foreach ($result->fetch_all(mode: MYSQLI_ASSOC) as $row) {
$savedata = json_decode($row['save_data'], true); $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);
if (!$savedata) continue; if (!$savedata) continue;
if ($request_type == "4") { if ($request_type == "4") {
@@ -59,27 +61,27 @@ foreach ($rows as $row) {
$value = 0; $value = 0;
foreach ($berries as $b) $value += (int)($savedata['gameStore'][$b] ?? 0); foreach ($berries as $b) $value += (int)($savedata['gameStore'][$b] ?? 0);
} else { } else {
$value = $request_type != 2 ? $request_type != 3 ? ($savedata['gameStore'][$request_value] ?? 0) : ($row['legacy_high_score'] ?? 0) : ($savedata['bird']['customIcon']['balance'] ?? 0); $value = $request_type != 2 ? $request_type != 3 ? ($savedata['gameStore'][$request_value] ?? 0) : ($row2['legacy_high_score'] ?? 0) : ($savedata['bird']['customIcon']['balance'] ?? 0);
} }
if ($value <= 0) continue; if ($value <= 0) continue;
$customIcon = $savedata['bird']['customIcon']['selected'] ?? null; $customIcon = $savedata['bird']['customIcon']['selected'] ?? null;
if ($customIcon != null && strlen($customIcon) == 36 && $icons[$customIcon] == null) { if ($customIcon && strlen($customIcon) == 36 && empty($icons[$customIcon])) {
$stmt = $conn->prepare("SELECT data FROM marketplaceicons WHERE uuid = ?"); $stmt = $conn1->prepare("SELECT data FROM marketplaceicons WHERE id = ?");
$stmt->bind_param("s", $customIcon); $stmt->bind_param("s", $customIcon);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
$rowData = $result->fetch_assoc(); $rowData = $result->fetch_assoc();
if ($rowData) { if ($rowData) {
$stmt->close();
$icons[$customIcon] = $rowData["data"]; $icons[$customIcon] = $rowData["data"];
} }
} }
$mapped[] = [ $mapped[] = [
'username' => $row['username'], 'username' => $row['username'],
'userid' => $row['id'], 'userid' => $id,
'value' => $value, 'value' => $value,
'icon' => $savedata['bird']['icon'] ?? 1, 'icon' => $savedata['bird']['icon'] ?? 1,
'overlay' => $savedata['bird']['overlay'] ?? 0, 'overlay' => $savedata['bird']['overlay'] ?? 0,
@@ -98,4 +100,5 @@ if (getClientVersion() == "1.6" || (getClientVersion() == "1.6.1" && $request_ty
echo encrypt(json_encode(["entries" => $limited, "customIcons" => $icons == [] ? new stdClass() : $icons])); echo encrypt(json_encode(["entries" => $limited, "customIcons" => $icons == [] ? new stdClass() : $icons]));
} }
$conn->close(); $conn0->close();
$conn1->close();
-34
View File
@@ -1,34 +0,0 @@
<?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();
Executable → Regular
+1 -2
View File
@@ -1,5 +1,4 @@
<?php <?php
require __DIR__ . '/../../incl/util.php'; require __DIR__ . '/../../incl/util.php';
require __DIR__ . '/../../config/general.php';
setPlainHeader(); setPlainHeader();
echo $latestLauncherVersion; echo "1.1.0";
Executable → Regular
+44 -13
View File
@@ -1,25 +1,56 @@
<?php <?php
require __DIR__ . '/../../incl/util.php'; require __DIR__ . '/../../incl/util.php';
setJsonHeader(); header("Content-Type: application/json");
$conn = newConnection(); $conn = newConnection(0);
$stmt = $conn->prepare("SELECT * FROM launcherversions WHERE hidden = 0 ORDER BY id DESC"); $stmt = $conn->prepare("SELECT versionName, downloads, place FROM launcherversionmanifest WHERE hidden = 0 AND game = 1 ORDER BY id DESC");
$stmt->execute(); $stmt->execute();
$result_versions = $stmt->get_result(); $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)); $versions = array_map(function($row) use ($conn) {
$downloads = json_decode($row['downloads'], true);
$stmt = $conn->prepare("SELECT * FROM launchercategories ORDER BY id DESC"); $downloads = array_combine(
$stmt->execute(); array_map(fn($k) => match($k) {
'windows-x86' => 'windows',
'windows-x64' => 'windows',
'linux-x64' => 'linux',
'macos-universal' => 'macos',
default => $k
}, array_keys($downloads)),
array_values($downloads)
);
$result_categories = $stmt->get_result(); $platforms = array_keys($downloads);
$rows = $result_categories->fetch_all(MYSQLI_ASSOC);
$categories = []; $downloadUrls = [];
foreach ($rows as $row) { foreach ($downloads as $platform => $fileId) {
$categories[$row['id']] = $row['name']; $cdnStmt = $conn->prepare("SELECT path FROM files WHERE id = ?");
} $cdnStmt->bind_param("i", $fileId);
$cdnStmt->execute();
$cdnResult = $cdnStmt->get_result()->fetch_assoc();
$downloadUrls[] = $cdnResult ? "https://archive.org/download/lncvrt-games-archive/" . $cdnResult['path'] : null;
$cdnStmt->close();
}
echo json_encode(["versions" => $versions, "categories" => $categories]); return [
'id' => $row['place'],
'version' => $row['versionName'],
'displayName' => $row['versionName'],
'platforms' => $platforms,
'downloadUrls' => $downloadUrls,
'executables' => array_map(function($platform) use ($row) {
return match(true) {
in_array($platform, ['windows', 'windows-arm64']) => $row['place'] >= 16 ? 'Berry Dash.exe' : 'Foodie Dash.exe',
$platform === 'macos' => $row['place'] >= 16 ? 'Berry Dash.app' : 'Foodie Dash.app',
$platform === 'linux' => $row['place'] >= 16 ? 'Berry Dash.x86_64' : 'Foodie Dash.x86_64',
in_array($platform, ['android', 'ios']) => null,
default => null
};
}, $platforms)
];
}, $result_versions->fetch_all(MYSQLI_ASSOC));
echo json_encode($versions);
$conn->close(); $conn->close();
+84 -25
View File
@@ -1,42 +1,101 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
if (isAllowedDatabaseVersion(getClientVersion())) { if (
if (getClientVersion() == "1.4.0-beta1") { getClientVersion() == "1.4.0-beta1" ||
require __DIR__ . '/backported/1.4.0-beta1/loadAccount.php'; getClientVersion() == "1.4.0" ||
exit; getClientVersion() == "1.4.1" ||
} getClientVersion() == "1.5.0" ||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") { getClientVersion() == "1.5.1" ||
require __DIR__ . '/backported/1.5/loadAccount.php'; getClientVersion() == "1.5.2"
exit; ) {
} require __DIR__ . '/backported/1.4.0-beta1/loadAccount.php';
exit;
} }
checkClientDatabaseVersion();
$post = getPostData(); $post = getPostData();
$token = $post['token'] ?? ''; $token = $post['token'] ?? '';
$username = $post['username'] ?? ''; $username = $post['username'] ?? '';
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?"); $stmt = $conn0->prepare("SELECT id, username FROM users WHERE username = ? AND token = ?");
$stmt->bind_param("ss", $token, $username); $stmt->bind_param("ss", $username, $token);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
if ($result->num_rows > 0) { if ($result->num_rows != 1) {
$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"])); 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(); $stmt->close();
$conn->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();
+33 -41
View File
@@ -1,62 +1,54 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
if (isAllowedDatabaseVersion(getClientVersion())) { if (
if ( getClientVersion() == "1.2-beta2" ||
getClientVersion() == "1.2-beta2" || getClientVersion() == "1.2" ||
getClientVersion() == "1.2" || getClientVersion() == "1.21" ||
getClientVersion() == "1.21" || getClientVersion() == "1.3-beta1" ||
getClientVersion() == "1.3-beta1" getClientVersion() == "1.3-beta2" ||
) { getClientVersion() == "1.3" ||
require __DIR__ . '/backported/1.2-beta2/loginAccount.php'; getClientVersion() == "1.33" ||
exit; getClientVersion() == "1.4.0-beta1" ||
} getClientVersion() == "1.4.0" ||
if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") { getClientVersion() == "1.4.1"
require __DIR__ . '/backported/1.3-beta2/loginAccount.php'; ) {
exit; require __DIR__ . '/backported/1.2-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;
}
} }
checkClientDatabaseVersion(); if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
$conn = newConnection(); require __DIR__ . '/backported/1.5/loginAccount.php';
exit;
}
$conn0 = newConnection(0);
$conn1 = newConnection(1);
$post = getPostData(); $post = getPostData();
$username = $post['username']; $username = $post['username'];
$password = $post['password']; $password = $post['password'];
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?"); $stmt = $conn0->prepare("SELECT id, username, password, token FROM users WHERE username = ?");
$stmt->bind_param("s", $username); $stmt->bind_param("s", $username);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
if ($result->num_rows === 0) { if ($result->num_rows != 1) exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
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"]));
$user = $result->fetch_assoc(); $id = $row['id'];
$token = $row['token'];
if (!password_verify($password, $user["password"])) {
exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
}
$id = $user['id'];
$token = $user['token'];
$ip = getIPAddress(); $ip = getIPAddress();
$stmt = $conn->prepare("UPDATE users SET latest_ip = ?, token = ? WHERE id = ?"); $stmt = $conn0->prepare("UPDATE users SET latest_ip = ? WHERE id = ?");
$stmt->bind_param("ssi", $ip, $token, $id); $stmt->bind_param("si", $ip, $id);
$stmt->execute(); $stmt->execute();
$stmt->close();
$data = ["session" => $token, "username" => $user['username'], "userid" => $id]; $data = ["session" => $token, "username" => $row['username'], "userid" => $id];
echo encrypt(json_encode(["success" => true, "data" => $data])); echo encrypt(json_encode(["success" => true, "data" => $data]));
$stmt->close(); $conn0->close();
$conn->close(); $conn1->close();
+17 -59
View File
@@ -1,64 +1,22 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
if (isAllowedDatabaseVersion(getClientVersion())) { if (
if (getClientVersion() == "1.2-beta2" || getClientVersion() == "1.2") { getClientVersion() == "1.2-beta2" ||
require __DIR__ . '/backported/1.2-beta2/registerAccount.php'; getClientVersion() == "1.2" ||
exit; getClientVersion() == "1.21" ||
} getClientVersion() == "1.3-beta1" ||
if ( getClientVersion() == "1.3-beta2" ||
getClientVersion() == "1.21" || getClientVersion() == "1.3" ||
getClientVersion() == "1.3-beta1" || getClientVersion() == "1.33" ||
getClientVersion() == "1.3-beta2" || getClientVersion() == "1.4.0-beta1" ||
getClientVersion() == "1.3" getClientVersion() == "1.4.0" ||
) { getClientVersion() == "1.4.1" ||
require __DIR__ . '/backported/1.21/registerAccount.php'; getClientVersion() == "1.5.0" ||
exit; getClientVersion() == "1.5.1" ||
} getClientVersion() == "1.5.2"
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") { ) {
require __DIR__ . '/backported/1.5/registerAccount.php'; exitWithMessage("-1", getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2");
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"]));
} }
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to register an account in game"]));
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]));
+20 -12
View File
@@ -1,7 +1,6 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
checkClientDatabaseVersion();
$post = getPostData(); $post = getPostData();
$id = $post['id'] ?? ''; $id = $post['id'] ?? '';
@@ -9,23 +8,30 @@ $reason = $post['reason'] ?? '';
$token = $post['token'] ?? ''; $token = $post['token'] ?? '';
$username = $post['username'] ?? ''; $username = $post['username'] ?? '';
if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~]+$/', $reason)) { if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~]+$/', $reason)) exit;
exitWithMessage(json_encode(["success" => false]));
}
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?"); $stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ? LIMIT 1");
$stmt->bind_param("ss", $token, $username); $stmt->bind_param("ss", $username, $token);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$row = $result->fetch_assoc(); $row = $result->fetch_assoc();
if (!$row) exit; if ($result->num_rows != 1) exit;
$stmt->close(); $stmt->close();
$user_id = $row["id"]; $user_id = $row["id"];
$stmt = $conn->prepare("SELECT id FROM chats WHERE userId != ? AND deleted_at = 0 AND id = ? LIMIT 1"); $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->bind_param("ii", $user_id, $id); $stmt->bind_param("ii", $user_id, $id);
$stmt->execute(); $stmt->execute();
$res = $stmt->get_result(); $res = $stmt->get_result();
@@ -33,7 +39,7 @@ $stmt->close();
if ($res->num_rows < 0) exit; if ($res->num_rows < 0) exit;
$stmt = $conn->prepare("SELECT id FROM chatroom_reports WHERE chatId = ? AND userId = ? LIMIT 1"); $stmt = $conn1->prepare("SELECT id FROM chatroom_reports WHERE chatId = ? AND userId = ? LIMIT 1");
$stmt->bind_param("ii", $id, $user_id); $stmt->bind_param("ii", $id, $user_id);
$stmt->execute(); $stmt->execute();
$res = $stmt->get_result(); $res = $stmt->get_result();
@@ -44,8 +50,10 @@ if ($res->num_rows > 0) exit;
$time = time(); $time = time();
$reason = base64_encode($reason); $reason = base64_encode($reason);
$stmt = $conn->prepare("INSERT INTO chatroom_reports (chatid, userId, reason, timestamp) VALUES (?, ?, ?, ?)"); $stmt = $conn1->prepare("INSERT INTO chatroom_reports (chatid, userId, reason, timestamp) VALUES (?, ?, ?, ?)");
$stmt->bind_param("iisi", $id, $user_id, $reason, $time); $stmt->bind_param("iisi", $id, $user_id, $reason, $time);
$stmt->execute(); $stmt->execute();
$stmt->close();
$conn->close(); $conn0->close();
$conn1->close();
+51 -33
View File
@@ -1,29 +1,26 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
if (isAllowedDatabaseVersion(getClientVersion())) { if (
if ( getClientVersion() == "1.2-beta2" ||
getClientVersion() == "1.2-beta2" || getClientVersion() == "1.2" ||
getClientVersion() == "1.2" || getClientVersion() == "1.21" ||
getClientVersion() == "1.21" || getClientVersion() == "1.3-beta1" ||
getClientVersion() == "1.3-beta1" || getClientVersion() == "1.3-beta2" ||
getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" ||
getClientVersion() == "1.3" || getClientVersion() == "1.33"
getClientVersion() == "1.33" ) {
) { require __DIR__ . '/backported/1.2-beta2/syncAccount.php';
require __DIR__ . '/backported/1.2-beta2/syncAccount.php'; exit;
exit; }
} if (getClientVersion() == "1.4.0-beta1" || getClientVersion() == "1.4.0" || getClientVersion() == "1.4.1") {
if (getClientVersion() == "1.4.0-beta1") { require __DIR__ . '/backported/1.4.0-beta1/saveAccount.php';
require __DIR__ . '/backported/1.4.0-beta1/saveAccount.php'; exit;
exit; }
} if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") { require __DIR__ . '/backported/1.5/saveAccount.php';
require __DIR__ . '/backported/1.5/saveAccount.php'; exit;
exit;
}
} }
checkClientDatabaseVersion();
$post = getPostData(); $post = getPostData();
$token = $post['token'] ?? ''; $token = $post['token'] ?? '';
@@ -40,22 +37,43 @@ try {
echo encrypt(json_encode(["success" => false, "message" => "Couldn't parse save data"])); echo encrypt(json_encode(["success" => false, "message" => "Couldn't parse save data"]));
} }
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?"); $stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
$stmt->bind_param("ss", $token, $username); $stmt->bind_param("ss", $username, $token);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
if ($result->num_rows > 0) { if ($result->num_rows != 1) {
$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"])); 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(); $stmt->close();
$conn->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();
+20 -12
View File
@@ -1,13 +1,10 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
if (isAllowedDatabaseVersion(getClientVersion())) { if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") { require __DIR__ . '/backported/1.5.1/sendChatroomMessage.php';
require __DIR__ . '/backported/1.5.1/sendChatroomMessage.php'; exit;
exit;
}
} }
checkClientDatabaseVersion();
$post = getPostData(); $post = getPostData();
$request_content = $post['content'] ?? ''; $request_content = $post['content'] ?? '';
@@ -18,25 +15,36 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
exitWithMessage(json_encode(["success" => false, "message" => "Invalid content recieved"])); exitWithMessage(json_encode(["success" => false, "message" => "Invalid content recieved"]));
} }
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?"); $stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
$stmt->bind_param("ss", $token, $username); $stmt->bind_param("ss", $username, $token);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$stmt->close();
$row = $result->fetch_assoc(); $row = $result->fetch_assoc();
if (!$row) exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"])); if (!$row) exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
$stmt->close();
$id = $row["id"]; $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); $content = base64_encode($request_content);
$time = time(); $time = time();
$stmt = $conn->prepare("INSERT INTO chats (userId, content, timestamp) VALUES (?, ?, ?)"); $stmt = $conn1->prepare("INSERT INTO chats (userId, content, timestamp) VALUES (?, ?, ?)");
$stmt->bind_param("isi", $id, $content, $time); $stmt->bind_param("isi", $id, $content, $time);
$stmt->execute(); $stmt->execute();
$stmt->close(); $stmt->close();
echo encrypt(json_encode(["success" => true])); echo encrypt(json_encode(["success" => true]));
$conn->close(); $conn0->close();
$conn1->close();
+18 -9
View File
@@ -1,7 +1,6 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
checkClientDatabaseVersion();
$post = getPostData(); $post = getPostData();
$request_content = $post['content'] ?? ''; $request_content = $post['content'] ?? '';
@@ -12,25 +11,35 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
exitWithMessage(json_encode(["success" => false])); exitWithMessage(json_encode(["success" => false]));
} }
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?"); $stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
$stmt->bind_param("ss", $token, $username); $stmt->bind_param("ss", $username, $token);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$row = $result->fetch_assoc();
if (!$row) exitWithMessage(json_encode(["success" => false]));
$stmt->close(); $stmt->close();
if ($result->num_rows != 1) exitWithMessage(json_encode(["success" => false]));
$row = $result->fetch_assoc();
$id = $row["id"]; $id = $row["id"];
$stmt = $conn1->prepare("SELECT * FROM userdata WHERE id = ?");
$stmt->bind_param("i", $id);
$stmt->execute();
$result2 = $stmt->get_result();
$stmt->close();
if ($result2->num_rows != 1) exitWithMessage(json_encode(["success" => false]));
$row2 = $result2->fetch_assoc();
$content = base64_encode($request_content); $content = base64_encode($request_content);
$time = time(); $time = time();
$stmt = $conn->prepare("INSERT INTO userposts (userId, content, timestamp) VALUES (?, ?, ?)"); $stmt = $conn1->prepare("INSERT INTO userposts (userId, content, timestamp) VALUES (?, ?, ?)");
$stmt->bind_param("isi", $id, $content, $time); $stmt->bind_param("isi", $id, $content, $time);
$stmt->execute(); $stmt->execute();
$stmt->close(); $stmt->close();
echo encrypt(json_encode(["success" => true])); echo encrypt(json_encode(["success" => true]));
$conn->close(); $conn0->close();
$conn1->close();
+1 -56
View File
@@ -1,59 +1,4 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
checkClientDatabaseVersion(); exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to upload a marketplace icon"]));
$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();
+8 -8
View File
@@ -1,8 +1,8 @@
<?php <?php
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
checkClientDatabaseVersion(); $conn0 = newConnection(0);
$conn = newConnection(); $conn1 = newConnection(1);
$post = getPostData(); $post = getPostData();
$targetId = (int)$post['targetId'] ?? 0; $targetId = (int)$post['targetId'] ?? 0;
@@ -14,8 +14,8 @@ if ($liked !== 0 && $liked !== 1) {
exit; exit;
} }
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?"); $stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
$stmt->bind_param("ss", $token, $username); $stmt->bind_param("ss", $username, $token);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
$row = $result->fetch_assoc(); $row = $result->fetch_assoc();
@@ -27,7 +27,7 @@ $stmt->close();
$user_id = $row["id"]; $user_id = $row["id"];
$stmt = $conn->prepare("SELECT votes, likes FROM userposts WHERE id = ?"); $stmt = $conn1->prepare("SELECT votes FROM userposts WHERE id = ?");
$stmt->bind_param("i", $targetId); $stmt->bind_param("i", $targetId);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
@@ -39,7 +39,6 @@ if (!$row) {
$stmt->close(); $stmt->close();
$votes = json_decode($row["votes"], true) ?? []; $votes = json_decode($row["votes"], true) ?? [];
$likes = (int)$row["likes"];
if (isset($votes[$user_id])) { if (isset($votes[$user_id])) {
echo encrypt(json_encode(["success" => false, "message" => 'You have already voted'])); echo encrypt(json_encode(["success" => false, "message" => 'You have already voted']));
exit; exit;
@@ -49,11 +48,12 @@ $votes[$user_id] = $liked === 0 ? false : true;
$likes += $liked ? 1 : -1; $likes += $liked ? 1 : -1;
$votes = json_encode($votes); $votes = json_encode($votes);
$stmt = $conn->prepare("UPDATE userposts SET likes = ?, votes = ? WHERE id = ?"); $stmt = $conn1->prepare("UPDATE userposts SET likes = ?, votes = ? WHERE id = ?");
$stmt->bind_param("isi", $likes, $votes, $targetId); $stmt->bind_param("isi", $likes, $votes, $targetId);
$stmt->execute(); $stmt->execute();
$stmt->close(); $stmt->close();
echo encrypt(json_encode(["success" => true, "likes" => $likes])); echo encrypt(json_encode(["success" => true, "likes" => $likes]));
$conn->close(); $conn0->close();
$conn1->close();
-6
View File
@@ -1,6 +0,0 @@
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
View File
@@ -0,0 +1 @@
Require all denied
+21 -43
View File
@@ -3,41 +3,51 @@ function setPlainHeader() {
header("Content-Type: text/plain"); header("Content-Type: text/plain");
} }
function setJsonHeader() {
header("Content-Type: application/json");
}
function getIPAddress() { function getIPAddress() {
return $_SERVER['HTTP_CF_CONNECTING_IP']; return $_SERVER['REMOTE_ADDR'];
} }
function newConnection() { function newConnection($type = 1) {
include __DIR__.'/../config/connection.php'; include __DIR__.'/../config/connection.php';
try { try {
$conn = new mysqli($db_host, $db_user, $db_pass, $db_name, $db_port); 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
);
} catch (mysqli_sql_exception $e) { } catch (mysqli_sql_exception $e) {
exitWithMessage("-999"); exitWithMessage("-999");
} }
return $conn;
} }
function getClientVersion() { function getClientVersion() {
return $_SERVER['HTTP_CLIENTVERSION']; return $_SERVER['HTTP_CLIENTVERSION'];
} }
function isLauncher() {
return ($_SERVER['HTTP_REQUESTER'] == "BerryDashLauncher" && $_SERVER['HTTP_LAUNCHERVERSION'] == "1.1.0");
}
function encrypt($plainText) { function encrypt($plainText) {
include __DIR__.'/../config/encryption.php'; include __DIR__.'/../config/encryption.php';
$key = isLauncher() ? $SERVER_SEND_TRANSFER_KEY_SPECIFIC["1.6"] : $SERVER_SEND_TRANSFER_KEY_SPECIFIC[getClientVersion()];
if ($key == null) return;
$iv = random_bytes(16); $iv = random_bytes(16);
$cipher = openssl_encrypt($plainText, 'aes-256-cbc', $SERVER_SEND_TRANSFER_KEY_SPECIFIC[getClientVersion()] ?? $SERVER_SEND_TRANSFER_KEY, OPENSSL_RAW_DATA, $iv); $cipher = openssl_encrypt($plainText, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
return base64_encode($iv . $cipher); return base64_encode($iv . $cipher);
} }
function decrypt($dataB64) { function decrypt($dataB64) {
include __DIR__.'/../config/encryption.php'; include __DIR__.'/../config/encryption.php';
$key = $SERVER_RECEIVE_TRANSFER_KEY_SPECIFIC[getClientVersion()];
if ($key == null) return;
$data = base64_decode($dataB64); $data = base64_decode($dataB64);
$iv = substr($data, 0, 16); $iv = substr($data, 0, 16);
$cipher = substr($data, 16); $cipher = substr($data, 16);
$decrypted = openssl_decrypt($cipher, 'aes-256-cbc', $SERVER_RECEIVE_TRANSFER_KEY_SPECIFIC[getClientVersion()] ?? $SERVER_RECEIVE_TRANSFER_KEY, OPENSSL_RAW_DATA, $iv); $decrypted = openssl_decrypt($cipher, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
if ($decrypted === false) { if ($decrypted === false) {
exit(encrypt('-997')); exit(encrypt('-997'));
} }
@@ -53,45 +63,13 @@ function exitWithMessage($message, $encrypt = true) {
exit; 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() { function getPostData() {
$raw = file_get_contents("php://input"); $raw = file_get_contents("php://input");
parse_str($raw, $postData); parse_str($raw, $postData);
$decrypted = []; $decrypted = [];
foreach ($postData as $k => $v) { foreach ($postData as $k => $v) {
$decKey = decrypt($k); $decKey = (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1") ? $k : decrypt($k);
$decValue = decrypt($v); $decValue = decrypt($v);
$decrypted[$decKey] = $decValue; $decrypted[$decKey] = $decValue;
} }