Delete panel_user directory

This commit is contained in:
Fernando Méndez 2021-07-02 17:54:45 +02:00 committed by GitHub
parent e1fe17d695
commit c657675b6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 0 additions and 780 deletions

View File

@ -1,104 +0,0 @@
<?php
require_once('../assets/php/form.php');
include_once('../assets/php/includes/user.php');
class FormChangeEmail 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])?)*$';
public function __construct() {
$options = array("action" => "./?option=manage_profile");
parent::__construct('formChangeUserEmail', $options);
}
protected function generaCamposFormulario($datos, $errores = array()){
$email = $datos['email'] ?? '';
// Se generan los mensajes de error si existen.
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
$errorEmail = self::createMensajeError($errores, 'new_email', 'span', array('class' => 'error'));
$errorEmail2 = self::createMensajeError($errores, 'remail', 'span', array('class' => 'error'));
$errorPassword = self::createMensajeError($errores, 'pass', 'span', array('class' => 'error'));
$html = "<div class='row'>
<fieldset id='email_usuario'><pre>".$htmlErroresGlobales."</pre>
<legend>Nuevo email de usuario</legend>
<input type='text' name='new_email' id='new_email' value='' placeholder='Nuevo Email' required/><pre>".$errorEmail."</pre>
<span id='emailValid'>&#x2714;</span></span><span id='emailInvalid'>&#x274C;</span>
<input type='text' name='remail' id='remail' value='' placeholder='Repita el email' required/><pre>".$errorEmail2."</pre>
<input type='password' name='pass' id='pass' value='' placeholder='Contraseña' required/><pre>".$errorPassword."</pre>
</fieldset>
<div class='actions'>
<input type='submit' id='submit' value='Cambiar Email de Usuario' class='primary' />
<input type='reset' id='reset' value='Borrar' />
</div>
</div>";
return $html;
}
protected function procesaFormulario($datos){
$result = array();
$email = $this->test_input($datos['new_email']) ?? null;
if ( empty($email) || !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $email) ) {
$result['new_email'] = "El nuevo email no es válido.";
}
$email2 = $this->test_input($datos['remail']) ?? null;
if ( empty($email2) || strcmp($email, $email2) !== 0 ) {
$result['remail'] = "Los emails deben coincidir";
}
$password = $this->test_input($datos['pass']) ?? null;
if ( empty($password) || mb_strlen($password) < 4 ) {
$result['pass'] = "El password tiene que tener\n una longitud de al menos\n 4 caracteres.";
}
if (count($result) === 0) {
$bd = new UserDAO("complucine");
$user = $bd->selectUser(unserialize($_SESSION['user'])->getName(), $password);
if (!$user) {
$result[] = "El usuario no existe.";
$_SESSION['message'] = "<div class='row'>
<div class='column side'></div>
<div class='column middle'>
<div class='code info'>
<h1>Ha ocurrido un probrema</h1><hr />
<p>No hemos podido actualizar su email de usuario.
Comprueba que la contraseña introducida sea correcta.</p>
<a href=''><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
} else {
$user = $bd->selectUserEmail($email);
if ($user->data_seek(0)){
$result[] = "El email ya está registrado.";
} else {
$bd->changeUserEmail(unserialize($_SESSION['user'])->getId(), $email);
$user = $bd->selectUser(unserialize($_SESSION['user'])->getName(), $password);
$_SESSION['user'] = serialize($user);
$_SESSION["nombre"] = $user->getName();
$_SESSION['message'] = "<div class='row'>
<div class='column side'></div>
<div class='column middle'>
<div class='code info'>
<h1>Operacion realizada con exito</h1><hr />
<p>Se ha modificado su email correctamente.</p>
<a href=''><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
$result = './?option=manage_profile';
}
}
}
return $result;
}
}
?>

View File

