Add files via upload
This commit is contained in:
parent
40e74c9eff
commit
bb94e30282
@ -44,6 +44,4 @@
|
||||
* @see http://php.net/manual/en/language.types.callable.php
|
||||
*/
|
||||
register_shutdown_function(array($app, 'shutdown'));
|
||||
|
||||
|
||||
?>
|
||||
|
@ -1,3 +1,85 @@
|
||||
<?php
|
||||
require_once('../assets/php/form.php');
|
||||
include_once('../assets/php/common/user.php');
|
||||
|
||||
class FormChangeEmail extends Form {
|
||||
|
||||
public function __construct() {
|
||||
$options = array("action" => "./?option=manage_profile");
|
||||
parent::__construct('formChangeUserEmail', $options);
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos, $errores = array()){
|
||||
$nombre = $datos['nombreUsuario'] ?? '';
|
||||
|
||||
// Se generan los mensajes de error si existen.
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorNombre = self::createMensajeError($errores, 'nombre', 'span', array('class' => 'error'));
|
||||
$errorPassword = self::createMensajeError($errores, 'pass', 'span', array('class' => 'error'));
|
||||
$errorPassword2 = self::createMensajeError($errores, 'repass', 'span', array('class' => 'error'));
|
||||
|
||||
$html = '<div class="row">'.$htmlErroresGlobales.'
|
||||
<fieldset id="email_usuario">
|
||||
<legend>Nuevo email de usuario</legend>
|
||||
<div class="_new_email">
|
||||
<input type="text" name="new_email" id="new_email" value="" placeholder="Nuevo Email" required/>
|
||||
</div>
|
||||
<div class="_passwd">
|
||||
<input type="password" name="pass" id="pass" value="" placeholder="Contraseña" required/>
|
||||
</div>
|
||||
<div class="_passwd">
|
||||
<input type="password" name="repass" id="repass" value="" placeholder="Repita la contraseña" required/>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Cambiar Nombre de Usuario" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/* TODO */
|
||||
protected function procesaFormulario($datos){
|
||||
$result = array();
|
||||
|
||||
$nombre = $datos['new_name'] ?? null;
|
||||
if ( empty($nombre) || mb_strlen($nombre) < 5 ) {
|
||||
$result['new_name'] = "El nombre tiene que tener una longitud de al menos 5 caracteres.";
|
||||
}
|
||||
|
||||
$password = $datos['pass'] ?? null;
|
||||
if ( empty($password) || mb_strlen($password) < 5 ) {
|
||||
$result['pass'] = "El password tiene que tener una longitud de al menos 5 caracteres.";
|
||||
}
|
||||
$password2 = $datos['repass'] ?? null;
|
||||
if ( empty($password2) || strcmp($password, $password2) !== 0 ) {
|
||||
$result['repass'] = "Los passwords deben coincidir";
|
||||
}
|
||||
|
||||
if (count($result) === 0) {
|
||||
$bd = new UserDAO("complucine");
|
||||
$user = $bd->selectUser(unserialize($_SESSION['user'])->getName(), $password);
|
||||
if (!$user) {
|
||||
$result[] = "El usuario no existe.";
|
||||
} else {
|
||||
$bd->changeUserName(unserialize($_SESSION['user'])->getId(), $username);
|
||||
$user = $bd->selectUser($username, $password);
|
||||
if (!$user){
|
||||
$result[] = "Ha ocurrido un probrema al actualizar el nombre de usuario.";
|
||||
}else{
|
||||
$_SESSION['user'] = serialize($user);
|
||||
$_SESSION["nombre"] = $user->getName();
|
||||
$result = './?option=manage_profile';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function test_input($input){
|
||||
return htmlspecialchars(trim(strip_tags($input)));
|
||||
}
|
||||
}
|
||||
?>
|
@ -36,10 +36,10 @@ class FormChangeName extends Form {
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
protected function procesaFormulario($datos){
|
||||
$result = array();
|
||||
|
||||
@ -81,3 +81,4 @@ class FormChangeName extends Form {
|
||||
return htmlspecialchars(trim(strip_tags($input)));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,3 +1,85 @@
|
||||
<?php
|
||||
require_once('../assets/php/form.php');
|
||||
include_once('../assets/php/common/user.php');
|
||||
|
||||
class FormChangePass extends Form {
|
||||
|
||||
public function __construct() {
|
||||
$options = array("action" => "./?option=manage_profile");
|
||||
parent::__construct('formChangeUserPass', $options);
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos, $errores = array()){
|
||||
$nombre = $datos['nombreUsuario'] ?? '';
|
||||
|
||||
// Se generan los mensajes de error si existen.
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorNombre = self::createMensajeError($errores, 'nombre', 'span', array('class' => 'error'));
|
||||
$errorPassword = self::createMensajeError($errores, 'pass', 'span', array('class' => 'error'));
|
||||
$errorPassword2 = self::createMensajeError($errores, 'repass', 'span', array('class' => 'error'));
|
||||
|
||||
$html = '<div class="row">'.$htmlErroresGlobales.'
|
||||
<fieldset id="contraseña_usuario">
|
||||
<legend>Contraseña Actual</legend>
|
||||
<div class="_passwd">
|
||||
<input type="password" name="old_pass" id="old_pass" value="" placeholder="Contraseña Actual" required/>
|
||||
</div>
|
||||
<div class="_passwd">
|
||||
<input type="password" name="pass" id="pass" value="" placeholder="Nueva Contraseña" required/>
|
||||
</div>
|
||||
<div class="_passwd">
|
||||
<input type="password" name="repass" id="repass" value="" placeholder="Repita la nueva contraseña" required/>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Cambiar Contraseña" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/* TODO */
|
||||
protected function procesaFormulario($datos){
|
||||
$result = array();
|
||||
|
||||
$nombre = $datos['new_name'] ?? null;
|
||||
if ( empty($nombre) || mb_strlen($nombre) < 5 ) {
|
||||
$result['new_name'] = "El nombre tiene que tener una longitud de al menos 5 caracteres.";
|
||||
}
|
||||
|
||||
$password = $datos['pass'] ?? null;
|
||||
if ( empty($password) || mb_strlen($password) < 5 ) {
|
||||
$result['pass'] = "El password tiene que tener una longitud de al menos 5 caracteres.";
|
||||
}
|
||||
$password2 = $datos['repass'] ?? null;
|
||||
if ( empty($password2) || strcmp($password, $password2) !== 0 ) {
|
||||
$result['repass'] = "Los passwords deben coincidir";
|
||||
}
|
||||
|
||||
if (count($result) === 0) {
|
||||
$bd = new UserDAO("complucine");
|
||||
$user = $bd->selectUser(unserialize($_SESSION['user'])->getName(), $password);
|
||||
if (!$user) {
|
||||
$result[] = "El usuario no existe.";
|
||||
} else {
|
||||
$bd->changeUserName(unserialize($_SESSION['user'])->getId(), $username);
|
||||
$user = $bd->selectUser($username, $password);
|
||||
if (!$user){
|
||||
$result[] = "Ha ocurrido un probrema al actualizar el nombre de usuario.";
|
||||
}else{
|
||||
$_SESSION['user'] = serialize($user);
|
||||
$_SESSION["nombre"] = $user->getName();
|
||||
$result = './?option=manage_profile';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function test_input($input){
|
||||
return htmlspecialchars(trim(strip_tags($input)));
|
||||
}
|
||||
}
|
||||
?>
|
@ -32,6 +32,12 @@
|
||||
$formCN = new FormChangeName();
|
||||
$htmlFormChangeName = $formCN->gestiona();
|
||||
|
||||
$formCP = new FormChangePass();
|
||||
$htmlFormChangePass = $formCP->gestiona();
|
||||
|
||||
$formCE = new FormChangeEmail();
|
||||
$htmlFormChangeEmail = $formCE->gestiona();
|
||||
|
||||
return $reply = '<!-- Change User Name -->
|
||||
<div class="column side">
|
||||
<h2>Cambiar nombre de usuario</h2>
|
||||
@ -39,49 +45,11 @@
|
||||
</div>
|
||||
<div class="column middle">
|
||||
<h2>Cambiar contraseña</h2>
|
||||
<form method="post" action="./includes/formChangePass.php">
|
||||
<div class="row">
|
||||
<fieldset id="contraseña_usuario">
|
||||
<legend>Contraseña Actual</legend>
|
||||
<div class="_passwd">
|
||||
<input type="password" name="old_pass" id="old_pass" value="" placeholder="Contraseña Actual" required/>
|
||||
</div>
|
||||
<div class="_passwd">
|
||||
<input type="password" name="pass" id="pass" value="" placeholder="Nueva Contraseña" required/>
|
||||
</div>
|
||||
<div class="_passwd">
|
||||
<input type="password" name="repass" id="repass" value="" placeholder="Repita la nueva contraseña" required/>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Cambiar Contraseña" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
'.$htmlFormChangePass.'
|
||||
</div>
|
||||
<div class="column side">
|
||||
<h2>Cambiar email de usuario</h2>
|
||||
<form method="post" action="./includes/formChangeEmail.php">
|
||||
<div class="row">
|
||||
<fieldset id="email_usuario">
|
||||
<legend>Nuevo email de usuario</legend>
|
||||
<div class="_new_email">
|
||||
<input type="text" name="new_email" id="new_email" value="" placeholder="Nuevo Email" required/>
|
||||
</div>
|
||||
<div class="_passwd">
|
||||
<input type="password" name="pass" id="pass" value="" placeholder="Contraseña" required/>
|
||||
</div>
|
||||
<div class="_passwd">
|
||||
<input type="password" name="repass" id="repass" value="" placeholder="Repita la contraseña" required/>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Cambiar Nombre de Usuario" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
'.$htmlFormChangeEmail.'
|
||||
</div>'."\n";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user