From 231e72f17a960bde3b455f4593c31d04e7d7750a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20M=C3=A9ndez?= <45081533+FerMdez@users.noreply.github.com> Date: Wed, 12 May 2021 22:24:10 +0200 Subject: [PATCH] Add files via upload --- assets/php/HTMLtemplate.php | 33 +++++++ assets/php/config.php | 5 ++ assets/php/template.php | 33 +++++-- cinemas/index.php | 33 ++----- contacto/includes/formContact.php | 88 ++++++++++++++++++ contacto/index.php | 88 ++++-------------- login/index.php | 115 ++++++++++-------------- login/validate.php | 58 ++++-------- logout/index.php | 60 ++++--------- panel_user/includes/formChangeEmail.php | 1 - panel_user/index.php | 48 +++------- register/includes/formRegister.php | 6 +- register/register.php | 54 +++-------- showtimes/index.php | 13 +++ 14 files changed, 284 insertions(+), 351 deletions(-) create mode 100644 assets/php/HTMLtemplate.php create mode 100644 contacto/includes/formContact.php diff --git a/assets/php/HTMLtemplate.php b/assets/php/HTMLtemplate.php new file mode 100644 index 0000000..f11c4fe --- /dev/null +++ b/assets/php/HTMLtemplate.php @@ -0,0 +1,33 @@ + + + + + print_head(); + ?> + + + print_header(); + ?> + + + print_main(); + ?> + + + print_section($section); + ?> + + + print_footer(); + ?> + + + \ No newline at end of file diff --git a/assets/php/config.php b/assets/php/config.php index d52c211..f03a4fb 100644 --- a/assets/php/config.php +++ b/assets/php/config.php @@ -46,4 +46,9 @@ * @see http://php.net/manual/en/language.types.callable.php */ register_shutdown_function(array($app, 'shutdown')); + + //Depuración (BORRAR): + ini_set('display_errors', 1); + ini_set('display_startup_errors', 1); + error_reporting(E_ALL); ?> diff --git a/assets/php/template.php b/assets/php/template.php index 1bf4567..58f0e30 100644 --- a/assets/php/template.php +++ b/assets/php/template.php @@ -5,13 +5,13 @@ //private const _NUMPAGES = 10; //Constant to page results. //Attributes: - public $page; //Page Name. - public $prefix; //Page prefix. + private $page; //Page Name. + private $prefix; //Page prefix. - public $session; //"Iniciar Sesión" (if user isn´t logged in), "Cerrar Sesión" (otherwise). - public $session_route; //"login/" (if user isn´t logged in), "logout/" (otherwise). - public $panel; //Button to access the user's dashboard (only displayed if logged in). - public $user_route; //Route of the panel (depends on the type of user). + private $session; //"Iniciar Sesión" (if user isn´t logged in), "Cerrar Sesión" (otherwise). + private $session_route; //"login/" (if user isn´t logged in), "logout/" (otherwise). + private $panel; //Button to access the user's dashboard (only displayed if logged in). + private $user_route; //Route of the panel (depends on the type of user). //Constructor: function __construct(){ @@ -216,11 +216,26 @@ } echo" - \n"; + + "; } } } + //Print specific page content: + function print_section($section){ + /* Panel menu */ + $sub_header = ''; + if(strpos($_SERVER['PHP_SELF'], 'panel')){ + echo " + "; + $this->print_panelMenu($_SESSION["rol"]); + $this->print_msg(); + } + + echo $section; + } + //Print Films Cards: function print_fimls(){ //List of the movies: @@ -457,7 +472,7 @@ //Print generic Footer: function print_footer(){ $prefix = $this->prefix; - + /* TODO */ $css = "{$prefix}assets/css/highContrast.css"; $nameCSS = "Alto Contraste"; @@ -472,7 +487,7 @@ Términos de uso | Nuestros cines | Contacto | - + \n"; echo" diff --git a/cinemas/index.php b/cinemas/index.php index 72471ad..2eb5d5a 100644 --- a/cinemas/index.php +++ b/cinemas/index.php @@ -1,33 +1,10 @@ - - - - - - print_head(); - ?> - - - print_header(); - ?> - - print_main(); - ?> + //Specific page content: + $section = ''; - - print_footer(); - ?> - - - \ No newline at end of file + //General page content: + require RAIZ_APP.'/HTMLtemplate.php'; +?> \ No newline at end of file diff --git a/contacto/includes/formContact.php b/contacto/includes/formContact.php new file mode 100644 index 0000000..3a0a117 --- /dev/null +++ b/contacto/includes/formContact.php @@ -0,0 +1,88 @@ + ""); + parent::__construct('formContact', $options); + } + + protected function generaCamposFormulario($datos, $errores = array()) { + + // Se generan los mensajes de error si existen. + $htmlErroresGlobales = self::generaListaErroresGlobales($errores); + $errorNombre = self::createMensajeError($errores, 'name', 'span', array('class' => 'error')); + $errorEmail = self::createMensajeError($errores, 'email', 'span', array('class' => 'error')); + $errorMessage = self::createMensajeError($errores, 'message', 'span', array('class' => 'error')); + + // Se genera el HTML asociado a los campos del formulario y los mensajes de error. + $html = "
+
+ Datos personales
".$htmlErroresGlobales."
+
+
".$errorNombre."
+
+
+
".$errorEmail."
+
+
+
+ Motivo de la consulta +
+ + +
+
+ + +
+
+ + +
+
+
".$errorMessage."
+ +
+
+ + +
+
+ + +
+
"; + + return $html; + } + + + protected function procesaFormulario($datos) { + $result = array(); + + $nombre = $this->test_input($datos['name']) ?? null; + if ( empty($nombre) || mb_strlen($nombre) < 3 || mb_strlen($nombre) > 8 ) { + $result['name'] = "El nombre tiene que tener\n una longitud de más de\n 3 caracteres\n y menos de 8 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."; + } + + $message = $this->test_input($datos['message']) ?? null; + if ( empty($message) || mb_strlen($message) < 1 || mb_strlen($message) > 250 ) { + $result['message'] = "El mensaje no puede estar vacío\ny no puede contener más de\n250 caracteres."; + } + + if (count($result) === 0) { + $result = ROUTE_APP; + } + + return $result; + } +} \ No newline at end of file diff --git a/contacto/index.php b/contacto/index.php index a5cbe0b..b9683ba 100644 --- a/contacto/index.php +++ b/contacto/index.php @@ -1,77 +1,19 @@ gestiona(); + + //Specific page content: + $section = ' +
+

