19 Commits

Author SHA1 Message Date
d711bc6152 Add registration functionality and update authentication views
- Implemented a new method in AuthController to display the registration form with localized labels and session error handling.
- Updated the login view to include a link for account creation.
- Enhanced the registration view with a link to the login form.
- Removed the obsolete showRegisterPage view to streamline the codebase.
2025-06-30 14:10:40 +02:00
8e1a13ea27 Remove unused render call in AuthController after session cleanup 2025-06-30 14:01:56 +02:00
6852923db0 Add login page styles and refactor authentication views
- Introduced new styles for the login page, enhancing layout and responsiveness.
- Updated the login view to utilize the new styles and improve user feedback for login errors and success messages.
- Removed unused controllers and views related to contact and login functionalities to streamline the codebase.
- Adjusted error message handling in the AuthController for better clarity on password requirements.
2025-06-30 14:01:08 +02:00
71d838da0a Merge branch 'feature/authentification' into frontendbackendtest
# Conflicts:
#	bibarts.sql
2025-06-30 11:13:44 +02:00
8583012c5b Refactor views wegen öffnendem body tag im header und schließenden tag im footer 2025-06-30 10:50:08 +02:00
31a381bba4 SQL spaltennamen vorkommen im code angepasst 2025-06-30 10:28:28 +02:00
a72a0c5fc5 SQL spaltennamen vorkommen im code angepasst 2025-06-30 10:27:10 +02:00
ce23d839a3 Register und login gefixt 2025-06-30 09:56:52 +02:00
36d6364cd0 Auth angepasst 2025-06-27 10:24:21 +02:00
Max538
5477e7fdd8 fixed sql 2025-06-23 14:23:00 +02:00
Max538
db526e5bb2 implemented Controller logic 2025-06-23 14:22:43 +02:00
Max538
dd6e98fe28 implemented update pw function 2025-06-23 14:14:25 +02:00
Max538
5965e1df81 implemented input validation for register function 2025-06-23 10:35:55 +02:00
Max538
8d4376d313 fixed login function 2025-06-23 10:17:17 +02:00
Max538
49a8f6a1dc added database sql skript with changes 2025-06-16 15:12:51 +02:00
Max538
78e1e72eba implemented authmodel 2025-06-16 15:12:28 +02:00
Max538
4fa775f326 implemented authcontroller logic 2025-06-16 15:12:13 +02:00
1df705a235 Merge remote-tracking branch 'origin/main' 2025-06-12 16:15:25 +02:00
5594d469de Test 2025-06-12 16:14:54 +02:00
32 changed files with 512 additions and 610 deletions

View File

