Example #1
0
 public function init()
 {
     //set timeout
     $this->_sessionAdmin = new Zend_Session_Namespace(Zend_Auth_Storage_Session::NAMESPACE_DEFAULT);
     $this->_sessionAdmin->setExpirationSeconds(30 * 60);
     //load acl
     $aclLoader = HCMS_Acl_Loader::getInstance();
     $aclLoader->load();
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         $this->_admin = null;
     } else {
         $this->_admin = Zend_Auth::getInstance()->getIdentity();
         $aclLoader->setCurrentRoleCode($aclLoader->getRoleCode($this->_admin->get_role_id()));
     }
     $this->view->admin = $this->_admin;
     if ($this->_checkAuth) {
         $this->_checkAuthorization();
     }
     $this->_redirect_to_ssl();
     $this->_checkIP();
     //set ACL object for Zend_Navigation
     Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($aclLoader->getAcl());
     Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($aclLoader->getCurrentRoleCode());
     $this->_initVersionInfo();
     $this->_module = new Application_Model_Module();
     if (Application_Model_ModuleMapper::getInstance()->findByCode($this->getRequest()->getModuleName(), $this->_module)) {
         $this->view->moduleSettings = $this->_module->get_settings();
     }
     parent::init();
 }
Example #2
0
 /**
  * Constructor, set optionnaly custom expiration seconds
  * 
  * @param int $expirationSeconds
  * @return void
  */
 public function __construct($namespace = 'Zfx_Registry_Session', $expirationSeconds = 1800)
 {
     self::$_namespace = $namespace;
     self::$_session = new Zend_Session_Namespace($namespace);
     self::$_session->setExpirationSeconds($expirationSeconds);
     self::$_session->lock();
 }
Example #3
0
 /**
  * Constructor
  *
  * @param string $sessionId
  */
 public function __construct($sessionId)
 {
     // session storage
     $this->_session = new \Zend_Session_Namespace(__CLASS__ . $sessionId);
     $this->_session->setExpirationSeconds($this->_expiration);
     // 3 hours
 }
Example #4
0
 public function _initSession()
 {
     Zend_Session::start();
     $defaultNameSpace = new Zend_Session_Namespace("defaultsession");
     $defaultNameSpace->setExpirationSeconds(7200);
     Zend_Registry::set("defaultsession", $defaultNameSpace);
 }
Example #5
0
 public function loginAction()
 {
     try {
         $this->_helper->layout->disableLayout();
         $request = $this->getRequest();
         $sessionNamespace = new Zend_Session_Namespace();
         if ($sessionNamespace->loginAuth == true) {
             $this->_helper->redirector('index', 'index', 'gyuser');
         }
         if ($this->getRequest()->isPost()) {
             $mapper = new Gyuser_Model_OperatorDataMapper();
             $Obj = new Gyuser_Model_Operator();
             if ($request->user_name) {
                 $Obj->setEmail($request->user_name);
             }
             if ($request->password) {
                 $Obj->setPassword($request->password);
             }
             $result = $mapper->LoginAuth($Obj);
             if ($result->getId()) {
                 $sessionNamespace = new Zend_Session_Namespace();
                 $sessionNamespace->loginAuth = true;
                 $sessionNamespace->authDetail = $result;
                 $sessionNamespace->setExpirationSeconds(7 * 24 * 60 * 60, 'a');
                 $this->_helper->redirector('dashboard', 'index', 'gyuser');
             } else {
                 $this->view->invalid = true;
             }
         }
     } catch (Exception $e) {
         echo $e;
     }
 }
