Compare commits

...

5 Commits

12 changed files with 569 additions and 38 deletions

193
.gitignore vendored Normal file
View File

@ -0,0 +1,193 @@
# Created by https://www.toptal.com/developers/gitignore/api/intellij,windows,macos,git
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij,windows,macos,git
### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig
# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/encodings.xml
.idea/php.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/
# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml
# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/
# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$
# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml
# Azure Toolkit for IntelliJ plugin
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
.idea/**/azureSettings.xml
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### macOS Patch ###
# iCloud generated files
*.icloud
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.toptal.com/developers/gitignore/api/intellij,windows,macos,git

View File

@ -13,14 +13,12 @@ class ContactController
private $labels = array("name" => "Name", "email" => "E-Mail-Adresse", "content" => "Nachricht");
public function __construct($view)
{
public function __construct($view) {
$this->db = new ContactModel();
$this->view = $view;
}
public function showContactForm()
{
public function showContactForm() {
$this->view->setVars([
'labels' => $this->labels,
'validData' => $this->validData,
@ -28,12 +26,11 @@ class ContactController
]);
}
public function showConfirmation()
{
public function showConfirmation() {
}
public function validateForm(){
public function validateForm() {
foreach ($this->labels as $index => $value) {
if (!isset($_POST[$index]) || empty($_POST[$index])) {
$this->errors[$index] = "Bitte " . $value . " angeben";

View File

@ -0,0 +1,52 @@
<?php
namespace Blog\Controller;
use Blog\Model\EventModel;
class EventController {
protected $view;
protected $eventModel;
public function __construct($view) {
$this->eventModel = new EventModel();
$this->view = $view;
}
public function updateEvent() {
$event = array(
"ausstellungid" => $_POST['ausstellungid'],
"standortid" => $_POST['standortid'],
"datum_von" => $_POST['datumVon'],
"datum_bis" => $_POST['datumBis'],
"name" => $_POST['name'],
"beschreibung" => $_POST['beschreibung'],
"max_tickets" => $_POST['max_tickets'],
"preis" => $_POST['preis'],
);
$this->eventModel->updateEvent($event);
$this->view->setVars([
"ausstellungid" => $_POST['ausstellungid'],
]);
}
public function createEvent() {
$event = array(
"standortid" => $_POST['standortid'],
"datum_von" => $_POST['datumVon'],
"datum_bis" => $_POST['datumBis'],
"name" => $_POST['name'],
"beschreibung" => $_POST['beschreibung'],
"max_tickets" => $_POST['max_tickets'],
"preis" => $_POST['preis'],
);
$this->eventModel->createEvent($event);
$this->view->setVars([
"name" => $_POST['name'],
]);
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace Blog\Controller;
use Blog\Model\EventModel;
use Blog\Model\TicketModel;
class TicketController {
protected $view;
protected $ticketModel;
protected $eventModel;
public function __construct($view)
{
$this->ticketModel = new TicketModel();
$this->eventModel = new EventModel();
$this->view = $view;
}
public function buyTicket() {
$userId = $_POST['userId'];
$eventId = $_POST['eventId'];
$gueltigkeitsdatum = $_POST['gueltigkeitsdatum'];
$values = array("userId" => $userId,
"eventId" => $eventId,
"gueltigkeitsdatum" => $gueltigkeitsdatum);
$this->ticketModel->buyTicket($values);
$event = $this->eventModel->getEvent($eventId);
$this->view->setVars([
"event" => $event[0]
]
);
}
private function hasTicket($userId, $eventId, $gueltigkeitsdatum) {
}
}

86
Model/EventModel.php Normal file
View File

@ -0,0 +1,86 @@
<?php
namespace Blog\Model;
use PDOException;
class EventModel extends Database {
public function showEvents() {
}
public function updateEvent($event) {
$pdo = $this->linkDB();
$sql = "UPDATE ausstellung SET
standortid = :standortid,
datum_von = :datum_von,
datum_bis = :datum_bis,
name = :name,
beschreibung = :beschreibung,
max_tickets = :max_tickets,
preis = :preis
WHERE ausstellungid = :ausstellungid;";
$params = array(
":standortid" => $event['standortid'],
":datum_von" => $event['datum_von'],
":datum_bis" => $event['datum_bis'],
":name" => $event['name'],
":beschreibung" => $event['beschreibung'],
":max_tickets" => $event['max_tickets'],
":preis" => $event['preis'],
":ausstellungid" => $event['ausstellungid']
);
try {
$sth = $pdo->prepare($sql);
$sth->execute($params);
} catch (PDOException $e) {
new \Blog\Library\ErrorMsg("Fehler beim Aktualisieren der Daten.", $e);
die;
}
}
public function createEvent($event) {
$pdo = $this->linkDB();
$sql = "INSERT INTO ausstellung (`standortid`, `datum_von`, `datum_bis`, `name`, `beschreibung`, `max_tickets`, `preis`) VALUES (
:standortid, :datum_von, :datum_bis, :name, :beschreibung, :max_tickets, :preis);";
$params = array(
":standortid" => $event['standortid'],
":datum_von" => $event['datum_von'],
":datum_bis" => $event['datum_bis'],
":name" => $event['name'],
":beschreibung" => $event['beschreibung'],
":max_tickets" => $event['max_tickets'],
":preis" => $event['preis']
);
try {
$sth = $pdo->prepare($sql);
$sth->execute($params);
return $sth;
} catch (PDOException $e) {
new \Blog\Library\ErrorMsg("Fehler beim Schreiben der Daten.", $e);
die;
}
}
public function getEvent($id) {
$pdo = $this->linkDB();
$sql = "SELECT * FROM `ausstellung` WHERE `ausstellungid` = :eventId;";
$params = array("eventId" => $id);
try {
$sth = $pdo->prepare($sql);
$sth->execute($params);
$erg = $sth->fetchAll(\PDO::FETCH_ASSOC);
return $erg[0];
} catch (PDOException $e) {
new \Blog\Library\ErrorMsg("Fehler beim Schreiben der Daten.", $e);
die;
}
}
}

31
Model/TicketModel.php Normal file
View File

@ -0,0 +1,31 @@
<?php
namespace Blog\Model;
use PDOException;
class TicketModel extends Database {
public function buyTicket($values) {
$sql = "INSERT INTO ticket (`userId`, `eventId`, `kaufdatum`, `gueltigkeitsdatum`) VALUES (
:userId, :eventId, :kaufdatum, :gueltigkeitsdatum);";
$pdo = $this->linkDB();
$params = array(
":userId" => $values['userId'],
":eventId" => $values['eventId'],
":kaufdatum" => $values['kaufdatum'],
":gueltigkeitsdatum" => $values['gueltigkeitsdatum']
);
try {
$sth = $pdo->prepare($sql);
$sth->execute($params);
} catch (PDOException $e) {
new \Blog\Library\ErrorMsg("Fehler beim Schreiben der Daten.", $e);
die;
}
return true;
}
}

View File

@ -0,0 +1,12 @@
<?php
include dirname(__DIR__).'/header.phtml';
?>
<div class="msg">
<p>Das Event "<?php echo $name?>" wurde erfolgreich erstellt!</p>
<a href="?controller=Welcome&do=showWelcome">Weiter</a>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>

View File

@ -0,0 +1,12 @@
<?php
include dirname(__DIR__).'/header.phtml';
?>
<div class="msg">
<p>Das Event mit der ID "<?php echo $ausstellungid?>" wurde erfolgreich bearbeitet!</p>
<a href="?controller=Welcome&do=showWelcome">Weiter</a>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>

View File

@ -0,0 +1,12 @@
<?php
include dirname(__DIR__).'/header.phtml';
?>
<div class="msg">
<p>Ihr Ticket für das Event "<?php echo $event['name']?>" wurde erfolgreich gekauft!</p>
<a href="?controller=Welcome&do=showWelcome">Weiter</a>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>

124
bibarts.sql Normal file
View File

@ -0,0 +1,124 @@
-- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Erstellungszeit: 24. Nov 2017 um 17:01
-- Server-Version: 10.1.16-MariaDB
-- PHP-Version: 7.0.9
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Datenbank: `blog`
--
-- --------------------------------------------------------
CREATE TABLE User (
userid INT AUTO_INCREMENT PRIMARY KEY,
vorname VARCHAR(50),
nachname VARCHAR(50),
straße VARCHAR(100),
hausnr VARCHAR(10),
postleitzahl VARCHAR(10),
ort VARCHAR(50),
land VARCHAR(50),
tel VARCHAR(20),
email VARCHAR(100) UNIQUE,
isAdmin BOOLEAN DEFAULT FALSE,
password VARCHAR(255)
);
CREATE TABLE Standort (
standortid INT AUTO_INCREMENT PRIMARY KEY,
straße VARCHAR(100),
hausnr VARCHAR(10),
postleitzahl VARCHAR(10),
ort VARCHAR(50),
land VARCHAR(50),
tel VARCHAR(20),
email VARCHAR(100)
);
CREATE TABLE Ausstellung (
austellungid INT AUTO_INCREMENT PRIMARY KEY,
standortid INT,
datum_von DATE,
datum_bis DATE,
name VARCHAR(100),
beschreibung TEXT,
max_tickets INT,
FOREIGN KEY (standortid) REFERENCES Standort(standortid)
);
CREATE TABLE Ticket (
ticketid INT AUTO_INCREMENT PRIMARY KEY,
userid INT,
eventid INT,
kaufdatum DATE,
gültigkeitsdatum DATE,
preis DECIMAL(10,2),
FOREIGN KEY (userid) REFERENCES User(userid),
FOREIGN KEY (eventid) REFERENCES Ausstellung(austellungid)
);
CREATE TABLE Gutschein (
gutscheinid INT AUTO_INCREMENT PRIMARY KEY,
code VARCHAR(50) UNIQUE,
rabatt INT CHECK (rabatt BETWEEN 0 AND 100),
eventid INT,
gültigkeit DATE,
FOREIGN KEY (eventid) REFERENCES Ausstellung(austellungid)
);
CREATE TABLE News (
newsid INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100),
beschreibung TEXT,
datum DATE
);
INSERT INTO User (vorname, nachname, straße, hausnr, postleitzahl, ort, land, tel, email, isAdmin, password)
VALUES
('Max', 'Muster', 'Musterstraße', '1', '12345', 'Musterstadt', 'Deutschland', '0123456789', 'max@muster.de', FALSE, 'passwort123'),
('Anna', 'Beispiel', 'Beispielweg', '5a', '54321', 'Beispielstadt', 'Deutschland', '0987654321', 'anna@beispiel.de', TRUE, 'adminpass');
INSERT INTO Standort (straße, hausnr, postleitzahl, ort, land, tel, email)
VALUES
('Galeriestraße', '10', '10115', 'Berlin', 'Deutschland', '030123456', 'kontakt@galerie-berlin.de'),
('Kunstallee', '22b', '50667', 'Köln', 'Deutschland', '0221123456', 'info@kunst-koeln.de');
INSERT INTO Ausstellung (standortid, datum_von, datum_bis, name, beschreibung, max_tickets)
VALUES
(1, '2025-07-01', '2025-08-31', 'Moderne Meisterwerke', 'Eine Sammlung moderner Kunstwerke aus Europa.', 200),
(2, '2025-09-10', '2025-10-20', 'Kunst der Antike', 'Ausstellung antiker Skulpturen und Gemälde.', 150);
INSERT INTO Gutschein (code, rabatt, eventid, gültigkeit)
VALUES
('SOMMER2025', 15, 1, '2025-08-31'),
('HERBST25', 25, 2, '2025-10-15');
INSERT INTO Ticket (userid, eventid, kaufdatum, gültigkeitsdatum, preis)
VALUES
(1, 1, '2025-06-01', '2025-07-15', 12.50),
(2, 2, '2025-06-05', '2025-09-15', 10.00);
INSERT INTO News (name, beschreibung, datum)
VALUES
('Neuer Standort eröffnet', 'Unsere Galerie in Köln ist jetzt geöffnet!', '2025-06-01'),
('Frühbucher-Rabatt', 'Sichern Sie sich jetzt 15% Rabatt auf unsere Sommerausstellung.', '2025-05-20');

View File

@ -1,30 +0,0 @@
-- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Erstellungszeit: 24. Nov 2017 um 17:01
-- Server-Version: 10.1.16-MariaDB
-- PHP-Version: 7.0.9
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Datenbank: `blog`
--
-- --------------------------------------------------------
CREATE TABLE `contact` (
`id` varchar(36) NOT NULL,
`topicCode` tinyint(2) NULL,
`name` varchar(200) NOT NULL,
`email` varchar(300) NOT NULL,
`phone` varchar(16) NULL,
`content` varchar(500) NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `contact`
ADD PRIMARY KEY (`id`)

View File

@ -1,6 +1,6 @@
<?php
session_start();
session_start();;;
spl_autoload_register(function ($className) {
if (substr($className, 0, 5) !== 'Blog\\') {