From 709ac9f3d4157fe0f988ef2131aa24e7c4af25f0 Mon Sep 17 00:00:00 2001 From: adrireal <80281789+adrireal@users.noreply.github.com> Date: Tue, 11 May 2021 13:15:13 +0200 Subject: [PATCH] Add files via upload --- panel_user/includes/formDeleteAccount.php | 85 +++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/panel_user/includes/formDeleteAccount.php b/panel_user/includes/formDeleteAccount.php index 15c5adc..dedec95 100644 --- a/panel_user/includes/formDeleteAccount.php +++ b/panel_user/includes/formDeleteAccount.php @@ -1,3 +1,88 @@ "./?option=delete_user"); + parent::__construct('formDelete', $options); + } + + // Metodos + // Generar formulario + protected function generaCamposFormulario($datos, $errores = array()){ + $nombre = $datos['nombreUsuario'] ?? ''; + + // Se generan los mensajes de error si existen. + $htmlErroresGlobales = self::generaListaErroresGlobales($errores); + $errorPassword = self::createMensajeError($errores, 'pass', 'span', array('class' => 'error')); + + $html = "
+
".$htmlErroresGlobales."
+ Eliminar usuario +
".$errorPassword."
+
+ + +
+
"; + + return $html; + } + + // Procesar el formulario + protected function procesaFormulario($datos){ + $result = array(); + + $password = $datos['pass'] ?? null; + if ( empty($password) || mb_strlen($password) < 4 ) { + $result['pass'] = "Vuelve a introducir tu contrseña."; + } + + if (count($result) === 0) { + $bd = new UserDAO("complucine"); + $user = $bd->selectUser(unserialize($_SESSION['user'])->getName(), $password); + if (!$user) { + $result[] = "Ha ocurrido un problema\nal eliminar el usuario."; + $_SESSION['message'] = "
+
+
+
+

Ha ocurrido un problema


+

No se ha podido eliminar el usuario. + Comprueba que la contraseña introducida sea correcta.

+ +
+
+
+
+ "; + } + else { + $bd->deleteUser(unserialize($_SESSION['user'])->getId()); + $_SESSION['message'] = "
+
+
+
+

Operacion realizada con exito


+

Se ha eliminado su usuario correctamente.

+ +
+
+
+
+ "; + $result = '/logout/index.php'; + } + } + return $result; + } + + protected function test_input($input){ + return htmlspecialchars(trim(strip_tags($input))); + } +} ?> \ No newline at end of file