Example #6
0
 public function logarAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout()->disableLayout();
     $resposta = array();
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
     $authAdapter->setTableName('sca_usuario')->setIdentityColumn('login_usuario')->setCredentialColumn('password_usuario')->getDbSelect()->join(array('g' => 'sca_grupo'), 'g.id_grupo = sca_usuario.id_grupo', array('nm_grupo', 'is_root'));
     $authAdapter->setIdentity($this->getRequest()->getParam('login_usuario'))->setCredential($this->getRequest()->getParam('password_usuario'))->setCredentialTreatment('MD5(?) and st_usuario = 1');
     //Realiza autenticacao
     $result = $authAdapter->authenticate();
     //Verifica se a autenticacao foi validada
     if ($result->isValid()) {
         //obtem os dados do usuario
         $usuario = $authAdapter->getResultRowObject();
         //Armazena seus dados na sessao
         $storage = Zend_Auth::getInstance()->getStorage();
         $storage->write($usuario);
         // se não for para lembrar os dados expira a sessao em 30 minutos
         if (!$this->getRequest()->getParam('lembrar')) {
             $session = new Zend_Session_Namespace('Zend_Auth');
             $session->setExpirationSeconds(1800);
         }
         //Redireciona para o Index
         $resposta['situacao'] = "success";
         $resposta['msg'] = "Logando aguarde...";
     } else {
         $resposta['situacao'] = "error";
         $resposta['msg'] = "Usuário inativo ou senha incorreta.";
     }
     echo json_encode($resposta);
 }
 public function loginAction()
 {
     if (!$this->getRequest()->isPost()) {
         return $this->_forward('index');
     }
     $form = $this->getForm();
     if (!$form->isValid($_POST)) {
         // Falla la validación; Se vuelve a mostrar el formulario
         $this->view->form = $form;
         return $this->render('form');
     }
     $username = $form->getValue('username');
     $password = $form->getValue('password');
     $remember = $form->getValue('remember');
     $usuario = new Application_Model_Usuario();
     $result = $usuario->validarLogin($username, $password);
     if (!$result->isValid()) {
         // Autenticación fallida, imprime el porque
         return $this->_redirect('/');
     } else {
         $usuario->setIdUsuario($result->getIdentity());
         $mysession = new Zend_Session_Namespace('sesion');
         $mysession->actividad = 'SI';
         $mysession->setExpirationSeconds(60 * 5, 'actividad');
         //$mysession->usuario_id =  $usuario->getIdUsuario();
         $mysession->usuario_nombre = $result->getIdentity();
         $_SESSION['username'] = strtoupper($mysession->usuario_nombre);
         $aux = $usuario->getUsuariobyNombreUsuario($mysession->usuario_nombre);
         $mysession->usuario_id = $aux[0]['iUsuIdUsuario'];
         $mysession->tipo_usuario = $aux[0]['TipoUsuario_iTiUsuarioIdTipoUsuario'];
         $log = new Application_Model_Logs();
         $log->crearLog('A');
         $this->redireccionar();
     }
 }
 /**
  * Initialize session
  */
 protected function _initSes()
 {
     $ses = new \Zend_Session_Namespace(self::SESSION_NAMESPACE, true);
     $ses->setExpirationHops(5, null, true);
     $ses->setExpirationSeconds(60 * 60 * 24);
     $this->_ses = $ses;
 }
Example #9
0
 /**
  * When the user actually submits their otp, this authenticates it.
  */
 public function submitAction()
 {
     $this->disableLayout();
     $this->disableView();
     Zend_Session::start();
     $mfaSession = new Zend_Session_Namespace('Mfa_Temp_User');
     $user = $mfaSession->Dao;
     if (!isset($user) || !$user) {
         echo JsonComponent::encode(array('status' => 'error', 'message' => 'Session has expired, refresh and try again'));
         return;
     }
     $otpDevice = $this->Mfa_Otpdevice->getByUser($user);
     if (!$otpDevice) {
         throw new Zend_Exception('User does not have an OTP device');
     }
     $token = $this->getParam('token');
     try {
         $valid = $this->ModuleComponent->Otp->authenticate($otpDevice, $token);
     } catch (Zend_Exception $exc) {
         $this->getLogger()->crit($exc->getMessage());
         echo JsonComponent::encode(array('status' => 'error', 'message' => $exc->getMessage()));
         return;
     }
     if ($valid) {
         session_start();
         $authUser = new Zend_Session_Namespace('Auth_User');
         $authUser->setExpirationSeconds(60 * Zend_Registry::get('configGlobal')->session->lifetime);
         $authUser->Dao = $user;
         $authUser->lock();
         $this->getLogger()->debug(__METHOD__ . ' Log in : ' . $user->getFullName());
         echo JsonComponent::encode(array('status' => 'ok'));
     } else {
         echo JsonComponent::encode(array('status' => 'error', 'message' => 'Incorrect token'));
     }
 }