@@ -4,22 +4,9 @@ body {
font-size: 15px;
margin: 0;
padding: 0;
min-height: 100vh;
display: flex;
flex-direction: column;
width: 100vw;
max-width: 100vw;
overflow-x: hidden;
}
#wrapper {
flex: 1 0 auto;
min-height: 0;
display: flex;
flex-direction: column;
justify-content: flex-start;
margin-bottom: 20px;
width: 100vw;
max-width: 100vw;
}
a {
@@ -29,11 +16,6 @@ a {
#navigation {
display: flex;
justify-content: center;
position: sticky;
top: 0;
z-index: 1000;
background: #BAC8D4;
width: 100vw;
}
.link-container {
display: grid;
@@ -56,19 +38,17 @@ a {
background-size: contain;
}
#footer {
position: relative;
position: absolute;
bottom: 0;
left: 0;
width: 100vw;
height: 180px;
width: 100%;
height: 240px;
background-color: #BAC8D4;
display: flex;
flex-direction: column;
display: grid;
grid-template-columns: 6% 5% 43% 32% 14%;
grid-template-rows: 45% 10% 45%;
align-items: center;
justify-content: center;
flex-shrink: 0;
z-index: 999;
padding: 10px 0;
}
.container-zahlungsmittel {
@@ -81,16 +61,11 @@ a {
}
.inhalt {
flex: 1 1 auto;
display: flex;
height: 10px;
justify-content: center;
align-items: center;
width: 100vw;
min-height: 0;
min-width: 0;
margin: 0;
padding: 0 2vw;
box-sizing: border-box;
width: 100%;
}
.zahlungsmittel-img {
@@ -127,251 +102,141 @@ a {
padding-right: 30px;
}
.container-welcome-inhalt {
grid-template-columns: 39% 61%;
display: grid;
grid-template-columns: 1fr 1fr;
width: 100%;
max-width: 900px;
min-height: 200px;
width: 110em;
min-height: 80%;
border-radius: 10px;
background: white;
box-shadow: 0 2px 16px rgba(0,0,0,0.08);
justify-items: center;
align-items: center;
box-sizing: border-box;
padding: 10px 0;
}
.beispiel-austellung1-img, .beispiel-austellung2-img {
height: 200px;
width: 90vw;
max-width: 320px;
.beispiel-austellung1-img {
height: 480px;
width: 670px;
background-image: url("../images/beispiel-austellung1.png");
background-position: center;
background-size: contain;
justify-self: right;
border-radius: 10px;
}
.beispiel-austellung2-img {
background-image: url("../images/beispiel-austellung2.png");
background-position: center;
background-size: contain;
justify-self: right;
border-radius: 10px;
}
/* Login Page Styles */
.login-page-bg {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #DFF0F2 60%, #BAC8D4 100%);
}
.login-container {
position: absolute;
top: 200px;
background-color: #BAC8D4;
width: 900px;
height: 450px;
border-radius: 10px;
background: #fff;
box-shadow: 0 4px 24px rgba(0,0,0,0.10);
border-radius: 16px;
padding: 40px 32px 32px 32px;
width: 100%;
max-width: 400px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.tickets-container {
position: absolute;
top: 200px;
background-color: #BAC8D4;
width: 900px;
height: 450px;
border-radius: 10px;
.login-title {
margin-bottom: 24px;
color: #4d4d4d;
font-size: 2rem;
font-weight: 600;
letter-spacing: 1px;
}
.login-form {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
gap: 18px;
}
.login-field {
display: flex;
flex-direction: column;
gap: 6px;
}
.login-field label {
font-weight: 500;
color: #4d4d4d;
}
.login-field input {
padding: 10px 12px;
border: 1px solid #BAC8D4;
border-radius: 6px;
font-size: 1rem;
background: #F7FAFC;
transition: border 0.2s;
}
.login-field input:focus {
border: 1.5px solid #09add0;
outline: none;
}
.login-btn {
margin-top: 10px;
padding: 12px 0;
background: #09add0;
color: #fff;
border: none;
border-radius: 6px;
font-size: 1.1rem;
font-weight: 600;
cursor: pointer;
transition: background 0.2s;
}
.login-btn:hover {
background: #007b9e;
}
.login-error {
background: #ffe0e0;
color: #b30000;
border: 1px solid #ffb3b3;
border-radius: 6px;
padding: 10px 16px;
margin-bottom: 18px;
width: 100%;
text-align: center;
}
.login-success {
background: #e0ffe6;
color: #006633;
border: 1px solid #b3ffd1;
border-radius: 6px;
padding: 10px 16px;
margin-bottom: 18px;
width: 100%;
text-align: center;
}
.login-link {
display: inline-block;
margin-top: 10px;
color: #09add0;
font-weight: 500;
text-decoration: underline;
}
@media (max-width: 600px) {
body {
font-size: 14px;
width: 100vw;
max-width: 100vw;
overflow-x: hidden;
}
#wrapper {
width: 100vw;
max-width: 100vw;
}
#navigation {
width: 100vw;
min-width: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
}
.link-container {
width: 100vw;
min-width: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
row-gap: 8px;
border-radius: 0;
padding: 0 4px;
}
.links {
font-size: 18px;
justify-content: center;
align-items: center;
padding: 6px 0;
text-align: center;
width: 100%;
}
#logo {
width: 120px;
height: 40px;
margin: 0 auto 8px auto;
display: flex;
justify-content: center;
align-items: center;
}
.container-welcome-inhalt {
grid-template-columns: 1fr;
width: 100vw;
max-width: 100vw;
min-height: 0;
padding: 8px 0;
}
.beispiel-austellung1-img, .beispiel-austellung2-img {
width: 90vw;
max-width: 98vw;
height: 120px;
margin-bottom: 10px;
}
.inhalt {
width: 100vw;
min-width: 0;
max-width: 100vw;
padding: 0 2vw;
box-sizing: border-box;
flex-direction: column;
align-items: stretch;
}
#footer {
width: 100vw;
height: auto;
min-height: 120px;
padding: 10px 0 10px 0;
font-size: 13px;
}
.container-zahlungsmittel {
width: 100vw;
text-align: center;
padding: 0;
}
.header-zahlungsarten {
font-size: 1.1em;
padding-right: 0;
text-align: center;
}
.zahlungsmittel-img {
width: 90vw;
max-width: 200px;
height: 30px;
margin: 0 auto;
}
.line {
width: 95vw;
}
.link-impressum, .link-datenschutz, .link-nutzungsbedingungen {
display: block;
padding: 2px 0;
text-align: center;
}
.text-bib {
display: block;
text-align: center;
padding: 0;
}
.desktop-only {
display: none !important;
}
.mobile-only {
display: block !important;
}
.login-container {
position: static;
width: 95vw;
max-width: 400px;
height: auto;
margin: 24px auto;
padding: 16px 8px;
box-sizing: border-box;
}
.tickets-container {
position: static;
width: 95vw;
max-width: 400px;
height: auto;
margin: 24px auto;
padding: 16px 8px;
box-sizing: border-box;
}
.login-container h1 {
font-size: 1.5em;
text-align: center;
}
.tickets-container h1 {
font-size: 1.5em;
text-align: center;
}
.login-container form,
.login-container label,
.login-container input {
width: 100%;
max-width: 100%;
box-sizing: border-box;
}
.login-container button,
.login-container a {
width: 100%;
max-width: 100%;
margin-top: 8px;
text-align: center;
box-sizing: border-box;
}
#nav-toggle-btn {
display: block;
background: none;
border: none;
font-size: 2em;
cursor: pointer;
margin: 0 auto 8px auto;
transition: transform 0.2s;
}
.nav-links {
display: none;
flex-direction: column;
align-items: center;
width: 100%;
transition: max-height 0.3s ease;
overflow: hidden;
}
.nav-links.open {
display: flex;
}
#nav-toggle-btn.open {
transform: rotate(180deg);
}
}
@media (min-width: 601px) {
.mobile-only {
display: none !important;
}
.desktop-only {
display: block !important;
}
#nav-toggle-btn {
display: none;
}
.nav-links {
display: flex !important;
flex-direction: row;
align-items: center;
width: auto;
gap: 32px;
}
.nav-links .links {
margin: 0 12px;
padding: 24px 8px;
max-width: 95vw;
}
}

View File

