From ebc132e2055973a88ce6936041e3a73132a8a156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20M=C3=A9ndez?= <45081533+FerMdez@users.noreply.github.com> Date: Tue, 4 May 2021 22:26:24 +0200 Subject: [PATCH] Add files via upload --- assets/css/main.css | 6 ++ assets/php/common/film_dao.php | 4 +- assets/php/common/film_dto.php | 1 - assets/php/common/hall.php | 14 +--- assets/php/common/hall_dao.php | 27 +------ assets/php/config.php | 11 ++- assets/php/template.php | 15 ++-- login/includes/formLogin.php | 1 + panel_admin/includes/formFilm.php | 30 ++++++-- panel_admin/manage_films.php | 35 +++------ panel_manager/edit_halls.php | 16 ++++ panel_manager/hello_panel.php | 9 +++ panel_manager/includes/formHall.php | 95 +++++++++++++----------- panel_manager/index.php | 57 ++------------- panel_manager/manage_halls.php | 35 +++++++++ panel_manager/manage_rooms.php | 37 ++++++++++ panel_manager/panel_manager.php | 109 +++++----------------------- panel_manager/validateSession.php | 77 ++++++++++++++++++++ register/includes/formRegister.php | 1 + 19 files changed, 319 insertions(+), 261 deletions(-) create mode 100644 panel_manager/edit_halls.php create mode 100644 panel_manager/hello_panel.php create mode 100644 panel_manager/manage_halls.php create mode 100644 panel_manager/manage_rooms.php create mode 100644 panel_manager/validateSession.php diff --git a/assets/css/main.css b/assets/css/main.css index d468ff4..080b88e 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -556,6 +556,12 @@ textarea { border:#000000; background-color: #791515; } +.file{ + margin-top: 10px; +} +.file input{ + height: 110%; +} /* Footer */ diff --git a/assets/php/common/film_dao.php b/assets/php/common/film_dao.php index 1bb9682..3afc769 100644 --- a/assets/php/common/film_dao.php +++ b/assets/php/common/film_dao.php @@ -14,10 +14,10 @@ //Methods: //Create a new Session. - public function createFilm($id, $tittle, $duration, $language,$description){ + public function createFilm($id, $tittle, $duration, $language, $description){ $sql = sprintf( "INSERT INTO `film`( `id`, `tittle`, `duration`, `language`,`description`) VALUES ( '%d', '%s', '%d', '%s','%s')", - $id, $tittle, $duration, $language,$description); + $id, $tittle, $duration, $language, $description); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); return $resul; diff --git a/assets/php/common/film_dto.php b/assets/php/common/film_dto.php index 3b24897..b177f38 100644 --- a/assets/php/common/film_dto.php +++ b/assets/php/common/film_dto.php @@ -9,7 +9,6 @@ private $_duration; //Film duration. private $_language; //Film language. private $_description; //Film description. - //Constructor: function __construct($id, $tittle, $duration, $language, $description){ diff --git a/assets/php/common/hall.php b/assets/php/common/hall.php index 9580548..a9f638a 100644 --- a/assets/php/common/hall.php +++ b/assets/php/common/hall.php @@ -1,5 +1,5 @@ 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: public function setNumber($number){ $this->_number = $number; } public function getNumber(){ return $this->_number; } diff --git a/assets/php/common/hall_dao.php b/assets/php/common/hall_dao.php index da50159..f1276d2 100644 --- a/assets/php/common/hall_dao.php +++ b/assets/php/common/hall_dao.php @@ -1,5 +1,5 @@ mysqli, $sql) or die ('Error BD createhall'); - + return $sql; } - + //Returns a query to get the halls data. public function getAllHalls($cinema){ $sql = sprintf( "SELECT * FROM hall WHERE @@ -41,24 +39,7 @@ return $hall; } - - //Returns the count of the hall searched - public function searchHall($number, $cinema){ - - $sql = sprintf( "SELECT COUNT(*) FROM hall WHERE - idcinema = '%s' AND number = '%s'", - $cinema, $number); - $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); - - $hall = mysqli_fetch_array($resul); - - mysqli_free_result($resul); - - return $hall[0]; - } - - - + //Create a new Hall Data Transfer Object. public function loadHall($number, $idcinema, $numrows, $numcolumns){ return new Hall($number, $idcinema, $numrows, $numcolumns); diff --git a/assets/php/config.php b/assets/php/config.php index fc77f87..ebb1e38 100644 --- a/assets/php/config.php +++ b/assets/php/config.php @@ -7,6 +7,11 @@ define('BD_USER', 'sw'); define('BD_PASS', '_admin_'); + /** + * Temprarl files directory. + */ + define('TMP_DIR', __DIR__.'/img/'); + /** * Utf-8 support settings, location (language and country) and time zone. */ @@ -23,7 +28,7 @@ $prefix = $template->get_prefix(); //Depuración (BORRAR): - //ini_set('display_errors', 1); - //ini_set('display_startup_errors', 1); - //error_reporting(E_ALL); + ini_set('display_errors', 1); + ini_set('display_startup_errors', 1); + error_reporting(E_ALL); ?> \ No newline at end of file diff --git a/assets/php/template.php b/assets/php/template.php index 9463435..0589493 100644 --- a/assets/php/template.php +++ b/assets/php/template.php @@ -1,6 +1,9 @@ Ver como...
Ha habido un error en la operacion. Revisa los datos introducidos
- + $this->reply = ""; } @@ -73,7 +79,7 @@ class FormFilm extends Form { } //Process form: - public function processesForm($_id,$_tittle,$_duration,$_language,$_description, $_option) { + public function processesForm($_id, $_tittle, $_duration, $_language, $_description, $_img, $_option) { $this->correct = true; $this->option = $_option; @@ -82,6 +88,20 @@ class FormFilm extends Form { $duration=$this->test_input($_duration); $language=$this->test_input($_language); $description=$this->test_input($_description); + + //Validate promotional film image. + $file_name = $_FILES['file']['name']; + $file_type = $_FILES['file']['type']; + $file_size = $_FILES['file']['size']; + if (strpos($file_type, "jpg") && $file_size < 100000) { + $uploadFile = TMP_DIR . basename($_FILES['file'][$_tittle]); + if (!move_uploaded_file($file_name, $uploadFile)){ + print_r($_FILES); + } + } + else{ + $this->correct =false; + } //Habria que validar todo para que encaje en la base de datos diff --git a/panel_admin/manage_films.php b/panel_admin/manage_films.php index bce68c6..c873c99 100644 --- a/panel_admin/manage_films.php +++ b/panel_admin/manage_films.php @@ -11,28 +11,22 @@ echo'Numero | +Filas | +Columnas | +|
---|---|---|---|
'. $hall->getNumber().' | +'. $hall->getNumRows().' | +'. $hall->getNumCol().' | ++ |
Esta vista esta en desarrollo
+
Sala | +Opción | +
---|---|
Sala". $r->getNumber() ." | +Editar | +
Usuario: '.$name.'
-Espero que estes pasando un buen dia
-'.$_SESSION['msg'].'
-Numero | -Filas | -Columnas | -|
---|---|---|---|
'. $hall->getNumber().' | -'. $hall->getNumRows().' | -'. $hall->getNumCol().' | -- |
Usuario: '.$name.'
-Espero que estes pasando un buen dia
-Esta vista no esta implementada
"; break; + case 'us_r': echo "Esta vista no esta implementada
"; break; + case 'rooms': require_once('manage_halls.php'); break; + case 'sessions': require_once('manage_sessions.php'); break; + case 'edit_session': require_once('edit_sessions.php'); break; + case 'edit_hall': require_once('edit_halls.php'); break; + default: require('hello_panel.php'); break; + } + } + else{ + echo "