Add files via upload

This commit is contained in:
Fernando Méndez 2021-05-09 20:31:54 +02:00 committed by GitHub
parent 99e298e1eb
commit d075d04a2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 74 additions and 106 deletions

View File

@ -18,7 +18,7 @@
VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%d', '%s', '%d')", VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%d', '%s', '%d')",
$id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, "0"); $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, "0");
$resul = mysqli_query($this->mysqli, $sql) or die ('Error createSession'); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $sql; return $sql;
} }
@ -35,7 +35,7 @@
public function filmTittle($idfilm){ public function filmTittle($idfilm){
$sql = sprintf("SELECT * FROM film JOIN session ON film.id = session.idfilm WHERE session.idfilm = '%d' ", $idfilm ); $sql = sprintf("SELECT * FROM film JOIN session ON film.id = session.idfilm WHERE session.idfilm = '%d' ", $idfilm );
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database en filmTittle con idfilm= '. $idfilm); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database en sessionData con la id '. $idfilm);
$resul = mysqli_fetch_array($resul); $resul = mysqli_fetch_array($resul);
@ -50,8 +50,7 @@
$sql = sprintf( "SELECT * FROM session WHERE $sql = sprintf( "SELECT * FROM session WHERE
idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'", idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'",
$cinema, $hall, $date, $startTime); $cinema, $hall, $date, $startTime);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
$resul = mysqli_query($this->mysqli, $sql) or die ('Error searchSession');
$session = mysqli_fetch_array($resul); $session = mysqli_fetch_array($resul);

View File

@ -44,4 +44,9 @@
* @see http://php.net/manual/en/language.types.callable.php * @see http://php.net/manual/en/language.types.callable.php
*/ */
register_shutdown_function(array($app, 'shutdown')); register_shutdown_function(array($app, 'shutdown'));
//Depuración (BORRAR):
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?> ?>

View File

@ -18,7 +18,7 @@ abstract class Form {
* envío del formulario. * envío del formulario.
*/ */
private $action; private $action;
private $printed;
/** /**
* Crea un nuevo formulario. * Crea un nuevo formulario.
* *
@ -52,7 +52,7 @@ abstract class Form {
$opcionesPorDefecto = array( 'action' => null, ); $opcionesPorDefecto = array( 'action' => null, );
$opciones = array_merge($opcionesPorDefecto, $opciones); $opciones = array_merge($opcionesPorDefecto, $opciones);
$this->action = $opciones['action']; $this->action = $opciones['action'];
if ( !$this->action ) { if ( !$this->action ) {
$this->action = htmlentities($_SERVER['PHP_SELF']); $this->action = htmlentities($_SERVER['PHP_SELF']);
@ -77,7 +77,7 @@ abstract class Form {
* </ul> * </ul>
*/ */
public function gestiona() public function gestiona()
{ {
if ( ! $this->formularioEnviado($_POST) ) { if ( ! $this->formularioEnviado($_POST) ) {
return $this->generaFormulario(); return $this->generaFormulario();
} else { } else {
@ -88,7 +88,7 @@ abstract class Form {
header('Location: '.$result); header('Location: '.$result);
exit(); exit();
} }
} }
} }
/** /**
@ -152,10 +152,10 @@ abstract class Form {
/* <<< Permite definir cadena en múltiples líneas. /* <<< Permite definir cadena en múltiples líneas.
* Revisa https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc * Revisa https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
*/ */
$htmlForm = '<form method="POST" action="'.$this->action.'" id="'.$this->formId.'" > $htmlForm = "<form method='POST' action='{$this->action}' id='{$this->formId}' >
<input type="hidden" name="action" value="$this->formId" /> <input type='hidden' name='action' value='{$this->formId}' />
'.$htmlCamposFormularios.' ".$htmlCamposFormularios."
</form>'; </form>";
return $htmlForm; return $htmlForm;
} }

View File

