From eb7c6eeabe8d8a8b54419ad8395e1ad7f4072200 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sat, 14 Mar 2020 03:05:28 +0100 Subject: [PATCH 1/9] put complete sql setup in one file --- sql/createDatabase.sql | 1 - sql/{entiresTable.sql => setup-database.sql} | 30 ++++++++++++++++---- sql/userTable.sql | 8 ------ 3 files changed, 25 insertions(+), 14 deletions(-) delete mode 100644 sql/createDatabase.sql rename sql/{entiresTable.sql => setup-database.sql} (56%) delete mode 100644 sql/userTable.sql diff --git a/sql/createDatabase.sql b/sql/createDatabase.sql deleted file mode 100644 index 2904e4c..0000000 --- a/sql/createDatabase.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE TABLE `friendsbook`.`tans` ( `id` INT NOT NULL AUTO_INCREMENT , `tan` VARCHAR(13) NOT NULL , `used` BOOLEAN NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB; diff --git a/sql/entiresTable.sql b/sql/setup-database.sql similarity index 56% rename from sql/entiresTable.sql rename to sql/setup-database.sql index 15d619d..37a0e4b 100644 --- a/sql/entiresTable.sql +++ b/sql/setup-database.sql @@ -1,4 +1,24 @@ -CREATE TABLE `kd42696_ipr-projekt`.`entries` ( +CREATE DATABASE friendsbook; + +USE friendsbook; + +CREATE TABLE `tans` ( + `id` INT NOT NULL AUTO_INCREMENT, + `tan` VARCHAR(13) NOT NULL, + `used` BOOLEAN NOT NULL, + PRIMARY KEY (`id`) +) ENGINE = InnoDB; + +CREATE TABLE `user` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `user` VARCHAR(50) NOT NULL DEFAULT '0', + `email` VARCHAR(100) NOT NULL DEFAULT '0', + `password` VARCHAR(100) NOT NULL DEFAULT '0', + PRIMARY KEY (`ID`), + UNIQUE INDEX `user` (`user`) +) ENGINE = InnoDB; + +CREATE TABLE `entries` ( `id` INT NOT NULL AUTO_INCREMENT , `userID` INT NOT NULL , `tanID` INT NOT NULL , @@ -26,7 +46,7 @@ CREATE TABLE `kd42696_ipr-projekt`.`entries` ( `absturz` LONGTEXT DEFAULT NULL , `trinkspiel` LONGTEXT DEFAULT NULL , PRIMARY KEY (`id`), - UNIQUE (`tanID`)) ENGINE = InnoDB; - - ALTER TABLE `entries` ADD FOREIGN KEY (`userID`) REFERENCES `user`(`ID`) ON DELETE CASCADE ON UPDATE CASCADE; - ALTER TABLE `entries` ADD FOREIGN KEY (`tanID`) REFERENCES `tans`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; + UNIQUE (`tanID`), + FOREIGN KEY (`userID`) REFERENCES `user`(`ID`) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`tanID`) REFERENCES `tans`(`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE = InnoDB; diff --git a/sql/userTable.sql b/sql/userTable.sql deleted file mode 100644 index b015f21..0000000 --- a/sql/userTable.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE `user` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `user` VARCHAR(50) NOT NULL DEFAULT '0', - `email` VARCHAR(100) NOT NULL DEFAULT '0', - `password` VARCHAR(100) NOT NULL DEFAULT '0', - PRIMARY KEY (`ID`), - UNIQUE INDEX `user` (`user`) -); From b018861b55e6335a0779bdaf4119f8a880cd290c Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sat, 14 Mar 2020 18:34:01 +0100 Subject: [PATCH 2/9] Add SQL Docker setup --- sql/Dockerfile | 2 + sql/run-container.sh | 1 + sql/sample-db.sql | 364 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 367 insertions(+) create mode 100644 sql/Dockerfile create mode 100644 sql/run-container.sh create mode 100644 sql/sample-db.sql diff --git a/sql/Dockerfile b/sql/Dockerfile new file mode 100644 index 0000000..a6f0619 --- /dev/null +++ b/sql/Dockerfile @@ -0,0 +1,2 @@ +FROM mariadb +COPY ./sql-dump.sql /docker-entrypoint-initdb.d/ diff --git a/sql/run-container.sh b/sql/run-container.sh new file mode 100644 index 0000000..d61be82 --- /dev/null +++ b/sql/run-container.sh @@ -0,0 +1 @@ +docker run -d -p 5455:3306 -v `pwd`/setup:/docker-entrypoint-initdb.d/ -v `pwd`/mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Test mariadb diff --git a/sql/sample-db.sql b/sql/sample-db.sql new file mode 100644 index 0000000..779e791 --- /dev/null +++ b/sql/sample-db.sql @@ -0,0 +1,364 @@ +-- phpMyAdmin SQL Dump +-- version 4.9.0.1 +-- https://www.phpmyadmin.net/ +-- +-- Host: localhost:3306 +-- Erstellungszeit: 10. Nov 2019 um 18:32 +-- Server-Version: 10.0.38-MariaDB-0+deb8u1 +-- PHP-Version: 7.1.14 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +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 */; + +CREATE DATABASE `kd42696_ipr-projekt`; + +USE `kd42696_ipr-projekt`; + +-- +-- Datenbank: `kd42696_ipr-projekt` +-- + +-- -------------------------------------------------------- + +-- +-- Tabellenstruktur für Tabelle `entries` +-- + +CREATE TABLE `entries` ( + `id` int(11) NOT NULL, + `userID` int(11) NOT NULL, + `tanID` int(11) NOT NULL, + `vorname` longtext CHARACTER SET utf8 NOT NULL, + `nachname` longtext CHARACTER SET utf8 NOT NULL, + `geburtstag` longtext CHARACTER SET utf8, + `wohnort` longtext CHARACTER SET utf8, + `strasse` longtext CHARACTER SET utf8, + `kennenUns` longtext CHARACTER SET utf8 NOT NULL, + `festnetz` longtext CHARACTER SET utf8, + `handynummer` longtext CHARACTER SET utf8, + `email` longtext CHARACTER SET utf8 NOT NULL, + `hobbies` longtext CHARACTER SET utf8, + `berufswunsch` longtext CHARACTER SET utf8, + `essen` longtext CHARACTER SET utf8, + `insel` longtext CHARACTER SET utf8, + `film` longtext CHARACTER SET utf8, + `sport` longtext CHARACTER SET utf8, + `charakter` longtext CHARACTER SET utf8, + `tier` longtext CHARACTER SET utf8, + `musik` longtext CHARACTER SET utf8, + `game` longtext CHARACTER SET utf8, + `alk` longtext CHARACTER SET utf8, + `story` longtext CHARACTER SET utf8, + `absturz` longtext CHARACTER SET utf8, + `trinkspiel` longtext CHARACTER SET utf8 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci; + +-- +-- Daten für Tabelle `entries` +-- + +INSERT INTO `entries` (`id`, `userID`, `tanID`, `vorname`, `nachname`, `geburtstag`, `wohnort`, `strasse`, `kennenUns`, `festnetz`, `handynummer`, `email`, `hobbies`, `berufswunsch`, `essen`, `insel`, `film`, `sport`, `charakter`, `tier`, `musik`, `game`, `alk`, `story`, `absturz`, `trinkspiel`) VALUES +(6, 24, 78, 'asdasd', 'asdasd', '', '', '', 'asdasd', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(7, 24, 79, 'asdasd', 'asdasd', '', '', '', 'aaassad', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(8, 24, 81, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(9, 2, 123, 'asd', 'asdasd', '', '', '', 'ssssss', '', '', 'sssss', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(10, 2, 124, 'Test', 'Nachname', '', '', '', 'von der Uni aus', '', '', 'sag_ich_nicht@noway.com ', 'Zocken', '', '', '', 'Terminator', '', '', '', '', '', '', '', '', ''), +(11, 2, 125, 'Peter', 'Dieter', '', '', 'Schlüpfweg 25', 'aus dem haus', '', '', 'mailmailman', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(12, 2, 126, 'sadadsf', 'asdfasdf', '', '', '', 'asdfhjkkjl', '', '', 'jklhjkl', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(13, 2, 131, 'Vorname ', 'Lol', '', '', '', 'Bahn', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(14, 2, 132, 'Simon', 'Kellner', '', '', '', 'Studium ', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(15, 2, 133, 'llol', 'Ashfsad', '283843', 'Idsofnjdsn', 'Sijdfdendefjno', 'Eiisdfwnedfn', '479', 'Q23829', 'Dndsifnsjd', 'Ue2981e2wsnddsn', 'Uiwwerue2r2', 'Uiewfewkrw', 'Kwerfekjwj', 'Kesnfnfjekwfn', 'Esnfnfewfn', 'Kdsfnff', 'Wefjfednq', 'Jwendf', 'Koewnfdksjfn', 'Jkwenfsfn', 'Jkewnfndw', 'Ewnfnfejkw', 'Wefksff'), +(16, 2, 134, 'frieder heinrich', 'baumann von neuschwanberg', '01.01.1971', '', '', 'hochadeltreffen', '', '', '', '', 'bin zu reich zum arbeiten', 'kaviar', '', '', '', '', '', 'Mozart', '', 'Champagner ', '', '', ''), +(17, 2, 139, ' hi', 'du', ' ', '', '', 'fd', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ' ', ' ', ' '), +(18, 2, 140, ' ', ' ', '', '', '', ' ', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(19, 6, 141, 'Vorname', 'Nachname', '', '', '', 'Studium', '', '', 'mailadresse@mail.com', '', 'Entwickler', '', '', '', '', '', '', '', '', '', '', '', ''), +(20, 10, 61, 'Simon', 'Kellner', '', '', '', 'Studium', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(21, 30, 144, 'Hans ', 'Wurst', '', 'Essen', 'Lyonerweg 12', ' Aus dem Supermarkt ', '', '', '', '', '', ' Käse ', '', '', '', '', '', '', '', '', '', '', ''), +(22, 30, 145, 'Angela', 'Merkel', '', '', '', 'Von den Wahlen', '', '', 'angieforpresident@cdu.de', ' Den Horst nerven ', ' Mutter Teresa ', '', ' Ein Flüchtlingsboot ', '', '', '', '', '', '', '', '', '', ''), +(23, 30, 146, ' Joachim ', 'Löw', '03.02.1960', 'Feiburg', 'Kicker-Allee 71', ' Aus dem Trainingslager ', '05474902014', 'nur für ganz besondere Freunde', 'hireme@besttrainereuwest.org', ' Handball, Am Sack kratzen', ' Volleyball Trainer ', '', ' Basketball ', ' Die wilden Kerle ', ' Tennis ', 'Trainer bei FIFA', ' Löwe', 'We are the Champions', ' FIFA ', '', ' Mit dem Bus über den Pokal gefahren ', ' Bin schon ganz unten ', ''), +(24, 30, 147, 'Dagobert ', 'Duck', '99.99.9999€', 'Entenhausen', 'Goldweg 99', 'Du hast meinen Geldspeicher gereinigt', '', '', '', 'Geld zählen und im Geld schwimmen und angeben dass man der Reichste im Dorf ist', 'Googilionär', 'Frische Scheine', 'Meine Kreditkarte ', '', '', '', 'Sparschwein', '', '', 'Teuerer Scotch', '', '', ''), +(25, 2, 66, '

Name

', 'Schwarz', '', '', '', 'lolo', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(26, 2, 67, 'asd', 'asd', '', '', '', '
Deine unbenutzen Tans:
67 | 68 | 69 | 70 | 71 | 72 | 75 | 76 | 77 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 129 | 130 | 135 | 136 | 137 | 138 | 142 | 143 | 148 | 149 |
', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(28, 8, 152, 'hgjfg', 'hfhgj', 'hgfjhgfj', '', '', 'jhgfhgjf', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(29, 8, 153, 'gfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshf', 'gfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshf', 'gfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshf', '', '', 'gfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshf', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(30, 30, 155, 'Matze', 'Maciossek', '', '', '', 'Vorlesung', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(31, 2, 110, 'asdfasdfasd', 'fasdfasdfasdf', '', '', '', 'asdfsadfasdfa', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(32, 2, 172, 'asdfadsfad', 'asdfasdfasd', '', '', '', 'asdfasdfasdf', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); + +-- -------------------------------------------------------- + +-- +-- Tabellenstruktur für Tabelle `tans` +-- + +CREATE TABLE `tans` ( + `id` int(11) NOT NULL, + `userID` int(11) NOT NULL, + `tan` varchar(13) NOT NULL, + `used` tinyint(1) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Daten für Tabelle `tans` +-- + +INSERT INTO `tans` (`id`, `userID`, `tan`, `used`) VALUES +(56, 2, '5b26cb6f52b00', 1), +(57, 2, '5b26cb8cab408', 1), +(58, 2, '5b26cbc094e4b', 1), +(59, 6, '5b26cbd5e5079', 1), +(60, 2, '5b26dfdf7ef82', 1), +(61, 10, '5b26e044ee6b4', 1), +(62, 10, '5b26e04b5fa17', 0), +(63, 10, '5b26e04ca13d3', 0), +(64, 10, '5b26e0978afa2', 0), +(65, 10, '5b26e09d6bb85', 0), +(66, 2, '5b26e0aab86df', 1), +(67, 2, '5b26e10f3ccec', 1), +(68, 2, '5b26e10fe7fe8', 0), +(69, 2, '5b26e1106cc5f', 0), +(70, 2, '5b26e11092fd1', 0), +(71, 2, '5b26e110af8bf', 0), +(72, 2, '5b26e1167aa12', 0), +(73, 10, '5b26e1318ac8c', 0), +(74, 10, '5b26e13246ae4', 0), +(75, 2, '5b26e1847838a', 0), +(76, 2, '5b26e8831b088', 0), +(77, 2, '5b26e89d078d5', 0), +(78, 24, '5b27c249a558a', 1), +(79, 24, '5b27c26b5d8fa', 1), +(80, 24, '5b27c26ee1364', 0), +(81, 24, '5b27d363876b9', 1), +(82, 2, '5b27de3b2d562', 0), +(83, 2, '5b27e53e75651', 0), +(84, 2, '5b27e53fdd5a6', 0), +(85, 2, '5b27e55417aa1', 0), +(86, 2, '5b27e55feb89a', 0), +(87, 2, '5b27e560a45cd', 0), +(88, 2, '5b27e56907521', 0), +(89, 2, '5b27e56eebee6', 0), +(90, 2, '5b27e586a27b2', 0), +(91, 2, '5b27e774ae8f1', 0), +(92, 2, '5b27e77650c98', 0), +(93, 2, '5b27e77a30937', 0), +(94, 2, '5b27e7ce24be6', 0), +(95, 2, '5b27ef2f1e384', 0), +(96, 2, '5b27ef3067710', 0), +(97, 2, '5b27ef30a3d8b', 0), +(98, 2, '5b27ef30d7cff', 0), +(99, 2, '5b27ef311836b', 0), +(100, 2, '5b27ef314c846', 0), +(101, 2, '5b27ef31866b4', 0), +(102, 2, '5b27ef3264a72', 0), +(103, 2, '5b27ef32ad605', 0), +(104, 2, '5b27ef333b5d4', 0), +(105, 2, '5b27ef376ef64', 0), +(106, 2, '5b27ef6751781', 0), +(107, 2, '5b27ef683d92f', 0), +(108, 2, '5b27ef80c21b1', 0), +(109, 2, '5b27efabb3e54', 0), +(110, 2, '5b27efc3b3fd3', 1), +(111, 2, '5b27efcf45cb1', 0), +(112, 2, '5b27efcfb9db2', 0), +(113, 2, '5b27effe82715', 0), +(114, 2, '5b27f01d0bb98', 0), +(115, 2, '5b27f02e2a691', 0), +(116, 2, '5b27f02fa0edd', 0), +(117, 2, '5b27f032b8fa5', 0), +(118, 2, '5b27f03401952', 0), +(119, 2, '5b27f2fe29d1d', 0), +(120, 2, '5b27f30ad2819', 0), +(121, 2, '5b27f38f7fabf', 0), +(122, 10, '5b27f3a84086f', 0), +(123, 2, '5b27f97bafe6f', 1), +(124, 2, '5b28017215d92', 1), +(125, 2, '5b2802ba4f013', 1), +(126, 2, '5b280388a76d2', 1), +(127, 24, '5b280510f4094', 0), +(128, 29, '5b280670dcb4f', 0), +(129, 2, '5b280c04c097f', 0), +(130, 2, '5b2831cdea21e', 0), +(131, 2, '5b28a84c13dcb', 1), +(132, 2, '5b28cb166f483', 1), +(133, 2, '5b28cbcdda3d5', 1), +(134, 2, '5b28cc211d9df', 1), +(135, 2, '5b291eb0e32d6', 0), +(136, 2, '5b291eb82d741', 0), +(137, 2, '5b291ec6b47f4', 0), +(138, 2, '5b291eca60052', 0), +(139, 2, '5b291eca8d267', 1), +(140, 2, '5b292fa313b33', 1), +(141, 6, '5b29318498b5d', 1), +(142, 2, '5b2933e999dfd', 0), +(143, 2, '5b2935c1a1455', 0), +(144, 30, '5b296bdd323e6', 1), +(145, 30, '5b296bdd9cc48', 1), +(146, 30, '5b296bde40a82', 1), +(147, 30, '5b296bdeb2dbf', 1), +(148, 2, '5b2a6db579881', 0), +(149, 2, '5b2a6db74b1d4', 0), +(151, 8, '5b2b8dea36bc1', 1), +(152, 8, '5b2b8e4ccadcc', 1), +(153, 8, '5b2b8e711aa0f', 1), +(154, 2, '5b2bfd2e6ee9b', 0), +(155, 30, '5b2c93c05ee3f', 1), +(156, 30, '5b2c941deaff7', 0), +(157, 30, '5b2c941e1ab05', 0), +(158, 30, '5b2c941e3f534', 0), +(159, 30, '5b2c941e694de', 0), +(160, 30, '5b2c941e8c875', 0), +(161, 30, '5b2c941eaff72', 0), +(162, 30, '5b2c941ed42d0', 0), +(163, 30, '5b2c941f01ac9', 0), +(164, 30, '5b2c941fbd02b', 0), +(165, 30, '5b2c941fe2335', 0), +(166, 30, '5b2c942008473', 0), +(167, 10, '5b3c1b75dd4bc', 0), +(168, 2, '5b665fbcf0b36', 0), +(169, 2, '5b665fbe0335e', 0), +(170, 2, '5b665fbf1ea2b', 0), +(171, 2, '5b665fbf515c7', 0), +(172, 2, '5b665fbf89319', 1), +(173, 2, '5b7df511aba41', 0), +(174, 2, '5bfb258d241cc', 0), +(175, 2, '5bfb258f56c52', 0), +(176, 2, '5bfb258fe4113', 0), +(177, 2, '5bfb259011caa', 0), +(178, 2, '5bfb25911c88c', 0), +(179, 2, '5bfb2591439b9', 0), +(180, 2, '5bfb2591862fb', 0), +(181, 2, '5bfb2591c5245', 0), +(182, 2, '5bfb25920a4ba', 0), +(183, 2, '5bfb2592381a2', 0), +(184, 2, '5bfb25925a839', 0), +(185, 2, '5bfb2592805e3', 0), +(186, 2, '5bfb2592a67e1', 0), +(187, 2, '5bfb2592c4dad', 0), +(188, 2, '5c9371215facd', 0); + +-- -------------------------------------------------------- + +-- +-- Tabellenstruktur für Tabelle `user` +-- + +CREATE TABLE `user` ( + `ID` int(11) NOT NULL, + `username` varchar(50) NOT NULL DEFAULT '0', + `email` varchar(100) NOT NULL DEFAULT '0', + `password` varchar(100) NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Daten für Tabelle `user` +-- + +INSERT INTO `user` (`ID`, `username`, `email`, `password`) VALUES +(2, 'asd', 'asd', '7815696ecbf1c96e6894b779456d330e'), +(3, 'assd', 'assd', '40b114b04ce020d26ccdc8fe28add240'), +(4, 'aaa', 'aaa', '47bce5c74f589f4867dbd57e9ca9f808'), +(5, 'asddd', 'asddd', '845441edc5ed7ea737439aa46715eed2'), +(6, 'bbb', 'bbb', '08f8e0260c64418510cefb2b06eee5cd'), +(7, 'marcel', 'marcel', '24dde05168c24253ce9fec0fddd1e48d'), +(8, 'tim', 'tim', 'b15d47e99831ee63e3f47cf3d4478e9a'), +(10, 'simon', 'simon', 'b30bd351371c686298d32281b337e8e9'), +(11, 'sdfa', 'asdf', '912ec803b2ce49e4a541068d495ab570'), +(12, '', '', 'd41d8cd98f00b204e9800998ecf8427e'), +(13, '123abc', '123abc', 'a906449d5769fa7361d7ecc6aa3f6d28'), +(14, 'fgfg', 'fgfg', '2af5c662cab479e5471ca76326a57563'), +(15, 'dfdf', 'dfdf', 'b52c96bea30646abf8170f333bbd42b9'), +(16, 'hallohallo', 'hallohallo', 'ecfcb09d14771e375f4a7ed2aa6b25c5'), +(18, 'test3', 'test', '098f6bcd4621d373cade4e832627b4f6'), +(19, 'asdfg', 'asdfg', '040b7cf4a55014e185813e0644502ea9'), +(20, 'asdf', 'asd', '7815696ecbf1c96e6894b779456d330e'), +(21, 'problem', 'problemxampp', '7815696ecbf1c96e6894b779456d330e'), +(22, 'xamp', 'xamp problem test', '7815696ecbf1c96e6894b779456d330e'), +(23, 'contentfix', 'contentfix', '7815696ecbf1c96e6894b779456d330e'), +(24, 'vvv', 'vvv', '4786f3282f04de5b5c7317c490c6d922'), +(25, 'nnn', 'nnn', 'a1931ec126bbad3fa7a3fc64209fd921'), +(26, 'asdb', 'asdb', 'bed23bc3248b6edc2d08204410e832c5'), +(27, 'sss', 'sss', '9f6e6800cfae7749eb6c486619254b9c'), +(28, 'hi', 'hi', '49f68a5c8493ec2c0bf489821c21fc3b'), +(29, 'handy', 'handy', '16f198404de4bb7b994f16b84e30f14f'), +(30, 'MarcelDavis', 'presi', '196801e16a9c169a12f3975e83fe6556'), +(31, 'tim1', 'ehtdichnichtsan@web.de', 'd1c9a9d96ec1b245bd976930be6b9ab3'), +(32, 'tobi', 'tobi', 'e0dd692dcb560bc04bfa1cbfaca9ecff'), +(33, 'demo', 'demo@demo.com', 'fe01ce2a7fbac8fafaed7c982a04e229'); + +-- +-- Indizes der exportierten Tabellen +-- + +-- +-- Indizes für die Tabelle `entries` +-- +ALTER TABLE `entries` + ADD PRIMARY KEY (`id`), + ADD UNIQUE KEY `tanID` (`tanID`), + ADD KEY `userID` (`userID`); + +-- +-- Indizes für die Tabelle `tans` +-- +ALTER TABLE `tans` + ADD PRIMARY KEY (`id`), + ADD KEY `userID` (`userID`); + +-- +-- Indizes für die Tabelle `user` +-- +ALTER TABLE `user` + ADD PRIMARY KEY (`ID`), + ADD UNIQUE KEY `user` (`username`); + +-- +-- AUTO_INCREMENT für exportierte Tabellen +-- + +-- +-- AUTO_INCREMENT für Tabelle `entries` +-- +ALTER TABLE `entries` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=33; + +-- +-- AUTO_INCREMENT für Tabelle `tans` +-- +ALTER TABLE `tans` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=189; + +-- +-- AUTO_INCREMENT für Tabelle `user` +-- +ALTER TABLE `user` + MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=34; + +-- +-- Constraints der exportierten Tabellen +-- + +-- +-- Constraints der Tabelle `entries` +-- +ALTER TABLE `entries` + ADD CONSTRAINT `entries_ibfk_1` FOREIGN KEY (`userID`) REFERENCES `user` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `entries_ibfk_2` FOREIGN KEY (`tanID`) REFERENCES `tans` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints der Tabelle `tans` +-- +ALTER TABLE `tans` + ADD CONSTRAINT `tans_ibfk_1` FOREIGN KEY (`userID`) REFERENCES `user` (`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 */; From f2619aeb2c0349bec8a45dccbd7fd65a1ec4bb51 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sat, 14 Mar 2020 19:14:26 +0100 Subject: [PATCH 3/9] Add docker compose, add db setup, add webserver dockerfile --- .gitignore | 2 -- Dockerfile | 5 +++++ ~dbConnect.php => dbConnect.php | 12 ++++++------ docker-compose.yml | 29 +++++++++++++++++++++++++++++ sql/Dockerfile | 2 +- sql/run-container.sh | 1 - 6 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 Dockerfile rename ~dbConnect.php => dbConnect.php (77%) create mode 100644 docker-compose.yml delete mode 100644 sql/run-container.sh diff --git a/.gitignore b/.gitignore index c7f7bd3..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +0,0 @@ - -dbConnect.php diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f95b823 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM php:7.0-apache + +RUN apt-get update +RUN docker-php-ext-install pdo pdo_mysql mysqli +RUN a2enmod rewrite diff --git a/~dbConnect.php b/dbConnect.php similarity index 77% rename from ~dbConnect.php rename to dbConnect.php index 888225d..be2e0a1 100644 --- a/~dbConnect.php +++ b/dbConnect.php @@ -1,12 +1,12 @@ -connect_error) { die('Connect Error (' . $database->connect_errno . ') ' . $database->connect_error); } -?> \ No newline at end of file +?> diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8222ba9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,29 @@ +version: '3' + +services: + db: + build: + context: ./sql + ports: + - "5455:3306" + volumes: + - "db-data:/var/lib/mysql" + environment: + MYSQL_ROOT_PASSWORD: "Test" + + webserver: + build: + context: . + ports: + - "80:80" + volumes: + - "./:/var/www/html" + depends_on: + - db + +volumes: + db-data: + + +# docker run -d -p 5455:3306 -v `pwd`/setup:/docker-entrypoint-initdb.d/ -v `pwd`/mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Test mariadb +# docker run -d -p 80:80 --name my-apache-php-app -v `pwd`:/var/www/html php:7.0-apache diff --git a/sql/Dockerfile b/sql/Dockerfile index a6f0619..4602ce3 100644 --- a/sql/Dockerfile +++ b/sql/Dockerfile @@ -1,2 +1,2 @@ FROM mariadb -COPY ./sql-dump.sql /docker-entrypoint-initdb.d/ +COPY ./sample-db.sql /docker-entrypoint-initdb.d/ diff --git a/sql/run-container.sh b/sql/run-container.sh deleted file mode 100644 index d61be82..0000000 --- a/sql/run-container.sh +++ /dev/null @@ -1 +0,0 @@ -docker run -d -p 5455:3306 -v `pwd`/setup:/docker-entrypoint-initdb.d/ -v `pwd`/mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Test mariadb From a0c8944d09a2ce7c6c29264dab6ad464f38c9441 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sat, 14 Mar 2020 19:25:21 +0100 Subject: [PATCH 4/9] Fix redirect after login --- segments/_login.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/segments/_login.php b/segments/_login.php index 2a37627..c91006b 100644 --- a/segments/_login.php +++ b/segments/_login.php @@ -14,9 +14,10 @@ if( (isset($_POST['loginName'])) && isset($_POST['loginPassword'])){ $object = $result->fetch_object(); $_SESSION['user'] = $object->id; $_SESSION['username'] = $object->username; - echo "Einloggen erfolgreich
Willkommen " . $_SESSION['username']; - //header("refresh:1;"); - header('Location: index.php?page=myFriendsBook'); + // echo "Einloggen erfolgreich
Willkommen " . $_SESSION['username']; + // header("refresh:1;"); + // header("location:index.php?page=myFriendsBook"); + echo ""; } else { echo "Einloggen fehlgeschlagen"; } From 6572f20b932bae1cecd3a27677f36c747643e64e Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sat, 14 Mar 2020 19:50:49 +0100 Subject: [PATCH 5/9] Align db setup to dumped values --- sql/setup-database.sql | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sql/setup-database.sql b/sql/setup-database.sql index 37a0e4b..1005723 100644 --- a/sql/setup-database.sql +++ b/sql/setup-database.sql @@ -2,20 +2,22 @@ CREATE DATABASE friendsbook; USE friendsbook; -CREATE TABLE `tans` ( - `id` INT NOT NULL AUTO_INCREMENT, - `tan` VARCHAR(13) NOT NULL, - `used` BOOLEAN NOT NULL, - PRIMARY KEY (`id`) -) ENGINE = InnoDB; - CREATE TABLE `user` ( `ID` INT NOT NULL AUTO_INCREMENT, - `user` VARCHAR(50) NOT NULL DEFAULT '0', + `username` VARCHAR(50) NOT NULL DEFAULT '0', `email` VARCHAR(100) NOT NULL DEFAULT '0', `password` VARCHAR(100) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`), - UNIQUE INDEX `user` (`user`) + UNIQUE INDEX `user`(`username`) +) ENGINE = InnoDB; + +CREATE TABLE `tans` ( + `id` INT NOT NULL AUTO_INCREMENT, + `userID` INT NOT NULL, + `tan` VARCHAR(13) NOT NULL, + `used` BOOLEAN NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`userID`) REFERENCES `user`(`ID`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = InnoDB; CREATE TABLE `entries` ( From 93e11c22bf6694001a3091046e0206ea26190fdc Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sat, 14 Mar 2020 20:10:00 +0100 Subject: [PATCH 6/9] Split sample data and setup, remove step from webserver dockerfile --- Dockerfile | 1 - dbConnect.php | 3 +- sql/{setup-database.sql => 1-setup.sql} | 0 sql/{sample-db.sql => 2-sample-data.sql} | 139 +---------------------- sql/Dockerfile | 4 +- 5 files changed, 9 insertions(+), 138 deletions(-) rename sql/{setup-database.sql => 1-setup.sql} (100%) rename sql/{sample-db.sql => 2-sample-data.sql} (78%) diff --git a/Dockerfile b/Dockerfile index f95b823..2208e15 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ FROM php:7.0-apache -RUN apt-get update RUN docker-php-ext-install pdo pdo_mysql mysqli RUN a2enmod rewrite diff --git a/dbConnect.php b/dbConnect.php index be2e0a1..07876fa 100644 --- a/dbConnect.php +++ b/dbConnect.php @@ -2,10 +2,9 @@ //Create DB connection. //This creates a usable "database" - Variable as mysqli Objekt -//simply remove the "~" in front of the filename $user = 'root'; $password = 'Test'; -$db = 'kd42696_ipr-projekt'; +$db = 'friendsbook'; $host = 'db'; $port = 3306; diff --git a/sql/setup-database.sql b/sql/1-setup.sql similarity index 100% rename from sql/setup-database.sql rename to sql/1-setup.sql diff --git a/sql/sample-db.sql b/sql/2-sample-data.sql similarity index 78% rename from sql/sample-db.sql rename to sql/2-sample-data.sql index 779e791..8de8c20 100644 --- a/sql/sample-db.sql +++ b/sql/2-sample-data.sql @@ -1,65 +1,7 @@ --- phpMyAdmin SQL Dump --- version 4.9.0.1 --- https://www.phpmyadmin.net/ --- --- Host: localhost:3306 --- Erstellungszeit: 10. Nov 2019 um 18:32 --- Server-Version: 10.0.38-MariaDB-0+deb8u1 --- PHP-Version: 7.1.14 -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET AUTOCOMMIT = 0; -START TRANSACTION; -SET time_zone = "+00:00"; +USE `friendsbook`; - -/*!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 */; - -CREATE DATABASE `kd42696_ipr-projekt`; - -USE `kd42696_ipr-projekt`; - --- --- Datenbank: `kd42696_ipr-projekt` --- - --- -------------------------------------------------------- - --- --- Tabellenstruktur für Tabelle `entries` --- - -CREATE TABLE `entries` ( - `id` int(11) NOT NULL, - `userID` int(11) NOT NULL, - `tanID` int(11) NOT NULL, - `vorname` longtext CHARACTER SET utf8 NOT NULL, - `nachname` longtext CHARACTER SET utf8 NOT NULL, - `geburtstag` longtext CHARACTER SET utf8, - `wohnort` longtext CHARACTER SET utf8, - `strasse` longtext CHARACTER SET utf8, - `kennenUns` longtext CHARACTER SET utf8 NOT NULL, - `festnetz` longtext CHARACTER SET utf8, - `handynummer` longtext CHARACTER SET utf8, - `email` longtext CHARACTER SET utf8 NOT NULL, - `hobbies` longtext CHARACTER SET utf8, - `berufswunsch` longtext CHARACTER SET utf8, - `essen` longtext CHARACTER SET utf8, - `insel` longtext CHARACTER SET utf8, - `film` longtext CHARACTER SET utf8, - `sport` longtext CHARACTER SET utf8, - `charakter` longtext CHARACTER SET utf8, - `tier` longtext CHARACTER SET utf8, - `musik` longtext CHARACTER SET utf8, - `game` longtext CHARACTER SET utf8, - `alk` longtext CHARACTER SET utf8, - `story` longtext CHARACTER SET utf8, - `absturz` longtext CHARACTER SET utf8, - `trinkspiel` longtext CHARACTER SET utf8 -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci; +SET FOREIGN_KEY_CHECKS=0; -- -- Daten für Tabelle `entries` @@ -89,23 +31,11 @@ INSERT INTO `entries` (`id`, `userID`, `tanID`, `vorname`, `nachname`, `geburtst (26, 2, 67, 'asd', 'asd', '', '', '', '
Deine unbenutzen Tans:
67 | 68 | 69 | 70 | 71 | 72 | 75 | 76 | 77 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 129 | 130 | 135 | 136 | 137 | 138 | 142 | 143 | 148 | 149 |
', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), (28, 8, 152, 'hgjfg', 'hfhgj', 'hgfjhgfj', '', '', 'jhgfhgjf', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), (29, 8, 153, 'gfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshf', 'gfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshf', 'gfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshf', '', '', 'gfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshfgfdshf', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), -(30, 30, 155, 'Matze', 'Maciossek', '', '', '', 'Vorlesung', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), -(31, 2, 110, 'asdfasdfasd', 'fasdfasdfasdf', '', '', '', 'asdfsadfasdfa', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), -(32, 2, 172, 'asdfadsfad', 'asdfasdfasd', '', '', '', 'asdfasdfasdf', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); +(30, 2, 110, 'asdfasdfasd', 'fasdfasdfasdf', '', '', '', 'asdfsadfasdfa', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''), +(31, 2, 172, 'asdfadsfad', 'asdfasdfasd', '', '', '', 'asdfasdfasdf', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); -- -------------------------------------------------------- --- --- Tabellenstruktur für Tabelle `tans` --- - -CREATE TABLE `tans` ( - `id` int(11) NOT NULL, - `userID` int(11) NOT NULL, - `tan` varchar(13) NOT NULL, - `used` tinyint(1) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -- -- Daten für Tabelle `tans` -- @@ -246,17 +176,6 @@ INSERT INTO `tans` (`id`, `userID`, `tan`, `used`) VALUES -- -------------------------------------------------------- --- --- Tabellenstruktur für Tabelle `user` --- - -CREATE TABLE `user` ( - `ID` int(11) NOT NULL, - `username` varchar(50) NOT NULL DEFAULT '0', - `email` varchar(100) NOT NULL DEFAULT '0', - `password` varchar(100) NOT NULL DEFAULT '0' -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -- -- Daten für Tabelle `user` -- @@ -293,32 +212,6 @@ INSERT INTO `user` (`ID`, `username`, `email`, `password`) VALUES (32, 'tobi', 'tobi', 'e0dd692dcb560bc04bfa1cbfaca9ecff'), (33, 'demo', 'demo@demo.com', 'fe01ce2a7fbac8fafaed7c982a04e229'); --- --- Indizes der exportierten Tabellen --- - --- --- Indizes für die Tabelle `entries` --- -ALTER TABLE `entries` - ADD PRIMARY KEY (`id`), - ADD UNIQUE KEY `tanID` (`tanID`), - ADD KEY `userID` (`userID`); - --- --- Indizes für die Tabelle `tans` --- -ALTER TABLE `tans` - ADD PRIMARY KEY (`id`), - ADD KEY `userID` (`userID`); - --- --- Indizes für die Tabelle `user` --- -ALTER TABLE `user` - ADD PRIMARY KEY (`ID`), - ADD UNIQUE KEY `user` (`username`); - -- -- AUTO_INCREMENT für exportierte Tabellen -- @@ -327,7 +220,7 @@ ALTER TABLE `user` -- AUTO_INCREMENT für Tabelle `entries` -- ALTER TABLE `entries` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=33; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=32; -- -- AUTO_INCREMENT für Tabelle `tans` @@ -340,25 +233,3 @@ ALTER TABLE `tans` -- ALTER TABLE `user` MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=34; - --- --- Constraints der exportierten Tabellen --- - --- --- Constraints der Tabelle `entries` --- -ALTER TABLE `entries` - ADD CONSTRAINT `entries_ibfk_1` FOREIGN KEY (`userID`) REFERENCES `user` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `entries_ibfk_2` FOREIGN KEY (`tanID`) REFERENCES `tans` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; - --- --- Constraints der Tabelle `tans` --- -ALTER TABLE `tans` - ADD CONSTRAINT `tans_ibfk_1` FOREIGN KEY (`userID`) REFERENCES `user` (`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 */; diff --git a/sql/Dockerfile b/sql/Dockerfile index 4602ce3..505ae2a 100644 --- a/sql/Dockerfile +++ b/sql/Dockerfile @@ -1,2 +1,4 @@ FROM mariadb -COPY ./sample-db.sql /docker-entrypoint-initdb.d/ + +COPY ./1-setup.sql /docker-entrypoint-initdb.d/ +COPY ./2-sample-data.sql /docker-entrypoint-initdb.d/ From 0507d27ebbffe777cb92a4ba1725107e029b07ea Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sat, 14 Mar 2020 20:21:40 +0100 Subject: [PATCH 7/9] Change structure to separate frontend and sql update path of sql-data --- .gitignore | 1 + docker-compose.yml | 6 +++--- Dockerfile => frontend/Dockerfile | 0 {css => frontend/css}/style.css | 0 dbConnect.php => frontend/dbConnect.php | 0 {img => frontend/img}/header_blue.png | Bin {img => frontend/img}/header_lime.png | Bin {img => frontend/img}/header_pink.png | Bin index.php => frontend/index.php | 0 {js => frontend/js}/app.js | 0 {js => frontend/js}/contentloader.js | 0 {js => frontend/js}/particles.js | 0 {js => frontend/js}/stats.js | 0 {php => frontend/php}/generateLink.php | 0 {php => frontend/php}/logout.php | 0 {php => frontend/php}/showentries.php | 0 {php => frontend/php}/signup.php | 0 {segments => frontend/segments}/_404.html | 0 {segments => frontend/segments}/_entryForm.php | 0 {segments => frontend/segments}/_footer.html | 0 {segments => frontend/segments}/_header.php | 0 {segments => frontend/segments}/_headerSession.php | 0 {segments => frontend/segments}/_home.php | 0 .../segments}/_indexTestLoginVals.php | 0 {segments => frontend/segments}/_login.php | 0 {segments => frontend/segments}/_myFriendsBook.php | 0 {segments => frontend/segments}/_register.php | 0 27 files changed, 4 insertions(+), 3 deletions(-) rename Dockerfile => frontend/Dockerfile (100%) rename {css => frontend/css}/style.css (100%) rename dbConnect.php => frontend/dbConnect.php (100%) rename {img => frontend/img}/header_blue.png (100%) rename {img => frontend/img}/header_lime.png (100%) rename {img => frontend/img}/header_pink.png (100%) rename index.php => frontend/index.php (100%) rename {js => frontend/js}/app.js (100%) rename {js => frontend/js}/contentloader.js (100%) rename {js => frontend/js}/particles.js (100%) rename {js => frontend/js}/stats.js (100%) rename {php => frontend/php}/generateLink.php (100%) rename {php => frontend/php}/logout.php (100%) rename {php => frontend/php}/showentries.php (100%) rename {php => frontend/php}/signup.php (100%) rename {segments => frontend/segments}/_404.html (100%) rename {segments => frontend/segments}/_entryForm.php (100%) rename {segments => frontend/segments}/_footer.html (100%) rename {segments => frontend/segments}/_header.php (100%) rename {segments => frontend/segments}/_headerSession.php (100%) rename {segments => frontend/segments}/_home.php (100%) rename {segments => frontend/segments}/_indexTestLoginVals.php (100%) rename {segments => frontend/segments}/_login.php (100%) rename {segments => frontend/segments}/_myFriendsBook.php (100%) rename {segments => frontend/segments}/_register.php (100%) diff --git a/.gitignore b/.gitignore index e69de29..cb0882e 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +sql/db-data/**/* diff --git a/docker-compose.yml b/docker-compose.yml index 8222ba9..bb3e4f3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,17 +7,17 @@ services: ports: - "5455:3306" volumes: - - "db-data:/var/lib/mysql" + - "./sql/db-data:/var/lib/mysql" environment: MYSQL_ROOT_PASSWORD: "Test" webserver: build: - context: . + context: ./frontend ports: - "80:80" volumes: - - "./:/var/www/html" + - "./frontend:/var/www/html" depends_on: - db diff --git a/Dockerfile b/frontend/Dockerfile similarity index 100% rename from Dockerfile rename to frontend/Dockerfile diff --git a/css/style.css b/frontend/css/style.css similarity index 100% rename from css/style.css rename to frontend/css/style.css diff --git a/dbConnect.php b/frontend/dbConnect.php similarity index 100% rename from dbConnect.php rename to frontend/dbConnect.php diff --git a/img/header_blue.png b/frontend/img/header_blue.png similarity index 100% rename from img/header_blue.png rename to frontend/img/header_blue.png diff --git a/img/header_lime.png b/frontend/img/header_lime.png similarity index 100% rename from img/header_lime.png rename to frontend/img/header_lime.png diff --git a/img/header_pink.png b/frontend/img/header_pink.png similarity index 100% rename from img/header_pink.png rename to frontend/img/header_pink.png diff --git a/index.php b/frontend/index.php similarity index 100% rename from index.php rename to frontend/index.php diff --git a/js/app.js b/frontend/js/app.js similarity index 100% rename from js/app.js rename to frontend/js/app.js diff --git a/js/contentloader.js b/frontend/js/contentloader.js similarity index 100% rename from js/contentloader.js rename to frontend/js/contentloader.js diff --git a/js/particles.js b/frontend/js/particles.js similarity index 100% rename from js/particles.js rename to frontend/js/particles.js diff --git a/js/stats.js b/frontend/js/stats.js similarity index 100% rename from js/stats.js rename to frontend/js/stats.js diff --git a/php/generateLink.php b/frontend/php/generateLink.php similarity index 100% rename from php/generateLink.php rename to frontend/php/generateLink.php diff --git a/php/logout.php b/frontend/php/logout.php similarity index 100% rename from php/logout.php rename to frontend/php/logout.php diff --git a/php/showentries.php b/frontend/php/showentries.php similarity index 100% rename from php/showentries.php rename to frontend/php/showentries.php diff --git a/php/signup.php b/frontend/php/signup.php similarity index 100% rename from php/signup.php rename to frontend/php/signup.php diff --git a/segments/_404.html b/frontend/segments/_404.html similarity index 100% rename from segments/_404.html rename to frontend/segments/_404.html diff --git a/segments/_entryForm.php b/frontend/segments/_entryForm.php similarity index 100% rename from segments/_entryForm.php rename to frontend/segments/_entryForm.php diff --git a/segments/_footer.html b/frontend/segments/_footer.html similarity index 100% rename from segments/_footer.html rename to frontend/segments/_footer.html diff --git a/segments/_header.php b/frontend/segments/_header.php similarity index 100% rename from segments/_header.php rename to frontend/segments/_header.php diff --git a/segments/_headerSession.php b/frontend/segments/_headerSession.php similarity index 100% rename from segments/_headerSession.php rename to frontend/segments/_headerSession.php diff --git a/segments/_home.php b/frontend/segments/_home.php similarity index 100% rename from segments/_home.php rename to frontend/segments/_home.php diff --git a/segments/_indexTestLoginVals.php b/frontend/segments/_indexTestLoginVals.php similarity index 100% rename from segments/_indexTestLoginVals.php rename to frontend/segments/_indexTestLoginVals.php diff --git a/segments/_login.php b/frontend/segments/_login.php similarity index 100% rename from segments/_login.php rename to frontend/segments/_login.php diff --git a/segments/_myFriendsBook.php b/frontend/segments/_myFriendsBook.php similarity index 100% rename from segments/_myFriendsBook.php rename to frontend/segments/_myFriendsBook.php diff --git a/segments/_register.php b/frontend/segments/_register.php similarity index 100% rename from segments/_register.php rename to frontend/segments/_register.php From 518a5f6ec87d0a2e9dd3fb57a1d0360ea45998b9 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sat, 14 Mar 2020 23:30:39 +0100 Subject: [PATCH 8/9] remove unused volume --- docker-compose.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index bb3e4f3..a778404 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,9 +21,5 @@ services: depends_on: - db -volumes: - db-data: - - # docker run -d -p 5455:3306 -v `pwd`/setup:/docker-entrypoint-initdb.d/ -v `pwd`/mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Test mariadb # docker run -d -p 80:80 --name my-apache-php-app -v `pwd`:/var/www/html php:7.0-apache From ef821f82f9b0799b97110deca2fda6a821ea2c5d Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sat, 14 Mar 2020 23:53:16 +0100 Subject: [PATCH 9/9] Update docker-compose version to 3.7, Update php to latest-7 --- docker-compose.yml | 2 +- frontend/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a778404..80df2ae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3' +version: '3.7' services: db: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 2208e15..26faba3 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.0-apache +FROM php:7-apache RUN docker-php-ext-install pdo pdo_mysql mysqli RUN a2enmod rewrite