Example #10
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     $params = $request->getParams();
     $auth = Zend_Auth::getInstance();
     Zend_Registry::set('Zend_Auth', $auth);
     if ($auth->hasIdentity()) {
         $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
         $identity = $auth->getIdentity();
         $userDb = new Users_Model_DbTable_User();
         $user = array('id' => $identity->id, 'username' => $identity->username, 'name' => $identity->name, 'email' => $identity->email, 'clientid' => $identity->clientid);
         $authNamespace = new Zend_Session_Namespace('Zend_Auth');
         $authNamespace->user = $user['username'];
         if ($_SESSION['__ZF']['Zend_Auth']['ENT'] - time() < 3600) {
             $authNamespace->setExpirationSeconds(3600);
         }
         Zend_Registry::set('User', $user);
         $view->user = $user;
         $clientDb = new Application_Model_DbTable_Client();
         $client = $clientDb->getClient($user['clientid']);
         Zend_Registry::set('Client', $client);
     } elseif ($params['module'] != 'users' && $params['action'] != 'login') {
         $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
         if (isset($params['id']) && $params['id']) {
             $redirector->gotoSimple('login', 'user', 'users', array('url' => $params['module'] . '|' . $params['controller'] . '|' . $params['action'] . '|' . $params['id']));
         } else {
             $redirector->gotoSimple('login', 'user', 'users', array('url' => $params['module'] . '|' . $params['controller'] . '|' . $params['action']));
         }
     }
 }
Example #11
0
 public function init()
 {
     $langNamespace = new Zend_Session_Namespace('Lang');
     $config = Zend_Registry::get('config');
     if ($langNamespace->lang == null) {
         //$config = Zend_Registry::get('config');
         $defaultLanguage = strval($config->framework->language->default);
         $langNamespace->lang = $defaultLanguage;
     }
     $this->view->home = $config->app->home;
     $this->view->joomlahome = $config->joomla->home;
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $authNamespace = new Zend_Session_Namespace('Zend_Auth');
         $this->_currentUser = $authNamespace->user;
         //2011-04-08 ham.bao separate the sessions with admin
         $this->_currentAdmin = $authNamespace->admin;
         $this->_currentClient = $authNamespace->client;
         $this->view->currentUser = $this->_currentUser;
         $authNamespace->setExpirationSeconds(12 * 60 * 60);
     }
     $this->_flashMessenger = $this->_helper->getHelper('FlashMessenger');
     $ajaxContext = $this->_helper->getHelper('AjaxContext');
     $ajaxContext->addActionContext('adminajax', 'json')->initContext();
     $this->initView();
 }
Example #12
0
 protected function autenticacao($isAjax = false)
 {
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         if ($isAjax) {
             // if is ajax request, let js handle redirect properly ;)
             $session = new Zend_Session_Namespace();
             if (isset($session->url)) {
                 unset($session->url);
             }
             $this->view->error = _("Permission denied.");
             $this->_response->setHttpResponseCode(403);
             return false;
         } else {
             $session = new Zend_Session_Namespace();
             $session->setExpirationSeconds(60 * 60 * 1);
             // 1 minuto
             $session->url = $_SERVER['REQUEST_URI'];
             return $this->_helper->redirector->goToRoute(array(), 'login', true);
         }
     }
     $sessao = Zend_Auth::getInstance()->getIdentity();
     if (!$sessao["administrador"]) {
         if ($this->getRequest()->isXmlHttpRequest()) {
             $this->view->error = _("Unauthorized.");
             $this->_response->setHttpResponseCode(401);
             return false;
         } else {
             return $this->_helper->redirector->goToRoute(array('controller' => 'participante', 'action' => 'index'), 'default', true);
         }
     }
     return true;
 }
 public function indexAction()
 {
     $this->view->headTitle("uiwiki-登陆");
     if ($this->getRequest()->isPost()) {
         Zend_Loader::loadClass('Zend_Filter_StripTags');
         $filter = new Zend_Filter_StripTags();
         //表单的post值
         $name = $filter->filter($this->_request->getPost('name'));
         $password = $filter->filter($this->_request->getPost('password'));
         if (!empty($name)) {
             $authAdapter = new Zend_Auth_Adapter_DbTable();
             $authAdapter->setTableName('ui_project')->setIdentityColumn('name')->setCredentialColumn('password')->setIdentity($name)->setCredential($password);
             $auth = Zend_Auth::getInstance();
             $result = $auth->authenticate($authAdapter);
             // 执行认证查询,并保存结果
             if ($result->isValid()) {
                 $data = $authAdapter->getResultRowObject(array('name', 'id'));
                 if ($auth->hasIdentity()) {
                     //auth之后写入session
                     $user = new Zend_Session_Namespace('user');
                     $user->name = $data->name;
                     $user->id = $data->id;
                     $user->setExpirationSeconds(6000);
                     //命名空间 "user" 将在第一次访问后 6000 秒过期
                     //echo '<h3><font color=red> 登录成功!</font></h3>';
                     $this->_redirect('/' . $name);
                 }
             } else {
                 echo '<h3><font color=red> 登录失败,请重新登录!</font></h3>';
             }
         }
     }
 }
 public function init()
 {
     $this->verificarInactividad();
     $mysession = new Zend_Session_Namespace('sesion');
     $mysession->setExpirationSeconds(60 * 3, 'actividad');
     /* Initialize action controller here */
 }