@ -325,46 +325,6 @@
break; break;
case "Panel de Gerente": case "Panel de Gerente":
$html="<div class='column'>";
for($i = 0; $i < count($films_array); $i++){
$tittle = str_replace('_', ' ', $tittles[$i]);
if($i%2 === 0){
if($i != 0) $html.= "</div>
";
$html.= "<div class='column side'>
";
}
else{
if($i != 0) $html.= "</div>
";
$html.= "<div class='column middle'>
";
}
$html.= "<section id='".$tittles[$i]."'>
<div class='zoom'>
<div class='code showtimes'>
<div class='image'><img src='".$prefix."img/".$tittles[$i].".jpg' alt='".$tittles[$i]."' /></div>
<h2>".$tittle."</h2>
<hr />
<form method='post' action='./?state=".$_SESSION['option']."'>
<input name='id' type='hidden' value='".$ids[$i]."'>
<input name='tittle' type='hidden' value='".$tittles[$i]."'>
<input name='duration' type='hidden' value='".$times[$i]."'>
<input name='language' type='hidden' value='".$languages[$i]."'>
<input name='description' type='hidden' value='".$descriptions[$i]."'>
<input name='price' type='hidden' value='".$_POST["price"]."'>
<input name='format' type='hidden' value='".$_POST["format"]."'>
<input name='start' type='hidden' value='".$_POST["start"]."'>
<input name='date' type='hidden' value='".$_POST["date"]."'>
<input name='hall' type='hidden' value='".$_POST["hall"]."'>
</form>
</div>
</div>
</section>
";
}
$html.= "</div>\n";
return $html;
break; break;
default: default:
@ -511,4 +471,4 @@
} }
} }
?> ?>

View File

@ -21,23 +21,23 @@ class FormChangeEmail extends Form {
$errorPassword2 = self::createMensajeError($errores, 'repass', 'span', array('class' => 'error')); $errorPassword2 = self::createMensajeError($errores, 'repass', 'span', array('class' => 'error'));
$html = '<div class="row">'.$htmlErroresGlobales.' $html = '<div class="row">'.$htmlErroresGlobales.'
<fieldset id="email_usuario"> <fieldset id="email_usuario">
<legend>Nuevo email de usuario</legend> <legend>Nuevo email de usuario</legend>
<div class="_new_email"> <div class="_new_email">
<input type="text" name="new_email" id="new_email" value="" placeholder="Nuevo Email" required/> <input type="text" name="new_email" id="new_email" value="" placeholder="Nuevo Email" required/>
</div> </div>
<div class="_passwd"> <div class="_passwd">
<input type="password" name="pass" id="pass" value="" placeholder="Contraseña" required/> <input type="password" name="pass" id="pass" value="" placeholder="Contraseña" required/>
</div> </div>
<div class="_passwd"> <div class="_passwd">
<input type="password" name="repass" id="repass" value="" placeholder="Repita la contraseña" required/> <input type="password" name="repass" id="repass" value="" placeholder="Repita la contraseña" required/>
</div> </div>
</fieldset> </fieldset>
<div class="actions"> <div class="actions">
<input type="submit" id="submit" value="Cambiar Nombre de Usuario" class="primary" /> <input type="submit" id="submit" value="Cambiar Nombre de Usuario" class="primary" />
<input type="reset" id="reset" value="Borrar" /> <input type="reset" id="reset" value="Borrar" />
</div> </div>
</div>'; </div>';
return $html; return $html;
} }

View File

