/application/modules/default/controllers/IndexController.php
https://bitbucket.org/darang/utm5cabinet_009 · PHP · 74 lines · 52 code · 14 blank · 8 comment · 8 complexity · d6e2a8cddbf7fd09cddd1f4c770031e5 MD5 · raw file
- <?php
- /**
- * @author Siomkin Alexandr <mail@mg7.by>
- * @link http://www.jext.biz/
- * @copyright Copyright © 2011-2012
- * @license GNU General Public License, version 2:
- * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
- */
- class Default_IndexController extends Zend_Controller_Action
- {
- public function init()
- {
- $this->config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/billing.ini', 'app');
- }
- public function indexAction()
- {
- $this->view->title = "";
- $this->view->headTitle($this->view->title, 'PREPEND');
- $uri = $this->_getParam('return_uri','/user/');
- if ($this->view->identity != FALSE) {
- $this->redirect('/user/');
- }
- $form = new Default_Form_Login();
- if ($this->getRequest()->isPost()) {
- if ($form->isValid($this->getRequest()->getPost())) {
- $auth = Zend_Auth::getInstance();
- $authAdapter = new Urfa_Auth_Adapter($form->getValue('username'), $form->getValue('password'));
- $result = $auth->authenticate($authAdapter);
- if ($result->isValid()) {
- // Yay! User is authenticated and stored in the session (via the storage class)
- $this->redirect($uri);
- } else {
- $this->_helper->flashMessenger->addMessage(
- array('error' => '?????? ???????????. ?? ?????? ???? ?????-??????')
- );
- $this->redirect('/');
- }
- }
- }
- $this->view->form = $form;
- if(!empty($this->config->notice)){
- $this->view->notice = $this->config->notice;
- }
- }
- public function logoutAction()
- {
- if (!$this->view->identity) {
- $this->_helper->flashMessenger->addMessage(
- array('error' => '??? ?????????? ??????????????')
- );
- $this->redirect('/');
- }
- $_auth = Zend_Auth::getInstance();
- $_auth->clearIdentity();
- $this->_helper->flashMessenger->addMessage(
- array('success' => '?? ????????')
- );
- $this->redirect('/');
- }
- }