From c380ae1b0b75a326f084edc7f47d1139c677b810 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 8 Mar 2011 19:38:31 +0100 Subject: ansehnlichere oberfläche && Controller auflistung --- application/controllers/AuthController.php | 180 +++++++++++++++-------------- application/layouts/main.phtml | 32 ++++- 2 files changed, 121 insertions(+), 91 deletions(-) (limited to 'application') diff --git a/application/controllers/AuthController.php b/application/controllers/AuthController.php index fd30d82..c43e5a9 100644 --- a/application/controllers/AuthController.php +++ b/application/controllers/AuthController.php @@ -5,82 +5,86 @@ class AuthController extends Zend_Controller_Action public function init() { - $db = Zend_Db_Table::getDefaultAdapter(); - + $db = Zend_Db_Table::getDefaultAdapter(); } - + + public function indexAction() + { + $this->_redirect('/auth/login'); + } + public function loginAction() - { - if (!isset($_POST["login"])){ - $loginForm = new Application_Form_AuthLogin(); - } else { - $loginForm = new Application_Form_AuthLogin($_POST); - - if ($loginForm->isValid($_POST)) { - - $auth = Zend_Auth::getInstance(); - - $adapter = new Zend_Auth_Adapter_DbTable( - $db, - 'pbs_person', - 'email', - 'password', - 'MD5(CONCAT(?, password_salt))' - ); - - - $adapter->setIdentity($loginForm->getValue('email')); - $adapter->setCredential($loginForm->getValue('password')); - - $result = $auth->authenticate($adapter); - - // TODO: erweiterte fehlerbeschreibung des Users - - if ($result->isValid()) { - $this->_redirect('/'); - return; - } else { - echo "Falsche Email oder Passwort"; - } - } - } - - $this->view->loginForm = $loginForm; + { + if (!isset($_POST["login"])){ + $loginForm = new Application_Form_AuthLogin(); + } else { + $loginForm = new Application_Form_AuthLogin($_POST); + + if ($loginForm->isValid($_POST)) { + + $auth = Zend_Auth::getInstance(); + + $adapter = new Zend_Auth_Adapter_DbTable( + $db, + 'pbs_person', + 'email', + 'password', + 'MD5(CONCAT(?, password_salt))' + ); + + + $adapter->setIdentity($loginForm->getValue('email')); + $adapter->setCredential($loginForm->getValue('password')); + + $result = $auth->authenticate($adapter); + + // TODO: erweiterte fehlerbeschreibung des Users + + if ($result->isValid()) { + $this->_redirect('/'); + return; + } else { + echo "Falsche Email oder Passwort"; + } + } + } + + $this->view->loginForm = $loginForm; } public function registerAction() - { - if (!isset($_POST["register"])){ - $registerForm = new Application_Form_AuthRegister(); - } else { - $registerForm = new Application_Form_AuthRegister($_POST); - - if ($registerForm->isValid($_POST)) { - - $person = new Application_Model_Person($_POST); - $personmapper = new Application_Model_PersonMapper(); - - $date = new DateTime(); - $person->setRegisterdate($date->getTimestamp()); - $person->setPasswordSalt(MD5($date->getTimestamp())); - $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); - - try { - $personmapper->save($person); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - echo "Email Adresse bereits vorhanden."; - return; - } - echo "Erfolgreich registriert.
"; - echo "Weiter zum Login: Login"; - return; - } - } - - $this->view->registerForm = $registerForm; + { + if (!isset($_POST["register"])){ + $registerForm = new Application_Form_AuthRegister(); + } else { + $registerForm = new Application_Form_AuthRegister($_POST); + + if ($registerForm->isValid($_POST)) { + + $person = new Application_Model_Person($_POST); + $personmapper = new Application_Model_PersonMapper(); + + $date = new DateTime(); + $person->setRegisterdate($date->getTimestamp()); + $person->setPasswordSalt(MD5($date->getTimestamp())); + $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); + + try { + $personmapper->save($person); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + echo "Email Adresse bereits vorhanden."; + return; + } + echo "Erfolgreich registriert.
"; + echo "Weiter zum Login: Login"; + return; + } + } + + $this->view->registerForm = $registerForm; } public function logoutAction() @@ -96,23 +100,23 @@ class AuthController extends Zend_Controller_Action public function deleteAction() { if (!isset($_POST["delete"])){ - $deleteForm = new Application_Form_AuthDelete(); - } else { - $deleteForm = new Application_Form_AuthDelete($_POST); - - if ($deleteForm->isValid($_POST)) { - - $person = new Application_Model_Person($_POST); - $personmapper = new Application_Model_PersonMapper(); - - - $personmapper->delete($person); - } - } - - $this->view->deleteForm = $deleteForm; - + $deleteForm = new Application_Form_AuthDelete(); + } else { + $deleteForm = new Application_Form_AuthDelete($_POST); + + if ($deleteForm->isValid($_POST)) { + + $person = new Application_Model_Person($_POST); + $personmapper = new Application_Model_PersonMapper(); + + + $personmapper->delete($person); + } + } + + $this->view->deleteForm = $deleteForm; } + } @@ -122,3 +126,5 @@ class AuthController extends Zend_Controller_Action + + diff --git a/application/layouts/main.phtml b/application/layouts/main.phtml index 51dd89c..80147b9 100644 --- a/application/layouts/main.phtml +++ b/application/layouts/main.phtml @@ -11,11 +11,35 @@ echo $this->headLink(); echo $this->headScript(); ?> - -layout()->content; ?> - +
+ +
+ layout()->content; ?> +
+
-- cgit v1.2.3-55-g7522