Advertisement
Guest User

Untitled

a guest
Jul 10th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1.     public function login($username, $password, $hash = true, $post = false) {
  2.         if (!$hash) {
  3.             $password = $this->hash($password);
  4.         }
  5.         $this->services->prepare("SELECT *
  6.                                FROM anope_ns_core
  7.                                WHERE display = :username
  8.                                LIMIT 1")
  9.                 ->bindValue('username', $username)
  10.                 ->execute();
  11.         if ($this->services->num_rows() == 1 && $user = $this->services->fetch_assoc()) {
  12.             if (substr(bin2hex($user['pass']), 0, 40) === $password) {
  13.                 $user['password'] = substr(bin2hex($user['pass']), 0, 40);
  14.                 $this->_loggedIn = true;
  15.                 foreach ($user as $key => $value) {
  16.                     $this->_information[$key] = $value;
  17.                     $_SESSION['user'][$key] = $value;
  18.                 }
  19.                 setcookie('FServices', $user['display'] . '|' . hash('sha512', $user['display'] . $user['password'] . $_SERVER['REMOTE_ADDR']), time() + 2592000, '/', '', '', 1);
  20.                 return true;
  21.             } else {
  22.                 return false;
  23.             }
  24.         }
  25.         return false;
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement