Guest User

Untitled

a guest
Dec 29th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. class User
  2. {
  3. public static function checkUser($password, $passwordDb, $username)
  4. {
  5. global $dbh;
  6. if (substr($passwordDb, 0, 1) == "$")
  7. {
  8. if (password_verify($password, $passwordDb))
  9. {
  10. return true;
  11. }
  12. return false;
  13. }
  14. else
  15. {
  16. $passwordBcrypt = self::hashed($password);
  17. if (md5($password) == $passwordDb)
  18. {
  19. $stmt = $dbh->prepare("UPDATE users SET password = :password WHERE username = :username");
  20. $stmt->bindParam(':username', $username);
  21. $stmt->bindParam(':password', $passwordBcrypt);
  22. $stmt->execute();
  23. return true;
  24. }
  25. return false;
  26. }
  27. }
Add Comment
Please, Sign In to add comment