@ -1,110 +0,0 @@
<?php
require_once('../assets/php/form.php');
include_once('../assets/php/includes/user.php');
include_once('../assets/php/includes/user_dao.php');
class FormChangeName extends Form {
public function __construct() {
$options = array("action" => "./?option=manage_profile");
parent::__construct('formChangeUserName', $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, 'new_name', 'span', array('class' => 'error'));
$errorNombre2 = self::createMensajeError($errores, 'rename', 'span', array('class' => 'error'));
$errorPassword = self::createMensajeError($errores, 'pass', 'span', array('class' => 'error'));
$html = "<div class='row'>
<fieldset id='nombre_usuario'><pre>".$htmlErroresGlobales."</pre>
<legend>Nuevo Nombre de usuario</legend>
<input type='text' name='new_name' id='new_name' value='' placeholder='Nuevo Nombre' required/><pre>".$errorNombre."</pre>
<span id='userValid'>&#x2714;</span><span id='userWarning'>&#x26a0;</span></span><span id='userInvalid'>&#x274C;</span>
<input type='text' name='rename' id='rename' value='' placeholder='Repita el nombre' required/><pre>".$errorNombre2."</pre>
<input type='password' name='pass' id='pass' value='' placeholder='Contraseña' required/><pre>".$errorPassword."</pre>
</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;
}
protected function procesaFormulario($datos){
$result = array();
$nombre = $this->test_input($datos['new_name']) ?? null;
$nombre = strtolower($nombre);
if ( empty($nombre) || mb_strlen($nombre) < 3 || mb_strlen($nombre) > 15 ) {
$result['new_name'] = "El nombre tiene que tener\n una longitud de al menos\n 3 caracteres\n y menos de 15 caracteres.";
}
$nombre2 = $this->test_input($datos['rename']) ?? null;
if ( empty($nombre2) || strcmp($nombre, $nombre2) !== 0 ) {
$result['rename'] = "Los nombres deben coincidir.";
}
$password = $this->test_input($datos['pass']) ?? null;
if ( empty($password) || mb_strlen($password) < 4 ) {
$result['pass'] = "El password tiene que tener\n una longitud de al menos\n 4 caracteres.";
}
if (count($result) === 0) {
$bd = new UserDAO("complucine");
$user = $bd->selectUser(unserialize($_SESSION['user'])->getName(), $password);
if (!$user) {
$result[] = "Ha ocurrido un problema\nal actualizar el nombre de usuario.";
$_SESSION['message'] = "<div class='row'>
<div class='column side'></div>
<div class='column middle'>
<div class='code info'>
<h1>Ha ocurrido un probrema</h1><hr />
<p>No hemos podido actualizar su nombre de usuario.
Comprueba que la contraseña introducida sea correcta.</p>
<a href=''><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
} else {
$user = $bd->selectUserName($nombre);
if ($user->data_seek(0)){
$result[] = "El nombre de usuario ya existe.";
} else {
$bd->changeUserName(unserialize($_SESSION['user'])->getId(), $nombre);
$user = $bd->selectUser($nombre, $password);
$actual_img = "../img/users/".unserialize($_SESSION['user'])->getName().".jpg";
$new_img = "../img/users/".$nombre.".jpg";
copy($actual_img, $new_img);
unlink($actual_img);
$_SESSION['user'] = serialize($user);
$_SESSION["nombre"] = $user->getName();
$_SESSION['message'] = "<div class='row'>
<div class='column side'></div>
<div class='column middle'>
<div class='code info'>
<h1>Operacion realizada con exito</h1><hr />
<p>Se ha modificado su nombre de usuario correctamente.</p>
<a href=''><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
$result = './?option=manage_profile';
}
}
}
return $result;
}
}
?>

View File