@ -1,6 +1,7 @@
<?php <?php
require_once('../assets/php/form.php'); require_once('../assets/php/form.php');
include_once('../assets/php/common/user.php'); include_once('../assets/php/common/user.php');
include_once('../assets/php/common/user_dao.php');
class FormChangeName extends Form { class FormChangeName extends Form {
@ -19,23 +20,23 @@ class FormChangeName extends Form {
$errorPassword2 = self::createMensajeError($errores, 'repass', 'span', array('class' => 'error')); $errorPassword2 = self::createMensajeError($errores, 'repass', 'span', array('class' => 'error'));
$html = '<div class="row">'.$htmlErroresGlobales.' $html = '<div class="row">'.$htmlErroresGlobales.'
<fieldset id="nombre_usuario"> <fieldset id="nombre_usuario">
<legend>Nuevo Nombre de usuario</legend> <legend>Nuevo Nombre de usuario</legend>
<div class="_new_name"> <div class="_new_name">
<input type="text" name="new_name" id="new_name" value="" placeholder="Nuevo Nombre" required/> <input type="text" name="new_name" id="new_name" value="" placeholder="Nuevo Nombre" required/>'.$errorNombre.'
</div> </div>
<div class="_passwd"> <div class="_passwd">
<input type="password" name="pass" id="pass" value="" placeholder="Contraseña" required/> <input type="password" name="pass" id="pass" value="" placeholder="Contraseña" required/>'.$errorPassword.'
</div> </div>
<div class="_passwd"> <div class="_passwd">
<input type="password" name="repass" id="repass" value="" placeholder="Repita la contraseña" required/> <input type="password" name="repass" id="repass" value="" placeholder="Repita la contraseña" required/>'.$errorPassword2.'
</div> </div>
</fieldset> </fieldset>
<div class="actions"> <div class="actions">
<input type="submit" id="submit" value="Cambiar Nombre de Usuario" class="primary" /> <input type="submit" id="submit" value="Cambiar Nombre de Usuario" class="primary" />
<input type="reset" id="reset" value="Borrar" /> <input type="reset" id="reset" value="Borrar" />
</div> </div>
</div>'; </div>';
return $html; return $html;
} }
@ -44,6 +45,7 @@ class FormChangeName extends Form {
$result = array(); $result = array();
$nombre = $datos['new_name'] ?? null; $nombre = $datos['new_name'] ?? null;
$nombre = strtolower($nombre);
if ( empty($nombre) || mb_strlen($nombre) < 4 ) { if ( empty($nombre) || mb_strlen($nombre) < 4 ) {
$result['new_name'] = "El nombre tiene que tener una longitud de al menos 4 caracteres."; $result['new_name'] = "El nombre tiene que tener una longitud de al menos 4 caracteres.";
} }
@ -63,8 +65,8 @@ class FormChangeName extends Form {
if (!$user) { if (!$user) {
$result[] = "El usuario no existe."; $result[] = "El usuario no existe.";
} else { } else {
$bd->changeUserName(unserialize($_SESSION['user'])->getId(), $username); $bd->changeUserName(unserialize($_SESSION['user'])->getId(), $nombre);
$user = $bd->selectUser($username, $password); $user = $bd->selectUser($nombre, $password);
if (!$user){ if (!$user){
$result[] = "Ha ocurrido un probrema al actualizar el nombre de usuario."; $result[] = "Ha ocurrido un probrema al actualizar el nombre de usuario.";
}else{ }else{

View File

@ -19,23 +19,23 @@ class FormChangePass extends Form {
$errorPassword2 = self::createMensajeError($errores, 'repass', 'span', array('class' => 'error')); $errorPassword2 = self::createMensajeError($errores, 'repass', 'span', array('class' => 'error'));
$html = '<div class="row">'.$htmlErroresGlobales.' $html = '<div class="row">'.$htmlErroresGlobales.'
<fieldset id="contraseña_usuario"> <fieldset id="contraseña_usuario">
<legend>Contraseña Actual</legend> <legend>Contraseña Actual</legend>
<div class="_passwd"> <div class="_passwd">
<input type="password" name="old_pass" id="old_pass" value="" placeholder="Contraseña Actual" required/> <input type="password" name="old_pass" id="old_pass" value="" placeholder="Contraseña Actual" required/>
</div> </div>
<div class="_passwd"> <div class="_passwd">
<input type="password" name="pass" id="pass" value="" placeholder="Nueva Contraseña" required/> <input type="password" name="pass" id="pass" value="" placeholder="Nueva Contraseña" required/>
</div> </div>
<div class="_passwd"> <div class="_passwd">
<input type="password" name="repass" id="repass" value="" placeholder="Repita la nueva contraseña" required/> <input type="password" name="repass" id="repass" value="" placeholder="Repita la nueva contraseña" required/>
</div> </div>
</fieldset> </fieldset>
<div class="actions"> <div class="actions">
<input type="submit" id="submit" value="Cambiar Contraseña" class="primary" /> <input type="submit" id="submit" value="Cambiar Contraseña" class="primary" />
<input type="reset" id="reset" value="Borrar" /> <input type="reset" id="reset" value="Borrar" />
</div> </div>
</div>'; </div>';
return $html; return $html;
} }

View File

@ -44,10 +44,12 @@
<h2>Cambiar nombre de usuario</h2> <h2>Cambiar nombre de usuario</h2>
'.$htmlFormChangeName.' '.$htmlFormChangeName.'
</div> </div>
<!-- Change User Password -->
<div class="column middle"> <div class="column middle">
<h2>Cambiar contraseña</h2> <h2>Cambiar contraseña</h2>
'.$htmlFormChangePass.' '.$htmlFormChangePass.'
</div> </div>
<!-- Change User Email -->
<div class="column side"> <div class="column side">
<h2>Cambiar email de usuario</h2> <h2>Cambiar email de usuario</h2>
'.$htmlFormChangeEmail.' '.$htmlFormChangeEmail.'