From b8a19e453e9fc812636ea654af8a06712328e324 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 11 Aug 2009 14:57:45 +0200 Subject: [PATCH] +added netbeans working directory Modified .gitignore *corrections in EOL/EOF Modified application/bootstrap.php Modified application/layouts/scripts/layout.phtml Modified public/.htaccess *correct tabbing Modified application/controllers/IndexController.php *opravena chyba s moznostou prihlasenia sa uzivatela s nespravnym heslom Modified application/controllers/UserController.php -unused file Deleted application/layouts/scripts/top_menu.phtml --- .gitignore | 1 + application/controllers/IndexController.php | 4 +- application/controllers/UserController.php | 402 ++++++++++++++-------------- application/layouts/scripts/top_menu.phtml | 8 - 4 files changed, 207 insertions(+), 208 deletions(-) rewrite application/controllers/UserController.php (80%) delete mode 100644 application/layouts/scripts/top_menu.phtml diff --git a/.gitignore b/.gitignore index a7e83c3..6754ad9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ .settings .buildpath commit_message +nbproject/* \ No newline at end of file diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index d4979a2..b4c6f7f 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -7,8 +7,8 @@ require_once APPLICATION_PATH.'/models/PlayerList.php'; class IndexController extends Zend_Controller_Action { - const PLAYER_ID = 'player_id'; - protected $_model; + const PLAYER_ID = 'player_id'; + protected $_model; public function indexAction() { diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php dissimilarity index 80% index 07499d4..54d06db 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/UserController.php @@ -1,198 +1,204 @@ -_form = $this->_getLoginForm(); - $this->view->form = $this->_form; - $this->render('loginform'); - #$this->_forward('login'); - } - - public function loginAction() - { - if (null == $this->_form) { - $this->_form = $this->_getLoginForm(); - } - - if (!$this->getRequest()->isPost()) { - #$this->view->form = $this->_form; - #return $this->render('loginform'); - return $this->_forward('index'); - } - - if (!$this->_form->isValid($_POST)) { - // Failed validation; redisplay form - $this->view->form = $this->_form; - return $this->forward('index'); - } - - $auth_result = $this->_authUser(); - } - - public function logoutAction() - { - Zend_Auth::getInstance()->clearIdentity(); - } - - public function registerAction() - { - - if (null === $this->_form) { - $this->_form = $this->_getRegistrationForm(); - } - - if (!$this->getRequest()->isPost()) { - $this->view->form = $this->_form; - return $this->render('registerform'); - #return $this->_forward('index'); - } - - - if (!$this->_form->isValid($_POST)) { - // Failed validation; redisplay form - $this->view->form = $this->_form; - return $this->render('registerform'); - } - - $this->_registerNewUser(); - return $this->render('thx4reg'); - } - - public function thx4regAction() - { - - } - - protected function _getLoginForm() - { - $form = new Zend_Form(); - $form->setAction($this->_helper->url('login')) - ->setMethod('post'); - // Create and configure username element: - $username = $form->createElement('text', 'username'); - $username->setLabel('Login'); - $username->addValidator('alnum') - ->addValidator('regex', false, array('/^[a-z]+/')) - ->addValidator('stringLength', false, array(5, 20)) - ->setRequired(true) - ->addFilter('StringToLower'); - // Create and configure password element: - $password = $form->createElement('password', 'password'); - $password->setLabel('Heslo'); - $password->addValidator('StringLength', false, array(6)) - ->setRequired(true); - // Add elements to form: - $form->addElement($username) - ->addElement($password) - ->addElement('submit', 'login', array('label' => 'Login')); - return $form; - } - - protected function _authUser() - { - $dbAdapter = Zend_Registry::get('dbAdapter'); - - $auth = Zend_Auth::getInstance(); - $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter); - $authAdapter->setTableName('player') - ->setIdentityColumn('login') - ->setCredentialColumn('passwd'); - - $authAdapter->setIdentity($this->_form->getValue('username')); - $authAdapter->setCredential($this->_form->getValue('password')); - - $result = $auth->authenticate($authAdapter); - - $storage = $auth->getStorage(); - $storage->write($authAdapter->getResultRowObject(null, 'passwd')); - - return $result; - } - - protected function _getRegistrationForm() - { - $form = new Zend_Form(); - $form->setAction($this->_helper->url('register')) - ->setMethod('post'); - - // Create and configure username element: - $username = $form->createElement('text', 'login'); - $username->setLabel('Login'); - $username->addValidator('alnum') - ->addValidator('regex', false, array('/^[a-z]+/')) - ->addValidator('stringLength', false, array(5, 20)) - ->setRequired(true) - ->addFilter('StringToLower'); - - // Create and configure password element: - $password = $form->createElement('password', 'passwd'); - $password->setLabel('Heslo'); - $password->addValidator('StringLength', false, array(6)) - ->setRequired(true); - - // Create and configure email element: - $email = $form->createElement('text', 'email'); - $email->setLabel('Email'); - $email->setRequired(true) - ->addValidator('EmailAddress', false); - - // Create and configure phone number element: - $gsm = $form->createElement('text', 'gsm'); - $gsm->setLabel('Tel.'); - $gsm->addValidator('alnum') - ->setRequired(false); - - // Add elements to form: - $form->addElement($username) - ->addElement($password) - ->addElement($email) - ->addElement($gsm) - ->addElement('submit', 'register', array('label' => 'Register')); - - return $form; - } - - protected function _registerNewUser() - { - #$this->render('thx4reg'); - //@todo overit ci dany uzivatel uz nahodou neexistuje - //ulozit udaje uzivatela do db - $table = $this->_getTable(); - $new_player_id = $table->insert($this->_form->getValues()); - - $this->_model = new Player($new_player_id); - //po uspesnom ulozeni mu to oznamit: - // - mailom @todo oznamenie mailom - // - vypisom na stranke - #return $this->_helper->redirector('thx4reg'); - } - - protected function _getTable() - { - if (null === $this->_table) { - $this->_table = new Model_DbTable_Player(); - } - - return $this->_table; - } - - protected function _getModel() - { - if (null === $this->_model) { - $this->_model = new Player($player_id); - } - - return $this->_model; - } -} - - +_form = $this->_getLoginForm(); + $this->view->form = $this->_form; + $this->render('loginform'); + #$this->_forward('login'); + } + + public function loginAction() + { + if (null == $this->_form) { + $this->_form = $this->_getLoginForm(); + } + + //ak nebolo nic odoslane cez post tak sa vrat na index + if (!$this->getRequest()->isPost()) { + #$this->view->form = $this->_form; + #return $this->render('loginform'); + return $this->_forward('index'); + } + + if (!$this->_form->isValid($_POST) || + !$this->_authUser()->isValid()) { + // Failed validation; redisplay form + $this->view->form = $this->_form; + $this->_forward('index'); + } + else { + $this->_redirect('index'); + } + + + } + + public function logoutAction() + { + Zend_Auth::getInstance()->clearIdentity(); + } + + public function registerAction() + { + if (null === $this->_form) { + $this->_form = $this->_getRegistrationForm(); + } + + if (!$this->getRequest()->isPost()) { + $this->view->form = $this->_form; + return $this->render('registerform'); + #return $this->_forward('index'); + } + + + if (!$this->_form->isValid($_POST)) { + // Failed validation; redisplay form + $this->view->form = $this->_form; + return $this->render('registerform'); + } + + $this->_registerNewUser(); + return $this->render('thx4reg'); + } + + public function thx4regAction() + { + + } + + protected function _getLoginForm() + { + $form = new Zend_Form(); + $form->setAction($this->_helper->url('login')) + ->setMethod('post'); + // Create and configure username element: + $username = $form->createElement('text', 'username'); + $username->setLabel('Login'); + $username->addValidator('alnum') + ->addValidator('regex', false, array('/^[a-z]+/')) + ->addValidator('stringLength', false, array(5, 20)) + ->setRequired(true) + ->addFilter('StringToLower'); + // Create and configure password element: + $password = $form->createElement('password', 'password'); + $password->setLabel('Heslo'); + $password->addValidator('StringLength', false, array(6)) + ->setRequired(true); + // Add elements to form: + $form->addElement($username) + ->addElement($password) + ->addElement('submit', 'login', array('label' => 'Login')); + return $form; + } + + protected function _authUser() + { + $dbAdapter = Zend_Registry::get('dbAdapter'); + + $auth = Zend_Auth::getInstance(); + $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter); + $authAdapter->setTableName('player') + ->setIdentityColumn('login') + ->setCredentialColumn('passwd'); + + $authAdapter->setIdentity($this->_form->getValue('username')); + $authAdapter->setCredential($this->_form->getValue('password')); + + $result = $auth->authenticate($authAdapter); + + if ($result->isValid()) { + $storage = $auth->getStorage(); + $storage->write($authAdapter->getResultRowObject(null, 'passwd')); + } + + return $result; + } + + protected function _getRegistrationForm() + { + $form = new Zend_Form(); + $form->setAction($this->_helper->url('register')) + ->setMethod('post'); + + // Create and configure username element: + $username = $form->createElement('text', 'login'); + $username->setLabel('Login'); + $username->addValidator('alnum') + ->addValidator('regex', false, array('/^[a-z]+/')) + ->addValidator('stringLength', false, array(5, 20)) + ->setRequired(true) + ->addFilter('StringToLower'); + + // Create and configure password element: + $password = $form->createElement('password', 'passwd'); + $password->setLabel('Heslo'); + $password->addValidator('StringLength', false, array(6)) + ->setRequired(true); + + // Create and configure email element: + $email = $form->createElement('text', 'email'); + $email->setLabel('Email'); + $email->setRequired(true) + ->addValidator('EmailAddress', false); + + // Create and configure phone number element: + $gsm = $form->createElement('text', 'gsm'); + $gsm->setLabel('Tel.'); + $gsm->addValidator('alnum') + ->setRequired(false); + + // Add elements to form: + $form->addElement($username) + ->addElement($password) + ->addElement($email) + ->addElement($gsm) + ->addElement('submit', 'register', array('label' => 'Register')); + + return $form; + } + + protected function _registerNewUser() + { + #$this->render('thx4reg'); + //@todo overit ci dany uzivatel uz nahodou neexistuje + //ulozit udaje uzivatela do db + $table = $this->_getTable(); + $new_player_id = $table->insert($this->_form->getValues()); + + $this->_model = new Player($new_player_id); + //po uspesnom ulozeni mu to oznamit: + // - mailom @todo oznamenie mailom + // - vypisom na stranke + #return $this->_helper->redirector('thx4reg'); + } + + protected function _getTable() + { + if (null === $this->_table) { + $this->_table = new Model_DbTable_Player(); + } + + return $this->_table; + } + + protected function _getModel() + { + if (null === $this->_model) { + $this->_model = new Player($player_id); + } + + return $this->_model; + } +} + + diff --git a/application/layouts/scripts/top_menu.phtml b/application/layouts/scripts/top_menu.phtml deleted file mode 100644 index fa63a8b..0000000 --- a/application/layouts/scripts/top_menu.phtml +++ /dev/null @@ -1,8 +0,0 @@ -headLink() - ->appendStylesheet('/css/top_menu.css');?> - -- 2.11.4.GIT