Add files via upload
This commit is contained in:
570
assets/css/main.css
Normal file
570
assets/css/main.css
Normal file
@ -0,0 +1,570 @@
|
||||
/* Basic */
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
/* Headers */
|
||||
h1, h2, h3, h4 {
|
||||
color: #363636;
|
||||
text-transform: uppercase;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 95%;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 85%;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 75%;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
button, .button.large {
|
||||
display: inline-block;
|
||||
margin: 10px;
|
||||
width: 150px;
|
||||
height: 30px;
|
||||
padding: 5px 10px;
|
||||
background-color :#1f2c3d;
|
||||
border: 1px solid #d3ebff;
|
||||
text-align: center;
|
||||
color :#d3ebff;
|
||||
font-weight: bold;
|
||||
position: relative;
|
||||
}
|
||||
.button.large {
|
||||
width: 95%;
|
||||
}
|
||||
button:hover, .button:hover {
|
||||
cursor: pointer;
|
||||
background-color:#d3ebff;
|
||||
color:#1f2c3d;
|
||||
border-color: #1f2c3d;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
.header {
|
||||
background-color: #1f2c3d;
|
||||
color: #dadada;
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
font-size: 18px;
|
||||
}
|
||||
.header img {
|
||||
width: 11px;
|
||||
}
|
||||
/* Header Menu */
|
||||
.menu {
|
||||
margin-top: 10px;
|
||||
text-align: right;
|
||||
font-size: 15px;
|
||||
}
|
||||
.menu nav a{
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
font-size: 15px;
|
||||
}
|
||||
.menu nav li{
|
||||
display: inline-block;
|
||||
width: 150px;
|
||||
height: 30px;
|
||||
padding: 5px 10px;
|
||||
background-color :#1f2c3d;
|
||||
border: 1px solid #d3ebff;
|
||||
text-align: center;
|
||||
color :#d3ebff;
|
||||
position: relative;
|
||||
}
|
||||
.menu nav li:hover{
|
||||
background-color:#d3ebff;
|
||||
color:#1f2c3d;
|
||||
border-color: #1f2c3d;
|
||||
}
|
||||
.menu nav li>ul{
|
||||
display: none;
|
||||
}
|
||||
.menu nav li:hover>ul{
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 29px;
|
||||
right: -1px;
|
||||
}
|
||||
/* Sub Header */
|
||||
.header.sub {
|
||||
margin-bottom: 20px;
|
||||
padding: 5px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
font-size: 20px;
|
||||
}
|
||||
.header.sub .menu {
|
||||
margin-top: 0px;
|
||||
text-align: center;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
|
||||
/* Paragraphs */
|
||||
p {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #dadada;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover{
|
||||
color:rgb(138, 150, 32);
|
||||
}
|
||||
|
||||
/* Body */
|
||||
body {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
background-color: #d3ebff;
|
||||
color: #000000
|
||||
}
|
||||
|
||||
/* Table */
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
margin: 0 0 2em 0;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
font-size: 15px;
|
||||
}
|
||||
table a{
|
||||
color: #1f2c3d;
|
||||
}
|
||||
table tbody tr {
|
||||
border: solid 1px #1f2c3d;
|
||||
border-left: 0;
|
||||
border-right: 0;
|
||||
}
|
||||
table tbody tr:nth-child(2n + 1) {
|
||||
background-color: rgba(144, 144, 144, 0.25);
|
||||
}
|
||||
table td {
|
||||
padding: 0.75em 0.75em;
|
||||
}
|
||||
table th {
|
||||
color: #1f2c3d;
|
||||
font-size: 0.9em;
|
||||
font-weight: 600;
|
||||
padding: 0 0.85em 0.85em 0.85em;
|
||||
}
|
||||
table thead, table tfoot {
|
||||
border-bottom: solid 2px #1f2c3d;
|
||||
}
|
||||
table.alt {
|
||||
border-collapse: separate;
|
||||
}
|
||||
table.alt tbody tr td {
|
||||
border: solid 1px #1f2c3d;
|
||||
border-left-width: 0;
|
||||
border-top-width: 0;
|
||||
}
|
||||
|
||||
table.alt tbody tr td:first-child {
|
||||
border-left-width: 1px;
|
||||
}
|
||||
|
||||
table.alt tbody tr:first-child td {
|
||||
border-top-width: 1px;
|
||||
}
|
||||
|
||||
table.alt thead, table.alt tfoot {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
|
||||
/* Main */
|
||||
.main {
|
||||
padding: 30px;
|
||||
text-align: center;
|
||||
font-size: 35px;
|
||||
}
|
||||
.main h1, h2, h3, h4 {
|
||||
color: #363636;
|
||||
}
|
||||
.main img {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
/* Create three unequal columns that floats next to each other */
|
||||
.column {
|
||||
float: left;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
/* Left and right column */
|
||||
.column.side {
|
||||
width: 33.33%;
|
||||
}
|
||||
|
||||
/* Middle column */
|
||||
.column.middle {
|
||||
width: 33.33%;
|
||||
}
|
||||
|
||||
.column.middle .image img, .column.side .image img{
|
||||
border-radius: 4px;
|
||||
border: 0;
|
||||
position: relative;
|
||||
border-radius: 4px;
|
||||
display: block;
|
||||
margin: 0 0 3rem 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Left column */
|
||||
.column.left {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
/* Right column */
|
||||
.column.right {
|
||||
float: right;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
/* Clear floats after the columns */
|
||||
.row:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* Responsive layout: makes the three columns stack on top of each other instead of next to each other */
|
||||
@media (max-width: 1000px) {
|
||||
.column.side, .column.middle, .column.left, .column.right{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
/* Zoom */
|
||||
.zoom {
|
||||
transition: transform .2s;
|
||||
}
|
||||
.zoom:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
/* Code & Blockquote */
|
||||
.code {
|
||||
background: #1f2c3d;
|
||||
border-radius: 3px;
|
||||
font-size: 0.9em;
|
||||
margin: 10px;
|
||||
display: block;
|
||||
line-height: 1.75em;
|
||||
padding: 1em 1.5em;
|
||||
overflow-x: auto;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.code h1, .code h2{
|
||||
color: #dadada;
|
||||
}
|
||||
.code h3, .code h4 {
|
||||
color: #d3ebff;
|
||||
}
|
||||
.code p {
|
||||
color: #dadada;
|
||||
}
|
||||
.code a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.code ul, .code ol {
|
||||
color: #dadada;
|
||||
}
|
||||
.code img{
|
||||
/* width: 80px; height: 80px; */
|
||||
width: 25%;
|
||||
}
|
||||
.code fieldset{
|
||||
margin: 1px;
|
||||
border-color: #dadada;
|
||||
border-style: groove;
|
||||
}
|
||||
.code fieldset legend {
|
||||
text-transform: uppercase;
|
||||
font-weight: bold;
|
||||
font-size: 90%;
|
||||
color: #d3ebff;
|
||||
}
|
||||
.code.details{
|
||||
height: 750px;
|
||||
}
|
||||
.code.plan {
|
||||
height: 1150px;
|
||||
}
|
||||
.code.info{
|
||||
text-align: center;
|
||||
height: 250px;
|
||||
}
|
||||
.code.showtimes{
|
||||
height: 600px;
|
||||
}
|
||||
|
||||
|
||||
/* BlockQuotes */
|
||||
.blockquote {
|
||||
border-left: solid 4px #dadada;
|
||||
margin: 0 0 2em 0;
|
||||
margin-top: 10px;
|
||||
padding: 0.5em 0 0.5em 2em;
|
||||
}
|
||||
.blockquote.bio {
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
/* Sketches */
|
||||
.sketches {
|
||||
text-align: center;
|
||||
display: block;
|
||||
line-height: 1.25em;
|
||||
padding: 1em 1em;
|
||||
overflow-x: auto;
|
||||
background: #1f2c3d;
|
||||
border-radius: 3px;
|
||||
height: 680px;
|
||||
}
|
||||
.sketches h1, .sketches h2, .sketches h3, .sketches h4, .sketches p {
|
||||
color: #dadada;
|
||||
}
|
||||
.sketches img {
|
||||
width: 550px;
|
||||
height: 550px;
|
||||
}
|
||||
.sketches .description {
|
||||
color: #d3ebff;
|
||||
}
|
||||
/* Responsive layout */
|
||||
@media (max-width: 1500px) {
|
||||
.column.side .sketches, .column.middle .sketches {
|
||||
width: 100%;
|
||||
height: 500px;
|
||||
}
|
||||
.column.side .sketches img, .column.middle .sketches img {
|
||||
width: 100%;
|
||||
height: 75%;
|
||||
}
|
||||
}
|
||||
@media (max-width: 1150px) {
|
||||
.sketches img {
|
||||
width: 100%;
|
||||
height: 75%;
|
||||
}
|
||||
}
|
||||
|
||||
/* Text Box */
|
||||
.textbox {
|
||||
color: #d3ebff;
|
||||
padding: 15px 15px 10px 15px;
|
||||
margin: 10px 0 10px;
|
||||
overflow: hidden;
|
||||
border-radius: 25px 0px 25px 0px;
|
||||
border: 2px solid #d3ebff;
|
||||
}
|
||||
.textbox h1, .textbox h2, .textbox h3 {
|
||||
color: #d3ebff;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* Galery */
|
||||
.galery {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.galery .columna {
|
||||
margin-top: 10px;
|
||||
float: left;
|
||||
width: 50%;
|
||||
padding-right: 10px;
|
||||
}
|
||||
.galery .fila::after {
|
||||
content: "";
|
||||
clear: both;
|
||||
display: table;
|
||||
}
|
||||
.galery .image img {
|
||||
width: 100%;
|
||||
}
|
||||
.galery .image.main img {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
/* Percentage bar */
|
||||
.bar {
|
||||
height: 15px;
|
||||
line-height: 15px;
|
||||
font-size: 13px;
|
||||
font-weight: bold;
|
||||
width: 100%;
|
||||
color: #00020f;
|
||||
background-color: #d3ebff;
|
||||
text-align: right;
|
||||
}
|
||||
.bar.seventyfive {
|
||||
width: 75%;
|
||||
}
|
||||
.bar.fifty {
|
||||
width: 50%;
|
||||
}
|
||||
.bar.twentyfive {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
/* Timeline Image */
|
||||
.timeline h2 {
|
||||
padding-top: 50px;
|
||||
}
|
||||
.timeline img{
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
padding-bottom: 50px;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
/* Sidebars */
|
||||
.sidebar.left {
|
||||
padding: 5px;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
float: left;
|
||||
width: 300px;
|
||||
height: 370PX;
|
||||
color: #d3ebff;
|
||||
background-color: #1f2c3d;
|
||||
}
|
||||
.sidebar.left a {
|
||||
color: #d3ebff;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
}
|
||||
.sidebar.left a:hover {
|
||||
color: #d3ebff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
/* Responsibe sidebar */
|
||||
@media (max-width: 1000px) {
|
||||
.sidebar.left {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Form */
|
||||
form {
|
||||
margin: auto;
|
||||
width: 65%;
|
||||
}
|
||||
|
||||
form h1, h2, h3, h4 {
|
||||
color: #363636;
|
||||
}
|
||||
|
||||
label {
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
input, textarea {
|
||||
width: 100%;
|
||||
height: 27px;
|
||||
border: 1px solid #000000;
|
||||
padding: 10px;
|
||||
margin-top: 5px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 100%;
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
#radio, #checkbox {
|
||||
width: auto;
|
||||
height: 15px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.verify {
|
||||
font-size: 11px;
|
||||
}
|
||||
.verify a {
|
||||
color: #1f2c3d;
|
||||
}
|
||||
.verify a:hover {
|
||||
color: rgb(138, 150, 32);
|
||||
}
|
||||
|
||||
#submit {
|
||||
width: 100%;
|
||||
height: 35px;
|
||||
border: 1px solid #000000;
|
||||
padding: 5px;
|
||||
margin-top: 5px;
|
||||
font-size: 15px;
|
||||
font-weight: bold;
|
||||
box-shadow: 2px 2px #1f2c3d;
|
||||
filter: brightness(105%);
|
||||
cursor: pointer;
|
||||
}
|
||||
#submit:hover {
|
||||
background-color: #d3ebff;
|
||||
}
|
||||
|
||||
#reset {
|
||||
width: 100%;
|
||||
height: 30px;
|
||||
border: 1px solid #dadada;
|
||||
background-color: #00020f;
|
||||
color: #dadada;
|
||||
padding: 5px;
|
||||
margin-top: 5px;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
box-shadow: 2px 2px #1f2c3d;
|
||||
cursor: pointer;
|
||||
}
|
||||
#reset:hover {
|
||||
border:#000000;
|
||||
background-color: #791515;
|
||||
}
|
||||
|
||||
|
||||
/* Footer */
|
||||
footer {
|
||||
text-align: left;
|
||||
background-color: #1f2c3d;
|
||||
color: #dadada;
|
||||
padding: 20px;
|
||||
margin-top: 100px;
|
||||
width: 100%;
|
||||
height: 80px;
|
||||
}
|
||||
.footer {
|
||||
text-align: right;
|
||||
}
|
||||
@media (max-width: 500px) {
|
||||
footer {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
3
assets/index.php
Normal file
3
assets/index.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
header('Location: ../');
|
||||
?>
|
9
assets/php/config.php
Normal file
9
assets/php/config.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
//Start session:
|
||||
session_start();
|
||||
|
||||
//HTML template:
|
||||
require_once('template.php');
|
||||
$template = new Template();
|
||||
$prefix = $template->get_prefix();
|
||||
?>
|
37
assets/php/dao.php
Normal file
37
assets/php/dao.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// TO-DO: Completar
|
||||
class DAO {
|
||||
//Constants:
|
||||
private const _SERVERNAME = "localhost";
|
||||
private const _USERNAME = "sw";
|
||||
private const _PASSWORD = "_admin_";
|
||||
private const _BD = "complucine";
|
||||
|
||||
//Atributes:
|
||||
public $mysqli;
|
||||
|
||||
//Constructor:
|
||||
public function __construct($bd_name){
|
||||
if($bd_name == null) $bd_name = self::_BD;
|
||||
try{
|
||||
if (!$this->mysqli) {
|
||||
$this->mysqli = new mysqli(self::_SERVERNAME, self::_USERNAME,
|
||||
self::_PASSWORD, $bd_name);
|
||||
}
|
||||
// echo "Conexión a la BD, satisfactoria.";
|
||||
} catch (Exception $e){
|
||||
echo "Error de conexión a la BD: ". mysqli_connect_error();
|
||||
exit();
|
||||
}
|
||||
|
||||
/* ... */
|
||||
}
|
||||
|
||||
//Destructor:
|
||||
public function __destruct(){
|
||||
$this->mysqli->close();
|
||||
}
|
||||
|
||||
//Methods:
|
||||
}
|
||||
?>
|
238
assets/php/form.php
Normal file
238
assets/php/form.php
Normal file
@ -0,0 +1,238 @@
|
||||
<?php
|
||||
|
||||
class Form {
|
||||
/**
|
||||
* Sufijo para el nombre del parámetro de la sesión del usuario donde se almacena el token CSRF.
|
||||
*/
|
||||
const CSRF_PARAM = 'csrf';
|
||||
|
||||
/**
|
||||
* Cadena utilizada como valor del atributo "id" de la etiqueta <form> asociada al formulario y como parámetro a comprobar para verificar que el usuario ha enviado el formulario.
|
||||
*/
|
||||
private $formId;
|
||||
|
||||
private $ajax;
|
||||
|
||||
/**
|
||||
* URL asociada al atributo "action" de la etiqueta <form> del fomrulario y que procesará el envío del formulario.
|
||||
*/
|
||||
private $action;
|
||||
|
||||
/**
|
||||
* Valor del atributo "class" de la etiqueta <form> asociada al formulario. Si este parámetro incluye la cadena "nocsrf" no se generá el token CSRF para este formulario.
|
||||
*/
|
||||
private $classAtt;
|
||||
|
||||
/**
|
||||
* Valor del parámetro enctype del formulario.
|
||||
*/
|
||||
private $enctype;
|
||||
|
||||
/**
|
||||
* Se encarga de orquestar todo el proceso de creación y procesamiento de un formulario web.
|
||||
*
|
||||
* @param string $formId Cadena utilizada como valor del atributo "id" de la etiqueta <form> asociada al formulario y como parámetro a comprobar para verificar que el usuario ha enviado el formulario.
|
||||
*
|
||||
* @param string $action (opcional) URL asociada al atributo "action" de la etiqueta <form> del fomrulario y que procesará el envío del formulario. Por defecto la URL es $_SERVER['PHP_SELF']
|
||||
*
|
||||
* @param string $class (opcional) Valor del atributo "class" de la etiqueta <form> asociada al formulario. Si este parámetro incluye la cadena "nocsrf" no se generá el token CSRF para este formulario.
|
||||
*
|
||||
* @param string enctype (opcional) Valor del parámetro enctype del formulario.
|
||||
*/
|
||||
public function __construct($formId, $opciones = array() ) {
|
||||
$this->formId = $formId;
|
||||
|
||||
$opcionesPorDefecto = array( 'ajax' => false, 'action' => null, 'class' => null, 'enctype' => null );
|
||||
$opciones = array_merge($opcionesPorDefecto, $opciones);
|
||||
|
||||
$this->ajax = $opciones['ajax'];
|
||||
$this->action = $opciones['action'];
|
||||
$this->classAtt = $opciones['class'];
|
||||
$this->enctype = $opciones['enctype'];
|
||||
|
||||
if ( !$this->action ) {
|
||||
$this->action = $_SERVER['PHP_SELF'];
|
||||
}
|
||||
}
|
||||
|
||||
public function gestiona() {
|
||||
|
||||
if ( ! $this->formularioEnviado($_POST) ) {
|
||||
echo $this->generaFormulario();
|
||||
} else {
|
||||
// Valida el token CSRF si es necesario (hay un token en la sesión asociada al formulario)
|
||||
$tokenRecibido = isset($_POST['CSRFToken']) ? $_POST['CSRFToken'] : FALSE;
|
||||
|
||||
if ( ($errores = $this->csrfguard_ValidateToken($this->formId, $tokenRecibido)) !== TRUE ) {
|
||||
if ( ! $this->ajax ) {
|
||||
echo $this->generaFormulario($errores, $_POST);
|
||||
} else {
|
||||
echo $this->generaHtmlErrores($errores);
|
||||
}
|
||||
} else {
|
||||
$result = $this->procesaFormulario($_POST);
|
||||
if ( is_array($result) ) {
|
||||
// Error al procesar el formulario, volvemos a mostrarlo
|
||||
if ( ! $this->ajax ) {
|
||||
echo $this->generaFormulario($result, $_POST);
|
||||
} else {
|
||||
echo $this->generaHtmlErrores($result);
|
||||
}
|
||||
} else {
|
||||
if ( ! $this->ajax ) {
|
||||
header('Location: '.$result);
|
||||
} else {
|
||||
echo $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve un <code>string</code> con el HTML necesario para presentar los campos del formulario. Es necesario asegurarse que como parte del envío se envía un parámetro con nombre <code$formId</code> (i.e. utilizado como valor del atributo name del botón de envío del formulario).
|
||||
*/
|
||||
protected function generaCamposFormulario ($datos) {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Procesa los datos del formulario.
|
||||
*/
|
||||
protected function procesaFormulario($datos) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Función que verifica si el usuario ha enviado el formulario. Comprueba si existe el parámetro <code>$formId</code> en <code>$params</code>.
|
||||
*
|
||||
* @param array $params Array que contiene los datos recibidos en el envío formulario.
|
||||
*
|
||||
* @return boolean Devuelve <code>TRUE</code> si <code>$formId</code> existe como clave en <code>$params</code>
|
||||
*/
|
||||
private function formularioEnviado(&$params) {
|
||||
return isset($params['action']) && $params['action'] == $this->formId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Función que genera el HTML necesario para el formulario.
|
||||
*
|
||||
*
|
||||
* @param array $errores (opcional) Array con los mensajes de error de validación y/o procesamiento del formulario.
|
||||
*
|
||||
* @param array $datos (opcional) Array con los valores por defecto de los campos del formulario.
|
||||
*/
|
||||
private function generaFormulario($errores = array(), &$datos = array()) {
|
||||
|
||||
$html= $this->generaListaErrores($errores);
|
||||
|
||||
$html .= '<form method="POST" action="'.$this->action.'" id="'.$this->formId.'"';
|
||||
if ( $this->classAtt ) {
|
||||
$html .= ' class="'.$this->classAtt.'"';
|
||||
}
|
||||
if ( $this->enctype ) {
|
||||
$html .= ' enctype="'.$this->enctype.'"';
|
||||
}
|
||||
$html .=' >';
|
||||
|
||||
// Se genera el token CSRF si el usuario no solicita explícitamente lo contrario.
|
||||
if ( ! $this->classAtt || strpos($this->classAtt, 'nocsrf') === false ) {
|
||||
$tokenValue = $this->csrfguard_GenerateToken($this->formId);
|
||||
$html .= '<input type="hidden" name="CSRFToken" value="'.$tokenValue.'" />';
|
||||
}
|
||||
|
||||
$html .= '<input type="hidden" name="action" value="'.$this->formId.'" />';
|
||||
|
||||
$html .= $this->generaCamposFormulario($datos);
|
||||
$html .= '</form>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function generaListaErrores($errores) {
|
||||
$html='';
|
||||
$numErrores = count($errores);
|
||||
if ( $numErrores == 1 ) {
|
||||
$html .= "<ul><li>".$errores[0]."</li></ul>";
|
||||
} else if ( $numErrores > 1 ) {
|
||||
$html .= "<ul><li>";
|
||||
$html .= implode("</li><li>", $errores);
|
||||
$html .= "</li></ul>";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function csrfguard_GenerateToken($formId) {
|
||||
if ( ! isset($_SESSION) ) {
|
||||
throw new Exception('La sesión del usuario no está definida.');
|
||||
}
|
||||
|
||||
if ( function_exists('hash_algos') && in_array('sha512', hash_algos()) ) {
|
||||
$token = hash('sha512', mt_rand(0, mt_getrandmax()));
|
||||
} else {
|
||||
$token=' ';
|
||||
for ($i=0;$i<128;++$i) {
|
||||
$r=mt_rand(0,35);
|
||||
if ($r<26){
|
||||
$c=chr(ord('a')+$r);
|
||||
} else{
|
||||
$c=chr(ord('0')+$r-26);
|
||||
}
|
||||
$token.=$c;
|
||||
}
|
||||
}
|
||||
|
||||
$_SESSION[$formId.'_'.self::CSRF_PARAM]=$token;
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
private function csrfguard_ValidateToken($formId, $tokenRecibido) {
|
||||
if ( ! isset($_SESSION) ) {
|
||||
throw new Exception('La sesión del usuario no está definida.');
|
||||
}
|
||||
|
||||
$result = TRUE;
|
||||
|
||||
if ( isset($_SESSION[$formId.'_'.self::CSRF_PARAM]) ) {
|
||||
if ( $_SESSION[$formId.'_'.self::CSRF_PARAM] !== $tokenRecibido ) {
|
||||
$result = array();
|
||||
$result[] = 'Has enviado el formulario dos veces';
|
||||
}
|
||||
$_SESSION[$formId.'_'.self::CSRF_PARAM] = ' ';
|
||||
unset($_SESSION[$formId.'_'.self::CSRF_PARAM]);
|
||||
} else {
|
||||
$result = array();
|
||||
$result[] = 'Formulario no válido';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
class Formulario {
|
||||
|
||||
private $formId;
|
||||
private $action;
|
||||
private $classAtt;
|
||||
private $enctype;
|
||||
|
||||
public function __construct($formId, $opciones = array() ) {
|
||||
$this->formId = $formId;
|
||||
$opcionesPorDefecto = array( 'ajax' => false, 'action' => null, 'class' => null,
|
||||
'enctype' => null );
|
||||
$opciones = array_merge($opcionesPorDefecto, $opciones);
|
||||
|
||||
$this->ajax = $opciones['ajax'];
|
||||
$this->action = $opciones['action'];
|
||||
$this->classAtt = $opciones['class'];
|
||||
$this->enctype = $opciones['enctype'];
|
||||
|
||||
if (!$this->action) {
|
||||
$app = Aplicacion::getSingleton();
|
||||
$this->action = htmlspecialchars($_SERVER['REQUEST_URI']);
|
||||
$this->action = $app->resuelve($this->action);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
?>
|
185
assets/php/template.php
Normal file
185
assets/php/template.php
Normal file
@ -0,0 +1,185 @@
|
||||
<?php
|
||||
class Template {
|
||||
|
||||
//Attributes:
|
||||
public $page; //Page Name.
|
||||
public $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).
|
||||
|
||||
//Constructor:
|
||||
function __construct(){
|
||||
$this->page = $_SERVER['PHP_SELF']; //Page that instantiates the template.
|
||||
$this->prefix = '../'; //Default prefix.
|
||||
|
||||
$this->set_page_prefix(); //Assigns the name and prefix of the page.
|
||||
|
||||
$this->session = 'Iniciar Sesión'; //Default, the session has not started.
|
||||
$this->session_route = 'login/'; //Default, the session has not started.
|
||||
$this->panel = ''; //Default, the session has not started.
|
||||
$this->user_route = 'panel_user/'; //Default, the type of client is user.
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Assigns the name and prefix of the page:
|
||||
private function set_page_prefix() {
|
||||
switch(true){
|
||||
case strpos($this->page, 'panel_user'): $this->page = 'Panel de Usuario'; break;
|
||||
case strpos($this->page, 'panel_manager'): $this->page = 'Panel de Gerente'; break;
|
||||
case strpos($this->page, 'panel_admin'): $this->page = 'Panel de Administrador'; break;
|
||||
case strpos($this->page, 'login'): $this->page = 'Acceso'; break;
|
||||
case strpos($this->page, 'logout'): $this->page = 'Cerrar Sesión'; break;
|
||||
case strpos($this->page, 'register'): $this->page = 'Registro de Usuario'; break;
|
||||
case strpos($this->page, 'showtimes'): $this->page = 'Cartelera'; break;
|
||||
case strpos($this->page, 'cinemas'): $this->page = 'Nuestros Cines'; break;
|
||||
case strpos($this->page, 'about_us'): $this->page = 'Sobre FDI-Cines'; $this->prefix = '../../'; break;
|
||||
case strpos($this->page, 'terms'): $this->page = 'Términos y Condiciones'; $this->prefix = '../../'; break;
|
||||
case strpos($this->page, 'detalles'): $this->page = 'Detalles'; $this->prefix = '../../'; break;
|
||||
case strpos($this->page, 'bocetos'): $this->page = 'Bocetos'; $this->prefix = '../../'; break;
|
||||
case strpos($this->page, 'miembros'): $this->page = 'Miembros'; $this->prefix = '../../'; break;
|
||||
case strpos($this->page, 'planificacion'): $this->page = 'Planificación'; $this->prefix = '../../'; break;
|
||||
case strpos($this->page, 'contacto'): $this->page = 'Contacto'; break;
|
||||
default: $this->page = 'FDI-Cines'; $this->prefix = './'; break;
|
||||
}
|
||||
}
|
||||
|
||||
//Returns page name:
|
||||
function get_page(){
|
||||
return $this->page;
|
||||
}
|
||||
|
||||
//Returns page prefix:
|
||||
function get_prefix(){
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
//Print generic Head:
|
||||
function print_head(){
|
||||
$page = $this->page;
|
||||
$prefix = $this->prefix;
|
||||
|
||||
echo"<head>
|
||||
<title>CompluCine | {$page}</title>
|
||||
<meta charset='utf-8' />
|
||||
<link id='estilo' rel='stylesheet' type='text/css' href='{$prefix}assets/css/main.css'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||
<link rel='icon' href='{$prefix}img/favicon.png' />
|
||||
</head>\n";
|
||||
}
|
||||
|
||||
//Print generic Header:
|
||||
function print_header(){
|
||||
$page = $this->page;
|
||||
$prefix = $this->prefix;
|
||||
$session = $this->session;
|
||||
$session_route =$this->session_route;
|
||||
$user_route = $this->user_route;
|
||||
$panel =$this->panel;
|
||||
|
||||
if(isset($_SESSION["nombre"])){
|
||||
if($_SESSION["rol"] == "admin") $user_route = 'panel_admin/';
|
||||
else if($_SESSION["rol"] == "manager") $user_route = 'panel_manager/';
|
||||
$panel = "<a href='{$prefix}{$user_route}'><li>Mi Panel</li></a>";
|
||||
$session = 'Cerrar Sesión';
|
||||
$session_route = 'logout/';
|
||||
}
|
||||
|
||||
echo"<div class='header'>
|
||||
<a href='{$prefix}'><img src='{$prefix}img/favicon2.png' alt='favicon' /> CompluCine</a> | {$page}
|
||||
<div class='menu'>
|
||||
<nav>
|
||||
<a href='{$prefix}{$session_route}'><li>{$session}</li></a>
|
||||
{$panel}
|
||||
<li>Menú
|
||||
<ul>
|
||||
<a href='{$prefix}'><li>Inicio</li></a>
|
||||
<a href='{$prefix}showtimes/'><li>Cartelera</li></a>
|
||||
<a href='{$prefix}cinemas/'><li>Nuestros Cines</li></a>
|
||||
<a href='{$prefix}fdicines/miembros/'><li>Quiénes somos</li></a>
|
||||
<a href='{$prefix}contacto/'><li>Contacto</li></a>
|
||||
<ul>
|
||||
</li>
|
||||
</nav>
|
||||
</div>
|
||||
</div>\n";
|
||||
}
|
||||
|
||||
//Print generic subHeader:
|
||||
function print_subheader(){
|
||||
//$page = $this->page;
|
||||
$prefix = $this->prefix;
|
||||
|
||||
echo"<div class='header sub'>
|
||||
<div class='menu'>
|
||||
<nav>
|
||||
<a href='{$prefix}fdicines/about_us/'><li>Sobre FDI-Cines</li></a>
|
||||
<a href='{$prefix}fdicines/detalles/'><li>Detalles</li></a>
|
||||
<a href='{$prefix}fdicines/bocetos/'><li>Bocetos</li></a>
|
||||
<a href='{$prefix}fdicines/miembros/'><li>Miembros</li></a>
|
||||
<a href='{$prefix}fdicines/planificacion/'><li>Planificación</li></a>
|
||||
</nav>
|
||||
</div>
|
||||
</div>\n";
|
||||
}
|
||||
|
||||
//Print generic Main:
|
||||
function print_main(){
|
||||
$page = $this->page;
|
||||
$prefix = $this->prefix;
|
||||
|
||||
/* SubHeader on Main */
|
||||
$sub_header = '';
|
||||
if(strpos($_SERVER['PHP_SELF'], 'fdicines')){
|
||||
$sub_header = "<!-- Sub Header -->
|
||||
<div class='header sub'>
|
||||
<div class='menu'>
|
||||
<nav>
|
||||
<a href='{$prefix}fdicines/about_us/'><li>Sobre FDI-Cines</li></a>
|
||||
<a href='{$prefix}fdicines/detalles/'><li>Detalles</li></a>
|
||||
<a href='{$prefix}fdicines/bocetos/'><li>Bocetos</li></a>
|
||||
<a href='{$prefix}fdicines/miembros/'><li>Miembros</li></a>
|
||||
<a href='{$prefix}fdicines/planificacion/'><li>Planificación</li></a>
|
||||
</nav>
|
||||
</div>
|
||||
</div>\n";
|
||||
}
|
||||
|
||||
/* MAIN */
|
||||
echo"<div class='main'>
|
||||
<div class='image'><a href='{$prefix}'><img src='{$prefix}img/logo_trasparente.png' alt='logo_FDI-Cines' /></a></div>
|
||||
{$sub_header}
|
||||
<h1>{$page}</h1>
|
||||
<hr />
|
||||
</div>\n";
|
||||
}
|
||||
|
||||
//Print session MSG:
|
||||
function print_msg() {
|
||||
if(isset($_SESSION['message'])){
|
||||
echo "<div>".$_SESSION['message']."</div>";
|
||||
unset($_SESSION['message']);
|
||||
}
|
||||
}
|
||||
|
||||
//Print generic Footer:
|
||||
function print_footer(){
|
||||
//$page = $this->page;
|
||||
$prefix = $this->prefix;
|
||||
|
||||
echo"<footer>
|
||||
<div class='footer'>
|
||||
<p>© Práctica 2 | Sistemas Web 2021 </p>
|
||||
</div>
|
||||
<a href='{$prefix}fdicines/about_us/'>Sobre FDI-Cines</a> |
|
||||
<a href='{$prefix}fdicines/terms_conditions/'>Términos y condiciones</a> |
|
||||
<a href='{$prefix}cinemas/'>Nuestros cines</a> |
|
||||
<a href='{$prefix}contacto/'>Contacto</a>
|
||||
</footer>\n";
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user