diff --git a/Controller/AuthController.php b/Controller/AuthController.php index b8808e8..79dab84 100644 --- a/Controller/AuthController.php +++ b/Controller/AuthController.php @@ -47,17 +47,17 @@ class AuthController $password = $_POST['password']; $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->setDoMethodName('showLoginSuccess'); } else { $this->view->setVars([ 'errors' => ['login' => is_string($result) ? $result : "Login fehlgeschlagen."], 'validData' => ['email' => $email], 'loginSuccess' => false ]); + $this->view->setDoMethodName('showLoginForm'); } } @@ -87,7 +87,6 @@ class AuthController $errors['register'] = is_string($result) ? $result : "Registrierung fehlgeschlagen."; $this->view->setVars(['errors' => $errors, 'validData' => $data]); $this->view->render('Auth/showRegistrationForm'); - exit; } } @@ -128,8 +127,7 @@ class AuthController } } - public function showConfirmation() - { + public function showConfirmation() { $messages = [ 'login' => "Login erfolgreich.", 'register' => "Registrierung erfolgreich.", @@ -145,7 +143,6 @@ class AuthController public function logout() { unset($_SESSION['user']); session_destroy(); - header('Location: /bibarts/?controller=Auth&do=showLoginForm'); - exit(); + $this->view->setDoMethodName('showLogoutSuccess'); } } \ No newline at end of file diff --git a/Views/Auth/showLoginSuccess.phtml b/Views/Auth/showLoginSuccess.phtml new file mode 100644 index 0000000..459c67e --- /dev/null +++ b/Views/Auth/showLoginSuccess.phtml @@ -0,0 +1,15 @@ +
+
+

Login erfolgreich!

+

Sie werden in wenigen Sekunden zu den News weitergeleitet...

+
+
+ + + diff --git a/Views/Auth/showLogoutSuccess.phtml b/Views/Auth/showLogoutSuccess.phtml new file mode 100644 index 0000000..0dc4a56 --- /dev/null +++ b/Views/Auth/showLogoutSuccess.phtml @@ -0,0 +1,14 @@ +
+
+

Logout erfolgreich!

+

Sie werden in wenigen Sekunden zum Login weitergeleitet...

+
+
+ + \ No newline at end of file diff --git a/Views/Event/createEvent.phtml b/Views/Event/createEvent.phtml index b0376d4..185470e 100644 --- a/Views/Event/createEvent.phtml +++ b/Views/Event/createEvent.phtml @@ -2,11 +2,11 @@ include dirname(__DIR__).'/header.phtml'; ?> +

Das Event "" wurde erfolgreich erstellt!

Weiter
- - +
\ No newline at end of file diff --git a/Views/Event/deleteEvent.phtml b/Views/Event/deleteEvent.phtml index 4a7ce55..05e6e6e 100644 --- a/Views/Event/deleteEvent.phtml +++ b/Views/Event/deleteEvent.phtml @@ -2,11 +2,11 @@ include dirname(__DIR__).'/header.phtml'; ?> +

Das Event mit der id"" wurde erfolgreich gelöscht!

Weiter
- - +
\ No newline at end of file diff --git a/Views/Event/showEvents.phtml b/Views/Event/showEvents.phtml index 58806b9..16ed989 100644 --- a/Views/Event/showEvents.phtml +++ b/Views/Event/showEvents.phtml @@ -1,6 +1,3 @@ - - -
diff --git a/Views/Event/updateEvent.phtml b/Views/Event/updateEvent.phtml index 32c1acf..e4cd61c 100644 --- a/Views/Event/updateEvent.phtml +++ b/Views/Event/updateEvent.phtml @@ -2,11 +2,11 @@ include dirname(__DIR__).'/header.phtml'; ?> +

Das Event mit der ID "" wurde erfolgreich bearbeitet!

Weiter
- - +
\ No newline at end of file diff --git a/Views/Gutschein/showGutscheine.phtml b/Views/Gutschein/showGutscheine.phtml index 6824976..a5566e9 100644 --- a/Views/Gutschein/showGutscheine.phtml +++ b/Views/Gutschein/showGutscheine.phtml @@ -1,5 +1,6 @@ +

Alle Gutscheine

Neuen Gutschein anlegen @@ -17,9 +18,9 @@ - - - + + + Bearbeiten | Löschen @@ -31,5 +32,5 @@

Keine Gutscheine vorhanden.

- +
\ No newline at end of file diff --git a/Views/News/showNews.phtml b/Views/News/showNews.phtml index 5f71b89..21ade6f 100644 --- a/Views/News/showNews.phtml +++ b/Views/News/showNews.phtml @@ -1,8 +1,7 @@ - - -

Alle News

+
+ @@ -15,14 +14,14 @@ - - + + +
+

Derzeit sind keine News verfügbar.

- - - \ No newline at end of file + \ No newline at end of file diff --git a/Views/Standort/showStandorte.phtml b/Views/Standort/showStandorte.phtml index 3ac6cdb..3122c7f 100644 --- a/Views/Standort/showStandorte.phtml +++ b/Views/Standort/showStandorte.phtml @@ -1,5 +1,6 @@ +

Unsere Standorte

@@ -18,12 +19,12 @@ - - - - - - + + + + + + @@ -32,5 +33,5 @@

Keine Standorte gefunden.

- +
\ No newline at end of file diff --git a/Views/header.phtml b/Views/header.phtml index 53a1f41..bff0852 100644 --- a/Views/header.phtml +++ b/Views/header.phtml @@ -15,7 +15,15 @@ Event Infos Profil - Login + +
+ + + +
+ + Login + Register
diff --git a/index.php b/index.php index abae14c..0d7b5c3 100644 --- a/index.php +++ b/index.php @@ -2,48 +2,46 @@ session_start(); include 'Views/header.phtml'; ?> -
- $doMethodName(); - - $view->render(); - - } else { - new \Blog\Library\ErrorMsg('Page not found: '.$controllerClassName.'::'.$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"; + } + + $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); + } + ?>