Example #15
0
    public function loginAction()
    {
        // Don't allow logged in people here
        $user = Zend_Auth::getInstance()->getIdentity();
        if ($user !== null) {
            $this->_redirect('/');
        }

        $this->view->title = 'Log in';
        if ($this->_request->isPost()) {
            // collect the data from the user
            $f = new Zend_Filter_StripTags();
            $username = $f->filter($this->_request->getPost('handle'));
            $password = $f->filter($this->_request->getPost('password'));

            if (empty($username) || empty($password)) {
                $this->addErrorMessage('Please provide a username and password.');
            } else {
                // do the authentication
                $authAdapter = $this->_getAuthAdapter($username, $password);
                $auth   = Zend_Auth::getInstance();
                $result = $auth->authenticate($authAdapter);

                if ($result->isValid()) {
                    $auth->getStorage()->write($authAdapter->getResult());

                    // Receive Zend_Session_Namespace object
                    $session = new Zend_Session_Namespace('Zend_Auth');
                    // Set the time of user logged in
                    $session->setExpirationSeconds(24*3600);

                    // If "remember" was marked
                    if ($this->getRequest()->getParam('rememberme') !== null) {
                        // remember the session for 604800s = 7 days
                        Zend_Session::rememberMe(604800);
                    }

                    $ns = new Zend_Session_Namespace('lastUrl');
                    $lastUrl = $ns->value;
                    if ($lastUrl !== '') {
                        $ns->value = '';

                        // If our last request was an tester ajax request just
                        // go back to /tester
                        $lastUrl = (strpos($lastUrl,'/tester/ajax') === false) ? $lastUrl : '/tester';

                        $this->_redirect($lastUrl);
                    }

                    $this->_redirect('/');
                } else {
                    // failure: clear database row from session
                    $this->addErrorMessage('Login failed.');
                }
            }
        } else {
            $this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden');
        }
    }
Example #16
0
 /**
  * Return checkout data storage
  *
  * @return Zend_Session_Namespace
  */
 public function getStorage()
 {
     if (null === $this->_storage) {
         $this->_storage = Axis::session($this->_code . '-Checkout');
         $this->_storage->setExpirationSeconds(600);
         $this->_storage->setExpirationHops(5);
     }
     return $this->_storage;
 }
Example #17
0
 /**
  * @return ArrayObject
  */
 public static function getFavorites()
 {
     $session = new Zend_Session_Namespace('favorites');
     if ($session->favorites === null) {
         $session->setExpirationSeconds(2592000);
         $session->favorites = new ArrayObject(array());
     }
     return $session->favorites;
 }