@ -1,95 +0,0 @@
<?php
require_once('../assets/php/form.php');
include_once('../assets/php/includes/user.php');
class FormChangePass extends Form {
//Constants:
const HTML5_PASS_REGEXP = '^(?=\w*\d)(?=\w*[A-Z])(?=\w*[a-z])\S{4,16}$';
public function __construct() {
$options = array("action" => "./?option=manage_profile");
parent::__construct('formChangeUserPass', $options);
}
protected function generaCamposFormulario($datos, $errores = array()){
// Se generan los mensajes de error si existen.
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
$errorOldPass = self::createMensajeError($errores, 'old_pass', 'span', array('class' => 'error'));
$errorPassword = self::createMensajeError($errores, 'new_pass', 'span', array('class' => 'error'));
$errorPassword2 = self::createMensajeError($errores, 'repass', 'span', array('class' => 'error'));
$html = "<div class='row'>
<fieldset id='contraseña_usuario'><pre>".$htmlErroresGlobales."</pre>
<legend>Nueva Contraseña</legend>
<input type='password' name='old_pass' id='old_pass' value='' placeholder='Contraseña Actual' required/><pre>".$errorOldPass."</pre>
<input type='password' name='new_pass' id='new_pass' value='' placeholder='Nueva Contraseña' required/><pre>".$errorPassword."</pre>
<span id='passValid'>&#x2714;</span><span id='passWarning'>&#x26a0;</span></span><span id='passInvalid'>&#x274C;</span>
<input type='password' name='repass' id='repass' value='' placeholder='Repita la nueva contraseña' required/><pre>".$errorPassword2."</pre>
<span id='repassValid'>&#x2714;</span></span><span id='repassInvalid'>&#x274C;</span>
</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;
}
protected function procesaFormulario($datos){
$result = array();
$old_pass = $this->test_input($datos['old_pass']) ?? null;
if ( empty($old_pass) || mb_strlen($old_pass) < 4 ) {
$result['old_pass'] = "El password tiene que tener\n una longitud de al menos\n 4 caracteres.";
}
$password = $this->test_input($datos['new_pass']) ?? null;
if ( empty($password) || !mb_ereg_match(self::HTML5_PASS_REGEXP, $password) ) {
$result['new_pass'] = "El password tiene que tener\n una longitud de al menos\n 4 caracteres 1 mayúscula y 1 número.";
}
$password2 = $this->test_input($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(), $old_pass);
if (!$user) {
$result[] = "Ha ocurrido un problema\nal actualizar la contraseña.";
$_SESSION['message'] = "<div class='row'>
<div class='column side'></div>
<div class='column middle'>
<div class='code info'>
<h1>Ha ocurrido un probrema</h1><hr />
<p>No hemos podido actualizar su contraseña de usuario.
Comprueba que la contraseña actual sea correcta.</p>
<a href=''><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
} else {
$bd->changeUserPass(unserialize($_SESSION['user'])->getId(), $password);
$_SESSION['message'] = "<div class='row'>
<div class='column side'></div>
<div class='column middle'>
<div class='code info'>
<h1>Operacion realizada con exito</h1><hr />
<p>Se ha modificado su contraseña de usuario correctamente.</p>
<a href=''><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
$result = './?option=manage_profile';
}
}
return $result;
}
}
?>

View File

@ -1,99 +0,0 @@
<?php
require_once('../assets/php/form.php');
include_once('../assets/php/includes/user.php');
include_once('../assets/php/includes/user_dao.php');
class FormDeleteAccount 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])?)*$';
public function __construct() {
$options = array("action" => "./?option=delete_user");
parent::__construct('formDeleteAccount', $options);
}
protected function generaCamposFormulario($datos, $errores = array()){
$nameValue = "value=".unserialize($_SESSION['user'])->getName()."";
$emailValue = "value=".unserialize($_SESSION['user'])->getEmail()."";
// Se generan los mensajes de error si existen.
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
$errorNombre = self::createMensajeError($errores, 'new_name', 'span', array('class' => 'error'));
$errorEmail = self::createMensajeError($errores, 'email', 'span', array('class' => 'error'));
$errorPassword = self::createMensajeError($errores, 'pass', 'span', array('class' => 'error'));
$errorPassword2 = self::createMensajeError($errores, 'repass', 'span', array('class' => 'error'));
$errorVerify = self::createMensajeError($errores, 'verify', 'span', array('class' => 'error'));
$html = "<div class='row'>
<fieldset id='cuenta_usuario'><pre>".$htmlErroresGlobales."</pre><pre>".$errorVerify."</pre>
<legend>Datos de la cuenta</legend>
<input type='text' name='name' id='name' ".$nameValue." placeholder='Nombre de usuario' required/><pre>".$errorNombre."</pre>
<input type='text' name='email' id='email' ".$emailValue." placeholder='Email de usuario' required/><pre>".$errorEmail."</pre>
<input type='password' name='pass' id='new_pass' value='' placeholder='Contraseña' required/><pre>".$errorPassword."</pre>
<input type='password' name='repass' id='repass' value='' placeholder='Repita la contraseña' required/><pre>".$errorPassword2."</pre>
<span id='repassValid'>&#x2714;</span></span><span id='repassInvalid'>&#x274C;</span>
</fieldset>
<div class='verify'>
<input type='checkbox' id='checkbox' name='verify' required>
<label for='verify'>Al marcar esta casilla, verifica y entiende que esta acción no se puede deshacer.</label>
</div>
<div class='actions'>
<!-- <input type='submit' id='submit' value='Eliminar Cuenta de Usuario' class='primary' /> -->
<button class='danger' onclick='confirmDelete(event)'>Eliminar Usuario</button>
</div>
</div>";
return $html;
}
protected function procesaFormulario($datos){
$result = array();
$nombre = $this->test_input($datos['name']) ?? null;
$nombre = strtolower($nombre);
if ( empty($nombre) || mb_strlen($nombre) < 3 || mb_strlen($nombre) > 15 ) {
$result['new_name'] = "El nombre tiene que tener\n una longitud de al menos\n 3 caracteres\n y menos de 15 caracteres.";
}
$email = $this->test_input($datos['email']) ?? null;
if ( empty($email) || !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $email) ) {
$result['email'] = "El email no es válido.";
}
$password = $this->test_input($datos['pass']) ?? null;
if ( empty($password) || mb_strlen($password) < 4 ) {
$result['pass'] = "El password tiene que tener\n una longitud de al menos\n 4 caracteres.";
}
$password2 = $this->test_input($datos['repass']) ?? null;
if ( empty($password2) || strcmp($password, $password2) !== 0 ) {
$result['repass'] = "Los passwords deben coincidir.";
}
$verify = $this->test_input($datos['verify']) ?? null;
if ( empty($verify) ) {
$result['verify'] = "Debe confirmar la casilla de verificación.";
}
if (count($result) === 0) {
$bd = new UserDAO("complucine");
$user = $bd->selectUser($nombre, $password);
if (!$user) {
$result[] = "El usuario o contraseña\nno son correctos.";
} else {
if( (unserialize($_SESSION['user'])->getId() === $user->getId()) && ($nombre === $user->getName())
&& ($email === $user->getEmail()) && ($bd->verifyPass($password, $user->getPass())) ){
$bd->deleteUserAccount($user->getId());
unset($_SESSION);
session_destroy();
$result = ROUTE_APP;
} else {
$result[] = "Los datos introducidos\nno son válidos.";
}
}
}
return $result;
}
}
?>

