Add launcher categories

This commit is contained in:
2025-10-04 13:23:41 -07:00
parent a4e089dd8c
commit cbbae78f38
2 changed files with 82 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Sep 12, 2025 at 07:45 PM
-- Generation Time: Oct 04, 2025 at 10:18 PM
-- Server version: 11.8.3-MariaDB-ubu2404
-- PHP Version: 8.1.33
@@ -51,6 +51,17 @@ CREATE TABLE `chats` (
-- --------------------------------------------------------
--
-- 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`
--
@@ -63,7 +74,8 @@ CREATE TABLE `launcherversions` (
`downloadUrls` text NOT NULL,
`platforms` text NOT NULL,
`executables` text NOT NULL,
`hidden` tinyint(1) NOT NULL DEFAULT 1
`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;
-- --------------------------------------------------------
@@ -86,6 +98,21 @@ CREATE TABLE `marketplaceicons` (
-- --------------------------------------------------------
--
-- 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`
--
@@ -139,11 +166,18 @@ 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 PRIMARY KEY (`id`),
ADD KEY `fk_category` (`category`);
--
-- Indexes for table `marketplaceicons`
@@ -152,6 +186,13 @@ 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`
--
@@ -181,6 +222,12 @@ ALTER TABLE `chatroom_reports`
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`
--
@@ -193,6 +240,12 @@ ALTER TABLE `launcherversions`
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`
--
@@ -222,12 +275,24 @@ ALTER TABLE `chatroom_reports`
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`
--

View File

@@ -6,8 +6,20 @@ $conn = newConnection();
$stmt = $conn->prepare("SELECT * FROM launcherversions WHERE hidden = 0 ORDER BY id DESC");
$stmt->execute();
$result = $stmt->get_result();
$result_versions = $stmt->get_result();
$versions = array_map(fn($row) => ['id' => $row['id'], 'version' => $row['version'], 'releaseDate' => $row['releaseDate'], 'displayName' => empty($row['displayName']) ? $row['version'] : $row['displayName'], 'platforms' => json_decode($row['platforms']), 'downloadUrls' => json_decode($row['downloadUrls']), 'executables' => json_decode($row['executables'])], $result_versions->fetch_all(MYSQLI_ASSOC));
echo json_encode(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'])], $result->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(["version" => $versions, "categories" => $categories]);
$conn->close();