Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function ValidateUser($username = '', $password = '')
- {
- $prefix = "SELECT ";
- $type = 'COUNT(id)';
- $suffix = " FROM users WHERE username = :username LIMIT 1";
- if($grabUser = $this->db->prepare($prefix.$type.$suffix))
- {
- $grabUser->bindParam(":username", $username, PDO::PARAM_STR);
- $grabUser->execute();
- if(count($grabUser->fetchColumn()) <= 0)
- {
- return array(0,0);
- }
- }
- else {
- return array(0,0);
- }
- $type = 'salt';
- if($grabUser = $this->db->prepare($prefix.$type.$suffix))
- {
- $grabUser->bindParam(":username", $username, PDO::PARAM_STR);
- $grabUser->execute();
- $salt = $grabUser->fetch()['salt'];
- $password = $this->core->blueHash($password, $salt);
- }
- else {
- return array(0,0);
- }
- $stmt = "SELECT COUNT(id) FROM users WHERE username = :username AND password = :password LIMIT 1";
- if($checkFinal = $this->db->prepare($stmt))
- {
- $checkFinal->bindParam(":username", $username, PDO::PARAM_STR);
- $checkFinal->bindParam(":password", $password, PDO::PARAM_STR);
- $checkFinal->execute();
- if(!count($checkFinal->fetchColumn()) > 0)
- {
- return array(0,0);
- }
- return array(count($checkFinal->fetchColumn()),$password);
- }
- return array(0,0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement