Delete login directory
This commit is contained in:
		@@ -1,238 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
class Form {
 | 
			
		||||
/**
 | 
			
		||||
   * Sufijo para el nombre del parámetro de la sesión del usuario donde se almacena el token CSRF.
 | 
			
		||||
   */
 | 
			
		||||
  const CSRF_PARAM = 'csrf';
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Cadena utilizada como valor del atributo "id" de la etiqueta <form> asociada al formulario y como parámetro a comprobar para verificar que el usuario ha enviado el formulario.
 | 
			
		||||
   */
 | 
			
		||||
  private $formId;
 | 
			
		||||
 | 
			
		||||
  private $ajax;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * URL asociada al atributo "action" de la etiqueta <form> del fomrulario y que procesará el envío del formulario.
 | 
			
		||||
   */
 | 
			
		||||
  private $action;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Valor del atributo "class" de la etiqueta <form> asociada al formulario. Si este parámetro incluye la cadena "nocsrf" no se generá el token CSRF para este formulario.
 | 
			
		||||
   */
 | 
			
		||||
  private $classAtt;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Valor del parámetro enctype del formulario.
 | 
			
		||||
   */
 | 
			
		||||
  private $enctype;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Se encarga de orquestar todo el proceso de creación y procesamiento de un formulario web.
 | 
			
		||||
   *
 | 
			
		||||
   * @param string $formId Cadena utilizada como valor del atributo "id" de la etiqueta <form> asociada al formulario y como parámetro a comprobar para verificar que el usuario ha enviado el formulario.
 | 
			
		||||
   *
 | 
			
		||||
   * @param string $action (opcional) URL asociada al atributo "action" de la etiqueta <form> del fomrulario y que procesará el envío del formulario. Por defecto la URL es $_SERVER['PHP_SELF']
 | 
			
		||||
   *
 | 
			
		||||
   * @param string $class (opcional) Valor del atributo "class" de la etiqueta <form> asociada al formulario. Si este parámetro incluye la cadena "nocsrf" no se generá el token CSRF para este formulario.
 | 
			
		||||
   *
 | 
			
		||||
   * @param string enctype (opcional) Valor del parámetro enctype del formulario.
 | 
			
		||||
   */
 | 
			