Formulario (EN DESARROLLO)

+ '.$htmlForm.' +
'; + + //General page content: + require RAIZ_APP.'/HTMLtemplate.php'; ?> - - - - - print_head(); - ?> - - - print_header(); - ?> - - - print_main(); - ?> - - -
-

Formulario

-
-
-
- Datos personales -
- -
-
- -
-
-
- Motivo de la consulta -
- - -
-
- - -
-
- - -
-
-
- -
-
- - -
-
- - -
-
-
-
- - - print_footer(); - ?> - - - - diff --git a/login/index.php b/login/index.php index f75ba24..dc148ba 100644 --- a/login/index.php +++ b/login/index.php @@ -22,76 +22,51 @@ $htmlFormLogin = $formLogin->gestiona(); $formRegister = new FormRegister(); $htmlFormRegister = $formRegister->gestiona(); -?> - - - - - print_head(); - ?> - - - print_header(); - ?> - - print_main(); - ?> - - -
-
- -
-
-

¿No tienes una cuenta?

-
-

Para crear una cuenta de usuario es necesario haber rellenado el formulario de registro previamente

-

Haz click en el botón para registrate.

-
- -
-
-
-
-

Iniciar Sesión

- ".$htmlFormLogin." -
"."\n"; - } else { - echo " -
-

Registro

- ".$htmlFormRegister." -
-
-
-

¿Ya estás registrado?

-
-

Si dispones de una cuenta de usuario, no es necesario que rellenes este formulario nuevamente

-

Haz click en el botón para iniciar sesión.