@@ -9,12 +9,14 @@ class AuthController
private $model;
private $view;
public function __construct($view) {
public function __construct($view)
{
$this->model = new AuthModel();
$this->view = $view;
}
public function showLoginForm() {
public function showAuthForm()
{
$this->view->setVars([
'labels' => [
"email" => "E-Mail-Adresse",
@@ -28,7 +30,8 @@ class AuthController
unset($_SESSION['auth_errors'], $_SESSION['auth_validData']);
}
public function showRegistrationForm() {
public function showRegistrationForm()
{
$this->view->setVars([
'labels' => [
"email" => "E-Mail-Adresse",
@@ -49,9 +52,12 @@ class AuthController
$result = $this->model->login($email, $password);
if ($result === true) {
$_SESSION['user'] = $email;
header('Location: /bibarts/?controller=News&do=showNews');
exit();
$_SESSION['user'] = $email;
$this->view->setVars([
'loginSuccess' => true,
'email' => $email
]);
} else {
$this->view->setVars([
'errors' => ['login' => is_string($result) ? $result : "Login fehlgeschlagen."],
@@ -63,32 +69,66 @@ class AuthController
public function register() {
$data = [
'first_name' => $_POST['vorname'] ?? '',
'last_name' => $_POST['nachname'] ?? '',
'street' => $_POST['strasse'] ?? '',
'house_number' => $_POST['hausnr'] ?? '',
'postal_code' => $_POST['plz'] ?? '',
'city' => $_POST['ort'] ?? '',
'country' => $_POST['land'] ?? '',
'phone' => $_POST['tel'] ?? '',
'vorname' => $_POST['vorname'] ?? '',
'nachname' => $_POST['nachname'] ?? '',
'straße' => $_POST['straße'] ?? '',
'hausnr' => $_POST['hausnr'] ?? '',
'postleitzahl' => $_POST['postleitzahl'] ?? '',
'ort' => $_POST['ort'] ?? '',
'land' => $_POST['land'] ?? '',
'tel' => $_POST['tel'] ?? '',
'email' => $_POST['email'] ?? '',
'password' => $_POST['password'] ?? '',
'password_repeat' => $_POST['password_repeat'] ?? '',
'is_admin' => $_POST['isAdmin'] ?? false,
'isAdmin' => $_POST['isAdmin'] ?? false,
];
$result = $this->model->register($data);
$errors = [];
if ($result === true) {
$this->view->setVars(['success' => 'Registrierung erfolgreich!']);
$this->view->render('Auth/showLoginForm');
exit;
} else {
$errors['register'] = is_string($result) ? $result : "Registrierung fehlgeschlagen.";
$this->view->setVars(['errors' => $errors, 'validData' => $data]);
$this->view->render('Auth/showRegistrationForm');
exit;
if (!$this->model->checkDoublePw($data['password'], $data['password_repeat'])) {
$errors['password'] = "Passwörter stimmen nicht überein.";
}
if ($this->pwRequirementCheck($data['password'])) {
$errors['password'] = "Passwort muss mindestens 8 Zeichen lang sein und mindestens ein Großbuchstabe, ein Kleinbuchstabe, eine Zahl und ein Sonderzeichen enthalten.";
}
if (empty($errors)) {
$result = $this->model->register($data);
if ($result === true) {
$this->view->setVars([
'success' => "Registrierung war erfolgreich."
]);
} else {
$errors['register'] = is_string($result) ? $result : "Registrierung fehlgeschlagen.";
}
}
$this->view->setVars([
'errors' => $errors,
'validData' => $data
]);
}
private function pwRequirementCheck($password){
$error = [];
if(strlen($password) <= 8)
$error[] = "min 8 Charackter";
if(!preg_match("/[A-Z]/", $password))
$error[] = "min one large Character";
if(!preg_match("/[a-z]/", $password))
$error[] = "min one small charakter";
if(!preg_match("/[0-9]/", $password))
$error[] = "min one number";
if(!preg_match("[^a-zA-Z0-9\s]", $password));
$error[] = "min one special character";
if(empty($error))
return true;
else
return $error;
}
public function forgotPassword() {
@@ -141,11 +181,4 @@ class AuthController
$this->view->setVars(['message' => $message]);
$this->view->render('auth/confirmation');
}
public function logout() {
unset($_SESSION['user']);
session_destroy();
header('Location: /bibarts/?controller=Auth&do=showLoginForm');
exit();
}
}

View File

@@ -1,53 +0,0 @@
<?php
namespace Blog\Controller;
use Blog\Model\ContactModel;
class ContactController
{
protected $view;
private $db;
private $validData = array();
private $errors = array();
private $labels = array("name" => "Name", "email" => "E-Mail-Adresse", "content" => "Nachricht");
public function __construct($view) {
$this->db = new ContactModel();
$this->view = $view;
}
public function showContactForm() {
$this->view->setVars([
'labels' => $this->labels,
'validData' => $this->validData,
'errors' => $this->errors
]);
}
public function showConfirmation() {
}
public function validateForm() {
foreach ($this->labels as $index => $value) {
if (!isset($_POST[$index]) || empty($_POST[$index])) {
$this->errors[$index] = "Bitte " . $value . " angeben";
} else {
$this->validData[$index] = $_POST[$index];
}
}
if (count($this->errors) > 0) {
$this->view->setDoMethodName("showContactForm");
$this->showContactForm();
} else {
if ($this->db->writeContactData($this->validData)) {
$this->view->setDoMethodName("showConfirmation");
$this->showConfirmation();
}
}
}
}
?>

View File

@@ -23,8 +23,8 @@ class GutscheinController {
$data = [
'code' => $_POST['code'] ?? null,
'rabatt' => $_POST['rabatt'] ?? null,
'eventid' => $_POST['eventid'] ?? null,
'gültigkeit' => $_POST['gültigkeit'] ?? null
'ausstellungid' => $_POST['ausstellungid'] ?? null,
'gueltigkeit' => $_POST['gueltigkeit'] ?? null
];
$erg = $this->model->createGutschein($data);
$this->view->setVars(['gutschein' => $erg]);
@@ -44,8 +44,8 @@ class GutscheinController {
$data = [
'code' => $_POST['code'] ?? null,
'rabatt' => $_POST['rabatt'] ?? null,
'eventid' => $_POST['eventid'] ?? null,
'gültigkeit' => $_POST['gültigkeit'] ?? null
'ausstellungid' => $_POST['ausstellungid'] ?? null,
'gueltigkeit' => $_POST['gueltigkeit'] ?? null
];
$this->model->updateGutschein($id, $data);
}

View File

@@ -1,10 +0,0 @@
<?php
namespace Blog\Controller;
class ProfileController {
function showProfile()
{
}
}

View File

@@ -21,9 +21,9 @@ class StandortController {
public function createStandort() {
$data = [
'straße' => $_POST['straße'],
'strasse' => $_POST['strasse'],
'hausnr' => $_POST['hausnr'],
'postleitzahl' => $_POST['postleitzahl'],
'plz' => $_POST['plz'],
'ort' => $_POST['ort'],
'land' => $_POST['land'],
'tel' => $_POST['tel'],
@@ -40,17 +40,17 @@ class StandortController {
}
public function updateStandort() {
$id = $_POST['standortid'];
$data = [
'straße' => $_POST['straße'],
'strasse' => $_POST['strasse'],
'hausnr' => $_POST['hausnr'],
'postleitzahl' => $_POST['postleitzahl'],
'plz' => $_POST['plz'],
'ort' => $_POST['ort'],
'land' => $_POST['land'],
'tel' => $_POST['tel'],
'email' => $_POST['email']
];
$erg = $this->model->updateStandort($id, $data);
];
$standortid = $_POST['standortid'];
$erg = $this->model->updateStandort($standortid, $data);
$this->view->setVars(['standort' => $erg]);
}

View File

@@ -22,9 +22,9 @@ class TicketController {
public function buyTicket() {
$data = [
'userid' => $_POST['userid'],
'eventid' => $_POST['eventid'],
'ausstellungid' => $_POST['ausstellungid'],
'kaufdatum' => date('Y-m-d'),
'gültigkeitsdatum' => $_POST['gültigkeitsdatum']
'gueltigkeit' => $_POST['gueltigkeit']
];
$erg = $this->ticketModel->buyTicket($data);
$this->view->setVars(['ticket' => $erg]);

View File

@@ -1,10 +0,0 @@
<?php
namespace Blog\Controller;
class TicketsController {
function showTickets()
{
}
}

View File

@@ -1,18 +0,0 @@
<?php
namespace Blog\Controller;
class WelcomeController
{
function showWelcome() {
}
function showProjects() {
}
function showTutorials() {
}
}

View File

@@ -11,7 +11,7 @@ class AuthModel extends Database
public function login(string $email, string $password)
{
$pdo = $this->linkDB();
$sql = "SELECT email, password, valid_until FROM user WHERE email = :email";
$sql = "SELECT email, password, validUntil FROM user WHERE email = :email";
$params = [":email" => $email];
try {
@@ -33,7 +33,7 @@ class AuthModel extends Database
try {
$now = new DateTime();
$validUntil = new DateTime($user['valid_until']);
$validUntil = new DateTime($user['validUntil']);
if ($now > $validUntil) {
return "Ihr Passwort ist abgelaufen. Bitte setzen Sie ein neues über \"Passwort vergessen\".";
@@ -46,14 +46,20 @@ class AuthModel extends Database
return true;
}
public function register($data) {
public function register($data)
{
$rtn = $this->pwRequirementCheck($data['password']);
if ($rtn !== true) {
return $rtn;
}
if (!filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
return "Bitte geben Sie eine gültige E-Mail ein.";
}
$requiredFields = [
'email', 'password', 'street', 'house_number', 'city', 'postal_code',
'country', 'first_name', 'last_name', 'phone'
'email', 'password', 'straße', 'hausnr', 'ort', 'postleitzahl',
'land', 'vorname', 'nachname', 'tel'
];
foreach ($requiredFields as $field) {
@@ -66,32 +72,23 @@ class AuthModel extends Database
return "Ein Account mit dieser E-Mail existiert bereits.";
}
// Passwort-Validierung
if (!$this->checkDoublePw($data['password'], $data['password_repeat'])) {
return "Passwörter stimmen nicht überein.";
}
if ($this->pwRequirementCheck($data['password']) !== true) {
return "Passwort muss mindestens 8 Zeichen lang sein und mindestens ein Großbuchstabe, ein Kleinbuchstabe, eine Zahl und ein Sonderzeichen enthalten.";
}
$hashedPassword = password_hash($data['password'], PASSWORD_DEFAULT);
$sql = "INSERT INTO user (email, password, street, house_number, city, postal_code, country, first_name, last_name, phone, is_admin)
VALUES (:email, :password, :street, :house_number, :city, :postal_code, :country, :first_name, :last_name, :phone, :is_admin)";
$sql = "INSERT INTO user (email, password, straße, hausnr, ort, postleitzahl, land,vorname, nachname, tel, isAdmin)
VALUES (:email, :password, :straße, :hausnr, :ort, :postleitzahl, :land,:vorname, :nachname, :tel, :isAdmin)";
$params = [
':email' => $data['email'],
':password' => $hashedPassword,
':street' => $data['street'],
':house_number' => $data['house_number'],
':city' => $data['city'],
':postal_code'=> $data['postal_code'],
':country'=> $data['country'],
':first_name' => $data['first_name'],
':last_name'=> $data['last_name'],
':phone' => $data['phone'],
':is_admin' => $data['is_admin'] ? 1 : 0,
':straße' => $data['straße'],
':hausnr' => $data['hausnr'],
':ort' => $data['ort'],
':postleitzahl'=> $data['postleitzahl'],
':land'=> $data['land'],
':vorname' => $data['vorname'],
':nachname'=> $data['nachname'],
':tel' => $data['tel'],
':isAdmin' => $data['isAdmin'] ? 1 : 0,
];
try {
@@ -109,7 +106,7 @@ class AuthModel extends Database
try {
$pdo = $this->linkDB();
$sql = "SELECT user_id FROM user WHERE email = :email";
$sql = "SELECT userid FROM user WHERE email = :email";
$params = [':email' => $email];
$stmt = $pdo->prepare($sql);
@@ -148,7 +145,8 @@ class AuthModel extends Database
}
}
private function forgottenPwUpdate($email, $hashedPassword) {
private function forgottenPwUpdate($email, $hashedPassword)
{
try{
$pdo = $this->linkDB();
@@ -163,16 +161,15 @@ class AuthModel extends Database
$sql = "UPDATE user
SET password = :password, valid_until = :valid_until
SET password = :password, validUntil = :validUntil
WHERE email = :email";
$stmt = $pdo->prepare($sql);
$params = [
return $stmt->execute([
':email' => $email,
':password' => $hashedPassword,
':valid_until' => $validUntil
];
return $stmt->execute($params);
':validUntil' => $validUntil
]);
} catch (PDOException $e) {
new \Blog\Library\ErrorMsg("Fehler beim Aktualisieren der Daten.", $e);
die;
@@ -193,16 +190,16 @@ class AuthModel extends Database
}
$hashedPassword = password_hash($newpw, PASSWORD_DEFAULT);
$sql = "UPDATE user SET password = :password WHERE email = :email";
$sql = "INSERT INTO user (email, password)
VALUES (:email, :password)";
try{
$pdo = $this->linkDB();
$stmt = $pdo->prepare($sql);
$params = [
return $stmt->execute([
':email' => $email,
':password' => $hashedPassword,
];
return $stmt->execute($params);
]);
} catch (PDOException $e) {
new \Blog\Library\ErrorMsg("Fehler beim Schreiben der Daten.", $e);
die;
@@ -216,24 +213,4 @@ class AuthModel extends Database
else
return false;
}
public function pwRequirementCheck($password){
$error = [];
if(strlen($password) <= 8)
$error[] = "min 8 Charackter";
if(!preg_match("/[A-Z]/", $password))
$error[] = "min one large Character";
if(!preg_match("/[a-z]/", $password))
$error[] = "min one small charakter";
if(!preg_match("/[0-9]/", $password))
$error[] = "min one number";
if(!preg_match("[^a-zA-Z0-9\s]", $password));
$error[] = "min one special character";
if(empty($error))
return true;
else
return $error;
}
}

View File

@@ -8,7 +8,7 @@ class GutscheinModel extends Database {
public function getGutscheine() {
$pdo = $this->linkDB();
$sql = "SELECT * FROM gutschein ORDER BY gültigkeit DESC;";
$sql = "SELECT * FROM gutschein ORDER BY gueltigkeit DESC;";
try {
$sth = $pdo->prepare($sql);
$sth->execute();
@@ -35,12 +35,12 @@ class GutscheinModel extends Database {
public function createGutschein($data) {
$pdo = $this->linkDB();
$sql = "INSERT INTO gutschein (code, rabatt, eventid, gültigkeit) VALUES (:code, :rabatt, :eventid, :gültigkeit);";
$sql = "INSERT INTO gutschein (code, rabatt, ausstellungid, gueltigkeit) VALUES (:code, :rabatt, :ausstellungid, :gueltigkeit);";
$params = [
":code" => $data['code'],
":rabatt" => $data['rabatt'],
":eventid" => $data['eventid'],
":gültigkeit" => $data['gültigkeit']
":ausstellungid" => $data['ausstellungid'],
":gueltigkeit" => $data['gueltigkeit']
];
try {
$sth = $pdo->prepare($sql);
@@ -54,12 +54,12 @@ class GutscheinModel extends Database {
public function updateGutschein($id, $data) {
$pdo = $this->linkDB();
$sql = "UPDATE gutschein SET code = :code, rabatt = :rabatt, eventid = :eventid, gültigkeit = :gültigkeit WHERE gutscheinid = :id;";
$sql = "UPDATE gutschein SET code = :code, rabatt = :rabatt, ausstellungid = :ausstellungid, gueltigkeit = :gueltigkeit WHERE gutscheinid = :id;";
$params = [
":code" => $data['code'],
":rabatt" => $data['rabatt'],
":eventid" => $data['eventid'],
":gültigkeit" => $data['gültigkeit'],
":ausstellungid" => $data['ausstellungid'],
":gueltigkeit" => $data['gueltigkeit'],
":id" => $id
];
try {

View File

@@ -35,12 +35,12 @@ class StandortModel extends Database {
public function createStandort($data) {
$pdo = $this->linkDB();
$sql = "INSERT INTO Standort (straße, hausnr, postleitzahl, ort, land, tel, email)
VALUES (:straße, :hausnr, :postleitzahl, :ort, :land, :tel, :email);";
$sql = "INSERT INTO Standort (strasse, hausnr, plz, ort, land, tel, email)
VALUES (:strasse, :hausnr, :plz, :ort, :land, :tel, :email);";
$params = [
":straße" => $data['straße'],
":strasse" => $data['strasse'],
":hausnr" => $data['hausnr'],
":postleitzahl" => $data['postleitzahl'],
":plz" => $data['plz'],
":ort" => $data['ort'],
":land" => $data['land'],
":tel" => $data['tel'],
@@ -59,18 +59,18 @@ class StandortModel extends Database {
public function updateStandort($standortid, $data) {
$pdo = $this->linkDB();
$sql = "UPDATE Standort SET
straße = :straße,
strasse = :strasse,
hausnr = :hausnr,
postleitzahl = :postleitzahl,
plz = :plz,
ort = :ort,
land = :land,
tel = :tel,
email = :email
WHERE standortid = :standortid;";
$params = [
":straße" => $data['straße'],
":strasse" => $data['strasse'],
":hausnr" => $data['hausnr'],
":postleitzahl" => $data['postleitzahl'],
":plz" => $data['plz'],
":ort" => $data['ort'],
":land" => $data['land'],
":tel" => $data['tel'],

View File

@@ -21,13 +21,13 @@ class TicketModel extends Database {
public function buyTicket($data) {
$pdo = $this->linkDB();
$sql = "INSERT INTO Ticket (userid, eventid, kaufdatum, gültigkeitsdatum)
VALUES (:userid, :eventid, :kaufdatum, :gültigkeitsdatum);";
$sql = "INSERT INTO Ticket (userid, ausstellungid, kaufdatum, gueltigkeit)
VALUES (:userid, :ausstellungid, :kaufdatum, :gueltigkeit);";
$params = [
":userid" => $data['userid'],
":eventid" => $data['eventid'],
":ausstellungid" => $data['ausstellungid'],
":kaufdatum" => $data['kaufdatum'],
":gültigkeitsdatum" => $data['gültigkeitsdatum']
":gueltigkeit" => $data['gueltigkeit']
];
try {
$sth = $pdo->prepare($sql);
@@ -39,12 +39,12 @@ class TicketModel extends Database {
}
}
public function hasTicket($userid, $eventid) {
public function hasTicket($userid, $ausstellungid) {
$pdo = $this->linkDB();
$sql = "SELECT COUNT(*) as count FROM Ticket WHERE userid = :userid AND eventid = :eventid;";
$sql = "SELECT COUNT(*) as count FROM Ticket WHERE userid = :userid AND ausstellungid = :ausstellungid;";
$params = [
":userid" => $userid,
":eventid" => $eventid
":ausstellungid" => $ausstellungid
];
try {
$sth = $pdo->prepare($sql);

38
Views/Auth/login.phtml Normal file
View File

@@ -0,0 +1,38 @@
<?php
include dirname(__DIR__).'/header.phtml';
?>
<div class="login-page-bg">
<div class="login-container">
<h2 class="login-title">Login</h2>
<?php if (!empty($errors['login'])): ?>
<div class="login-error">
<?php echo htmlspecialchars($errors['login']); ?>
</div>
<?php elseif (!empty($loginSuccess)): ?>
<div class="login-success">
<p>Login f&uuml;r Benutzer <?php echo htmlspecialchars($_SESSION["user"]); ?> erfolgreich</p>
<a class="login-link" href="?controller=Welcome&do=showWelcome">Weiter</a>
</div>
<?php else: ?>
<form method="post" class="login-form">
<input type="hidden" name="controller" value="Auth">
<input type="hidden" name="do" value="login">
<div class="login-field">
<label for="email">E-Mail:</label>
<input type="email" name="email" id="email" value="<?= htmlspecialchars($validData['email'] ?? '') ?>">
</div>
<div class="login-field">
<label for="password">Passwort:</label>
<input type="password" name="password" id="password">
</div>
<button class="login-btn" type="submit">Einloggen</button>
</form>
<div style="text-align:center; margin-top: 1.5em;">
<a href="?controller=Auth&do=register" class="login-link">Konto erstellen</a>
</div>
<?php endif; ?>
</div>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>

65
Views/Auth/register.phtml Normal file
View File

@@ -0,0 +1,65 @@
<?php include dirname(__DIR__).'/header.phtml'; ?>
<?php if (!empty($success)) : ?>
<div class="success-message" style="color: green; margin-bottom: 1em;">
<p><?php echo htmlspecialchars($success); ?></p>
</div>
<?php endif; ?>
<?php if (!empty($errors)) : ?>
<div class="error-messages" style="color: red; margin-bottom: 1em;">
<ul>
<?php foreach ($errors as $field => $error) : ?>
<li><?php echo htmlspecialchars($error); ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<form action="?controller=Auth&do=register" method="post">
<label for="vorname">Vorname:</label>
<input type="text" name="vorname" id="vorname" value="<?php echo htmlspecialchars($validData['vorname'] ?? ''); ?>" required>
<label for="nachname">Nachname:</label>
<input type="text" name="nachname" id="nachname" value="<?php echo htmlspecialchars($validData['nachname'] ?? ''); ?>" required>
<label for="straße">Straße:</label>
<input type="text" name="straße" id="straße" value="<?php echo htmlspecialchars($validData['straße'] ?? ''); ?>" required>
<label for="hausnr">Hausnummer:</label>
<input type="text" name="hausnr" id="hausnr" value="<?php echo htmlspecialchars($validData['hausnr'] ?? ''); ?>" required>
<label for="postleitzahl">Postleitzahl:</label>
<input type="text" name="postleitzahl" id="postleitzahl" value="<?php echo htmlspecialchars($validData['postleitzahl'] ?? ''); ?>" required>
<label for="ort">Ort:</label>
<input type="text" name="ort" id="ort" value="<?php echo htmlspecialchars($validData['ort'] ?? ''); ?>" required>
<label for="land">Land:</label>
<input type="text" name="land" id="land" value="<?php echo htmlspecialchars($validData['land'] ?? ''); ?>" required>
<label for="tel">Telefonnummer:</label>
<input type="text" name="tel" id="tel" value="<?php echo htmlspecialchars($validData['tel'] ?? ''); ?>">
<label for="email">E-Mail-Adresse:</label>
<input type="email" name="email" id="email" value="<?php echo htmlspecialchars($validData['email'] ?? ''); ?>" required>
<label for="password">Passwort:</label>
<input type="password" name="password" id="password" required>
<label for="password_repeat">Passwort wiederholen:</label>
<input type="password" name="password_repeat" id="password_repeat" required>
<label for="isAdmin">
<input type="checkbox" name="isAdmin" id="isAdmin" value="1" <?php echo (!empty($validData['isAdmin'])) ? 'checked' : ''; ?>>
Admin-Rechte
</label>
<button type="submit">Registrieren</button>
</form>
<div style="text-align:center; margin-top: 1.5em;">
<a href="?controller=Auth&do=showAuthForm" class="login-link">Bereits registriert? Hier einloggen</a>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>

View File

@@ -1,3 +1,7 @@
<?php
include dirname(__DIR__) . '/header.phtml';
?>
<div class="inhalt">
<div class="login-container">
<h1>Anmelden</h1>
@@ -12,9 +16,12 @@
</label>
</form>
<button class="button-loggin">Login</button>
<a class="link-passwort-vergessen" href="?controller=Login&do=showPasswortVergessen">Passwort vergessen?</a>
<a class="link-konto-erstellen" href="?controller=Register&do=showRegisterPage">Konto erstellen</a>
<a class="link-passwort-vergessen">Passwort vergessen?</a>
<a class="link-konto-erstellen" href="?controller=Auth&do=showRegistrationForm">Konto erstellen</a>
</div>
</div>
<?php
include dirname(__DIR__) . '/footer.phtml';
?>

View File

@@ -1,3 +1,6 @@
<?php
include dirname(__DIR__) . '/header.phtml';
?>
<div class="inhalt">
<div class="login-container">
<h1>Registrieren</h1>
@@ -57,8 +60,11 @@
</label>
</form>
<button class="button-register">Registrieren</button>
<a class="link-konto-erstellen" href="?controller=Login&do=showLoginPage">Login</a>
<div style="text-align:center; margin-top: 1.5em;">
<a href="?controller=Auth&do=showAuthForm" class="login-link">Bereits registriert? Hier einloggen</a>
</div>
</div>
<?php
include dirname(__DIR__) . '/footer.phtml';
?>

View File

@@ -7,6 +7,6 @@ include dirname(__DIR__).'/header.phtml';
<a href="?controller=Event&do=showEvents">Weiter</a>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>
<?php
include dirname(__DIR__).'/footer.phtml';
?>

View File

@@ -7,6 +7,6 @@ include dirname(__DIR__).'/header.phtml';
<a href="?controller=Event&do=showEvents">Weiter</a>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>
<?php
include dirname(__DIR__).'/footer.phtml';
?>

View File

@@ -1,7 +1,7 @@
<?php include dirname(__DIR__) . '/header.phtml'; ?>
<h2>Alle Ausstellungen</h2>
<?php
include dirname(__DIR__).'/header.phtml';
?>
<h2>Alle Ausstellungen</h2>
<?php if (!empty($events)): ?>
<table>
<thead>
@@ -28,5 +28,6 @@
<?php else: ?>
<p>Derzeit sind keine Ausstellungen verfügbar.</p>
<?php endif; ?>
<?php include dirname(__DIR__) . '/footer.phtml'; ?>
<?php
include dirname(__DIR__).'/footer.phtml';
?>

View File

@@ -7,6 +7,6 @@ include dirname(__DIR__).'/header.phtml';
<a href="?controller=Event&do=showEvents">Weiter</a>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>
<?php
include dirname(__DIR__).'/footer.phtml';
?>

View File

@@ -1 +1,7 @@
echo "create gutschein"
<?php
include dirname(__DIR__).'/header.phtml';
?>
<!-- Gutschein-Erstellungsformular oder Inhalt hier einfügen -->
<?php
include dirname(__DIR__).'/footer.phtml';
?>

View File

@@ -1,7 +1,8 @@
<?php include dirname(__DIR__) . '/header.phtml'; ?>
<h2>Alle Gutscheine</h2>
<a href="?controller=Gutschein&do=createGutscheinForm">Neuen Gutschein anlegen</a>
<?php
include dirname(__DIR__).'/header.phtml';
?>
<h2>Alle Gutscheine</h2>
<a href="?controller=Gutschein&do=createGutscheinForm">Neuen Gutschein anlegen</a>
<?php if (!empty($gutscheine)): ?>
<table border="1" cellpadding="8" cellspacing="0">
<thead>
@@ -18,8 +19,8 @@
<tr>
<td><?php echo htmlspecialchars($g['code']); ?></td>
<td><?php echo (int)$g['rabatt']; ?></td>
<td><?php echo (int)$g['eventid']; ?></td>
<td><?php echo htmlspecialchars($g['gültigkeit']); ?></td>
<td><?php echo (int)$g['ausstellungid']; ?></td>
<td><?php echo htmlspecialchars($g['gueltigkeit']); ?></td>
<td>
<a href="?controller=Gutschein&action=editGutscheinForm&id=<?php echo $g['gutscheinid']; ?>">Bearbeiten</a> |
<a href="?controller=Gutschein&action=deleteGutschein&id=<?php echo $g['gutscheinid']; ?>" onclick="return confirm('Wirklich löschen?');">Löschen</a>
@@ -31,5 +32,6 @@
<?php else: ?>
<p>Keine Gutscheine vorhanden.</p>
<?php endif; ?>
<?php include dirname(__DIR__) . '/footer.phtml'; ?>
<?php
include dirname(__DIR__).'/footer.phtml';
?>

View File

@@ -1,7 +1,7 @@
<?php include dirname(__DIR__) . '/header.phtml'; ?>
<h2>Alle News</h2>
<?php
include dirname(__DIR__).'/header.phtml';
?>
<h2>Alle News</h2>
<?php if (!empty($news)): ?>
<table>
<thead>
@@ -24,5 +24,6 @@
<?php else: ?>
<p>Derzeit sind keine News verfügbar.</p>
<?php endif; ?>
<?php include dirname(__DIR__) . '/footer.phtml'; ?>
<?php
include dirname(__DIR__).'/footer.phtml';
?>

View File

@@ -1,7 +1,7 @@
<?php include dirname(__DIR__) . '/header.phtml'; ?>
<h2>Unsere Standorte</h2>
<?php
include dirname(__DIR__).'/header.phtml';
?>
<h2>Unsere Standorte</h2>
<?php if (!empty($standorte)): ?>
<table border="1" cellpadding="8" cellspacing="0">
<thead>
@@ -18,9 +18,9 @@
<tbody>
<?php foreach ($standorte as $standort): ?>
<tr>
<td><?php echo htmlspecialchars($standort['straße']); ?></td>
<td><?php echo htmlspecialchars($standort['strasse']); ?></td>
<td><?php echo htmlspecialchars($standort['hausnr']); ?></td>
<td><?php echo htmlspecialchars($standort['postleitzahl']); ?></td>
<td><?php echo htmlspecialchars($standort['plz']); ?></td>
<td><?php echo htmlspecialchars($standort['ort']); ?></td>
<td><?php echo htmlspecialchars($standort['land']); ?></td>
<td><?php echo htmlspecialchars($standort['tel']); ?></td>
@@ -32,5 +32,6 @@
<?php else: ?>
<p>Keine Standorte gefunden.</p>
<?php endif; ?>
<?php include dirname(__DIR__) . '/footer.phtml'; ?>
<?php
include dirname(__DIR__).'/footer.phtml';
?>

View File

@@ -7,6 +7,6 @@ include dirname(__DIR__).'/header.phtml';
<a href="?controller=Welcome&do=showWelcome">Weiter</a>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>
<?php
include dirname(__DIR__).'/footer.phtml';
?>

View File

@@ -1,8 +0,0 @@
<div class="inhalt">
<div class="tickets-container">
<h1>Tickets</h1>
<div class="tickets-container-inhalt">
</div>
</div>
</div>

View File

@@ -1,36 +1,20 @@
<!DOCTYPE html>
<html lang="HTML-5">
<html lang="de">
<head>
<title>VR Contact</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="CSS/style.css" rel="stylesheet" type="text/css" />
<link href="/bibarts/CSS/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<nav id="navigation">
<div class="link-container">
<div id="logo" ><a class="link-logo" href="#"></a></div>
<button id="nav-toggle-btn" aria-label="Menü ein-/ausklappen">&#9660;</button>
<div class="nav-links">
<a id="link-tickets" class="links" href="?controller=Tickets&do=showTickets">Tickets</a>
<div id="wrapper">
<nav id="navigation">
<div class="link-container">
<div id="logo" ><a class="link-logo" href="#"></a></div>
<a id="link-tickets" class="links" href="#">Tickets</a>
<a id="link-infos" class="links" href="?controller=Welcome&do=showWelcome">Infos</a>
<a id="link-profil" class="links" href="?controller=Profile&do=showProfile">Profil</a>
<a id="link-login" class="links" href="?controller=Login&do=showLoginPage">Login</a>
<a id="link-register" class="links" href="?controller=Register&do=showRegisterPage">Register</a>
<a id="link-profil" class="links" href="?controller=Contact&do=showContactForm">Profil</a>
<div id="profile-picture"></div>
</div>
</div>
</nav>
<script>
document.addEventListener('DOMContentLoaded', function() {
var btn = document.getElementById('nav-toggle-btn');
var links = document.querySelector('.nav-links');
if (btn && links) {
btn.addEventListener('click', function() {
links.classList.toggle('open');
btn.classList.toggle('open');
btn.innerHTML = links.classList.contains('open') ? '&#9650;' : '&#9660;';
});
}
});
</script>
</nav>
</div>

View File

@@ -1,19 +1,6 @@
-- 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 (
@@ -121,4 +108,37 @@ VALUES
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');
('Frühbucher-Rabatt', 'Sichern Sie sich jetzt 15% Rabatt auf unsere Sommerausstellung.', '2025-05-20');
--Änderungen:
ALTER TABLE austellung
ADD preis decimal NOT NULL
ALTER TABLE ticket
DROP COLUMN preis
ALTER TABLE user
MODIFY COLUMN userid INT NOT NULL AUTO_INCREMENT;
ALTER TABLE ticket
MODIFY COLUMN ticketid INT NOT NULL AUTO_INCREMENT;
ALTER TABLE standort
MODIFY COLUMN standortid INT NOT NULL AUTO_INCREMENT;
ALTER TABLE news
MODIFY COLUMN newsid INT NOT NULL AUTO_INCREMENT;
ALTER TABLE gutschein
MODIFY COLUMN gutscheinid INT NOT NULL AUTO_INCREMENT;
ALTER TABLE ausstellung
MODIFY COLUMN austellungid INT NOT NULL AUTO_INCREMENT;
ALTER TABLE user
MODIFY COLUMN isAdmin BOOLEAN DEFAULT FALSE;
ALTER TABLE user
ADD validUntil DATETIME NOT NULL DEFAULT '3025-01-01 00:00:00';

View File

@@ -1,50 +1,45 @@
<?php
session_start();
include 'Views/header.phtml';
?>
<div id="wrapper">
<?php
spl_autoload_register(function ($className) {
if (substr($className, 0, 5) !== 'Blog\\') {
// not our business
return;
}
<?php
$fileName = __DIR__.'/'.str_replace('\\', DIRECTORY_SEPARATOR, substr($className, 5)).'.php';
session_start();;;
if (file_exists($fileName)) {
include $fileName;
}
});
$controllerName = "";
$doMethodName = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$controllerName = isset($_POST['controller']) && $_POST['controller'] ? $_POST['controller'] : "Welcome";
$doMethodName = isset($_POST['do']) && $_POST['do'] ? $_POST['do'] : "showWelcome";
} else {
$controllerName = isset($_GET['controller']) && $_GET['controller'] ? $_GET['controller'] : "Welcome";
$doMethodName = isset($_GET['do']) && $_GET['do'] ? $_GET['do'] : "showWelcome";
}
spl_autoload_register(function ($className) {
if (substr($className, 0, 5) !== 'Blog\\') {
// not our business
return;
}
$controllerClassName = 'Blog\\Controller\\'.ucfirst($controllerName).'Controller';
$fileName = __DIR__.'/'.str_replace('\\', DIRECTORY_SEPARATOR, substr($className, 5)).'.php';
if (method_exists($controllerClassName, $doMethodName)) {
$view = new \Blog\Library\View(__DIR__.DIRECTORY_SEPARATOR.'Views'
, ucfirst($controllerName), $doMethodName);
$controller = new $controllerClassName($view);
$controller->$doMethodName();
if (file_exists($fileName)) {
include $fileName;
}
});
$controllerName = "";
$doMethodName = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$controllerName = isset($_POST['controller']) && $_POST['controller'] ? $_POST['controller'] : "Welcome";
$doMethodName = isset($_POST['do']) && $_POST['do'] ? $_POST['do'] : "showWelcome";
} else {
$controllerName = isset($_GET['controller']) && $_GET['controller'] ? $_GET['controller'] : "Welcome";
$doMethodName = isset($_GET['do']) && $_GET['do'] ? $_GET['do'] : "showWelcome";
}
$view->render();
$controllerClassName = 'Blog\\Controller\\'.ucfirst($controllerName).'Controller';
} else {
new \Blog\Library\ErrorMsg('Page not found: '.$controllerClassName.'::'.$doMethodName);
}
?>
</div>
<?php
include 'Views/footer.phtml';
if (method_exists($controllerClassName, $doMethodName)) {
$view = new \Blog\Library\View(__DIR__.DIRECTORY_SEPARATOR.'Views'
, ucfirst($controllerName), $doMethodName);
$controller = new $controllerClassName($view);
$controller->$doMethodName();
$view->render();
} else {
new \Blog\Library\ErrorMsg('Page not found: '.$controllerClassName.'::'.$doMethodName);
}
?>