From 4bc68b299edcec6c6b5edc0989de1c4fb1982c81 Mon Sep 17 00:00:00 2001 From: ui0ppk Date: Sat, 18 Feb 2023 20:49:20 +0200 Subject: [PATCH] sesdad --- core/classes.php | 2 +- grublox.sql | 113 ++++++++++++++++++++++++++++------------------- 2 files changed, 68 insertions(+), 47 deletions(-) diff --git a/core/classes.php b/core/classes.php index d55791a..548f2b7 100644 --- a/core/classes.php +++ b/core/classes.php @@ -160,7 +160,7 @@ class PartyStarter { unset($_SESSION["user"]); } - $query = $con->prepare('SELECT * FROM friends WHERE user=:id AND state="pending"'); + $query = $con->prepare('SELECT * FROM friendships WHERE user1=:id AND isAccepted=1'); $query->bindParam(':id', $_SESSION['user'], PDO::PARAM_INT); $query->execute(); diff --git a/grublox.sql b/grublox.sql index 7d2ec11..e9d512b 100644 --- a/grublox.sql +++ b/grublox.sql @@ -2,18 +2,26 @@ -- version 5.2.0 -- https://www.phpmyadmin.net/ -- --- Host: 127.0.0.1 --- Generation Time: Feb 16, 2023 at 10:40 AM --- Server version: 10.4.27-MariaDB --- PHP Version: 8.2.0 +-- Host: localhost +-- Generation Time: Feb 18, 2023 at 03:40 PM +-- Server version: 10.4.21-MariaDB-log +-- PHP Version: 8.0.27 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: `grublox` -- +CREATE DATABASE IF NOT EXISTS `grublox` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; +USE `grublox`; -- -------------------------------------------------------- @@ -21,7 +29,8 @@ SET time_zone = "+00:00"; -- Table structure for table `catalog` -- -CREATE TABLE IF NOT EXISTS `catalog` ( +DROP TABLE IF EXISTS `catalog`; +CREATE TABLE `catalog` ( `id` int(11) NOT NULL, `name` varchar(50) NOT NULL, `description` varchar(255) NOT NULL, @@ -35,7 +44,7 @@ CREATE TABLE IF NOT EXISTS `catalog` ( `limited` int(1) DEFAULT 0, `stock` int(11) NOT NULL DEFAULT 0, `state` varchar(50) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- @@ -43,25 +52,13 @@ CREATE TABLE IF NOT EXISTS `catalog` ( -- Table structure for table `comments` -- -CREATE TABLE IF NOT EXISTS `comments` ( +DROP TABLE IF EXISTS `comments`; +CREATE TABLE `comments` ( `id` int(11) NOT NULL, `user` int(11) NOT NULL, `type` varchar(250) NOT NULL, `text` varchar(500) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `friends` --- - -CREATE TABLE IF NOT EXISTS `friends` ( - `id` int(11) NOT NULL, - `user` int(11) NOT NULL, - `state` varchar(50) NOT NULL DEFAULT 'pending', - `friend` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -69,12 +66,14 @@ CREATE TABLE IF NOT EXISTS `friends` ( -- Table structure for table `friendships` -- -CREATE TABLE IF NOT EXISTS `friendships` ( +DROP TABLE IF EXISTS `friendships`; +CREATE TABLE `friendships` ( `id` int(11) NOT NULL, `user1` int(11) NOT NULL, `user2` int(11) NOT NULL, - `isAccepted` int(11) NOT NULL DEFAULT 0 -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + `isAccepted` int(11) NOT NULL DEFAULT 0, + `date` datetime NOT NULL DEFAULT current_timestamp() +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- @@ -82,7 +81,8 @@ CREATE TABLE IF NOT EXISTS `friendships` ( -- Table structure for table `games` -- -CREATE TABLE IF NOT EXISTS `games` ( +DROP TABLE IF EXISTS `games`; +CREATE TABLE `games` ( `id` int(11) NOT NULL, `name` varchar(50) NOT NULL, `description` varchar(255) NOT NULL, @@ -92,8 +92,8 @@ CREATE TABLE IF NOT EXISTS `games` ( `state` varchar(50) NOT NULL, `date` datetime NOT NULL DEFAULT current_timestamp(), `updateddate` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `thumbnail` mediumtext NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + `thumbnail` mediumtext NOT NULL DEFAULT '/assets/placeholder2.png' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- @@ -101,13 +101,28 @@ CREATE TABLE IF NOT EXISTS `games` ( -- Table structure for table `jobs` -- -CREATE TABLE IF NOT EXISTS `jobs` ( +DROP TABLE IF EXISTS `jobs`; +CREATE TABLE `jobs` ( `id` int(11) NOT NULL, `jobid` varchar(50) NOT NULL, `placeid` int(11) NOT NULL, `port` int(11) NOT NULL, `name` varchar(50) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `owned` +-- + +DROP TABLE IF EXISTS `owned`; +CREATE TABLE `owned` ( + `id` int(11) NOT NULL, + `user` int(11) NOT NULL, + `item` int(11) NOT NULL, + `date` datetime NOT NULL DEFAULT current_timestamp() +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -115,14 +130,15 @@ CREATE TABLE IF NOT EXISTS `jobs` ( -- Table structure for table `tokens` -- -CREATE TABLE IF NOT EXISTS `tokens` ( +DROP TABLE IF EXISTS `tokens`; +CREATE TABLE `tokens` ( `id` int(11) NOT NULL, `token` varchar(500) NOT NULL, `placeid` int(11) NOT NULL, `userid` int(11) NOT NULL, `passedplacelauncher` int(11) NOT NULL DEFAULT 0, `passedjoinscript` int(11) NOT NULL DEFAULT 0 -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- @@ -130,7 +146,8 @@ CREATE TABLE IF NOT EXISTS `tokens` ( -- Table structure for table `users` -- -CREATE TABLE IF NOT EXISTS `users` ( +DROP TABLE IF EXISTS `users`; +CREATE TABLE `users` ( `id` int(11) NOT NULL, `username` varchar(20) NOT NULL, `password` varchar(450) NOT NULL, @@ -140,7 +157,7 @@ CREATE TABLE IF NOT EXISTS `users` ( `money` int(11) NOT NULL DEFAULT 10, `lastPaid` varchar(30) DEFAULT current_timestamp(), `admin` int(1) NOT NULL DEFAULT 0 -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Indexes for dumped tables @@ -158,12 +175,6 @@ ALTER TABLE `catalog` ALTER TABLE `comments` ADD PRIMARY KEY (`id`); --- --- Indexes for table `friends` --- -ALTER TABLE `friends` - ADD PRIMARY KEY (`id`); - -- -- Indexes for table `friendships` -- @@ -182,6 +193,12 @@ ALTER TABLE `games` ALTER TABLE `jobs` ADD PRIMARY KEY (`id`); +-- +-- Indexes for table `owned` +-- +ALTER TABLE `owned` + ADD PRIMARY KEY (`id`); + -- -- Indexes for table `tokens` -- @@ -210,12 +227,6 @@ ALTER TABLE `catalog` ALTER TABLE `comments` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; --- --- AUTO_INCREMENT for table `friends` --- -ALTER TABLE `friends` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; - -- -- AUTO_INCREMENT for table `friendships` -- @@ -234,6 +245,12 @@ ALTER TABLE `games` ALTER TABLE `jobs` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; +-- +-- AUTO_INCREMENT for table `owned` +-- +ALTER TABLE `owned` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; + -- -- AUTO_INCREMENT for table `tokens` -- @@ -244,5 +261,9 @@ ALTER TABLE `tokens` -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 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 */;