Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. public function ValidateUser($username = '', $password = '')
  2. {
  3. $prefix = "SELECT ";
  4. $type = 'COUNT(id)';
  5. $suffix = " FROM users WHERE username = :username LIMIT 1";
  6. if($grabUser = $this->db->prepare($prefix.$type.$suffix))
  7. {
  8. $grabUser->bindParam(":username", $username, PDO::PARAM_STR);
  9. $grabUser->execute();
  10. if(count($grabUser->fetchColumn()) <= 0)
  11. {
  12. return array(0,0);
  13. }
  14. }
  15. else {
  16. return array(0,0);
  17. }
  18.  
  19. $type = 'salt';
  20. if($grabUser = $this->db->prepare($prefix.$type.$suffix))
  21. {
  22. $grabUser->bindParam(":username", $username, PDO::PARAM_STR);
  23. $grabUser->execute();
  24. $salt = $grabUser->fetch()['salt'];
  25. $password = $this->core->blueHash($password, $salt);
  26. }
  27. else {
  28. return array(0,0);
  29. }
  30.  
  31.  
  32. $stmt = "SELECT COUNT(id) FROM users WHERE username = :username AND password = :password LIMIT 1";
  33. if($checkFinal = $this->db->prepare($stmt))
  34. {
  35. $checkFinal->bindParam(":username", $username, PDO::PARAM_STR);
  36. $checkFinal->bindParam(":password", $password, PDO::PARAM_STR);
  37. $checkFinal->execute();
  38. if(!count($checkFinal->fetchColumn()) > 0)
  39. {
  40. return array(0,0);
  41. }
  42. return array(count($checkFinal->fetchColumn()),$password);
  43. }
  44. return array(0,0);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement