From 70a0bd93c162fbd8216e7acdc5dd91c591f99a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20M=C3=A9ndez?= <45081533+FerMdez@users.noreply.github.com> Date: Sun, 9 May 2021 16:58:21 +0200 Subject: [PATCH] Delete user_dao.php --- login/includes/user_dao.php | 95 ------------------------------------- 1 file changed, 95 deletions(-) delete mode 100644 login/includes/user_dao.php diff --git a/login/includes/user_dao.php b/login/includes/user_dao.php deleted file mode 100644 index 3c8f7e3..0000000 --- a/login/includes/user_dao.php +++ /dev/null @@ -1,95 +0,0 @@ -encryptPass($password); - - $sql = sprintf( "INSERT INTO users( id, username, email, passwd, rol) - VALUES ( '%s', '%s', '%s', '%s', '%s')", - $id, $username, $email, $password, $rol ); - - $resul = mysqli_query($this->mysqli, $sql) /*or die ('Error into query database')*/; - - return $resul; - } - - //Returns a query to check if the user name exists. - public function selectUser($username, $password){ - $username = $this->mysqli->real_escape_string($username); - - $sql = sprintf( "SELECT * FROM users WHERE username = '%s'", $username ); - $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); - - $resul->data_seek(0); - while ($fila = $resul->fetch_assoc()) { - if($username === $fila['username'] && $this->verifyPass($password, $fila['passwd'])){ - $user = $this->loadUser($fila['id'], $fila['username'], $fila['email'], $fila['passwd'], $fila['rol']); - } - } - - //mysqli_free_result($selectUser); - $resul->free(); - - return $user; - } - - //Returns a query to check if the user pass matches. - public function selectPass($username, $password){ - $username = $this->mysqli->real_escape_string($username); - $password = $this->mysqli->real_escape_string($password); - $password = $this->encryptPass($password); - - $sql = sprintf( "SELECT * FROM users WHERE username = '%s' AND passwd = '%s'", $username, $password); - $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); - - //return $this->mysqli->query($sql); - return $resul; - } - - //Returns a query to get the user's data. - public function userData($id){ - $sql = sprintf( "SELECT * FROM users WHERE id = '%d'", $id ); - $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); - - return $resul; - } - - //Create a new User Data Transfer Object. - public function loadUser($id, $username, $email, $password, $rol){ - return new UserDTO($id, $username, $email, $password, $rol); - } - - } - -?> \ No newline at end of file