示例#1
0
 /**
  * Authentification sur la page de login
  * @param $create
  * @param bool $debug
  */
 private function getAuth($create, $debug = false)
 {
     $token = isset($_SESSION['mc_auth_token']) ? $_SESSION['mc_auth_token'] : filter_rsa::tokenID();
     $tokentools = self::hashPassCreate($token);
     $create->assign('hashpass', $tokentools);
     if (isset($this->email_admin) and isset($this->passwd_admin)) {
         $firebug = new debug_firephp();
         if (strcasecmp($this->hashtoken, $tokentools) == 0) {
             if ($debug == true) {
                 $firebug->group('tokentest');
                 if ($this->hashtoken) {
                     if (strcasecmp($this->hashtoken, $tokentools) == 0) {
                         $firebug->log('session compatible');
                     } else {
                         $firebug->error('session incompatible');
                     }
                 }
                 $firebug->log($_SESSION);
                 $firebug->groupEnd();
             }
             $auth_exist = parent::s_auth_exist($this->email_admin, $this->passwd_admin);
             if (count($auth_exist['idadmin']) == true) {
                 $data = parent::s_data_session($auth_exist['keyuniqid_admin']);
                 $session = new http_session();
                 $language = new backend_model_language();
                 $session->start('mc_adminlang');
                 $sessionUtils = new admin_model_sessionUtils();
                 if (!isset($_SESSION['email_admin']) and !isset($_SESSION['keyuniqid_admin'])) {
                     $sessionUtils->openSession($data['idadmin'], session_regenerate_id(true), $data['keyuniqid_admin']);
                     $array_sess = array('id_admin' => $data['idadmin'], 'email_admin' => $data['email_admin'], 'keyuniqid_admin' => $data['keyuniqid_admin'], 'language_admin' => $language->run());
                     $session->run($array_sess, $language->run());
                     if ($debug == true) {
                         $firebug = new debug_firephp();
                         $firebug->group('adminsession');
                         $firebug->dump('User session', $_SESSION);
                         $firebug->log($session->ip());
                         $firebug->groupEnd();
                     }
                     admin_model_redirect::login(false);
                 } else {
                     $sessionUtils->openSession($data['idadmin'], null, $data['keyuniqid_admin']);
                     $array_sess = array('email_admin' => $data['email_admin'], 'keyuniqid_admin' => $data['keyuniqid_admin']);
                     $language = new admin_model_language();
                     $session->run($array_sess, $language->run());
                     if ($debug == true) {
                         $firebug = new debug_firephp();
                         $firebug->group('adminsession');
                         $firebug->dump('User session', $_SESSION);
                         $firebug->log($session->ip());
                         $firebug->groupEnd();
                     }
                     admin_model_redirect::login(false);
                 }
             }
         }
     }
 }
示例#2
0
 /**
  * Création d'un token
  * @param $tokename
  * @return array
  */
 public function token($tokename)
 {
     if (empty($_SESSION[$tokename])) {
         return $_SESSION[$tokename] = filter_rsa::tokenID();
     } else {
         if (isset($_SESSION[$tokename])) {
             return $_SESSION[$tokename];
         }
     }
 }