		||||
  public function __construct($formId, $opciones = array() ) {
 | 
			
		||||
    $this->formId = $formId;
 | 
			
		||||
 | 
			
		||||
    $opcionesPorDefecto = array( 'ajax' => false, 'action' => null, 'class' => null, 'enctype' => null );
 | 
			
		||||
    $opciones = array_merge($opcionesPorDefecto, $opciones);
 | 
			
		||||
 | 
			
		||||
    $this->ajax     = $opciones['ajax'];
 | 
			
		||||
    $this->action   = $opciones['action'];
 | 
			
		||||
    $this->classAtt = $opciones['class'];
 | 
			
		||||
    $this->enctype  = $opciones['enctype'];
 | 
			
		||||
    
 | 
			
		||||
    if ( !$this->action ) {
 | 
			
		||||
      $this->action = $_SERVER['PHP_SELF'];
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  public function gestiona() {
 | 
			
		||||
    
 | 
			
		||||
    if ( ! $this->formularioEnviado($_POST) ) {
 | 
			
		||||
      echo $this->generaFormulario();
 | 
			
		||||
    } else {
 | 
			
		||||
      // Valida el token CSRF si es necesario (hay un token en la sesión asociada al formulario)
 | 
			
		||||
      $tokenRecibido = isset($_POST['CSRFToken']) ? $_POST['CSRFToken'] : FALSE;
 | 
			
		||||
      
 | 
			
		||||
      if ( ($errores = $this->csrfguard_ValidateToken($this->formId, $tokenRecibido)) !== TRUE ) { 
 | 
			
		||||
          if ( ! $this->ajax ) {
 | 
			
		||||
            echo $this->generaFormulario($errores, $_POST);
 | 
			
		||||
          } else {
 | 
			
		||||
            echo $this->generaHtmlErrores($errores);
 | 
			
		||||
          }
 | 
			
		||||
      } else  {
 | 
			
		||||
        $result = $this->procesaFormulario($_POST);
 | 
			
		||||
        if ( is_array($result) ) {
 | 
			
		||||
          // Error al procesar el formulario, volvemos a mostrarlo
 | 
			
		||||
          if ( ! $this->ajax ) {
 | 
			
		||||
            echo $this->generaFormulario($result, $_POST);
 | 
			
		||||
          } else {
 | 
			
		||||
            echo $this->generaHtmlErrores($result);
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          if ( ! $this->ajax ) {
 | 
			
		||||
            header('Location: '.$result);
 | 
			
		||||
          } else {
 | 
			
		||||
            echo $result;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }  
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Devuelve un <code>string</code> con el HTML necesario para presentar los campos del formulario. Es necesario asegurarse que como parte del envío se envía un parámetro con nombre <code$formId</code> (i.e. utilizado como valor del atributo name del botón de envío del formulario).
 | 
			
		||||
   */
 | 
			
		||||
  protected function generaCamposFormulario ($datos) {
 | 
			
		||||
    return '';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Procesa los datos del formulario.
 | 
			
		||||
   */
 | 
			
		||||
  protected function procesaFormulario($datos) {
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Función que verifica si el usuario ha enviado el formulario. Comprueba si existe el parámetro <code>$formId</code> en <code>$params</code>.
 | 
			
		||||
   *
 | 
			
		||||
   * @param array $params Array que contiene los datos recibidos en el envío formulario.
 | 
			
		||||
   *
 | 
			
		||||
   * @return boolean Devuelve <code>TRUE</code> si <code>$formId</code> existe como clave en <code>$params</code>
 | 
			
		||||
   */
 | 
			
		||||
  private function formularioEnviado(&$params) {
 | 
			
		||||
    return isset($params['action']) && $params['action'] == $this->formId;
 | 
			
		||||
  } 
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Función que genera el HTML necesario para el formulario.
 | 
			
		||||
   *
 | 
			
		||||
   *
 | 
			
		||||
   * @param array $errores (opcional) Array con los mensajes de error de validación y/o procesamiento del formulario.
 | 
			
		||||
   *
 | 
			
		||||
   * @param array $datos (opcional) Array con los valores por defecto de los campos del formulario.
 | 
			
		||||
   */
 | 
			
		||||
  private function generaFormulario($errores = array(), &$datos = array()) {
 | 
			
		||||
 | 
			
		||||
    $html= $this->generaListaErrores($errores);
 | 
			
		||||
 | 
			
		||||
    $html .= '<form method="POST" action="'.$this->action.'" id="'.$this->formId.'"';
 | 
			
		||||
    if ( $this->classAtt ) {
 | 
			
		||||
      $html .= ' class="'.$this->classAtt.'"';
 | 
			
		||||
    }
 | 
			
		||||
    if ( $this->enctype ) {
 | 
			
		||||
      $html .= ' enctype="'.$this->enctype.'"';
 | 
			
		||||
    }
 | 
			
		||||
    $html .=' >';
 | 
			
		||||
    
 | 
			
		||||
    // Se genera el token CSRF si el usuario no solicita explícitamente lo contrario.
 | 
			
		||||
    if ( ! $this->classAtt || strpos($this->classAtt, 'nocsrf') === false ) {
 | 
			
		||||
      $tokenValue = $this->csrfguard_GenerateToken($this->formId);
 | 
			
		||||
      $html .= '<input type="hidden" name="CSRFToken" value="'.$tokenValue.'" />';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $html .= '<input type="hidden" name="action" value="'.$this->formId.'" />';
 | 
			
		||||
    
 | 
			
		||||
    $html .= $this->generaCamposFormulario($datos);
 | 
			
		||||
    $html .= '</form>';
 | 
			
		||||
    return $html;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private function generaListaErrores($errores) {
 | 
			
		||||
    $html='';
 | 
			
		||||
    $numErrores = count($errores);
 | 
			
		||||
    if (  $numErrores == 1 ) {
 | 
			
		||||
      $html .= "<ul><li>".$errores[0]."</li></ul>";
 | 
			
		||||
    } else if ( $numErrores > 1 ) {
 | 
			
		||||
      $html .= "<ul><li>";
 | 
			
		||||
      $html .= implode("</li><li>", $errores);
 | 
			
		||||
      $html .= "</li></ul>";
 | 
			
		||||
    }
 | 
			
		||||
    return $html;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private function csrfguard_GenerateToken($formId) {
 | 
			
		||||
    if ( ! isset($_SESSION) ) {
 | 
			
		||||
      throw new Exception('La sesión del usuario no está definida.');
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
	  if ( function_exists('hash_algos') && in_array('sha512', hash_algos()) ) {
 | 
			
		||||
		  $token = hash('sha512', mt_rand(0, mt_getrandmax()));
 | 
			
		||||
	  }	else {
 | 
			
		||||
		  $token=' ';
 | 
			
		||||
		  for ($i=0;$i<128;++$i) {
 | 
			
		||||
			  $r=mt_rand(0,35);
 | 
			
		||||
			  if ($r<26){
 | 
			
		||||
				  $c=chr(ord('a')+$r);
 | 
			
		||||
			  }	else{ 
 | 
			
		||||
				  $c=chr(ord('0')+$r-26);
 | 
			
		||||
			  } 
 | 
			
		||||
			  $token.=$c;
 | 
			
		||||
		  }
 | 
			
		||||
	  }
 | 
			
		||||
 | 
			
		||||
    $_SESSION[$formId.'_'.self::CSRF_PARAM]=$token;
 | 
			
		||||
 | 
			
		||||
	  return $token;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private function csrfguard_ValidateToken($formId, $tokenRecibido) {
 | 
			
		||||
    if ( ! isset($_SESSION) ) {
 | 
			
		||||
      throw new Exception('La sesión del usuario no está definida.');
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    $result = TRUE;
 | 
			
		||||
    
 | 
			
		||||
    if ( isset($_SESSION[$formId.'_'.self::CSRF_PARAM]) ) {
 | 
			
		||||
      if ( $_SESSION[$formId.'_'.self::CSRF_PARAM] !== $tokenRecibido ) {
 | 
			
		||||
        $result = array();
 | 
			
		||||
        $result[] = 'Has enviado el formulario dos veces';
 | 
			
		||||
      }
 | 
			
		||||
      $_SESSION[$formId.'_'.self::CSRF_PARAM] = ' ';
 | 
			
		||||
      unset($_SESSION[$formId.'_'.self::CSRF_PARAM]);
 | 
			
		||||
    } else {
 | 
			
		||||
      $result = array();
 | 
			
		||||
      $result[] = 'Formulario no válido';
 | 
			
		||||
    }
 | 
			
		||||
	  return $result;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
class Formulario {
 | 
			
		||||
 | 
			
		||||
    private $formId;
 | 
			
		||||
    private $action;
 | 
			
		||||
    private $classAtt;
 | 
			
		||||
    private $enctype;
 | 
			
		||||
 | 
			
		||||
    public function __construct($formId, $opciones = array() )  {
 | 
			
		||||
        $this->formId = $formId;
 | 
			
		||||
        $opcionesPorDefecto = array( 'ajax' => false, 'action' => null, 'class' => null,
 | 
			
		||||
                                    'enctype' => null );
 | 
			
		||||
        $opciones = array_merge($opcionesPorDefecto, $opciones);
 | 
			
		||||
 | 
			
		||||
        $this->ajax     = $opciones['ajax'];
 | 
			
		||||
        $this->action   = $opciones['action'];
 | 
			
		||||
        $this->classAtt = $opciones['class'];
 | 
			
		||||
        $this->enctype  = $opciones['enctype'];
 | 
			
		||||
        
 | 
			
		||||
        if (!$this->action) {
 | 
			
		||||
            $app = Aplicacion::getSingleton();
 | 
			
		||||
            $this->action = htmlspecialchars($_SERVER['REQUEST_URI']);
 | 
			
		||||
            $this->action = $app->resuelve($this->action);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
?>
 | 
			
		||||
@@ -1,104 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
include_once('user_dao.php');
 | 
			
		||||
include_once('../assets/php/form.php');
 | 
			
		||||
 | 
			
		||||
class FormLogin extends Form {
 | 
			
		||||
    //Constants:
 | 
			
		||||
    const HTML5_EMAIL_REGEXP = '^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$'; 
 | 
			
		||||
 | 
			
		||||
    //Atributes:
 | 
			
		||||
    private $user;  // User who is going to log-in.
 | 
			
		||||
    private $reply; // Validation response
 | 
			
		||||
 | 
			
		||||
    //Constructor:
 | 
			
		||||
    public function __construct() {
 | 
			
		||||
        parent::__construct('formLogin');
 | 
			
		||||
        $this->reply = array();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //Methods:
 | 
			
		||||
 | 
			
		||||
    //Returns validation response:
 | 
			
		||||
    public function getReply() {
 | 
			
		||||
        
 | 
			
		||||
        if(isset($_SESSION["login"])){
 | 
			
		||||
            $name = strtoupper($_SESSION['nombre']);
 | 
			
		||||
            $this->reply = "<h1>Bienvenido {$_SESSION['nombre']}</h1><hr />
 | 
			
		||||
                        <p>{$name}, has iniciado sesión correctamente.</p>
 | 
			
		||||
                        <p>Usa los botones para navegar</p>
 | 
			
		||||
                        <a href='../'><button>Inicio</button></a>
 | 
			
		||||
                        <a href='../../panel_{$_SESSION["rol"]}'><button>Mi Panel</button></a>\n";
 | 
			
		||||
        }   
 | 
			
		||||
        else if(!isset($_SESSION["login"])){
 | 
			
		||||
            $this->reply = "<h1>ERROR</h1><hr />".
 | 
			
		||||
                        "<p>El usuario o contraseña no son válidos.</p>
 | 
			
		||||
                        <p>Vuelve a intetarlo o regístrate si no lo habías hecho previamente.</p>
 | 
			
		||||
                        <a href='./'><button>Iniciar Sesión</button></a>
 | 
			
		||||
                        <form method='post' action='./'><button name='register' id='register'>Registro</button></form>\n";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->reply;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //Process form:
 | 
			
		||||
    public function processesForm($name, $pass) {
 | 
			
		||||
        $login = true;
 | 
			
		||||
        $name = $this->test_input($name); 
 | 
			
		||||
        $pass = $this->test_input($pass);
 | 
			
		||||
 | 
			
		||||
        $username = isset($name) ? $name : null ;
 | 
			
		||||
        if (!$username) {
 | 
			
		||||
          $login = false;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        /*
 | 
			
		||||
        $email = isset($mail) ? $mail : null ;
 | 
			
		||||
        if (!$email || !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $email)) {
 | 
			
		||||
          $login = false;
 | 
			
		||||
        }
 | 
			
		||||
        */
 | 
			
		||||
    
 | 
			
		||||
        $password = isset($pass) ? $pass : null ;
 | 
			
		||||
        if (!$password || mb_strlen($password) < 4) {
 | 
			
		||||
          $login = false;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if ($login) {
 | 
			
		||||
            $bd = new UserDAO('complucine');
 | 
			
		||||
            if($bd){
 | 
			
		||||
                $selectUser = $bd->selectUser($username);
 | 
			
		||||
                $selectUser->data_seek(0);
 | 
			
		||||
                while ($fila = $selectUser->fetch_assoc()) {
 | 
			
		||||
                    if($username === $fila['username'] && $bd->verifyPass($password, $fila['passwd'])){ 
 | 
			
		||||
                        $this->user = $bd->loadUser($fila['id'], $fila['username'], $fila['email'], $fila['passwd'], $fila['rol']);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
                try{
 | 
			
		||||
                    if ($this->user) {
 | 
			
		||||
                        $_SESSION['user'] = $this->user;
 | 
			
		||||
                        $_SESSION["nombre"] = $this->user->getName();
 | 
			
		||||
                        $_SESSION["login"] = $login;
 | 
			
		||||
                        $_SESSION["rol"] = $this->user->getRol();
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                catch (Exception $e){
 | 
			
		||||
                    $_SESSION["login"] = $login;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                mysqli_free_result($selectUser);
 | 
			
		||||
                //$selectUser->free();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function test_input($input){
 | 
			
		||||
        return htmlspecialchars(trim(strip_tags($input)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
@@ -1,83 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
	require_once('../assets/php/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);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
@@ -1,37 +0,0 @@
 | 
			
		||||
<?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; }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
?>
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
<?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