Example #18
0
 /**
  * Return checkout data storage
  *
  * @return Zend_Session_Namespace
  */
 public function getStorage()
 {
     if (null === $this->_storage) {
         $this->_storage = new Zend_Session_Namespace($this->_code . '-Checkout');
         $this->_storage->setExpirationSeconds(600);
         $this->_storage->setExpirationHops(5);
     }
     return $this->_storage;
 }
 /**
  * Push value to session with key.
  * 
  * @param $key
  * @param $value
  */
 public static function setProperty($key, $value)
 {
     $myNamespace = new Zend_Session_Namespace(self::NAME);
     if (!isset($myNamespace->initialized)) {
         Zend_Session::regenerateId();
         $myNamespace->initialized = true;
     }
     $myNamespace->setExpirationSeconds(self::EXPIRE_IN_SEC, $key);
     $myNamespace->{$key} = $value;
 }
Example #20
0
File: Word.php Project: lortnus/zf1
 /**
  * Get session object
  *
  * @return Zend_Session_Namespace
  */
 public function getSession()
 {
     if (!isset($this->_session) || null === $this->_session) {
         $id = $this->getId();
         $this->_session = new $this->_sessionClass('Zend_Form_Captcha_' . $id);
         $this->_session->setExpirationHops(1, null, true);
         $this->_session->setExpirationSeconds($this->getTimeout());
     }
     return $this->_session;
 }
Example #21
0
 /**
  * Initializes a new token
  */
 protected function _initializeTokens()
 {
     $this->_previousToken = $this->_session->key;
     $newKey = sha1(microtime() . mt_rand());
     $this->_session->key = $newKey;
     if ($this->_expiryTime > 0) {
         $this->_session->setExpirationSeconds($this->_expiryTime);
     }
     $this->_token = $newKey;
 }
Example #22
0
 public function loginAction()
 {
     $username = strip_tags(trim($this->getRequest()->getParam('username')));
     $password = md5(strip_tags(trim($this->getRequest()->getParam('password'))));
     $UserMapper = new Application_Model_UserMapper();
     $arr = $UserMapper->checkUser($username, $password);
     if (!empty($arr)) {
         if ($arr[0]['Activate'] == 1) {
             $DeptMapper = new Application_Model_DepartmentMapper();
             $DeptID = $arr[0]['Department'];
             $arrDept = $DeptMapper->findDept($DeptID);
             if (!empty($arrDept)) {
                 $DeptCode = $arrDept[0]['DeptCode'];
                 $DeptName = $arrDept[0]['DeptName'];
             }
             $session = new Zend_Session_Namespace('user');
             $session->UserID = $arr[0]['UID'];
             $session->UserName = $arr[0]['UserName'];
             $session->RealName = $arr[0]['RealName'];
             $session->DeptID = $arr[0]['Department'];
             $session->DeptCode = $DeptCode;
             $session->DeptName = $DeptName;
             $session->Type = $arr[0]['Type'];
             $session->LastLoginTime = $arr[0]['LastLoginTime'];
             if ($this->getRequest()->getParam('remember') == "on") {
                 $session->setExpirationSeconds(3600);
             } else {
                 $session->setExpirationSeconds(1800);
             }
             $res = $UserMapper->updateLastLoginTime($arr[0]['UID']);
             $this->_redirect('/admin');
         } else {
             $string = "<meta http-equiv='content-type' content='text/html; charset=UTF-8'><script language=\"JavaScript\">alert(\"未授权用户!\");location.href = \"/login\";</script>";
             echo $string;
             exit;
         }
     } else {
         $string = "<meta http-equiv='content-type' content='text/html; charset=UTF-8'><script language=\"JavaScript\">alert(\"登陆失败!\");location.href = \"/login\";</script>";
         echo $string;
         exit;
     }
 }
 public function loginAction()
 {
     $auth = Zend_Auth::getInstance();
     $this->_layout->setLayout('admin_login');
     $this->view->message = $this->_flashMessenger->getMessages();
     $form = new Admin_Form_LoginForm();
     $form->setMethod('post')->setAction($this->view->rootUrl('/admin/index/login'));
     $this->view->form = $form;
     $flashMessenger = $this->_helper->getHelper('FlashMessenger');
     if ($this->getRequest()->isPost()) {
         $username = $this->_getParam('username');
         $password = md5($this->_getParam('password'));
         if (empty($username) || empty($password)) {
             $flashMessenger->addMessage('Field Cannot Empty');
         } else {
             $db = Zend_Db_Table::getDefaultAdapter();
             $authAdapter = new Zend_Auth_Adapter_DbTable($db, 'admin_account', 'username', 'password');
             $authAdapter->setIdentity($username);
             $authAdapter->setCredential($password);
             $result = $authAdapter->authenticate();
             if ($result->isValid()) {
                 $auth = Zend_Auth::getInstance();
                 $storage = $auth->getStorage();
                 $storage->write($authAdapter->getResultRowObject(array('admin_id', 'username', 'email', 'role_id')));
                 $identity = $auth->getIdentity();
                 //set auth session expired
                 $auth_sess = new Zend_Session_Namespace($auth->getStorage()->getNamespace());
                 $auth_sess->setExpirationSeconds(strtotime('30 day', 0));
                 //store user information on session
                 Zend_Session::namespaceUnset('userInfo');
                 $userInfo = new Zend_Session_Namespace('userInfo');
                 $userInfo->id = $identity->admin_id;
                 $userInfo->name = $identity->username;
                 $userInfo->email = $identity->email;
                 $userInfo->role_id = $identity->role_id;
                 //set user allowed module list
                 $table_adminAccount = new Model_DbTable_AdminAccount();
                 $module_list = $table_adminAccount->getUserInformation($identity->admin_id);
                 $userInfo->module_list = explode(',', $module_list['allowed_module']);
                 $userInfo->canApprove = in_array(47, $userInfo->module_list);
                 //get module list from the database
                 Zend_Session::namespaceUnset('moduleList');
                 $moduleList = new Zend_Session_Namespace('moduleList');
                 $table_module = new Model_DbTable_AdminModule();
                 $module = $table_module->getAllModuleId();
                 $moduleList->module = $module;
                 //redirecting to the dashboard
                 $this->_redirect($this->view->rootUrl('/admin/index'));
             } else {
                 $flashMessenger->addMessage('Login Failed');
             }
         }
     }
 }
