getControllerName()=='user' && $request->getActionName()=='login') { $checkAuth = false; } if ($request->getControllerName()=='fichier' && $request->getClientIp(false)=='78.31.45.206') { $checkAuth = false; } if ($checkAuth) { $login = $request->getParam('login'); $pass = $request->getParam('pass', ''); $hach = $request->getParam('hach'); $checkIp = $request->getParam('checkIp'); $auth = Zend_Auth::getInstance(); //Est ce que l'on a checkIp=only lors de la requête $iponly = false; if ($checkIp=='only') { $hach = 'iponly:'.$_SERVER['REMOTE_ADDR']; $iponly = true; } //On vérifie le tout lors d'une connexion par url if ( !empty($login) && !empty($hach) ) { $authAdapter = new Scores_AuthAdapter($login, $hach, $iponly); $result = $auth->authenticate($authAdapter); if (!$result->isValid()) { $messageF = ''; foreach ($result->getMessages() as $message) { $messageF.= $message."
"; } $request->setModuleName('default') ->setControllerName('user') ->setActionName('logout') ->setParam('message', $messageF); } else { $storage = new Zend_Auth_Storage_Session(); $session = new Zend_Session_Namespace($storage->getNamespace()); //$session->setExpirationSeconds(86400); $auth->setStorage($storage); } //Sinon on reste sur le standard } else { //Authentifié => on met à jour la session if ( $auth->hasIdentity() ) { $identity = $auth->getIdentity(); $identity->time = time() + $identity->timeout; $auth->getStorage()->write($identity); if (Zend_Session::namespaceIsset('login')){ Zend_Session::namespaceUnset('login'); } //Check CGU if ( $request->getControllerName()!='aide' && $request->getActionName()!='cgu' && $request->getControllerName()!='user' && $request->getActionName()!='logout') { if ( empty($identity->acceptationCGU) || $identity->acceptationCGU=='0000-00-00 00:00:00' ) { $request->setModuleName('default') ->setControllerName('aide') ->setActionName('cgu'); } } //Temps de connexion dépassé } elseif (time() > $auth->getIdentity()->time ) { $auth->clearIdentity(); $storage = $auth->getStorage(); Zend_Session::namespaceUnset($storage->getNamespace()); if (!$request->isXmlHttpRequest()) { $session = new Zend_Session_Namespace('login'); $session->url = $_SERVER['REQUEST_URI']; } if ( $request->getControllerName()=='index' && $request->getActionName()=='index' ) { $request->setModuleName('default') ->setControllerName('user') ->setActionName('login'); } else { $request->setModuleName('default') ->setControllerName('user') ->setActionName('logout') ->setParam('ajax', $request->isXmlHttpRequest()); } //Pas Authentifié } else { if (!$request->isXmlHttpRequest()) { $session = new Zend_Session_Namespace('login'); $session->url = $_SERVER['REQUEST_URI']; $request->setModuleName('default') ->setControllerName('user') ->setActionName('login'); } else { $request->setModuleName('default') ->setControllerName('user') ->setActionName('logout') ->setParam('ajax', 1); } } } } } }