View File

@ -1,125 +0,0 @@
<?php
require_once('../assets/php/form.php');
include_once('../assets/php/includes/user.php');
class FormUploadFiles extends Form {
const EXTENSIONS = array('gif','jpg','jpe','jpeg','png');
public function __construct() {
$options = array("enctype" => "multipart/form-data", "action" => "./?option=change_profile_pic");
parent::__construct('formUploadFiles', $options);
}
protected function generaCamposFormulario($datos, $errores = array()) {
// Se generan los mensajes de error si existen.
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
$errorFile = self::createMensajeError($errores, 'archivo', 'span', array('class' => 'error'));
foreach($datos as $key => $value){
$dats = $key." ".$value." ";
}
// Se genera el HTML asociado a los campos del formulario y los mensajes de error.
$html = '
<div class="file">
<input type="file" name="archivo" id="archivo" /><pre>'.$htmlErroresGlobales.'</pre>
</div>
<input type="submit" id="submit" value="Subir" class="primary" /><pre>'.$errorFile.'</pre>
';
return $html;
}
protected function procesaFormulario($datos) {
// Solo se pueden definir arrays como constantes en PHP >= 5.6
global $ALLOWED_EXTENSIONS;
$result = array();
$ok = count($_FILES) == 1 && $_FILES['archivo']['error'] == UPLOAD_ERR_OK;
if ( $ok ) {
$nombre = $_FILES['archivo']['name'];
//1.a) Valida el nombre del archivo
$ok = $this->check_file_uploaded_name($nombre) && $this->check_file_uploaded_length($nombre) ;
// 1.b) Sanitiza el nombre del archivo
//$ok = $this->sanitize_file_uploaded_name($nombre);
//
// 2. comprueba si la extensión está permitida
$ok = $ok && in_array(pathinfo($nombre, PATHINFO_EXTENSION), self::EXTENSIONS);
// 3. comprueba el tipo mime del archivo correspode a una imagen image
$finfo = new \finfo(FILEINFO_MIME_TYPE);
$mimeType = $finfo->file($_FILES['archivo']['tmp_name']);
$ok = preg_match('/image\/*./', $mimeType);
//finfo_close();
if ( $ok ) {
$tmp_name = $_FILES['archivo']['tmp_name'];
$new_name = strtolower(unserialize($_SESSION["user"])->getName()).".jpg";
if ( !move_uploaded_file($tmp_name, "../img/users/{$new_name}") ) {
$result['img'] = 'Error al mover el archivo';
}
$result = "./";
} else {
$result["errorFile"] = 'El archivo tiene un nombre o tipo no soportado';
}
} else {
$result[] = 'Error al subir el archivo.';
}
return $result;
}
/**
* Check $_FILES[][name]
*
* @param (string) $filename - Uploaded file name.
* @author Yousef Ismaeil Cliprz
* @See http://php.net/manual/es/function.move-uploaded-file.php#111412
*/
protected function check_file_uploaded_name($filename) {
return (bool) ((mb_ereg_match('/^[0-9A-Z-_\.]+$/i', $filename) === 1) ? true : false );
}
/**
* Sanitize $_FILES[][name]. Remove anything which isn't a word, whitespace, number
* or any of the following caracters -_~,;[]().
*
* If you don't need to handle multi-byte characters you can use preg_replace
* rather than mb_ereg_replace.
*
* @param (string) $filename - Uploaded file name.
* @author Sean Vieira
* @see http://stackoverflow.com/a/2021729
*/
protected function sanitize_file_uploaded_name($filename) {
/* Remove anything which isn't a word, whitespace, number
* or any of the following caracters -_~,;[]().
* If you don't need to handle multi-byte characters
* you can use preg_replace rather than mb_ereg_replace
* Thanks @Łukasz Rysiak!
*/
$newName = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $filename);
// Remove any runs of periods (thanks falstro!)
$newName = mb_ereg_replace("([\.]{2,})", '', $newName);
return $newName;
}
/**
* Check $_FILES[][name] length.
*
* @param (string) $filename - Uploaded file name.
* @author Yousef Ismaeil Cliprz.
* @See http://php.net/manual/es/function.move-uploaded-file.php#111412
*/
protected function check_file_uploaded_length ($filename) {
return (bool) ((mb_strlen($filename,'UTF-8') < 250) ? true : false);
}
}
?>

