Add files via upload

This commit is contained in:
Fernando Méndez 2021-05-06 10:40:56 +02:00 committed by GitHub
parent 993f70a373
commit 89669ce53e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 37 additions and 102 deletions

View File

@ -1,5 +1,5 @@
<?php <?php
include_once($prefix.'assets/php/common/hall_dao.php'); include_once('../assets/php/common/hall_dao.php');
class Hall{ class Hall{
@ -25,18 +25,6 @@
return ""; return "";
} }
public static function create_hall($hall){
$bd = new HallDAO('complucine');
if($bd ){
if(!$bd->searchHall($hall['cinema'], $hall['number'])){
$bd->createHall($hall['number'], $hall['cinema'], $hall['cols'], $hall['rows']);
return "Se ha creado la sala con exito";
} else {
return "Esta sala ya existe";
}
} else { return "Error al conectarse a la base de datos"; }
}
//Getters && Setters: //Getters && Setters:
public function setNumber($number){ $this->_number = $number; } public function setNumber($number){ $this->_number = $number; }
public function getNumber(){ return $this->_number; } public function getNumber(){ return $this->_number; }

View File

@ -1,7 +1,7 @@
<?php <?php
include_once($prefix.'assets/php/common/session_dao.php'); include_once('session_dao.php');
include_once($prefix.'panel_admin/includes/film.php'); include_once('film.php');
include_once($prefix.'assets/php/common/film_dao.php'); include_once('film_dao.php');
class Session{ class Session{
@ -55,34 +55,6 @@
} else return "Error al conectarse a la base de datos"; } else return "Error al conectarse a la base de datos";
} }
public static function edit_session($session){
$bd = new SessionDAO('complucine');
if($bd ){
if($bd->searchSession($session['cinema'], $session['origin_hall'],$session['origin_start'],$session['origin_date'])){
$origin = array("cinema" => $session['cinema'],"hall" => $session['origin_hall'],"start" => $session['origin_start'],"date" => $session['origin_date']);
$bd->editSession($session['film'], $session['hall'], $session['cinema'], $session['date'],
$session['start'], $session['price'], $session['format'],$origin);
return "Se ha editado la session con exito";
} else
return "Esta session no existe";
} else return "Error al conectarse a la base de datos";
}
public static function delete_session($session){
$bd = new SessionDAO('complucine');
if($bd ){
if($bd->searchSession($session['cinema'], $session['hall'],$session['start'],$session['date'])){
$bd->deleteSession($session['hall'], $session['cinema'], $session['date'], $session['start']);
return "Se ha eliminado la session con exito";
} else
return "Esta session no existe";
} else return "Error al conectarse a la base de datos";
}
//Esto deberia estar en film.php? seguramente //Esto deberia estar en film.php? seguramente
public static function getFilmTitle($idfilm){ public static function getFilmTitle($idfilm){
$bd = new Film_DAO('complucine'); $bd = new Film_DAO('complucine');

View File

@ -67,7 +67,7 @@
return $sessions; return $sessions;
} }
public function editSession($idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $origin){ public function editSession($idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
$format = $this->mysqli->real_escape_string($format); $format = $this->mysqli->real_escape_string($format);
$date = date('Y-m-d', strtotime( $date ) ); $date = date('Y-m-d', strtotime( $date ) );
$startTime = date('H:i:s', strtotime( $startTime ) ); $startTime = date('H:i:s', strtotime( $startTime ) );
@ -77,7 +77,7 @@
`start_time` = '%s', `seat_price` = '%d', `format` = '%s' `start_time` = '%s', `seat_price` = '%d', `format` = '%s'
WHERE 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'",
$idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $origin["cinema"],$origin["hall"],$origin["date"],$origin["start"]); $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $_SESSION["cinema"],$_SESSION["hall"],$_SESSION["date"],$_SESSION["start"]);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');

View File