Example #24
0
 function init()
 {
     define('KUTU_ROOT_DIR', dirname(__FILE__));
     error_reporting(E_ALL | E_STRICT);
     date_default_timezone_set('Asia/Jakarta');
     set_include_path('.' . PATH_SEPARATOR . KUTU_ROOT_DIR . '/library' . PATH_SEPARATOR . get_include_path());
     require_once 'Zend/Loader/Autoloader.php';
     $loader = Zend_Loader_Autoloader::getInstance();
     $loader->setFallbackAutoloader(true);
     $loader->suppressNotFoundWarnings(false);
     //		include "Zend/Loader.php";
     //		Zend_Loader::registerAutoload();
     require_once KUTU_ROOT_DIR . '/library/phpgacl/gacl.class.php';
     require_once KUTU_ROOT_DIR . '/library/phpgacl/gacl_api.class.php';
     require_once KUTU_ROOT_DIR . '/js/jcart/jcart.php';
     $config = new Zend_Config_Ini(KUTU_ROOT_DIR . '/application/configs/application.ini', 'general');
     $registry = Zend_Registry::getInstance();
     $registry->set('config', $config);
     $registry->set('files', $_FILES);
     //$db = Zend_Db::factory($config->db->adapter, $config->db->config->toArray());
     //Zend_Db_Table_Abstract::setDefaultAdapter($db);
     $databases = new Zend_Config_Ini(KUTU_ROOT_DIR . '/application/configs/application.ini', 'databases');
     $dbAdapters = array();
     foreach ($databases->db as $config_name => $db) {
         $dbAdapters[$config_name] = Zend_Db::factory($db->adapter, $db->config->toArray());
         if ((bool) $db->default) {
             Zend_Db_Table::setDefaultAdapter($dbAdapters[$config_name]);
         }
     }
     Zend_Registry::set('dbAdapters', $dbAdapters);
     $kutuUtil = new Kutu_Core_Util();
     define('KUTU_ROOT_URL', $kutuUtil->getRootUrl(KUTU_ROOT_DIR));
     require_once 'Kutu/Session/Manager.php';
     $kutuSession = new Kutu_Session_Manager();
     $kutuSession->start();
     // set the expiration time for auth session to expire
     $authNamespace = new Zend_Session_Namespace('Zend_Auth');
     $authNamespace->setExpirationSeconds(86400);
     // will expire in one day
     $frontendOptions = array('lifetime' => 7200, 'automatic_serialization' => true);
     $backendOptions = array('cache_dir' => KUTU_ROOT_DIR . '/data/cache');
     $cacheDbTable = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     // Next, set the cache to be used with all table objects
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cacheDbTable);
     //		define('IN_PHPBB', true);
     //		define('PBB_ROOT_PATH', "../phpBB3");
     //		global $phpbb_root_path, $phpEx, $user, $db, $config, $cache, $template;
     //		$phpEx = "php";
     //		$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : PBB_ROOT_PATH . '/';
     //		require_once($phpbb_root_path . 'config.' . $phpEx);
     //		include($phpbb_root_path . 'common.' . $phpEx);
     //		$user->session_begin();
     //		$auth->acl($user->data);
 }
 public function init()
 {
     $this->_helper->layout->setLayout('mobile');
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         $session = new Zend_Session_Namespace();
         $session->setExpirationSeconds(60 * 60 * 1);
         // 1 minuto
         $session->url = $_SERVER['REQUEST_URI'];
         // TODO: criar login mobile
         return $this->_helper->redirector->goToRoute(array(), 'login', true);
     }
 }