View File

@ -1,59 +0,0 @@
<?php
//General Config File:
require_once('../assets/php/config.php');
//Controller file:
include_once('panelUser.php');
if($_SESSION["login"] && $_SESSION["rol"] === "user"){
if(!isset($_GET["option"])) $_GET["option"] = null;
switch($_GET["option"]){
case "change_profile_pic":
$reply = UserPanel::changeUserPic();
break;
case "purchases":
$reply = UserPanel::purchases();
break;
case "payment":
$reply = UserPanel::payment();
break;
case "delete_user";
$reply = UserPanel::delete();
break;
default:
$reply = UserPanel::panel();
break;
}
}
else{
$reply = '<div class="column side"></div>
<div class="column middle">
<div class="code info">
<h1>Debes iniciar sesión para ver tu Panel de Usuario.</h1><hr />
<p>Inicia Sesión si estás registrado.</p>
<a href="'.$prefix.'login/"><button>Iniciar Sesión</button></a>
<p>Registrate si no lo habías hecho previamente.</p>
<form method="post" action="'.$prefix.'login/"><button name="register" id="_register">Registro</button></form>
</div>
</div>
<div class="column side"></div>'."\n";
}
//Specific page content:
$section = '<!-- User Panel -->
<section id="user_panel">
<div class="row">
<!-- Contents -->
<div class="row">
'.$reply.'
</div>
</div>
</section>
';
//General page content:
require RAIZ_APP.'/HTMLtemplate.php';
?>

View File