@ -7,10 +7,15 @@
define('BD_USER', 'sw'); define('BD_USER', 'sw');
define('BD_PASS', '_admin_'); define('BD_PASS', '_admin_');
/** /*
* Temprarl files directory. * Configuration parameters used to generate URLs and file paths in the application
*/ */
define('TMP_DIR', __DIR__.'/img/'); define('ROUTE_APP', '/'); //Change if it´s necessary.
/**
* Image files directory.
*/
define('IMG_DIR', ROUTE_APP.'img/');
/** /**
* Utf-8 support settings, location (language and country) and time zone. * Utf-8 support settings, location (language and country) and time zone.

View File

@ -186,14 +186,14 @@
case "manager": array_push($menus, "<li>Ver como... case "manager": array_push($menus, "<li>Ver como...
<ul> <ul>
<a href='./?state=view_user'><li>Usuario</li></a> <a href='./?state=us_u'><li>Usuario</li></a>
<a href='./?state=view_ruser'><li>Usuario registrado</li></a> <a href='./?state=us_r'><li>Usuario registrado</li></a>
</ul> </ul>
</li>"); </li>");
array_push($menus, "<li>Modificar array_push($menus, "<li>Modificar
<ul> <ul>
<a href='./?state=manage_halls'><li>Salas</li></a> <a href='./?state=rooms'><li>Salas</li></a>
<a href='./?state=manage_sessions'><li>Sesiones</li></a> <a href='./?state=sessions'><li>Sesiones</li></a>
</ul> </ul>
</li>"); </li>");
break; break;

View File

@ -91,10 +91,11 @@ class FormFilm extends Form {
//Validate promotional film image. //Validate promotional film image.
$file_name = $_FILES['file']['name']; $file_name = $_FILES['file']['name'];
$file_type = $_FILES['file']['type']; //$file_type = $_FILES['file']['type'];
$file_size = $_FILES['file']['size']; $file_size = $_FILES['file']['size'];
if (strpos($file_type, "jpg") && $file_size < 100000) { if(isset($file_name) && $file_name != ""
$uploadFile = TMP_DIR . basename($_FILES['file'][$_tittle]); && strpos($file_name, "jpg") && $file_size < 100000){
$uploadFile = IMG_DIR . basename($_FILES['file'][$_tittle]);
if (!move_uploaded_file($file_name, $uploadFile)){ if (!move_uploaded_file($file_name, $uploadFile)){
print_r($_FILES); print_r($_FILES);
} }

View File

@ -19,7 +19,7 @@
<input type="number" name="duration" id="duration" placeholder="Duración" /> <input type="number" name="duration" id="duration" placeholder="Duración" />
<input type="text" name="language" id="language" placeholder="Idioma" /> <input type="text" name="language" id="language" placeholder="Idioma" />
<input type="text" name="description" id="description" placeholder="Descripción" /> <input type="text" name="description" id="description" placeholder="Descripción" />
<div class="file">Imagen promocional:<input type="file" name="file" placeholder="Imagen promocional" /></div> <div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div>
</fieldset> </fieldset>
<div class="actions"> <div class="actions">
<input type="submit" id="submit" value="Añadir pelicula" name="add_film" class="primary" /> <input type="submit" id="submit" value="Añadir pelicula" name="add_film" class="primary" />
@ -61,7 +61,7 @@
echo'<div class="column side"></div> echo'<div class="column side"></div>
<div class="column middle"> <div class="column middle">
<h2>Editar pelicula</h2> <h2>Editar pelicula</h2>
<form method="post" action="index.php?state=mf"> <form method="post" enctype="multipart/form-data" action="index.php?state=mf">
<div class="row"> <div class="row">
<fieldset id="film_form"> <fieldset id="film_form">
<legend>Datos de pelicula</legend> <legend>Datos de pelicula</legend>
@ -70,7 +70,7 @@
<input type="number" name="duration" id="duration" value='.$_POST['duration'].' /> <input type="number" name="duration" id="duration" value='.$_POST['duration'].' />
<input type="text" name="language" id="language" value="'.$_POST['language'].'" /> <input type="text" name="language" id="language" value="'.$_POST['language'].'" />
<input type="text" name="description" id="description" value="'.$_POST['description'].'"/> <input type="text" name="description" id="description" value="'.$_POST['description'].'"/>
<div class="file">Imagen promocional:<input type="file" name="file" placeholder="Imagen promocional" /></div> <div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div>
</fieldset> </fieldset>
<div class="actions"> <div class="actions">
<input type="submit" id="submit" value="Editar" name="confirm_edit_film" class="primary" /> <input type="submit" id="submit" value="Editar" name="confirm_edit_film" class="primary" />

View File

@ -34,9 +34,6 @@
}; };
break; break;
case 'mf': require_once('manage_films.php'); case 'mf': require_once('manage_films.php');
//echo $_SERVER['DOCUMENT_ROOT']."/../img";
echo TMP_DIR;
//echo $_SERVER['PHP_SELF'];
if(isset($_POST['edit_film'])) { if(isset($_POST['edit_film'])) {
editFilm(); editFilm();
} }

View File

@ -3,7 +3,7 @@ require_once($prefix.'assets/php/common/session_dao.php');
require_once($prefix.'assets/php/common/session.php'); require_once($prefix.'assets/php/common/session.php');
require_once($prefix.'assets/php/form.php'); require_once($prefix.'assets/php/form.php');
require_once($prefix.'panel_admin/includes/film.php'); require_once($prefix.'assets/php/common/film.php');
require_once($prefix.'assets/php/common/film_dao.php'); require_once($prefix.'assets/php/common/film_dao.php');
//Receive data from froms and prepare the correct response //Receive data from froms and prepare the correct response
@ -31,7 +31,7 @@ class FormSession extends Form {
<form method="post" id="'.$data['option'].'" action="./includes/processForm.php"\> <form method="post" id="'.$data['option'].'" action="./includes/processForm.php"\>
<fieldset> <fieldset>
<legend>Datos</legend> <legend>Datos</legend>
<input type="number" name="price" value="'.$price.'" min="0" placeholder="Precio de la entrada" required/> <br> <input type="number" name="price" value="'.$number.'" min="0" placeholder="Precio de la entrada" required/> <br>
<input type="text" name="format" value="'.$format.'" placeholder="Formato de pelicula" required/> <br> <input type="text" name="format" value="'.$format.'" placeholder="Formato de pelicula" required/> <br>
<select name="hall" class="button large">'; <select name="hall" class="button large">';
foreach(Hall::getListHalls($cinema) as $hll){ foreach(Hall::getListHalls($cinema) as $hll){
@ -56,11 +56,7 @@ class FormSession extends Form {
$htmlform .= '<input type="number" name="repeat" value="" min="0" title="Añadir esta sesion durante los proximos X dias" min="0" max="31" placeholder="Añadir X dias"/> <br> $htmlform .= '<input type="number" name="repeat" value="" min="0" title="Añadir esta sesion durante los proximos X dias" min="0" max="31" placeholder="Añadir X dias"/> <br>
<button type="submit" name="new_session" class="button large">Crear</button><br>'; <button type="submit" name="new_session" class="button large">Crear</button><br>';
if($data['option'] == "edit_session") if($data['option'] == "edit_session")
$htmlform .= ' $htmlform .= '<button type="submit" name="edit_session" class="button large">Editar</button><br>
<input name="origin_hall" type="hidden" value="'.$hall.'">
<input name="origin_date" type="hidden" value="'.$date.'">
<input name="origin_start" type="hidden" value="'.$start.'">
<button type="submit" name="edit_session" class="button large">Editar</button><br>
<button type="submit" name="delete_session" class="primary">Borrar</button><br>'; <button type="submit" name="delete_session" class="primary">Borrar</button><br>';
$htmlform .= ' $htmlform .= '
<input type="reset" value="Limpiar Campos" > <input type="reset" value="Limpiar Campos" >
@ -90,13 +86,8 @@ class FormSession extends Form {
if($data["option"] == "new_session"){ if($data["option"] == "new_session"){
$_SESSION['msg'] = Session::create_session($data); $_SESSION['msg'] = Session::create_session($data);
header( "Location: ../?state=success" ); header( "Location: ../?state=success" );
}else if($data["option"] == "edit_session"){ }else {
$_SESSION['msg'] = Session::edit_session($data);
header( "Location: ../?state=success" );
}
else if($data["option"] == "delete_session") {
$_SESSION['msg'] = Session::delete_session($data);
header( "Location: ../?state=success" );
} }
} }
} }

View File

@ -16,17 +16,4 @@
,"price" => $_POST["price"],"format" => $_POST["format"],"repeat" => $_POST["repeat"], "cinema" => $_SESSION["cinema"]); ,"price" => $_POST["price"],"format" => $_POST["format"],"repeat" => $_POST["repeat"], "cinema" => $_SESSION["cinema"]);
FormSession::processesForm($data); FormSession::processesForm($data);
} }
if(isset($_POST['edit_session'])){
$data = array("option" => "edit_session","film" => $_POST["film"],"hall" => $_POST["hall"],"date" => $_POST["date"],"start" => $_POST["start"]
,"price" => $_POST["price"],"format" => $_POST["format"],"repeat" => $_POST["repeat"], "cinema" => $_SESSION["cinema"]
, "origin_hall"=> $_POST["origin_hall"],"origin_date"=> $_POST["origin_date"],"origin_start"=> $_POST["origin_start"]);
FormSession::processesForm($data);
}
if(isset($_POST['delete_session'])){
$data = array("option" => "delete_session","cinema" => $_SESSION["cinema"], "hall"=> $_POST["origin_hall"]
,"date"=> $_POST["origin_date"],"start"=> $_POST["origin_start"]);
FormSession::processesForm($data);
}
?> ?>

View File

@ -141,16 +141,7 @@
<td> '. str_replace('_', ' ', Session::getFilmTitle($session->getIdfilm())) .' </td> <td> '. str_replace('_', ' ', Session::getFilmTitle($session->getIdfilm())) .' </td>
<td> '.$session->getFormat().' </td> <td> '.$session->getFormat().' </td>
<td> '.$session->getSeatPrice().' </td> <td> '.$session->getSeatPrice().' </td>
<td> <input type="date" name="date" value="'.$date.'">
<form method="post" action="./?state=edit_session">
<input name="film" type="hidden" value="'.$session->getIdfilm().'">
<input name="hall" type="hidden" value="'.$session->getIdhall().'">
<input name="date" type="hidden" value="'.$session->getDate().'">
<input name="start" type="hidden" value="'.$session->getStartTime().'">
<input name="price" type="hidden" value="'.$session->getSeatPrice().'">
<input name="format" type="hidden" value="'.$session->getFormat().'">
<td> <input type="submit" name="edit" value="Editar" class="button" ></td> <td> <input type="submit" name="edit" value="Editar" class="button" ></td>
</form>
</tr>'; </tr>';
} }
$panel.=' $panel.='
@ -178,9 +169,12 @@
} }
static function edit_session(){ static function edit_session(){
$data = array("option" => "edit_session","hall" => $_POST["hall"],"cinema" => $_SESSION["cinema"],"date" => $_POST['date'],"film" => $_POST['film'],"start" => $_POST['start'],"price" => $_POST['price'],"format" => $_POST['format']); $panel = '<div class="column side"></div>
$panel = '<h1>Editar una sesión.</h1><hr /></br> <div class="column middle">
'.FormSession::generaCampoFormulario($data, null); <h1>Editar una session.</h1><hr /></br>
<p> En desarrollo... </p>
</div>
<div class="column side"></div>'."\n";
return $panel; return $panel;
} }