Compare commits
29
Commits
main
...
f99c8a42f3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f99c8a42f3
|
||
|
|
5be2bbf796
|
||
|
|
abf62a6df6
|
||
|
|
4269f91653
|
||
|
|
fec71aa736
|
||
|
|
b3858a2e85
|
||
|
|
e8243db62a
|
||
|
|
680da8414a
|
||
|
|
a5f98cd7c4
|
||
|
|
07c437d05e
|
||
|
|
2728fc6e83
|
||
|
|
7cc6afeca6
|
||
|
|
8ac41d660a
|
||
|
|
1d29f5da84
|
||
|
|
34328de9b6
|
||
|
|
2d78565f77
|
||
|
|
1cee054cd7
|
||
|
|
f511da6f21
|
||
|
|
9b499e35f4
|
||
|
|
b292e4b58f
|
||
|
|
9f26fc103f
|
||
|
|
1b93f152a2
|
||
|
|
7da7eb90c6
|
||
|
|
56f92948fa
|
||
|
|
12c5b431cb
|
||
|
|
87e595b420
|
||
|
|
cf6c0eff73
|
||
|
|
b4884362fe
|
||
|
|
85fff884ec
|
No files matched your search
@@ -631,7 +631,7 @@ to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
Berry Dash Server Code Copyright (C) 2025 Lncvrt
|
||||
Berry Dash Server Code Copyright (C) 2026 Lncvrt
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -651,7 +651,7 @@ Also add information on how to contact you by electronic and paper mail.
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
Berry Dash Server Code Copyright (C) 2025 Lncvrt
|
||||
Berry Dash Server Code Copyright (C) 2026 Lncvrt
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
@@ -2,37 +2,13 @@
|
||||
|
||||
> [!CAUTION]
|
||||
> This project has moved to the Lncvrt Games originization.
|
||||
> You can find the new repository [here](https://github.com/Lncvrt-Games/servers)
|
||||
>
|
||||
> You can find the new server API [here](https://github.com/Lncvrt-Games/api).
|
||||
>
|
||||
> NOTE: This is also the branch that is being modified so it can continue to work for 1.8.2 and lower.
|
||||
>
|
||||
> Find old branch [here](https://github.com/BerryDash/server/tree/main)
|
||||
|
||||
---
|
||||
|
||||
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.
|
||||
This is the source code for Berry Dash.
|
||||
@@ -0,0 +1 @@
|
||||
Require all denied
|
||||
+10
-5
@@ -1,6 +1,11 @@
|
||||
<?php
|
||||
$db_host = "localhost";
|
||||
$db_port = 3306;
|
||||
$db_user = "";
|
||||
$db_pass = "";
|
||||
$db_name = "";
|
||||
$games_db_host = "localhost";
|
||||
$games_db_port = 3306;
|
||||
$games_db_user = "";
|
||||
$games_db_pass = "";
|
||||
$games_db_name = "";
|
||||
$bd_db_host = "localhost";
|
||||
$bd_db_port = 3306;
|
||||
$bd_db_user = "";
|
||||
$bd_db_pass = "";
|
||||
$bd_db_name = "";
|
||||
@@ -1,5 +1,3 @@
|
||||
<?php
|
||||
$SERVER_RECEIVE_TRANSFER_KEY = ""; //SERVER_SEND_TRANSFER_KEY on the client
|
||||
$SERVER_SEND_TRANSFER_KEY = ""; //SERVER_RECEIVE_TRANSFER_KEY on the client
|
||||
$SERVER_RECEIVE_TRANSFER_KEY_SPECIFIC = [];
|
||||
$SERVER_SEND_TRANSFER_KEY_SPECIFIC = [];
|
||||
$SERVER_RECEIVE_TRANSFER_KEY_SPECIFIC = ["1.5.0" => "67bafe2be3940d1f713b96b3ca4fb852", "1.5.1" => "67bafe2be3940d1f713b96b3ca4fb852", "1.5.2" => "474111bd6b6e16a044f50e464029def6", "1.6" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.6.1" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.6.2" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.6.3" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.7" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.7.1" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.8" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.8.1" => "397fb5fca6d8f9c8afe49d8cd31bae4c", "1.8.2" => "7bedd0bfd2ea5d4629ea2426b284c0cc"];
|
||||
$SERVER_SEND_TRANSFER_KEY_SPECIFIC = ["1.5.0" => "00490b14efea6a20a1395aa6b83a83c0", "1.5.1" => "00490b14efea6a20a1395aa6b83a83c0", "1.5.2" => "7c734d6f1ea37dc1e1157f8d9c8b588f", "1.6" => "779a4cff3d144649324133495f136b0f", "1.6.1" => "779a4cff3d144649324133495f136b0f", "1.6.2" => "779a4cff3d144649324133495f136b0f", "1.6.3" => "779a4cff3d144649324133495f136b0f", "1.7" => "779a4cff3d144649324133495f136b0f", "1.7.1" => "779a4cff3d144649324133495f136b0f", "1.8" => "779a4cff3d144649324133495f136b0f", "1.8.1" => "779a4cff3d144649324133495f136b0f", "1.8.2" => "dd82c15dc4cfa03f9a06ecffe19cc525"];
|
||||
@@ -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
@@ -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 */;
|
||||
@@ -0,0 +1 @@
|
||||
Require all denied
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$request_username = $_POST['username'];
|
||||
$request_password = $_POST['password'];
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $request_username);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
@@ -17,28 +17,56 @@ if ($result->num_rows > 0) {
|
||||
$login_ip = getIPAddress();
|
||||
$login_time = time();
|
||||
$uid = $row['id'];
|
||||
$username = $row['username'];
|
||||
$highscore = $row['legacy_high_score'];
|
||||
$token = $row['token'];
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET latest_ip = ? WHERE id = ?");
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE id = ?");
|
||||
$stmt2->bind_param("i", $uid);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
echo '-1';
|
||||
exit;
|
||||
}
|
||||
|
||||
$user2 = $result2->fetch_assoc();
|
||||
|
||||
$username = $row['username'];
|
||||
$highscore = $user2['legacy_high_score'];
|
||||
$token = $user2['token'];
|
||||
$savedata = json_decode($user2['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();
|
||||
|
||||
echo "$token:$uid:$highscore";
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1"
|
||||
) {
|
||||
echo "$token:$uid:$highscore";
|
||||
} else if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
echo "$token:$uid:$highscore:$icon:$overlay";
|
||||
} else if (getClientVersion() == "1.4.0-beta1" || getClientVersion() == "1.4.0" || getClientVersion() == "1.4.1") {
|
||||
echo "1:$token:$username:$uid:$highscore:$icon:$overlay";
|
||||
}
|
||||
} else {
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit("-2");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit("-2");
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
?>
|
||||
$conn0->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';
|
||||
@@ -1,25 +1,40 @@
|
||||
<?php
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$request_uid = $_POST['userID'] ?? 0;
|
||||
$request_session = $_POST['gameSession'] ?? '';
|
||||
$request_score = $_POST['highScore'] ?? 0;
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND id = ?");
|
||||
$stmt->bind_param("ss", $request_session, $request_uid);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE id = ?");
|
||||
$stmt->bind_param("s", $request_uid);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$updateStmt = $conn->prepare("UPDATE users SET legacy_high_score = ? WHERE token = ? AND id = ?");
|
||||
$updateStmt->bind_param("isi", $request_score, $request_session, $request_uid);
|
||||
$updateStmt->execute();
|
||||
echo "1";
|
||||
$updateStmt->close();
|
||||
} else {
|
||||
echo "-3";
|
||||
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();
|
||||
$conn->close();
|
||||
?>
|
||||
$request_uid = $result->fetch_assoc()["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt2->bind_param("si", $request_session, $request_uid);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
echo (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") ? "-2" : "-3";
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$updateStmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ? WHERE token = ? AND id = ?");
|
||||
$updateStmt->bind_param("isi", $request_score, $request_session, $request_uid);
|
||||
$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';
|
||||
|
||||
?>
|
||||
@@ -1,25 +1,8 @@
|
||||
<?php
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$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 = $conn0->prepare("SELECT username, id FROM users WHERE leaderboards_banned = 0");
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
@@ -28,18 +11,48 @@ if ($result->num_rows > 0) {
|
||||
$topPlayers = [];
|
||||
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$id = $row["id"];
|
||||
$stmt2 = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? AND legacy_high_score > 0 ORDER BY legacy_high_score DESC LIMIT 1");
|
||||
$stmt2->bind_param("i", $id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$user2 = $result2->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($user2['save_data'], true);
|
||||
$icon = $savedata['bird']['icon'] ?? 1;
|
||||
$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"] . ":" . $user2["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $id;
|
||||
} else if (getClientVersion() == "0") {
|
||||
$topPlayers[] = base64_encode($row["username"]) . ":" . $user2["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"]) . ":" . $user2["legacy_high_score"] . ":" . $icon . ":" . $overlay . ":" . $id . ":" . $birdColor[0] . ":" . $birdColor[1] . ":" . $birdColor[2] . ":" . $overlayColor[0] . ":" . $overlayColor[1] . ":" . $overlayColor[2];
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
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();
|
||||
?>
|
||||
@@ -1,23 +1,59 @@
|
||||
<?php
|
||||
$token = $_POST['gameSession'] ?? '';
|
||||
$username = $_POST['userName'] ?? '';
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
$post = getPostData();
|
||||
$token = $post['gameSession'] ?? '';
|
||||
$username = $post['userName'] ?? '';
|
||||
} else {
|
||||
$token = $_POST['gameSession'] ?? '';
|
||||
$username = $_POST['userName'] ?? '';
|
||||
}
|
||||
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$icon = $savedata['bird']['icon'] ?? 1;
|
||||
$overlay = $savedata['bird']['overlay'] ?? 0;
|
||||
echo "1:" . $row['legacy_high_score'] . ":" . $icon . ":" . $overlay;
|
||||
} else {
|
||||
echo "-1";
|
||||
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;
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT save_data, legacy_high_score FROM userdata WHERE id = ? AND token = ? LIMIT 1");
|
||||
$stmt2->bind_param("is", $id, $token);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
|
||||
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();
|
||||
|
||||
?>
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$request_userName = $_POST['userName'] ?? 0;
|
||||
$request_gameSession = $_POST['gameSession'] ?? '';
|
||||
@@ -7,27 +8,42 @@ $request_highScore = $_POST['highScore'] ?? 0;
|
||||
$request_icon = $_POST['icon'] ?? 0;
|
||||
$request_overlay = $_POST['overlay'] ?? 0;
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $request_gameSession, $request_userName);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $request_userName);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$savedata['bird']['icon'] = $request_icon;
|
||||
$savedata['bird']['overlay'] = $request_overlay;
|
||||
$savedata = json_encode($savedata);
|
||||
|
||||
$updateStmt = $conn->prepare("UPDATE users SET legacy_high_score = ?, save_data = ? WHERE token = ? AND username = ?");
|
||||
$updateStmt->bind_param("isss", $request_highScore, $savedata, $request_gameSession, $request_userName);
|
||||
$updateStmt->execute();
|
||||
echo "1";
|
||||
$updateStmt->close();
|
||||
} else {
|
||||
echo "-3";
|
||||
if ($result->num_rows != 1) {
|
||||
echo "-2";
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
$request_uid = $result->fetch_assoc()["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt2->bind_param("si", $request_gameSession, $request_uid);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
|
||||
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);
|
||||
|
||||
$updateStmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ?, save_data = ? WHERE token = ? AND id = ?");
|
||||
$updateStmt->bind_param("issi", $request_highScore, $savedata, $request_gameSession, $request_uid);
|
||||
$updateStmt->execute();
|
||||
$updateStmt->close();
|
||||
|
||||
echo "1";
|
||||
@@ -1,31 +1,46 @@
|
||||
<?php
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn->prepare("
|
||||
SELECT c.id AS chat_id, c.content, u.username, u.id AS user_id, u.save_data
|
||||
FROM chats c
|
||||
JOIN users u ON c.userId = u.id
|
||||
WHERE u.banned = 0 AND c.deleted_at = 0
|
||||
ORDER BY c.id DESC LIMIT 50
|
||||
$stmt = $conn1 ->prepare("
|
||||
SELECT id, content, userId
|
||||
FROM chats
|
||||
WHERE deleted_at = 0
|
||||
ORDER BY id DESC LIMIT 50
|
||||
");
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
$rows = [];
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$userId = $row["userId"];
|
||||
$stmt2 = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt2->bind_param("i", $userId);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
if ($result2->num_rows != 1) continue;
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$stmt3 = $conn0->prepare("SELECT username FROM users WHERE id = ? LIMIT 1");
|
||||
$stmt3->bind_param("i", $userId);
|
||||
$stmt3->execute();
|
||||
$result3 = $stmt3->get_result();
|
||||
if ($result3->num_rows != 1) continue;
|
||||
$row3 = $result3->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
$icon = $savedata['bird']['icon'] ?? 1;
|
||||
$overlay = $savedata['bird']['overlay'] ?? 0;
|
||||
$birdColor = $savedata['settings']['colors']['icon'] ?? [255,255,255];
|
||||
$overlayColor = $savedata['settings']['colors']['overlay'] ?? [255,255,255];
|
||||
|
||||
$rows[] = implode(";", [
|
||||
$row['chat_id'],
|
||||
base64_encode($row['username']),
|
||||
$row['id'],
|
||||
base64_encode($row3['username']),
|
||||
$row['content'],
|
||||
$icon,
|
||||
$overlay,
|
||||
$row['user_id'],
|
||||
$userId,
|
||||
$birdColor[0],
|
||||
$birdColor[1],
|
||||
$birdColor[2],
|
||||
@@ -37,4 +52,5 @@ while ($row = $result->fetch_assoc()) {
|
||||
|
||||
echo encrypt("1" . ":" . implode("|", array_reverse($rows)));
|
||||
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -7,9 +7,9 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
|
||||
exitWithMessage("-1");
|
||||
}
|
||||
|
||||
$conn = newConnection();
|
||||
$conn = newConnection(1);
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ?");
|
||||
$stmt = $conn->prepare("SELECT id FROM userdata WHERE token = ?");
|
||||
$stmt->bind_param("s", $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
@@ -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();
|
||||
?>
|
||||
@@ -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();
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$post = getPostData();
|
||||
$username = $post['username'];
|
||||
@@ -7,12 +8,12 @@ $password = $post['password'];
|
||||
$currentHighScore = $post['currentHighScore'] ?? 0;
|
||||
$loginType = $post['loginType'] ?? '0';
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows === 0) {
|
||||
if ($result->num_rows != 1) {
|
||||
exitWithMessage("-1");
|
||||
}
|
||||
|
||||
@@ -23,15 +24,29 @@ if (!password_verify($password, $user["password"])) {
|
||||
}
|
||||
|
||||
$id = $user['id'];
|
||||
$token = $user['token'];
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE id = ?");
|
||||
$stmt2->bind_param("i", $id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
exitWithMessage("-1");
|
||||
}
|
||||
|
||||
$user2 = $result2->fetch_assoc();
|
||||
|
||||
$token = $user2['token'];
|
||||
$ip = getIPAddress();
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET latest_ip = ?, token = ? WHERE id = ?");
|
||||
$stmt->bind_param("ssi", $ip, $token, $id);
|
||||
$stmt = $conn0->prepare("UPDATE users SET latest_ip = ? WHERE id = ?");
|
||||
$stmt->bind_param("si", $ip, $id);
|
||||
$stmt->execute();
|
||||
$stmt2 = $conn1->prepare("UPDATE userdata SET token = ? WHERE id = ?");
|
||||
$stmt2->bind_param("si", $token, $id);
|
||||
$stmt2->execute();
|
||||
|
||||
if ($currentHighScore > $user['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->execute();
|
||||
$user['legacy_high_score'] = $currentHighScore;
|
||||
@@ -47,4 +62,5 @@ if ($loginType === "0") {
|
||||
echo encrypt("1" . ":" . $token . ":" . $user['username'] . ":" . $id);
|
||||
}
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
$conn0->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");
|
||||
@@ -8,40 +8,61 @@ $overlay = (int)$post['overlay'] ?? 0;
|
||||
$birdR = (int)$post['birdR'] ?? 255;
|
||||
$birdG = (int)$post['birdG'] ?? 255;
|
||||
$birdB = (int)$post['birdB'] ?? 255;
|
||||
$overlayR = (int)$post['overlayR'] ?? 255;
|
||||
$overlayG = (int)$post['overlayG'] ?? 255;
|
||||
$overlayB = (int)$post['overlayB'] ?? 255;
|
||||
if (getClientVersion() == "1.5.2") {
|
||||
$overlayR = (int)$post['overlayR'] ?? 255;
|
||||
$overlayG = (int)$post['overlayG'] ?? 255;
|
||||
$overlayB = (int)$post['overlayB'] ?? 255;
|
||||
}
|
||||
$birdColor = [$birdR, $birdG, $birdB];
|
||||
$overlayColor = [$overlayR, $overlayG, $overlayB];
|
||||
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$savedata['bird']['icon'] = $icon;
|
||||
$savedata['bird']['overlay'] = $overlay;
|
||||
$savedata['settings']['colors']['icon'] = $birdColor;
|
||||
$savedata['settings']['colors']['overlay'] = $overlayColor;
|
||||
$savedata = json_encode($savedata);
|
||||
$updateStmt = $conn->prepare("UPDATE users SET legacy_high_score = ?, save_data = ? WHERE token = ? AND username = ?");
|
||||
$updateStmt->bind_param("isss",
|
||||
$highScore,
|
||||
$savedata,
|
||||
$token,
|
||||
$username
|
||||
);
|
||||
$updateStmt->execute();
|
||||
$updateStmt->close();
|
||||
echo encrypt("1");
|
||||
} else {
|
||||
if ($result->num_rows != 1) {
|
||||
echo encrypt("-1");
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE id = ? AND token = ?");
|
||||
$stmt2->bind_param("is", $id, $token);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
|
||||
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;
|
||||
$savedata['settings']['colors']['icon'] = $birdColor;
|
||||
if (getClientVersion() == "1.5.2") $savedata['settings']['colors']['overlay'] = $overlayColor;
|
||||
$savedata = json_encode($savedata);
|
||||
$updateStmt = $conn1->prepare("UPDATE userdata SET legacy_high_score = ?, save_data = ? WHERE id = ? AND token = ?");
|
||||
$updateStmt->bind_param("isis",
|
||||
$highScore,
|
||||
$savedata,
|
||||
$id,
|
||||
$token
|
||||
);
|
||||
$updateStmt->execute();
|
||||
$updateStmt->close();
|
||||
echo encrypt("1");
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -1,23 +1,4 @@
|
||||
<?php
|
||||
require __DIR__ . '/../config/general.php';
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
|
||||
$clientVersion = $_SERVER['HTTP_CLIENTVERSION'] ?? "0";
|
||||
if (($_SERVER['HTTP_REQUESTER'] ?? "0") != "BerryDashClient" && ($_SERVER['HTTP_USER_AGENT'] ?? "0") != "BerryDashClient" && ($clientVersion == "1.4.1" || $clientVersion == "1.4.0" || $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";
|
||||
}
|
||||
echo '1';
|
||||
@@ -1,45 +1,24 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
|
||||
$post = getPostData();
|
||||
$oldpassword = $post['oldpassword'] ?? '';
|
||||
$newpassword = $post['newpassword'] ?? '';
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
|
||||
if (!preg_match('/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!@#$%^&*()_\-+=]{8,}$/', $newpassword)) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "New password must be at least 8 characters with at least one letter and one number"]));
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3" ||
|
||||
getClientVersion() == "1.33" ||
|
||||
getClientVersion() == "1.4.0-beta1" ||
|
||||
getClientVersion() == "1.4.0" ||
|
||||
getClientVersion() == "1.4.1"
|
||||
) {
|
||||
echo "-1";
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
exitWithMessage("-1");
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $username, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$user = $result->fetch_assoc();
|
||||
if (!password_verify($oldpassword, $user['password'])) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Old password is incorrect"]));
|
||||
}
|
||||
if (password_verify($newpassword, $user['password'])) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "New password cannot be the same as the old password"]));
|
||||
}
|
||||
$id = $user['id'];
|
||||
} else {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
}
|
||||
|
||||
$hashednewpassword = password_hash($newpassword, PASSWORD_DEFAULT);
|
||||
$token = bin2hex(random_bytes(256));
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET token = ?, password = ? WHERE id = ?");
|
||||
$stmt->bind_param("sss", $token, $hashednewpassword, $id);
|
||||
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
echo encrypt(json_encode(["success" => true, "token" => $token]));
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to register an account in game"]));
|
||||
@@ -1,53 +1,24 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.3-beta1") {
|
||||
require __DIR__ . '/backported/1.3-beta1/changeAccountUsername.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
require __DIR__ . '/backported/1.3-beta2/changeAccountUsername.php';
|
||||
exit;
|
||||
}
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3" ||
|
||||
getClientVersion() == "1.33" ||
|
||||
getClientVersion() == "1.4.0-beta1" ||
|
||||
getClientVersion() == "1.4.0" ||
|
||||
getClientVersion() == "1.4.1"
|
||||
) {
|
||||
echo "-1";
|
||||
exit;
|
||||
}
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
|
||||
$post = getPostData();
|
||||
$oldusername = $post['oldusername'] ?? '';
|
||||
$newusername = $post['newusername'] ?? '';
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9]{3,16}$/', $newusername)) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "New username must be 3-16 characters, letters and numbers only"]));
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
exitWithMessage("-1");
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $newusername);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "New username already exists"]));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("ss", $oldusername, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows === 0) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid old username"]));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET username = ? WHERE username = ? AND token = ?");
|
||||
$stmt->bind_param("sss", $newusername, $username, $token);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->affected_rows === 0) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
}
|
||||
|
||||
echo encrypt(json_encode(["success" => true]));
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to register an account in game"]));
|
||||
@@ -1,35 +1,36 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$post = getPostData();
|
||||
$targetId = (int)$post['targetId'] ?? 0;
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
if ($result->num_rows != 1) exitWithMessage(json_encode(["success" => false, "message" => 'User info not found']));
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) {
|
||||
echo encrypt(json_encode(["success" => false, "message" => 'User info not found']));
|
||||
exit;
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
$user_id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt2->bind_param("si", $token, $user_id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
if ($result2->num_rows != 1) exitWithMessage(json_encode(["success" => false, "message" => 'User info not found']));
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$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->execute();
|
||||
|
||||
$success = $stmt->affected_rows > 0;
|
||||
$stmt->close();
|
||||
echo encrypt(json_encode(["success" => $stmt->affected_rows > 0]));
|
||||
|
||||
echo encrypt(json_encode(["success" => $success]));
|
||||
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$id = $post['id'] ?? '';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$id = $post['id'] ?? '';
|
||||
@@ -11,10 +10,11 @@ $username = $post['username'] ?? '';
|
||||
|
||||
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->bind_param("ss", $token, $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
@@ -22,11 +22,21 @@ if (!$row) exit;
|
||||
$stmt->close();
|
||||
|
||||
$user_id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt2->bind_param("si", $token, $user_id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
if (!$row2) exit;
|
||||
$stmt2->close();
|
||||
|
||||
$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->execute();
|
||||
$stmt->close();
|
||||
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -1,21 +1,28 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$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->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ?");
|
||||
$stmt2->bind_param("i", $row['id']);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
$custom = null;
|
||||
if (isset($savedata['bird']['customIcon']['selected'])) {
|
||||
$selected = $savedata['bird']['customIcon']['selected'];
|
||||
@@ -49,4 +56,5 @@ if ($result->num_rows > 0) {
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -1,23 +1,35 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
|
||||
$post = getPostData();
|
||||
$targetId = (int)$post['targetId'] ?? 0;
|
||||
|
||||
$stmt = $conn->prepare("
|
||||
SELECT p.id, p.content, p.timestamp, p.likes, u.id as userId
|
||||
FROM userposts p
|
||||
JOIN users u ON p.userId = u.id
|
||||
WHERE u.id = ? AND p.deleted_at = 0
|
||||
ORDER BY p.id DESC
|
||||
SELECT id, content, timestamp, votes, userId
|
||||
FROM userposts
|
||||
WHERE userId = ? AND deleted_at = 0
|
||||
ORDER BY id DESC
|
||||
");
|
||||
$stmt->bind_param("i", $targetId);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
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();
|
||||
@@ -1,21 +1,18 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5.1/getChatroomMessages.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5.1/getChatroomMessages.php';
|
||||
exit;
|
||||
}
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn->prepare("
|
||||
SELECT c.id AS chat_id, c.content, c.deleted_at, u.id AS user_id, u.username, u.save_data
|
||||
FROM chats c
|
||||
JOIN users u ON c.userId = u.id
|
||||
WHERE u.banned = 0 AND c.deleted_at = 0
|
||||
ORDER BY c.id DESC
|
||||
$stmt = $conn1->prepare("
|
||||
SELECT id, content, deleted_at, userId
|
||||
FROM chats
|
||||
WHERE deleted_at = 0
|
||||
ORDER BY id DESC
|
||||
LIMIT 50
|
||||
");
|
||||
$stmt->execute();
|
||||
@@ -26,12 +23,27 @@ $rows = $result->fetch_all(MYSQLI_ASSOC);
|
||||
$mapped = [];
|
||||
$icons = [];
|
||||
foreach ($rows as $row) {
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$userId = $row["userId"];
|
||||
$stmt2 = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt2->bind_param("i", $userId);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
if ($result2->num_rows != 1) continue;
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$stmt3 = $conn0->prepare("SELECT username FROM users WHERE id = ? LIMIT 1");
|
||||
$stmt3->bind_param("i", $userId);
|
||||
$stmt3->execute();
|
||||
$result3 = $stmt3->get_result();
|
||||
if ($result3->num_rows != 1) continue;
|
||||
$row3 = $result3->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($row2['save_data'], true);
|
||||
|
||||
$customIcon = $savedata['bird']['customIcon']['selected'] ?? 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 uuid = ?");
|
||||
$stmt->bind_param("s", $customIcon);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
@@ -43,11 +55,11 @@ foreach ($rows as $row) {
|
||||
}
|
||||
|
||||
$mapped[] = [
|
||||
'username' => $row['username'],
|
||||
'userid' => $row['user_id'],
|
||||
'username' => $row3['username'],
|
||||
'userid' => $row['userId'],
|
||||
'content' => (int)$row['deleted_at'] == 0 ? $row['content'] : null,
|
||||
'deleted' => (int)$row['deleted_at'] != 0,
|
||||
'id' => $row['chat_id'],
|
||||
'id' => $row['id'],
|
||||
'icon' => $savedata['bird']['icon'] ?? 1,
|
||||
'overlay' => $savedata['bird']['overlay'] ?? 0,
|
||||
'birdColor' => $savedata['settings']['colors']['icon'] ?? [255,255,255],
|
||||
@@ -63,4 +75,5 @@ if (getClientVersion() == "1.6") {
|
||||
echo encrypt(json_encode(["messages" => array_reverse($mapped), "customIcons" => $icons == [] ? new stdClass() : $icons]));
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -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();
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
require __DIR__ . '/../config/general.php';
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
echo $latestVersion;
|
||||
echo "1.8.2";
|
||||
@@ -1,75 +1,74 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$post = getPostData();
|
||||
$userId = (int)$post['userId'] ?? 0;
|
||||
$sortBy = (int)$post['sortBy'] ?? 2;
|
||||
$priceRangeEnabled = isset($post['priceRangeEnabled']) ? (string)$post['priceRangeEnabled'] == 'False' ? false : true : false;
|
||||
$priceRangeMin = (int)$post['priceRangeMin'] ?? 10;
|
||||
$priceRangeMax = (int)$post['priceRangeMax'] ?? 250;
|
||||
$searchForEnabled = isset($post['searchForEnabled']) ? (string)$post['searchForEnabled'] == 'False' ? false : true : false;
|
||||
$searchForValue = (string)$post['searchForValue'] ?? '';
|
||||
$onlyShowEnabled = isset($post['onlyShowEnabled']) ? (string)$post['onlyShowEnabled'] == 'False' ? false : true : false;
|
||||
$onlyShowValue = (string)$post['onlyShowValue'] ?? '';
|
||||
$currentIcons = json_decode(base64_decode((string)($post['currentIcons'] ?? 'W10K')));
|
||||
$userId = (int) $post['userId'] ?? 0;
|
||||
$sortBy = (int) $post['sortBy'] ?? 2;
|
||||
$priceRangeEnabled = isset($post['priceRangeEnabled']) ? (string) $post['priceRangeEnabled'] == 'False' ? false : true : false;
|
||||
$priceRangeMin = (int) $post['priceRangeMin'] ?? 10;
|
||||
$priceRangeMax = (int) $post['priceRangeMax'] ?? 250;
|
||||
$searchForEnabled = isset($post['searchForEnabled']) ? (string) $post['searchForEnabled'] == 'False' ? false : true : false;
|
||||
$searchForValue = (string) $post['searchForValue'] ?? '';
|
||||
$onlyShowEnabled = isset($post['onlyShowEnabled']) ? (string) $post['onlyShowEnabled'] == 'False' ? false : true : false;
|
||||
$onlyShowValue = (string) $post['onlyShowValue'] ?? '';
|
||||
$currentIcons = json_decode(base64_decode((string) ($post['currentIcons'] ?? 'W10K')));
|
||||
|
||||
$where = ["u.banned = 0", "(c.state = 1 OR c.state = 2)"];
|
||||
$where = ["(state = 1 OR state = 2)"];
|
||||
$params = [];
|
||||
$types = "";
|
||||
$order = match($sortBy) {
|
||||
1 => "ORDER BY c.price ASC",
|
||||
2 => "ORDER BY c.id ASC",
|
||||
3 => "ORDER BY c.id DESC",
|
||||
default => "ORDER BY c.price DESC",
|
||||
$order = match ($sortBy) {
|
||||
1 => "ORDER BY price ASC",
|
||||
2 => "ORDER BY id ASC",
|
||||
3 => "ORDER BY id DESC",
|
||||
default => "ORDER BY price DESC",
|
||||
};
|
||||
|
||||
if ($priceRangeEnabled) {
|
||||
$where[] = "c.price BETWEEN ? AND ?";
|
||||
$where[] = "price BETWEEN ? AND ?";
|
||||
$params[] = $priceRangeMin;
|
||||
$params[] = $priceRangeMax;
|
||||
$types .= "ii";
|
||||
}
|
||||
|
||||
if ($searchForEnabled && $searchForValue !== '') {
|
||||
$where[] = "FROM_BASE64(c.name) LIKE ?";
|
||||
$where[] = "FROM_BASE64(name) LIKE ?";
|
||||
$params[] = "%$searchForValue%";
|
||||
$types .= "s";
|
||||
}
|
||||
|
||||
if ($onlyShowEnabled) {
|
||||
if ($onlyShowValue === '0') {
|
||||
$where[] = "c.userId = ?";
|
||||
$where[] = "userId = ?";
|
||||
$params[] = $userId;
|
||||
$types .= "i";
|
||||
} elseif ($onlyShowValue === '1') {
|
||||
$where[] = "c.userId != ?";
|
||||
$where[] = "userId != ?";
|
||||
$params[] = $userId;
|
||||
$types .= "i";
|
||||
} elseif ($onlyShowValue === '2') {
|
||||
$placeholders = implode(',', array_fill(0, count($currentIcons), '?'));
|
||||
$where[] = "c.uuid IN ($placeholders)";
|
||||
$where[] = "uuid IN ($placeholders)";
|
||||
$params = array_merge($params, $currentIcons);
|
||||
$types .= str_repeat('s', count($currentIcons));
|
||||
} elseif ($onlyShowValue === '3') {
|
||||
$placeholders = implode(',', array_fill(0, count($currentIcons), '?'));
|
||||
$where[] = "c.uuid NOT IN ($placeholders)";
|
||||
$where[] = "uuid NOT IN ($placeholders)";
|
||||
$params = array_merge($params, $currentIcons);
|
||||
$types .= str_repeat('s', count($currentIcons));
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT c.data, u.username, u.id, c.price, c.name, c.uuid, c.state
|
||||
FROM marketplaceicons c
|
||||
JOIN users u ON c.userId = u.id
|
||||
SELECT data, price, name, uuid, state, userId
|
||||
FROM marketplaceicons
|
||||
WHERE " . implode(" AND ", $where) . "
|
||||
$order
|
||||
";
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt = $conn1->prepare($sql);
|
||||
|
||||
if (!empty($params)) {
|
||||
$stmt->bind_param($types, ...$params);
|
||||
@@ -78,6 +77,27 @@ if (!empty($params)) {
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
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();
|
||||
$stmt2 = $conn0->prepare("SELECT username FROM users WHERE id = ?");
|
||||
$stmt2->bind_param("i", $row['userId']);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
return [
|
||||
'username' => $row2['username'] ?? 'Unknown',
|
||||
'userid' => $row['userId'],
|
||||
'data' => $row['data'],
|
||||
'uuid' => $row['uuid'],
|
||||
'price' => (int) $row['state'] == 2 ? 100000000 : $row['price'],
|
||||
'name' => base64_decode($row['name'])
|
||||
];
|
||||
},
|
||||
$result->fetch_all(MYSQLI_ASSOC)
|
||||
)));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
+31
-24
@@ -1,26 +1,22 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (getClientVersion() == "0" && isAllowedDatabaseVersion("1.4.0-beta1") && isAllowedDatabaseVersion("1.4.0") && isAllowedDatabaseVersion("1.4.1")) {
|
||||
require __DIR__ . '/backported/1.4.0-beta1/getTopPlayers.php';
|
||||
if (
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3" ||
|
||||
getClientVersion() == "1.33" ||
|
||||
getClientVersion() == "0" || // 1.4.x
|
||||
getClientVersion() == "1.5.0" ||
|
||||
getClientVersion() == "1.5.1" ||
|
||||
getClientVersion() == "1.5.2"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.3-beta2/getTopPlayers.php';
|
||||
exit;
|
||||
}
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
require __DIR__ . '/backported/1.3-beta2/getTopPlayers.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5/getTopPlayers.php';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if ($_SERVER['HTTP_REQUESTER'] != 'BerryDashLauncher') {
|
||||
checkClientDatabaseVersion();
|
||||
}
|
||||
$post = getPostData();
|
||||
$request_type = $post['type'] ?? '';
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$request_value = "";
|
||||
if ($request_type === "0") {
|
||||
@@ -40,9 +36,7 @@ if ($request_type === "0") {
|
||||
exitWithMessage(json_encode([]));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT username, id, save_data, legacy_high_score
|
||||
FROM users
|
||||
WHERE banned = 0 AND leaderboardsBanned = 0");
|
||||
$stmt = $conn0->prepare("SELECT username, id FROM users WHERE leaderboards_banned = 0");
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
@@ -51,7 +45,19 @@ $rows = $result->fetch_all(MYSQLI_ASSOC);
|
||||
$mapped = [];
|
||||
$icons = [];
|
||||
foreach ($rows as $row) {
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$id = $row["id"];
|
||||
$stmt2 = $conn1->prepare("SELECT legacy_high_score, save_data FROM userdata WHERE id = ? LIMIT 1");
|
||||
$stmt2->bind_param("i", $id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$user2 = $result2->fetch_assoc();
|
||||
|
||||
$savedata = json_decode($user2['save_data'], true);
|
||||
if (!$savedata) continue;
|
||||
|
||||
if ($request_type == "4") {
|
||||
@@ -59,14 +65,14 @@ foreach ($rows as $row) {
|
||||
$value = 0;
|
||||
foreach ($berries as $b) $value += (int)($savedata['gameStore'][$b] ?? 0);
|
||||
} else {
|
||||
$value = $request_type != 2 ? $request_type != 3 ? ($savedata['gameStore'][$request_value] ?? 0) : ($row['legacy_high_score'] ?? 0) : ($savedata['bird']['customIcon']['balance'] ?? 0);
|
||||
$value = $request_type != 2 ? $request_type != 3 ? ($savedata['gameStore'][$request_value] ?? 0) : ($user2['legacy_high_score'] ?? 0) : ($savedata['bird']['customIcon']['balance'] ?? 0);
|
||||
}
|
||||
if ($value <= 0) continue;
|
||||
|
||||
$customIcon = $savedata['bird']['customIcon']['selected'] ?? 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 uuid = ?");
|
||||
$stmt->bind_param("s", $customIcon);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
@@ -79,7 +85,7 @@ foreach ($rows as $row) {
|
||||
|
||||
$mapped[] = [
|
||||
'username' => $row['username'],
|
||||
'userid' => $row['id'],
|
||||
'userid' => $id,
|
||||
'value' => $value,
|
||||
'icon' => $savedata['bird']['icon'] ?? 1,
|
||||
'overlay' => $savedata['bird']['overlay'] ?? 0,
|
||||
@@ -98,4 +104,5 @@ if (getClientVersion() == "1.6" || (getClientVersion() == "1.6.1" && $request_ty
|
||||
echo encrypt(json_encode(["entries" => $limited, "customIcons" => $icons == [] ? new stdClass() : $icons]));
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -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
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
require __DIR__ . '/../../incl/util.php';
|
||||
require __DIR__ . '/../../config/general.php';
|
||||
setPlainHeader();
|
||||
echo $latestLauncherVersion;
|
||||
echo "-1";
|
||||
Executable → Regular
+1
-12
@@ -9,17 +9,6 @@ $stmt->execute();
|
||||
$result_versions = $stmt->get_result();
|
||||
$versions = array_map(fn($row) => ['id' => $row['id'], 'version' => $row['version'], 'releaseDate' => $row['releaseDate'], 'displayName' => empty($row['displayName']) ? $row['version'] : $row['displayName'], 'platforms' => json_decode($row['platforms']), 'downloadUrls' => json_decode($row['downloadUrls']), 'executables' => json_decode($row['executables']), 'category' => $row['category']], $result_versions->fetch_all(MYSQLI_ASSOC));
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM launchercategories ORDER BY id DESC");
|
||||
$stmt->execute();
|
||||
|
||||
$result_categories = $stmt->get_result();
|
||||
$rows = $result_categories->fetch_all(MYSQLI_ASSOC);
|
||||
|
||||
$categories = [];
|
||||
foreach ($rows as $row) {
|
||||
$categories[$row['id']] = $row['name'];
|
||||
}
|
||||
|
||||
echo json_encode(["versions" => $versions, "categories" => $categories]);
|
||||
echo json_encode($versions);
|
||||
|
||||
$conn->close();
|
||||
+46
-26
@@ -1,42 +1,62 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.4.0-beta1") {
|
||||
require __DIR__ . '/backported/1.4.0-beta1/loadAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5/loadAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (
|
||||
getClientVersion() == "1.4.0-beta1" ||
|
||||
getClientVersion() == "1.4.0" ||
|
||||
getClientVersion() == "1.4.1" ||
|
||||
getClientVersion() == "1.5.0" ||
|
||||
getClientVersion() == "1.5.1" ||
|
||||
getClientVersion() == "1.5.2"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.4.0-beta1/loadAccount.php';
|
||||
exit;
|
||||
}
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt = $conn0->prepare("SELECT id, username FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
$savedata = json_decode($row['save_data'], true);
|
||||
$savedata['account']['id'] = $row['id'];
|
||||
$savedata['account']['name'] = $row['username'];
|
||||
$savedata['account']['session'] = $row['token'];
|
||||
echo encrypt(json_encode([
|
||||
"success" => true,
|
||||
"data" => $savedata
|
||||
]));
|
||||
} else {
|
||||
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->close();
|
||||
$conn->close();
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT save_data, token FROM userdata WHERE id = ? AND token = ?");
|
||||
$stmt2->bind_param("is", $id, $token);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
|
||||
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'] = $row2['token'];
|
||||
echo encrypt(json_encode([
|
||||
"success" => true,
|
||||
"data" => $savedata
|
||||
]));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
+42
-30
@@ -1,42 +1,38 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.2-beta2/loginAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.3-beta2" || getClientVersion() == "1.3" || getClientVersion() == "1.33") {
|
||||
require __DIR__ . '/backported/1.3-beta2/loginAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.4.0-beta1") {
|
||||
require __DIR__ . '/backported/1.4.0-beta1/loginAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5/loginAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3" ||
|
||||
getClientVersion() == "1.33" ||
|
||||
getClientVersion() == "1.4.0-beta1" ||
|
||||
getClientVersion() == "1.4.0" ||
|
||||
getClientVersion() == "1.4.1"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.2-beta2/loginAccount.php';
|
||||
exit;
|
||||
}
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5/loginAccount.php';
|
||||
exit;
|
||||
}
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$post = getPostData();
|
||||
$username = $post['username'];
|
||||
$password = $post['password'];
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt = $conn0->prepare("SELECT id, username, password FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows === 0) {
|
||||
if ($result->num_rows != 1) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
|
||||
}
|
||||
|
||||
@@ -47,16 +43,32 @@ if (!password_verify($password, $user["password"])) {
|
||||
}
|
||||
|
||||
$id = $user['id'];
|
||||
$token = $user['token'];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT token FROM userdata WHERE id = ?");
|
||||
$stmt2->bind_param("i", $id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
|
||||
if ($result2->num_rows != 1) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
|
||||
}
|
||||
|
||||
$user2 = $result2->fetch_assoc();
|
||||
|
||||
$token = $user2['token'];
|
||||
$ip = getIPAddress();
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET latest_ip = ?, token = ? WHERE id = ?");
|
||||
$stmt->bind_param("ssi", $ip, $token, $id);
|
||||
$stmt = $conn0->prepare("UPDATE users SET latest_ip = ? WHERE id = ?");
|
||||
$stmt->bind_param("si", $ip, $id);
|
||||
$stmt->execute();
|
||||
$stmt2 = $conn1->prepare("UPDATE userdata SET token = ? WHERE id = ?");
|
||||
$stmt2->bind_param("si", $token, $id);
|
||||
$stmt2->execute();
|
||||
|
||||
$data = ["session" => $token, "username" => $user['username'], "userid" => $id];
|
||||
|
||||
echo encrypt(json_encode(["success" => true, "data" => $data]));
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -1,64 +1,24 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.2-beta2" || getClientVersion() == "1.2") {
|
||||
require __DIR__ . '/backported/1.2-beta2/registerAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.21/registerAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5/registerAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3" ||
|
||||
getClientVersion() == "1.33" ||
|
||||
getClientVersion() == "1.4.0-beta1" ||
|
||||
getClientVersion() == "1.4.0" ||
|
||||
getClientVersion() == "1.4.1"
|
||||
) {
|
||||
echo "-1";
|
||||
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 (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
exitWithMessage("-1");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Email is invalid"]));
|
||||
}
|
||||
|
||||
if (!preg_match('/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!@#$%^&*()_\-+=]{8,}$/', $password)) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Password must be at least 8 characters with at least one letter and one number"]));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT id FROM users WHERE username = ? OR email = ?");
|
||||
$stmt->bind_param("ss", $username, $email);
|
||||
$stmt->execute();
|
||||
$res = $stmt->get_result();
|
||||
|
||||
if ($res->num_rows > 0) {
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "Username or email already taken"]));
|
||||
}
|
||||
|
||||
$hashed = password_hash($password, PASSWORD_DEFAULT);
|
||||
$token = bin2hex(random_bytes(256));
|
||||
$ip = getIPAddress();
|
||||
$time = time();
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO users (token, username, password, email, register_time, latest_ip) VALUES (?, ?, ?, ?, ?, ?)");
|
||||
$stmt->bind_param("ssssis", $token, $username, $hashed, $email, $time, $ip);
|
||||
$stmt->execute();
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
echo encrypt(json_encode(["success" => true]));
|
||||
exitWithMessage(json_encode(["success" => false, "message" => "You must use client version 26.1 or higher to register an account in game"]));
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$id = $post['id'] ?? '';
|
||||
@@ -9,23 +8,30 @@ $reason = $post['reason'] ?? '';
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
|
||||
if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~]+$/', $reason)) {
|
||||
exitWithMessage(json_encode(["success" => false]));
|
||||
}
|
||||
if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~]+$/', $reason)) exit;
|
||||
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ? LIMIT 1");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) exit;
|
||||
if ($result->num_rows != 1) exit;
|
||||
$stmt->close();
|
||||
|
||||
$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 = ? AND token = ? LIMIT 1");
|
||||
$stmt2->bind_param("is", $user_id, $token);
|
||||
$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->execute();
|
||||
$res = $stmt->get_result();
|
||||
@@ -33,7 +39,7 @@ $stmt->close();
|
||||
|
||||
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->execute();
|
||||
$res = $stmt->get_result();
|
||||
@@ -44,8 +50,9 @@ if ($res->num_rows > 0) exit;
|
||||
$time = time();
|
||||
$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->execute();
|
||||
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
+50
-34
@@ -1,29 +1,26 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3" ||
|
||||
getClientVersion() == "1.33"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.2-beta2/syncAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.4.0-beta1") {
|
||||
require __DIR__ . '/backported/1.4.0-beta1/saveAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5/saveAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (
|
||||
getClientVersion() == "1.2-beta2" ||
|
||||
getClientVersion() == "1.2" ||
|
||||
getClientVersion() == "1.21" ||
|
||||
getClientVersion() == "1.3-beta1" ||
|
||||
getClientVersion() == "1.3-beta2" ||
|
||||
getClientVersion() == "1.3" ||
|
||||
getClientVersion() == "1.33"
|
||||
) {
|
||||
require __DIR__ . '/backported/1.2-beta2/syncAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.4.0-beta1" || getClientVersion() == "1.4.0" || getClientVersion() == "1.4.1") {
|
||||
require __DIR__ . '/backported/1.4.0-beta1/saveAccount.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5/saveAccount.php';
|
||||
exit;
|
||||
}
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$token = $post['token'] ?? '';
|
||||
@@ -40,22 +37,41 @@ try {
|
||||
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->bind_param("ss", $token, $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$updateStmt = $conn->prepare("UPDATE users SET save_data = ? WHERE token = ? AND username = ?");
|
||||
$updateStmt->bind_param("sss", $savedata, $token, $username);
|
||||
$updateStmt->execute();
|
||||
$updateStmt->close();
|
||||
echo encrypt(json_encode(["success" => true]));
|
||||
} else {
|
||||
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->close();
|
||||
$conn->close();
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT id FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt->bind_param("si", $token, $id);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
$updateStmt = $conn1->prepare("UPDATE userdata SET save_data = ? WHERE token = ? AND id = ?");
|
||||
$updateStmt->bind_param("ssi", $savedata, $token, $id);
|
||||
$updateStmt->execute();
|
||||
$updateStmt->close();
|
||||
echo encrypt(json_encode(["success" => true]));
|
||||
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -1,13 +1,10 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5.1/sendChatroomMessage.php';
|
||||
exit;
|
||||
}
|
||||
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||
require __DIR__ . '/backported/1.5.1/sendChatroomMessage.php';
|
||||
exit;
|
||||
}
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$request_content = $post['content'] ?? '';
|
||||
@@ -18,10 +15,11 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
|
||||
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->bind_param("ss", $token, $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
@@ -29,14 +27,24 @@ if (!$row) exitWithMessage(json_encode(["success" => false, "message" => "Invali
|
||||
$stmt->close();
|
||||
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE id = ? AND token = ?");
|
||||
$stmt2->bind_param("is", $id, $token);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
if (!$row2) exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
$stmt2->close();
|
||||
|
||||
$content = base64_encode($request_content);
|
||||
$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->execute();
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt(json_encode(["success" => true]));
|
||||
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$request_content = $post['content'] ?? '';
|
||||
@@ -12,25 +11,33 @@ if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~
|
||||
exitWithMessage(json_encode(["success" => false]));
|
||||
}
|
||||
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
if ($result->num_rows != 1) exitWithMessage(json_encode(["success" => false]));
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) exitWithMessage(json_encode(["success" => false]));
|
||||
$stmt->close();
|
||||
|
||||
$id = $row["id"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt2->bind_param("si", $token, $id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
if ($result2->num_rows != 1) exitWithMessage(json_encode(["success" => false]));
|
||||
$row2 = $result2->fetch_assoc();
|
||||
|
||||
$content = base64_encode($request_content);
|
||||
$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->execute();
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt(json_encode(["success" => true]));
|
||||
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
|
||||
$post = getPostData();
|
||||
$token = $post['token'] ?? '';
|
||||
@@ -20,23 +19,32 @@ if (strlen($decoded) > 1024 * 1024) exitWithMessage(json_encode(["success" => fa
|
||||
$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"]));
|
||||
if ($info[0] !== 128 || $info[1] !== 128) exitWithMessage(json_encode(["success" => false, "message" => "Image has to be 128x128"]));
|
||||
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $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"];
|
||||
|
||||
$stmt2 = $conn1->prepare("SELECT * FROM userdata WHERE token = ? AND id = ?");
|
||||
$stmt2->bind_param("si", $token, $id);
|
||||
$stmt2->execute();
|
||||
$result2 = $stmt2->get_result();
|
||||
$row2 = $result2->fetch_assoc();
|
||||
if (!$row2) exitWithMessage(json_encode(["success" => false, "message" => "Invalid session token or username, please refresh login"]));
|
||||
$stmt2->close();
|
||||
|
||||
$time = time();
|
||||
$hash = hash('sha512', base64_decode($filecontent));
|
||||
|
||||
$stmt = $conn->prepare("SELECT id FROM marketplaceicons WHERE hash = ?");
|
||||
$stmt = $conn1->prepare("SELECT id FROM marketplaceicons WHERE hash = ?");
|
||||
$stmt->bind_param("s", $hash);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
@@ -48,12 +56,13 @@ $stmt->close();
|
||||
|
||||
$uuid = uuidv4();
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO marketplaceicons (uuid, userId, data, hash, price, name, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt = $conn1->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;
|
||||
$insertId = $conn1->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();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
require __DIR__ . '/../incl/util.php';
|
||||
setPlainHeader();
|
||||
checkClientDatabaseVersion();
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$post = getPostData();
|
||||
$targetId = (int)$post['targetId'] ?? 0;
|
||||
@@ -14,8 +14,8 @@ if ($liked !== 0 && $liked !== 1) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt = $conn0->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
@@ -27,7 +27,7 @@ $stmt->close();
|
||||
|
||||
$user_id = $row["id"];
|
||||
|
||||
$stmt = $conn->prepare("SELECT votes, likes FROM userposts WHERE id = ?");
|
||||
$stmt = $conn1->prepare("SELECT votes, likes FROM userposts WHERE id = ?");
|
||||
$stmt->bind_param("i", $targetId);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
@@ -49,11 +49,12 @@ $votes[$user_id] = $liked === 0 ? false : true;
|
||||
$likes += $liked ? 1 : -1;
|
||||
$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->execute();
|
||||
$stmt->close();
|
||||
|
||||
echo encrypt(json_encode(["success" => true, "likes" => $likes]));
|
||||
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
@@ -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())
|
||||
@@ -0,0 +1 @@
|
||||
Require all denied
|
||||
+17
-39
@@ -8,17 +8,23 @@ function setJsonHeader() {
|
||||
}
|
||||
|
||||
function getIPAddress() {
|
||||
return $_SERVER['HTTP_CF_CONNECTING_IP'];
|
||||
return $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
function newConnection() {
|
||||
function newConnection($type = 1) {
|
||||
include __DIR__.'/../config/connection.php';
|
||||
|
||||
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) {
|
||||
exitWithMessage("-999");
|
||||
}
|
||||
return $conn;
|
||||
}
|
||||
|
||||
function getClientVersion() {
|
||||
@@ -27,17 +33,21 @@ function getClientVersion() {
|
||||
|
||||
function encrypt($plainText) {
|
||||
include __DIR__.'/../config/encryption.php';
|
||||
$key = $SERVER_SEND_TRANSFER_KEY_SPECIFIC[getClientVersion()];
|
||||
if ($key == null) return;
|
||||
$iv = random_bytes(16);
|
||||
$cipher = openssl_encrypt($plainText, 'aes-256-cbc', $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);
|
||||
}
|
||||
|
||||
function decrypt($dataB64) {
|
||||
include __DIR__.'/../config/encryption.php';
|
||||
$key = $SERVER_RECEIVE_TRANSFER_KEY_SPECIFIC[getClientVersion()];
|
||||
if ($key == null) return;
|
||||
$data = base64_decode($dataB64);
|
||||
$iv = substr($data, 0, 16);
|
||||
$cipher = substr($data, 16);
|
||||
$decrypted = openssl_decrypt($cipher, 'aes-256-cbc', $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) {
|
||||
exit(encrypt('-997'));
|
||||
}
|
||||
@@ -53,45 +63,13 @@ function exitWithMessage($message, $encrypt = true) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function isLatestVersion($version) {
|
||||
global $latestVersion;
|
||||
if (!isset($latestVersion)) require __DIR__ . '/../config/general.php';
|
||||
return $version === $latestVersion;
|
||||
}
|
||||
|
||||
function isBetaVersion($version) {
|
||||
global $latestBetaVersion;
|
||||
if (!isset($latestBetaVersion)) require __DIR__ . '/../config/general.php';
|
||||
return $version === $latestBetaVersion;
|
||||
}
|
||||
|
||||
function isAllowedVersion($version) {
|
||||
global $allowedVersions;
|
||||
if (!isset($allowedVersions)) require __DIR__ . '/../config/general.php';
|
||||
return in_array($version, $allowedVersions);
|
||||
}
|
||||
|
||||
function isAllowedDatabaseVersion($version) {
|
||||
global $allowedDatabaseVersions;
|
||||
if (!isset($allowedDatabaseVersions)) require __DIR__ . '/../config/general.php';
|
||||
return in_array($version, $allowedDatabaseVersions);
|
||||
}
|
||||
|
||||
function checkClientDatabaseVersion() {
|
||||
global $allowedDatabaseVersions;
|
||||
if (!isset($allowedDatabaseVersions)) require __DIR__ . '/../config/general.php';
|
||||
if (!isset($_SERVER['HTTP_REQUESTER'])) exitWithMessage("-998");
|
||||
if ($_SERVER['HTTP_REQUESTER'] != "BerryDashClient") exitWithMessage("-998");
|
||||
if (!in_array($_SERVER['HTTP_CLIENTVERSION'] ?? '', $allowedDatabaseVersions)) exitWithMessage("-998");
|
||||
}
|
||||
|
||||
function getPostData() {
|
||||
$raw = file_get_contents("php://input");
|
||||
parse_str($raw, $postData);
|
||||
|
||||
$decrypted = [];
|
||||
foreach ($postData as $k => $v) {
|
||||
$decKey = decrypt($k);
|
||||
$decKey = (getClientVersion() == "1.5.0" || getClientVersion() == "1.5.1") ? $k : decrypt($k);
|
||||
$decValue = decrypt($v);
|
||||
$decrypted[$decKey] = $decValue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user