-
- -
-
-
"."\n"; - } - ?> -
-
+ if($isLogin){ + $form = " +
+
+

¿No tienes una cuenta?

+
+

Para crear una cuenta de usuario es necesario haber rellenado el formulario de registro previamente

+

Haz click en el botón para registrate.

+
+ +
+
+
+
+

Iniciar Sesión

+ ".$htmlFormLogin." +
"."\n"; + } else { + $form = " +
+

Registro

+ ".$htmlFormRegister." +
+
+
+

¿Ya estás registrado?

+
+

Si dispones de una cuenta de usuario, no es necesario que rellenes este formulario nuevamente

+

Haz click en el botón para iniciar sesión.

+
+ +
+
+
"."\n"; + } - - print_footer(); - ?> + //Specific page content: + $section = ' +
+
+ '.$form.' +
+
'; - - - + //General page content: + require RAIZ_APP.'/HTMLtemplate.php'; +?> \ No newline at end of file diff --git a/login/validate.php b/login/validate.php index 9e56d2a..701eb50 100644 --- a/login/validate.php +++ b/login/validate.php @@ -6,48 +6,20 @@ require_once('./includes/formLogin.php'); $reply = FormLogin::getReply(); -?> - - - - - print_head(); - ?> - - - print_header(); - ?> + //Specific page content: + $section = ' +
+
+
+
+
+ '.$reply.' +
+
+
+
'; - - print_main(); - ?> - - -
-
-
-
-
- -
-
-
-
-
+ //General page content: + require RAIZ_APP.'/HTMLtemplate.php'; - - print_footer(); - ?> - - - - \ No newline at end of file +?> \ No newline at end of file diff --git a/logout/index.php b/logout/index.php index 075f7eb..5e91cb6 100644 --- a/logout/index.php +++ b/logout/index.php @@ -19,49 +19,21 @@ Haz clic aquí si tu navegador no te redirige automáticamente.

\n"; } - -?> - - - - - print_head(); - ?> - - - print_header(); - ?> - - - print_main(); - ?> - - -
-
-
-
-
- + //Specific page content: + $section = ' +
+
+
+
+
+ '.$reply.' +
+
+
-
-
-
-
+
'; - - print_footer(); - ?> - - - - \ No newline at end of file + //General page content: + require RAIZ_APP.'/HTMLtemplate.php'; + +?> \ No newline at end of file diff --git a/panel_user/includes/formChangeEmail.php b/panel_user/includes/formChangeEmail.php index ecd9f8b..3392b48 100644 --- a/panel_user/includes/formChangeEmail.php +++ b/panel_user/includes/formChangeEmail.php @@ -36,7 +36,6 @@ class FormChangeEmail extends Form { return $html; } - /* TODO */ protected function procesaFormulario($datos){ $result = array(); diff --git a/panel_user/index.php b/panel_user/index.php index e6bacff..6917735 100644 --- a/panel_user/index.php +++ b/panel_user/index.php @@ -37,49 +37,21 @@
'."\n"; } -?> - - - - - print_head(); - ?> - - - print_header(); - ?> - - print_main(); - ?> - - + + //Specific page content: + $section = '
- - print_panelMenu($_SESSION["rol"]); - ?>
- print_msg(); - echo $reply; - ?> + '.$reply.'
-
- - print_footer(); - ?> - - + '; + + //General page content: + require RAIZ_APP.'/HTMLtemplate.php'; + +?> - diff --git a/register/includes/formRegister.php b/register/includes/formRegister.php index c85dbe2..eaa0c58 100644 --- a/register/includes/formRegister.php +++ b/register/includes/formRegister.php @@ -21,14 +21,14 @@ class FormRegister extends Form { //$nombre = $datos['name'] ?? ''; // Se generan los mensajes de error si existen. - $htmlErroresGlobales2 = self::generaListaErroresGlobales($errores); + $htmlErroresGlobales = self::generaListaErroresGlobales($errores); $errorNombre = self::createMensajeError($errores, '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')); $html = "
-
".$htmlErroresGlobales2."
+
".$htmlErroresGlobales."
Datos personales
".$errorNombre."
".$errorEmail."
@@ -114,7 +114,7 @@ class FormRegister extends Form {

Ha ocurrido un problema y no hemos podido completar el registro

Vuelve a intetarlo o inicia sesión si tienes una cuenta de usuario.

-
\n"; +
\n"; } return $reply; diff --git a/register/register.php b/register/register.php index 56a3159..b1cfa90 100644 --- a/register/register.php +++ b/register/register.php @@ -6,48 +6,18 @@ require_once('./includes/formRegister.php'); $reply = FormRegister::getReply(); -?> - - - - - print_head(); - ?> - - - print_header(); - ?> - - - print_main(); - ?> - - -
-
-
-
-
- -
+ $section = ' +
+
+
+
+
+ '.$reply.'
-
-
+
+
+
'; - - print_footer(); - ?> - - - - \ No newline at end of file + require RAIZ_APP.'/HTMLtemplate.php'; +?> \ No newline at end of file diff --git a/showtimes/index.php b/showtimes/index.php index 52a1fb4..f804ea9 100644 --- a/showtimes/index.php +++ b/showtimes/index.php @@ -1,6 +1,19 @@ +
+
+ '.$template->print_fimls().' +
+
'; + + //General page content: + require RAIZ_APP.'/HTMLtemplate.php'; + */ ?>