Add files via upload
This commit is contained in:
@ -316,7 +316,7 @@ table a{
|
||||
height: 250px;
|
||||
}
|
||||
.code.showtimes{
|
||||
height: 550px;
|
||||
height: 600px;
|
||||
}
|
||||
|
||||
|
||||
@ -507,6 +507,12 @@ textarea {
|
||||
.verify {
|
||||
font-size: 11px;
|
||||
}
|
||||
.verify a {
|
||||
color: #1f2c3d;
|
||||
}
|
||||
.verify a:hover {
|
||||
color: rgb(138, 150, 32);
|
||||
}
|
||||
|
||||
#submit {
|
||||
width: 100%;
|
||||
|
@ -6,4 +6,4 @@
|
||||
require_once('template.php');
|
||||
$template = new Template();
|
||||
$prefix = $template->get_prefix();
|
||||
?>
|
||||
?>
|
@ -157,6 +157,14 @@
|
||||
</div>\n";
|
||||
}
|
||||
|
||||
//Print session MSG:
|
||||
function print_msg() {
|
||||
if(isset($_SESSION['message'])){
|
||||
echo "<div>".$_SESSION['message']."</div>";
|
||||
unset($_SESSION['message']);
|
||||
}
|
||||
}
|
||||
|
||||
//Print generic Footer:
|
||||
function print_footer(){
|
||||
//$page = $this->page;
|
||||
@ -173,13 +181,5 @@
|
||||
</footer>\n";
|
||||
}
|
||||
|
||||
//Print session MSG:
|
||||
function print_msg() {
|
||||
if(isset($_SESSION['message'])){
|
||||
echo "<div>".$_SESSION['message']."</div>";
|
||||
unset($_SESSION['message']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
83
assets/php/user_dao.php
Normal file
83
assets/php/user_dao.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
require_once('dao.php');
|
||||
include_once('user_dto.php');
|
||||
|
||||
class UserDAO extends DAO {
|
||||
|
||||
//Constants:
|
||||
private const _USER = "user";
|
||||
private const _MANAGER = "manager";
|
||||
private const _ADMIN = "admin";
|
||||
|
||||
//Attributes:
|
||||
|
||||
//Constructor:
|
||||
function __construct($bd_name){
|
||||
parent::__construct($bd_name);
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Encrypt password with SHA254.
|
||||
private function encryptPass($password){
|
||||
//$password = hash('sha256', $password);
|
||||
$password = password_hash($password, PASSWORD_DEFAULT);
|
||||
|
||||
return $password;
|
||||
}
|
||||
|
||||
//Returns true if the password and hash match, or false otherwise.
|
||||
public function verifyPass($password, $passwd){
|
||||
return password_verify($password, $passwd);
|
||||
}
|
||||
|
||||
//Create a new User.
|
||||
public function createUser($id, $username, $email, $password, $rol){
|
||||
$password = $this->encryptPass($password);
|
||||
|
||||
$sql = sprintf( "INSERT INTO users( id, username, email, passwd, rol)
|
||||
VALUES ( '%s', '%s', '%s', '%s', '%s')",
|
||||
$id, $username, $email, $password, $rol );
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
//Returns a query to check if the user name exists.
|
||||
public function selectUser($username){
|
||||
$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');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
37
assets/php/user_dto.php
Normal file
37
assets/php/user_dto.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
include_once('users_dto_interface.php');
|
||||
|
||||
class UserDTO implements UsersDTO {
|
||||
|
||||
//Attributes:
|
||||
private $_id; //User Id.
|
||||
private $_username; //User name.
|
||||
private $_email; //User email.
|
||||
private $_password; //User password.
|
||||
private $_rol; //Type of user: user | manager | admin.
|
||||
|
||||
//Constructor:
|
||||
function __construct($id, $username, $email, $password, $rol){
|
||||
$this->_id = $id;
|
||||
$this->_username = $username;
|
||||
$this->_email = $email;
|
||||
$this->_password = $password;
|
||||
$this->_rol = $rol;
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Getters && Setters:
|
||||
public function setId($id){ $this->_id = $id; }
|
||||
public function getId(){ return $this->_id; }
|
||||
public function setName($username){ $this->_username = $username; }
|
||||
public function getName(){ return $this->_username; }
|
||||
public function setEmail($email){ $this->_email = $email; }
|
||||
public function getEmail(){ return $this->_email; }
|
||||
public function setPass($passwd){ $this->_password = $passwd; }
|
||||
public function getPass(){ return $this->_password; }
|
||||
public function setRol($rol){ $this->_rol = $rol; }
|
||||
public function getRol(){ return $this->_rol; }
|
||||
|
||||
}
|
||||
?>
|
14
assets/php/users_dto_interface.php
Normal file
14
assets/php/users_dto_interface.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
interface UsersDTO {
|
||||
public function setId($id);
|
||||
public function getId();
|
||||
public function setName($username);
|
||||
public function getName();
|
||||
public function setEmail($email);
|
||||
public function getEmail();
|
||||
public function setPass($passwd);
|
||||
public function getPass();
|
||||
public function setRol($rol);
|
||||
public function getRol();
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user