@ -1,188 +0,0 @@
<?php
require_once($prefix.'assets/php/includes/user.php');
class UserPanel {
//Atributes:
//Constructor:
function __construct(){}
//Methods:
//Welcome view.
static function panel(){
$name = strtoupper(unserialize($_SESSION['user'])->getName());
$email = unserialize($_SESSION['user'])->getEmail();
$userPic = USER_PICS.strtolower($name).".jpg";
$forms = self::manage();
return $reply = '<div class="code info">
<h1>Bienvenido '.$name.', a tu Panel de Usuario.</h1>
<hr />
<a href="./?option=change_profile_pic"><img src='.$userPic.' alt="user_profile_picture"/></a>
<h3>'.strftime("%A %e de %B de %Y | %H:%M").'</h3>
<br />
<p>Usuario: '.$name.'</p>
<p>Email: '.$email.'</p>
</div>'."\n".$forms;
}
//Manage the user account.
static function manage(){
require_once('./includes/formChangePass.php');
require_once('./includes/formChangeEmail.php');
require_once('./includes/formChangeName.php');
$formCN = new FormChangeName();
$htmlFormChangeName = $formCN->gestiona();
$formCP = new FormChangePass();
$htmlFormChangePass = $formCP->gestiona();
$formCE = new FormChangeEmail();
$htmlFormChangeEmail = $formCE->gestiona();
return $reply = '
<!-- Cambiar Información de la Usuario -->
<br /><h2>Cambiar información de la cuenta</h2><hr />
<!-- Change User Name -->
<div class="column side">
<h2>Cambiar nombre de usuario</h2>
'.$htmlFormChangeName.'
</div>
<!-- Change User Password -->
<div class="column middle">
<h2>Cambiar contraseña</h2>
'.$htmlFormChangePass.'
</div>
<!-- Change User Email -->
<div class="column side">
<h2>Cambiar email de usuario</h2>
'.$htmlFormChangeEmail.'
</div>'."\n";
}
//User purchase history.
static function changeUserPic(){
require_once('./includes/formUploadPic.php');
$formCP = new FormUploadFiles();
$htmlFormChangeUserPic = $formCP->gestiona();
$name = strtoupper(unserialize($_SESSION['user'])->getName());
$userPic = USER_PICS.strtolower($name).".jpg";
return $reply = '<!-- Form Change User Profile Picture -->
<div class="column side"></div>
<div class="column middle">
<div class="code info">
<h1>Cambiar imagen de perfil</h1><hr />
<img src='.$userPic.' alt="user_profile_picture"/>
'.$htmlFormChangeUserPic.'
</div>
</div>
<div class="column side"></div>'."\n";
}
//User purchase history.
static function purchases(){
require_once('../assets/php/includes/purchase_dao.php');
include_once('../assets/php/includes/cinema_dao.php');
include_once('../assets/php/includes/hall_dao.php');
include_once('../assets/php/includes/session_dao.php');
include_once('../assets/php/includes/film_dao.php');
$purchasesHTML = '';
$purchaseDAO = new PurchaseDAO("complucine");
$purchases = $purchaseDAO->allPurchasesData(unserialize($_SESSION['user'])->getId());
if($purchases){
$sessions = array();
$halls = array();
$cinemas = array();
$rows = array();
$columns = array();
$dates = array();
foreach($purchases as $key=>$value){
$sessions[$key] = $value->getSessionId();
$halls[$key] = $value->getHallId();
$cinemas[$key] = $value->getCinemaId();
$rows[$key] = $value->getRow();
$columns[$key] = $value->getColumn();
$dates[$key] = $value->getTime();
}
for($i = 0; $i < count($purchases); $i++){
$cinemaDAO = new Cinema_DAO("complucine");
$cinema = $cinemaDAO->cinemaData($cinemas[$i]);
$hallDAO = new HallDAO("complucine");
$hall = $hallDAO->HallData($halls[$i]);
$sessionDAO = new SessionDAO("complucine");
$session = $sessionDAO->sessionData($sessions[$i]);
$filmDAO = new Film_DAO("complucine");
$film = $filmDAO->FilmData($session->getIdfilm());
if($i%3 === 0 && $i !== 0){
if($i !== 0) $purchasesHTML .= '</div>
';
$purchasesHTML .= '<div class="column right">
';
} else {
if($i !== 0) $purchasesHTML .= '</div>
';
$purchasesHTML .= '<div class="column left">
';
}
$purchasesHTML .= '<h1>Compara realizada el: '.$dates[$i].'</h1><hr />
<div class="column left">
<p>Película: '.str_replace('_', ' ', strtoupper($film->getTittle())).'</p>
<p>Idioma: '.$film->getLanguage().'</p>
<p>Cine: '.$cinema->getName().'</p>
<p>Dirección: '.$cinema->getDirection().'</p>
</div>
<div class="column right">
<p>Sala: '.$hall->getNumber().'</p>
<p>Sesión: '.$sessions[$i].'</p>
<p>Asiento(Fila): '.$rows[$i].'</p>
<p>Asiento(Columna): '.$columns[$i].'</p>
</div>
';
}
}
return $reply = '<div class="code">
<h2>Historial de compras</h2><hr />
'.$purchasesHTML.'
</div>';
}
//User payment details
static function payment(){
return $reply = '<div class="code info">
<h2>Aquí los datos de pago</h2><hr />
</div>'."\n";
}
//Delete user account.
static function delete(){
require_once('./includes/formDeleteAccount.php');
$formDA = new FormDeleteAccount();
$htmlFormDeleteAccount = $formDA->gestiona();
return $reply = '<div class="code">
<h2>ELIMINAR CUENTA DE USUARIO</h2><hr />
<div class="column side"></div>
<!-- Delete User Form -->
<div class="column middle">
'.$htmlFormDeleteAccount.'
</div>
<div class="column side"></div>
</div>'."\n";
}
}
?>