Beispiel #1
0
 public function run($data)
 {
     $array = [];
     $bind = [":login" => $data['user']];
     $q = DB::inst()->select("user", "login=:login", "", "*", $bind);
     foreach ($q as $r) {
         $array[] = $r;
     }
     $cookie = sprintf("data=%s&auth=%s", urlencode($data['user']), urlencode(tp_hash_cookie($data['user'] . $data['pass'])));
     $mac = hash_hmac("sha512", $cookie, rand(22, 999999 * 1000000));
     $auth = $cookie . '&digest=' . urlencode($mac);
     if (tp_check_password($data['pass'], $r['password'], $r['userID'])) {
         if ($data['rememberme']) {
             /* Now we can set our login cookies. */
             $this->_auth->_setcookie("TP_COOKNAME", $auth);
             $this->_auth->_setcookie("TP_COOKID", tp_hash_cookie($r['userID']));
             $this->_auth->_setcookie("TP_REMEMBER", 'rememberme');
         } else {
             /* Now we can set our login cookies. */
             $this->_auth->_setcookie("TP_COOKNAME", $auth, time() + 86400);
             $this->_auth->_setcookie("TP_COOKID", tp_hash_cookie($r['userID']), time() + 86400);
         }
         redirect(BASE_URL . 'dashboard/');
     } else {
         redirect(BASE_URL);
     }
 }
Beispiel #2
0
 /**
  * Switch back to the original user
  *
  * @since 3.0.2
  * @return mixed
  * 
  */
 public function _switchUserBack($id)
 {
     if (isset($_COOKIE['TP_REMEMBER']) && $_COOKIE['TP_REMEMBER'] == 'rememberme') {
         $this->_setcookie("TP_COOKNAME", '', time() - COOKIE_EXPIRE);
         $this->_setcookie("TP_COOKID", '', time() - COOKIE_EXPIRE);
         $this->_setcookie("SWITCH_USERBACK", '', time() - COOKIE_EXPIRE);
         $this->_setcookie("SWITCH_USERNAME", '', time() - COOKIE_EXPIRE);
     } else {
         $this->_setcookie("TP_COOKNAME", '', time() - 86400);
         $this->_setcookie("TP_COOKID", '', time() - 86400);
         $this->_setcookie("SWITCH_USERBACK", '', time() - 86400);
         $this->_setcookie("SWITCH_USERNAME", '', time() - 86400);
     }
     $auth = $this->hashHmac($this->getUserValue($id, 'login'));
     if (isset($_COOKIE['TP_REMEMBER']) && $_COOKIE['TP_REMEMBER'] == 'rememberme') {
         $this->_setcookie("TP_COOKNAME", $auth);
         $this->_setcookie("TP_COOKID", tp_hash_cookie($id));
     } else {
         $this->_setcookie("TP_COOKNAME", $auth, time() + 86400);
         $this->_setcookie("TP_COOKID", tp_hash_cookie($id), time() + 86400);
     }
 }