Example #26
0
 /**
  * Validate the form
  *
  * @param  array $data
  * @return boolean
  */
 public function isValid($data)
 {
     $valid = parent::isValid($data);
     if ($valid) {
         $session = new Zend_Session_Namespace('Zend_Auth');
         if ((bool) $this->getValue('remember_me')) {
             Zend_Session::rememberMe();
         } else {
             $session->setExpirationSeconds($this->_loginLifetime);
         }
     }
     return $valid;
 }
Example #27
0
 /**
  * Get session object
  *
  * @return Zend_Session_Namespace
  */
 public function getSession()
 {
     if (!isset($this->_session) || null === $this->_session) {
         $id = $this->getId();
         if (!class_exists($this->_sessionClass)) {
             #require_once 'Zend/Loader.php';
             Zend_Loader::loadClass($this->_sessionClass);
         }
         $this->_session = new $this->_sessionClass('Zend_Form_Captcha_' . $id);
         $this->_session->setExpirationHops(1, null, true);
         $this->_session->setExpirationSeconds($this->getTimeout());
     }
     return $this->_session;
 }
Example #28
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     try {
         $config = Zend_Registry::get('config');
         $timeout = $config->authentication->timeout;
         $csrf = new Zend_Session_Namespace("csrf");
         $token = $csrf->token;
         if ($token == null) {
             $csrf->setExpirationSeconds($timeout * 60);
             $csrf->token = md5(uniqid(rand(), TRUE));
         }
     } catch (Exception $e) {
     }
 }
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         // user is logged in
         // get an instance of Zend_Session_Namespace used by Zend_Auth
         $session = new Zend_Session_Namespace($auth->getStorage()->getNamespace());
         /*$timeLeftTillSessionExpires = $_SESSION['__ZF']['Zend_Auth']['ENT'] - time(); */
         if (isset($_SESSION['__ZF']['Zend_Auth']['ENT'])) {
             //var_dump($_SESSION['__ZF']['Zend_Auth']['ENT'] - time());
             $session->setExpirationSeconds(self::SECONDS_IN_MINUTE * self::EXPIRATION_MINUTES);
         }
     }
 }
Example #30
0
 /**
  * Un membre est authentifiable via sa propre table
  * Elle comporte donc aussi des colonnes 'nom' et 'password'
  *
  * @var int $sessionDuration durée de vie de la persistance
  * @return Zend_Auth_Result
  */
 public function authenticate($sessionDuration = 7200)
 {
     $dba = Zend_Registry::get('dba');
     $auth = new Zend_Auth_Adapter_DbTable($dba, "MEMBRE", "LOGIN", "PASSWORD", "MD5(?)");
     $auth->setIdentity($this->LOGIN)->setCredential($this->PASSWORD);
     $result = $auth->authenticate();
     if ($result->isValid()) {
         $this->setFromArray((array) $auth->getResultRowObject());
         $session = new Zend_Session_Namespace('Zend_Auth');
         $session->setExpirationSeconds(abs((int) $sessionDuration));
         Zend_Auth::getInstance()->getStorage()->write($this);
     }
     return $result;
 }