Merge branch 'frontendBackendFinal' of https://git.bib.de/PBBFA23CSE/Bib-Arts into frontendBackendFinal

This commit is contained in:
Max Schneider 2025-07-07 14:22:53 +02:00
commit ca757d1723
11 changed files with 97 additions and 66 deletions

View File

@ -47,17 +47,17 @@ class AuthController
$password = $_POST['password']; $password = $_POST['password'];
$result = $this->model->login($email, $password); $result = $this->model->login($email, $password);
if ($result === true) { if ($result === true) {
$_SESSION['user'] = $email; $_SESSION['user'] = $email;
header('Location: /bibarts/?controller=News&do=showNews'); $this->view->setDoMethodName('showLoginSuccess');
exit();
} else { } else {
$this->view->setVars([ $this->view->setVars([
'errors' => ['login' => is_string($result) ? $result : "Login fehlgeschlagen."], 'errors' => ['login' => is_string($result) ? $result : "Login fehlgeschlagen."],
'validData' => ['email' => $email], 'validData' => ['email' => $email],
'loginSuccess' => false 'loginSuccess' => false
]); ]);
$this->view->setDoMethodName('showLoginForm');
} }
} }
@ -87,7 +87,6 @@ class AuthController
$errors['register'] = is_string($result) ? $result : "Registrierung fehlgeschlagen."; $errors['register'] = is_string($result) ? $result : "Registrierung fehlgeschlagen.";
$this->view->setVars(['errors' => $errors, 'validData' => $data]); $this->view->setVars(['errors' => $errors, 'validData' => $data]);
$this->view->render('Auth/showRegistrationForm'); $this->view->render('Auth/showRegistrationForm');
exit;
} }
} }
@ -128,8 +127,7 @@ class AuthController
} }
} }
public function showConfirmation() public function showConfirmation() {
{
$messages = [ $messages = [
'login' => "Login erfolgreich.", 'login' => "Login erfolgreich.",
'register' => "Registrierung erfolgreich.", 'register' => "Registrierung erfolgreich.",
@ -145,7 +143,6 @@ class AuthController
public function logout() { public function logout() {
unset($_SESSION['user']); unset($_SESSION['user']);
session_destroy(); session_destroy();
header('Location: /bibarts/?controller=Auth&do=showLoginForm'); $this->view->setDoMethodName('showLogoutSuccess');
exit();
} }
} }

View File

@ -0,0 +1,15 @@
<div class="inhalt">
<div class="login-success">
<h2>Login erfolgreich!</h2>
<p>Sie werden in wenigen Sekunden zu den News weitergeleitet...</p>
</div>
</div>
<script>
setTimeout(function() {
window.location.href = "?controller=News&do=showNews";
}, 2000); // 2 Sekunden warten
</script>
<noscript>
<meta http-equiv="refresh" content="2;url=?controller=News&do=showNews">
</noscript>

View File

@ -0,0 +1,14 @@
<div class="inhalt">
<div class="login-success">
<h2>Logout erfolgreich!</h2>
<p>Sie werden in wenigen Sekunden zum Login weitergeleitet...</p>
</div>
</div>
<script>
setTimeout(function() {
window.location.href = "?controller=Auth&do=showLoginForm";
}, 2000); // 2 Sekunden warten
</script>
<noscript>
<meta http-equiv="refresh" content="2;url=?controller=Auth&do=showLoginForm">
</noscript>

View File

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

View File

@ -2,11 +2,11 @@
include dirname(__DIR__).'/header.phtml'; include dirname(__DIR__).'/header.phtml';
?> ?>
<div class="inhalt">
<div class="msg"> <div class="msg">
<p>Das Event mit der id"<?php echo $id?>" wurde erfolgreich gelöscht!</p> <p>Das Event mit der id"<?php echo $id?>" wurde erfolgreich gelöscht!</p>
<a href="?controller=Event&do=showEvents">Weiter</a> <a href="?controller=Event&do=showEvents">Weiter</a>
</div> </div>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?> <?php include dirname(__DIR__).'/footer.phtml'; ?>

View File

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

View File

@ -1,5 +1,6 @@
<?php include dirname(__DIR__) . '/header.phtml'; ?> <?php include dirname(__DIR__) . '/header.phtml'; ?>
<div class="inhalt">
<h2>Alle Gutscheine</h2> <h2>Alle Gutscheine</h2>
<a href="?controller=Gutschein&do=createGutscheinForm">Neuen Gutschein anlegen</a> <a href="?controller=Gutschein&do=createGutscheinForm">Neuen Gutschein anlegen</a>
<?php if (!empty($gutscheine)): ?> <?php if (!empty($gutscheine)): ?>
@ -17,9 +18,9 @@
<?php foreach ($gutscheine as $g): ?> <?php foreach ($gutscheine as $g): ?>
<tr> <tr>
<td><?php echo htmlspecialchars($g['code']); ?></td> <td><?php echo htmlspecialchars($g['code']); ?></td>
<td><?php echo (int)$g['rabatt']; ?></td> <td><?php echo (int)$g['discount']; ?></td>
<td><?php echo (int)$g['eventid']; ?></td> <td><?php echo (int)$g['event_id']; ?></td>
<td><?php echo htmlspecialchars($g['gültigkeit']); ?></td> <td><?php echo htmlspecialchars($g['valid_until']); ?></td>
<td> <td>
<a href="?controller=Gutschein&action=editGutscheinForm&id=<?php echo $g['gutscheinid']; ?>">Bearbeiten</a> | <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> <a href="?controller=Gutschein&action=deleteGutschein&id=<?php echo $g['gutscheinid']; ?>" onclick="return confirm('Wirklich löschen?');">Löschen</a>
@ -31,5 +32,5 @@
<?php else: ?> <?php else: ?>
<p>Keine Gutscheine vorhanden.</p> <p>Keine Gutscheine vorhanden.</p>
<?php endif; ?> <?php endif; ?>
</div>
<?php include dirname(__DIR__) . '/footer.phtml'; ?> <?php include dirname(__DIR__) . '/footer.phtml'; ?>

View File

@ -1,7 +1,6 @@
<?php if (!empty($news)): ?> <?php if (!empty($news)): ?>
<h2>Alle News</h2>
<table> <table>
<thead> <thead>
<tr> <tr>
@ -14,12 +13,14 @@
<?php foreach ($news as $item): ?> <?php foreach ($news as $item): ?>
<tr> <tr>
<td><?php echo htmlspecialchars($item['name']); ?></td> <td><?php echo htmlspecialchars($item['name']); ?></td>
<td><?php echo nl2br(htmlspecialchars($item['name'])); ?></td>
<td><?php echo nl2br(htmlspecialchars($item['description'])); ?></td> <td><?php echo nl2br(htmlspecialchars($item['description'])); ?></td>
<td><?php echo date('d.m.Y', strtotime($item['date'])); ?></td> <td><?php echo date('d.m.Y', strtotime($item['date'])); ?></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div>
<?php else: ?> <?php else: ?>
<p>Derzeit sind keine News verfügbar.</p> <p>Derzeit sind keine News verfügbar.</p>
<?php endif; ?> <?php endif; ?>

View File

@ -1,5 +1,6 @@
<?php include dirname(__DIR__) . '/header.phtml'; ?> <?php include dirname(__DIR__) . '/header.phtml'; ?>
<div class="inhalt">
<h2>Unsere Standorte</h2> <h2>Unsere Standorte</h2>
<?php if (!empty($standorte)): ?> <?php if (!empty($standorte)): ?>
@ -18,12 +19,12 @@
<tbody> <tbody>
<?php foreach ($standorte as $standort): ?> <?php foreach ($standorte as $standort): ?>
<tr> <tr>
<td><?php echo htmlspecialchars($standort['stre']); ?></td> <td><?php echo htmlspecialchars($standort['street']); ?></td>
<td><?php echo htmlspecialchars($standort['hausnr']); ?></td> <td><?php echo htmlspecialchars($standort['house_number']); ?></td>
<td><?php echo htmlspecialchars($standort['postleitzahl']); ?></td> <td><?php echo htmlspecialchars($standort['postal_code']); ?></td>
<td><?php echo htmlspecialchars($standort['ort']); ?></td> <td><?php echo htmlspecialchars($standort['city']); ?></td>
<td><?php echo htmlspecialchars($standort['land']); ?></td> <td><?php echo htmlspecialchars($standort['country']); ?></td>
<td><?php echo htmlspecialchars($standort['tel']); ?></td> <td><?php echo htmlspecialchars($standort['phone']); ?></td>
<td><?php echo htmlspecialchars($standort['email']); ?></td> <td><?php echo htmlspecialchars($standort['email']); ?></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
@ -32,5 +33,5 @@
<?php else: ?> <?php else: ?>
<p>Keine Standorte gefunden.</p> <p>Keine Standorte gefunden.</p>
<?php endif; ?> <?php endif; ?>
</div>
<?php include dirname(__DIR__) . '/footer.phtml'; ?> <?php include dirname(__DIR__) . '/footer.phtml'; ?>

View File

@ -15,7 +15,11 @@
<a id="link-tickets" class="links" href="?controller=Event&do=showEvents">Event</a> <a id="link-tickets" class="links" href="?controller=Event&do=showEvents">Event</a>
<a id="link-infos" class="links" href="?controller=News&do=showNews">Infos</a> <a id="link-infos" class="links" href="?controller=News&do=showNews">Infos</a>
<a id="link-profil" class="links" href="?controller=Profile&do=showProfile">Profil</a> <a id="link-profil" class="links" href="?controller=Profile&do=showProfile">Profil</a>
<a id="link-login" class="links" href="?controller=Auth&do=showLoginForm">Login</a> <?php if (isset($_SESSION['user'])): ?>
<a id="link-logout" class="links" href="?controller=Auth&do=logout">Logout</a>
<?php else: ?>
<a id="link-login" class="links" href="?controller=Auth&do=showLoginForm">Login</a>
<?php endif; ?>
<a id="link-register" class="links" href="?controller=Auth&do=showRegistrationForm">Register</a> <a id="link-register" class="links" href="?controller=Auth&do=showRegistrationForm">Register</a>
<div id="profile-picture"></div> <div id="profile-picture"></div>
</div> </div>

View File

@ -2,48 +2,46 @@
session_start(); session_start();
include 'Views/header.phtml'; include 'Views/header.phtml';
?> ?>
<div id="wrapper"> <?php
<?php spl_autoload_register(function ($className) {
spl_autoload_register(function ($className) { if (substr($className, 0, 5) !== 'Blog\\') {
if (substr($className, 0, 5) !== 'Blog\\') { // not our business
// not our business return;
return;
}
$fileName = __DIR__.'/'.str_replace('\\', DIRECTORY_SEPARATOR, substr($className, 5)).'.php';
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";
} }
$controllerClassName = 'Blog\\Controller\\'.ucfirst($controllerName).'Controller'; $fileName = __DIR__.'/'.str_replace('\\', DIRECTORY_SEPARATOR, substr($className, 5)).'.php';
if (method_exists($controllerClassName, $doMethodName)) { if (file_exists($fileName)) {
$view = new \Blog\Library\View(__DIR__.DIRECTORY_SEPARATOR.'Views' include $fileName;
, ucfirst($controllerName), $doMethodName);
$controller = new $controllerClassName($view);
$controller->$doMethodName();
$view->render();
} else {
new \Blog\Library\ErrorMsg('Page not found: '.$controllerClassName.'::'.$doMethodName);
} }
?> });
</div>
$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";
}
$controllerClassName = 'Blog\\Controller\\'.ucfirst($controllerName).'Controller';
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);
}
?>
<?php <?php
include 'Views/footer.phtml'; include 'Views/footer.phtml';
?> ?>