public function init()
 {
     parent::init();
     $helper = new vkNgine_View_Helper_PublicUrl();
     $this->view->registerHelper($helper, 'publicUrl');
     $helper = new vkNgine_View_Helper_Seo();
     $this->view->registerHelper($helper, 'seo');
     $helper = new vkNgine_View_Helper_AssetUrl();
     $this->view->registerHelper($helper, 'assetUrl');
     $helper = new vkNgine_View_Helper_Dateformat();
     $this->view->registerHelper($helper, 'dateFormat');
     $searchForm = new Public_Model_Form_Search();
     $this->view->searchForm = $searchForm;
     $view = Zend_Registry::get('view');
     $appTitle = Zend_Registry::get('t')->_('GYM Tracker');
     $view->headTitle($appTitle, Zend_View_Helper_Placeholder_Container_Abstract::SET);
     if (!vkNgine_Auth::isAuthenticated()) {
         header("location:/auth/login");
         exit;
     }
     $modelExercises = new Model_Exercises();
     $this->view->exercises = $modelExercises;
     $user = vkNgine_Public_Auth::revalidate();
     $this->view->params = $this->getAllParams();
     Zend_Registry::set('user', $user);
     $this->view->assign('user', $user);
     $this->user = Zend_Registry::get('user');
     $this->view->t = Zend_Registry::get('t');
     $this->t = Zend_Registry::get('t');
 }
 public function loginAction()
 {
     if (vkNgine_Auth::isAuthenticated()) {
         header("location:/");
         exit;
     }
     $logger = Zend_Registry::get('logger');
     $form = $this->getLoginForm();
     $request = $this->getRequest();
     $this->view->error = false;
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $info = $form->getValues();
             $user = null;
             if (vkNgine_Public_Auth::attemptLogin($info)) {
                 $user = vkNgine_Auth::revalidate();
             } else {
                 $this->view->error = true;
             }
             $user = vkNgine_Auth::revalidate();
             $logger->log('LOGIN_REQUEST', print_r($info, true), vkNgine_Log::INFO, $user['userId']);
             if ($user != null) {
                 $modelUsers = new Model_Users();
                 $modelTrafficActivity = new vkNgine_Log_Activity();
                 $modelTrafficLogins = new vkNgine_Log_Logins();
                 $modelTrafficActivity->processActivity($user, $request, 'Logged in to Site');
                 $modelTrafficLogins->insertTrafficLogin($user->userId, $user->type);
                 $config = vkNgine_Config::getSystemConfig();
                 Zend_Session::rememberMe($config->settings->login->remember);
                 $modelUsers->update($user['userId'], array('lastLogin' => date('Y-m-d H:i:s')));
                 echo Zend_Json::encode(array('success' => 1, 'icon' => 'success', 'href' => '/'));
                 exit;
             } else {
                 echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Access denied!'), 'icon' => 'error'));
                 exit;
             }
         } else {
             echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Access denied!'), 'icon' => 'error'));
             exit;
         }
     }
     $this->view->form = $form;
 }
 public function init()
 {
     $helper = new vkNgine_View_Helper_AdminUrl();
     $this->view->registerHelper($helper, 'adminUrl');
     $helper = new vkNgine_View_Helper_Dateformat();
     $this->view->registerHelper($helper, 'dateFormat');
     $helper = new vkNgine_View_Helper_FormDate();
     $this->view->registerHelper($helper, 'formDate');
     $helper = new vkNgine_View_Helper_Phoneformat();
     $this->view->registerHelper($helper, 'phoneFormat');
     $helper = new vkNgine_View_Helper_Breadcrumb();
     $this->view->registerHelper($helper, 'breadcrumb');
     $helper = new vkNgine_View_Helper_Plural();
     $this->view->registerHelper($helper, 'plural');
     $view = Zend_Registry::get('view');
     $vkNgineVersion = vkNgine_Version::VERSION;
     $appTitle = sprintf(Zend_Registry::get('t')->_('%s Administrator Control Panel'), 'vkNgine' . $vkNgineVersion[0]);
     $this->view->appTitle = $appTitle;
     $view->headTitle($appTitle, Zend_View_Helper_Placeholder_Container_Abstract::SET);
     if (!vkNgine_Auth::isAuthenticated()) {
         $this->_redirect('/admin/auth/login');
         exit;
     }
     $user = vkNgine_Admin_Auth::revalidate();
     if (!$user) {
         $this->_redirect('/admin/auth/login');
         exit;
     }
     Zend_Registry::set('user', $user);
     $this->view->assign('user', $user);
     $this->user = Zend_Registry::get('user');
     $this->config = vkNgine_Config::getSystemConfig();
     $modelTrafficLogins = new vkNgine_Log_Logins();
     $lastLoggedInInfo = $modelTrafficLogins->fetchLastLoggedInInfo($this->user);
     $this->view->assign('lastLoggedInInfo', $lastLoggedInInfo);
     $this->view->action = array('controller' => $this->_request->controller, 'action' => $this->_request->action);
     $acl = new vkNgine_Admin_Acl();
     $this->acl = $acl;
     Zend_Registry::set('acl', $acl);
     $this->view->t = Zend_Registry::get('t');
     $this->t = Zend_Registry::get('t');
     parent::init();
 }
 public function resetpasswordAction()
 {
     if (vkNgine_Auth::isAuthenticated()) {
         $this->_redirect('/admin');
         exit;
     }
     $modelUsers = new Model_Users();
     $modelUsersTokens = new Model_Users_Tokens();
     $token = $this->_getParam('token');
     if (!$token) {
         $this->_redirect('/admin/auth/login');
     }
     $form = self::getResetPasswordForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post = $request->getPost();
         if ($form->isValid($post)) {
             $values = $form->getValues();
             $user = $modelUsers->fetchWithEmail($values['email']);
             $token = $modelUsersTokens->fetch($user, $values['token']);
             if ($token) {
                 $data = array('password' => $values['password']);
                 $modelUsers->update($user->getId(), $data);
                 $modelUsersTokens->delete($token['tokenId']);
                 echo Zend_Json::encode(array('success' => 1, 'title' => $this->t->_('Success Message'), 'message' => $this->t->_('Password was changed successfully'), 'icon' => 'success', 'href' => '/admin/auth/login'));
                 exit;
             } else {
                 echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Given token was not valid'), 'icon' => 'error'));
                 exit;
             }
         } else {
             echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Given token/email or password was not valid'), 'icon' => 'error'));
             exit;
         }
     }
     $this->view->form = $form->setTokenValue($token);
 }