Forráskód Böngészése

Merge branch 'master' into Help

Iñigo Valentin 9 éve
szülő
commit
5043317e98
100 módosított fájl, 7967 hozzáadás és 6675 törlés
  1. 5 1
      .gitignore
  2. 60 0
      README.es-ES.md
  3. 60 0
      README.es-EU.md
  4. 14 7
      README.md
  5. 328 314
      sql/setup.sql
  6. 567 0
      utils/GMSchedule.php
  7. 6 0
      utils/imgresize
  8. 163 163
      www-admin/actividades/add/add.php
  9. 105 105
      www-admin/actividades/add/additinerary.php
  10. 126 126
      www-admin/actividades/add/index.php
  11. 97 97
      www-admin/actividades/add/itinerary.php
  12. 167 167
      www-admin/actividades/add/script.js
  13. 9 9
      www-admin/actividades/delete/delete.php
  14. 9 9
      www-admin/actividades/edit/edit.php
  15. 23 23
      www-admin/actividades/edit/index.php
  16. 100 100
      www-admin/actividades/index.php
  17. 25 25
      www-admin/actividades/moderate/index.php
  18. 76 76
      www-admin/actividades/translate/apply.php
  19. 88 88
      www-admin/actividades/translate/index.php
  20. 105 105
      www-admin/actividades/translate/translate.php
  21. 0 0
      www-admin/ajustes/guardar.php
  22. 58 1
      www-admin/ajustes/index.php
  23. 129 129
      www-admin/blog/add/add.php
  24. 111 111
      www-admin/blog/add/index.php
  25. 105 105
      www-admin/blog/add/script.js
  26. 14 14
      www-admin/blog/delete/delete.php
  27. 130 130
      www-admin/blog/edit/edit.php
  28. 193 193
      www-admin/blog/edit/index.php
  29. 110 110
      www-admin/blog/edit/script.js
  30. 102 102
      www-admin/blog/index.php
  31. 27 27
      www-admin/blog/moderate/index.php
  32. 21 21
      www-admin/blog/script.js
  33. 36 36
      www-admin/blog/translate/apply.php
  34. 59 59
      www-admin/blog/translate/index.php
  35. 70 70
      www-admin/blog/translate/translate.php
  36. 46 46
      www-admin/ckeditor/build-config.js
  37. 24 24
      www-admin/ckeditor/config.js
  38. 60 60
      www-admin/ckeditor/contents.css
  39. 95 95
      www-admin/ckeditor/samples/index.html
  40. 36 36
      www-admin/ckeditor/samples/js/sample.js
  41. 44 44
      www-admin/ckeditor/samples/old/assets/outputxhtml/outputxhtml.css
  42. 38 38
      www-admin/ckeditor/samples/old/assets/posteddata.php
  43. 40 40
      www-admin/ckeditor/samples/old/dialog/assets/my_dialog.js
  44. 135 135
      www-admin/ckeditor/samples/old/sample.css
  45. 40 40
      www-admin/ckeditor/samples/old/sample.js
  46. 93 93
      www-admin/ckeditor/styles.js
  47. 112 112
      www-admin/css/actividades.css
  48. 56 56
      www-admin/css/blog.css
  49. 13 0
      www-admin/css/estadisticas.css
  50. 50 61
      www-admin/css/galeria.css
  51. 2 2
      www-admin/css/galleria.css
  52. 2 2
      www-admin/css/gallery.css
  53. 3 3
      www-admin/css/index.css
  54. 103 99
      www-admin/css/lablanca.css
  55. 115 115
      www-admin/css/m/ui.css
  56. 11 11
      www-admin/css/main.css
  57. 41 41
      www-admin/css/miembros.css
  58. 152 152
      www-admin/css/ui.css
  59. 175 0
      www-admin/estadisticas/web/index.php
  60. 270 258
      www-admin/functions.php
  61. 102 1
      www-admin/galeria/add/add.php
  62. 92 0
      www-admin/galeria/add/index.php
  63. 15 15
      www-admin/galeria/edit/index.php
  64. 80 14
      www-admin/galeria/index.php
  65. 15 15
      www-admin/galeria/moderate/index.php
  66. 69 69
      www-admin/galeria/translate/apply.php
  67. 80 80
      www-admin/galeria/translate/index.php
  68. 82 82
      www-admin/galeria/translate/translate.php
  69. 41 40
      www-admin/index.php
  70. 15 15
      www-admin/lablanca/add/index.php
  71. 169 169
      www-admin/lablanca/calculate.php
  72. 13 13
      www-admin/lablanca/edit/index.php
  73. 43 43
      www-admin/lablanca/execute.php
  74. 256 239
      www-admin/lablanca/index.php
  75. 59 59
      www-admin/lablanca/insertoffer.php
  76. 13 13
      www-admin/lablanca/moderate/index.php
  77. 200 200
      www-admin/lablanca/script.js
  78. 13 13
      www-admin/lablanca/translate/index.php
  79. 75 75
      www-admin/lablanca/uploadimage.php
  80. 8 8
      www-admin/login.php
  81. 120 121
      www-admin/main.php
  82. 13 13
      www-admin/miembros/add/index.php
  83. 13 13
      www-admin/miembros/edit/index.php
  84. 88 88
      www-admin/miembros/index.php
  85. 186 186
      www-admin/miembros/miembro-bkp.php
  86. 205 205
      www-admin/miembros/miembro.php
  87. 13 13
      www-admin/miembros/moderate/index.php
  88. 16 16
      www-admin/miembros/script.js
  89. 13 13
      www-admin/miembros/translate/index.php
  90. 7 0
      www-admin/salir/index.php
  91. 130 130
      www-admin/script/blog.js
  92. 27 27
      www-admin/script/ui.js
  93. 120 119
      www-admin/toolbar.php
  94. 33 0
      www-admin/usuarios/index.php
  95. 9 2
      www/.htaccess
  96. 308 308
      www/API/v1/comment.php
  97. 50 50
      www/API/v1/help/comment.php
  98. 50 50
      www/API/v1/help/index.php
  99. 50 50
      www/API/v1/help/sync.php
  100. 22 22
      www/API/v1/help/toolbar.php

+ 5 - 1
.gitignore

@@ -14,18 +14,22 @@ Thumbs.db
 #Utility folders
 3rdparty/
 pending/
-utils/
+utils-local/
 copy
 remotecopy
+remoteadmin
+www-admin/redirect_s.php
 
 #SQL data
 sql/dbusers.sql
 sql/rows-test.sql
 sql/rows.sql
+sql/*201*
 
 #Passwords file
 www/.htpasswd
 www-admin/.htpasswd
+www/.htaccess_local
 
 #Photos and unnecessary images
 www/img/actividades/script

+ 60 - 0
README.es-ES.md

@@ -0,0 +1,60 @@
+---
+[Information in english](README.md) 
+[Informazioa euskaraz](README.es-EU.md)
+---
+
+# Web Gasteizko Margolariak #
+
+Código fuente de el sitio web de [Gasteizko Margolariak](https://margolariak.com/)
+
+Diseñado sobre Apache+MySQL+PHP.
+
+### Página pública ###
+
+La parte disponible al público es ligera, respetuosa con la privacidad del usuario e incluye:
+
+* Un blog de noticias en el que los usuarios pueden comentar.
+* Una galeria de imágenes con la que los usuarios pueden contribuir.
+* Informacion sobre las próximas actividades.
+* Reseñas de actividades pasadas.
+* Durante las Fiestas, informacion sobre las actividades y el programa de la cuadrilla.
+* Durante las Fiestass, información sobre los precios y las ofertas.
+* Localización en tiempo real de Gasteizko Margolariak.
+* Informacion sobre la cuadrilla.
+* Publicidad personaliza, no intrusiva, de los patrocinadores.
+* Una API para sincronizar aplicaciones propias o de terceros.
+* Recolección respetuosa de estadísticas.
+* Vanity URLs.
+
+
+### Página privada ###
+
+La parte privada del portal, reservada para administradores. Protegida por contraseña.
+
+Por ahora, incluye:
+
+* Un formulario para publicar, editar, borrar y traducir entradas del blog.
+* Un formulario para publicar, editar, borrar y traducir actividades.
+* Gestión de socios.
+* Formulario para confeccionar el programa de Fiestas.
+* Registro de actividad.
+
+Funcionalidades previstas:
+
+* Gestión de cuentas de usuario.
+* Gestión de la galería.
+* Visor de estadísticas.
+* Ajustes del sitio.
+* Borradores.
+* Otros.
+
+
+### Sobre este proyecto ###
+
+Se incluye el código fuente para la parte privada y la pública, así como scripts para construir la base de datos.
+
+
+### Aplicaciones ###
+
+* Tienes un iPhone? [Estamos en ellos!](https://github.com/GasteizkoMargolariak/GasteizkoMargolariakIOSApp) 
+* Android? [Lo tenemos!](https://github.com/GasteizkoMargolariak/GasteizkoMargolariakApp)

+ 60 - 0
README.es-EU.md

@@ -0,0 +1,60 @@
+---
+[Informacion en castellano](README.es-ES.md) 
+[Information in english](README.md)
+---
+
+# Web Gasteizko Margolariak #
+
+Código fuente de el sitio web de [Gasteizko Margolariak](https://margolariak.com/)
+
+Diseñado sobre Apache+MySQL+PHP.
+
+### Página pública ###
+
+La parte disponible al público es ligera, respetuosa con la privacidad del usuario e incluye:
+
+* Un blog de noticias en el que los usuarios pueden comentar.
+* Una galeria de imágenes con la que los usuarios pueden contribuir.
+* Informacion sobre las próximas actividades.
+* Reseñas de actividades pasadas.
+* Durante las Fiestas, informacion sobre las actividades y el programa de la cuadrilla.
+* Durante las Fiestass, información sobre los precios y las ofertas.
+* Localización en tiempo real de Gasteizko Margolariak.
+* Informacion sobre la cuadrilla.
+* Publicidad personaliza, no intrusiva, de los patrocinadores.
+* Una API para sincronizar aplicaciones propias o de terceros.
+* Recolección respetuosa de estadísticas.
+* Vanity URLs.
+
+
+### Página privada ###
+
+La parte privada del portal, reservada para administradores. Protegida por contraseña.
+
+Por ahora, incluye:
+
+* Un formulario para publicar, editar, borrar y traducir entradas del blog.
+* Un formulario para publicar, editar, borrar y traducir actividades.
+* Gestión de socios.
+* Formulario para confeccionar el programa de Fiestas.
+* Registro de actividad.
+
+Funcionalidades previstas:
+
+* Gestión de cuentas de usuario.
+* Gestión de la galería.
+* Visor de estadísticas.
+* Ajustes del sitio.
+* Borradores.
+* Otros.
+
+
+### Sobre este proyecto ###
+
+Se incluye el código fuente para la parte privada y la pública, así como scripts para construir la base de datos.
+
+
+### Aplicaciones ###
+
+* Tienes un iPhone? [Estamos en ellos!](https://github.com/GasteizkoMargolariak/GasteizkoMargolariakIOSApp) 
+* Android? [Lo tenemos!](https://github.com/GasteizkoMargolariak/GasteizkoMargolariakApp)

+ 14 - 7
README.md

@@ -1,11 +1,10 @@
-Gasteizko Margolariak Web
-===
+# Gasteizko Margolariak Web #
 
-Source code of the <a href="http://margolariak.com/">Gasteizko Margolariak</a> Web Portal.
+Source code of the [Gasteizko Margolariak](https://margolariak.com/) Web Portal.
 
 Website designed to work over Apache+MySQL+PHP.
 
-###Public page###
+### Public page ###
 
 The public page is available for anyone to visit, is respectfull with the privacy of the user, lightweight, and it includes:
 
@@ -18,12 +17,12 @@ The public page is available for anyone to visit, is respectfull with the privac
 * Real time location of Gasteizko Margolariak.
 * Information and the History of Gasteizko Margolariak.
 * Custom-made, non intrusive, privacy-awatre advertisment of collaborators.
-* An API to sync the <a href="https://github.com/GasteizkoMargolariak/GasteizkoMargolariakApp">App</a>.
+* An API to sync apps.
 * A respectfull statistics counter.
 * Vanity URLs.
 
 
-###Private page###
+### Private pag e###
 
 The private page includes a private area for the directives of Gasteizko Margolariak. It is designed to be served on a different port and is password protected.
 
@@ -44,6 +43,14 @@ In the future, more functionalities will be added:
 * Drafts.
 * Many more.
 
-###About this project###
+
+### About this project ###
 
 This projets includes the source for both the public and private page, as well as the files required to build the database. Apache configuration is left as an exercice to the reader.
+
+
+### On other devices ###
+
+* Got an iPhone? [We are working on it!](https://github.com/GasteizkoMargolariak/GasteizkoMargolariakIOSApp) 
+* Android? [Got you covered!](https://github.com/GasteizkoMargolariak/GasteizkoMargolariakApp)
+

+ 328 - 314
sql/setup.sql

@@ -6,468 +6,482 @@ CONNECT gm;
 
 DROP TABLE IF EXISTS user;
 CREATE TABLE user (
-	id			INT				AUTO_INCREMENT	PRIMARY KEY,
-	username	VARCHAR(64)		NOT NULL,
-	email		VARCHAR(128)	NOT NULL,
-	password	CHAR(128)		NOT NULL,
-	salt		CHAR(128)		NOT NULL, 
-	fname		VARCHAR(64),
-	lname		VARCHAR(64),
-	picture		VARCHAR(100),
-	phone		VARCHAR(16),
-	cp			VARCHAR(6),
-	admin		BOOLEAN			NOT NULL		DEFAULT 0,
-	active		BOOLEAN			NOT NULL		DEFAULT 0
+    id            INT                AUTO_INCREMENT    PRIMARY KEY,
+    username    VARCHAR(64)        NOT NULL,
+    email        VARCHAR(128)    NOT NULL,
+    password    CHAR(128)        NOT NULL,
+    salt        CHAR(128)        NOT NULL, 
+    fname        VARCHAR(64),
+    lname        VARCHAR(64),
+    picture        VARCHAR(100),
+    phone        VARCHAR(16),
+    cp            VARCHAR(6),
+    admin        BOOLEAN            NOT NULL        DEFAULT 0,
+    active        BOOLEAN            NOT NULL        DEFAULT 0
 );
 
 DROP TABLE IF EXISTS login_attempts;
 CREATE TABLE login_attempts (
-	user	INT			NOT NULL	references user.id,
-	dtime	VARCHAR(30)	NOT NULL
+    user    INT            NOT NULL    references user.id,
+    dtime    VARCHAR(30)    NOT NULL
 );
 
 DROP TABLE IF EXISTS permissions;
 CREATE TABLE permissions(
-	user		INT			PRIMARY KEY references user.id,
-	access		BOOLEAN		NOT NULL	DEFAULT 1,
-	post		BOOLEAN		NOT NULL	DEFAULT 1,
-	settings	BOOLEAN		NOT NULL	DEFAULT 1,
-	money_r		BOOLEAN		NOT NULL	DEFAULT 0,
-	money_w		BOOLEAN		NOT NULL	DEFAULT 0,
-	manager		BOOLEAN		NOT NULL	DEFAULT 0
+    user        INT            PRIMARY KEY references user.id,
+    access        BOOLEAN        NOT NULL    DEFAULT 1,
+    post        BOOLEAN        NOT NULL    DEFAULT 1,
+    settings    BOOLEAN        NOT NULL    DEFAULT 1,
+    money_r        BOOLEAN        NOT NULL    DEFAULT 0,
+    money_w        BOOLEAN        NOT NULL    DEFAULT 0,
+    manager        BOOLEAN        NOT NULL    DEFAULT 0
 );
 
 DROP TABLE IF EXISTS post;
 CREATE TABLE post (
-	id			INT				AUTO_INCREMENT	PRIMARY KEY,
-	permalink	VARCHAR(300)	NOT NULL,
-	title_es	VARCHAR(300)	NOT NULL,
-	title_en	VARCHAR(300),
-	title_eu	VARCHAR(300),
-	text_es		VARCHAR(5000)	NOT NULL,
-	text_en		VARCHAR(5000),
-	text_eu		VARCHAR(5000),
-	user		INT				NOT NULL		DEFAULT 1	REFERENCES user.id,
-	dtime		TIMESTAMP		NOT NULL		DEFAULT now(),
-	visible		BOOLEAN			NOT NULL		DEFAULT	1,
-	comments	BOOLEAN			NOT NULL		DEFAULT 1
+    id            INT                AUTO_INCREMENT    PRIMARY KEY,
+    permalink    VARCHAR(300)    NOT NULL,
+    title_es    VARCHAR(300)    NOT NULL,
+    title_en    VARCHAR(300),
+    title_eu    VARCHAR(300),
+    text_es        VARCHAR(5000)    NOT NULL,
+    text_en        VARCHAR(5000),
+    text_eu        VARCHAR(5000),
+    user        INT                NOT NULL        DEFAULT 1    REFERENCES user.id,
+    dtime        TIMESTAMP        NOT NULL        DEFAULT now(),
+    visible        BOOLEAN            NOT NULL        DEFAULT    1,
+    comments    BOOLEAN            NOT NULL        DEFAULT 1
 );
 
 DROP TABLE IF EXISTS post_tag;
 CREATE TABLE post_tag (
-	post	INT			NOT NULL	REFERENCES post.id,
-	tag		VARCHAR(64)	NOT NULL,
-	PRIMARY KEY (post, tag)
+    post    INT            NOT NULL    REFERENCES post.id,
+    tag        VARCHAR(64)    NOT NULL,
+    PRIMARY KEY (post, tag)
 );
 
 DROP TABLE IF EXISTS post_image;
 CREATE TABLE post_image (
-	id		INT				AUTO_INCREMENT	PRIMARY KEY,
-	post	INT				NOT NULL	REFERENCES post.id,
-	image	VARCHAR(300)	NOT NULL,
-	idx		INT				NOT NULL
+    id        INT                AUTO_INCREMENT    PRIMARY KEY,
+    post    INT                NOT NULL    REFERENCES post.id,
+    image    VARCHAR(300)    NOT NULL,
+    idx        INT                NOT NULL
 );
 
 DROP TABLE IF EXISTS post_comment;
 CREATE TABLE post_comment (
-	id			INT				AUTO_INCREMENT			PRIMARY KEY,
-	post		INT				NOT NULL				REFERENCES post(id),
-	text		VARCHAR(5000)	NOT NULL,
-	dtime		TIMESTAMP		NOT NULL				DEFAULT now(),
-	user		INT				REFERENCES user.id,
-	username	VARCHAR(200),
-	lang		VARCHAR(10),
-	approved	BOOLEAN			NOT NULL				DEFAULT 1,
-	visit		INT				REFERENCES stat_visit.id,
-	app			VARCHAR(24)
+    id            INT                AUTO_INCREMENT            PRIMARY KEY,
+    post        INT                NOT NULL                REFERENCES post(id),
+    text        VARCHAR(5000)    NOT NULL,
+    dtime        TIMESTAMP        NOT NULL                DEFAULT now(),
+    user        INT                REFERENCES user.id,
+    username    VARCHAR(200),
+    lang        VARCHAR(10),
+    approved    BOOLEAN            NOT NULL                DEFAULT 1,
+    visit        INT                REFERENCES stat_visit.id,
+    app            VARCHAR(24)
 );
 
 DROP TABLE IF EXISTS place;
 CREATE TABLE place (
-	id			INT				AUTO_INCREMENT  PRIMARY KEY,
-	name_es		VARCHAR(100)	NOT NULL,
-	name_en		VARCHAR(100),
-	name_eu		VARCHAR(100),
-	address_es	VARCHAR(200)	NOT NULL,
-	address_en	VARCHAR(200),
-	address_eu	VARCHAR(200),
-	cp			VARCHAR(10),
-	lat			DOUBLE,
-	lon			DOUBLE
+    id            INT                AUTO_INCREMENT  PRIMARY KEY,
+    name_es        VARCHAR(100)    NOT NULL,
+    name_en        VARCHAR(100),
+    name_eu        VARCHAR(100),
+    address_es    VARCHAR(200)    NOT NULL,
+    address_en    VARCHAR(200),
+    address_eu    VARCHAR(200),
+    cp            VARCHAR(10),
+    lat            DOUBLE,
+    lon            DOUBLE
 );
 
 DROP TABLE IF EXISTS sponsor;
 CREATE TABLE sponsor (
-	id				INT				NOT NULL	AUTO_INCREMENT  PRIMARY KEY,
-	name_es			VARCHAR(100)    NOT NULL,
-	name_en			VARCHAR(100),
-	name_eu			VARCHAR(100),
-	text_es			VARCHAR(1000),
-	text_en			VARCHAR(1000),
-	text_eu			VARCHAR(1000),
-	image			VARCHAR(100),
-	address_es		VARCHAR(200),
-	address_en		VARCHAR(200),
-	address_eu		VARCHAR(200),
-	link			VARCHAR(300),
-	lat				DOUBLE,
-	lon				DOUBLE,
-	ammount			INT,
-	print 			INT				DEFAULT 0,
-	print_static	INT				DEFAULT 0,
-	click			INT				DEFAULT 0
+    id                INT                NOT NULL    AUTO_INCREMENT  PRIMARY KEY,
+    name_es            VARCHAR(100)    NOT NULL,
+    name_en            VARCHAR(100),
+    name_eu            VARCHAR(100),
+    text_es            VARCHAR(1000),
+    text_en            VARCHAR(1000),
+    text_eu            VARCHAR(1000),
+    image            VARCHAR(100),
+    address_es        VARCHAR(200),
+    address_en        VARCHAR(200),
+    address_eu        VARCHAR(200),
+    link            VARCHAR(300),
+    lat                DOUBLE,
+    lon                DOUBLE,
+    ammount            INT,
+    print             INT                DEFAULT 0,
+    print_static    INT                DEFAULT 0,
+    click            INT                DEFAULT 0
 );
 
 DROP TABLE IF EXISTS stat_visit;
 CREATE TABLE stat_visit (
-	id		INT				NOT NULL	AUTO_INCREMENT	PRIMARY KEY,
-	ip		VARCHAR(50),
-	uagent	VARCHAR(400),
-	os		VARCHAR(150),
-	browser	VARCHAR(150)
+    id        INT                NOT NULL    AUTO_INCREMENT    PRIMARY KEY,
+    ip        VARCHAR(50),
+    uagent    VARCHAR(400),
+    os        VARCHAR(150),
+    browser    VARCHAR(150)
 );
 
 DROP TABLE IF EXISTS stat_view;
 CREATE TABLE stat_view (
-	id		INT				NOT NULL	AUTO_INCREMENT	PRIMARY KEY,
-	visit	INT				NOT NULL	REFERENCES stat_visit.id,
-	section	VARCHAR(80)		NOT NULL,
-	entry	VARCHAR(100)	NOT NULL,
-	dtime	TIMESTAMP		NOT NULL	DEFAULT now()
+    id        INT                NOT NULL    AUTO_INCREMENT    PRIMARY KEY,
+    visit    INT                NOT NULL    REFERENCES stat_visit.id,
+    section    VARCHAR(80)        NOT NULL,
+    entry    VARCHAR(100)    NOT NULL,
+    dtime    TIMESTAMP        NOT NULL    DEFAULT now()
 );
+CREATE INDEX visit_dtime ON stat_view(visit, dtime);
 
 DROP TABLE IF EXISTS sync;
 CREATE TABLE sync (
-	id				INT			NOT NULL	AUTO_INCREMENT	PRIMARY KEY,
-	dtime			TIMESTAMP	NOT NULL	DEFAULT now(),
-	client			VARCHAR(64),
-	user			VARCHAR(64),
-	action			VARCHAR(12),
-	section			VARCHAR(32),
-	version_from	INT			NOT NULL	DEFAULT 0,
-	version_to		INT			NOT NULL	DEFAULT -1,
-	fg				INT			NOT NULL	DEFAULT 1,
-	format			VARCHAR(24),
-	error			VARCHAR(256),
-	ip				VARCHAR(128),
-	os				VARCHAR(128),
-	uagent			VARCHAR(256)
+    id                INT            NOT NULL    AUTO_INCREMENT    PRIMARY KEY,
+    dtime            TIMESTAMP    NOT NULL    DEFAULT now(),
+    client            VARCHAR(64),
+    user            VARCHAR(64),
+    action            VARCHAR(12),
+    section            VARCHAR(32),
+    version_from    INT            NOT NULL    DEFAULT 0,
+    version_to        INT            NOT NULL    DEFAULT -1,
+    fg                INT            NOT NULL    DEFAULT 1,
+    format            VARCHAR(24),
+    error            VARCHAR(256),
+    ip                VARCHAR(128),
+    os                VARCHAR(128),
+    uagent            VARCHAR(256)
 );
 
 DROP TABLE IF EXISTS stat_sync;
 CREATE TABLE stat_sync (
-	id		INT			NOT NULL	AUTO_INCREMENT	PRIMARY KEY,
-	dtime	TIMESTAMP	NOT NULL	DEFAULT now(),
-	user	VARCHAR(64)	NOT NULL,
-	fg		INT			NOT NULL	DEFAULT 1,
-	os		VARCHAR(64)	NOT NULL,
-	ip		VARCHAR(50)	NOT NULL,
-	synced	INT			NOT NULL	DEFAULT 0
+    id        INT            NOT NULL    AUTO_INCREMENT    PRIMARY KEY,
+    dtime    TIMESTAMP    NOT NULL    DEFAULT now(),
+    user    VARCHAR(64)    NOT NULL,
+    fg        INT            NOT NULL    DEFAULT 1,
+    os        VARCHAR(64)    NOT NULL,
+    ip        VARCHAR(50)    NOT NULL,
+    synced    INT            NOT NULL    DEFAULT 0
 );
 
 DROP TABLE IF EXISTS photo;
 CREATE TABLE photo (
-	id				INT				NOT NULL	AUTO_INCREMENT	PRIMARY KEY,
-	file			VARCHAR(100)	NOT NULL	UNIQUE,
-	permalink		VARCHAR(100)	NOT NULL	UNIQUE,
-	title_es		VARCHAR(100),
-	title_en		VARCHAR(100),
-	title_eu		VARCHAR(100),
-	description_es	VARCHAR(1000),
-	description_en	VARCHAR(1000),
-	description_eu	VARCHAR(1000),
-	dtime			DATETIME,
-	uploaded		TIMESTAMP		NOT NULL	DEFAULT now(),
-	place			INT				REFERENCES place.id,
-	width			INT,
-	height			INT,
-	size			BIGINT,
-	approved		BOOLEAN			NOT NULL	DEFAULT 1,
-	user			INT				NOT NULL	DEFAULT 1	REFERENCES user.id,
-	username		VARCHAR(64)
+    id                INT                NOT NULL    AUTO_INCREMENT    PRIMARY KEY,
+    file            VARCHAR(100)    NOT NULL    UNIQUE,
+    permalink        VARCHAR(100)    NOT NULL    UNIQUE,
+    title_es        VARCHAR(100),
+    title_en        VARCHAR(100),
+    title_eu        VARCHAR(100),
+    description_es    VARCHAR(1000),
+    description_en    VARCHAR(1000),
+    description_eu    VARCHAR(1000),
+    dtime            DATETIME,
+    uploaded        TIMESTAMP        NOT NULL    DEFAULT now(),
+    place            INT                REFERENCES place.id,
+    width            INT,
+    height            INT,
+    size            BIGINT,
+    approved        BOOLEAN            NOT NULL    DEFAULT 1,
+    user            INT                NOT NULL    DEFAULT 1    REFERENCES user.id,
+    username        VARCHAR(64)
 );
 
 DROP TABLE IF EXISTS album;
 CREATE TABLE album (
-	id				INT				NOT NULL	AUTO_INCREMENT	PRIMARY KEY,
-	permalink		VARCHAR(100)	NOT NULL,
-	title_es		VARCHAR(100)	NOT NULL,
-	title_en		VARCHAR(100),
-	title_eu		VARCHAR(100),
-	description_es	VARCHAR(1000),
-	description_en	VARCHAR(1000),
-	description_eu	VARCHAR(1000),
-	user			INT				NOT NULL	DEFAULT 1	REFERENCES user.id,
-	open			BOOLEAN			NOT NULL	DEFAULT 1,
-	dtime			TIMESTAMP		NOT NULL	DEFAULT now()
+    id                INT                NOT NULL    AUTO_INCREMENT    PRIMARY KEY,
+    permalink        VARCHAR(100)    NOT NULL,
+    title_es        VARCHAR(100)    NOT NULL,
+    title_en        VARCHAR(100),
+    title_eu        VARCHAR(100),
+    description_es    VARCHAR(1000),
+    description_en    VARCHAR(1000),
+    description_eu    VARCHAR(1000),
+    user            INT                NOT NULL    DEFAULT 1    REFERENCES user.id,
+    open            BOOLEAN            NOT NULL    DEFAULT 1,
+    dtime            TIMESTAMP        NOT NULL    DEFAULT now()
 );
 
 DROP TABLE IF EXISTS photo_album;
 CREATE TABLE photo_album (
-	photo	INT	NOT NULL	REFERENCES photo.id,
-	album	INT	NOT NULL	REFERENCES album.id,
-	PRIMARY KEY (photo, album)
+    photo    INT    NOT NULL    REFERENCES photo.id,
+    album    INT    NOT NULL    REFERENCES album.id,
+    PRIMARY KEY (photo, album)
 );
 
 DROP TABLE IF EXISTS photo_comment;
 CREATE TABLE photo_comment (
-	id			INT				AUTO_INCREMENT			PRIMARY KEY,
-	photo		INT				NOT NULL				REFERENCES photo(id),
-	text		VARCHAR(3000)	NOT NULL,
-	dtime		TIMESTAMP		NOT NULL				DEFAULT now(),
-	user		INT				REFERENCES user.id,
-	username	VARCHAR(200),
-	lang		VARCHAR(10),
-	approved	BOOLEAN			NOT NULL				DEFAULT 1,
-	visit		INT				REFERENCES stat_visit.id,
-	app			VARCHAR(24)
+    id            INT                AUTO_INCREMENT            PRIMARY KEY,
+    photo        INT                NOT NULL                REFERENCES photo(id),
+    text        VARCHAR(3000)    NOT NULL,
+    dtime        TIMESTAMP        NOT NULL                DEFAULT now(),
+    user        INT                REFERENCES user.id,
+    username    VARCHAR(200),
+    lang        VARCHAR(10),
+    approved    BOOLEAN            NOT NULL                DEFAULT 1,
+    visit        INT                REFERENCES stat_visit.id,
+    app            VARCHAR(24)
 );
 
 DROP TABLE IF EXISTS activity;
 CREATE TABLE activity (
-	id			INT				AUTO_INCREMENT	PRIMARY KEY,
-	permalink	VARCHAR(100)	NOT NULL,
-	date		DATE			NOT NULL,
-	city		VARCHAR(100)	NOT NULL	DEFAULT "Vitoria-Gasteiz",
-	title_es	VARCHAR(300)	NOT NULL,
-	title_en	VARCHAR(300),
-	title_eu	VARCHAR(300),
-	text_es		TEXT			NOT NULL,
-	text_en		TEXT,
-	text_eu		TEXT,
-	after_es	VARCHAR(2000),
-	after_en	VARCHAR(2000),
-	after_eu	VARCHAR(2000),
-	price		FLOAT			NOT NULL,
-	inscription	BOOLEAN			NOT NULL		DEFAULT 1,
-	people		INT				DEFAULT 0,
-	max_people	INT,
-	album		INT				REFERENCES album.id,
-	user		INT				NOT NULL		DEFAULT 1	REFERENCES user.id,
-	dtime		TIMESTAMP		NOT NULL		DEFAULT now(),
-	visible		BOOLEAN			NOT NULL		DEFAULT	1,
-	comments	BOOLEAN			NOT NULL		DEFAULT 1
+    id            INT                AUTO_INCREMENT    PRIMARY KEY,
+    permalink    VARCHAR(100)    NOT NULL,
+    date        DATE            NOT NULL,
+    city        VARCHAR(100)    NOT NULL    DEFAULT "Vitoria-Gasteiz",
+    title_es    VARCHAR(300)    NOT NULL,
+    title_en    VARCHAR(300),
+    title_eu    VARCHAR(300),
+    text_es        TEXT            NOT NULL,
+    text_en        TEXT,
+    text_eu        TEXT,
+    after_es    VARCHAR(2000),
+    after_en    VARCHAR(2000),
+    after_eu    VARCHAR(2000),
+    price        FLOAT            NOT NULL,
+    inscription    BOOLEAN            NOT NULL        DEFAULT 1,
+    people        INT                DEFAULT 0,
+    max_people    INT,
+    album        INT                REFERENCES album.id,
+    user        INT                NOT NULL        DEFAULT 1    REFERENCES user.id,
+    dtime        TIMESTAMP        NOT NULL        DEFAULT now(),
+    visible        BOOLEAN            NOT NULL        DEFAULT    1,
+    comments    BOOLEAN            NOT NULL        DEFAULT 1
 );
 
 DROP TABLE IF EXISTS activity_tag;
 CREATE TABLE activity_tag (
-	activity	INT			NOT NULL	REFERENCES activity.id,
-	tag			VARCHAR(64)	NOT NULL,
-	PRIMARY KEY (activity, tag)
+    activity    INT            NOT NULL    REFERENCES activity.id,
+    tag            VARCHAR(64)    NOT NULL,
+    PRIMARY KEY (activity, tag)
 );
 
 DROP TABLE IF EXISTS activity_image;
 CREATE TABLE activity_image (
-	id			INT			AUTO_INCREMENT	PRIMARY KEY,
-	activity	INT			NOT NULL	REFERENCES activity.id,
-	image		VARCHAR(64)	NOT NULL,
-	idx			INT			NOT NULL
+    id            INT            AUTO_INCREMENT    PRIMARY KEY,
+    activity    INT            NOT NULL    REFERENCES activity.id,
+    image        VARCHAR(64)    NOT NULL,
+    idx            INT            NOT NULL
 );
 
 DROP TABLE IF EXISTS activity_itinerary;
 CREATE TABLE activity_itinerary (
-	id				INT				AUTO_INCREMENT	PRIMARY KEY,
-	activity		INT				NOT NULL	REFERENCES activity.id,
-	name_es			VARCHAR(64)		NOT NULL,
-	name_en			VARCHAR(64),
-	name_eu			VARCHAR(64),
-	description_es	VARCHAR(1000),
-	description_en	VARCHAR(1000),
-	description_eu	VARCHAR(1000),
-	start			DATETIME		NOT NULL,
-	end				DATETIME,
-	place			INT				NOT NULL	REFERENCES place.id
+    id                INT                AUTO_INCREMENT    PRIMARY KEY,
+    activity        INT                NOT NULL    REFERENCES activity.id,
+    name_es            VARCHAR(64)        NOT NULL,
+    name_en            VARCHAR(64),
+    name_eu            VARCHAR(64),
+    description_es    VARCHAR(1000),
+    description_en    VARCHAR(1000),
+    description_eu    VARCHAR(1000),
+    start            DATETIME        NOT NULL,
+    end                DATETIME,
+    place            INT                NOT NULL    REFERENCES place.id
 );
 
 DROP TABLE IF EXISTS activity_comment;
 CREATE TABLE activity_comment (
-	id			INT				AUTO_INCREMENT			PRIMARY KEY,
-	activity	INT				NOT NULL				REFERENCES post(id),
-	text		VARCHAR(5000)	NOT NULL,
-	dtime		TIMESTAMP		NOT NULL				DEFAULT now(),
-	user		INT				REFERENCES user.id,
-	username	VARCHAR(200),
-	lang		VARCHAR(10),
-	approved	BOOLEAN			NOT NULL				DEFAULT 1,
-	visit		INT				REFERENCES stat_visit.id,
-	app			VARCHAR(24)
+    id            INT                AUTO_INCREMENT            PRIMARY KEY,
+    activity    INT                NOT NULL                REFERENCES post(id),
+    text        VARCHAR(5000)    NOT NULL,
+    dtime        TIMESTAMP        NOT NULL                DEFAULT now(),
+    user        INT                REFERENCES user.id,
+    username    VARCHAR(200),
+    lang        VARCHAR(10),
+    approved    BOOLEAN            NOT NULL                DEFAULT 1,
+    visit        INT                REFERENCES stat_visit.id,
+    app            VARCHAR(24)
 );
 
 DROP TABLE IF EXISTS festival;
 CREATE TABLE festival (
-	id			INT				AUTO_INCREMENT	PRIMARY KEY,
-	year		INT				UNIQUE,
-	text_es		VARCHAR(3000)	NOT NULL,
-	text_en		VARCHAR(3000),
-	text_eu		VARCHAR(3000),
-	summary_es	VARCHAR(3000),
-	summary_en	VARCHAR(3000),
-	summary_eu	VARCHAR(3000),
-	img			VARCHAR(2000)
+    id            INT                AUTO_INCREMENT    PRIMARY KEY,
+    year        INT                UNIQUE,
+    text_es        VARCHAR(3000)    NOT NULL,
+    text_en        VARCHAR(3000),
+    text_eu        VARCHAR(3000),
+    summary_es    VARCHAR(3000),
+    summary_en    VARCHAR(3000),
+    summary_eu    VARCHAR(3000),
+    img            VARCHAR(2000)
 );
 
 DROP TABLE IF EXISTS festival_day;
 CREATE TABLE festival_day (
-	id		INT			AUTO_INCREMENT	PRIMARY KEY,
-	date	DATE		NOT NULL,
-	name_es	VARCHAR(60)	NOT NULL,
-	name_en	VARCHAR(60),
-	name_eu	VARCHAR(60),
-	price	INT			NOT NULL
+    id        INT            AUTO_INCREMENT    PRIMARY KEY,
+    date    DATE        NOT NULL,
+    name_es    VARCHAR(60)    NOT NULL,
+    name_en    VARCHAR(60),
+    name_eu    VARCHAR(60),
+    price    INT            NOT NULL
 );
 
 DROP TABLE IF EXISTS festival_offer;
 CREATE TABLE festival_offer (
-	id				INT			AUTO_INCREMENT	PRIMARY KEY,
-	year			INT,
-	name_es			VARCHAR(60)	NOT NULL,
-	name_en			VARCHAR(60),
-	name_eu			VARCHAR(60),
-	description_es	VARCHAR(500),
-	description_en	VARCHAR(500),
-	description_eu	VARCHAR(500),
-	days			INT			NOT NULL,
-	price			INT			NOT NULL
+    id                INT            AUTO_INCREMENT    PRIMARY KEY,
+    year            INT,
+    name_es            VARCHAR(60)    NOT NULL,
+    name_en            VARCHAR(60),
+    name_eu            VARCHAR(60),
+    description_es    VARCHAR(500),
+    description_en    VARCHAR(500),
+    description_eu    VARCHAR(500),
+    days            INT            NOT NULL,
+    price            INT            NOT NULL
 );
 
 DROP TABLE IF EXISTS location;
 CREATE TABLE location (
-	id		INT			AUTO_INCREMENT 	PRIMARY KEY,
-	action	VARCHAR(40)	NOT NULL,
-	dtime	TIMESTAMP	NOT NULL		DEFAULT now(),
-	lat		DOUBLE		NOT NULL,
-	lon		DOUBLE		NOT NULL,
-	manual	BOOLEAN		NOT NULL		DEFAULT 0,
-	user	INT			NOT NULL		REFERENCES user.id
+    id        INT            AUTO_INCREMENT     PRIMARY KEY,
+    action    VARCHAR(1)    NOT NULL,
+    dtime    TIMESTAMP    NOT NULL        DEFAULT now(),
+    lat        DOUBLE,
+    lon        DOUBLE,
+    start    INT,
+    user    INT            NOT NULL        REFERENCES user.id
 );
 
 DROP TABLE IF EXISTS notification;
 CREATE TABLE notification (
-	id			INT				AUTO_INCREMENT 	PRIMARY KEY,
-	user		INT				NOT NULL		REFERENCES user.id,
-	dtime		TIMESTAMP		NOT NULL		DEFAULT now(),
-	duration	INT				NOT NULL		DEFAULT 60,
-	action		VARCHAR(20)		NOT NULL		DEFAULT 'message',
-	title_es	VARCHAR(100)	NOT NULL,
-	title_en	VARCHAR(100),
-	title_eu	VARCHAR(100),
-	text_es		VARCHAR(1000),
-	text_en		VARCHAR(1000),
-	text_eu		VARCHAR(1000),
-	internal	BOOLEAN			NOT NULL		DEFAULT 0
+    id            INT                AUTO_INCREMENT     PRIMARY KEY,
+    user        INT                NOT NULL        REFERENCES user.id,
+    dtime        TIMESTAMP        NOT NULL        DEFAULT now(),
+    duration    INT                NOT NULL        DEFAULT 60,
+    action        VARCHAR(20)        NOT NULL        DEFAULT 'message',
+    title_es    VARCHAR(100)    NOT NULL,
+    title_en    VARCHAR(100),
+    title_eu    VARCHAR(100),
+    text_es        VARCHAR(1000),
+    text_en        VARCHAR(1000),
+    text_eu        VARCHAR(1000),
+    internal    BOOLEAN            NOT NULL        DEFAULT 0
 );
 
 DROP TABLE IF EXISTS people;
 CREATE TABLE people (
-	id		INT				AUTO_INCREMENT	PRIMARY KEY,
-	name_es	VARCHAR(100)	NOT NULL,
-	name_en	VARCHAR(100),
-	name_eu	VARCHAR(100),
-	link	VARCHAR(300)
+    id        INT                AUTO_INCREMENT    PRIMARY KEY,
+    name_es    VARCHAR(100)    NOT NULL,
+    name_en    VARCHAR(100),
+    name_eu    VARCHAR(100),
+    link    VARCHAR(300)
 );
 
 DROP TABLE IF EXISTS festival_event;
 CREATE TABLE festival_event (
-	id				INT				AUTO_INCREMENT	PRIMARY KEY,
-	gm				BOOLEAN			DEFAULT 0,
-	title_es		VARCHAR(200)	NOT NULL,
-	title_en		VARCHAR(200),
-	title_eu		VARCHAR(200),
-	description_es	VARCHAR(5000),
-	description_en	VARCHAR(5000),
-	description_eu	VARCHAR(5000),
-	host			INT				REFERENCES people.id,
-	place			INT				REFERENCES place.id,
-	start			DATETIME,
-	end				DATETIME
+    id                INT                AUTO_INCREMENT    PRIMARY KEY,
+    gm                BOOLEAN            DEFAULT 0,
+    title_es        VARCHAR(200)    NOT NULL,
+    title_en        VARCHAR(200),
+    title_eu        VARCHAR(200),
+    description_es    VARCHAR(5000),
+    description_en    VARCHAR(5000),
+    description_eu    VARCHAR(5000),
+    host            INT                REFERENCES people.id,
+    place            INT                REFERENCES place.id,
+    start            DATETIME,
+    end                DATETIME
 );
 
 DROP TABLE IF EXISTS festival_event_image;
 CREATE TABLE festival_event_image (
-	id			INT			AUTO_INCREMENT	PRIMARY KEY,
-	event		INT			NOT NULL	REFERENCES activity.id,
-	image		VARCHAR(64)	NOT NULL,
-	idx			INT			NOT NULL
+    id            INT            AUTO_INCREMENT    PRIMARY KEY,
+    event        INT            NOT NULL    REFERENCES activity.id,
+    image        VARCHAR(64)    NOT NULL,
+    idx            INT            NOT NULL
 );
 
 DROP TABLE IF EXISTS settings;
 CREATE TABLE settings (
-	name		VARCHAR(64)	PRIMARY KEY,
-	value		VARCHAR(64)	NOT NULL,
-	user		INT			REFERENCES user.id,
-	changed		TIMESTAMP	NOT NULL		DEFAULT now()
+    name        VARCHAR(64)    PRIMARY KEY,
+    value        VARCHAR(64)    NOT NULL,
+    user        INT            REFERENCES user.id,
+    changed        TIMESTAMP    NOT NULL        DEFAULT now()
 );
 
 DROP TABLE IF EXISTS version;
 CREATE TABLE version (
-	section		VARCHAR(12)	PRIMARY KEY,
-	version		INT			DEFAULT 1
+    section        VARCHAR(12)    PRIMARY KEY,
+    version        INT            DEFAULT 1
 );
 
 DROP TABLE IF EXISTS member;
 CREATE TABLE member (
-	id			INT				AUTO_INCREMENT	PRIMARY KEY,
-	name		VARCHAR(64)		NOT NULL,
-	lname		VARCHAR(128)	NOT NULL,
-	lname2		VARCHAR(128),
-	alias		VARCHAR(32),
-	dni			VARCHAR(16),
-	bdate		DATE,
-	phone		VARCHAR(32),
-	mail		VARCHAR(128),
-	address		VARCHAR(512),
-	jdate		DATE,
-	joined		VARCHAR(16),
-	board		BOOLEAN			NOT NULL	DEFAULT 0,
-	facebook	VARCHAR(1024),
-	twitter		VARCHAR(1024),
-	googleplus	VARCHAR(1024)
+    id            INT                AUTO_INCREMENT    PRIMARY KEY,
+    name        VARCHAR(64)        NOT NULL,
+    lname        VARCHAR(128)    NOT NULL,
+    lname2        VARCHAR(128),
+    alias        VARCHAR(32),
+    dni            VARCHAR(16),
+    bdate        DATE,
+    phone        VARCHAR(32),
+    mail        VARCHAR(128),
+    address        VARCHAR(512),
+    jdate        DATE,
+    joined        VARCHAR(16),
+    board        BOOLEAN            NOT NULL    DEFAULT 0,
+    facebook    VARCHAR(1024),
+    twitter        VARCHAR(1024),
+    googleplus    VARCHAR(1024)
 );
 
 DROP TABLE IF EXISTS member_activity;
 CREATE TABLE member_activity(
-	member		INT		REFERENCES member.id,
-	activity	INT		REFERENCES activity.id,
-	paid		BOOLEAN	NOT NULL	DEFAULT 1,
-	PRIMARY KEY(member, activity)
+    member        INT        REFERENCES member.id,
+    activity    INT        REFERENCES activity.id,
+    paid        BOOLEAN    NOT NULL    DEFAULT 1,
+    PRIMARY KEY(member, activity)
 );
 
 DROP TABLE IF EXISTS intolerance;
 CREATE TABLE intolerance(
-	member	INT				REFERENCES member.id,
-	element	VARCHAR(128),
-	PRIMARY KEY(member, element)
+    member    INT                REFERENCES member.id,
+    element    VARCHAR(128),
+    PRIMARY KEY(member, element)
 );
 
 DROP TABLE IF EXISTS member_day;
 CREATE TABLE member_day(
-	member	INT		REFERENCES member.id,
-	day		INT		REFERENCES festival_day.id,
-	paid	BOOLEAN	NOT NULL	DEFAULT 1,
-	PRIMARY KEY (member, day)
+    member    INT        REFERENCES member.id,
+    day        INT        REFERENCES festival_day.id,
+    paid    BOOLEAN    NOT NULL    DEFAULT 1,
+    PRIMARY KEY (member, day)
 );
 
 DROP TABLE IF EXISTS transac_category;
 CREATE TABLE transac_category(
-	id						INT				AUTO_INCREMENT PRIMARY KEY,
-	title_internal			VARCHAR(510)	NOT NULL,
-	title_es				VARCHAR(510)	NOT NULL,
-	title_en				VARCHAR(510),
-	title_eu				VARCHAR(510),
-	description_internal	VARCHAR(510)	NOT NULL,
-	description_es			VARCHAR(510)	NOT NULL,
-	description_en			VARCHAR(510),
-	description_eu			VARCHAR(510)
+    id                        INT                AUTO_INCREMENT PRIMARY KEY,
+    title_internal            VARCHAR(510)    NOT NULL,
+    title_es                VARCHAR(510)    NOT NULL,
+    title_en                VARCHAR(510),
+    title_eu                VARCHAR(510),
+    description_internal    VARCHAR(510)    NOT NULL,
+    description_es            VARCHAR(510)    NOT NULL,
+    description_en            VARCHAR(510),
+    description_eu            VARCHAR(510)
 );
 
 DROP TABLE IF EXISTS transact;
 CREATE TABLE transact(
-	id				INT				AUTO_INCREMENT PRIMARY KEY,
-	dtime			TIMESTAMP		NOT NULL	DEFAULT now(),
-	ammount			FLOAT			NOT NULL,
-	user			INT				NOT NULL	REFERENCES user.id,
-	concept			VARCHAR(1024),
-	category		INT				NOT NULL	REFERENCES transac_category.id
+    id                INT                AUTO_INCREMENT PRIMARY KEY,
+    dtime            TIMESTAMP        NOT NULL    DEFAULT now(),
+    ammount            FLOAT            NOT NULL,
+    user            INT                NOT NULL    REFERENCES user.id,
+    concept            VARCHAR(1024),
+    category        INT                NOT NULL    REFERENCES transac_category.id
+);
+
+DROP TABLE IF EXISTS translation;
+CREATE TABLE translation(
+    id                INT                AUTO_INCREMENT PRIMARY KEY,
+    dtime            TIMESTAMP        NOT NULL    DEFAULT now(),
+    username        VARCHAR(255)    NOT NULL    DEFAULT 'unknown',
+    tab                VARCHAR(255)    NOT NULL,
+    field            VARCHAR(255)    NOT NULL,
+    eid                INT                NOT NULL,
+    lang            VARCHAR(2)        NOT NULL,
+    text            VARCHAR(9000)    NOT NULL,
+    applied            DATETIME
 );
 
 #Set up two users for database. File dbusers.sql contains:

+ 567 - 0
utils/GMSchedule.php

@@ -0,0 +1,567 @@
+ <?php
+        
+    function startdb(){
+        //Include the db configuration file. It's somehow like this
+        /*
+        <?php
+            $host = 'XXXX';
+            $db_name = 'XXXX';
+            $username_ro = 'XXXX';
+            $username_rw = 'XXXX';
+            $pass_ro = 'XXXX';
+            $pass_rw = 'XXXX';
+        ?>
+        */
+        include('.htpasswd');
+        
+        //Connect to to database
+        $con = mysqli_connect($host, $username_rw, $pass_rw, $db_name);
+        
+        //Set encoding options
+        mysqli_set_charset($con, 'utf-8');
+        header('Content-Type: text/html; charset=utf8');
+        mysqli_query($con, 'SET NAMES utf8;');
+        
+        //Return the db connection
+        return $con;
+    }    
+    
+?>
+
+<html>
+    <head>
+        <style>
+            @media print {
+                div#header, div.day, div.meetings{
+                    page-break-after: always;
+                }
+                body{
+                    background: #ffffff;
+                    filter: initial;
+                    font-size: 80%;
+                    color: #ff0000;
+                }
+            }
+            @font-face{
+                font-family: font;
+                src: url('/font/FreeSans.ttf')
+            }
+            body{
+                font-family:        font;
+                margin:                2em;
+                /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#b5d3e5+0,e5f4ff+10,e5f4ff+90,b5d3e5+100 */
+                /*background: #b5d3e5; */
+                /*background: -moz-linear-gradient(left, #b5d3e5 0%, #e5f4ff 10%, #e5f4ff 90%, #b5d3e5 100%);*/ /* FF3.6-15 */
+                /*background: -webkit-linear-gradient(left, #b5d3e5 0%,#e5f4ff 10%,#e5f4ff 90%,#b5d3e5 100%);*/ /* Chrome10-25,Safari5.1-6 */
+                /*background: linear-gradient(to right, #b5d3e5 0%,#e5f4ff 10%,#e5f4ff 90%,#b5d3e5 100%);*/ /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
+                /*filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b5d3e5', endColorstr='#b5d3e5',GradientType=1 );(/ /* IE6-9 */
+            }
+            div#header{
+                width: 100%;
+                text-align:    center;
+                margin-top: 18em;
+            }
+            div#header div#title{
+                display: inline;
+                vertical-align: middle;
+                width: 90%;
+                margin-top: 2em;
+                background-color: #0078ff;
+                color: #ffffff;
+                border-top-right-radius: 0.5em;
+                border-bottom-right-radius: 0.5em;
+                border: 0.3em solid #0045cc;
+                padding: 4em 4em 4em 0em;
+            }
+            div#header div#title img{
+                display: inline-block;
+                /*width: 6em;*/
+                /*height: 6em;*/
+                vertical-align: middle;
+                margin: -1em 1em -1em -2em;
+                -webkit-filter: drop-shadow(0 0 0.4em #dde);
+                filter: drop-shadow(0 0 0.4em #dde);
+                border: 0.1em solid #000011;
+                border-radius: 100%;
+                -ms-filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=0, Color='#dde')";
+                filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=0, Color='#dde')";
+            }
+            div#header div#title h2{
+                display: inline-block;
+                font-size: 5em;
+                margin: 0.5em;
+                vertical-align: middle;
+            }
+            div#header h4{
+                display: inline-block;
+                margin: 1em auto 2em auto;
+                padding: 4em 2em 7em 2em;
+                color: #ffffff;
+                font-weight: bold;
+                font-size: 4em;
+                text-shadow: -0.02em 0 black, 0 0.02em black, 0.02em 0 black, 0 -0.02em #0045cc;
+                background: -moz-radial-gradient(center, ellipse cover, rgba(0,120,255,1) 10%, rgba(255,255,255,0) 67%, rgba(255,255,255,0) 100%); /* ff3.6+ */
+                background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(10%, rgba(0,120,255,1)), color-stop(67%, rgba(255,255,255,0)), color-stop(100%, rgba(255,255,255,0))); /* safari4+,chrome */
+                background:-webkit-radial-gradient(center, ellipse cover, rgba(0,120,255,1) 10%, rgba(255,255,255,0) 67%, rgba(255,255,255,0) 100%); /* safari5.1+,chrome10+ */
+                background: -o-radial-gradient(center, ellipse cover, rgba(0,120,255,1) 10%, rgba(255,255,255,0) 67%, rgba(255,255,255,0) 100%); /* opera 11.10+ */
+                background: -ms-radial-gradient(center, ellipse cover, rgba(0,120,255,1) 10%, rgba(255,255,255,0) 67%, rgba(255,255,255,0) 100%); /* ie10+ */
+                background:radial-gradient(ellipse at center, rgba(0,120,255,1) 10%, rgba(255,255,255,0) 67%, rgba(255,255,255,0) 100%); /* w3c */
+                filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0078ff', endColorstr='#ffffff',GradientType=1 ); /* ie6-9 */ 
+            }
+            div#header h3{
+                color: #ffffff;
+                font-weight: bold;
+                font-size: 5em;
+                text-shadow: -0.04em 0 #000033, 0 0.04em #000033, 0.04em 0 #000033, 0 -0.04em #000033;
+                display: inline-block;
+                margin: -8em auto 2em auto;
+            }
+            div#header span#warning{
+                color: #ff0000;
+                font-weight: bold;
+                font-size: 1.5em;
+                text-shadow: -0.04em 0 #000033, 0 0.04em #000033, 0.04em 0 #000033, 0 -0.04em #000033;
+                display: inline-block;
+                margin: -12em -7em 2em 7em;
+                -ms-transform: rotate(-30deg); /* IE 9 */
+                -webkit-transform: rotate(-30deg); /* Chrome, Safari, Opera */
+                transform: rotate(-30deg);
+            }
+            div#header table#contact{
+                color: #0056cc;
+                font-weight: bold;
+                margin: auto 0 auto auto;
+                /*text-shadow: -0.02em 0 #000000, 0 0.02em #000000, 0.02em 0 #000000, 0 -0.02em #000000;*/
+                /*text-shadow: -0.08em 0.3em black, 0.3em 0.08em black, 0.08em 0.3em black, 0.3em -0.08em #black;*/
+            }
+            div#header table#contact img{
+                height: 2em;
+                width: 2em;
+            }
+
+            div.tarifas table td{
+                vertical_align: middle;
+                border-top: 0.07em solid #999999;
+                padding: 1em;
+            }
+
+            div.tarifas table td.price{
+                text-align: right;
+                width: 4em;
+            }
+            div.tarifas table td.info{
+                padding-left: 4em;
+                color:initial;
+                text-align: center;
+            }
+            div.tarifas table td.warning{
+                padding-left: 4em;
+                color: red;
+                font-weight: bold;
+                text-align: center;
+            }
+
+            div.meetings td{
+                color: initial;
+                padding: 1em;
+            }
+
+
+            div.meetings table.location td.pinpoint{
+                width: 2em;
+            }
+
+            div.meetings table.location img{
+                margin-left: 1em;
+                margin-right: 0.5em;
+            }
+            div.meetings table.location span.place{
+                color: #444444;
+                font-size: 0.9em;
+            }
+            div.meetings span.address{
+                color: #666666;
+                margin-left: 0.5em;
+                font-style: italic;
+                font-size: 0.8em;
+            }
+
+            div.day,div.tarifas, div.meetings{
+                border-left: 0.1em solid #000011;
+                border-right: 0.1em solid #000011;
+                border-bottom: 0.1em solid #000011;
+                border-top-right-radius: 1em;
+                border-top-left-radius: 1em;
+                max-width:    80em;
+                margin: 2em auto 2em auto;
+                padding: 0 0 0.4em 0;
+                background-color: #0078ff;
+                -webkit-filter: drop-shadow(0 0 1em #0078ff);
+                filter: drop-shadow(0 0 1em #0078ff);
+                -ms-filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=0, Color='#000011')";
+                filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=0, Color='#000011')";
+            }
+            div.day h3,div.tarifas h3, div.meetings h3{
+                font-size: 110%;
+                font-style: bold;
+                color: #ffffff;
+                background-color: #0078ff;
+                padding: 0.5em 2em 0.1em 1.5em;
+                border-top-left-radius: 0.7em;
+                border-top-right-radius: 0.7em;
+                border: 0.1em solid #000011;
+                margin: 0;
+            }
+            div.day table.day_content, div.tarifas table, div.meetings table{
+                width:    100%;
+                /*border-spacing: 10px;*/
+                border-collapse: collapse;
+                background-color: #ffffff;
+                margin: 0;
+            }
+            div.day table.day_content td{
+                padding: 0;
+            }
+            div.day table.day_content td.time{
+                width: 3em;
+                text-align: right;
+                color: #275573;
+                font-size: 1.2em;
+                font-weight: bold;
+                padding: 0.3em 0.5em 0.3em 0.3em;
+                vertical-align: top;
+                border-top: 0.07em solid #999999;
+            }
+            div.day table.day_content td.timeline{
+                text-align:center;
+                border-left: 0.2em dotted #999999;
+                border-top: 0.07em solid #999999;
+                vertical-align: top;
+            }
+            div.day table.day_content td.timeline img{
+                width: 1.1em;
+                height: 1.1em;
+                margin: 0.4em -1.4em 0 -1.4em;
+            }
+            div.day table.day_content td.info{
+                border-top: 0.07em solid #999999;
+                vertical-align: top;
+                padding: 0.3em 0.5em 0.3em 0.8em;
+            }
+            div.day table.day_content td.info h4, div.tarifas table td h4, div.meetings table td h4{
+                color: #275573;
+                /*letter-spacing: 0.07em;*/
+                font-size: 1.2em;
+                font-weight: bold;
+                margin:    0 0 0.2em 0em;
+            }
+            div.day table.day_content td.info p, div.tarifas table td span{
+                font-style: italic;
+                /*letter-spacing: 0.07em;*/
+                color: #222222;
+                font-size: 1em;
+                margin: 0 1em 0.5em 0.3em;
+            }
+            div.day table.day_content td.info table.location img{
+                margin-left: 1em;
+                margin-right: 0.5em;
+            }
+            div.day table.day_content td.info table.location span.place{
+                color: #444444;
+                font-size: 0.9em;
+            }
+            div.day table.day_content td.info table.location span.address{
+                color: #666666;
+                margin-left: 0.5em;
+                font-style: italic;
+                font-size: 0.8em;
+            }
+        </style>
+    </head>
+    <body>
+<?php
+        $con = startdb();
+    
+        $lang = strtolower($_GET['l']);
+        if ($lang != 'es' && $lang!= 'en' && $lang != 'eu'){
+            $lang = 'es';
+        }
+        
+        // TODO: Get current year
+        $year = 2017;
+?>
+        <div id='header'>
+            <div id='title'>
+                <img src='https://margolariak.com/img/logo/GasetizkoMargolariak.png' />
+                <h2>Gasteizko Margolariak</h2>
+            </div>
+<?php
+            switch($lang){
+                case 'eu':
+                    $title = "Andre Maria Zuriaren jaiak egunetarako";
+                    $warning = "";//"Behin-behineko !!";
+                    break;
+                case 'en':
+                    $title = "La Blanca Festivals schedule.";
+                    $warning = "";//"Provisional !!";
+                    break;
+                case 'es':
+                    $title = "Programa Margolari<br/>Fiestas de La Blanca";
+                    $warning = "";//"¡¡ Provisional !!";
+                    break;
+            }
+?>
+            <br/>
+            <h4><?=$title?></h4>
+            <br/>
+            <h3><?=$year?></h3>
+            <br/>
+            <span id="warning"><?=$warning?></span>
+            <br/><br/><br/><br/><br/><br/><br/>
+            <table id='contact'>
+                <tr>
+                    <td>
+                        <img src='https://margolariak.com/img/social/whatsapp.png'/>
+                    </td>
+                    <td>
+                        637 14 03 71
+                    </td>
+                </tr>
+                <tr>
+                    <td>
+                        <img src='https://margolariak.com/img/social/mail.png'/>
+                    </td>
+                    <td>
+                        gasteizko@margolariak.com
+                    </td>
+                </tr>
+                <tr>
+                    <td>
+                        <img src='https://margolariak.com/img/social/twitter.png'/>
+                    </td>
+                    <td>
+                        @gmargolariak
+                    </td>
+                </tr>
+            </table>
+        </div>
+        <br/><br/>
+        <div class='tarifas'>
+<?php
+        $title = "";
+            switch($lang){
+                case 'es':
+                    $title = "Tarifas y ofertas";
+                    break;
+                case 'en':
+                    $title = "Prices and offers";
+                    break;
+                case 'eu':
+                    $title = "Prezioak eta eskaintzak";
+            }
+?>
+            <h3><?=$title?></h3>
+                <table>
+<?php
+                    $q_day = mysqli_query($con, "SELECT id, name_$lang AS name, DATE_FORMAT(date, '%e') AS day, DATE_FORMAT(date, '%c') AS month, price FROM festival_day WHERE date >= str_to_date('$year-00-00', '%Y-%m-%d') AND date <= str_to_date('$year-12-31', '%Y-%m-%d') ORDER BY date;");
+                    while ($r = mysqli_fetch_array($q_day)){
+                        $day = $r['day'];
+                        $month_n = $r['month'];
+                        $title = "";
+                        switch($lang){
+                            case 'es':
+                                if ($month_n == '8'){
+                                    $title = "$day de agosto";
+                                }
+                                else{
+                                    $title = "$day de julio";
+                                }
+                                break;
+                            case 'en':
+                                if ($month_n == '8'){
+                                    $title = "August " . $day . "th";
+                                }
+                                else{
+                                    $title = "July " . $day . "th";
+                                }
+                                break;
+                            case 'eu':
+                                if ($month_n == '8'){
+                                    $title = "Abustuaren " . $day . "a";
+                                }
+                                else{
+                                    $title = "Uztailaren " . $day . "a";
+                                }
+                                break;
+                        }
+?>
+                        <tr>
+                            <td>
+                                <h4><?=$title?> - <?=$r['name']?></h4>
+                            </td>
+                            <td class='price'>
+                                <h4><?=$r['price']?> €</h4>
+                            </td>
+                        </tr>
+<?php
+                    }
+                    $q_offer = mysqli_query($con, "SELECT name_$lang AS name, description_$lang AS description, price FROM festival_offer WHERE year = $year;");
+                    while ($r = mysqli_fetch_array($q_offer)){
+?>
+                        <tr>
+                            <td>
+                                <h4><?=$r['name']?></h4>
+                                <span><?=$r['description']?></span>
+                            </td>
+                            <td class='price'>
+                                <h4><?=$r['price']?> €</h4>
+                            </td>
+                        </tr>
+<?php
+                    }
+?>
+                    <tr>
+                        <td class='info'>
+                            Para apuntarte, solo tienes que hacer el ingreso correspondiente en la cuenta de Gasteizko Margolariak 
+                            <br/><br/>
+                            ES91 3035 0012 71 0120111936 de la Caja Laboral
+                            <br/><br/>
+                            indicando tu nombre y apellidos en el concepto. Si coges d&iacute;as sueltos o el pack de 3 d&iacute;as, deber&aacute;s indicar adem&aacute;s los d&iacute;as.
+                        </td>
+                        <td>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td class='warning'>
+                            ¡Importante! El &uacute;ltimo d&iacute;a para realizar los ingresos es el 15 de julio.
+                        </td>
+                        <td>
+                        </td>
+                    </tr>
+                </table>
+        </div>
+        <br/><br/><br/><br/>
+        <div class='meetings'>
+<?php
+            $title = "";
+            switch($lang){
+                case 'es':
+                    $title = "Reuniones";
+                    break;
+                case 'en':
+                    $title = "Meetings";
+                    break;
+                case 'eu':
+                    $title = "Bilerak";
+                }
+?>
+            <h3><?=$title?></h3>
+            <table>
+                <tr>
+                    <td>
+                        Antes de Fiestas, se organizar&aacute;n dos reuniones informativas, donde adem&aacute;s podr&aacute;s recoger las pulseras de control, parches, pines...
+                    </td>
+                </tr>
+                <tr>
+                    <td>
+                        <h4>Domingos 9 y 23 de julio, 20:00</h4>
+                        <table class="location">
+                                <tr>
+                                    <td class='pinpoint'><img src="https://margolariak.com/img/misc/pinpoint.png"></td>
+                                    <td>
+                                        <span class="place">Café Prado</span>
+                                        <br>
+                                        <span class="address">C/. Felicia Olave, S/N</span>
+                                    </td>
+                                </tr>
+                            </table>
+                    </td>
+                </tr>
+
+            </table>
+        </div>
+<?php
+        // Gey day list
+        $q = mysqli_query($con, "SELECT id, name_$lang AS name, DATE_FORMAT(date, '%e') AS day, DATE_FORMAT(date, '%c') AS month FROM festival_day WHERE date >= str_to_date('$year-00-00', '%Y-%m-%d') AND date <= str_to_date('$year-12-31', '%Y-%m-%d') UNION SELECT 0, '' AS name, 10 AS day, 8 AS month FROM dual;");
+        while ($r = mysqli_fetch_array($q)){
+            $day = $r['day'];
+            $month_n = $r['month'];
+            $title = "";
+            switch($lang){
+                case 'es':
+                    if ($month_n == '8'){
+                        $title = "$day de agosto";
+                    }
+                    else{
+                        $title = "$day de julio";
+                    }
+                    break;
+                case 'en':
+                    if ($month_n == '8'){
+                        $title = "August " . $day . "th";
+                    }
+                    else{
+                        $title = "July " . $day . "th";
+                    }
+                    break;
+                case 'eu':
+                    if ($month_n == '8'){
+                        $title = "Abustuaren " . $day . "a";
+                    }
+                    else{
+                        $title = "Uztailaren " . $day . "a";
+                    }
+                    break;
+            }
+            if (strlen($r['name']) > 0){
+                $title = "$title - $r[name]";
+            }
+
+?>
+            <br/><br/>
+            <div class='day'>
+                <h3><?=$title?></h3>
+                <table class='day_content'>
+<?php
+                $s_date = date_create_from_format('Y-m-d H:i', "$year-0" . $month_n . "-$day 07:00");
+                $e_date = date_create_from_format('Y-m-d H:i', "$year-0" . $month_n . "-$day 06:59");
+                $e_date = date_add($e_date, date_interval_create_from_date_string('1 days'));
+                $s_date = date_format($s_date, 'Y-m-d H:i');
+                $e_date = date_format($e_date, 'Y-m-d H:i');
+                $q_e = mysqli_query($con, "SELECT festival_event.id AS id, title_$lang AS title, description_$lang AS description, name_$lang AS place, address_$lang AS address, DATE_FORMAT(start, '%k:%i') AS time FROM festival_event, place WHERE place.id = place AND gm = 1 AND start >= str_to_date('$s_date', '%Y-%m-%d %H:%i') AND start <= str_to_date('$e_date', '%Y-%m-%d %H:%i') ORDER BY start;");
+                while ($r_e = mysqli_fetch_array($q_e)){
+?>
+                    <tr>
+                        <td class='time'><?=$r_e['time']?></td>
+                        <td class='timeline'>
+                            <img src='https://margolariak.com/img/misc/schedule-point.png'>
+                        </td>
+                        <td class='info'>
+                            <h4><?=$r_e['title']?></h4>
+                            <p><?=$r_e['description']?></p>
+                            <table class='location'>
+                                <tr>
+                                    <td><img src='https://margolariak.com/img/misc/pinpoint.png'/></td>
+                                    <td>
+                                        <span class='place'><?=$r_e['place']?></span>
+                                        <br/>
+                                        <span class='address'><?=$r_e['address']?></span>
+                                    </td>
+                                </tr>
+                            </table>
+                        </td>
+                    </tr>
+<?php
+                }
+?>
+            
+                </table> <!-- .day_content -->
+<?php            
+                //}
+?>
+            </div> <!-- .day -->
+<?php
+        }
+?>
+    </body>
+</html>

+ 6 - 0
utils/imgresize

@@ -0,0 +1,6 @@
+for file in *.jpg;do
+	convert "$file" -resize 800x800  "view/$file"
+	convert "$file" -resize 600x600  "preview/$file"
+	convert "$file" -resize 340x340  "miniature/$file"
+	convert "$file" -resize 180x180  "thumb/$file"
+done

+ 163 - 163
www-admin/actividades/add/add.php

@@ -1,165 +1,165 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb('rw');
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
-		// Get post data
-		$title_es = mysqli_real_escape_string($con, $_POST['title_es']);
-		$title_eu = mysqli_real_escape_string($con, $_POST['title_eu']);
-		$title_en = mysqli_real_escape_string($con, $_POST['title_en']);
-		$text_es = mysqli_real_escape_string($con, $_POST['text_es']);
-		$text_eu = mysqli_real_escape_string($con, $_POST['text_eu']);
-		$text_en = mysqli_real_escape_string($con, $_POST['text_en']);
-		$image = array();
-		$image[0] = $_FILES['image_0'];
-		$image[1] = $_FILES['image_1'];
-		$image[2] = $_FILES['image_2'];
-		$image[3] = $_FILES['image_3'];
-		$comments = mysqli_real_escape_string($con, $_POST['comments']);
-		$visible = mysqli_real_escape_string($con, $_POST['visible']);
-		$admin = mysqli_real_escape_string($con, $_POST['admin']);
-		$schedule = mysqli_real_escape_string($con, $_POST['schedule']);
-		$city = mysqli_real_escape_string($con, $_POST['city']);
-		$day = mysqli_real_escape_string($con, $_POST['day']);
-		$month = mysqli_real_escape_string($con, $_POST['month']);
-		$year = mysqli_real_escape_string($con, $_POST['year']);
-		//$hour = mysqli_real_escape_string($con, $_POST['hour']);
-		//$minute = mysqli_real_escape_string($con, $_POST['minute']);
-		$price = mysqli_real_escape_string($con, $_POST['price']);
-		$inscription = mysqli_real_escape_string($con, $_POST['inscription']);
-		$people = mysqli_real_escape_string($con, $_POST['people']);
-		
-		
-		//Check spanish title and generate permalink
-		if ($title_es == null)
-			exit();
-		else{
-			$permalink = permalink($title_es);
-			$i = 2;
-			$ok = false;
-			$tmppermalink = $permalink;
-			while ($ok == false){
-				$query = mysqli_query($con, "SELECT id FROM activity WHERE permalink = '$tmppermalink';");
-				if (mysqli_num_rows($query) > 0){
-					$tmppermalink = $permalink . "-" . $i;
-					$i ++;
-				}
-				else{
-					$permalink = $tmppermalink;
-					$ok = true;
-				}
-			}
-		}
-		
-		//Check titles with no text
-		if (strlen($title_eu) > 0 && strlen($text_eu) < 1)
-			exit();
-		if (strlen($title_en) > 0 && strlen($text_en) < 1)
-			exit();
-		
-		//Check text with no titles
-		if (strlen($text_eu) > 0 && strlen($title_eu) < 1)
-			exit();
-		if (strlen($text_en) > 0 && strlen($title_en) < 1)
-			exit();
-		
-		//Check city
-		if ($city == '')
-			$city = 'Vitoria-Gasteiz';
-		
-		//Check booleans and assign default values if not
-		if ($comments == 'off')
-			$comments = 0;
-		else
-			$comments = 1;
-		if ($visible == 'off')
-			$visible = 0;
-		else
-			$visible = 1;
-		if ($admin == 'on')
-			$admin = 1;
-		else
-			$admin = 0;
-		if ($inscription == 'off')
-			$inscription = 0;
-		else
-			$inscription = 1;
-		
-		//TODO:Check valid date
-		if ($day == '' || $month == '' || $year == '')
-			exit();
-		$date = "str_to_date('$year-$month-$day', '%Y-%m-%d')";
-		
-		//Assign numeric inputs, defaulting to 0 if not numeric
-		$price = intval($price);
-		$people = intval($people);
-			
-		// If no translations, same text in all languages
-		if (strlen($text_eu) == 0){
-			$text_eu = $text_es;
-			$title_eu = $title_es; 
-		}
-		
-		if (strlen($text_en) == 0){
-			$text_en = $text_es;
-			$title_en = $title_es; 
-		}
-		
-		//Get user
-		if ($admin)
-			$user = 0;
-		else{
-			//TODO
-			$user = 0;
-		}
-		
-		// TODO: Check for valid date
-		
-		//Insert into database and get id
-		mysqli_query($con, "INSERT INTO activity (permalink, date, title_es, title_eu, title_en, text_es, text_eu, text_en, price, inscription, max_people, user, visible, comments, city) VALUES('$permalink', $date, '$title_es', '$title_eu', '$title_en', '$text_es', '$text_eu', '$text_en', $price, $inscription, $people, $user, $visible, $comments, '$city');");
-		$q = mysqli_query($con, "SELECT id FROM activity WHERE permalink = '$permalink' ORDER BY dtime DESC LIMIT 1;");
-		$r = mysqli_fetch_array($q);
-		$id = $r['id'];
-		
-		//Process images
-		$file_idx = 0;
-		$img_idx = 0;
-		while ($file_idx < 4 && $img_idx < 4){
-			if (file_exists($image[$file_idx]['tmp_name']) > 0){
-				
-				//Convert to jpg
-				$im = new imagick($image[$file_idx]['tmp_name']);
-				$im->setImageFormat('jpg');
-				$im->writeImage("../../../www/img/actividades/$permalink-n$img_idx.jpg");
-				$im->resizeImage(800, 800, Imagick::FILTER_POINT, false);
-				$im->writeImage("../../../www/img/actividades/view/$permalink-n$img_idx.jpg");
-				$im->resizeImage(600, 600, Imagick::FILTER_POINT, false);
-				$im->writeImage("../../../www/img/actividades/preview/$permalink-n$img_idx.jpg");
-				$im->resizeImage(340, 340, Imagick::FILTER_POINT, false);
-				$im->writeImage("../../../www/img/actividades/miniature/$permalink-n$img_idx.jpg");
-				$im->resizeImage(180, 180, Imagick::FILTER_POINT, false);
-				$im->writeImage("../../../www/img/actividades/thumb/$permalink-n$img_idx.jpg");
-				$im->clear();
-				$im->destroy();
-				
-				//Database
-				mysqli_query($con, "INSERT INTO activity_image (activity, image, idx) VALUES ($id, '$permalink-n$img_idx.jpg', $img_idx);");
-				
-				$img_idx ++;
-			}
-			$file_idx ++;
-		}
-		
-		version();
-		
-		//Edit schedule if requires, return if not
-		if ($schedule == 'on')
-			header("Location: /actividades/add/itinerary.php?id=$id");
-		else
-			header("Location: /actividades/");
-	}
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb('rw');
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+        // Get post data
+        $title_es = mysqli_real_escape_string($con, $_POST['title_es']);
+        $title_eu = mysqli_real_escape_string($con, $_POST['title_eu']);
+        $title_en = mysqli_real_escape_string($con, $_POST['title_en']);
+        $text_es = mysqli_real_escape_string($con, $_POST['text_es']);
+        $text_eu = mysqli_real_escape_string($con, $_POST['text_eu']);
+        $text_en = mysqli_real_escape_string($con, $_POST['text_en']);
+        $image = array();
+        $image[0] = $_FILES['image_0'];
+        $image[1] = $_FILES['image_1'];
+        $image[2] = $_FILES['image_2'];
+        $image[3] = $_FILES['image_3'];
+        $comments = mysqli_real_escape_string($con, $_POST['comments']);
+        $visible = mysqli_real_escape_string($con, $_POST['visible']);
+        $admin = mysqli_real_escape_string($con, $_POST['admin']);
+        $schedule = mysqli_real_escape_string($con, $_POST['schedule']);
+        $city = mysqli_real_escape_string($con, $_POST['city']);
+        $day = mysqli_real_escape_string($con, $_POST['day']);
+        $month = mysqli_real_escape_string($con, $_POST['month']);
+        $year = mysqli_real_escape_string($con, $_POST['year']);
+        //$hour = mysqli_real_escape_string($con, $_POST['hour']);
+        //$minute = mysqli_real_escape_string($con, $_POST['minute']);
+        $price = mysqli_real_escape_string($con, $_POST['price']);
+        $inscription = mysqli_real_escape_string($con, $_POST['inscription']);
+        $people = mysqli_real_escape_string($con, $_POST['people']);
+        
+        
+        //Check spanish title and generate permalink
+        if ($title_es == null)
+            exit();
+        else{
+            $permalink = permalink($title_es);
+            $i = 2;
+            $ok = false;
+            $tmppermalink = $permalink;
+            while ($ok == false){
+                $query = mysqli_query($con, "SELECT id FROM activity WHERE permalink = '$tmppermalink';");
+                if (mysqli_num_rows($query) > 0){
+                    $tmppermalink = $permalink . "-" . $i;
+                    $i ++;
+                }
+                else{
+                    $permalink = $tmppermalink;
+                    $ok = true;
+                }
+            }
+        }
+        
+        //Check titles with no text
+        if (strlen($title_eu) > 0 && strlen($text_eu) < 1)
+            exit();
+        if (strlen($title_en) > 0 && strlen($text_en) < 1)
+            exit();
+        
+        //Check text with no titles
+        if (strlen($text_eu) > 0 && strlen($title_eu) < 1)
+            exit();
+        if (strlen($text_en) > 0 && strlen($title_en) < 1)
+            exit();
+        
+        //Check city
+        if ($city == '')
+            $city = 'Vitoria-Gasteiz';
+        
+        //Check booleans and assign default values if not
+        if ($comments == 'off')
+            $comments = 0;
+        else
+            $comments = 1;
+        if ($visible == 'off')
+            $visible = 0;
+        else
+            $visible = 1;
+        if ($admin == 'on')
+            $admin = 1;
+        else
+            $admin = 0;
+        if ($inscription == 'off')
+            $inscription = 0;
+        else
+            $inscription = 1;
+        
+        //TODO:Check valid date
+        if ($day == '' || $month == '' || $year == '')
+            exit();
+        $date = "str_to_date('$year-$month-$day', '%Y-%m-%d')";
+        
+        //Assign numeric inputs, defaulting to 0 if not numeric
+        $price = intval($price);
+        $people = intval($people);
+            
+        // If no translations, same text in all languages
+        if (strlen($text_eu) == 0){
+            $text_eu = $text_es;
+            $title_eu = $title_es; 
+        }
+        
+        if (strlen($text_en) == 0){
+            $text_en = $text_es;
+            $title_en = $title_es; 
+        }
+        
+        //Get user
+        if ($admin)
+            $user = 0;
+        else{
+            //TODO
+            $user = 0;
+        }
+        
+        // TODO: Check for valid date
+        
+        //Insert into database and get id
+        mysqli_query($con, "INSERT INTO activity (permalink, date, title_es, title_eu, title_en, text_es, text_eu, text_en, price, inscription, max_people, user, visible, comments, city) VALUES('$permalink', $date, '$title_es', '$title_eu', '$title_en', '$text_es', '$text_eu', '$text_en', $price, $inscription, $people, $user, $visible, $comments, '$city');");
+        $q = mysqli_query($con, "SELECT id FROM activity WHERE permalink = '$permalink' ORDER BY dtime DESC LIMIT 1;");
+        $r = mysqli_fetch_array($q);
+        $id = $r['id'];
+        
+        //Process images
+        $file_idx = 0;
+        $img_idx = 0;
+        while ($file_idx < 4 && $img_idx < 4){
+            if (file_exists($image[$file_idx]['tmp_name']) > 0){
+                
+                //Convert to jpg
+                $im = new imagick($image[$file_idx]['tmp_name']);
+                $im->setImageFormat('jpg');
+                $im->writeImage("../../../www/img/actividades/$permalink-n$img_idx.jpg");
+                $im->resizeImage(800, 800, Imagick::FILTER_POINT, false);
+                $im->writeImage("../../../www/img/actividades/view/$permalink-n$img_idx.jpg");
+                $im->resizeImage(600, 600, Imagick::FILTER_POINT, false);
+                $im->writeImage("../../../www/img/actividades/preview/$permalink-n$img_idx.jpg");
+                $im->resizeImage(340, 340, Imagick::FILTER_POINT, false);
+                $im->writeImage("../../../www/img/actividades/miniature/$permalink-n$img_idx.jpg");
+                $im->resizeImage(180, 180, Imagick::FILTER_POINT, false);
+                $im->writeImage("../../../www/img/actividades/thumb/$permalink-n$img_idx.jpg");
+                $im->clear();
+                $im->destroy();
+                
+                //Database
+                mysqli_query($con, "INSERT INTO activity_image (activity, image, idx) VALUES ($id, '$permalink-n$img_idx.jpg', $img_idx);");
+                
+                $img_idx ++;
+            }
+            $file_idx ++;
+        }
+        
+        version();
+        
+        //Edit schedule if requires, return if not
+        if ($schedule == 'on')
+            header("Location: /actividades/add/itinerary.php?id=$id");
+        else
+            header("Location: /actividades/");
+    }
 ?>

+ 105 - 105
www-admin/actividades/add/additinerary.php

@@ -1,107 +1,107 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb('rw');
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	//Get activity id
-	$id = mysqli_real_escape_string($con, $_POST['activity']);
-	//echo "ID " . $id;
-	$q = mysqli_query($con, "SELECT id, DATE_FORMAT(date, '%Y-%m-%d') AS date FROM activity WHERE id = $id;");
-	if(mysqli_num_rows($q) == 0){
-		header("Location: $http_host/actividades/");
-		exit (-1);
-	}
-	
-	//Get date
-	$r = mysqli_fetch_array($q);
-	$date = $r['date'];
-	
-	//Initialize data arrays
-	$starth = [];
-	$startm = [];
-	$endh = [];
-	$endm = [];
-	$place = [];
-	$title_es = [];
-	$title_en = [];
-	$title_eu = [];
-	$text_es = [];
-	$text_en = [];
-	$text_eu = [];
-	
-	//Loop all rows
-	for ($i = 0; $i < 100; $i ++){
-	
-		//Get post data
-		$starth[$i] = mysqli_real_escape_string($con, $_POST["sh_$i"]);
-		$startm[$i] = mysqli_real_escape_string($con, $_POST["sm_$i"]);
-		$endh[$i] = mysqli_real_escape_string($con, $_POST["eh_$i"]);
-		$endm[$i] = mysqli_real_escape_string($con, $_POST["em_$i"]);
-		$place[$i] = mysqli_real_escape_string($con, $_POST["place_$i"]);
-		$title_es[$i] = mysqli_real_escape_string($con, $_POST["title_es_$i"]);
-		$title_en[$i] = mysqli_real_escape_string($con, $_POST["title_en_$i"]);
-		$title_eu[$i] = mysqli_real_escape_string($con, $_POST["title_eu_$i"]);
-		$text_es[$i] = mysqli_real_escape_string($con, $_POST["text_es_$i"]);
-		$text_en[$i] = mysqli_real_escape_string($con, $_POST["text_en_$i"]);
-		$text_eu[$i] = mysqli_real_escape_string($con, $_POST["text_eu_$i"]);
-		
-		//Check data
-		$insert = true;
-		
-		//Preconfigure query strings with known data
-		$fields = "INSERT INTO activity_itinerary VALUES (activity, place, start, ";
-		$values = " VALUES ($id, $place[i] ";
-		if ($starth[$i] == '' || $starth[$i] < 0 || $starth[$i] > 24 || $startm[$i] == '' || $startm[$i] < 0 || $startm[$i] > 60){ //Validate start time
-			$insert = false;
-		}
-		else{
-			$values = $values . "STR_TO_DATE('$date " . $starth[$i] . ":" . $startm[$i] . ":00', '%Y-%m-%d %H:%i:%s'), ";
-		}
-		if ($endh[$i] == '' ||$endh[$i] < 0 || $endh[$i] > 24 || $endm[$i] == '' || $endm[$i] < 0 || $endm[$i] > 60){ //Validate end time
-			//$insert = false;
-		}
-		else{
-			$fields = $fields . "end, ";
-			$values = $values . "STR_TO_DATE('$date " . $endh[$i] . ":" . $endm[$i] . ":00', '%Y-%m-%d %H:%i:%s'), ";
-		}
-		if ($title_es[$i] == ''){ //Validate title
-			$insert = false;
-		}
-		else{
-			if ($title_en[$i] == ''){
-				$title_en[$i] = $title_es[$i];
-			}
-			if ($title_eu[$i] == ''){
-				$title_eu[$i] = $title_es[$i];
-			}
-			$fields = $fields . "title_es, title_en, title_eu, ";
-			$values = $values . "'" . $title_es[$i] . "', '" . $title_en[$i] . "', '" . $title_eu[$i] . "', ";
-		}
-		if ($text_es[$i] == ''){ //Validate text
-			$insert = false;
-		}
-		else{
-			if ($text_en[$i] == ''){
-				$text_en[$i] = $text_es[$i];
-			}
-			if ($text_eu[$i] == ''){
-				$text_eu[$i] = $text_es[$i];
-			}
-			$fields = $fields . "text_es, text_en, text_eu)";
-			$values = $values . "'" . $text_es[$i] . "', '" . $text_en[$i] . "', '" . $text_eu[$i] . "');";
-		}
-		
-		//Insert if appropiate
-		if ($insert == true){
-			$query = $fields . $values;
-			mysqli_query($con, $query); //TODO further test
-			version();
-		}
-		
-		//Redirect
-		header("Location: $http_host/actividades/");
-	}
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb('rw');
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    //Get activity id
+    $id = mysqli_real_escape_string($con, $_POST['activity']);
+    //echo "ID " . $id;
+    $q = mysqli_query($con, "SELECT id, DATE_FORMAT(date, '%Y-%m-%d') AS date FROM activity WHERE id = $id;");
+    if(mysqli_num_rows($q) == 0){
+        header("Location: $http_host/actividades/");
+        exit (-1);
+    }
+    
+    //Get date
+    $r = mysqli_fetch_array($q);
+    $date = $r['date'];
+    
+    //Initialize data arrays
+    $starth = [];
+    $startm = [];
+    $endh = [];
+    $endm = [];
+    $place = [];
+    $title_es = [];
+    $title_en = [];
+    $title_eu = [];
+    $text_es = [];
+    $text_en = [];
+    $text_eu = [];
+    
+    //Loop all rows
+    for ($i = 0; $i < 100; $i ++){
+    
+        //Get post data
+        $starth[$i] = mysqli_real_escape_string($con, $_POST["sh_$i"]);
+        $startm[$i] = mysqli_real_escape_string($con, $_POST["sm_$i"]);
+        $endh[$i] = mysqli_real_escape_string($con, $_POST["eh_$i"]);
+        $endm[$i] = mysqli_real_escape_string($con, $_POST["em_$i"]);
+        $place[$i] = mysqli_real_escape_string($con, $_POST["place_$i"]);
+        $title_es[$i] = mysqli_real_escape_string($con, $_POST["title_es_$i"]);
+        $title_en[$i] = mysqli_real_escape_string($con, $_POST["title_en_$i"]);
+        $title_eu[$i] = mysqli_real_escape_string($con, $_POST["title_eu_$i"]);
+        $text_es[$i] = mysqli_real_escape_string($con, $_POST["text_es_$i"]);
+        $text_en[$i] = mysqli_real_escape_string($con, $_POST["text_en_$i"]);
+        $text_eu[$i] = mysqli_real_escape_string($con, $_POST["text_eu_$i"]);
+        
+        //Check data
+        $insert = true;
+        
+        //Preconfigure query strings with known data
+        $fields = "INSERT INTO activity_itinerary VALUES (activity, place, start, ";
+        $values = " VALUES ($id, $place[i] ";
+        if ($starth[$i] == '' || $starth[$i] < 0 || $starth[$i] > 24 || $startm[$i] == '' || $startm[$i] < 0 || $startm[$i] > 60){ //Validate start time
+            $insert = false;
+        }
+        else{
+            $values = $values . "STR_TO_DATE('$date " . $starth[$i] . ":" . $startm[$i] . ":00', '%Y-%m-%d %H:%i:%s'), ";
+        }
+        if ($endh[$i] == '' ||$endh[$i] < 0 || $endh[$i] > 24 || $endm[$i] == '' || $endm[$i] < 0 || $endm[$i] > 60){ //Validate end time
+            //$insert = false;
+        }
+        else{
+            $fields = $fields . "end, ";
+            $values = $values . "STR_TO_DATE('$date " . $endh[$i] . ":" . $endm[$i] . ":00', '%Y-%m-%d %H:%i:%s'), ";
+        }
+        if ($title_es[$i] == ''){ //Validate title
+            $insert = false;
+        }
+        else{
+            if ($title_en[$i] == ''){
+                $title_en[$i] = $title_es[$i];
+            }
+            if ($title_eu[$i] == ''){
+                $title_eu[$i] = $title_es[$i];
+            }
+            $fields = $fields . "title_es, title_en, title_eu, ";
+            $values = $values . "'" . $title_es[$i] . "', '" . $title_en[$i] . "', '" . $title_eu[$i] . "', ";
+        }
+        if ($text_es[$i] == ''){ //Validate text
+            $insert = false;
+        }
+        else{
+            if ($text_en[$i] == ''){
+                $text_en[$i] = $text_es[$i];
+            }
+            if ($text_eu[$i] == ''){
+                $text_eu[$i] = $text_es[$i];
+            }
+            $fields = $fields . "text_es, text_en, text_eu)";
+            $values = $values . "'" . $text_es[$i] . "', '" . $text_en[$i] . "', '" . $text_eu[$i] . "');";
+        }
+        
+        //Insert if appropiate
+        if ($insert == true){
+            $query = $fields . $values;
+            mysqli_query($con, $query); //TODO further test
+            version();
+        }
+        
+        //Redirect
+        header("Location: $http_host/actividades/");
+    }
 ?>

+ 126 - 126
www-admin/actividades/add/index.php

@@ -1,130 +1,130 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{?>
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nueva actividad - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/actividades.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/actividades.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="script.js"></script>
-		<script type="text/javascript" src="/script/ui.js"></script>
-		<script src="../../ckeditor/ckeditor.js"></script>
-	</head>
-	<body>
-		<?php include('../../toolbar.php'); ?>
-		<div id='content'>
-			<div class="section">
-				<h3 class="section_title">Nueva actividad</h3>
-				<form action="/actividades/add/add.php" maxlength="120" method="post" enctype="multipart/form-data" onsubmit="return validateActivity();">
-					<div class="entry">
-						<div id="lang_tabs">
-							<table>
-								<tr>
-									<td class="pointer lang_tabs_active" id="lang_tab_es" onclick="showLanguage('es');">
-										Castellano
-									</td>
-									<td class="pointer" id="lang_tab_eu" onclick="showLanguage('eu');">
-										Euskera
-									</td>
-									<td class="pointer" id="lang_tab_en" onclick="showLanguage('en');">
-										Ingl&eacute;s
-									</td>
-								</tr>
-							</table>
-						</div>
-						<div id="content_lang_es">
-							<input type="text" id="title_es" name="title_es" placeholder="Titulo"/><br/><br/>
-							<textarea name="text_es" id="text_es" placeholder="Texto"></textarea>
-							<script>
-								CKEDITOR.replace('text_es');
-							</script>
-						</div>
-						<div id="content_lang_eu" style="display:none;">
-							<input type="text" id="title_eu" name="title_eu" placeholder="Titulu"/><br/><br/>
-							<textarea name="text_eu" id="text_eu" placeholder="Textua"></textarea>
-							<script>
-								CKEDITOR.replace('text_eu');
-							</script>
-						</div>
-						<div id="content_lang_en" style="display:none;">
-							<input type="text" id="title_en" name="title_en" placeholder="Title"/><br/><br/>
-							<textarea name="text_en" id="text_en" placeholder="Content"></textarea>
-							<script>
-								CKEDITOR.replace('text_en');
-							</script>
-						</div>
-					</div> <!--Entry-->
-					<div class="entry" id="activity_images">
-						<h4>Detalles</h4>
-						Ciudad:<input type="text" name="city" length="30" value="Vitoria-Gasteiz"/><br/><br/>
-						Fecha:
-						<input type="text" length="4" name="year" placeholder="yyyy"/> -
-						<input type="text" length="2" name="month" placeholder="mm"/> -
-						<input type="text" length="2" name="day" placeholder="dd"/>
-						<!--<br/>Hora (opcional):
-						<input type="text" length="2" name="hour" placeholder="hh"/> :
-						<input type="text" length="2" name="minute" placeholder="mm"/>-->
-						<br/><br/>Precio (en blanco si es gratuita):
-						<input type="text" length="4" name="price" placeholder="eur"/>
-						<br/><br/><label><input type="checkbox" name="inscription" checked/>Se requiere inscripcion</label>
-						<br/><br/>Numero de plazas (en blanco para ilimitadas): <input type="text" length="4" name="people" placeholder="#"/>
-						
-						<h4>Imagenes</h4>
-						<ul>
-							<li>
-								Principal (Sobre el texto y en previsualizaciones)<br/>
-								<div class="image_upload_container">
-									<img class="image_upload_preview" id="image_preview_0" src="/img/misc/alpha.png"/>
-									<input id="image_0" onchange="previewImage(this, image_preview_0);" type="file" name="image_0" accept="image/x-png, image/gif, image/jpeg"/>
-								</div>
-								<br/>
-							</li>
-							<li>
-								Secundarias (Bajo el texto)<br/>
-								<div class="image_upload_container">
-									<img class="image_upload_preview" id="image_preview_1" src="/img/misc/alpha.png"/>
-									<input id="image_1" onchange="previewImage(this, image_preview_1);" type="file" name="image_1" accept="image/x-png, image/gif, image/jpeg"/>
-								</div>
-								<div class="image_upload_container">
-									<img class="image_upload_preview" id="image_preview_2" src="/img/misc/alpha.png"/>
-									<input id="image_2" onchange="previewImage(this, image_preview_2);" type="file" name="image_2" accept="image/x-png, image/gif, image/jpeg"/>
-								</div>
-								<div class="image_upload_container">
-									<img class="image_upload_preview" id="image_preview_3" src="/img/misc/alpha.png"/>
-									<input id="image_3" onchange="previewImage(this, image_preview_3);" type="file" name="image_3" accept="image/x-png, image/gif, image/jpeg"/>
-								</div>
-							</li>
-						</ul>
-					</div>
-					<div class="entry" id="activity_options">
-						<h4>Ajustes</h4>
-						<label><input type="checkbox" name="schedule" checked/>Editar itinerario en la siguiente pantalla</label><br/><br/>
-						<label><input type="checkbox" name="visible" checked/>Actividad visible</label><br/><br/>
-						<label><input type="checkbox" name="comments" checked/>Permitir comentarios</label><br/><br/>
-						<label><input type="checkbox" name="admin"/>Publicar como Gasteizko Margolariak en lugar de mi nombre</label>
-						<br/><br/><br/><br/>
-						<div id="button_container">
-							<input type="button" value="Previsualizar" onClick="alert(validateActivity());"/> <!--TODO-->
-							</br>
-							<input type="submit" value="Publicar"/>
-						</div>
-					</div>
-				</form>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nueva actividad - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/actividades.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/actividades.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+        <script type="text/javascript" src="/script/ui.js"></script>
+        <script src="../../ckeditor/ckeditor.js"></script>
+    </head>
+    <body>
+        <?php include('../../toolbar.php'); ?>
+        <div id='content'>
+            <div class="section">
+                <h3 class="section_title">Nueva actividad</h3>
+                <form action="/actividades/add/add.php" maxlength="120" method="post" enctype="multipart/form-data" onsubmit="return validateActivity();">
+                    <div class="entry">
+                        <div id="lang_tabs">
+                            <table>
+                                <tr>
+                                    <td class="pointer lang_tabs_active" id="lang_tab_es" onclick="showLanguage('es');">
+                                        Castellano
+                                    </td>
+                                    <td class="pointer" id="lang_tab_eu" onclick="showLanguage('eu');">
+                                        Euskera
+                                    </td>
+                                    <td class="pointer" id="lang_tab_en" onclick="showLanguage('en');">
+                                        Ingl&eacute;s
+                                    </td>
+                                </tr>
+                            </table>
+                        </div>
+                        <div id="content_lang_es">
+                            <input type="text" id="title_es" name="title_es" placeholder="Titulo"/><br/><br/>
+                            <textarea name="text_es" id="text_es" placeholder="Texto"></textarea>
+                            <script>
+                                CKEDITOR.replace('text_es');
+                            </script>
+                        </div>
+                        <div id="content_lang_eu" style="display:none;">
+                            <input type="text" id="title_eu" name="title_eu" placeholder="Titulu"/><br/><br/>
+                            <textarea name="text_eu" id="text_eu" placeholder="Textua"></textarea>
+                            <script>
+                                CKEDITOR.replace('text_eu');
+                            </script>
+                        </div>
+                        <div id="content_lang_en" style="display:none;">
+                            <input type="text" id="title_en" name="title_en" placeholder="Title"/><br/><br/>
+                            <textarea name="text_en" id="text_en" placeholder="Content"></textarea>
+                            <script>
+                                CKEDITOR.replace('text_en');
+                            </script>
+                        </div>
+                    </div> <!--Entry-->
+                    <div class="entry" id="activity_images">
+                        <h4>Detalles</h4>
+                        Ciudad:<input type="text" name="city" length="30" value="Vitoria-Gasteiz"/><br/><br/>
+                        Fecha:
+                        <input type="text" length="4" name="year" placeholder="yyyy"/> -
+                        <input type="text" length="2" name="month" placeholder="mm"/> -
+                        <input type="text" length="2" name="day" placeholder="dd"/>
+                        <!--<br/>Hora (opcional):
+                        <input type="text" length="2" name="hour" placeholder="hh"/> :
+                        <input type="text" length="2" name="minute" placeholder="mm"/>-->
+                        <br/><br/>Precio (en blanco si es gratuita):
+                        <input type="text" length="4" name="price" placeholder="eur"/>
+                        <br/><br/><label><input type="checkbox" name="inscription" checked/>Se requiere inscripcion</label>
+                        <br/><br/>Numero de plazas (en blanco para ilimitadas): <input type="text" length="4" name="people" placeholder="#"/>
+                        
+                        <h4>Imagenes</h4>
+                        <ul>
+                            <li>
+                                Principal (Sobre el texto y en previsualizaciones)<br/>
+                                <div class="image_upload_container">
+                                    <img class="image_upload_preview" id="image_preview_0" src="/img/misc/alpha.png"/>
+                                    <input id="image_0" onchange="previewImage(this, image_preview_0);" type="file" name="image_0" accept="image/x-png, image/gif, image/jpeg"/>
+                                </div>
+                                <br/>
+                            </li>
+                            <li>
+                                Secundarias (Bajo el texto)<br/>
+                                <div class="image_upload_container">
+                                    <img class="image_upload_preview" id="image_preview_1" src="/img/misc/alpha.png"/>
+                                    <input id="image_1" onchange="previewImage(this, image_preview_1);" type="file" name="image_1" accept="image/x-png, image/gif, image/jpeg"/>
+                                </div>
+                                <div class="image_upload_container">
+                                    <img class="image_upload_preview" id="image_preview_2" src="/img/misc/alpha.png"/>
+                                    <input id="image_2" onchange="previewImage(this, image_preview_2);" type="file" name="image_2" accept="image/x-png, image/gif, image/jpeg"/>
+                                </div>
+                                <div class="image_upload_container">
+                                    <img class="image_upload_preview" id="image_preview_3" src="/img/misc/alpha.png"/>
+                                    <input id="image_3" onchange="previewImage(this, image_preview_3);" type="file" name="image_3" accept="image/x-png, image/gif, image/jpeg"/>
+                                </div>
+                            </li>
+                        </ul>
+                    </div>
+                    <div class="entry" id="activity_options">
+                        <h4>Ajustes</h4>
+                        <label><input type="checkbox" name="schedule" checked/>Editar itinerario en la siguiente pantalla</label><br/><br/>
+                        <label><input type="checkbox" name="visible" checked/>Actividad visible</label><br/><br/>
+                        <label><input type="checkbox" name="comments" checked/>Permitir comentarios</label><br/><br/>
+                        <label><input type="checkbox" name="admin"/>Publicar como Gasteizko Margolariak en lugar de mi nombre</label>
+                        <br/><br/><br/><br/>
+                        <div id="button_container">
+                            <input type="button" value="Previsualizar" onClick="alert(validateActivity());"/> <!--TODO-->
+                            </br>
+                            <input type="submit" value="Publicar"/>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </body>
 </html>
 <?php } ?>

+ 97 - 97
www-admin/actividades/add/itinerary.php

@@ -1,111 +1,111 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	//Get activity id
-	$id = mysqli_real_escape_string($con, $_GET['id']);
-	$q = mysqli_query($con, "SELECT * FROM activity WHERE id = $id;");
-	//echo "SELECT * FROM activity WHERE id = $id;";
-	if(mysqli_num_rows($q) == 0){
-		header("Location: $http_host/actividades/");
-		exit (-1);
-	}
-	else{
-		$r = mysqli_fetch_array($q);
-	?>
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    //Get activity id
+    $id = mysqli_real_escape_string($con, $_GET['id']);
+    $q = mysqli_query($con, "SELECT * FROM activity WHERE id = $id;");
+    //echo "SELECT * FROM activity WHERE id = $id;";
+    if(mysqli_num_rows($q) == 0){
+        header("Location: $http_host/actividades/");
+        exit (-1);
+    }
+    else{
+        $r = mysqli_fetch_array($q);
+    ?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nueva actividad - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/actividades.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/actividades.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="script.js"></script>
-		<script type="text/javascript" src="/script/ui.js"></script>
-		<script src="../../ckeditor/ckeditor.js"></script>
-	</head>
-	<body>
-		<?php include('../../toolbar.php'); ?>
-		<div id='content'>
-			<div class='section'>
-				<h3 class="section_title">Modificar itinerario</h3>
-				<form action='additinerary.php' method='post'>
-					<div class="entry">
-						<input type='hidden' name='activity' value='<?php echo $id; ?>'/>
-						<table id='itinerary'>
-						<?php
-							$q_place = mysqli_query($con, "SELECT id, name_es FROM place ORDER BY name_es;");
-							$i = 0;
-							for ($i = 0; $i < 50; $i ++){
-								echo "<tr id='itinerary_row_$i' class='itinerary_row'>\n";
-								echo "<td class='itinerary_cell time'>\n";
-								echo "<h4>Hora y lugar</h4>\n";
-								echo "Inicio*:&nbsp<input type='number' maxlength='2' name='sh_$i' id='sh_$i' onChange='showNextRow($i);'/>:<input type='number' maxlength='2' name='sm_$i' id='sm_$i' onChange='showNextRow($i);'/>\n";
-								echo "<br/>Final:&nbsp<input type='number' maxlength='2' name='eh_$i' id='eh_$i' onChange='showNextRow($i);'/>:<input type='number' maxlength='2' name='em_$i' id='em_$i' onChange='showNextRow($i);'/>\n";
-								echo "<br/><br/>\n";
-								echo "Lugar*: <select name='place_$i' id='place_$i' onChange='showNextRow($i);'>\n";
-								echo "<option value='-1'>SELECCIONA</option>\n";
-								mysqli_data_seek($q_place, 0);
-								while ($r_place = mysqli_fetch_array($q_place)){
-									echo "<option value='$r_place[id]'>$r_place[name_es]</option>\n";
-								}
-								echo "</select><br/>\n";
-								echo "<span id='add_place' class='pointer' onClick='addPlace($i);'>A&ntilde;adir nuevo lugar</span>\n";
-								echo "</td>\n";
-								echo "<td class='itinerary_cell itinerary_cell_content'>\n";
-							?>
-							<div id='lang_tabs'>
-	                                                        <table>
-               		                                                <tr>
-                               		                                        <td class="pointer lang_tabs_active" id="lang_tab_es" onclick="showLanguage('es');">
-                                               		                                Castellano
-                                                               		        </td>
-	                                                                        <td class="pointer" id="lang_tab_eu" onclick="showLanguage('eu');">
-               		                                                                Euskera
-                               		                                        </td>
-                                               		                        <td class="pointer" id="lang_tab_en" onclick="showLanguage('en');">
-                                                               		                Ingl&eacute;s
-                                                                       		</td>
-                       			                                 </tr>
-                                               		        </table>
-		                                                </div>
-	               		                                <div id="content_lang_es">
-									<h4>T&iacute;tulo</h4>
-									<input type='text' name='title_es_<?php echo($i); ?>' id='title_es_<?php echo($i); ?>' onKeyUp='showNextRow(<?php echo($i); ?>'/>
-									<h4>Texto</h4>
-									<textarea name='text_es_<?php echo($i); ?>' id='text_es_<?php echo($i); ?>' onKeyUp='showNextRow(<?php echo($i); ?>);'/></textarea>
-								</div>
-								<div id="content_lang_eu" style="display:none;">
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nueva actividad - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/actividades.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/actividades.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+        <script type="text/javascript" src="/script/ui.js"></script>
+        <script src="../../ckeditor/ckeditor.js"></script>
+    </head>
+    <body>
+        <?php include('../../toolbar.php'); ?>
+        <div id='content'>
+            <div class='section'>
+                <h3 class="section_title">Modificar itinerario</h3>
+                <form action='additinerary.php' method='post'>
+                    <div class="entry">
+                        <input type='hidden' name='activity' value='<?php echo $id; ?>'/>
+                        <table id='itinerary'>
+                        <?php
+                            $q_place = mysqli_query($con, "SELECT id, name_es FROM place ORDER BY name_es;");
+                            $i = 0;
+                            for ($i = 0; $i < 50; $i ++){
+                                echo "<tr id='itinerary_row_$i' class='itinerary_row'>\n";
+                                echo "<td class='itinerary_cell time'>\n";
+                                echo "<h4>Hora y lugar</h4>\n";
+                                echo "Inicio*:&nbsp<input type='number' maxlength='2' name='sh_$i' id='sh_$i' onChange='showNextRow($i);'/>:<input type='number' maxlength='2' name='sm_$i' id='sm_$i' onChange='showNextRow($i);'/>\n";
+                                echo "<br/>Final:&nbsp<input type='number' maxlength='2' name='eh_$i' id='eh_$i' onChange='showNextRow($i);'/>:<input type='number' maxlength='2' name='em_$i' id='em_$i' onChange='showNextRow($i);'/>\n";
+                                echo "<br/><br/>\n";
+                                echo "Lugar*: <select name='place_$i' id='place_$i' onChange='showNextRow($i);'>\n";
+                                echo "<option value='-1'>SELECCIONA</option>\n";
+                                mysqli_data_seek($q_place, 0);
+                                while ($r_place = mysqli_fetch_array($q_place)){
+                                    echo "<option value='$r_place[id]'>$r_place[name_es]</option>\n";
+                                }
+                                echo "</select><br/>\n";
+                                echo "<span id='add_place' class='pointer' onClick='addPlace($i);'>A&ntilde;adir nuevo lugar</span>\n";
+                                echo "</td>\n";
+                                echo "<td class='itinerary_cell itinerary_cell_content'>\n";
+                            ?>
+                            <div id='lang_tabs'>
+                                                            <table>
+                                                                       <tr>
+                                                                               <td class="pointer lang_tabs_active" id="lang_tab_es" onclick="showLanguage('es');">
+                                                                                       Castellano
+                                                                               </td>
+                                                                            <td class="pointer" id="lang_tab_eu" onclick="showLanguage('eu');">
+                                                                                       Euskera
+                                                                               </td>
+                                                                               <td class="pointer" id="lang_tab_en" onclick="showLanguage('en');">
+                                                                                       Ingl&eacute;s
+                                                                               </td>
+                                                                    </tr>
+                                                               </table>
+                                                        </div>
+                                                           <div id="content_lang_es">
+                                    <h4>T&iacute;tulo</h4>
+                                    <input type='text' name='title_es_<?php echo($i); ?>' id='title_es_<?php echo($i); ?>' onKeyUp='showNextRow(<?php echo($i); ?>'/>
+                                    <h4>Texto</h4>
+                                    <textarea name='text_es_<?php echo($i); ?>' id='text_es_<?php echo($i); ?>' onKeyUp='showNextRow(<?php echo($i); ?>);'/></textarea>
+                                </div>
+                                <div id="content_lang_eu" style="display:none;">
                                                                         <h4>Titulo</h4>
                                                                         <input type='text' name='title_eu_<?php echo($i); ?>' id='title_eu_<?php echo($i); ?>' onKeyUp='showNextRow(<?php echo($i); ?>'/>
                                                                         <h4>Textua</h4>
                                                                         <textarea name='text_eu_<?php echo($i); ?>' id='text_eu_<?php echo($i); ?>' onKeyUp='showNextRow(<?php echo($i); ?>);'/></textarea>
                                                                 </div>
-								<div id="content_lang_en" style="display:none;">
+                                <div id="content_lang_en" style="display:none;">
                                                                         <h4>Title</h4>
                                                                         <input type='text' name='title_en_<?php echo($i); ?>' id='title_en_<?php echo($i); ?>' onKeyUp='showNextRow(<?php echo($i); ?>'/>
                                                                         <h4>Content</h4>
                                                                         <textarea name='text_en_<?php echo($i); ?>' id='text_en_<?php echo($i); ?>' onKeyUp='showNextRow(<?php echo($i); ?>);'/></textarea>
                                                                 </div>
-								<?php
-									echo("</td>\n");
-									echo("</tr>\n");
-							}
-						?>
-					</table>
-					<input type='submit' id="save_itinerary"  value='Guardar'/>
-				</div> <!--Entry-->
-			</form>
-		</div>
-	</body>
+                                <?php
+                                    echo("</td>\n");
+                                    echo("</tr>\n");
+                            }
+                        ?>
+                    </table>
+                    <input type='submit' id="save_itinerary"  value='Guardar'/>
+                </div> <!--Entry-->
+            </form>
+        </div>
+    </body>
 </html>
 <?php } ?>

+ 167 - 167
www-admin/actividades/add/script.js

@@ -1,184 +1,184 @@
 function showTab(lang){
-	switch (lang){
-		case 'es':
-			document.getElementById('tab_content_es').style.display = 'inline-block';
-			document.getElementById('tab_content_eu').style.display = 'none';
-			document.getElementById('tab_content_en').style.display = 'none';
-			document.getElementById('tab_selector_es').style.color = '#000000';
-			document.getElementById('tab_selector_eu').style.color = '#8899bb';
-			document.getElementById('tab_selector_en').style.color = '#8899bb';
-			document.getElementById('tab_selector_es').style.zIndex = '3';
-			document.getElementById('tab_selector_eu').style.zIndex = '1';
-			document.getElementById('tab_selector_en').style.zIndex = '1';
-			document.getElementById('tab_selector_es').style.borderBottom = '0em solid #000000';
-			document.getElementById('tab_selector_eu').style.borderBottom = '0.1em solid #000000';
-			document.getElementById('tab_selector_en').style.borderBottom = '0.1em solid #000000';
-			break;
-		case 'eu':
-			document.getElementById('tab_content_es').style.display = 'none';
-			document.getElementById('tab_content_eu').style.display = 'inline-block';
-			document.getElementById('tab_content_en').style.display = 'none';
-			document.getElementById('tab_selector_es').style.color = '#8899bb';
-			document.getElementById('tab_selector_eu').style.color = '#000000';
-			document.getElementById('tab_selector_en').style.color = '#8899bb';
-			document.getElementById('tab_selector_es').style.zIndex = '1';
-			document.getElementById('tab_selector_eu').style.zIndex = '3';
-			document.getElementById('tab_selector_en').style.zIndex = '1';
-			document.getElementById('tab_selector_es').style.borderBottom = '0.1em solid #000000';
-			document.getElementById('tab_selector_eu').style.borderBottom = '0em solid #000000';
-			document.getElementById('tab_selector_en').style.borderBottom = '0.1em solid #000000';
-			break;
-		case 'en':
-			document.getElementById('tab_content_es').style.display = 'none';
-			document.getElementById('tab_content_eu').style.display = 'none';
-			document.getElementById('tab_content_en').style.display = 'inline-block';
-			document.getElementById('tab_selector_es').style.color = '#8899bb';
-			document.getElementById('tab_selector_eu').style.color = '#8899bb';
-			document.getElementById('tab_selector_en').style.color = '#000000';
-			document.getElementById('tab_selector_es').style.zIndex = '1';
-			document.getElementById('tab_selector_eu').style.zIndex = '1';
-			document.getElementById('tab_selector_en').style.zIndex = '3';
-			document.getElementById('tab_selector_es').style.borderBottom = '0.1em solid #000000';
-			document.getElementById('tab_selector_eu').style.borderBottom = '0.1em solid #000000';
-			document.getElementById('tab_selector_en').style.borderBottom = '0em solid #000000';
-			break;
-	}
+    switch (lang){
+        case 'es':
+            document.getElementById('tab_content_es').style.display = 'inline-block';
+            document.getElementById('tab_content_eu').style.display = 'none';
+            document.getElementById('tab_content_en').style.display = 'none';
+            document.getElementById('tab_selector_es').style.color = '#000000';
+            document.getElementById('tab_selector_eu').style.color = '#8899bb';
+            document.getElementById('tab_selector_en').style.color = '#8899bb';
+            document.getElementById('tab_selector_es').style.zIndex = '3';
+            document.getElementById('tab_selector_eu').style.zIndex = '1';
+            document.getElementById('tab_selector_en').style.zIndex = '1';
+            document.getElementById('tab_selector_es').style.borderBottom = '0em solid #000000';
+            document.getElementById('tab_selector_eu').style.borderBottom = '0.1em solid #000000';
+            document.getElementById('tab_selector_en').style.borderBottom = '0.1em solid #000000';
+            break;
+        case 'eu':
+            document.getElementById('tab_content_es').style.display = 'none';
+            document.getElementById('tab_content_eu').style.display = 'inline-block';
+            document.getElementById('tab_content_en').style.display = 'none';
+            document.getElementById('tab_selector_es').style.color = '#8899bb';
+            document.getElementById('tab_selector_eu').style.color = '#000000';
+            document.getElementById('tab_selector_en').style.color = '#8899bb';
+            document.getElementById('tab_selector_es').style.zIndex = '1';
+            document.getElementById('tab_selector_eu').style.zIndex = '3';
+            document.getElementById('tab_selector_en').style.zIndex = '1';
+            document.getElementById('tab_selector_es').style.borderBottom = '0.1em solid #000000';
+            document.getElementById('tab_selector_eu').style.borderBottom = '0em solid #000000';
+            document.getElementById('tab_selector_en').style.borderBottom = '0.1em solid #000000';
+            break;
+        case 'en':
+            document.getElementById('tab_content_es').style.display = 'none';
+            document.getElementById('tab_content_eu').style.display = 'none';
+            document.getElementById('tab_content_en').style.display = 'inline-block';
+            document.getElementById('tab_selector_es').style.color = '#8899bb';
+            document.getElementById('tab_selector_eu').style.color = '#8899bb';
+            document.getElementById('tab_selector_en').style.color = '#000000';
+            document.getElementById('tab_selector_es').style.zIndex = '1';
+            document.getElementById('tab_selector_eu').style.zIndex = '1';
+            document.getElementById('tab_selector_en').style.zIndex = '3';
+            document.getElementById('tab_selector_es').style.borderBottom = '0.1em solid #000000';
+            document.getElementById('tab_selector_eu').style.borderBottom = '0.1em solid #000000';
+            document.getElementById('tab_selector_en').style.borderBottom = '0em solid #000000';
+            break;
+    }
 }
 
 function validateActivity(){
-	var text_es = document.getElementById('text_es').value;
-	var text_eu = document.getElementById('text_eu').value;
-	var text_en = document.getElementById('text_en').value;
-	var title_es = document.getElementById('title_es').value;
-	var title_eu = document.getElementById('title_eu').value;
-	var title_en = document.getElementById('title_en').value;
-	result = true;
-	
-	//Spanish fields empty
-	if (title_es.length < 1){
-		result = false;
-		alert("Introduce un titulo en castellano");
-		return false;
-	}
-	if (text_es.length < 1){
-		result = false;
-		alert("Introduce un texto en castellano");
-		return false;
-	}
-	
-	//Titles without texts
-	if (title_eu.length > 0 && text_eu.length < 1){
-		result = false;
-		alert("Introduce un texto o borra el titulo en euskera")
-		return false;
-	}
-	if (title_en.length > 0 && text_en.length < 1){
-		result = false;
-		alert("Introduce un texto o borra el titulo en ingles")
-		return false;
-	}
-	
-	//Text without titles
-	if (text_eu.length > 0 && title_eu.length < 1){
-		result = false;
-		alert("Introduce un titulo o borra el texto en euskera")
-		return false;
-	}
-	if (text_en.length > 0 && title_en.length < 1){
-		result = false;
-		alert("Introduce un titulo o borra el texto en ingles")
-		return false;
-	}
-	
-	// TODO: check date
-	// TODO: check numeric fields price, people
-	return true;
+    var text_es = document.getElementById('text_es').value;
+    var text_eu = document.getElementById('text_eu').value;
+    var text_en = document.getElementById('text_en').value;
+    var title_es = document.getElementById('title_es').value;
+    var title_eu = document.getElementById('title_eu').value;
+    var title_en = document.getElementById('title_en').value;
+    result = true;
+    
+    //Spanish fields empty
+    if (title_es.length < 1){
+        result = false;
+        alert("Introduce un titulo en castellano");
+        return false;
+    }
+    if (text_es.length < 1){
+        result = false;
+        alert("Introduce un texto en castellano");
+        return false;
+    }
+    
+    //Titles without texts
+    if (title_eu.length > 0 && text_eu.length < 1){
+        result = false;
+        alert("Introduce un texto o borra el titulo en euskera")
+        return false;
+    }
+    if (title_en.length > 0 && text_en.length < 1){
+        result = false;
+        alert("Introduce un texto o borra el titulo en ingles")
+        return false;
+    }
+    
+    //Text without titles
+    if (text_eu.length > 0 && title_eu.length < 1){
+        result = false;
+        alert("Introduce un titulo o borra el texto en euskera")
+        return false;
+    }
+    if (text_en.length > 0 && title_en.length < 1){
+        result = false;
+        alert("Introduce un titulo o borra el texto en ingles")
+        return false;
+    }
+    
+    // TODO: check date
+    // TODO: check numeric fields price, people
+    return true;
 }
 
 
 
 function formatText(textarea, format){
-	
-	var text = textarea.value;
-	var selectedText= window.getSelection().toString();
-	event.preventDefault();
-	//IE
-	if (document.selection != undefined){
-		textarea.focus();
-		var selection = document.selection.createRange();
-		selectedText = selection.text;
-	}
-	
-	//Mozilla
-	else if (textarea.selectionStart != undefined){
-		var startPos = textarea.selectionStart;
-		var endPos = textarea.selectionEnd;
-		selectedText = textarea.value.substring(startPos, endPos);
-	}
-	
-	var replace;
-	switch (format){
-		case "italic":
-			replace = "<span style='font-style:italic;'>" + selectedText + "</span>";
-			break;
-		case "bold":
-			replace = "<span style='font-weight:bold;'>" + selectedText + "</span>";
-			break;
-		case "underline":
-			replace = "<span style='text-decoration:underline;'>" + selectedText + "</span>";
-			break;
-		case "stroke":
-			replace = "<span style='text-decoration:line-through;'>" + selectedText + "</span>";
-			break;
-		case "link":
-			replace = "<a href='" + selectedText + "'>" + selectedText + "</a>";
-			break;
-		case "color-red":
-			replace = "<span style='color:#f00;'>" + selectedText + "</span>";
-			break;
-		case "color-green":
-			replace = "<span style='color:#0f0;'>" + selectedText + "</span>";
-			break;
-		case "color-blue":
-			replace = "<span style='color:#00f;'>" + selectedText + "</span>";
-			break;
-		default:
-			replace = selectedText;
-	}
-	
-	if (selectedText.length  >0 && text != replace){
-		text = text.replace(selectedText, replace);
-		textarea.value = text;
-	}
+    
+    var text = textarea.value;
+    var selectedText= window.getSelection().toString();
+    event.preventDefault();
+    //IE
+    if (document.selection != undefined){
+        textarea.focus();
+        var selection = document.selection.createRange();
+        selectedText = selection.text;
+    }
+    
+    //Mozilla
+    else if (textarea.selectionStart != undefined){
+        var startPos = textarea.selectionStart;
+        var endPos = textarea.selectionEnd;
+        selectedText = textarea.value.substring(startPos, endPos);
+    }
+    
+    var replace;
+    switch (format){
+        case "italic":
+            replace = "<span style='font-style:italic;'>" + selectedText + "</span>";
+            break;
+        case "bold":
+            replace = "<span style='font-weight:bold;'>" + selectedText + "</span>";
+            break;
+        case "underline":
+            replace = "<span style='text-decoration:underline;'>" + selectedText + "</span>";
+            break;
+        case "stroke":
+            replace = "<span style='text-decoration:line-through;'>" + selectedText + "</span>";
+            break;
+        case "link":
+            replace = "<a href='" + selectedText + "'>" + selectedText + "</a>";
+            break;
+        case "color-red":
+            replace = "<span style='color:#f00;'>" + selectedText + "</span>";
+            break;
+        case "color-green":
+            replace = "<span style='color:#0f0;'>" + selectedText + "</span>";
+            break;
+        case "color-blue":
+            replace = "<span style='color:#00f;'>" + selectedText + "</span>";
+            break;
+        default:
+            replace = selectedText;
+    }
+    
+    if (selectedText.length  >0 && text != replace){
+        text = text.replace(selectedText, replace);
+        textarea.value = text;
+    }
 }
 
 function previewImage(source, target) {
-	var reader = new FileReader();
-	reader.readAsDataURL(source.files[0]);
+    var reader = new FileReader();
+    reader.readAsDataURL(source.files[0]);
 
-	reader.onload = function (reader_event) {
-		target.src = reader_event.target.result;
-		target.style.border = "2px solid black";
-		target.style.display = "inline";
-	};
+    reader.onload = function (reader_event) {
+        target.src = reader_event.target.result;
+        target.style.border = "2px solid black";
+        target.style.display = "inline";
+    };
 };
 
 function showNextRow(current){
-	if (document.getElementById('sh_' + current).value != '' ||
-		document.getElementById('eh_' + current).value != '' || 
-		document.getElementById('sm_' + current).value != '' || 
-		document.getElementById('em_' + current).value != '' || 
-		document.getElementById('place_' + current).value != -1 || 
-		document.getElementById('title_es_' + current).value != '' || 
-		document.getElementById('title_en_' + current).value != '' || 
-		document.getElementById('title_eu_' + current).value != '' || 
-		document.getElementById('text_es_' + current).value != '' || 
-		document.getElementById('text_en_' + current).value != '' || 
-		document.getElementById('text_eu_' + current).value != ''
-	){
-		document.getElementById('itinerary_row_' + (current + 1)).style.display = 'table-row';
-	}
-	else{
-		document.getElementById('itinerary_row_' + (current + 1)).style.display = 'none';
-	}
+    if (document.getElementById('sh_' + current).value != '' ||
+        document.getElementById('eh_' + current).value != '' || 
+        document.getElementById('sm_' + current).value != '' || 
+        document.getElementById('em_' + current).value != '' || 
+        document.getElementById('place_' + current).value != -1 || 
+        document.getElementById('title_es_' + current).value != '' || 
+        document.getElementById('title_en_' + current).value != '' || 
+        document.getElementById('title_eu_' + current).value != '' || 
+        document.getElementById('text_es_' + current).value != '' || 
+        document.getElementById('text_en_' + current).value != '' || 
+        document.getElementById('text_eu_' + current).value != ''
+    ){
+        document.getElementById('itinerary_row_' + (current + 1)).style.display = 'table-row';
+    }
+    else{
+        document.getElementById('itinerary_row_' + (current + 1)).style.display = 'none';
+    }
 }

+ 9 - 9
www-admin/actividades/delete/delete.php

@@ -1,11 +1,11 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
-	}
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+    }
 ?>

+ 9 - 9
www-admin/actividades/edit/edit.php

@@ -1,11 +1,11 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{?>
-	
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{?>
+    
 <?php } ?>

+ 23 - 23
www-admin/actividades/edit/index.php

@@ -1,27 +1,27 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{?>
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nuevo post - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nuevo post - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+    </body>
 </html>
 <?php } ?>

+ 100 - 100
www-admin/actividades/index.php

@@ -1,105 +1,105 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	$default_host = substr($http_host, 0, strpos($http_host, ':'));
-	include("../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
+    $http_host = $_SERVER['HTTP_HOST'];
+    $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    include("../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
 ?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Actividades - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/actividades.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/activiadades.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-		<?php include('../toolbar.php'); ?>
-		<div id='content'>
-			<div class="section">
-				<h3 class="section_title">Actividades - <a href="/actividades/add/">Anadir nueva</a></h3>
-				<div class="entry">
-					<table id='activity_list'>
-						<tr>
-							<th>Titulo / Fecha</th>
-							<th>Texto</th>
-							<th>Detalles</th>
-							<th>Traducciones</th>
-							<th>Accion</th>
-						</tr>
-						<?php
-							$q = mysqli_query($con, "SELECT id, DATE_FORMAT(date, '%b %d, %Y') AS dat, title_es, title_eu, title_en, text_es, text_eu, text_en, user, visible, comments, DATE_FORMAT(dtime, '%b %d, %Y %H:%i:%s') AS ptime FROM activity ORDER BY date DESC;");
-							while ($r = mysqli_fetch_array($q)){
-								echo "<tr>\n<td class='activity_column_title'>" . cutText($r['title_es'], 35, '', '') . "<br/>$r[dat]</td>";
-								echo "<td class='activity_column_text'>" . str_replace('<br/>', ' ', cutText($r['text_es'], 60, '', '')) . "\n";
-								
-								//Images
-								$q_image = mysqli_query($con, "SELECT image FROM activity_image WHERE activity = $r[id] ORDER BY idx;");
-								if (mysqli_num_rows($q_image) > 0){
-									echo "<br/>";
-									while ($r_image = mysqli_fetch_array($q_image))
-										echo "<img src='http://$default_host/img/actividades/miniature/$r_image[image]'\>\n";
-								}
-								
-								//Itinerary
-								$q_itinerary = mysqli_query($con, "SELECT count(id) AS count FROM activity_itinerary WHERE activity = $r[id]");
-								$r_itinerary = mysqli_fetch_array($q_itinerary);
-								if ($r_itinerary['count'] == 0){
-									echo("<ul><li>Sin itinerario.</li></ul>");
-								}
-								elseif ($r_itinerary['count'] == 1){
-									echo("<ul><li>1 entrada de itinerario.</li></ul>");
-								}
-								else{
-									echo("<ul><li>$r_itinerary[count] entradas de itinerario.</li></ul>");
-								}
-								
-								echo "</td>\n";
-								$q_user = mysqli_query($con, "SELECT username FROM user WHERE id = $r[user];");
-								$r_user = mysqli_fetch_array($q_user);
-								echo "<td class='activity_column_details'>$r[ptime]<br/>Por $r_user[username]<br/>Comentarios:";
-								if ($r['comments'] == 1){
-									$q_comments = mysqli_query($con, "SELECT id FROM activity_comment WHERE activity = $r[id];");
-									echo "Si (" . mysqli_num_rows($q_comments) . ")";
-								}
-								else
-									echo "No";
-								echo "<br/>Visible: ";
-								if ($r['visible'] == 1)
-									echo "Si";
-								else
-									echo "No";
-								echo "</td>\n<td class='activity_column_translations'>\nEuskera: ";
-								if (strlen($r['text_eu']) == 0 || $r['text_eu'] == $r['text_es'])
-									echo "No";
-								else
-									echo "Si";
-								echo "<br/>Ingl&eacute;s: ";
-									if (strlen($r['text_en']) == 0 || $r['text_en'] == $r['text_es'])
-									echo "No";
-								else
-									echo "Si";
-								echo "\n</td>\n<td class='activity_column_action'>\n<form action='/activity/edit/edit.php?p=$r[id]'>\n<input type='submit' value='Editar / Traducir'/>\n</form>\n";
-								echo "<input type='button' onClick='delete_activity($r[id], \"$r[title_es]\");' value='Borrar'/>";
-								echo "<form action='/activity/moderate/moderate.php?p=$r[id]'>\n<input type='submit' value='Moderar comentarios'/>\n</form>";
-								echo "</td>\n</tr>";
-							}
-							
-						?>
-					</table>
-				</div>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Actividades - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/actividades.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/activiadades.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+        <?php include('../toolbar.php'); ?>
+        <div id='content'>
+            <div class="section">
+                <h3 class="section_title">Actividades - <a href="/actividades/add/">Anadir nueva</a></h3>
+                <div class="entry">
+                    <table id='activity_list'>
+                        <tr>
+                            <th>Titulo / Fecha</th>
+                            <th>Texto</th>
+                            <th>Detalles</th>
+                            <th>Traducciones</th>
+                            <th>Accion</th>
+                        </tr>
+                        <?php
+                            $q = mysqli_query($con, "SELECT id, DATE_FORMAT(date, '%b %d, %Y') AS dat, title_es, title_eu, title_en, text_es, text_eu, text_en, user, visible, comments, DATE_FORMAT(dtime, '%b %d, %Y %H:%i:%s') AS ptime FROM activity ORDER BY date DESC;");
+                            while ($r = mysqli_fetch_array($q)){
+                                echo "<tr>\n<td class='activity_column_title'>" . cutText($r['title_es'], 35, '', '') . "<br/>$r[dat]</td>";
+                                echo "<td class='activity_column_text'>" . str_replace('<br/>', ' ', cutText($r['text_es'], 60, '', '')) . "\n";
+                                
+                                //Images
+                                $q_image = mysqli_query($con, "SELECT image FROM activity_image WHERE activity = $r[id] ORDER BY idx;");
+                                if (mysqli_num_rows($q_image) > 0){
+                                    echo "<br/>";
+                                    while ($r_image = mysqli_fetch_array($q_image))
+                                        echo "<img src='http://$default_host/img/actividades/miniature/$r_image[image]'\>\n";
+                                }
+                                
+                                //Itinerary
+                                $q_itinerary = mysqli_query($con, "SELECT count(id) AS count FROM activity_itinerary WHERE activity = $r[id]");
+                                $r_itinerary = mysqli_fetch_array($q_itinerary);
+                                if ($r_itinerary['count'] == 0){
+                                    echo("<ul><li>Sin itinerario.</li></ul>");
+                                }
+                                elseif ($r_itinerary['count'] == 1){
+                                    echo("<ul><li>1 entrada de itinerario.</li></ul>");
+                                }
+                                else{
+                                    echo("<ul><li>$r_itinerary[count] entradas de itinerario.</li></ul>");
+                                }
+                                
+                                echo "</td>\n";
+                                $q_user = mysqli_query($con, "SELECT username FROM user WHERE id = $r[user];");
+                                $r_user = mysqli_fetch_array($q_user);
+                                echo "<td class='activity_column_details'>$r[ptime]<br/>Por $r_user[username]<br/>Comentarios:";
+                                if ($r['comments'] == 1){
+                                    $q_comments = mysqli_query($con, "SELECT id FROM activity_comment WHERE activity = $r[id];");
+                                    echo "Si (" . mysqli_num_rows($q_comments) . ")";
+                                }
+                                else
+                                    echo "No";
+                                echo "<br/>Visible: ";
+                                if ($r['visible'] == 1)
+                                    echo "Si";
+                                else
+                                    echo "No";
+                                echo "</td>\n<td class='activity_column_translations'>\nEuskera: ";
+                                if (strlen($r['text_eu']) == 0 || $r['text_eu'] == $r['text_es'])
+                                    echo "No";
+                                else
+                                    echo "Si";
+                                echo "<br/>Ingl&eacute;s: ";
+                                    if (strlen($r['text_en']) == 0 || $r['text_en'] == $r['text_es'])
+                                    echo "No";
+                                else
+                                    echo "Si";
+                                echo "\n</td>\n<td class='activity_column_action'>\n<form action='/activity/edit/edit.php?p=$r[id]'>\n<input type='submit' value='Editar / Traducir'/>\n</form>\n";
+                                echo "<input type='button' onClick='delete_activity($r[id], \"$r[title_es]\");' value='Borrar'/>";
+                                echo "<form action='/activity/moderate/moderate.php?p=$r[id]'>\n<input type='submit' value='Moderar comentarios'/>\n</form>";
+                                echo "</td>\n</tr>";
+                            }
+                            
+                        ?>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </body>
 </html>
 <?php } ?>

+ 25 - 25
www-admin/actividades/moderate/index.php

@@ -1,36 +1,36 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{ ?>
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{ ?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Moderar comentarios - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="script.js"></script>
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-		<?php include('../../toolbar.php'); ?>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Moderar comentarios - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+        <?php include('../../toolbar.php'); ?>
                 <div id='content'>
                         <div class="section">
                                 <h3 class="section_title">Moderar comentarios</h3>
                                 <h4 span class="TODO">En construcci&oacute;n</h4>
                         </div>
                 </div>
-	</body>
+    </body>
 </html>
 
 <?php } ?>

+ 76 - 76
www-admin/actividades/translate/apply.php

@@ -1,78 +1,78 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb('rw');
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	//Get activity fields
-	$id = mysqli_real_escape_string($con, $_POST['id']);
-	$title_en = mysqli_real_escape_string($con, $_POST['title_en']);
-	$text_en = mysqli_real_escape_string($con, $_POST['text_en']);
-	$after_en = mysqli_real_escape_string($con, $_POST['after_en']);
-	$title_eu = mysqli_real_escape_string($con, $_POST['title_eu']);
-	$text_eu = mysqli_real_escape_string($con, $_POST['text_eu']);
-	$after_eu = mysqli_real_escape_string($con, $_POST['after_eu']);
-	
-	//Get activity_itinerary fields
-	$q_i = mysqli_query($con, "SELECT * FROM activity_itinerary WHERE activity = $id;");
-	$i = 0;
-	$total_i = 0;
-	while ($r_i = mysqli_fetch_array($q_i)){
-		$i_id[$i] = $r_i['id'];
-		$i_name_en[$i] = mysqli_real_escape_string($con, $_POST['it_' . $i_id[$i] . '_name_en']);
-		$i_desc_en[$i] = mysqli_real_escape_string($con, $_POST['it_' . $i_id[$i] . '_desc_en']);
-		$i_name_eu[$i] = mysqli_real_escape_string($con, $_POST['it_' . $i_id[$i] . '_name_eu']);
-		$i_desc_eu[$i] = mysqli_real_escape_string($con, $_POST['it_' . $i_id[$i] . '_desc_eu']);
-		$i ++;
-		$total_i ++;
-	}
-	
-	//Get current activity data
-	$q = mysqli_query($con, "SELECT * FROM activity WHERE id = $id");
-	if (mysqli_num_rows($q) > 0){
-		$r = mysqli_fetch_array($q);
-		
-		//Update activity fields
-		if (strlen($title_en) > 0 && $title_en != $r['title_en']){
-			mysqli_query($con, "UPDATE activity SET title_en = '$title_en' WHERE id = $id;");
-		}
-		if (strlen($text_en) > 0 && $text_en != $r['text_en']){
-			mysqli_query($con, "UPDATE activity SET text_en = '$text_en' WHERE id = $id;");
-		}
-		if (strlen($after_en) > 0 && $after_en != $r['after_en']){
-			mysqli_query($con, "UPDATE activity SET after_en = '$after_en' WHERE id = $id;");
-		}
-		if (strlen($title_eu) > 0 && $title_eu != $r['title_eu']){
-			mysqli_query($con, "UPDATE activity SET title_eu = '$title_eu' WHERE id = $id;");
-		}
-		if (strlen($text_eu) > 0 && $text_eu != $r['text_eu']){
-			mysqli_query($con, "UPDATE activity SET text_eu = '$text_eu' WHERE id = $id;");
-		}
-		if (strlen($after_eu) > 0 && $after_eu != $r['after_eu']){
-			mysqli_query($con, "UPDATE activity SET after_eu = '$after_eu' WHERE id = $id;");
-		}
-	}
-	
-	//Update itinerary entries
-	for ($i = 0; $i < $total_i; $i ++){
-		$q_i = mysqli_query($con, "SELECT * FROM activity_itinerary WHERE activity = $id AND id = $i_id[$i];");
-		if (mysqli_num_rows($q_i) > 0){
-			$r_i = mysqli_fetch_array($q_i);
-			if (strlen($i_name_en[$i]) > 0 && $i_name_en[$i] != $r_i['name_en']){
-				mysqli_query($con, "UPDATE activity_itinerary SET name_en = '$i_name_en[$i]' WHERE id = $i_id[$i];");
-			}
-			if (strlen($i_desc_en[$i]) > 0 && $i_desc_en[$i] != $r_i['description_en']){
-				mysqli_query($con, "UPDATE activity_itinerary SET description_en = '$i_desc_en[$i]' WHERE id = $i_id[$i];");
-			}
-			if (strlen($i_name_eu[$i]) > 0 && $i_name_eu[$i] != $r_i['name_eu']){
-				mysqli_query($con, "UPDATE activity_itinerary SET name_eu = '$i_name_eu[$i]' WHERE id = $i_id[$i];");
-			}
-			if (strlen($i_desc_eu[$i]) > 0 && $i_desc_eu[$i] != $r_i['description_eu']){
-				mysqli_query($con, "UPDATE activity_itinerary SET description_eu = '$i_desc_eu[$i]' WHERE id = $i_id[$i];");
-			}
-		}
-	}
-	header("Location: /actividades/translate/index.php");	
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb('rw');
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    //Get activity fields
+    $id = mysqli_real_escape_string($con, $_POST['id']);
+    $title_en = mysqli_real_escape_string($con, $_POST['title_en']);
+    $text_en = mysqli_real_escape_string($con, $_POST['text_en']);
+    $after_en = mysqli_real_escape_string($con, $_POST['after_en']);
+    $title_eu = mysqli_real_escape_string($con, $_POST['title_eu']);
+    $text_eu = mysqli_real_escape_string($con, $_POST['text_eu']);
+    $after_eu = mysqli_real_escape_string($con, $_POST['after_eu']);
+    
+    //Get activity_itinerary fields
+    $q_i = mysqli_query($con, "SELECT * FROM activity_itinerary WHERE activity = $id;");
+    $i = 0;
+    $total_i = 0;
+    while ($r_i = mysqli_fetch_array($q_i)){
+        $i_id[$i] = $r_i['id'];
+        $i_name_en[$i] = mysqli_real_escape_string($con, $_POST['it_' . $i_id[$i] . '_name_en']);
+        $i_desc_en[$i] = mysqli_real_escape_string($con, $_POST['it_' . $i_id[$i] . '_desc_en']);
+        $i_name_eu[$i] = mysqli_real_escape_string($con, $_POST['it_' . $i_id[$i] . '_name_eu']);
+        $i_desc_eu[$i] = mysqli_real_escape_string($con, $_POST['it_' . $i_id[$i] . '_desc_eu']);
+        $i ++;
+        $total_i ++;
+    }
+    
+    //Get current activity data
+    $q = mysqli_query($con, "SELECT * FROM activity WHERE id = $id");
+    if (mysqli_num_rows($q) > 0){
+        $r = mysqli_fetch_array($q);
+        
+        //Update activity fields
+        if (strlen($title_en) > 0 && $title_en != $r['title_en']){
+            mysqli_query($con, "UPDATE activity SET title_en = '$title_en' WHERE id = $id;");
+        }
+        if (strlen($text_en) > 0 && $text_en != $r['text_en']){
+            mysqli_query($con, "UPDATE activity SET text_en = '$text_en' WHERE id = $id;");
+        }
+        if (strlen($after_en) > 0 && $after_en != $r['after_en']){
+            mysqli_query($con, "UPDATE activity SET after_en = '$after_en' WHERE id = $id;");
+        }
+        if (strlen($title_eu) > 0 && $title_eu != $r['title_eu']){
+            mysqli_query($con, "UPDATE activity SET title_eu = '$title_eu' WHERE id = $id;");
+        }
+        if (strlen($text_eu) > 0 && $text_eu != $r['text_eu']){
+            mysqli_query($con, "UPDATE activity SET text_eu = '$text_eu' WHERE id = $id;");
+        }
+        if (strlen($after_eu) > 0 && $after_eu != $r['after_eu']){
+            mysqli_query($con, "UPDATE activity SET after_eu = '$after_eu' WHERE id = $id;");
+        }
+    }
+    
+    //Update itinerary entries
+    for ($i = 0; $i < $total_i; $i ++){
+        $q_i = mysqli_query($con, "SELECT * FROM activity_itinerary WHERE activity = $id AND id = $i_id[$i];");
+        if (mysqli_num_rows($q_i) > 0){
+            $r_i = mysqli_fetch_array($q_i);
+            if (strlen($i_name_en[$i]) > 0 && $i_name_en[$i] != $r_i['name_en']){
+                mysqli_query($con, "UPDATE activity_itinerary SET name_en = '$i_name_en[$i]' WHERE id = $i_id[$i];");
+            }
+            if (strlen($i_desc_en[$i]) > 0 && $i_desc_en[$i] != $r_i['description_en']){
+                mysqli_query($con, "UPDATE activity_itinerary SET description_en = '$i_desc_en[$i]' WHERE id = $i_id[$i];");
+            }
+            if (strlen($i_name_eu[$i]) > 0 && $i_name_eu[$i] != $r_i['name_eu']){
+                mysqli_query($con, "UPDATE activity_itinerary SET name_eu = '$i_name_eu[$i]' WHERE id = $i_id[$i];");
+            }
+            if (strlen($i_desc_eu[$i]) > 0 && $i_desc_eu[$i] != $r_i['description_eu']){
+                mysqli_query($con, "UPDATE activity_itinerary SET description_eu = '$i_desc_eu[$i]' WHERE id = $i_id[$i];");
+            }
+        }
+    }
+    header("Location: /actividades/translate/index.php");    
 ?>

+ 88 - 88
www-admin/actividades/translate/index.php

@@ -1,92 +1,92 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{?>
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Taducir actividades - Administraci&oacute;n</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/actividades.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/actividades.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-		<?php include('../../toolbar.php'); ?>
-		<div id='content'>
-			<div class='section'>
-				<h3>Lista de actividades</h3>
-				<div class='entry'>
-					<?php
-						$q = mysqli_query($con, "SELECT id, title_es, title_eu, title_en, text_es, text_en, text_eu, DATE_FORMAT(date, '%b %d, %Y') AS dat FROM activity ORDER BY date;");
-						echo "<table class='translation_table'><tr><th>Nombre</th><th>Fecha</th><th>Ingles</th><th>Euskera</th></tr>\n";
-						while ($r = mysqli_fetch_array($q)){
-							echo "<tr><td><a href='http://$http_host/actividades/translate/translate.php?id=$r[id]'>$r[title_es]</a></td>";
-							echo("<td>$r[dat]</td>");
-							$total = 2; //Title and text are mandatory
-							$translated_en = 0;
-							$translated_eu = 0;
-							
-							//Calculate field number
-							if ($r['title_en'] != $r['title_es']){
-								$translated_en ++;
-							}
-							if ($r['title_eu'] != $r['title_es']){
-								$translated_eu ++;
-							}
-							if ($r['text_en'] != $r['text_es']){
-								$translated_en ++;
-							}
-							if ($r['text_eu'] != $r['text_es']){
-								$translated_eu ++;
-							}
-							if (strlen($r['after_es']) > 0){
-								$total ++;
-								if ($r['after_en'] != $r['after_es']){
-									$translated_en ++;
-								}
-								if ($r['after_eu'] != $r['after_es']){
-									$translated_eu ++;
-								}
-							}
-							$q_i = mysqli_query($con, "SELECT * FROM activity_itinerary WHERE activity = $r[id]");
-							while ($r_i = mysqli_fetch_array($q_i)){
-								$total ++;
-								if ($r_i['title_en'] != $r_i['title_es']){
-									$translated_en ++;
-								}
-								if ($r_i['title_eu'] != $r_i['title_es']){
-									$translated_eu ++;
-								}
-								if (strlen($r_i['description_es']) > 0){
-									$total ++;
-									if ($r_i['description_en'] != $r_i['description_es']){
-										$translated_en ++;
-									}
-									if ($r_i['description_eu'] != $r_i['description_es']){
-										$translated_eu ++;
-									}
-								}
-							}
-							
-							//Calculate percents
-							echo "<td>" . intval($translated_en * 100 / $total) . "%</td><td>" . intval($translated_eu * 100 / $total) . "%</td></tr>\n";
-						}
-						echo "</table>\n";
-					?>
-				</div>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Taducir actividades - Administraci&oacute;n</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/actividades.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/actividades.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+        <?php include('../../toolbar.php'); ?>
+        <div id='content'>
+            <div class='section'>
+                <h3>Lista de actividades</h3>
+                <div class='entry'>
+                    <?php
+                        $q = mysqli_query($con, "SELECT id, title_es, title_eu, title_en, text_es, text_en, text_eu, DATE_FORMAT(date, '%b %d, %Y') AS dat FROM activity ORDER BY date;");
+                        echo "<table class='translation_table'><tr><th>Nombre</th><th>Fecha</th><th>Ingles</th><th>Euskera</th></tr>\n";
+                        while ($r = mysqli_fetch_array($q)){
+                            echo "<tr><td><a href='http://$http_host/actividades/translate/translate.php?id=$r[id]'>$r[title_es]</a></td>";
+                            echo("<td>$r[dat]</td>");
+                            $total = 2; //Title and text are mandatory
+                            $translated_en = 0;
+                            $translated_eu = 0;
+                            
+                            //Calculate field number
+                            if ($r['title_en'] != $r['title_es']){
+                                $translated_en ++;
+                            }
+                            if ($r['title_eu'] != $r['title_es']){
+                                $translated_eu ++;
+                            }
+                            if ($r['text_en'] != $r['text_es']){
+                                $translated_en ++;
+                            }
+                            if ($r['text_eu'] != $r['text_es']){
+                                $translated_eu ++;
+                            }
+                            if (strlen($r['after_es']) > 0){
+                                $total ++;
+                                if ($r['after_en'] != $r['after_es']){
+                                    $translated_en ++;
+                                }
+                                if ($r['after_eu'] != $r['after_es']){
+                                    $translated_eu ++;
+                                }
+                            }
+                            $q_i = mysqli_query($con, "SELECT * FROM activity_itinerary WHERE activity = $r[id]");
+                            while ($r_i = mysqli_fetch_array($q_i)){
+                                $total ++;
+                                if ($r_i['title_en'] != $r_i['title_es']){
+                                    $translated_en ++;
+                                }
+                                if ($r_i['title_eu'] != $r_i['title_es']){
+                                    $translated_eu ++;
+                                }
+                                if (strlen($r_i['description_es']) > 0){
+                                    $total ++;
+                                    if ($r_i['description_en'] != $r_i['description_es']){
+                                        $translated_en ++;
+                                    }
+                                    if ($r_i['description_eu'] != $r_i['description_es']){
+                                        $translated_eu ++;
+                                    }
+                                }
+                            }
+                            
+                            //Calculate percents
+                            echo "<td>" . intval($translated_en * 100 / $total) . "%</td><td>" . intval($translated_eu * 100 / $total) . "%</td></tr>\n";
+                        }
+                        echo "</table>\n";
+                    ?>
+                </div>
+            </div>
+        </div>
+    </body>
 </html>
 <?php } ?>

+ 105 - 105
www-admin/actividades/translate/translate.php

@@ -1,109 +1,109 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
-		$id = mysqli_real_escape_string($con, $_GET['id']);
-		$q = mysqli_query($con, "SELECT * FROM activity WHERE id = $id");
-		if(mysqli_num_rows($q) == 0){
-			header("Location: $http_host/actividades/translate/");
-			exit (-1);
-		}
-		else{
-			$r = mysqli_fetch_array($q);
-	?>
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+        $id = mysqli_real_escape_string($con, $_GET['id']);
+        $q = mysqli_query($con, "SELECT * FROM activity WHERE id = $id");
+        if(mysqli_num_rows($q) == 0){
+            header("Location: $http_host/actividades/translate/");
+            exit (-1);
+        }
+        else{
+            $r = mysqli_fetch_array($q);
+    ?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Traducir <?php echo $r['title_es']; ?> - Administraci&oacute;n</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/actividades.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/actividades.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="script.js"></script>
-		<script type="text/javascript" src="/script/ui.js"></script>
-		<script src="../../ckeditor/ckeditor.js"></script>
-	</head>
-	<body>
-		<?php include('../../toolbar.php'); ?>
-		<div id='content'>
-			<div class='section'>
-				<?php
-					echo "<h3>Taducir &#8216;$r[title_es]&#8217;</h3>\n";
-					echo "<div id='translation_instructions' class='entry'><h4>C&oacute;mo traducir</h4>\n";
-					echo "<ul><li>Rellena los campos de abajo para el idioma correspondiente (columna de en medio para ingl&eacute;s, derecha para euskera)</li>\n";
-					echo "<li>No es necesario traducir todos los campos ni todos los idiomas. Traduce solo lo que sepas y quieras.</li>\n";
-					echo "<li>Al terminar, recuerda pulsar el boton &#8216;Guardar&#8217; al final de la p&acute;gina.</li>\n";
-					echo "<li>Muchas gracias por tu trabajo!</li></ul>\n";
-					echo "</div><br/><br/>\n";
-					echo "<form method='post' action='http://$http_host/actividades/translate/apply.php'>\n";
-					echo "<input type='hidden' name='id' value='$r[id]'/>\n";
-					
-					echo "<table id='table_translate_languages'><tr>\n";
-					echo "<td class='translate_language'><div class='entry translation'>\n";
-					echo "<h3>Castellano</h4><div class='translate_row_title'>\n<span class='bold'>T&iacute;tulo: </span>$r[title_es]</div>\n";
-					echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><p>$r[text_es]</p></div>\n";
-					if (strlen($r['after_es']) > 0){
-						echo "<div class='translate_row_after'><span class='bold'>Texto para despu&eacute;s</span><br/><p>$r[after_es]</p></div>\n";
-					}
-					$q_i = mysqli_query($con, "SELECT id, name_es, name_en, name_eu, description_es, description_en, description_eu, date_format(start, '%H:%i') AS start FROM activity_itinerary WHERE activity = $r[id];");
-					if (mysqli_num_rows($q_i) > 0){
-						echo "<div class='translate_row_itinerary'><span class='bold'>Itinerario<br/></span><table id='table_translate_itinerary'>\n";
-						while ($r_i = mysqli_fetch_array($q_i)){
-							echo "<tr><td>$r_i[start]</td><td>&nbsp;&nbsp;$r_i[name_es]&nbsp;&nbsp;</td><td>&nbsp;&nbsp;$r_i[description_es]&nbsp;&nbsp;</td></tr>\n";
-						}
-						echo "</table></div>\n";
-					}
-					echo "</div></td>\n";
-					
-					echo "<td class='translate_language'><div class='entry translation'>\n";
-					echo "<h3>Ingl&eacute;s</h4><div class='translate_row_title'>\n<span class='bold'>T&iacute;tulo: </span><input required type='text' name='title_en' required value='$r[title_en]'/></div>\n";
-					echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><textarea name='text_en' required>$r[text_en]</textarea></div>\n";
-					echo "<script>CKEDITOR.replace('text_en');</script>\n";
-					if (strlen($r['after_es']) > 0){
-						echo "<div class='translate_row_after'><span class='bold'>Texto para despu&eacute;s</span><br/><textarea name='after_en' required>$r[after_en]</textarea></div>\n";
-						echo "<script>CKEDITOR.replace('after_en');</script>\n";
-					}
-					$q_i = mysqli_query($con, "SELECT id, name_es, name_en, name_en, description_es, description_en, description_en, date_format(start, '%H:%i') AS start FROM activity_itinerary WHERE activity = $r[id];");
-					if (mysqli_num_rows($q_i) > 0){
-						echo "<div class='translate_row_itinerary'><span class='bold'>Itinerario<br/></span><table id='table_translate_itinerary'>\n";
-						while ($r_i = mysqli_fetch_array($q_i)){
-							echo "<tr><td>$r_i[start]</td><td><input type='text' name='it_$r_i[id]_name_en' required value='$r_i[name_en]'/></td><td><textarea name='it_$r_i[id]_desc_en' required>$r_i[description_en]</textarea></td></tr>\n";
-						}
-						echo "</table></div>\n";
-					}
-					echo "</div></td>\n";
-					
-					echo "<td class='translate_language'><div class='entry translation'>\n";
-					echo "<h3>Euskera</h4><div class='translate_row_title'>\n<span class='bold'>T&iacute;tulo: </span><input required type='text' name='title_eu' required value='$r[title_eu]'/></div>\n";
-					echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><textarea name='text_eu' required>$r[text_eu]</textarea></div>\n";
-					echo "<script>CKEDITOR.replace('text_eu');</script>\n";
-					if (strlen($r['after_es']) > 0){
-						echo "<div class='translate_row_after'><span class='bold'>Texto para despu&eacute;s</span><br/><textarea name='after_eu' required>$r[after_eu]</textarea></div>\n";
-						echo "<script>CKEDITOR.replace('after_eu');</script>\n";
-					}
-					$q_i = mysqli_query($con, "SELECT id, name_es, name_eu, name_eu, description_es, description_eu, description_eu, date_format(start, '%H:%i') AS start FROM activity_itinerary WHERE activity = $r[id];");
-					if (mysqli_num_rows($q_i) > 0){
-						echo "<div class='translate_row_itinerary'><span class='bold'>Itinerario<br/></span><table id='table_translate_itinerary'>\n";
-						while ($r_i = mysqli_fetch_array($q_i)){
-							echo "<tr><td>$r_i[start]</td><td><input type='text' name='it_$r_i[id]_name_eu' required value='$r_i[name_eu]'/></td><td><textarea name='it_$r_i[id]_desc_eu' required>$r_i[description_eu]</textarea></td></tr>\n";
-						}
-						echo "</table></div>\n";
-					}
-					echo "</div></td>\n";
-										
-					echo "</tr></table><div id='translate_controls'><input type='submit' value='Guardar'/><input type='button' value='Cancelar y salir' onClick='exitTranslation();'/></div></form>\n";
-				?>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Traducir <?php echo $r['title_es']; ?> - Administraci&oacute;n</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/actividades.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/actividades.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+        <script type="text/javascript" src="/script/ui.js"></script>
+        <script src="../../ckeditor/ckeditor.js"></script>
+    </head>
+    <body>
+        <?php include('../../toolbar.php'); ?>
+        <div id='content'>
+            <div class='section'>
+                <?php
+                    echo "<h3>Taducir &#8216;$r[title_es]&#8217;</h3>\n";
+                    echo "<div id='translation_instructions' class='entry'><h4>C&oacute;mo traducir</h4>\n";
+                    echo "<ul><li>Rellena los campos de abajo para el idioma correspondiente (columna de en medio para ingl&eacute;s, derecha para euskera)</li>\n";
+                    echo "<li>No es necesario traducir todos los campos ni todos los idiomas. Traduce solo lo que sepas y quieras.</li>\n";
+                    echo "<li>Al terminar, recuerda pulsar el boton &#8216;Guardar&#8217; al final de la p&acute;gina.</li>\n";
+                    echo "<li>Muchas gracias por tu trabajo!</li></ul>\n";
+                    echo "</div><br/><br/>\n";
+                    echo "<form method='post' action='http://$http_host/actividades/translate/apply.php'>\n";
+                    echo "<input type='hidden' name='id' value='$r[id]'/>\n";
+                    
+                    echo "<table id='table_translate_languages'><tr>\n";
+                    echo "<td class='translate_language'><div class='entry translation'>\n";
+                    echo "<h3>Castellano</h4><div class='translate_row_title'>\n<span class='bold'>T&iacute;tulo: </span>$r[title_es]</div>\n";
+                    echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><p>$r[text_es]</p></div>\n";
+                    if (strlen($r['after_es']) > 0){
+                        echo "<div class='translate_row_after'><span class='bold'>Texto para despu&eacute;s</span><br/><p>$r[after_es]</p></div>\n";
+                    }
+                    $q_i = mysqli_query($con, "SELECT id, name_es, name_en, name_eu, description_es, description_en, description_eu, date_format(start, '%H:%i') AS start FROM activity_itinerary WHERE activity = $r[id];");
+                    if (mysqli_num_rows($q_i) > 0){
+                        echo "<div class='translate_row_itinerary'><span class='bold'>Itinerario<br/></span><table id='table_translate_itinerary'>\n";
+                        while ($r_i = mysqli_fetch_array($q_i)){
+                            echo "<tr><td>$r_i[start]</td><td>&nbsp;&nbsp;$r_i[name_es]&nbsp;&nbsp;</td><td>&nbsp;&nbsp;$r_i[description_es]&nbsp;&nbsp;</td></tr>\n";
+                        }
+                        echo "</table></div>\n";
+                    }
+                    echo "</div></td>\n";
+                    
+                    echo "<td class='translate_language'><div class='entry translation'>\n";
+                    echo "<h3>Ingl&eacute;s</h4><div class='translate_row_title'>\n<span class='bold'>T&iacute;tulo: </span><input required type='text' name='title_en' required value='$r[title_en]'/></div>\n";
+                    echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><textarea name='text_en' required>$r[text_en]</textarea></div>\n";
+                    echo "<script>CKEDITOR.replace('text_en');</script>\n";
+                    if (strlen($r['after_es']) > 0){
+                        echo "<div class='translate_row_after'><span class='bold'>Texto para despu&eacute;s</span><br/><textarea name='after_en' required>$r[after_en]</textarea></div>\n";
+                        echo "<script>CKEDITOR.replace('after_en');</script>\n";
+                    }
+                    $q_i = mysqli_query($con, "SELECT id, name_es, name_en, name_en, description_es, description_en, description_en, date_format(start, '%H:%i') AS start FROM activity_itinerary WHERE activity = $r[id];");
+                    if (mysqli_num_rows($q_i) > 0){
+                        echo "<div class='translate_row_itinerary'><span class='bold'>Itinerario<br/></span><table id='table_translate_itinerary'>\n";
+                        while ($r_i = mysqli_fetch_array($q_i)){
+                            echo "<tr><td>$r_i[start]</td><td><input type='text' name='it_$r_i[id]_name_en' required value='$r_i[name_en]'/></td><td><textarea name='it_$r_i[id]_desc_en' required>$r_i[description_en]</textarea></td></tr>\n";
+                        }
+                        echo "</table></div>\n";
+                    }
+                    echo "</div></td>\n";
+                    
+                    echo "<td class='translate_language'><div class='entry translation'>\n";
+                    echo "<h3>Euskera</h4><div class='translate_row_title'>\n<span class='bold'>T&iacute;tulo: </span><input required type='text' name='title_eu' required value='$r[title_eu]'/></div>\n";
+                    echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><textarea name='text_eu' required>$r[text_eu]</textarea></div>\n";
+                    echo "<script>CKEDITOR.replace('text_eu');</script>\n";
+                    if (strlen($r['after_es']) > 0){
+                        echo "<div class='translate_row_after'><span class='bold'>Texto para despu&eacute;s</span><br/><textarea name='after_eu' required>$r[after_eu]</textarea></div>\n";
+                        echo "<script>CKEDITOR.replace('after_eu');</script>\n";
+                    }
+                    $q_i = mysqli_query($con, "SELECT id, name_es, name_eu, name_eu, description_es, description_eu, description_eu, date_format(start, '%H:%i') AS start FROM activity_itinerary WHERE activity = $r[id];");
+                    if (mysqli_num_rows($q_i) > 0){
+                        echo "<div class='translate_row_itinerary'><span class='bold'>Itinerario<br/></span><table id='table_translate_itinerary'>\n";
+                        while ($r_i = mysqli_fetch_array($q_i)){
+                            echo "<tr><td>$r_i[start]</td><td><input type='text' name='it_$r_i[id]_name_eu' required value='$r_i[name_eu]'/></td><td><textarea name='it_$r_i[id]_desc_eu' required>$r_i[description_eu]</textarea></td></tr>\n";
+                        }
+                        echo "</table></div>\n";
+                    }
+                    echo "</div></td>\n";
+                                        
+                    echo "</tr></table><div id='translate_controls'><input type='submit' value='Guardar'/><input type='button' value='Cancelar y salir' onClick='exitTranslation();'/></div></form>\n";
+                ?>
+            </div>
+        </div>
+    </body>
 </html>
 <?php } } ?>

+ 0 - 0
www-admin/ajustes/settings.php → www-admin/ajustes/guardar.php


+ 58 - 1
www-admin/ajustes/index.php

@@ -1 +1,58 @@
- 
+<?php
+    $server = get_protocol() . $_SERVER['HTTP_HOST'];
+    $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    include("../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+?>
+<html>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Ajustes - Gasteizko Margolariak - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/settings.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/settings.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="/script/ui.js"></script>
+        <script type="text/javascript">
+            function saveSetting(name, value){
+                // TODO: Call guardar.php
+            }
+        </script>
+    </head>
+    <body>
+        <?php include('../toolbar.php'); ?>
+        <div id='content'>
+            <div class='section'>
+                <h3 class='section_title'>Ajustes</h3>
+                <div class='entry'>
+                    Permitir que los visitantes comenten anonimamente...
+                    <br/>&nbsp;&nbsp;&nbsp;&nbsp;
+                    <label><input type="checkbox" name="comment_blog" value="value">... en el blog</label>
+                    <br/>&nbsp;&nbsp;&nbsp;&nbsp;
+                    <label><input type="checkbox" name="comment_activities" value="value">... en las actividades</label>
+                    <br/>&nbsp;&nbsp;&nbsp;&nbsp;
+                    <label><input type="checkbox" name="comment_gallery" value="value">... en la galer&iacute;a</label>
+                    <br/><br/>
+                    <label>
+                        <input type="checkbox" name="upload_gallery" value="value">
+                        Permitir que los usuarios contribuyan a los albums con sus fotos (puede restringirse por album)
+                    </label>
+                    <label>
+                        <input type="checkbox" name="festivals" value="value">
+                        Usar disseño para fiestas de Vitoria.
+                    </label>
+                </div>
+            </div>
+        </div>
+    </body>
+</html>
+<?php } ?>

+ 129 - 129
www-admin/blog/add/add.php

@@ -1,131 +1,131 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb('rw');
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
-		
-		//Get POST data
-		$title_es = mysqli_real_escape_string($con, $_POST['title_es']);
-		$title_eu = mysqli_real_escape_string($con, $_POST['title_eu']);
-		$title_en = mysqli_real_escape_string($con, $_POST['title_en']);
-		$text_es = mysqli_real_escape_string($con, $_POST['text_es']);
-		$text_eu = mysqli_real_escape_string($con, $_POST['text_eu']);
-		$text_en = mysqli_real_escape_string($con, $_POST['text_en']);
-		$image = array();
-		$image[0] = $_FILES['image_0'];
-		$image[1] = $_FILES['image_1'];
-		$image[2] = $_FILES['image_2'];
-		$image[3] = $_FILES['image_3'];
-		$comments = mysqli_real_escape_string($con, $_POST['comments']);
-		$visible = mysqli_real_escape_string($con, $_POST['visible']);
-		$admin = mysqli_real_escape_string($con, $_POST['admin']);
-		
-		//Check spanish title and generate permalink
-		if ($title_es == null)
-			exit();
-		else{
-			$permalink = permalink($title_es);
-			$i = 2;
-			$ok = false;
-			$tmppermalink = $permalink;
-			while ($ok == false){
-				$query = mysqli_query($con, "SELECT id FROM post WHERE permalink = '$tmppermalink';");
-				if (mysqli_num_rows($query) > 0){
-					$tmppermalink = $permalink . "-" . $i;
-					$i ++;
-				}
-				else{
-					$permalink = $tmppermalink;
-					$ok = true;
-				}
-			}
-		}
-		
-		//Check titles with no text
-		if (strlen($title_eu) > 0 && strlen($text_eu) < 1)
-			exit();
-		if (strlen($title_en) > 0 && strlen($text_en) < 1)
-			exit();
-		
-		//Check text with no titles
-		if (strlen($text_eu) > 0 && strlen($title_eu) < 1)
-			exit();
-		if (strlen($text_en) > 0 && strlen($title_en) < 1)
-			exit();
-		
-		//Check booleans and assign default values if not
-		if ($comments == 'off')
-			$comments = 0;
-		else
-			$comments = 1;
-		if ($visible == 'off')
-			$visible = 0;
-		else
-			$visible = 1;
-		if ($admin == 'on')
-			$admin = 1;
-		else
-			$admin = 0;
-			
-		// If no translations, same text in all languages
-		if (strlen($text_eu) == 0){
-			$text_eu = $text_es;
-			$title_eu = $title_es; 
-		}
-		
-		if (strlen($text_en) == 0){
-			$text_en = $text_es;
-			$title_en = $title_es; 
-		}
-		
-		//Get user
-		if ($admin)
-			$user = 0;
-		else{
-			//TODO
-			$user = 0;
-		}
-		
-		//Insert into database and get id
-		mysqli_query($con, "INSERT INTO post (permalink, title_es, title_eu, title_en, text_es, text_eu, text_en, user, visible, comments) VALUES ('$permalink', '$title_es', '$title_eu', '$title_en', '$text_es', '$text_eu', '$text_en', $user, $visible, $comments);");
-		$res_post = mysqli_query($con, "SELECT id FROM post WHERE permalink = '$permalink' ORDER BY dtime DESC LIMIT 1;");
-		$row_post = mysqli_fetch_array($res_post);
-		$post_id = $row_post['id'];
-		//Process images
-		$file_idx = 0;
-		$img_idx = 0;
-		while ($file_idx < 4 && $img_idx < 4){
-			if (file_exists($image[$file_idx]['tmp_name']) > 0){
-				
-				//Convert to jpg
-				$im = new imagick($image[$file_idx]['tmp_name']);
-				$im->setImageFormat('jpg');
-				$im->writeImage("../../../www/img/blog/$permalink-n$img_idx.jpg");
-				$im->resizeImage(800, 800, Imagick::FILTER_POINT, false);
-				$im->writeImage("../../../www/img/blog/view/$permalink-n$img_idx.jpg");
-				$im->resizeImage(600, 600, Imagick::FILTER_POINT, false);
-				$im->writeImage("../../../www/img/blog/preview/$permalink-n$img_idx.jpg");
-				$im->resizeImage(340, 340, Imagick::FILTER_POINT, false);
-				$im->writeImage("../../../www/img/blog/miniature/$permalink-n$img_idx.jpg");
-				$im->resizeImage(180, 180, Imagick::FILTER_POINT, false);
-				$im->writeImage("../../../www/img/blog/thumb/$permalink-n$img_idx.jpg");
-				$im->clear();
-				$im->destroy();
-				
-				//Database
-				mysqli_query($con, "INSERT INTO post_image (post, image, idx) VALUES ($post_id, '$permalink-n$img_idx.jpg', $img_idx);");
-				
-				$img_idx ++;
-			}
-			$file_idx ++;
-		}
-		
-		version();
-		
-		header("Location: /blog/");
-	}
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb('rw');
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+        
+        //Get POST data
+        $title_es = mysqli_real_escape_string($con, $_POST['title_es']);
+        $title_eu = mysqli_real_escape_string($con, $_POST['title_eu']);
+        $title_en = mysqli_real_escape_string($con, $_POST['title_en']);
+        $text_es = mysqli_real_escape_string($con, $_POST['text_es']);
+        $text_eu = mysqli_real_escape_string($con, $_POST['text_eu']);
+        $text_en = mysqli_real_escape_string($con, $_POST['text_en']);
+        $image = array();
+        $image[0] = $_FILES['image_0'];
+        $image[1] = $_FILES['image_1'];
+        $image[2] = $_FILES['image_2'];
+        $image[3] = $_FILES['image_3'];
+        $comments = mysqli_real_escape_string($con, $_POST['comments']);
+        $visible = mysqli_real_escape_string($con, $_POST['visible']);
+        $admin = mysqli_real_escape_string($con, $_POST['admin']);
+        
+        //Check spanish title and generate permalink
+        if ($title_es == null)
+            exit();
+        else{
+            $permalink = permalink($title_es);
+            $i = 2;
+            $ok = false;
+            $tmppermalink = $permalink;
+            while ($ok == false){
+                $query = mysqli_query($con, "SELECT id FROM post WHERE permalink = '$tmppermalink';");
+                if (mysqli_num_rows($query) > 0){
+                    $tmppermalink = $permalink . "-" . $i;
+                    $i ++;
+                }
+                else{
+                    $permalink = $tmppermalink;
+                    $ok = true;
+                }
+            }
+        }
+        
+        //Check titles with no text
+        if (strlen($title_eu) > 0 && strlen($text_eu) < 1)
+            exit();
+        if (strlen($title_en) > 0 && strlen($text_en) < 1)
+            exit();
+        
+        //Check text with no titles
+        if (strlen($text_eu) > 0 && strlen($title_eu) < 1)
+            exit();
+        if (strlen($text_en) > 0 && strlen($title_en) < 1)
+            exit();
+        
+        //Check booleans and assign default values if not
+        if ($comments == 'off')
+            $comments = 0;
+        else
+            $comments = 1;
+        if ($visible == 'off')
+            $visible = 0;
+        else
+            $visible = 1;
+        if ($admin == 'on')
+            $admin = 1;
+        else
+            $admin = 0;
+            
+        // If no translations, same text in all languages
+        if (strlen($text_eu) == 0){
+            $text_eu = $text_es;
+            $title_eu = $title_es; 
+        }
+        
+        if (strlen($text_en) == 0){
+            $text_en = $text_es;
+            $title_en = $title_es; 
+        }
+        
+        //Get user
+        if ($admin)
+            $user = 0;
+        else{
+            //TODO
+            $user = 0;
+        }
+        
+        //Insert into database and get id
+        mysqli_query($con, "INSERT INTO post (permalink, title_es, title_eu, title_en, text_es, text_eu, text_en, user, visible, comments) VALUES ('$permalink', '$title_es', '$title_eu', '$title_en', '$text_es', '$text_eu', '$text_en', $user, $visible, $comments);");
+        $res_post = mysqli_query($con, "SELECT id FROM post WHERE permalink = '$permalink' ORDER BY dtime DESC LIMIT 1;");
+        $row_post = mysqli_fetch_array($res_post);
+        $post_id = $row_post['id'];
+        //Process images
+        $file_idx = 0;
+        $img_idx = 0;
+        while ($file_idx < 4 && $img_idx < 4){
+            if (file_exists($image[$file_idx]['tmp_name']) > 0){
+                
+                //Convert to jpg
+                $im = new imagick($image[$file_idx]['tmp_name']);
+                $im->setImageFormat('jpg');
+                $im->writeImage("../../../www/img/blog/$permalink-n$img_idx.jpg");
+                $im->resizeImage(800, 800, Imagick::FILTER_POINT, false);
+                $im->writeImage("../../../www/img/blog/view/$permalink-n$img_idx.jpg");
+                $im->resizeImage(600, 600, Imagick::FILTER_POINT, false);
+                $im->writeImage("../../../www/img/blog/preview/$permalink-n$img_idx.jpg");
+                $im->resizeImage(340, 340, Imagick::FILTER_POINT, false);
+                $im->writeImage("../../../www/img/blog/miniature/$permalink-n$img_idx.jpg");
+                $im->resizeImage(180, 180, Imagick::FILTER_POINT, false);
+                $im->writeImage("../../../www/img/blog/thumb/$permalink-n$img_idx.jpg");
+                $im->clear();
+                $im->destroy();
+                
+                //Database
+                mysqli_query($con, "INSERT INTO post_image (post, image, idx) VALUES ($post_id, '$permalink-n$img_idx.jpg', $img_idx);");
+                
+                $img_idx ++;
+            }
+            $file_idx ++;
+        }
+        
+        version();
+        
+        header("Location: /blog/");
+    }
 ?>

+ 111 - 111
www-admin/blog/add/index.php

@@ -1,118 +1,118 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
 ?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nuevo post - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="script.js"></script>
-		<script type="text/javascript" src="/script/ui.js"></script>
-		<script src="../../ckeditor/ckeditor.js"></script>
-	</head>
-	<body>
-		<?php include('../../toolbar.php'); ?>
-		<div id='content'>
-			<div class="section">
-				<h3 class="section_title">Nuevo post</h3>
-				<form action="add.php" maxlength="120" method="post" enctype="multipart/form-data" onsubmit="return validate_post();">
-					<div class="entry">
-						<div id="lang_tabs">
-							<table>
-								<tr>
-									<td class="pointer lang_tabs_active" id="lang_tab_es" onclick="showLanguage('es');">
-										Castellano
-									</td>
-									<td class="pointer" id="lang_tab_eu" onclick="showLanguage('eu');">
-										Euskera
-									</td>
-									<td class="pointer" id="lang_tab_en" onclick="showLanguage('en');">
-										Ingl&eacute;s
-									</td>
-								</tr>
-							</table>
-						</div>
-						<div id="content_lang_es" class="blog_add_language">
-							<input type="text" id="title_es" name="title_es" placeholder="Titulo"/><br/><br/>
-							<textarea name="text_es" id="text_es" placeholder="Texto"></textarea>
-							<script>
-								CKEDITOR.replace('text_es');
-							</script>
-						</div>
-						<div id="content_lang_eu" class="blog_add_language" style="display:none;">
-							<input type="text" name="title_eu" id="title_eu" placeholder="Titulu"><br/><br/>
-							<textarea name="text_eu" id="text_eu" placeholder="Textua"></textarea>
-							<script>
-								CKEDITOR.replace('text_eu');
-							</script>
-						</div>
-						<div id="content_lang_en" class="blog_add_language" style="display:none;">
-							<input type="text" name="title_en" id="title_en" placeholder="Titlu"><br><br/>
-							<textarea name="text_en" id="text_en" placeholder="Content"></textarea>
-							<script>
-								CKEDITOR.replace('text_en');
-							</script>
-						</div>
-					</div> <!--Entry-->
-					<div class="entry" id="images">
-						<h4>Im&aacute;genes</h4>
-						<ul>
-							<li>
-								Principal (Aparecera sobre el texto y en las previsualizaciones)<br/>
-								<div class="image_upload_container">
-									<img class="image_upload_preview" id="image_preview_0" src="/img/misc/alpha.png"/><br/><br/>
-									<input id="image_0" onchange="preview_image(this, image_preview_0);" type="file" name="image_0" accept="image/x-png, image/gif, image/jpeg"/>
-								</div>
-							</li>
-							<li>
-								Secundarias (Bajo el texto)<br/>
-								<div class="image_upload_container">
-									<img class="image_upload_preview" id="image_preview_1" src="/img/misc/alpha.png"/><br/><br/>
-									<input id="image_1" onchange="preview_image(this, image_preview_1);" type="file" name="image_1" accept="image/x-png, image/gif, image/jpeg"/>
-								</div>
-								<div class="image_upload_container">
-									<img class="image_upload_preview" id="image_preview_2" src="/img/misc/alpha.png"/><br/><br/>
-									<input id="image_2" onchange="preview_image(this, image_preview_2);" type="file" name="image_2" accept="image/x-png, image/gif, image/jpeg"/>
-								</div>
-								<div class="image_upload_container">
-									<img class="image_upload_preview" id="image_preview_3" src="/img/misc/alpha.png"/><br/><br/>
-									<input id="image_3" onchange="preview_image(this, image_preview_3);" type="file" name="image_3" accept="image/x-png, image/gif, image/jpeg"/>
-								</div>
-							</li>
-						</ul>
-					</div>
-					<div class="entry" id="settings">
-						<h4>Ajustes</h4>
-						<label><input type="checkbox" name="visible" checked/>Post visible</label><br/><br/>
-						<label><input type="checkbox" name="comments" checked/>Permitir comentarios</label><br/><br/>
-						<label><input type="checkbox" name="admin"/>Publicar como Gasteizko Margolariak en lugar de mi nombre</label>
-						<br/><br/><br/><br/>
-						<div id="add_button_container">
-							<input type="button" value="Previsualizar" onClick="alert(validate_post());"/> <!--TODO-->
-							<br/>
-							<input type="submit" value="Publicar"/>
-						</div>
-					</div>
-				</form>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nuevo post - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+        <script type="text/javascript" src="/script/ui.js"></script>
+        <script src="../../ckeditor/ckeditor.js"></script>
+    </head>
+    <body>
+        <?php include('../../toolbar.php'); ?>
+        <div id='content'>
+            <div class="section">
+                <h3 class="section_title">Nuevo post</h3>
+                <form action="add.php" maxlength="120" method="post" enctype="multipart/form-data" onsubmit="return validate_post();">
+                    <div class="entry">
+                        <div id="lang_tabs">
+                            <table>
+                                <tr>
+                                    <td class="pointer lang_tabs_active" id="lang_tab_es" onclick="showLanguage('es');">
+                                        Castellano
+                                    </td>
+                                    <td class="pointer" id="lang_tab_eu" onclick="showLanguage('eu');">
+                                        Euskera
+                                    </td>
+                                    <td class="pointer" id="lang_tab_en" onclick="showLanguage('en');">
+                                        Ingl&eacute;s
+                                    </td>
+                                </tr>
+                            </table>
+                        </div>
+                        <div id="content_lang_es" class="blog_add_language">
+                            <input type="text" id="title_es" name="title_es" placeholder="Titulo"/><br/><br/>
+                            <textarea name="text_es" id="text_es" placeholder="Texto"></textarea>
+                            <script>
+                                CKEDITOR.replace('text_es');
+                            </script>
+                        </div>
+                        <div id="content_lang_eu" class="blog_add_language" style="display:none;">
+                            <input type="text" name="title_eu" id="title_eu" placeholder="Titulu"><br/><br/>
+                            <textarea name="text_eu" id="text_eu" placeholder="Textua"></textarea>
+                            <script>
+                                CKEDITOR.replace('text_eu');
+                            </script>
+                        </div>
+                        <div id="content_lang_en" class="blog_add_language" style="display:none;">
+                            <input type="text" name="title_en" id="title_en" placeholder="Titlu"><br><br/>
+                            <textarea name="text_en" id="text_en" placeholder="Content"></textarea>
+                            <script>
+                                CKEDITOR.replace('text_en');
+                            </script>
+                        </div>
+                    </div> <!--Entry-->
+                    <div class="entry" id="images">
+                        <h4>Im&aacute;genes</h4>
+                        <ul>
+                            <li>
+                                Principal (Aparecera sobre el texto y en las previsualizaciones)<br/>
+                                <div class="image_upload_container">
+                                    <img class="image_upload_preview" id="image_preview_0" src="/img/misc/alpha.png"/><br/><br/>
+                                    <input id="image_0" onchange="preview_image(this, image_preview_0);" type="file" name="image_0" accept="image/x-png, image/gif, image/jpeg"/>
+                                </div>
+                            </li>
+                            <li>
+                                Secundarias (Bajo el texto)<br/>
+                                <div class="image_upload_container">
+                                    <img class="image_upload_preview" id="image_preview_1" src="/img/misc/alpha.png"/><br/><br/>
+                                    <input id="image_1" onchange="preview_image(this, image_preview_1);" type="file" name="image_1" accept="image/x-png, image/gif, image/jpeg"/>
+                                </div>
+                                <div class="image_upload_container">
+                                    <img class="image_upload_preview" id="image_preview_2" src="/img/misc/alpha.png"/><br/><br/>
+                                    <input id="image_2" onchange="preview_image(this, image_preview_2);" type="file" name="image_2" accept="image/x-png, image/gif, image/jpeg"/>
+                                </div>
+                                <div class="image_upload_container">
+                                    <img class="image_upload_preview" id="image_preview_3" src="/img/misc/alpha.png"/><br/><br/>
+                                    <input id="image_3" onchange="preview_image(this, image_preview_3);" type="file" name="image_3" accept="image/x-png, image/gif, image/jpeg"/>
+                                </div>
+                            </li>
+                        </ul>
+                    </div>
+                    <div class="entry" id="settings">
+                        <h4>Ajustes</h4>
+                        <label><input type="checkbox" name="visible" checked/>Post visible</label><br/><br/>
+                        <label><input type="checkbox" name="comments" checked/>Permitir comentarios</label><br/><br/>
+                        <label><input type="checkbox" name="admin"/>Publicar como Gasteizko Margolariak en lugar de mi nombre</label>
+                        <br/><br/><br/><br/>
+                        <div id="add_button_container">
+                            <input type="button" value="Previsualizar" onClick="alert(validate_post());"/> <!--TODO-->
+                            <br/>
+                            <input type="submit" value="Publicar"/>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </body>
 </html>
 
 <?php
-	}
+    }
 ?>

+ 105 - 105
www-admin/blog/add/script.js

@@ -1,117 +1,117 @@
 function validate_post(){
-	var text_es = document.getElementById('text_es').value;
-	var text_eu = document.getElementById('text_eu').value;
-	var text_en = document.getElementById('text_en').value;
-	var title_es = document.getElementById('title_es').value;
-	var title_eu = document.getElementById('title_eu').value;
-	var title_en = document.getElementById('title_en').value;
-	result = true;
-	
-	//Spanish fields empty
-	if (title_es.length < 1){
-		result = false;
-		alert("Introduce un titulo en castellano");
-		return false;
-	}
-	if (text_es.length < 1){
-		result = false;
-		alert("Introduce un texto en castellano");
-		return false;
-	}
-	
-	//Titles without texts
-	if (title_eu.length > 0 && text_eu.length < 1){
-		result = false;
-		alert("Introduce un texto o borra el titulo en euskera")
-		return false;
-	}
-	if (title_en.length > 0 && text_en.length < 1){
-		result = false;
-		alert("Introduce un texto o borra el titulo en ingles")
-		return false;
-	}
-	
-	//Text without titles
-	if (text_eu.length > 0 && title_eu.length < 1){
-		result = false;
-		alert("Introduce un titulo o borra el texto en euskera")
-		return false;
-	}
-	if (text_en.length > 0 && title_en.length < 1){
-		result = false;
-		alert("Introduce un titulo o borra el texto en ingles")
-		return false;
-	}
-	return true;
+    var text_es = document.getElementById('text_es').value;
+    var text_eu = document.getElementById('text_eu').value;
+    var text_en = document.getElementById('text_en').value;
+    var title_es = document.getElementById('title_es').value;
+    var title_eu = document.getElementById('title_eu').value;
+    var title_en = document.getElementById('title_en').value;
+    result = true;
+    
+    //Spanish fields empty
+    if (title_es.length < 1){
+        result = false;
+        alert("Introduce un titulo en castellano");
+        return false;
+    }
+    if (text_es.length < 1){
+        result = false;
+        alert("Introduce un texto en castellano");
+        return false;
+    }
+    
+    //Titles without texts
+    if (title_eu.length > 0 && text_eu.length < 1){
+        result = false;
+        alert("Introduce un texto o borra el titulo en euskera")
+        return false;
+    }
+    if (title_en.length > 0 && text_en.length < 1){
+        result = false;
+        alert("Introduce un texto o borra el titulo en ingles")
+        return false;
+    }
+    
+    //Text without titles
+    if (text_eu.length > 0 && title_eu.length < 1){
+        result = false;
+        alert("Introduce un titulo o borra el texto en euskera")
+        return false;
+    }
+    if (text_en.length > 0 && title_en.length < 1){
+        result = false;
+        alert("Introduce un titulo o borra el texto en ingles")
+        return false;
+    }
+    return true;
 }
 
 
 
 function formatText(textarea, format){
-	
-	var text = textarea.value;
-	var selectedText= window.getSelection().toString();
-	event.preventDefault();
-	//IE
-	if (document.selection != undefined){
-		textarea.focus();
-		var selection = document.selection.createRange();
-		selectedText = selection.text;
-	}
-	
-	//Mozilla
-	else if (textarea.selectionStart != undefined){
-		var startPos = textarea.selectionStart;
-		var endPos = textarea.selectionEnd;
-		selectedText = textarea.value.substring(startPos, endPos);
-	}
-	
-	var replace;
-	switch (format){
-		case "italic":
-			replace = "<span style='font-style:italic;'>" + selectedText + "</span>";
-			break;
-		case "bold":
-			replace = "<span style='font-weight:bold;'>" + selectedText + "</span>";
-			break;
-		case "underline":
-			replace = "<span style='text-decoration:underline;'>" + selectedText + "</span>";
-			break;
-		case "stroke":
-			replace = "<span style='text-decoration:line-through;'>" + selectedText + "</span>";
-			break;
-		case "link":
-			replace = "<a href='" + selectedText + "'>" + selectedText + "</a>";
-			break;
-		case "color-red":
-			replace = "<span style='color:#f00;'>" + selectedText + "</span>";
-			break;
-		case "color-green":
-			replace = "<span style='color:#0f0;'>" + selectedText + "</span>";
-			break;
-		case "color-blue":
-			replace = "<span style='color:#00f;'>" + selectedText + "</span>";
-			break;
-		default:
-			replace = selectedText;
-	}
-	
-	if (selectedText.length  >0 && text != replace){
-		text = text.replace(selectedText, replace);
-		textarea.value = text;
-	}
+    
+    var text = textarea.value;
+    var selectedText= window.getSelection().toString();
+    event.preventDefault();
+    //IE
+    if (document.selection != undefined){
+        textarea.focus();
+        var selection = document.selection.createRange();
+        selectedText = selection.text;
+    }
+    
+    //Mozilla
+    else if (textarea.selectionStart != undefined){
+        var startPos = textarea.selectionStart;
+        var endPos = textarea.selectionEnd;
+        selectedText = textarea.value.substring(startPos, endPos);
+    }
+    
+    var replace;
+    switch (format){
+        case "italic":
+            replace = "<span style='font-style:italic;'>" + selectedText + "</span>";
+            break;
+        case "bold":
+            replace = "<span style='font-weight:bold;'>" + selectedText + "</span>";
+            break;
+        case "underline":
+            replace = "<span style='text-decoration:underline;'>" + selectedText + "</span>";
+            break;
+        case "stroke":
+            replace = "<span style='text-decoration:line-through;'>" + selectedText + "</span>";
+            break;
+        case "link":
+            replace = "<a href='" + selectedText + "'>" + selectedText + "</a>";
+            break;
+        case "color-red":
+            replace = "<span style='color:#f00;'>" + selectedText + "</span>";
+            break;
+        case "color-green":
+            replace = "<span style='color:#0f0;'>" + selectedText + "</span>";
+            break;
+        case "color-blue":
+            replace = "<span style='color:#00f;'>" + selectedText + "</span>";
+            break;
+        default:
+            replace = selectedText;
+    }
+    
+    if (selectedText.length  >0 && text != replace){
+        text = text.replace(selectedText, replace);
+        textarea.value = text;
+    }
 }
 
 function preview_image(source, target) {
-	var reader = new FileReader();
-	reader.readAsDataURL(source.files[0]);
+    var reader = new FileReader();
+    reader.readAsDataURL(source.files[0]);
 
-	reader.onload = function (reader_event) {
-		target.src = reader_event.target.result;
-		target.style.border = "2px solid black";
-		target.style.marginTop = 10 + "px";
-		target.style.marginBottom = 10 + "px";
-		target.style.display = "inline";
-	};
+    reader.onload = function (reader_event) {
+        target.src = reader_event.target.result;
+        target.style.border = "2px solid black";
+        target.style.marginTop = 10 + "px";
+        target.style.marginBottom = 10 + "px";
+        target.style.display = "inline";
+    };
 };
 

+ 14 - 14
www-admin/blog/delete/delete.php

@@ -1,16 +1,16 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb('rw');
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
-		$id = mysqli_real_escape_string($con, $_GET['p']);
-		mysqli_query($con, "DELETE FROM post_comment WHERE post = $id;");
-		mysqli_query($con, "DELETE FROM post_image WHERE post = $id;");
-		mysqli_query($con, "DELETE FROM post WHERE id = $id;");
-		version();
-	}
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb('rw');
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+        $id = mysqli_real_escape_string($con, $_GET['p']);
+        mysqli_query($con, "DELETE FROM post_comment WHERE post = $id;");
+        mysqli_query($con, "DELETE FROM post_image WHERE post = $id;");
+        mysqli_query($con, "DELETE FROM post WHERE id = $id;");
+        version();
+    }
 ?>

+ 130 - 130
www-admin/blog/edit/edit.php

@@ -1,132 +1,132 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb('rw');
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
-		
-		//Get POST data
-		$id = mysqli_real_escape_string($con, $_POST['id']);
-		$title_es = mysqli_real_escape_string($con, $_POST['title_es']);
-		$title_eu = mysqli_real_escape_string($con, $_POST['title_eu']);
-		$title_en = mysqli_real_escape_string($con, $_POST['title_en']);
-		$text_es = mysqli_real_escape_string($con, $_POST['text_es']);
-		$text_eu = mysqli_real_escape_string($con, $_POST['text_eu']);
-		$text_en = mysqli_real_escape_string($con, $_POST['text_en']);
-		$image = array();
-		$image[0] = $_FILES['image_0'];
-		$image[1] = $_FILES['image_1'];
-		$image[2] = $_FILES['image_2'];
-		$image[3] = $_FILES['image_3'];
-		$comments = mysqli_real_escape_string($con, $_POST['comments']);
-		$visible = mysqli_real_escape_string($con, $_POST['visible']);
-		$admin = mysqli_real_escape_string($con, $_POST['admin']);
-		
-		//Check spanish title
-		if ($title_es == null)
-			exit();
-		
-		//Check titles with no text
-		if (strlen($title_eu) > 0 && strlen($text_eu) < 1)
-			exit();
-		if (strlen($title_en) > 0 && strlen($text_en) < 1)
-			exit();
-		
-		//Check text with no titles
-		if (strlen($text_eu) > 0 && strlen($title_eu) < 1)
-			exit();
-		if (strlen($text_en) > 0 && strlen($title_en) < 1)
-			exit();
-		
-		//Check booleans and assign default values if not
-		if ($comments == 'off')
-			$comments = 0;
-		else
-			$comments = 1;
-		if ($visible == 'off')
-			$visible = 0;
-		else
-			$visible = 1;
-		if ($admin == 'on')
-			$admin = 1;
-		else
-			$admin = 0;
-			
-		// If no translations, same text in all languages
-		if (strlen($text_eu) == 0){
-			$text_eu = $text_es;
-			$title_eu = $title_es; 
-		}
-		
-		if (strlen($text_en) == 0){
-			$text_en = $text_es;
-			$title_en = $title_es; 
-		}
-		
-		//Get database entry
-		$q = mysqli_query($con, "SELECT * FROM post WHERE id = $id;");
-		if (mysqli_num_rows($q) == 0)
-			exit();
-		$r = mysqli_fetch_array($q);
-		if ($title_es != $r['title_es']){
-			mysqli_query($con, "UPDATE post SET title_es = '$title_es' WHERE id = $id;");
-		}
-		if ($title_eu != $r['title_eu']){
-			mysqli_query($con, "UPDATE post SET title_eu = '$title_eu' WHERE id = $id;");
-		}
-		if ($title_en != $r['title_en']){
-			mysqli_query($con, "UPDATE post SET title_en = '$title_en' WHERE id = $id;");
-		}
-		if ($text_es != $r['text_es']){
-			mysqli_query($con, "UPDATE post SET text_es = '$text_es' WHERE id = $id;");
-		}
-		if ($text_eu != $r['text_eu']){
-			mysqli_query($con, "UPDATE post SET text_eu = '$text_eu' WHERE id = $id;");
-		}
-		if ($text_en != $r['text_en']){
-			mysqli_query($con, "UPDATE post SET text_en = '$text_en' WHERE id = $id;");
-		}
-		if ($comments != $r['comments']){
-			mysqli_query($con, "UPDATE post SET comments = $comments WHERE id = $id;");
-		}
-		if ($visible != $r['visible']){
-			mysqli_query($con, "UPDATE post SET visible = $visible WHERE id = $id;");
-		}
-		
-		while ($file_idx < 4 && $img_idx < 4){
-			if ($_POST["delete_image_$file_idx"] == 'yes'){
-				mysqli_query($con, "DELETE FROM pot_image WHERE post = $id AND idx = $file_idx;");
-				//TODO: Maybe images should be sorted after this
-			}
-			
-			if (file_exists($image[$file_idx]['tmp_name']) > 0){
-				
-				//Convert to jpg
-				$im = new imagick($image[$file_idx]['tmp_name']);
-				$im->setImageFormat('jpg');
-				$im->writeImage("../../../www/img/blog/$permalink-n$img_idx.jpg");
-				$im->resizeImage(800, 800, Imagick::FILTER_POINT, false);
-				$im->writeImage("../../../www/img/blog/view/$permalink-n$img_idx.jpg");
-				$im->resizeImage(600, 600, Imagick::FILTER_POINT, false);
-				$im->writeImage("../../../www/img/blog/preview/$permalink-n$img_idx.jpg");
-				$im->resizeImage(350, 350, Imagick::FILTER_POINT, false);
-				$im->writeImage("../../../www/img/blog/miniature/$permalink-n$img_idx.jpg");
-				$im->resizeImage(200, 200, Imagick::FILTER_POINT, false);
-				$im->writeImage("../../../www/img/blog/thumb/$permalink-n$img_idx.jpg");
-				$im->clear();
-				$im->destroy();
-				
-				//Database
-				mysqli_query($con, "INSERT INTO post_image (post, image, idx) VALUES ($post_id, '$permalink-n$img_idx.jpg', $img_idx);");
-				
-				$img_idx ++;
-			}
-			$file_idx ++;
-		}
-		
-		version();
-	}
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb('rw');
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+        
+        //Get POST data
+        $id = mysqli_real_escape_string($con, $_POST['id']);
+        $title_es = mysqli_real_escape_string($con, $_POST['title_es']);
+        $title_eu = mysqli_real_escape_string($con, $_POST['title_eu']);
+        $title_en = mysqli_real_escape_string($con, $_POST['title_en']);
+        $text_es = mysqli_real_escape_string($con, $_POST['text_es']);
+        $text_eu = mysqli_real_escape_string($con, $_POST['text_eu']);
+        $text_en = mysqli_real_escape_string($con, $_POST['text_en']);
+        $image = array();
+        $image[0] = $_FILES['image_0'];
+        $image[1] = $_FILES['image_1'];
+        $image[2] = $_FILES['image_2'];
+        $image[3] = $_FILES['image_3'];
+        $comments = mysqli_real_escape_string($con, $_POST['comments']);
+        $visible = mysqli_real_escape_string($con, $_POST['visible']);
+        $admin = mysqli_real_escape_string($con, $_POST['admin']);
+        
+        //Check spanish title
+        if ($title_es == null)
+            exit();
+        
+        //Check titles with no text
+        if (strlen($title_eu) > 0 && strlen($text_eu) < 1)
+            exit();
+        if (strlen($title_en) > 0 && strlen($text_en) < 1)
+            exit();
+        
+        //Check text with no titles
+        if (strlen($text_eu) > 0 && strlen($title_eu) < 1)
+            exit();
+        if (strlen($text_en) > 0 && strlen($title_en) < 1)
+            exit();
+        
+        //Check booleans and assign default values if not
+        if ($comments == 'off')
+            $comments = 0;
+        else
+            $comments = 1;
+        if ($visible == 'off')
+            $visible = 0;
+        else
+            $visible = 1;
+        if ($admin == 'on')
+            $admin = 1;
+        else
+            $admin = 0;
+            
+        // If no translations, same text in all languages
+        if (strlen($text_eu) == 0){
+            $text_eu = $text_es;
+            $title_eu = $title_es; 
+        }
+        
+        if (strlen($text_en) == 0){
+            $text_en = $text_es;
+            $title_en = $title_es; 
+        }
+        
+        //Get database entry
+        $q = mysqli_query($con, "SELECT * FROM post WHERE id = $id;");
+        if (mysqli_num_rows($q) == 0)
+            exit();
+        $r = mysqli_fetch_array($q);
+        if ($title_es != $r['title_es']){
+            mysqli_query($con, "UPDATE post SET title_es = '$title_es' WHERE id = $id;");
+        }
+        if ($title_eu != $r['title_eu']){
+            mysqli_query($con, "UPDATE post SET title_eu = '$title_eu' WHERE id = $id;");
+        }
+        if ($title_en != $r['title_en']){
+            mysqli_query($con, "UPDATE post SET title_en = '$title_en' WHERE id = $id;");
+        }
+        if ($text_es != $r['text_es']){
+            mysqli_query($con, "UPDATE post SET text_es = '$text_es' WHERE id = $id;");
+        }
+        if ($text_eu != $r['text_eu']){
+            mysqli_query($con, "UPDATE post SET text_eu = '$text_eu' WHERE id = $id;");
+        }
+        if ($text_en != $r['text_en']){
+            mysqli_query($con, "UPDATE post SET text_en = '$text_en' WHERE id = $id;");
+        }
+        if ($comments != $r['comments']){
+            mysqli_query($con, "UPDATE post SET comments = $comments WHERE id = $id;");
+        }
+        if ($visible != $r['visible']){
+            mysqli_query($con, "UPDATE post SET visible = $visible WHERE id = $id;");
+        }
+        
+        while ($file_idx < 4 && $img_idx < 4){
+            if ($_POST["delete_image_$file_idx"] == 'yes'){
+                mysqli_query($con, "DELETE FROM pot_image WHERE post = $id AND idx = $file_idx;");
+                //TODO: Maybe images should be sorted after this
+            }
+            
+            if (file_exists($image[$file_idx]['tmp_name']) > 0){
+                
+                //Convert to jpg
+                $im = new imagick($image[$file_idx]['tmp_name']);
+                $im->setImageFormat('jpg');
+                $im->writeImage("../../../www/img/blog/$permalink-n$img_idx.jpg");
+                $im->resizeImage(800, 800, Imagick::FILTER_POINT, false);
+                $im->writeImage("../../../www/img/blog/view/$permalink-n$img_idx.jpg");
+                $im->resizeImage(600, 600, Imagick::FILTER_POINT, false);
+                $im->writeImage("../../../www/img/blog/preview/$permalink-n$img_idx.jpg");
+                $im->resizeImage(350, 350, Imagick::FILTER_POINT, false);
+                $im->writeImage("../../../www/img/blog/miniature/$permalink-n$img_idx.jpg");
+                $im->resizeImage(200, 200, Imagick::FILTER_POINT, false);
+                $im->writeImage("../../../www/img/blog/thumb/$permalink-n$img_idx.jpg");
+                $im->clear();
+                $im->destroy();
+                
+                //Database
+                mysqli_query($con, "INSERT INTO post_image (post, image, idx) VALUES ($post_id, '$permalink-n$img_idx.jpg', $img_idx);");
+                
+                $img_idx ++;
+            }
+            $file_idx ++;
+        }
+        
+        version();
+    }
 ?>

+ 193 - 193
www-admin/blog/edit/index.php

@@ -1,201 +1,201 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	$default_host = substr($http_host, 0, strpos($http_host, ':'));
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
-		$id = mysqli_real_escape_string($con, $_GET['p']);
-		$q = mysqli_query($con, "SELECT * FROM post WHERE id = $id;");
-		if (mysqli_num_rows($q) == 0){
-			header("Location: /blog/");
-			exit (-1);
-		}
-		else{
-			$r = mysqli_fetch_array($q);
-			$title_es = $r["title_es"];
-			$title_eu = $r["title_eu"];
-			if ($title_eu == $title_es)
-				$title_eu = "";
-			$title_en = $r["title_en"];
-			if ($title_en == $title_es)
-				$title_en = "";
-			$text_es = $r["text_es"];
-			$text_eu = $r["text_eu"];
-			if ($text_eu == $text_es)
-				$text_eu = "";
-			$text_en = $r["text_en"];
-			if ($text_en == $text_es)
-				$text_en = "";
-			$visible = $r["visible"];
-			$comments = $r["comments"];
+    $http_host = $_SERVER['HTTP_HOST'];
+    $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+        $id = mysqli_real_escape_string($con, $_GET['p']);
+        $q = mysqli_query($con, "SELECT * FROM post WHERE id = $id;");
+        if (mysqli_num_rows($q) == 0){
+            header("Location: /blog/");
+            exit (-1);
+        }
+        else{
+            $r = mysqli_fetch_array($q);
+            $title_es = $r["title_es"];
+            $title_eu = $r["title_eu"];
+            if ($title_eu == $title_es)
+                $title_eu = "";
+            $title_en = $r["title_en"];
+            if ($title_en == $title_es)
+                $title_en = "";
+            $text_es = $r["text_es"];
+            $text_eu = $r["text_eu"];
+            if ($text_eu == $text_es)
+                $text_eu = "";
+            $text_en = $r["text_en"];
+            if ($text_en == $text_es)
+                $text_en = "";
+            $visible = $r["visible"];
+            $comments = $r["comments"];
 ?>
 
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Editar post - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="script.js"></script>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="script.js"></script>
-		<script type="text/javascript" src="/script/ui.js"></script>
-		<script src="../../ckeditor/ckeditor.js"></script>
-	</head>
-	<body>
-		<?php include('../../toolbar.php'); ?>
-		<div id='content'>
-			<div class="section">
-				<h3 class="section_title">Editar post</h3>
-				<form action="edit.php" maxlength="120" method="post" enctype="multipart/form-data" onsubmit="return validate_post();">
-					<?php
-						echo "<input type='hidden' name='id' value='$id'/>\n";
-					?>
-					<div class="entry">
-						<div id="lang_tabs">
-							<table>
-								<tr>
-									<td class="pointer lang_tabs_active" id="lang_tab_es" onclick="showLanguage('es');">
-										Castellano
-									</td>
-									<td class="pointer" id="lang_tab_eu" onclick="showLanguage('eu');">
-										Euskera
-									</td>
-									<td class="pointer" id="lang_tab_en" onclick="showLanguage('en');">
-										Ingl&eacute;s
-									</td>
-								</tr>
-							</table>
-						</div>
-						<div id="content_lang_es" class="blog_add_language">
-							<input type="text" id="title_es" name="title_es" placeholder="Titulo" value="<?php echo $title_es;?>"/><br/><br/>
-							<textarea name="text_es" id="text_es" placeholder="Texto"><?php echo $text_es;?></textarea>
-							<script>
-								CKEDITOR.replace('text_es');
-							</script>
-						</div>
-						<div id="content_lang_eu" class="blog_add_language" style="display:none;">
-							<input type="text" name="title_eu" id="title_eu" placeholder="Titulu" value="<?php echo $title_eu;?>"/><br/><br/>
-							<textarea name="text_eu" id="text_eu" placeholder="Textua"><?php echo $text_eu;?></textarea>
-							<script>
-								CKEDITOR.replace('text_eu');
-							</script>
-						</div>
-						<div id="content_lang_en" class="blog_add_language" style="display:none;">
-							<input type="text" name="title_en" id="title_en" placeholder="Title" value="<?php echo $title_en;?>"/><br><br/>
-							<textarea name="text_en" id="text_en" placeholder="Content"><?php echo $text_en;?></textarea>
-							<script>
-								CKEDITOR.replace('text_es');
-							</script>
-						</div>
-					</div> <!--Entry-->
-					<div class="entry" id="images">
-						<h4>Im&aacute;genes</h4>
-						<ul>
-							<li>
-								Principal (Aparecera sobre el texto y en las previsualizaciones)<br/>
-								<div class="image_upload_container">
-									<?php
-										$q_img = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id AND idx = 0");
-										if (mysqli_num_rows($q_img) == 0){
-											echo "<img class='image_upload_preview' id='image_preview_0' src='/img/misc/alpha.png'/>\n";
-											echo "<input type='button' style='display:none;' onClick='delete_image(0, image_preview_0, this);' value='Eliminar'";
-										}
-										else{
-											$r_img = mysqli_fetch_array($q_img);
-											echo "<img class='image_upload_preview' style='display:block;' id='image_preview_0' src='http://$default_host/img/blog/miniature/$r_img[image]'/>\n";
-											echo "<input type='button' style='display:block;' onClick='delete_image(0, image_preview_0, this);' value='Eliminar'";
-										}
-									?>
-									<br/><br/>
-									<input type="hidden" name="delete_image_0" id="delete_image_0" value="no"/>
-									<input id="image_0" onchange="preview_image(0, this, image_preview_0);" type="file" name="image_0" accept="image/x-png, image/gif, image/jpeg"/>
-								</div>
-							</li>
-							<li>
-								Secundarias (Bajo el texto)<br/>
-								<div class="image_upload_container">
-									<?php
-										$q_img = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id AND idx = 1");
-										if (mysqli_num_rows($q_img) == 0){
-											echo "<img class='image_upload_preview' id='image_preview_1' src='/img/misc/alpha.png'/>\n";
-											echo "<input type='button' style='display:none;' onClick='delete_image(1, image_preview_1, this);' value='Eliminar'";
-										}
-										else{
-											$r_img = mysqli_fetch_array($q_img);
-											echo "<img class='image_upload_preview' style='display:block;' id='image_preview_1' src='http://$default_host/img/blog/miniature/$r_img[image]'/>\n";
-											echo "<input type='button' style='display:block;' onClick='delete_image(1, image_preview_1, this);' value='Eliminar'";
-										}
-									?>
-									<br/><br/>
-									<input type="hidden" name="delete_image_1" id="delete_image_1" value="no"/>
-									<input id="image_1" onchange="preview_image(1, this, image_preview_1);" type="file" name="image_1" accept="image/x-png, image/gif, image/jpeg"/>
-								</div>
-								<div class="image_upload_container">
-									<?php
-										$q_img = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id AND idx = 2");
-										if (mysqli_num_rows($q_img) == 0){
-											echo "<img class='image_upload_preview' id='image_preview_2' src='/img/misc/alpha.png'/>\n";
-											echo "<input type='button' style='display:none;' onClick='delete_image(2, image_preview_2, this);' value='Eliminar'";
-										}
-										else{
-											$r_img = mysqli_fetch_array($q_img);
-											echo "<img class='image_upload_preview' style='display:block;' id='image_preview_2' src='http://$default_host/img/blog/miniature/$r_img[image]'/>\n";
-											echo "<input type='button' style='display:block;' onClick='delete_image(2, image_preview_2, this);' value='Eliminar'";
-										}
-									?>
-									<br/><br/>
-									<input type="hidden" name="delete_image_2" id="delete_image_2" value="no"/>
-									<input id="image_2" onchange="preview_image(2, this, image_preview_0);" type="file" name="image_2" accept="image/x-png, image/gif, image/jpeg"/>
-								</div>
-								<div class="image_upload_container">
-									<?php
-										$q_img = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id AND idx = 3");
-										if (mysqli_num_rows($q_img) == 0){
-											echo "<img class='image_upload_preview' id='image_preview_3' src='/img/misc/alpha.png'/>\n";
-											echo "<input type='button' style='display:none;' onClick='delete_image(3, image_preview_3, this);' value='Eliminar'";
-										}
-										else{
-											$r_img = mysqli_fetch_array($q_img);
-											echo "<img class='image_upload_preview' style='display:block;' id='image_preview_3' src='http://$default_host/img/blog/miniature/$r_img[image]'/>\n";
-											echo "<input type='button' style='display:block;' onClick='delete_image(3, image_preview_3, this);' value='Eliminar'";
-										}
-									?>
-									<br/><br/>
-									<input type="hidden" name="delete_image_3" id="delete_image_3" value="no"/>
-									<input id="image_3" onchange="preview_image(3, this, image_preview_0);" type="file" name="image_3" accept="image/x-png, image/gif, image/jpeg"/>
-								</div>
-							</li>
-						</ul>
-					</div>
-					<div class="entry" id="settings">
-						<h4>Ajustes</h4>
-						<label><input type="checkbox" name="visible" <?php if ($r['visible'] == 1) echo 'checked'; ?>/>Post visible</label><br/><br/>
-						<label><input type="checkbox" name="comments" <?php if ($r['comments'] == 1) echo 'checked'; ?>/>Permitir comentarios</label><br/><br/>
-						<br/><br/><br/><br/>
-						<div id="add_button_container">
-							<input type="button" value="Previsualizar" onClick="alert(validate_post());"/> <!--TODO-->
-							<br/>
-							<input type="submit" value="Publicar"/>
-						</div>
-					</div>
-				</form>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Editar post - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+        <script type="text/javascript" src="/script/ui.js"></script>
+        <script src="../../ckeditor/ckeditor.js"></script>
+    </head>
+    <body>
+        <?php include('../../toolbar.php'); ?>
+        <div id='content'>
+            <div class="section">
+                <h3 class="section_title">Editar post</h3>
+                <form action="edit.php" maxlength="120" method="post" enctype="multipart/form-data" onsubmit="return validate_post();">
+                    <?php
+                        echo "<input type='hidden' name='id' value='$id'/>\n";
+                    ?>
+                    <div class="entry">
+                        <div id="lang_tabs">
+                            <table>
+                                <tr>
+                                    <td class="pointer lang_tabs_active" id="lang_tab_es" onclick="showLanguage('es');">
+                                        Castellano
+                                    </td>
+                                    <td class="pointer" id="lang_tab_eu" onclick="showLanguage('eu');">
+                                        Euskera
+                                    </td>
+                                    <td class="pointer" id="lang_tab_en" onclick="showLanguage('en');">
+                                        Ingl&eacute;s
+                                    </td>
+                                </tr>
+                            </table>
+                        </div>
+                        <div id="content_lang_es" class="blog_add_language">
+                            <input type="text" id="title_es" name="title_es" placeholder="Titulo" value="<?php echo $title_es;?>"/><br/><br/>
+                            <textarea name="text_es" id="text_es" placeholder="Texto"><?php echo $text_es;?></textarea>
+                            <script>
+                                CKEDITOR.replace('text_es');
+                            </script>
+                        </div>
+                        <div id="content_lang_eu" class="blog_add_language" style="display:none;">
+                            <input type="text" name="title_eu" id="title_eu" placeholder="Titulu" value="<?php echo $title_eu;?>"/><br/><br/>
+                            <textarea name="text_eu" id="text_eu" placeholder="Textua"><?php echo $text_eu;?></textarea>
+                            <script>
+                                CKEDITOR.replace('text_eu');
+                            </script>
+                        </div>
+                        <div id="content_lang_en" class="blog_add_language" style="display:none;">
+                            <input type="text" name="title_en" id="title_en" placeholder="Title" value="<?php echo $title_en;?>"/><br><br/>
+                            <textarea name="text_en" id="text_en" placeholder="Content"><?php echo $text_en;?></textarea>
+                            <script>
+                                CKEDITOR.replace('text_es');
+                            </script>
+                        </div>
+                    </div> <!--Entry-->
+                    <div class="entry" id="images">
+                        <h4>Im&aacute;genes</h4>
+                        <ul>
+                            <li>
+                                Principal (Aparecera sobre el texto y en las previsualizaciones)<br/>
+                                <div class="image_upload_container">
+                                    <?php
+                                        $q_img = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id AND idx = 0");
+                                        if (mysqli_num_rows($q_img) == 0){
+                                            echo "<img class='image_upload_preview' id='image_preview_0' src='/img/misc/alpha.png'/>\n";
+                                            echo "<input type='button' style='display:none;' onClick='delete_image(0, image_preview_0, this);' value='Eliminar'";
+                                        }
+                                        else{
+                                            $r_img = mysqli_fetch_array($q_img);
+                                            echo "<img class='image_upload_preview' style='display:block;' id='image_preview_0' src='http://$default_host/img/blog/miniature/$r_img[image]'/>\n";
+                                            echo "<input type='button' style='display:block;' onClick='delete_image(0, image_preview_0, this);' value='Eliminar'";
+                                        }
+                                    ?>
+                                    <br/><br/>
+                                    <input type="hidden" name="delete_image_0" id="delete_image_0" value="no"/>
+                                    <input id="image_0" onchange="preview_image(0, this, image_preview_0);" type="file" name="image_0" accept="image/x-png, image/gif, image/jpeg"/>
+                                </div>
+                            </li>
+                            <li>
+                                Secundarias (Bajo el texto)<br/>
+                                <div class="image_upload_container">
+                                    <?php
+                                        $q_img = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id AND idx = 1");
+                                        if (mysqli_num_rows($q_img) == 0){
+                                            echo "<img class='image_upload_preview' id='image_preview_1' src='/img/misc/alpha.png'/>\n";
+                                            echo "<input type='button' style='display:none;' onClick='delete_image(1, image_preview_1, this);' value='Eliminar'";
+                                        }
+                                        else{
+                                            $r_img = mysqli_fetch_array($q_img);
+                                            echo "<img class='image_upload_preview' style='display:block;' id='image_preview_1' src='http://$default_host/img/blog/miniature/$r_img[image]'/>\n";
+                                            echo "<input type='button' style='display:block;' onClick='delete_image(1, image_preview_1, this);' value='Eliminar'";
+                                        }
+                                    ?>
+                                    <br/><br/>
+                                    <input type="hidden" name="delete_image_1" id="delete_image_1" value="no"/>
+                                    <input id="image_1" onchange="preview_image(1, this, image_preview_1);" type="file" name="image_1" accept="image/x-png, image/gif, image/jpeg"/>
+                                </div>
+                                <div class="image_upload_container">
+                                    <?php
+                                        $q_img = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id AND idx = 2");
+                                        if (mysqli_num_rows($q_img) == 0){
+                                            echo "<img class='image_upload_preview' id='image_preview_2' src='/img/misc/alpha.png'/>\n";
+                                            echo "<input type='button' style='display:none;' onClick='delete_image(2, image_preview_2, this);' value='Eliminar'";
+                                        }
+                                        else{
+                                            $r_img = mysqli_fetch_array($q_img);
+                                            echo "<img class='image_upload_preview' style='display:block;' id='image_preview_2' src='http://$default_host/img/blog/miniature/$r_img[image]'/>\n";
+                                            echo "<input type='button' style='display:block;' onClick='delete_image(2, image_preview_2, this);' value='Eliminar'";
+                                        }
+                                    ?>
+                                    <br/><br/>
+                                    <input type="hidden" name="delete_image_2" id="delete_image_2" value="no"/>
+                                    <input id="image_2" onchange="preview_image(2, this, image_preview_0);" type="file" name="image_2" accept="image/x-png, image/gif, image/jpeg"/>
+                                </div>
+                                <div class="image_upload_container">
+                                    <?php
+                                        $q_img = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id AND idx = 3");
+                                        if (mysqli_num_rows($q_img) == 0){
+                                            echo "<img class='image_upload_preview' id='image_preview_3' src='/img/misc/alpha.png'/>\n";
+                                            echo "<input type='button' style='display:none;' onClick='delete_image(3, image_preview_3, this);' value='Eliminar'";
+                                        }
+                                        else{
+                                            $r_img = mysqli_fetch_array($q_img);
+                                            echo "<img class='image_upload_preview' style='display:block;' id='image_preview_3' src='http://$default_host/img/blog/miniature/$r_img[image]'/>\n";
+                                            echo "<input type='button' style='display:block;' onClick='delete_image(3, image_preview_3, this);' value='Eliminar'";
+                                        }
+                                    ?>
+                                    <br/><br/>
+                                    <input type="hidden" name="delete_image_3" id="delete_image_3" value="no"/>
+                                    <input id="image_3" onchange="preview_image(3, this, image_preview_0);" type="file" name="image_3" accept="image/x-png, image/gif, image/jpeg"/>
+                                </div>
+                            </li>
+                        </ul>
+                    </div>
+                    <div class="entry" id="settings">
+                        <h4>Ajustes</h4>
+                        <label><input type="checkbox" name="visible" <?php if ($r['visible'] == 1) echo 'checked'; ?>/>Post visible</label><br/><br/>
+                        <label><input type="checkbox" name="comments" <?php if ($r['comments'] == 1) echo 'checked'; ?>/>Permitir comentarios</label><br/><br/>
+                        <br/><br/><br/><br/>
+                        <div id="add_button_container">
+                            <input type="button" value="Previsualizar" onClick="alert(validate_post());"/> <!--TODO-->
+                            <br/>
+                            <input type="submit" value="Publicar"/>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </body>
 </html>
 
 <?php
-		}
-	}
+        }
+    }
 ?>

+ 110 - 110
www-admin/blog/edit/script.js

@@ -1,124 +1,124 @@
 function validate_post(){
-	var text_es = document.getElementById('text_es').value;
-	var text_eu = document.getElementById('text_eu').value;
-	var text_en = document.getElementById('text_en').value;
-	var title_es = document.getElementById('title_es').value;
-	var title_eu = document.getElementById('title_eu').value;
-	var title_en = document.getElementById('title_en').value;
-	result = true;
-	
-	//Spanish fields empty
-	if (title_es.length < 1){
-		result = false;
-		alert("Introduce un titulo en castellano");
-		return false;
-	}
-	if (text_es.length < 1){
-		result = false;
-		alert("Introduce un texto en castellano");
-		return false;
-	}
-	
-	//Titles without texts
-	if (title_eu.length > 0 && text_eu.length < 1){
-		result = false;
-		alert("Introduce un texto o borra el titulo en euskera")
-		return false;
-	}
-	if (title_en.length > 0 && text_en.length < 1){
-		result = false;
-		alert("Introduce un texto o borra el titulo en ingles")
-		return false;
-	}
-	
-	//Text without titles
-	if (text_eu.length > 0 && title_eu.length < 1){
-		result = false;
-		alert("Introduce un titulo o borra el texto en euskera")
-		return false;
-	}
-	if (text_en.length > 0 && title_en.length < 1){
-		result = false;
-		alert("Introduce un titulo o borra el texto en ingles")
-		return false;
-	}
-	return true;
+    var text_es = document.getElementById('text_es').value;
+    var text_eu = document.getElementById('text_eu').value;
+    var text_en = document.getElementById('text_en').value;
+    var title_es = document.getElementById('title_es').value;
+    var title_eu = document.getElementById('title_eu').value;
+    var title_en = document.getElementById('title_en').value;
+    result = true;
+    
+    //Spanish fields empty
+    if (title_es.length < 1){
+        result = false;
+        alert("Introduce un titulo en castellano");
+        return false;
+    }
+    if (text_es.length < 1){
+        result = false;
+        alert("Introduce un texto en castellano");
+        return false;
+    }
+    
+    //Titles without texts
+    if (title_eu.length > 0 && text_eu.length < 1){
+        result = false;
+        alert("Introduce un texto o borra el titulo en euskera")
+        return false;
+    }
+    if (title_en.length > 0 && text_en.length < 1){
+        result = false;
+        alert("Introduce un texto o borra el titulo en ingles")
+        return false;
+    }
+    
+    //Text without titles
+    if (text_eu.length > 0 && title_eu.length < 1){
+        result = false;
+        alert("Introduce un titulo o borra el texto en euskera")
+        return false;
+    }
+    if (text_en.length > 0 && title_en.length < 1){
+        result = false;
+        alert("Introduce un titulo o borra el texto en ingles")
+        return false;
+    }
+    return true;
 }
 
 
 
 function formatText(textarea, format){
-	
-	var text = textarea.value;
-	var selectedText= window.getSelection().toString();
-	event.preventDefault();
-	//IE
-	if (document.selection != undefined){
-		textarea.focus();
-		var selection = document.selection.createRange();
-		selectedText = selection.text;
-	}
-	
-	//Mozilla
-	else if (textarea.selectionStart != undefined){
-		var startPos = textarea.selectionStart;
-		var endPos = textarea.selectionEnd;
-		selectedText = textarea.value.substring(startPos, endPos);
-	}
-	
-	var replace;
-	switch (format){
-		case "italic":
-			replace = "<span style='font-style:italic;'>" + selectedText + "</span>";
-			break;
-		case "bold":
-			replace = "<span style='font-weight:bold;'>" + selectedText + "</span>";
-			break;
-		case "underline":
-			replace = "<span style='text-decoration:underline;'>" + selectedText + "</span>";
-			break;
-		case "stroke":
-			replace = "<span style='text-decoration:line-through;'>" + selectedText + "</span>";
-			break;
-		case "link":
-			replace = "<a href='" + selectedText + "'>" + selectedText + "</a>";
-			break;
-		case "color-red":
-			replace = "<span style='color:#f00;'>" + selectedText + "</span>";
-			break;
-		case "color-green":
-			replace = "<span style='color:#0f0;'>" + selectedText + "</span>";
-			break;
-		case "color-blue":
-			replace = "<span style='color:#00f;'>" + selectedText + "</span>";
-			break;
-		default:
-			replace = selectedText;
-	}
-	
-	if (selectedText.length  >0 && text != replace){
-		text = text.replace(selectedText, replace);
-		textarea.value = text;
-	}
+    
+    var text = textarea.value;
+    var selectedText= window.getSelection().toString();
+    event.preventDefault();
+    //IE
+    if (document.selection != undefined){
+        textarea.focus();
+        var selection = document.selection.createRange();
+        selectedText = selection.text;
+    }
+    
+    //Mozilla
+    else if (textarea.selectionStart != undefined){
+        var startPos = textarea.selectionStart;
+        var endPos = textarea.selectionEnd;
+        selectedText = textarea.value.substring(startPos, endPos);
+    }
+    
+    var replace;
+    switch (format){
+        case "italic":
+            replace = "<span style='font-style:italic;'>" + selectedText + "</span>";
+            break;
+        case "bold":
+            replace = "<span style='font-weight:bold;'>" + selectedText + "</span>";
+            break;
+        case "underline":
+            replace = "<span style='text-decoration:underline;'>" + selectedText + "</span>";
+            break;
+        case "stroke":
+            replace = "<span style='text-decoration:line-through;'>" + selectedText + "</span>";
+            break;
+        case "link":
+            replace = "<a href='" + selectedText + "'>" + selectedText + "</a>";
+            break;
+        case "color-red":
+            replace = "<span style='color:#f00;'>" + selectedText + "</span>";
+            break;
+        case "color-green":
+            replace = "<span style='color:#0f0;'>" + selectedText + "</span>";
+            break;
+        case "color-blue":
+            replace = "<span style='color:#00f;'>" + selectedText + "</span>";
+            break;
+        default:
+            replace = selectedText;
+    }
+    
+    if (selectedText.length  >0 && text != replace){
+        text = text.replace(selectedText, replace);
+        textarea.value = text;
+    }
 }
 
 function preview_image(id, source, target, button) {
-	var reader = new FileReader();
-	reader.readAsDataURL(source.files[0]);
+    var reader = new FileReader();
+    reader.readAsDataURL(source.files[0]);
 
-	reader.onload = function (reader_event) {
-		target.src = reader_event.target.result;
-		target.style.border = "2px solid black";
-		target.style.marginTop = 10 + "px";
-		target.style.marginBottom = 10 + "px";
-		target.style.display = "block";
-		document.getElementById("delete_image_" + id).value = "no";
-	};
+    reader.onload = function (reader_event) {
+        target.src = reader_event.target.result;
+        target.style.border = "2px solid black";
+        target.style.marginTop = 10 + "px";
+        target.style.marginBottom = 10 + "px";
+        target.style.display = "block";
+        document.getElementById("delete_image_" + id).value = "no";
+    };
 };
 
 function delete_image(id, target, button){
-	target.src = "/img/misc/alpha.png";
-	target.style.display = "none";
-	button.style.display = "none";
-	document.getElementById("delete_image_" + id).value = "yes";
+    target.src = "/img/misc/alpha.png";
+    target.style.display = "none";
+    button.style.display = "none";
+    document.getElementById("delete_image_" + id).value = "yes";
 }

+ 102 - 102
www-admin/blog/index.php

@@ -1,107 +1,107 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	$default_host = substr($http_host, 0, strpos($http_host, ':'));
-	include("../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
+    $http_host = $_SERVER['HTTP_HOST'];
+    $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    include("../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
 ?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Blog - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="script.js"></script>
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-		<?php include('../toolbar.php'); ?>
-		<div id='content'>
-			<div class="section">
-				<h3 class="section_title">Entradas del blog - <a href="/blog/add/">A&ntilde;adir nueva</a></h3>
-				<div class="entry">
-					<table id='blog_post_list'>
-						<tr>
-							<th>Titulo</th>
-							<th>Texto</th>
-							<th>Detalles</th>
-							<th>Traducciones</th>
-							<th>Accion</th>
-						</tr>
-						<?php
-							$query = mysqli_query($con, "SELECT id, title_es, title_eu, title_en, text_es, text_eu, text_en, user, visible, comments, DATE_FORMAT(dtime, '%b %d, %Y %H:%i:%s') AS ptime, permalink FROM post ORDER BY id DESC;");
-							while ($r = mysqli_fetch_array($query)){
-								echo "<tr>\n<td class='blog_column_title'><a href='https://margolariak.com/blog/$r[permalink]'>" . cutText($r['title_es'], 35, '', '') . "</a></td>";
-								echo "<td class='blog_column_text'>" . str_replace('<br/>', ' ', cutText($r['text_es'], 60, '', '')) . "\n";
-								
-								$q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $r[id] ORDER BY idx;");
-								if (mysqli_num_rows($q_image) > 0){
-									echo "<br/>";
-									while ($r_image = mysqli_fetch_array($q_image))
-										echo "<img src='http://$default_host/img/blog/miniature/$r_image[image]'\>\n";
-								}
-								
-								echo "</td>\n";
-								$q_user = mysqli_query($con, "SELECT username FROM user WHERE id = $r[user];");
-								$r_user = mysqli_fetch_array($q_user);
-								echo "<td class='blog_column_details'>$r[ptime]<br/>Por $r_user[username]<br/>Comentarios:";
-								if ($r['comments'] == 1){
-									$q_comments = mysqli_query($con, "SELECT id FROM post_comment WHERE post = $r[id];");
-									echo "Si (" . mysqli_num_rows($q_comments) . ")";
-								}
-								else
-									echo "No";
-								echo "<br/>Visible: ";
-								if ($r['visible'] == 1)
-									echo "Si";
-								else
-									echo "No";
-								echo "</td>\n<td class='blog_column_translations'>\n"; //TODO percent
-								
-								
-								$total = 2; //Title and text are mandatory
-								$translated_en = 0;
-								$translated_eu = 0;
-								
-								//Calculate field number
-								if ($r['title_en'] != $r['title_es']){
-									$translated_en ++;
-								}
-								if ($r['title_eu'] != $r['title_es']){
-									$translated_eu ++;
-								}
-								if ($r['text_en'] != $r['text_es']){
-									$translated_en ++;
-								}
-								if ($r['text_eu'] != $r['text_es']){
-									$translated_eu ++;
-								}
-								
-								//Calculate percents
-								echo "Ingl&eacute;s: " . intval($translated_en * 100 / $total) . "%<br/>Euskera: " . intval($translated_eu * 100 / $total) . "%\n";
-								
-								
-								echo "\n</td>\n<td class='blog_column_action'>\n<form method='get' action='http://$http_host/blog/edit/index.php'>\n<input type='submit' value='Editar / Traducir'/>\n<input type='hidden' name='p' value='$r[id]'/></form>\n";
-								echo "<input type='button' onClick='delete_post($r[id], \"$r[title_es]\");' value='Borrar'/>";
-								echo "<form action='/blog/moderate/moderate.php?p=$r[id]'>\n<input type='submit' value='Moderar comentarios'/>\n</form>";
-								echo "</td>\n</tr>";
-							}
-							
-						?>
-					</table>
-				</div>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Blog - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+        <?php include('../toolbar.php'); ?>
+        <div id='content'>
+            <div class="section">
+                <h3 class="section_title">Entradas del blog - <a href="/blog/add/">A&ntilde;adir nueva</a></h3>
+                <div class="entry">
+                    <table id='blog_post_list'>
+                        <tr>
+                            <th>Titulo</th>
+                            <th>Texto</th>
+                            <th>Detalles</th>
+                            <th>Traducciones</th>
+                            <th>Accion</th>
+                        </tr>
+                        <?php
+                            $query = mysqli_query($con, "SELECT id, title_es, title_eu, title_en, text_es, text_eu, text_en, user, visible, comments, DATE_FORMAT(dtime, '%b %d, %Y %H:%i:%s') AS ptime, permalink FROM post ORDER BY id DESC;");
+                            while ($r = mysqli_fetch_array($query)){
+                                echo "<tr>\n<td class='blog_column_title'><a href='https://margolariak.com/blog/$r[permalink]'>" . cutText($r['title_es'], 35, '', '') . "</a></td>";
+                                echo "<td class='blog_column_text'>" . str_replace('<br/>', ' ', cutText($r['text_es'], 60, '', '')) . "\n";
+                                
+                                $q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $r[id] ORDER BY idx;");
+                                if (mysqli_num_rows($q_image) > 0){
+                                    echo "<br/>";
+                                    while ($r_image = mysqli_fetch_array($q_image))
+                                        echo "<img src='http://$default_host/img/blog/miniature/$r_image[image]'\>\n";
+                                }
+                                
+                                echo "</td>\n";
+                                $q_user = mysqli_query($con, "SELECT username FROM user WHERE id = $r[user];");
+                                $r_user = mysqli_fetch_array($q_user);
+                                echo "<td class='blog_column_details'>$r[ptime]<br/>Por $r_user[username]<br/>Comentarios:";
+                                if ($r['comments'] == 1){
+                                    $q_comments = mysqli_query($con, "SELECT id FROM post_comment WHERE post = $r[id];");
+                                    echo "Si (" . mysqli_num_rows($q_comments) . ")";
+                                }
+                                else
+                                    echo "No";
+                                echo "<br/>Visible: ";
+                                if ($r['visible'] == 1)
+                                    echo "Si";
+                                else
+                                    echo "No";
+                                echo "</td>\n<td class='blog_column_translations'>\n"; //TODO percent
+                                
+                                
+                                $total = 2; //Title and text are mandatory
+                                $translated_en = 0;
+                                $translated_eu = 0;
+                                
+                                //Calculate field number
+                                if ($r['title_en'] != $r['title_es']){
+                                    $translated_en ++;
+                                }
+                                if ($r['title_eu'] != $r['title_es']){
+                                    $translated_eu ++;
+                                }
+                                if ($r['text_en'] != $r['text_es']){
+                                    $translated_en ++;
+                                }
+                                if ($r['text_eu'] != $r['text_es']){
+                                    $translated_eu ++;
+                                }
+                                
+                                //Calculate percents
+                                echo "Ingl&eacute;s: " . intval($translated_en * 100 / $total) . "%<br/>Euskera: " . intval($translated_eu * 100 / $total) . "%\n";
+                                
+                                
+                                echo "\n</td>\n<td class='blog_column_action'>\n<form method='get' action='http://$http_host/blog/edit/index.php'>\n<input type='submit' value='Editar / Traducir'/>\n<input type='hidden' name='p' value='$r[id]'/></form>\n";
+                                echo "<input type='button' onClick='delete_post($r[id], \"$r[title_es]\");' value='Borrar'/>";
+                                echo "<form action='/blog/moderate/moderate.php?p=$r[id]'>\n<input type='submit' value='Moderar comentarios'/>\n</form>";
+                                echo "</td>\n</tr>";
+                            }
+                            
+                        ?>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </body>
 </html>
 <?php } ?>

+ 27 - 27
www-admin/blog/moderate/index.php

@@ -1,35 +1,35 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
 ?>
 
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Moderar comentarios - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="script.js"></script>
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-	<?php include('../../toolbar.php'); ?>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Moderar comentarios - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+    <?php include('../../toolbar.php'); ?>
                 <div id='content'>
                         <div class="section">
                                 <h3 class="section_title">Moderar comentarios</h3>
-				<h4 span class="TODO">En construcci&oacute;n</h4>
-			</div>
-		</div>
-	</body>
+                <h4 span class="TODO">En construcci&oacute;n</h4>
+            </div>
+        </div>
+    </body>
 </html>

+ 21 - 21
www-admin/blog/script.js

@@ -1,23 +1,23 @@
 function delete_post(id, title){
-	if (confirm("Seguro que deseas borrar el post '" + title + "'? Esta accion es irreversible.")){
-		//window.location.href = "/blog/delete/delete.php?p=" + id;
-		
-		var xmlhttp;
-		if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
-			xmlhttp=new XMLHttpRequest();
-		}
-		else{// code for IE6, IE5
-			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
-		}
-		xmlhttp.onreadystatechange=function(){
-			if (xmlhttp.readyState==4 && xmlhttp.status==200){
-				//document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
-				location.reload();
-			}
-		}
-		xmlhttp.open("GET","/blog/delete/delete.php?p=" + id, true);
-		xmlhttp.send();
-		
-		//location.reload();
-	}
+    if (confirm("Seguro que deseas borrar el post '" + title + "'? Esta accion es irreversible.")){
+        //window.location.href = "/blog/delete/delete.php?p=" + id;
+        
+        var xmlhttp;
+        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
+            xmlhttp=new XMLHttpRequest();
+        }
+        else{// code for IE6, IE5
+            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
+        }
+        xmlhttp.onreadystatechange=function(){
+            if (xmlhttp.readyState==4 && xmlhttp.status==200){
+                //document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
+                location.reload();
+            }
+        }
+        xmlhttp.open("GET","/blog/delete/delete.php?p=" + id, true);
+        xmlhttp.send();
+        
+        //location.reload();
+    }
 }

+ 36 - 36
www-admin/blog/translate/apply.php

@@ -1,38 +1,38 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb('rw');
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	//Get activity fields
-	$id = mysqli_real_escape_string($con, $_POST['id']);
-	$title_en = mysqli_real_escape_string($con, $_POST['title_en']);
-	$text_en = mysqli_real_escape_string($con, $_POST['text_en']);
-	$title_eu = mysqli_real_escape_string($con, $_POST['title_eu']);
-	$text_eu = mysqli_real_escape_string($con, $_POST['text_eu']);
-	
-	//Get current activity data
-	$q = mysqli_query($con, "SELECT * FROM post WHERE id = $id");
-	if (mysqli_num_rows($q) > 0){
-		$r = mysqli_fetch_array($q);
-		
-		//Update activity fields
-		if (strlen($title_en) > 0 && $title_en != $r['title_en']){
-			mysqli_query($con, "UPDATE post SET title_en = '$title_en' WHERE id = $id;");
-		}
-		if (strlen($text_en) > 0 && $text_en != $r['text_en']){
-			mysqli_query($con, "UPDATE post SET text_en = '$text_en' WHERE id = $id;");
-		}
-		if (strlen($title_eu) > 0 && $title_eu != $r['title_eu']){
-			mysqli_query($con, "UPDATE post SET title_eu = '$title_eu' WHERE id = $id;");
-		}
-		if (strlen($text_eu) > 0 && $text_eu != $r['text_eu']){
-			mysqli_query($con, "UPDATE post SET text_eu = '$text_eu' WHERE id = $id;");
-		}
-		version();
-	}
-	
-	header("Location: /blog/translate/index.php");	
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb('rw');
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    //Get activity fields
+    $id = mysqli_real_escape_string($con, $_POST['id']);
+    $title_en = mysqli_real_escape_string($con, $_POST['title_en']);
+    $text_en = mysqli_real_escape_string($con, $_POST['text_en']);
+    $title_eu = mysqli_real_escape_string($con, $_POST['title_eu']);
+    $text_eu = mysqli_real_escape_string($con, $_POST['text_eu']);
+    
+    //Get current activity data
+    $q = mysqli_query($con, "SELECT * FROM post WHERE id = $id");
+    if (mysqli_num_rows($q) > 0){
+        $r = mysqli_fetch_array($q);
+        
+        //Update activity fields
+        if (strlen($title_en) > 0 && $title_en != $r['title_en']){
+            mysqli_query($con, "UPDATE post SET title_en = '$title_en' WHERE id = $id;");
+        }
+        if (strlen($text_en) > 0 && $text_en != $r['text_en']){
+            mysqli_query($con, "UPDATE post SET text_en = '$text_en' WHERE id = $id;");
+        }
+        if (strlen($title_eu) > 0 && $title_eu != $r['title_eu']){
+            mysqli_query($con, "UPDATE post SET title_eu = '$title_eu' WHERE id = $id;");
+        }
+        if (strlen($text_eu) > 0 && $text_eu != $r['text_eu']){
+            mysqli_query($con, "UPDATE post SET text_eu = '$text_eu' WHERE id = $id;");
+        }
+        version();
+    }
+    
+    header("Location: /blog/translate/index.php");    
 ?>

+ 59 - 59
www-admin/blog/translate/index.php

@@ -1,63 +1,63 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{?>
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Taducir posts - Administraci&oacute;n</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-		<?php include('../../toolbar.php'); ?>
-		<div id='content'>
-			<div class='section'>
-				<h3>Lista de posts en el blog</h3>
-				<div class='entry'>
-					<?php
-						$q = mysqli_query($con, "SELECT * FROM post;");
-						echo "<table class='translation_table'><tr><th>Nombre</th><th>Ingles</th><th>Euskera</th></tr>\n";
-						while ($r = mysqli_fetch_array($q)){
-							echo "<tr><td><a href='http://$http_host/blog/translate/translate.php?id=$r[id]'>$r[title_es]</a></td>";
-							$total = 2; //Title and text are mandatory
-							$translated_en = 0;
-							$translated_eu = 0;
-							
-							//Calculate field number
-							if ($r['title_en'] != $r['title_es']){
-								$translated_en ++;
-							}
-							if ($r['title_eu'] != $r['title_es']){
-								$translated_eu ++;
-							}
-							if ($r['text_en'] != $r['text_es']){
-								$translated_en ++;
-							}
-							if ($r['text_eu'] != $r['text_es']){
-								$translated_eu ++;
-							}
-							
-							//Calculate percents
-							echo "<td>" . intval($translated_en * 100 / $total) . "%</td><td>" . intval($translated_eu * 100 / $total) . "%</td></tr>\n";
-						}
-						echo "</table>\n";
-					?>
-				</div>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Taducir posts - Administraci&oacute;n</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+        <?php include('../../toolbar.php'); ?>
+        <div id='content'>
+            <div class='section'>
+                <h3>Lista de posts en el blog</h3>
+                <div class='entry'>
+                    <?php
+                        $q = mysqli_query($con, "SELECT * FROM post;");
+                        echo "<table class='translation_table'><tr><th>Nombre</th><th>Ingles</th><th>Euskera</th></tr>\n";
+                        while ($r = mysqli_fetch_array($q)){
+                            echo "<tr><td><a href='http://$http_host/blog/translate/translate.php?id=$r[id]'>$r[title_es]</a></td>";
+                            $total = 2; //Title and text are mandatory
+                            $translated_en = 0;
+                            $translated_eu = 0;
+                            
+                            //Calculate field number
+                            if ($r['title_en'] != $r['title_es']){
+                                $translated_en ++;
+                            }
+                            if ($r['title_eu'] != $r['title_es']){
+                                $translated_eu ++;
+                            }
+                            if ($r['text_en'] != $r['text_es']){
+                                $translated_en ++;
+                            }
+                            if ($r['text_eu'] != $r['text_es']){
+                                $translated_eu ++;
+                            }
+                            
+                            //Calculate percents
+                            echo "<td>" . intval($translated_en * 100 / $total) . "%</td><td>" . intval($translated_eu * 100 / $total) . "%</td></tr>\n";
+                        }
+                        echo "</table>\n";
+                    ?>
+                </div>
+            </div>
+        </div>
+    </body>
 </html>
 <?php } ?>

+ 70 - 70
www-admin/blog/translate/translate.php

@@ -1,74 +1,74 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
-		$id = mysqli_real_escape_string($con, $_GET['id']);
-		$q = mysqli_query($con, "SELECT * FROM post WHERE id = $id");
-		if(mysqli_num_rows($q) == 0){
-			header("Location: $http_host/blog/translate/");
-			exit (-1);
-		}
-		else{
-			$r = mysqli_fetch_array($q);
-	?>
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+        $id = mysqli_real_escape_string($con, $_GET['id']);
+        $q = mysqli_query($con, "SELECT * FROM post WHERE id = $id");
+        if(mysqli_num_rows($q) == 0){
+            header("Location: $http_host/blog/translate/");
+            exit (-1);
+        }
+        else{
+            $r = mysqli_fetch_array($q);
+    ?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Taducir <?php echo $r['title_es']; ?> - Administraci&oacute;n</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="script.js"></script>
-		<script type="text/javascript" src="/script/ui.js"></script>
-		<script src="../../ckeditor/ckeditor.js"></script>
-	</head>
-	<body>
-		<?php include('../../toolbar.php'); ?>
-		<div id='content'>
-			<div class='section'>
-				<?php
-					echo "<h3>Taducir &#8216;$r[title_es]&#8217;</h3>\n";
-					echo "<div id='translation_instructions' class='entry'><h4>C&oacute;mo traducir</h4>\n";
-					echo "<ul><li>Rellena los campos de abajo para el idioma correspondiente (columna de en medio para ingl&eacute;s, derecha para euskera)</li>\n";
-					echo "<li>No es necesario traducir todos los campos ni todos los idiomas. Traduce solo lo que sepas y quieras.</li>\n";
-					echo "<li>Al terminar, recuerda pulsar el boton &#8216;Guardar&#8217; al final de la p&acute;gina.</li>\n";
-					echo "<li>Muchas gracias por tu trabajo!</li></ul>\n";
-					echo "</div><br/><br/>\n";
-					echo "<form method='post' action='http://$http_host/blog/translate/apply.php'>\n";
-					echo "<input type='hidden' name='id' value='$r[id]'/>\n";
-					echo "<table id='table_translate_languages'><tr>\n";
-					
-					echo "<td class='translate_language'><div class='entry translation'>\n";
-					echo "<h3>Castellano</h4><div class='translate_row_title'>\n<span class='bold'>T&iacute;tulo: </span>$r[title_es]</div>\n";
-					echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><p>$r[text_es]</p></div>\n";
-					echo "</div></td>\n";
-					
-					echo "<td class='translate_language'><div class='entry translation'>\n";
-					echo "<h3>Ingl&eacute;s</h4>\n<div class='translate_row_title'><span class='bold'>T&iacute;tulo: </span><input type='text' name='title_en' required value='$r[title_en]'/></div>\n";
-					echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><textarea  name='text_en' required>$r[text_en]</textarea></div>\n";
-					echo "<script>CKEDITOR.replace('text_en');</script>\n";
-					echo "</div></td>\n";
-					
-					echo "<td class='translate_language'><div class='entry translation'>\n";
-					echo "<h3>Euskera</h4><div class='translate_row_title'>\n<span class='bold'>T&iacute;tulo: </span><input required type='text' name='title_eu' required value='$r[title_eu]'/></div>\n";
-					echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><textarea name='text_eu' required>$r[text_eu]</textarea></div>\n";
-					echo "<script>CKEDITOR.replace('text_eu');</script>\n";
-					echo "</div></td>\n";
-					
-					echo "</tr></table><div id='translate_controls'><input type='submit' value='Guardar'/><input type='button' value='Cancelar y salir' onClick='exitTranslation();'/></div></form>\n";
-				?>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Taducir <?php echo $r['title_es']; ?> - Administraci&oacute;n</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+        <script type="text/javascript" src="/script/ui.js"></script>
+        <script src="../../ckeditor/ckeditor.js"></script>
+    </head>
+    <body>
+        <?php include('../../toolbar.php'); ?>
+        <div id='content'>
+            <div class='section'>
+                <?php
+                    echo "<h3>Taducir &#8216;$r[title_es]&#8217;</h3>\n";
+                    echo "<div id='translation_instructions' class='entry'><h4>C&oacute;mo traducir</h4>\n";
+                    echo "<ul><li>Rellena los campos de abajo para el idioma correspondiente (columna de en medio para ingl&eacute;s, derecha para euskera)</li>\n";
+                    echo "<li>No es necesario traducir todos los campos ni todos los idiomas. Traduce solo lo que sepas y quieras.</li>\n";
+                    echo "<li>Al terminar, recuerda pulsar el boton &#8216;Guardar&#8217; al final de la p&acute;gina.</li>\n";
+                    echo "<li>Muchas gracias por tu trabajo!</li></ul>\n";
+                    echo "</div><br/><br/>\n";
+                    echo "<form method='post' action='http://$http_host/blog/translate/apply.php'>\n";
+                    echo "<input type='hidden' name='id' value='$r[id]'/>\n";
+                    echo "<table id='table_translate_languages'><tr>\n";
+                    
+                    echo "<td class='translate_language'><div class='entry translation'>\n";
+                    echo "<h3>Castellano</h4><div class='translate_row_title'>\n<span class='bold'>T&iacute;tulo: </span>$r[title_es]</div>\n";
+                    echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><p>$r[text_es]</p></div>\n";
+                    echo "</div></td>\n";
+                    
+                    echo "<td class='translate_language'><div class='entry translation'>\n";
+                    echo "<h3>Ingl&eacute;s</h4>\n<div class='translate_row_title'><span class='bold'>T&iacute;tulo: </span><input type='text' name='title_en' required value='$r[title_en]'/></div>\n";
+                    echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><textarea  name='text_en' required>$r[text_en]</textarea></div>\n";
+                    echo "<script>CKEDITOR.replace('text_en');</script>\n";
+                    echo "</div></td>\n";
+                    
+                    echo "<td class='translate_language'><div class='entry translation'>\n";
+                    echo "<h3>Euskera</h4><div class='translate_row_title'>\n<span class='bold'>T&iacute;tulo: </span><input required type='text' name='title_eu' required value='$r[title_eu]'/></div>\n";
+                    echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><textarea name='text_eu' required>$r[text_eu]</textarea></div>\n";
+                    echo "<script>CKEDITOR.replace('text_eu');</script>\n";
+                    echo "</div></td>\n";
+                    
+                    echo "</tr></table><div id='translate_controls'><input type='submit' value='Guardar'/><input type='button' value='Cancelar y salir' onClick='exitTranslation();'/></div></form>\n";
+                ?>
+            </div>
+        </div>
+    </body>
 </html>
 <?php } } ?>

+ 46 - 46
www-admin/ckeditor/build-config.js

@@ -25,50 +25,50 @@
  */
 
 var CKBUILDER_CONFIG = {
-	skin: 'moono',
-	preset: 'basic',
-	ignore: [
-		'.bender',
-		'bender.js',
-		'bender-err.log',
-		'bender-out.log',
-		'dev',
-		'.DS_Store',
-		'.editorconfig',
-		'.gitattributes',
-		'.gitignore',
-		'gruntfile.js',
-		'.idea',
-		'.jscsrc',
-		'.jshintignore',
-		'.jshintrc',
-		'less',
-		'.mailmap',
-		'node_modules',
-		'package.json',
-		'README.md',
-		'tests'
-	],
-	plugins : {
-		'about' : 1,
-		'basicstyles' : 1,
-		'colorbutton' : 1,
-		'colordialog' : 1,
-		'enterkey' : 1,
-		'entities' : 1,
-		'floatingspace' : 1,
-		'indentlist' : 1,
-		'link' : 1,
-		'list' : 1,
-		'removeformat' : 1,
-		'toolbar' : 1,
-		'undo' : 1,
-		'wysiwygarea' : 1,
-		'youtube' : 1
-	},
-	languages : {
-		'en' : 1,
-		'es' : 1,
-		'eu' : 1
-	}
+    skin: 'moono',
+    preset: 'basic',
+    ignore: [
+        '.bender',
+        'bender.js',
+        'bender-err.log',
+        'bender-out.log',
+        'dev',
+        '.DS_Store',
+        '.editorconfig',
+        '.gitattributes',
+        '.gitignore',
+        'gruntfile.js',
+        '.idea',
+        '.jscsrc',
+        '.jshintignore',
+        '.jshintrc',
+        'less',
+        '.mailmap',
+        'node_modules',
+        'package.json',
+        'README.md',
+        'tests'
+    ],
+    plugins : {
+        'about' : 1,
+        'basicstyles' : 1,
+        'colorbutton' : 1,
+        'colordialog' : 1,
+        'enterkey' : 1,
+        'entities' : 1,
+        'floatingspace' : 1,
+        'indentlist' : 1,
+        'link' : 1,
+        'list' : 1,
+        'removeformat' : 1,
+        'toolbar' : 1,
+        'undo' : 1,
+        'wysiwygarea' : 1,
+        'youtube' : 1
+    },
+    languages : {
+        'en' : 1,
+        'es' : 1,
+        'eu' : 1
+    }
 };

+ 24 - 24
www-admin/ckeditor/config.js

@@ -4,31 +4,31 @@
  */
 
 CKEDITOR.editorConfig = function( config ) {
-	// Define changes to default configuration here.
-	// For complete reference see:
-	// http://docs.ckeditor.com/#!/api/CKEDITOR.config
+    // Define changes to default configuration here.
+    // For complete reference see:
+    // http://docs.ckeditor.com/#!/api/CKEDITOR.config
 
-	// The toolbar groups arrangement, optimized for a single toolbar row.
-	config.toolbarGroups = [
-		{ name: 'document',	   groups: [ 'mode', 'document', 'doctools' ] },
-		{ name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },
-		{ name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
-		{ name: 'forms' },
-		{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
-		{ name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
-		{ name: 'links' },
-		{ name: 'insert' },
-		{ name: 'styles' },
-		{ name: 'colors' },
-		{ name: 'tools' },
-		{ name: 'others' },
-		{ name: 'about' }
-	];
+    // The toolbar groups arrangement, optimized for a single toolbar row.
+    config.toolbarGroups = [
+        { name: 'document',       groups: [ 'mode', 'document', 'doctools' ] },
+        { name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },
+        { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
+        { name: 'forms' },
+        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
+        { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
+        { name: 'links' },
+        { name: 'insert' },
+        { name: 'styles' },
+        { name: 'colors' },
+        { name: 'tools' },
+        { name: 'others' },
+        { name: 'about' }
+    ];
 
-	// The default plugins included in the basic setup define some buttons that
-	// are not needed in a basic editor. They are removed here.
-	config.removeButtons = 'Cut,Copy,Paste,Undo,Redo,Anchor,Underline,Strike,Subscript,Superscript';
+    // The default plugins included in the basic setup define some buttons that
+    // are not needed in a basic editor. They are removed here.
+    config.removeButtons = 'Cut,Copy,Paste,Undo,Redo,Anchor,Underline,Strike,Subscript,Superscript';
 
-	// Dialog windows are also simplified.
-	config.removeDialogTabs = 'link:advanced';
+    // Dialog windows are also simplified.
+    config.removeDialogTabs = 'link:advanced';
 };

+ 60 - 60
www-admin/ckeditor/contents.css

@@ -5,131 +5,131 @@ For licensing, see LICENSE.md or http://ckeditor.com/license
 
 body
 {
-	/* Font */
-	font-family: sans-serif, Arial, Verdana, "Trebuchet MS";
-	font-size: 12px;
+    /* Font */
+    font-family: sans-serif, Arial, Verdana, "Trebuchet MS";
+    font-size: 12px;
 
-	/* Text color */
-	color: #333;
+    /* Text color */
+    color: #333;
 
-	/* Remove the background color to make it transparent */
-	background-color: #fff;
+    /* Remove the background color to make it transparent */
+    background-color: #fff;
 
-	margin: 20px;
+    margin: 20px;
 }
 
 .cke_editable
 {
-	font-size: 13px;
-	line-height: 1.6;
+    font-size: 13px;
+    line-height: 1.6;
 
-	/* Fix for missing scrollbars with RTL texts. (#10488) */
-	word-wrap: break-word;
+    /* Fix for missing scrollbars with RTL texts. (#10488) */
+    word-wrap: break-word;
 }
 
 blockquote
 {
-	font-style: italic;
-	font-family: Georgia, Times, "Times New Roman", serif;
-	padding: 2px 0;
-	border-style: solid;
-	border-color: #ccc;
-	border-width: 0;
+    font-style: italic;
+    font-family: Georgia, Times, "Times New Roman", serif;
+    padding: 2px 0;
+    border-style: solid;
+    border-color: #ccc;
+    border-width: 0;
 }
 
 .cke_contents_ltr blockquote
 {
-	padding-left: 20px;
-	padding-right: 8px;
-	border-left-width: 5px;
+    padding-left: 20px;
+    padding-right: 8px;
+    border-left-width: 5px;
 }
 
 .cke_contents_rtl blockquote
 {
-	padding-left: 8px;
-	padding-right: 20px;
-	border-right-width: 5px;
+    padding-left: 8px;
+    padding-right: 20px;
+    border-right-width: 5px;
 }
 
 a
 {
-	color: #0782C1;
+    color: #0782C1;
 }
 
 ol,ul,dl
 {
-	/* IE7: reset rtl list margin. (#7334) */
-	*margin-right: 0px;
-	/* preserved spaces for list items with text direction other than the list. (#6249,#8049)*/
-	padding: 0 40px;
+    /* IE7: reset rtl list margin. (#7334) */
+    *margin-right: 0px;
+    /* preserved spaces for list items with text direction other than the list. (#6249,#8049)*/
+    padding: 0 40px;
 }
 
 h1,h2,h3,h4,h5,h6
 {
-	font-weight: normal;
-	line-height: 1.2;
+    font-weight: normal;
+    line-height: 1.2;
 }
 
 hr
 {
-	border: 0px;
-	border-top: 1px solid #ccc;
+    border: 0px;
+    border-top: 1px solid #ccc;
 }
 
 img.right
 {
-	border: 1px solid #ccc;
-	float: right;
-	margin-left: 15px;
-	padding: 5px;
+    border: 1px solid #ccc;
+    float: right;
+    margin-left: 15px;
+    padding: 5px;
 }
 
 img.left
 {
-	border: 1px solid #ccc;
-	float: left;
-	margin-right: 15px;
-	padding: 5px;
+    border: 1px solid #ccc;
+    float: left;
+    margin-right: 15px;
+    padding: 5px;
 }
 
 pre
 {
-	white-space: pre-wrap; /* CSS 2.1 */
-	word-wrap: break-word; /* IE7 */
-	-moz-tab-size: 4;
-	tab-size: 4;
+    white-space: pre-wrap; /* CSS 2.1 */
+    word-wrap: break-word; /* IE7 */
+    -moz-tab-size: 4;
+    tab-size: 4;
 }
 
 .marker
 {
-	background-color: Yellow;
+    background-color: Yellow;
 }
 
 span[lang]
 {
-	font-style: italic;
+    font-style: italic;
 }
 
 figure
 {
-	text-align: center;
-	border: solid 1px #ccc;
-	border-radius: 2px;
-	background: rgba(0,0,0,0.05);
-	padding: 10px;
-	margin: 10px 20px;
-	display: inline-block;
+    text-align: center;
+    border: solid 1px #ccc;
+    border-radius: 2px;
+    background: rgba(0,0,0,0.05);
+    padding: 10px;
+    margin: 10px 20px;
+    display: inline-block;
 }
 
 figure > figcaption
 {
-	text-align: center;
-	display: block; /* For IE8 */
+    text-align: center;
+    display: block; /* For IE8 */
 }
 
 a > img {
-	padding: 1px;
-	margin: 1px;
-	border: none;
-	outline: 1px solid #0782C1;
+    padding: 1px;
+    margin: 1px;
+    border: none;
+    outline: 1px solid #0782C1;
 }

+ 95 - 95
www-admin/ckeditor/samples/index.html

@@ -5,123 +5,123 @@ For licensing, see LICENSE.md or http://ckeditor.com/license
 -->
 <html>
 <head>
-	<meta charset="utf-8">
-	<title>CKEditor Sample</title>
-	<script src="../ckeditor.js"></script>
-	<script src="js/sample.js"></script>
-	<link rel="stylesheet" href="css/samples.css">
-	<link rel="stylesheet" href="toolbarconfigurator/lib/codemirror/neo.css">
+    <meta charset="utf-8">
+    <title>CKEditor Sample</title>
+    <script src="../ckeditor.js"></script>
+    <script src="js/sample.js"></script>
+    <link rel="stylesheet" href="css/samples.css">
+    <link rel="stylesheet" href="toolbarconfigurator/lib/codemirror/neo.css">
 </head>
 <body id="main">
 
 <nav class="navigation-a">
-	<div class="grid-container">
-		<ul class="navigation-a-left grid-width-70">
-			<li><a href="http://ckeditor.com">Project Homepage</a></li>
-			<li><a href="http://dev.ckeditor.com/">I found a bug</a></li>
-			<li><a href="http://github.com/ckeditor/ckeditor-dev" class="icon-pos-right icon-navigation-a-github">Fork CKEditor on GitHub</a></li>
-		</ul>
-		<ul class="navigation-a-right grid-width-30">
-			<li><a href="http://ckeditor.com/blog-list">CKEditor Blog</a></li>
-		</ul>
-	</div>
+    <div class="grid-container">
+        <ul class="navigation-a-left grid-width-70">
+            <li><a href="http://ckeditor.com">Project Homepage</a></li>
+            <li><a href="http://dev.ckeditor.com/">I found a bug</a></li>
+            <li><a href="http://github.com/ckeditor/ckeditor-dev" class="icon-pos-right icon-navigation-a-github">Fork CKEditor on GitHub</a></li>
+        </ul>
+        <ul class="navigation-a-right grid-width-30">
+            <li><a href="http://ckeditor.com/blog-list">CKEditor Blog</a></li>
+        </ul>
+    </div>
 </nav>
 
 <header class="header-a">
-	<div class="grid-container">
-		<h1 class="header-a-logo grid-width-30">
-			<a href="index.html"><img src="img/logo.png" alt="CKEditor Sample"></a>
-		</h1>
+    <div class="grid-container">
+        <h1 class="header-a-logo grid-width-30">
+            <a href="index.html"><img src="img/logo.png" alt="CKEditor Sample"></a>
+        </h1>
 
-		<nav class="navigation-b grid-width-70">
-			<ul>
-				<li><a href="index.html" class="button-a button-a-background">Start</a></li>
-				<li><a href="toolbarconfigurator/index.html" class="button-a">Toolbar configurator <span class="balloon-a balloon-a-nw">Edit your toolbar now!</span></a></li>
-			</ul>
-		</nav>
-	</div>
+        <nav class="navigation-b grid-width-70">
+            <ul>
+                <li><a href="index.html" class="button-a button-a-background">Start</a></li>
+                <li><a href="toolbarconfigurator/index.html" class="button-a">Toolbar configurator <span class="balloon-a balloon-a-nw">Edit your toolbar now!</span></a></li>
+            </ul>
+        </nav>
+    </div>
 </header>
 
 <main>
-	<div class="adjoined-top">
-		<div class="grid-container">
-			<div class="content grid-width-100">
-				<h1>Congratulations!</h1>
-				<p>
-					If you can see CKEditor below, it means that the installation succeeded.
-					You can now try out your new editor version, see its features, and when you are ready to move on, check some of the <a href="#sample-customize">most useful resources</a> recommended below.
-				</p>
-			</div>
-		</div>
-	</div>
-	<div class="adjoined-bottom">
-		<div class="grid-container">
-			<div class="grid-width-100">
-				<div id="editor">
-					<h1>Hello world!</h1>
-					<p>I'm an instance of <a href="http://ckeditor.com">CKEditor</a>.</p>
-				</div>
-			</div>
-		</div>
-	</div>
+    <div class="adjoined-top">
+        <div class="grid-container">
+            <div class="content grid-width-100">
+                <h1>Congratulations!</h1>
+                <p>
+                    If you can see CKEditor below, it means that the installation succeeded.
+                    You can now try out your new editor version, see its features, and when you are ready to move on, check some of the <a href="#sample-customize">most useful resources</a> recommended below.
+                </p>
+            </div>
+        </div>
+    </div>
+    <div class="adjoined-bottom">
+        <div class="grid-container">
+            <div class="grid-width-100">
+                <div id="editor">
+                    <h1>Hello world!</h1>
+                    <p>I'm an instance of <a href="http://ckeditor.com">CKEditor</a>.</p>
+                </div>
+            </div>
+        </div>
+    </div>
 
-	<div class="grid-container">
-		<div class="content grid-width-100">
-			<section id="sample-customize">
-				<h2>Customize Your Editor</h2>
-				<p>Modular build and <a href="http://docs.ckeditor.com/#!/guide/dev_configuration">numerous configuration options</a> give you nearly endless possibilities to customize CKEditor. Replace the content of your <code><a href="../config.js">config.js</a></code> file with the following code and refresh this page (<strong>remember to clear the browser cache</strong>)!</p>
-		<pre class="cm-s-neo CodeMirror"><code><span style="padding-right: 0.1px;"><span class="cm-variable">CKEDITOR</span>.<span class="cm-property">editorConfig</span> <span class="cm-operator">=</span> <span class="cm-keyword">function</span>( <span class="cm-def">config</span> ) {</span>
-<span style="padding-right: 0.1px;"><span class="cm-tab">	</span><span class="cm-variable-2">config</span>.<span class="cm-property">language</span> <span class="cm-operator">=</span> <span class="cm-string">'es'</span>;</span>
-<span style="padding-right: 0.1px;"><span class="cm-tab">	</span><span class="cm-variable-2">config</span>.<span class="cm-property">uiColor</span> <span class="cm-operator">=</span> <span class="cm-string">'#F7B42C'</span>;</span>
-<span style="padding-right: 0.1px;"><span class="cm-tab">	</span><span class="cm-variable-2">config</span>.<span class="cm-property">height</span> <span class="cm-operator">=</span> <span class="cm-number">300</span>;</span>
-<span style="padding-right: 0.1px;"><span class="cm-tab">	</span><span class="cm-variable-2">config</span>.<span class="cm-property">toolbarCanCollapse</span> <span class="cm-operator">=</span> <span class="cm-atom">true</span>;</span>
+    <div class="grid-container">
+        <div class="content grid-width-100">
+            <section id="sample-customize">
+                <h2>Customize Your Editor</h2>
+                <p>Modular build and <a href="http://docs.ckeditor.com/#!/guide/dev_configuration">numerous configuration options</a> give you nearly endless possibilities to customize CKEditor. Replace the content of your <code><a href="../config.js">config.js</a></code> file with the following code and refresh this page (<strong>remember to clear the browser cache</strong>)!</p>
+        <pre class="cm-s-neo CodeMirror"><code><span style="padding-right: 0.1px;"><span class="cm-variable">CKEDITOR</span>.<span class="cm-property">editorConfig</span> <span class="cm-operator">=</span> <span class="cm-keyword">function</span>( <span class="cm-def">config</span> ) {</span>
+<span style="padding-right: 0.1px;"><span class="cm-tab">    </span><span class="cm-variable-2">config</span>.<span class="cm-property">language</span> <span class="cm-operator">=</span> <span class="cm-string">'es'</span>;</span>
+<span style="padding-right: 0.1px;"><span class="cm-tab">    </span><span class="cm-variable-2">config</span>.<span class="cm-property">uiColor</span> <span class="cm-operator">=</span> <span class="cm-string">'#F7B42C'</span>;</span>
+<span style="padding-right: 0.1px;"><span class="cm-tab">    </span><span class="cm-variable-2">config</span>.<span class="cm-property">height</span> <span class="cm-operator">=</span> <span class="cm-number">300</span>;</span>
+<span style="padding-right: 0.1px;"><span class="cm-tab">    </span><span class="cm-variable-2">config</span>.<span class="cm-property">toolbarCanCollapse</span> <span class="cm-operator">=</span> <span class="cm-atom">true</span>;</span>
 <span style="padding-right: 0.1px;">};</span></code></pre>
-			</section>
+            </section>
 
-			<section>
-				<h2>Toolbar Configuration</h2>
-				<p>If you want to reorder toolbar buttons or remove some of them, check <a href="toolbarconfigurator/index.html">this handy tool</a>!</p>
-			</section>
+            <section>
+                <h2>Toolbar Configuration</h2>
+                <p>If you want to reorder toolbar buttons or remove some of them, check <a href="toolbarconfigurator/index.html">this handy tool</a>!</p>
+            </section>
 
-			<section>
-				<h2>More Samples!</h2>
-				<p>Visit the <a href="http://sdk.ckeditor.com">CKEditor SDK</a> for a huge collection of samples showcasing editor features, with source code readily available to copy and use in your own implementation.</p>
-			</section>
+            <section>
+                <h2>More Samples!</h2>
+                <p>Visit the <a href="http://sdk.ckeditor.com">CKEditor SDK</a> for a huge collection of samples showcasing editor features, with source code readily available to copy and use in your own implementation.</p>
+            </section>
 
-			<section>
-				<h2>Developer's Guide</h2>
-				<p>The most important resource for all developers working with CKEditor, integrating it with their websites and applications, and customizing to their needs. You can start from here:</p>
-				<ul>
-					<li><a href="http://docs.ckeditor.com/#!/guide/dev_installation">Getting Started</a> &ndash; Explains most crucial editor concepts and practices as well as the installation process and integration with your website.</li>
-					<li><a href="http://docs.ckeditor.com/#!/guide/dev_advanced_installation">Advanced Installation Concepts</a> &ndash; Describes how to upgrade, install additional components (plugins, skins), or create a custom build.</li>
-				</ul>
-					<p>When you have the basics sorted out, feel free to browse some more advanced sections like:</p>
-				<ul>
-					<li><a href="http://docs.ckeditor.com/#!/guide/dev_features">Functionality Overview</a> &ndash; Descriptions and samples of various editor features.</li>
-					<li><a href="http://docs.ckeditor.com/#!/guide/plugin_sdk_intro">Plugin SDK</a>, <a href="http://docs.ckeditor.com/#!/guide/widget_sdk_intro">Widget SDK</a>, and <a href="http://docs.ckeditor.com/#!/guide/skin_sdk_intro">Skin SDK</a> &ndash; Useful when you want to create your own editor components.</li>
-				</ul>
-			</section>
+            <section>
+                <h2>Developer's Guide</h2>
+                <p>The most important resource for all developers working with CKEditor, integrating it with their websites and applications, and customizing to their needs. You can start from here:</p>
+                <ul>
+                    <li><a href="http://docs.ckeditor.com/#!/guide/dev_installation">Getting Started</a> &ndash; Explains most crucial editor concepts and practices as well as the installation process and integration with your website.</li>
+                    <li><a href="http://docs.ckeditor.com/#!/guide/dev_advanced_installation">Advanced Installation Concepts</a> &ndash; Describes how to upgrade, install additional components (plugins, skins), or create a custom build.</li>
+                </ul>
+                    <p>When you have the basics sorted out, feel free to browse some more advanced sections like:</p>
+                <ul>
+                    <li><a href="http://docs.ckeditor.com/#!/guide/dev_features">Functionality Overview</a> &ndash; Descriptions and samples of various editor features.</li>
+                    <li><a href="http://docs.ckeditor.com/#!/guide/plugin_sdk_intro">Plugin SDK</a>, <a href="http://docs.ckeditor.com/#!/guide/widget_sdk_intro">Widget SDK</a>, and <a href="http://docs.ckeditor.com/#!/guide/skin_sdk_intro">Skin SDK</a> &ndash; Useful when you want to create your own editor components.</li>
+                </ul>
+            </section>
 
-			<section>
-				<h2>CKEditor JavaScript API</h2>
-				<p>CKEditor boasts a rich <a href="http://docs.ckeditor.com/#!/api">JavaScript API</a> that you can use to adjust the editor to your needs and integrate it with your website or application.</p>
-			</section>
-		</div>
-	</div>
+            <section>
+                <h2>CKEditor JavaScript API</h2>
+                <p>CKEditor boasts a rich <a href="http://docs.ckeditor.com/#!/api">JavaScript API</a> that you can use to adjust the editor to your needs and integrate it with your website or application.</p>
+            </section>
+        </div>
+    </div>
 </main>
 
 <footer class="footer-a grid-container">
-	<div class="grid-container">
-		<p class="grid-width-100">
-			CKEditor &ndash; The text editor for the Internet &ndash; <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
-		</p>
-		<p class="grid-width-100" id="copy">
-			Copyright &copy; 2003-2016, <a class="samples" href="http://cksource.com/">CKSource</a> &ndash; Frederico Knabben. All rights reserved.
-		</p>
-	</div>
+    <div class="grid-container">
+        <p class="grid-width-100">
+            CKEditor &ndash; The text editor for the Internet &ndash; <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
+        </p>
+        <p class="grid-width-100" id="copy">
+            Copyright &copy; 2003-2016, <a class="samples" href="http://cksource.com/">CKSource</a> &ndash; Frederico Knabben. All rights reserved.
+        </p>
+    </div>
 </footer>
 <script>
-	initSample();
+    initSample();
 </script>
 
 </body>

+ 36 - 36
www-admin/ckeditor/samples/js/sample.js

@@ -6,7 +6,7 @@
 /* exported initSample */
 
 if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 )
-	CKEDITOR.tools.enableHtml5Elements( document );
+    CKEDITOR.tools.enableHtml5Elements( document );
 
 // The trick to keep the editor in the sample quite small
 // unless user specified own height.
@@ -14,40 +14,40 @@ CKEDITOR.config.height = 150;
 CKEDITOR.config.width = 'auto';
 
 var initSample = ( function() {
-	var wysiwygareaAvailable = isWysiwygareaAvailable(),
-		isBBCodeBuiltIn = !!CKEDITOR.plugins.get( 'bbcode' );
-
-	return function() {
-		var editorElement = CKEDITOR.document.getById( 'editor' );
-
-		// :(((
-		if ( isBBCodeBuiltIn ) {
-			editorElement.setHtml(
-				'Hello world!\n\n' +
-				'I\'m an instance of [url=http://ckeditor.com]CKEditor[/url].'
-			);
-		}
-
-		// Depending on the wysiwygare plugin availability initialize classic or inline editor.
-		if ( wysiwygareaAvailable ) {
-			CKEDITOR.replace( 'editor' );
-		} else {
-			editorElement.setAttribute( 'contenteditable', 'true' );
-			CKEDITOR.inline( 'editor' );
-
-			// TODO we can consider displaying some info box that
-			// without wysiwygarea the classic editor may not work.
-		}
-	};
-
-	function isWysiwygareaAvailable() {
-		// If in development mode, then the wysiwygarea must be available.
-		// Split REV into two strings so builder does not replace it :D.
-		if ( CKEDITOR.revision == ( '%RE' + 'V%' ) ) {
-			return true;
-		}
-
-		return !!CKEDITOR.plugins.get( 'wysiwygarea' );
-	}
+    var wysiwygareaAvailable = isWysiwygareaAvailable(),
+        isBBCodeBuiltIn = !!CKEDITOR.plugins.get( 'bbcode' );
+
+    return function() {
+        var editorElement = CKEDITOR.document.getById( 'editor' );
+
+        // :(((
+        if ( isBBCodeBuiltIn ) {
+            editorElement.setHtml(
+                'Hello world!\n\n' +
+                'I\'m an instance of [url=http://ckeditor.com]CKEditor[/url].'
+            );
+        }
+
+        // Depending on the wysiwygare plugin availability initialize classic or inline editor.
+        if ( wysiwygareaAvailable ) {
+            CKEDITOR.replace( 'editor' );
+        } else {
+            editorElement.setAttribute( 'contenteditable', 'true' );
+            CKEDITOR.inline( 'editor' );
+
+            // TODO we can consider displaying some info box that
+            // without wysiwygarea the classic editor may not work.
+        }
+    };
+
+    function isWysiwygareaAvailable() {
+        // If in development mode, then the wysiwygarea must be available.
+        // Split REV into two strings so builder does not replace it :D.
+        if ( CKEDITOR.revision == ( '%RE' + 'V%' ) ) {
+            return true;
+        }
+
+        return !!CKEDITOR.plugins.get( 'wysiwygarea' );
+    }
 } )();
 

+ 44 - 44
www-admin/ckeditor/samples/old/assets/outputxhtml/outputxhtml.css

@@ -10,12 +10,12 @@
  */
 body
 {
-	font-family: Arial, Verdana, sans-serif;
-	font-size: 80%;
-	color: #000000;
-	background-color: #ffffff;
-	padding: 5px;
-	margin: 0px;
+    font-family: Arial, Verdana, sans-serif;
+    font-size: 80%;
+    color: #000000;
+    background-color: #ffffff;
+    padding: 5px;
+    margin: 0px;
 }
 
 /**
@@ -24,34 +24,34 @@ body
 
 .Bold
 {
-	font-weight: bold;
+    font-weight: bold;
 }
 
 .Italic
 {
-	font-style: italic;
+    font-style: italic;
 }
 
 .Underline
 {
-	text-decoration: underline;
+    text-decoration: underline;
 }
 
 .StrikeThrough
 {
-	text-decoration: line-through;
+    text-decoration: line-through;
 }
 
 .Subscript
 {
-	vertical-align: sub;
-	font-size: smaller;
+    vertical-align: sub;
+    font-size: smaller;
 }
 
 .Superscript
 {
-	vertical-align: super;
-	font-size: smaller;
+    vertical-align: super;
+    font-size: smaller;
 }
 
 /**
@@ -60,17 +60,17 @@ body
 
 .FontComic
 {
-	font-family: 'Comic Sans MS';
+    font-family: 'Comic Sans MS';
 }
 
 .FontCourier
 {
-	font-family: 'Courier New';
+    font-family: 'Courier New';
 }
 
 .FontTimes
 {
-	font-family: 'Times New Roman';
+    font-family: 'Times New Roman';
 }
 
 /**
@@ -79,27 +79,27 @@ body
 
 .FontSmaller
 {
-	font-size: smaller;
+    font-size: smaller;
 }
 
 .FontLarger
 {
-	font-size: larger;
+    font-size: larger;
 }
 
 .FontSmall
 {
-	font-size: 8pt;
+    font-size: 8pt;
 }
 
 .FontBig
 {
-	font-size: 14pt;
+    font-size: 14pt;
 }
 
 .FontDouble
 {
-	font-size: 200%;
+    font-size: 200%;
 }
 
 /**
@@ -107,32 +107,32 @@ body
  */
 .FontColor1
 {
-	color: #ff9900;
+    color: #ff9900;
 }
 
 .FontColor2
 {
-	color: #0066cc;
+    color: #0066cc;
 }
 
 .FontColor3
 {
-	color: #ff0000;
+    color: #ff0000;
 }
 
 .FontColor1BG
 {
-	background-color: #ff9900;
+    background-color: #ff9900;
 }
 
 .FontColor2BG
 {
-	background-color: #0066cc;
+    background-color: #0066cc;
 }
 
 .FontColor3BG
 {
-	background-color: #ff0000;
+    background-color: #ff0000;
 }
 
 /**
@@ -141,17 +141,17 @@ body
 
 .Indent1
 {
-	margin-left: 40px;
+    margin-left: 40px;
 }
 
 .Indent2
 {
-	margin-left: 80px;
+    margin-left: 80px;
 }
 
 .Indent3
 {
-	margin-left: 120px;
+    margin-left: 120px;
 }
 
 /**
@@ -160,22 +160,22 @@ body
 
 .JustifyLeft
 {
-	text-align: left;
+    text-align: left;
 }
 
 .JustifyRight
 {
-	text-align: right;
+    text-align: right;
 }
 
 .JustifyCenter
 {
-	text-align: center;
+    text-align: center;
 }
 
 .JustifyFull
 {
-	text-align: justify;
+    text-align: justify;
 }
 
 /**
@@ -184,21 +184,21 @@ body
 
 code
 {
-	font-family: courier, monospace;
-	background-color: #eeeeee;
-	padding-left: 1px;
-	padding-right: 1px;
-	border: #c0c0c0 1px solid;
+    font-family: courier, monospace;
+    background-color: #eeeeee;
+    padding-left: 1px;
+    padding-right: 1px;
+    border: #c0c0c0 1px solid;
 }
 
 kbd
 {
-	padding: 0px 1px 0px 1px;
-	border-width: 1px 2px 2px 1px;
-	border-style: solid;
+    padding: 0px 1px 0px 1px;
+    border-width: 1px 2px 2px 1px;
+    border-style: solid;
 }
 
 blockquote
 {
-	color: #808080;
+    color: #808080;
 }

+ 38 - 38
www-admin/ckeditor/samples/old/assets/posteddata.php

@@ -7,53 +7,53 @@ For licensing, see LICENSE.md or http://ckeditor.com/license
 ?>
 <html>
 <head>
-	<meta charset="utf-8">
-	<title>Sample &mdash; CKEditor</title>
-	<link rel="stylesheet" href="sample.css">
+    <meta charset="utf-8">
+    <title>Sample &mdash; CKEditor</title>
+    <link rel="stylesheet" href="sample.css">
 </head>
 <body>
-	<h1 class="samples">
-		CKEditor &mdash; Posted Data
-	</h1>
-	<table border="1" cellspacing="0" id="outputSample">
-		<colgroup><col width="120"></colgroup>
-		<thead>
-			<tr>
-				<th>Field&nbsp;Name</th>
-				<th>Value</th>
-			</tr>
-		</thead>
+    <h1 class="samples">
+        CKEditor &mdash; Posted Data
+    </h1>
+    <table border="1" cellspacing="0" id="outputSample">
+        <colgroup><col width="120"></colgroup>
+        <thead>
+            <tr>
+                <th>Field&nbsp;Name</th>
+                <th>Value</th>
+            </tr>
+        </thead>
 <?php
 
 if (!empty($_POST))
 {
-	foreach ( $_POST as $key => $value )
-	{
-		if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) )
-			continue;
+    foreach ( $_POST as $key => $value )
+    {
+        if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) )
+            continue;
 
-		if ( get_magic_quotes_gpc() )
-			$value = htmlspecialchars( stripslashes((string)$value) );
-		else
-			$value = htmlspecialchars( (string)$value );
+        if ( get_magic_quotes_gpc() )
+            $value = htmlspecialchars( stripslashes((string)$value) );
+        else
+            $value = htmlspecialchars( (string)$value );
 ?>
-		<tr>
-			<th style="vertical-align: top"><?php echo htmlspecialchars( (string)$key ); ?></th>
-			<td><pre class="samples"><?php echo $value; ?></pre></td>
-		</tr>
-	<?php
-	}
+        <tr>
+            <th style="vertical-align: top"><?php echo htmlspecialchars( (string)$key ); ?></th>
+            <td><pre class="samples"><?php echo $value; ?></pre></td>
+        </tr>
+    <?php
+    }
 }
 ?>
-	</table>
-	<div id="footer">
-		<hr>
-		<p>
-			CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
-		</p>
-		<p id="copy">
-			Copyright &copy; 2003-2016, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico Knabben. All rights reserved.
-		</p>
-	</div>
+    </table>
+    <div id="footer">
+        <hr>
+        <p>
+            CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
+        </p>
+        <p id="copy">
+            Copyright &copy; 2003-2016, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico Knabben. All rights reserved.
+        </p>
+    </div>
 </body>
 </html>

+ 40 - 40
www-admin/ckeditor/samples/old/dialog/assets/my_dialog.js

@@ -4,45 +4,45 @@
  */
 
 CKEDITOR.dialog.add( 'myDialog', function() {
-	return {
-		title: 'My Dialog',
-		minWidth: 400,
-		minHeight: 200,
-		contents: [
-			{
-				id: 'tab1',
-				label: 'First Tab',
-				title: 'First Tab',
-				elements: [
-					{
-						id: 'input1',
-						type: 'text',
-						label: 'Text Field'
-					},
-					{
-						id: 'select1',
-						type: 'select',
-						label: 'Select Field',
-						items: [
-							[ 'option1', 'value1' ],
-							[ 'option2', 'value2' ]
-						]
-					}
-				]
-			},
-			{
-				id: 'tab2',
-				label: 'Second Tab',
-				title: 'Second Tab',
-				elements: [
-					{
-						id: 'button1',
-						type: 'button',
-						label: 'Button Field'
-					}
-				]
-			}
-		]
-	};
+    return {
+        title: 'My Dialog',
+        minWidth: 400,
+        minHeight: 200,
+        contents: [
+            {
+                id: 'tab1',
+                label: 'First Tab',
+                title: 'First Tab',
+                elements: [
+                    {
+                        id: 'input1',
+                        type: 'text',
+                        label: 'Text Field'
+                    },
+                    {
+                        id: 'select1',
+                        type: 'select',
+                        label: 'Select Field',
+                        items: [
+                            [ 'option1', 'value1' ],
+                            [ 'option2', 'value2' ]
+                        ]
+                    }
+                ]
+            },
+            {
+                id: 'tab2',
+                label: 'Second Tab',
+                title: 'Second Tab',
+                elements: [
+                    {
+                        id: 'button1',
+                        type: 'button',
+                        label: 'Button Field'
+                    }
+                ]
+            }
+        ]
+    };
 } );
 

+ 135 - 135
www-admin/ckeditor/samples/old/sample.css

@@ -5,353 +5,353 @@ For licensing, see LICENSE.md or http://ckeditor.com/license
 
 html, body, h1, h2, h3, h4, h5, h6, div, span, blockquote, p, address, form, fieldset, img, ul, ol, dl, dt, dd, li, hr, table, td, th, strong, em, sup, sub, dfn, ins, del, q, cite, var, samp, code, kbd, tt, pre
 {
-	line-height: 1.5;
+    line-height: 1.5;
 }
 
 body
 {
-	padding: 10px 30px;
+    padding: 10px 30px;
 }
 
 input, textarea, select, option, optgroup, button, td, th
 {
-	font-size: 100%;
+    font-size: 100%;
 }
 
 pre
 {
-	-moz-tab-size: 4;
-	tab-size: 4;
+    -moz-tab-size: 4;
+    tab-size: 4;
 }
 
 pre, code, kbd, samp, tt
 {
-	font-family: monospace,monospace;
-	font-size: 1em;
+    font-family: monospace,monospace;
+    font-size: 1em;
 }
 
 body {
-	width: 960px;
-	margin: 0 auto;
+    width: 960px;
+    margin: 0 auto;
 }
 
 code
 {
-	background: #f3f3f3;
-	border: 1px solid #ddd;
-	padding: 1px 4px;
-	border-radius: 3px;
+    background: #f3f3f3;
+    border: 1px solid #ddd;
+    padding: 1px 4px;
+    border-radius: 3px;
 }
 
 abbr
 {
-	border-bottom: 1px dotted #555;
-	cursor: pointer;
+    border-bottom: 1px dotted #555;
+    cursor: pointer;
 }
 
 .new, .beta
 {
-	text-transform: uppercase;
-	font-size: 10px;
-	font-weight: bold;
-	padding: 1px 4px;
-	margin: 0 0 0 5px;
-	color: #fff;
-	float: right;
-	border-radius: 3px;
+    text-transform: uppercase;
+    font-size: 10px;
+    font-weight: bold;
+    padding: 1px 4px;
+    margin: 0 0 0 5px;
+    color: #fff;
+    float: right;
+    border-radius: 3px;
 }
 
 .new
 {
-	background: #FF7E00;
-	border: 1px solid #DA8028;
-	text-shadow: 0 1px 0 #C97626;
+    background: #FF7E00;
+    border: 1px solid #DA8028;
+    text-shadow: 0 1px 0 #C97626;
 
-	box-shadow: 0 2px 3px 0 #FFA54E inset;
+    box-shadow: 0 2px 3px 0 #FFA54E inset;
 }
 
 .beta
 {
-	background: #18C0DF;
-	border: 1px solid #19AAD8;
-	text-shadow: 0 1px 0 #048CAD;
-	font-style: italic;
+    background: #18C0DF;
+    border: 1px solid #19AAD8;
+    text-shadow: 0 1px 0 #048CAD;
+    font-style: italic;
 
-	box-shadow: 0 2px 3px 0 #50D4FD inset;
+    box-shadow: 0 2px 3px 0 #50D4FD inset;
 }
 
 h1.samples
 {
-	color: #0782C1;
-	font-size: 200%;
-	font-weight: normal;
-	margin: 0;
-	padding: 0;
+    color: #0782C1;
+    font-size: 200%;
+    font-weight: normal;
+    margin: 0;
+    padding: 0;
 }
 
 h1.samples a
 {
-	color: #0782C1;
-	text-decoration: none;
-	border-bottom: 1px dotted #0782C1;
+    color: #0782C1;
+    text-decoration: none;
+    border-bottom: 1px dotted #0782C1;
 }
 
 .samples a:hover
 {
-	border-bottom: 1px dotted #0782C1;
+    border-bottom: 1px dotted #0782C1;
 }
 
 h2.samples
 {
-	color: #000000;
-	font-size: 130%;
-	margin: 15px 0 0 0;
-	padding: 0;
+    color: #000000;
+    font-size: 130%;
+    margin: 15px 0 0 0;
+    padding: 0;
 }
 
 p, blockquote, address, form, pre, dl, h1.samples, h2.samples
 {
-	margin-bottom: 15px;
+    margin-bottom: 15px;
 }
 
 ul.samples
 {
-	margin-bottom: 15px;
+    margin-bottom: 15px;
 }
 
 .clear
 {
-	clear: both;
+    clear: both;
 }
 
 fieldset
 {
-	margin: 0;
-	padding: 10px;
+    margin: 0;
+    padding: 10px;
 }
 
 body, input, textarea
 {
-	color: #333333;
-	font-family: Arial, Helvetica, sans-serif;
+    color: #333333;
+    font-family: Arial, Helvetica, sans-serif;
 }
 
 body
 {
-	font-size: 75%;
+    font-size: 75%;
 }
 
 a.samples
 {
-	color: #189DE1;
-	text-decoration: none;
+    color: #189DE1;
+    text-decoration: none;
 }
 
 form
 {
-	margin: 0;
-	padding: 0;
+    margin: 0;
+    padding: 0;
 }
 
 pre.samples
 {
-	background-color: #F7F7F7;
-	border: 1px solid #D7D7D7;
-	overflow: auto;
-	padding: 0.25em;
-	white-space: pre-wrap; /* CSS 2.1 */
-	word-wrap: break-word; /* IE7 */
+    background-color: #F7F7F7;
+    border: 1px solid #D7D7D7;
+    overflow: auto;
+    padding: 0.25em;
+    white-space: pre-wrap; /* CSS 2.1 */
+    word-wrap: break-word; /* IE7 */
 }
 
 #footer
 {
-	clear: both;
-	padding-top: 10px;
+    clear: both;
+    padding-top: 10px;
 }
 
 #footer hr
 {
-	margin: 10px 0 15px 0;
-	height: 1px;
-	border: solid 1px gray;
-	border-bottom: none;
+    margin: 10px 0 15px 0;
+    height: 1px;
+    border: solid 1px gray;
+    border-bottom: none;
 }
 
 #footer p
 {
-	margin: 0 10px 10px 10px;
-	float: left;
+    margin: 0 10px 10px 10px;
+    float: left;
 }
 
 #footer #copy
 {
-	float: right;
+    float: right;
 }
 
 #outputSample
 {
-	width: 100%;
-	table-layout: fixed;
+    width: 100%;
+    table-layout: fixed;
 }
 
 #outputSample thead th
 {
-	color: #dddddd;
-	background-color: #999999;
-	padding: 4px;
-	white-space: nowrap;
+    color: #dddddd;
+    background-color: #999999;
+    padding: 4px;
+    white-space: nowrap;
 }
 
 #outputSample tbody th
 {
-	vertical-align: top;
-	text-align: left;
+    vertical-align: top;
+    text-align: left;
 }
 
 #outputSample pre
 {
-	margin: 0;
-	padding: 0;
+    margin: 0;
+    padding: 0;
 }
 
 .description
 {
-	border: 1px dotted #B7B7B7;
-	margin-bottom: 10px;
-	padding: 10px 10px 0;
-	overflow: hidden;
+    border: 1px dotted #B7B7B7;
+    margin-bottom: 10px;
+    padding: 10px 10px 0;
+    overflow: hidden;
 }
 
 label
 {
-	display: block;
-	margin-bottom: 6px;
+    display: block;
+    margin-bottom: 6px;
 }
 
 /**
- *	CKEditor editables are automatically set with the "cke_editable" class
- *	plus cke_editable_(inline|themed) depending on the editor type.
+ *    CKEditor editables are automatically set with the "cke_editable" class
+ *    plus cke_editable_(inline|themed) depending on the editor type.
  */
 
 /* Style a bit the inline editables. */
 .cke_editable.cke_editable_inline
 {
-	cursor: pointer;
+    cursor: pointer;
 }
 
 /* Once an editable element gets focused, the "cke_focus" class is
    added to it, so we can style it differently. */
 .cke_editable.cke_editable_inline.cke_focus
 {
-	box-shadow: inset 0px 0px 20px 3px #ddd, inset 0 0 1px #000;
-	outline: none;
-	background: #eee;
-	cursor: text;
+    box-shadow: inset 0px 0px 20px 3px #ddd, inset 0 0 1px #000;
+    outline: none;
+    background: #eee;
+    cursor: text;
 }
 
 /* Avoid pre-formatted overflows inline editable. */
 .cke_editable_inline pre
 {
-	white-space: pre-wrap;
-	word-wrap: break-word;
+    white-space: pre-wrap;
+    word-wrap: break-word;
 }
 
 /**
- *	Samples index styles.
+ *    Samples index styles.
  */
 
 .twoColumns,
 .twoColumnsLeft,
 .twoColumnsRight
 {
-	overflow: hidden;
+    overflow: hidden;
 }
 
 .twoColumnsLeft,
 .twoColumnsRight
 {
-	width: 45%;
+    width: 45%;
 }
 
 .twoColumnsLeft
 {
-	float: left;
+    float: left;
 }
 
 .twoColumnsRight
 {
-	float: right;
+    float: right;
 }
 
 dl.samples
 {
-	padding: 0 0 0 40px;
+    padding: 0 0 0 40px;
 }
 dl.samples > dt
 {
-	display: list-item;
-	list-style-type: disc;
-	list-style-position: outside;
-	margin: 0 0 3px;
+    display: list-item;
+    list-style-type: disc;
+    list-style-position: outside;
+    margin: 0 0 3px;
 }
 dl.samples > dd
 {
-	margin: 0 0 3px;
+    margin: 0 0 3px;
 }
 .warning
 {
-	color: #ff0000;
-	background-color: #FFCCBA;
-	border: 2px dotted #ff0000;
-	padding: 15px 10px;
-	margin: 10px 0;
+    color: #ff0000;
+    background-color: #FFCCBA;
+    border: 2px dotted #ff0000;
+    padding: 15px 10px;
+    margin: 10px 0;
 }
 
 .warning.deprecated {
-	font-size: 1.3em;
+    font-size: 1.3em;
 }
 
 /* Used on inline samples */
 
 blockquote
 {
-	font-style: italic;
-	font-family: Georgia, Times, "Times New Roman", serif;
-	padding: 2px 0;
-	border-style: solid;
-	border-color: #ccc;
-	border-width: 0;
+    font-style: italic;
+    font-family: Georgia, Times, "Times New Roman", serif;
+    padding: 2px 0;
+    border-style: solid;
+    border-color: #ccc;
+    border-width: 0;
 }
 
 .cke_contents_ltr blockquote
 {
-	padding-left: 20px;
-	padding-right: 8px;
-	border-left-width: 5px;
+    padding-left: 20px;
+    padding-right: 8px;
+    border-left-width: 5px;
 }
 
 .cke_contents_rtl blockquote
 {
-	padding-left: 8px;
-	padding-right: 20px;
-	border-right-width: 5px;
+    padding-left: 8px;
+    padding-right: 20px;
+    border-right-width: 5px;
 }
 
 img.right {
-	border: 1px solid #ccc;
-	float: right;
-	margin-left: 15px;
-	padding: 5px;
+    border: 1px solid #ccc;
+    float: right;
+    margin-left: 15px;
+    padding: 5px;
 }
 
 img.left {
-	border: 1px solid #ccc;
-	float: left;
-	margin-right: 15px;
-	padding: 5px;
+    border: 1px solid #ccc;
+    float: left;
+    margin-right: 15px;
+    padding: 5px;
 }
 
 .marker
 {
-	background-color: Yellow;
+    background-color: Yellow;
 }

+ 40 - 40
www-admin/ckeditor/samples/old/sample.js

@@ -7,44 +7,44 @@
 // This file can be ignored and is not required to make use of CKEditor.
 
 ( function() {
-	CKEDITOR.on( 'instanceReady', function( ev ) {
-		// Check for sample compliance.
-		var editor = ev.editor,
-			meta = CKEDITOR.document.$.getElementsByName( 'ckeditor-sample-required-plugins' ),
-			requires = meta.length ? CKEDITOR.dom.element.get( meta[ 0 ] ).getAttribute( 'content' ).split( ',' ) : [],
-			missing = [],
-			i;
-
-		if ( requires.length ) {
-			for ( i = 0; i < requires.length; i++ ) {
-				if ( !editor.plugins[ requires[ i ] ] )
-					missing.push( '<code>' + requires[ i ] + '</code>' );
-			}
-
-			if ( missing.length ) {
-				var warn = CKEDITOR.dom.element.createFromHtml(
-					'<div class="warning">' +
-						'<span>To fully experience this demo, the ' + missing.join( ', ' ) + ' plugin' + ( missing.length > 1 ? 's are' : ' is' ) + ' required.</span>' +
-					'</div>'
-				);
-				warn.insertBefore( editor.container );
-			}
-		}
-
-		// Set icons.
-		var doc = new CKEDITOR.dom.document( document ),
-			icons = doc.find( '.button_icon' );
-
-		for ( i = 0; i < icons.count(); i++ ) {
-			var icon = icons.getItem( i ),
-				name = icon.getAttribute( 'data-icon' ),
-				style = CKEDITOR.skin.getIconStyle( name, ( CKEDITOR.lang.dir == 'rtl' ) );
-
-			icon.addClass( 'cke_button_icon' );
-			icon.addClass( 'cke_button__' + name + '_icon' );
-			icon.setAttribute( 'style', style );
-			icon.setStyle( 'float', 'none' );
-
-		}
-	} );
+    CKEDITOR.on( 'instanceReady', function( ev ) {
+        // Check for sample compliance.
+        var editor = ev.editor,
+            meta = CKEDITOR.document.$.getElementsByName( 'ckeditor-sample-required-plugins' ),
+            requires = meta.length ? CKEDITOR.dom.element.get( meta[ 0 ] ).getAttribute( 'content' ).split( ',' ) : [],
+            missing = [],
+            i;
+
+        if ( requires.length ) {
+            for ( i = 0; i < requires.length; i++ ) {
+                if ( !editor.plugins[ requires[ i ] ] )
+                    missing.push( '<code>' + requires[ i ] + '</code>' );
+            }
+
+            if ( missing.length ) {
+                var warn = CKEDITOR.dom.element.createFromHtml(
+                    '<div class="warning">' +
+                        '<span>To fully experience this demo, the ' + missing.join( ', ' ) + ' plugin' + ( missing.length > 1 ? 's are' : ' is' ) + ' required.</span>' +
+                    '</div>'
+                );
+                warn.insertBefore( editor.container );
+            }
+        }
+
+        // Set icons.
+        var doc = new CKEDITOR.dom.document( document ),
+            icons = doc.find( '.button_icon' );
+
+        for ( i = 0; i < icons.count(); i++ ) {
+            var icon = icons.getItem( i ),
+                name = icon.getAttribute( 'data-icon' ),
+                style = CKEDITOR.skin.getIconStyle( name, ( CKEDITOR.lang.dir == 'rtl' ) );
+
+            icon.addClass( 'cke_button_icon' );
+            icon.addClass( 'cke_button__' + name + '_icon' );
+            icon.setAttribute( 'style', style );
+            icon.setStyle( 'float', 'none' );
+
+        }
+    } );
 } )();

+ 93 - 93
www-admin/ckeditor/styles.js

@@ -14,98 +14,98 @@
 // website requirements and design properly.
 
 CKEDITOR.stylesSet.add( 'default', [
-	/* Block Styles */
-
-	// These styles are already available in the "Format" combo ("format" plugin),
-	// so they are not needed here by default. You may enable them to avoid
-	// placing the "Format" combo in the toolbar, maintaining the same features.
-	/*
-	{ name: 'Paragraph',		element: 'p' },
-	{ name: 'Heading 1',		element: 'h1' },
-	{ name: 'Heading 2',		element: 'h2' },
-	{ name: 'Heading 3',		element: 'h3' },
-	{ name: 'Heading 4',		element: 'h4' },
-	{ name: 'Heading 5',		element: 'h5' },
-	{ name: 'Heading 6',		element: 'h6' },
-	{ name: 'Preformatted Text',element: 'pre' },
-	{ name: 'Address',			element: 'address' },
-	*/
-
-	{ name: 'Italic Title',		element: 'h2', styles: { 'font-style': 'italic' } },
-	{ name: 'Subtitle',			element: 'h3', styles: { 'color': '#aaa', 'font-style': 'italic' } },
-	{
-		name: 'Special Container',
-		element: 'div',
-		styles: {
-			padding: '5px 10px',
-			background: '#eee',
-			border: '1px solid #ccc'
-		}
-	},
-
-	/* Inline Styles */
-
-	// These are core styles available as toolbar buttons. You may opt enabling
-	// some of them in the Styles combo, removing them from the toolbar.
-	// (This requires the "stylescombo" plugin)
-	/*
-	{ name: 'Strong',			element: 'strong', overrides: 'b' },
-	{ name: 'Emphasis',			element: 'em'	, overrides: 'i' },
-	{ name: 'Underline',		element: 'u' },
-	{ name: 'Strikethrough',	element: 'strike' },
-	{ name: 'Subscript',		element: 'sub' },
-	{ name: 'Superscript',		element: 'sup' },
-	*/
-
-	{ name: 'Marker',			element: 'span', attributes: { 'class': 'marker' } },
-
-	{ name: 'Big',				element: 'big' },
-	{ name: 'Small',			element: 'small' },
-	{ name: 'Typewriter',		element: 'tt' },
-
-	{ name: 'Computer Code',	element: 'code' },
-	{ name: 'Keyboard Phrase',	element: 'kbd' },
-	{ name: 'Sample Text',		element: 'samp' },
-	{ name: 'Variable',			element: 'var' },
-
-	{ name: 'Deleted Text',		element: 'del' },
-	{ name: 'Inserted Text',	element: 'ins' },
-
-	{ name: 'Cited Work',		element: 'cite' },
-	{ name: 'Inline Quotation',	element: 'q' },
-
-	{ name: 'Language: RTL',	element: 'span', attributes: { 'dir': 'rtl' } },
-	{ name: 'Language: LTR',	element: 'span', attributes: { 'dir': 'ltr' } },
-
-	/* Object Styles */
-
-	{
-		name: 'Styled image (left)',
-		element: 'img',
-		attributes: { 'class': 'left' }
-	},
-
-	{
-		name: 'Styled image (right)',
-		element: 'img',
-		attributes: { 'class': 'right' }
-	},
-
-	{
-		name: 'Compact table',
-		element: 'table',
-		attributes: {
-			cellpadding: '5',
-			cellspacing: '0',
-			border: '1',
-			bordercolor: '#ccc'
-		},
-		styles: {
-			'border-collapse': 'collapse'
-		}
-	},
-
-	{ name: 'Borderless Table',		element: 'table',	styles: { 'border-style': 'hidden', 'background-color': '#E6E6FA' } },
-	{ name: 'Square Bulleted List',	element: 'ul',		styles: { 'list-style-type': 'square' } }
+    /* Block Styles */
+
+    // These styles are already available in the "Format" combo ("format" plugin),
+    // so they are not needed here by default. You may enable them to avoid
+    // placing the "Format" combo in the toolbar, maintaining the same features.
+    /*
+    { name: 'Paragraph',        element: 'p' },
+    { name: 'Heading 1',        element: 'h1' },
+    { name: 'Heading 2',        element: 'h2' },
+    { name: 'Heading 3',        element: 'h3' },
+    { name: 'Heading 4',        element: 'h4' },
+    { name: 'Heading 5',        element: 'h5' },
+    { name: 'Heading 6',        element: 'h6' },
+    { name: 'Preformatted Text',element: 'pre' },
+    { name: 'Address',            element: 'address' },
+    */
+
+    { name: 'Italic Title',        element: 'h2', styles: { 'font-style': 'italic' } },
+    { name: 'Subtitle',            element: 'h3', styles: { 'color': '#aaa', 'font-style': 'italic' } },
+    {
+        name: 'Special Container',
+        element: 'div',
+        styles: {
+            padding: '5px 10px',
+            background: '#eee',
+            border: '1px solid #ccc'
+        }
+    },
+
+    /* Inline Styles */
+
+    // These are core styles available as toolbar buttons. You may opt enabling
+    // some of them in the Styles combo, removing them from the toolbar.
+    // (This requires the "stylescombo" plugin)
+    /*
+    { name: 'Strong',            element: 'strong', overrides: 'b' },
+    { name: 'Emphasis',            element: 'em'    , overrides: 'i' },
+    { name: 'Underline',        element: 'u' },
+    { name: 'Strikethrough',    element: 'strike' },
+    { name: 'Subscript',        element: 'sub' },
+    { name: 'Superscript',        element: 'sup' },
+    */
+
+    { name: 'Marker',            element: 'span', attributes: { 'class': 'marker' } },
+
+    { name: 'Big',                element: 'big' },
+    { name: 'Small',            element: 'small' },
+    { name: 'Typewriter',        element: 'tt' },
+
+    { name: 'Computer Code',    element: 'code' },
+    { name: 'Keyboard Phrase',    element: 'kbd' },
+    { name: 'Sample Text',        element: 'samp' },
+    { name: 'Variable',            element: 'var' },
+
+    { name: 'Deleted Text',        element: 'del' },
+    { name: 'Inserted Text',    element: 'ins' },
+
+    { name: 'Cited Work',        element: 'cite' },
+    { name: 'Inline Quotation',    element: 'q' },
+
+    { name: 'Language: RTL',    element: 'span', attributes: { 'dir': 'rtl' } },
+    { name: 'Language: LTR',    element: 'span', attributes: { 'dir': 'ltr' } },
+
+    /* Object Styles */
+
+    {
+        name: 'Styled image (left)',
+        element: 'img',
+        attributes: { 'class': 'left' }
+    },
+
+    {
+        name: 'Styled image (right)',
+        element: 'img',
+        attributes: { 'class': 'right' }
+    },
+
+    {
+        name: 'Compact table',
+        element: 'table',
+        attributes: {
+            cellpadding: '5',
+            cellspacing: '0',
+            border: '1',
+            bordercolor: '#ccc'
+        },
+        styles: {
+            'border-collapse': 'collapse'
+        }
+    },
+
+    { name: 'Borderless Table',        element: 'table',    styles: { 'border-style': 'hidden', 'background-color': '#E6E6FA' } },
+    { name: 'Square Bulleted List',    element: 'ul',        styles: { 'list-style-type': 'square' } }
 ] );
 

+ 112 - 112
www-admin/css/actividades.css

@@ -1,59 +1,59 @@
 /* /actividades/add/index.php */
 
 input[type="text"]{
-	width:	100%;
+    width:    100%;
 }
 
 textarea{
-	width:		100%;
-	height:		20em;
+    width:        100%;
+    height:        20em;
 }
 
 div.tab_content_hidden{
-	display:	none;
+    display:    none;
 }
 
 div#activity_images input[name="city"]{
-        width:  	100%;
-	max-width:	15em;
+        width:      100%;
+    max-width:    15em;
 }
 
 div#activity_images input[name="day"]{
-	width:	2em;
+    width:    2em;
 }
 
 div#activity_images input[name="month"]{
-	width:	2em;
+    width:    2em;
 }
 
 div#activity_images input[name="year"]{
-	width:	4em;
+    width:    4em;
 }
 
 div#activity_images input[name="hour"]{
-	width:	2em;
+    width:    2em;
 }
 
 div#activity_images input[name="minute"]{
-	width:	2em;
+    width:    2em;
 }
 
 div#activity_images input[name="price"]{
-	width:	4em;
+    width:    4em;
 }
 
 div#activity_images input[name="people"]{
-	width:	4em;
+    width:    4em;
 }
 
 div.image_upload_container{
-	margin:	0.5em 0 0.5em 1em;
+    margin:    0.5em 0 0.5em 1em;
 }
 
 img.image_upload_preview{
-	max-width:		8em;
-	max-height:		4em;
-	vertical-align:	middle;
+    max-width:        8em;
+    max-height:        4em;
+    vertical-align:    middle;
 }
 
 /* Buttons */
@@ -70,118 +70,118 @@ div#button_container input{
 /* Translate page */
 
 div#translation_instructions{
-	text-align:	center;
+    text-align:    center;
 }
 
 div#translation_instructions ul{
-	display:	inline-block;
-	text-align:	left;
+    display:    inline-block;
+    text-align:    left;
 }
 
 div#translation_instructions ul li{
-	margin-top: 0.5em;
+    margin-top: 0.5em;
 }
 
 table#table_translate_languages td.translate_language{
-	min-width:			30%;
-	border-collapse:	collapse;
-	border:				none;
-	vertical-align:		top;
+    min-width:            30%;
+    border-collapse:    collapse;
+    border:                none;
+    vertical-align:        top;
 }
 
 table#table_translate_itinerary{
-	border-collapse:	collapse;
+    border-collapse:    collapse;
 }
 
 table#table_translate_itinerary td{
-	border:	1px solid #000000;
+    border:    1px solid #000000;
 }
 
 div.translate_row_title{
-	height:	3em;
+    height:    3em;
 }
 
 div.translate_row_description{
-	height:		28em;
-	overflow: 	auto;
+    height:        28em;
+    overflow:     auto;
 }
 
 div.translate_row_description p{
-	font-size:	80%;
+    font-size:    80%;
 }
 
 div.translate_row_description textarea{
-	width:	100%;
-	height:	80%;
-    resize:	none;
+    width:    100%;
+    height:    80%;
+    resize:    none;
 }
 
 div.translate_row_after{
-	height:		28em;
-	overflow: 	auto;
+    height:        28em;
+    overflow:     auto;
 }
 
 div.translate_row_after p{
-	font-size:	80%;
+    font-size:    80%;
 }
 
 div.translate_row_after textarea{
-	width:	100%;
-	height:	80%;
-	resize:	none;
+    width:    100%;
+    height:    80%;
+    resize:    none;
 }
 
 div.translate_row_itinerary table{
-	font-size:	80%;
-	width:		100%;
+    font-size:    80%;
+    width:        100%;
 }
 
 div.translate_row_itinerary table tr{
-	height:		5em;
-	max-height:	5em;
-	min-height:	5em;
+    height:        5em;
+    max-height:    5em;
+    min-height:    5em;
 }
 
 div.translate_row_itinerary table tr{
-	overflow:	auto;
+    overflow:    auto;
 }
 
 div.translate_row_itinerary table td textarea{
-	width:		100%;
-	min-width:	10em;
-	height:		100%;
-	resize:		none;
+    width:        100%;
+    min-width:    10em;
+    height:        100%;
+    resize:        none;
 }
 
 /* /actividades/add/itinerary.php */
 table#itinerary{
-	margin:			1em;
-	border-collapse:	collapse; 
-	border:			0.1em solid #000000;
+    margin:            1em;
+    border-collapse:    collapse; 
+    border:            0.1em solid #000000;
 }
 
 table#itinerary tr.itinerary_row{
-	vertical-align:	top;
-	border-top:		0.5em solid #333333;
-	display:		none;
+    vertical-align:    top;
+    border-top:        0.5em solid #333333;
+    display:        none;
 }
 
 table#itinerary tr#itinerary_row_0{
-	display:	table-row;
-	border-top:	0.1em solid #000000;
+    display:    table-row;
+    border-top:    0.1em solid #000000;
 }
 
 table#itinerary tr.itinerary_row td.itinerary_cell{
-	border:		0.1em solid #000000;
-	padding:	0.5em;
+    border:        0.1em solid #000000;
+    padding:    0.5em;
 }
 
 table#itinerary tr.itinerary_row td.itinerary_cell_content{
-        width:	100%;
+        width:    100%;
 }
 
 table#itinerary tr.itinerary_row td.itinerary_cell h4{
-	margin:	0.3em;
+    margin:    0.3em;
 }
 
 table#itinerary tr.itinerary_row td.time{
@@ -190,119 +190,119 @@ table#itinerary tr.itinerary_row td.time{
 
 
 table#itinerary tr.itinerary_row td.time input{
-	width:	3em;
+    width:    3em;
 }
 
 table#itinerary tr.itinerary_row td.time select{
-	max-width:	10em;
+    max-width:    10em;
 }
 
 table#itinerary tr.itinerary_row td.time span{
-	font-size:			85%;
-	color:				#6040a8;
-	text-shadow:		0 0 0.5em #7799ff;
-	text-decoration:	none;
-	transition:			all .3s ease-in-out;
+    font-size:            85%;
+    color:                #6040a8;
+    text-shadow:        0 0 0.5em #7799ff;
+    text-decoration:    none;
+    transition:            all .3s ease-in-out;
 }
 
 table#itinerary tr.itinerary_row td.time span:hover{
-	color:				#301075;
-	text-shadow:		0 0 0.4em #ffffff;
-	text-decoration:	underline;
+    color:                #301075;
+    text-shadow:        0 0 0.4em #ffffff;
+    text-decoration:    underline;
 }
 
 table#itinerary tr.itinerary_row td.text textarea{
-	min-width:	15em;
-	height:		7em;
-	resize:		none;
+    min-width:    15em;
+    height:        7em;
+    resize:        none;
 }
 
 input#save_itinerary{
-	width:	30%;
-	margin:	1em 30% 1em 30%;
+    width:    30%;
+    margin:    1em 30% 1em 30%;
 }
 
 /* Activity list */
 
 table#activity_list{
-	border-collapse:	collapse;
-	margin:				0.5em;
+    border-collapse:    collapse;
+    margin:                0.5em;
 }
 
 table#activity_list td, th{
-	border: 	1px solid black;
-	padding:	0.5em;
+    border:     1px solid black;
+    padding:    0.5em;
 }
 
 table#activity_list th{
-	background-color:	#66aaff;
+    background-color:    #66aaff;
 }
 
 table#activity_list td.activity_column_title{
-	width:	10%;
+    width:    10%;
 }
 
 table#activity_list td.activity_column_text{
-	width:	25%;
+    width:    25%;
 }
 
 table#activity_list td.activity_column_text ul{
-	margin:		0;
+    margin:        0;
 }
 
 table#activity_list td.activity_column_text li{
-	margin:		0.5em 0.1em 0 0.2em;
-	font-size:	80%;
-	font-style:	italic;
+    margin:        0.5em 0.1em 0 0.2em;
+    font-size:    80%;
+    font-style:    italic;
 }
 
 table#activity_list td.activity_column_text img{
-	max-width:	5em;
-	max-height:	2em;
-	border:		0.1em solid black;
-	margin:		0.05em;
+    max-width:    5em;
+    max-height:    2em;
+    border:        0.1em solid black;
+    margin:        0.05em;
 }
 
 table#activity_list td.activity_column_details{
-	font-size:	80%;
-	width:		10%;
-	text-align:	center;
+    font-size:    80%;
+    width:        10%;
+    text-align:    center;
 }
 
 table#activity_list td.activity_column_translations{
-	width:		10%;
-	text-align:	center;
+    width:        10%;
+    text-align:    center;
 }
 
 table#activity_list td.activity_column_action{
-	width:		10%;
-	text-align:	center;
+    width:        10%;
+    text-align:    center;
 }
 
 table#activity_list td.activity_column_action input{
-	margin: 	0.05em;
-	padding:	0.06em;
-	font-size:	70%
+    margin:     0.05em;
+    padding:    0.06em;
+    font-size:    70%
 }
 
 table#activity_list form{
-	margin:	0;
+    margin:    0;
 }
 
 table#activity_list td.activity_column_action input[type="button"], input[type="submit"]{
-	width:			90%;
-	margin-top:		0.2em;
-	margin-bottom:	0.2em;
+    width:            90%;
+    margin-top:        0.2em;
+    margin-bottom:    0.2em;
 }
 
 div#translate_controls{
-	width:			50%;
-	margin-left:	auto;
-	margin-right:	auto;
-	text-align:		center;
+    width:            50%;
+    margin-left:    auto;
+    margin-right:    auto;
+    text-align:        center;
 }
 
 div#translate_controls input{
-	width:		100%;
-	margin-top:	1em;
+    width:        100%;
+    margin-top:    1em;
 }

+ 56 - 56
www-admin/css/blog.css

@@ -2,149 +2,149 @@
 
 /* Post title */
 input[type=text]{
-	width:	100%;
+    width:    100%;
 }
 
 /* Post text */ 
 textarea{
-	width:	100%;
-	height:	20em;
+    width:    100%;
+    height:    20em;
 }
 
 div.image_upload_container{
-	border-radius:		1em;
-	vertical-align:		top;
-	display:			inline-block;
-	background-color:	#888888;
-	padding:			1em;
-	margin:				1em 1em 1em 1em;
+    border-radius:        1em;
+    vertical-align:        top;
+    display:            inline-block;
+    background-color:    #888888;
+    padding:            1em;
+    margin:                1em 1em 1em 1em;
 }
 
 img.image_upload_preview{
-	display:	none;
-	height:		5em;
+    display:    none;
+    height:        5em;
 }
 
 /* Buttons */
 div#add_button_container{
-	text-align:	center;
+    text-align:    center;
 }
 
 div#add_button_container input{
-	width:	30%;
-	margin:	0.5em auto 0.5em auto;	
+    width:    30%;
+    margin:    0.5em auto 0.5em auto;    
 }
 
 
 /* /blog/index.php */
 
 table#blog_post_list{
-	border-collapse:	collapse;
-	margin:				0.5em;
+    border-collapse:    collapse;
+    margin:                0.5em;
 }
 
 table#blog_post_list td, th{
-	border: 	1px solid black;
-	padding:	0.5em;
+    border:     1px solid black;
+    padding:    0.5em;
 }
 
 table#blog_post_list th{
-	background-color:	#66aaff;
+    background-color:    #66aaff;
 }
 
 table#blog_post_list td.blog_column_title{
-	width:	10%;
+    width:    10%;
 }
 
 table#blog_post_list td.blog_column_text{
-	width:	25%;
+    width:    25%;
 }
 
 table#blog_post_list td.blog_column_text img{
-	max-width:	5em;
-	max-height:	2em;
-	border:		0.1em solid black;
-	margin:		0.05em;
+    max-width:    5em;
+    max-height:    2em;
+    border:        0.1em solid black;
+    margin:        0.05em;
 }
 
 table#blog_post_list td.blog_column_details{
-	font-size:	80%;
-	width:		10%;
-	text-align:	center;
+    font-size:    80%;
+    width:        10%;
+    text-align:    center;
 }
 
 table#blog_post_list td.blog_column_translations{
-	width:		10%;
-	text-align:	center;
+    width:        10%;
+    text-align:    center;
 }
 
 table#blog_post_list td.blog_column_action{
-	width:		10%;
-	text-align:	center;
+    width:        10%;
+    text-align:    center;
 }
 
 table#blog_post_list td.blog_column_action input{
-	margin: 	0.05em;
-	padding:	0.06em;
-	font-size:	70%
+    margin:     0.05em;
+    padding:    0.06em;
+    font-size:    70%
 }
 
 
 table#blog_post_list form{
-	margin:	0;
+    margin:    0;
 }
 
 table#blog_post_list input[type="button"], input[type="submit"]{
-	width:			90%;
-	margin-top:		0.2em;
-	margin-bottom:	0.2em;
+    width:            90%;
+    margin-top:        0.2em;
+    margin-bottom:    0.2em;
 }
 
 /* /blog/edit/index.php */
 
 img.image_upload_preview_visible{
-	display:	block;
-	height:		5em;
+    display:    block;
+    height:        5em;
 }
 
 
 /* Translate page */
 
 div#translation_instructions{
-	text-align:	center;
+    text-align:    center;
 }
 
 div#translation_instructions ul{
-	display:	inline-block;
-	text-align:	left;
+    display:    inline-block;
+    text-align:    left;
 }
 
 div#translation_instructions ul li{
-	margin-top: 0.5em;
+    margin-top: 0.5em;
 }
 
 table#table_translate_languages td.translate_language{
-	min-width:			30%;
-	border-collapse:	collapse;
-	border:				none;
-	vertical-align:		top;
+    min-width:            30%;
+    border-collapse:    collapse;
+    border:                none;
+    vertical-align:        top;
 }
 
 div.translate_row_title{
-	height:	3em;
+    height:    3em;
 }
 
 div.translate_row_description{
-	max-height:	20em;
-	overflow: 	auto;
+    max-height:    20em;
+    overflow:     auto;
 }
 
 div.translate_row_description p{
-	font-size:	80%;
+    font-size:    80%;
 }
 
 div.translate_row_description textarea{
-	width:	100%;
-	height:	80%;
-    resize:	none;
+    width:    100%;
+    height:    80%;
+    resize:    none;
 }

+ 13 - 0
www-admin/css/estadisticas.css

@@ -0,0 +1,13 @@
+div.section_row{
+    margin: 0;
+    text-align: center;
+}
+
+div.section_row div.section_cell{
+    text-align: left;
+    margin: 0;
+    padding: 1em;
+    width: 40%;
+    display: inline-block;
+  vertical-align: top;
+}

+ 50 - 61
www-admin/css/galeria.css

@@ -1,96 +1,85 @@
-div.album_list{
-	display:inline-block;
-	vertical-align:	bottom;
-}
-
-/* Translate page */
+/* Album list */
 
-div#translation_instructions{
-	text-align:	center;
+table#album_list{
+        border-collapse:        collapse;
+        margin:                         0.5em;
 }
 
-div#translation_instructions ul{
-	display:	inline-block;
-	text-align:	left;
+table#album_list td, th{
+        border:         1px solid black;
+        padding:        0.5em;
 }
 
-div#translation_instructions ul li{
-	margin-top: 0.5em;
+table#album_list th{
+        background-color:       #66aaff;
 }
 
-table#table_translate_languages td.translate_language{
-	min-width:			30%;
-	border-collapse:	collapse;
-	border:				none;
-	vertical-align:		top;
+table#album_list td.album_column_title{
+        width:  10%;
 }
 
-table#table_translate_photos{
-	border-collapse:	collapse;
+table#album_list td.album_column_text{
+        width:  25%;
 }
 
-table#table_translate_photos td.details{
-	width:	24%;
-	border:	1px solid #000000;
-	vertical-align:	top;
+table#album_list td.album_column_text ul{
+        margin:         0;
 }
 
-table#table_translate_photos td.image{
-	max-width:		8.5em;
-	border:			1px solid #000000;
-	vertical-align:	top;
+table#album_list td.album_column_text li{
+        margin:         0.5em 0.1em 0 0.2em;
+        font-size:      80%;
+        font-style:     italic;
 }
 
-table#table_translate_photos textarea{
-	width:		100%;
-	height:		100%;
-	min-height:	6em;
-	resize:		none;
+table#album_list td.album_column_text img{
+        max-width:      5em;
+        max-height:     2em;
+        border:         0.1em solid black;
+        margin:         0.05em;
 }
 
-table#table_translate_photos img{
-	min-width:	8em;
-	min-height:	6em;
-	float:		right;
-	border:		1px solid black;
-	resize:		none;
+table#album_list td.album_column_details{
+        font-size:      80%;
+        width:          10%;
+        text-align:     center;
 }
 
-div.translate_row_title{
-	height:	3em;
+table#album_list td.album_column_translations{
+        width:          10%;
+        text-align:     center;
 }
 
-div.translate_row_description{
-	height:		12em;
-	overflow: 	auto;
+table#album_list td.album_column_action{
+        width:          10%;
+        text-align:     center;
 }
 
-div.translate_row_description p{
-	font-size:	80%;
+table#album_list td.album_column_action input{
+        margin:         0.05em;
+        padding:        0.06em;
+        font-size:      70%
 }
 
-div.translate_row_description textarea{
-	width:	100%;
-	height:	80%;
-    resize:	none;
+table#album_list form{
+        margin: 0;
 }
 
-
-div.translate_row_itinerary table td textarea{
-	width:	100%;
-	height:	100%;
-	resize:	none;
+table#album_list td.album_column_action input[type="button"], input[type="submit"]{
+        width:                  90%;
+        margin-top:             0.2em;
+        margin-bottom:  0.2em;
 }
 
-
 div#translate_controls{
-	margin-top:		20px;
-	margin-bottom:	20px;
-	text-align:		center;
+        width:                  50%;
+        margin-left:    auto;
+        margin-right:   auto;
+        text-align:             center;
 }
 
 div#translate_controls input{
-	margin:	20px;
+        width:          100%;
+        margin-top:     1em;
 }
 
-xmp{ white-space:pre-wrap; word-wrap:break-word; }

+ 2 - 2
www-admin/css/galleria.css

@@ -1,4 +1,4 @@
 div.album_list{
-	display:inline-block;
-	vertical-align:	bottom;
+    display:inline-block;
+    vertical-align:    bottom;
 }

+ 2 - 2
www-admin/css/gallery.css

@@ -1,4 +1,4 @@
 div.album_list{
-	display:inline-block;
-	vertical-align:	bottom;
+    display:inline-block;
+    vertical-align:    bottom;
 }

+ 3 - 3
www-admin/css/index.css

@@ -1,8 +1,8 @@
 body{
-	text-align:	center;
-	padding-top:	15%;
+    text-align:    center;
+    padding-top:    15%;
 }
 
 div{
-	display:	inline-block;
+    display:    inline-block;
 }

+ 103 - 99
www-admin/css/lablanca.css

@@ -1,216 +1,220 @@
 span.status_red{
-	font-weight:	bold;
-	color:			#bb0000;
+    font-weight:    bold;
+    color:            #bb0000;
 }
 
 span.status_green{
-	font-weight:	bold;
-	color:			#00bb00;
+    font-weight:    bold;
+    color:            #00bb00;
 }
 
 span.status_yellow{
-	font-weight:	bold;
-	color:			#ff8800;
-}
-
-div#entry_header{
-	display:	table-row;
-	padding:	0;
+    font-weight:    bold;
+    color:            #ff8800;
 }
 
 div#entry_header div.header_text{
-	display:		table-cell;
-	vertical-align:	top;
-	width:			28%;
-	margin:			0;
-	padding:		1em;
+    display:        table-cell;
+    vertical-align:    top;
+    width:            28%;
+    margin:            0;
+    padding:        1em;
 }
 
 div#entry_header div.header_text textarea{
-	width:		100%;
-	min-height:	12em;
-	max-height:	36em;
-	resize:		vertical;
+    width:        100%;
+    min-height:    12em;
+    max-height:    36em;
+    resize:        vertical;
 }
 
 div#entry_header div#header_image{
-	display:		table-cell;
-	vertical-align:	top;
-	width:			16%;
-	margin:			0;
-	padding:		1em;	
+    display:        table-cell;
+    vertical-align:    top;
+    width:            16%;
+    margin:            0;
+    padding:        1em;    
 }
 
 div#entry_header div#header_image img{
-	max-width:	100%;
-	max-height:	10em;
+    max-width:    100%;
+    max-height:    10em;
 }
 
 div#entry_header div.header_text p{
-	font-size:	75%;
-	margin:		0.5em 1em 0.5em 1em;
+    font-size:    75%;
+    margin:        0.5em 1em 0.5em 1em;
 }
 
 div#section_prices table#prices{
-	border-collapse:	collapse;
+    border-collapse:    collapse;
+}
+
+div#section_prices table#prices td, th{
+  border:    0.1em solid black;
 }
 
+div#section_prices table#prices table td, th{
+  border: 0;
+}
+
+
 div#section_prices table#prices input[type='text']{
-	max-width:	10em;
+    max-width:    10em;
 }
 
 div#section_prices table#prices input[type='number']{
-	max-width:	4em;
+    max-width:    4em;
 }
 
 div#section_prices table#offers{
-	width:	100%;
+    width:    100%;
 }
 
 div#section_prices table#offers td{
-	vertical-align:	top;
+    vertical-align:    top;
 }
 
 div#section_prices table#offers td.large{
-	width:	22%;
+    width:    22%;
 }
 
 div#section_prices table#offers td.small{
-	width:	9%;
+    width:    9%;
 }
 
 div#section_prices table#offers input[type='text']{
-	width:		100%;
+    width:        100%;
 }
 
 div#section_prices table#offers textarea{
-	width:		100%;
-	min-height:	4em;
-	max-height:	15em;
-	resize:		vertical;
+    width:        100%;
+    min-height:    4em;
+    max-height:    15em;
+    resize:        vertical;
 }
 
 div#section_prices table#offers input[type='number']{
-	width:		5em;
+    width:        5em;
 }
 
 div#screen_cover{
-	background-color:	#000000;
-	opacity:			0;
-	display:			none;
-	z-index:			900;
-	transition:			opacity	0.5s ease-in-out;
-	width:				100%;
-	height:				100%;
-	position:			fixed;
-	top:				0;
-	left:				0;
-	right:				0;
-	bottom:				0;
+    background-color:    #000000;
+    opacity:            0;
+    display:            none;
+    z-index:            900;
+    transition:            opacity    0.5s ease-in-out;
+    width:                100%;
+    height:                100%;
+    position:            fixed;
+    top:                0;
+    left:                0;
+    right:                0;
+    bottom:                0;
 }
 
 div#form_new_offer{
-	opacity:			0;
-	display:			none;
-	z-index:			1000;
-	transition:			opacity	1s ease-in-out;
-	position:			fixed;
-	height:				80%;
-	top:				10%;
-	left:				10%;
-	right:				10%;
-	bottom:				10%;
+    opacity:            0;
+    display:            none;
+    z-index:            1000;
+    transition:            opacity    1s ease-in-out;
+    position:            fixed;
+    height:                80%;
+    top:                10%;
+    left:                10%;
+    right:                10%;
+    bottom:                10%;
 }
 
 div#form_new_offer table{
-	width:	100%;
+    width:    100%;
 }
 
 div#form_new_offer table td{
-	vertical-align:	top;
+    vertical-align:    top;
 }
 
 div#form_new_offer table td.large{
-	width:	27%;
+    width:    27%;
 }
 
 div#form_new_offer table td.small{
-	width:	9%;
+    width:    9%;
 }
 
 div#form_new_offer table input[type='text']{
-	width:		100%;
+    width:        100%;
 }
 
 div#form_new_offer table textarea{
-	width:		100%;
-	min-height:	4em;
-	max-height:	15em;
-	resize:		vertical;
+    width:        100%;
+    min-height:    4em;
+    max-height:    15em;
+    resize:        vertical;
 }
 
 div#form_new_offer table input[type='number']{
-	width:		5em;
+    width:        5em;
 }
 
 div#form_new_offer div#controls{
-	text-align:	center;
+    text-align:    center;
 }
 
 div#form_new_offer div#controls input{
-	margin:	2em 4em 2em 4em;
+    margin:    2em 4em 2em 4em;
 }
 
 div.entry_schedule table.new_event{
-	width:						80%;
-	margin:						auto;
-	border-collapse:	collapse;
+    width:                        80%;
+    margin:                        auto;
+    border-collapse:    collapse;
 }
 
 div.entry_schedule table.new_event tr{
-	width:	100%;
+    width:    100%;
 }
 
 div.entry_schedule table.new_event th{
-	width:						30%;
-	background-color:	#777777;
+    width:                        30%;
+    background-color:    #777777;
 }
 
 div.entry_schedule table.new_event th{
-	padding-top:			1em;
-	width:						30%;
-	background-color:	#777777;
+    padding-top:            1em;
+    width:                        30%;
+    background-color:    #777777;
 }
 
 div.entry_schedule table.new_event td{
-	padding:					0.3em;
-	text-align:				center;
-	width:						30%;
-	background-color:	#777777;
+    padding:                    0.3em;
+    text-align:                center;
+    width:                        30%;
+    background-color:    #777777;
 }
 
 div.entry_schedule table.new_event td input{
-	display:	inline-block;
+    display:    inline-block;
 }
 
 div.entry_schedule table.new_event td input[type='text']{
-	width:		100%;
-	display:	inline-block;
+    width:        100%;
+    display:    inline-block;
 }
 
 div.entry_schedule table.new_event td textarea{
-	display:	inline-block;
-	width:	100%;
-	resize:	vertical;
+    display:    inline-block;
+    width:    100%;
+    resize:    vertical;
 }
 
 div.entry_schedule table.new_event td select{
-	width:		100%;
-	display:	inline-block;
+    width:        100%;
+    display:    inline-block;
 }
 
 div.entry_schedule table.new_event td input[type='number']{
-	width:		4em;
-	display:	inline-block;
+    width:        4em;
+    display:    inline-block;
 }
 

+ 115 - 115
www-admin/css/m/ui.css

@@ -3,11 +3,11 @@
 * show elements for mobile.               *
 ******************************************/
 .mobile{
-	display:	initial;
+    display:    initial;
 }
 
 .desktop{
-	display:	none !important;
+    display:    none !important;
 }
 
 
@@ -18,87 +18,87 @@
 
 /* Header top container */
 div#header_m{
-	width:		100%;
-	margin:		0;
-	padding:	0;
-	transition:	max-height 0.9s ease-in-out;
+    width:        100%;
+    margin:        0;
+    padding:    0;
+    transition:    max-height 0.9s ease-in-out;
 }
 
 /* Main image of the header, contains the logo */
 div#header_m img#mobile_logo{
-	float:			left;
-	width:			4em;
-	margin-right:	-4em;
-	-webkit-filter:	drop-shadow(0 0 0.2em #336);
-	filter:			url(#drop-shadow);
-	filter:			drop-shadow(0 0 0.2em #336);
-	-ms-filter:		"progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=0, Color='#444')";
-	filter:			"progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=0, Color='#444')";
-	border:			0.05em solid #000011;
-	border-radius:	100%;
+    float:            left;
+    width:            4em;
+    margin-right:    -4em;
+    -webkit-filter:    drop-shadow(0 0 0.2em #336);
+    filter:            url(#drop-shadow);
+    filter:            drop-shadow(0 0 0.2em #336);
+    -ms-filter:        "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=0, Color='#444')";
+    filter:            "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=0, Color='#444')";
+    border:            0.05em solid #000011;
+    border-radius:    100%;
 }
 
 div#header_menu_m div{
-	padding-top:		0.6em;
-	font-weight:		bold;
-	text-align:			center;
-	background-color:	#aaaaaa;
-	border:				1px solid #000000;
+    padding-top:        0.6em;
+    font-weight:        bold;
+    text-align:            center;
+    background-color:    #aaaaaa;
+    border:                1px solid #000000;
 }
 
 div#header_menu_m div#header_m_slider{
-	display:			none;
-	background-color:	#0078ff;
+    display:            none;
+    background-color:    #0078ff;
 }
 
 div#header_menu_m div#header_m_slider img{
-	height: 1em;
-	width:	1em;
-	margin: auto;
+    height: 1em;
+    width:    1em;
+    margin: auto;
 }
 
 div#header_menu_m div#header_m_title{
-	vertical-align:		middle;
-	color:				#ffffff;
-	max-height:			3.5em;
-	padding-top:		0.75em;
-	transition:			max-height 0.3s ease-in-out;
-	overflow:			hidden;
-	padding:			0;
-	background-color:	#0078ff
+    vertical-align:        middle;
+    color:                #ffffff;
+    max-height:            3.5em;
+    padding-top:        0.75em;
+    transition:            max-height 0.3s ease-in-out;
+    overflow:            hidden;
+    padding:            0;
+    background-color:    #0078ff
 }
 
 div#header_menu_m div#header_m_title span {
-	display:	block;
-	margin:		0.4em;
+    display:    block;
+    margin:        0.4em;
 }
 
 div#header_menu_m div#header_m_title span img{
-	vertical-align:	middle;
+    vertical-align:    middle;
 }
 
 div#header_menu_m div#header_m_title img{
-	height: 1.9em;
-	width:	1.9em;
-	float:	center;
+    height: 1.9em;
+    width:    1.9em;
+    float:    center;
 }
 
 div#header_menu_m div.header_m_link{
-/* 	display:			none; */
-	max-height:			0;
-	padding:			0;
-	border:				0;
-	overflow:			hidden;
-	transition:			max-height 0.3s ease-in-out;
-	background-color:	#0078ff;
+/*     display:            none; */
+    max-height:            0;
+    padding:            0;
+    border:                0;
+    overflow:            hidden;
+    transition:            max-height 0.3s ease-in-out;
+    background-color:    #0078ff;
 }
 
 div#header_menu_m div.header_m_link a{
-	color:			#ffffff;
-	text-shadow:	0 0 0.5em #444444;
-	display:		block;
-	width:			100%;
-	height:			2.8em;
+    color:            #ffffff;
+    text-shadow:    0 0 0.5em #444444;
+    display:        block;
+    width:            100%;
+    height:            2.8em;
 }
 
 /******************************************
@@ -108,58 +108,58 @@ div#header_menu_m div.header_m_link a{
 
 /* Table containing the footer elemnts */
 div#footer div#footer_table{
-	display:	block;
+    display:    block;
 }
 
 div#footer div#footer_table div.tr{
-	display:	block;
+    display:    block;
 }
 
 /* Each main section of the footer */
 div#footer div#footer_table div.td{
-	width:			100%;
-	display:		block;
-	text-align:		center;
-	margin-bottom:	1em;
-	margin:			0;
-	padding:		0;
+    width:            100%;
+    display:        block;
+    text-align:        center;
+    margin-bottom:    1em;
+    margin:            0;
+    padding:        0;
 }
 
 /* Images for language selection */
 img.lang{
-	height:			1.5em;
-	margin:			0.5em 1em 0.5em 1em;
-	border-radius:	0.2em;
-	border:			0.1em solid #222222;
-	box-shadow:		0 0 0.3em #333333;
+    height:            1.5em;
+    margin:            0.5em 1em 0.5em 1em;
+    border-radius:    0.2em;
+    border:            0.1em solid #222222;
+    box-shadow:        0 0 0.3em #333333;
 }
 
 img.lang:hover{
- 	box-shadow:		0 0 0.3em #333333; /*NONE*/
+     box-shadow:        0 0 0.3em #333333; /*NONE*/
 }
 
 /* Mobile app link image in the footer */
 img.app{
-	height:			1.5em;
-	margin:			0.5em 1em 0.5em 1em;
-	border-radius:	0.2em;
-	border:			0.1em solid #222222;
-	box-shadow:		0 0 0.3em #333333;
+    height:            1.5em;
+    margin:            0.5em 1em 0.5em 1em;
+    border-radius:    0.2em;
+    border:            0.1em solid #222222;
+    box-shadow:        0 0 0.3em #333333;
 }
 
 img.app:hover{
-	box-shadow:	0 0 0.5em #666666; /*NONE*/
+    box-shadow:    0 0 0.5em #666666; /*NONE*/
 }
 
 /* Each of the social links in the footer */
 img.footer_social_icon{
-	height:			3em;
-	margin:			0.25em;
+    height:            3em;
+    margin:            0.25em;
 }
 
 img.footer_social_icon:hover{
-	-webkit-filter:	drop-shadow(0 0 0.2em #444444);/*NONE*/
-	filter:			drop-shadow(0 0 0.2em #444444);/*NONE*/
+    -webkit-filter:    drop-shadow(0 0 0.2em #444444);/*NONE*/
+    filter:            drop-shadow(0 0 0.2em #444444);/*NONE*/
 }
 
 
@@ -171,70 +171,70 @@ img.footer_social_icon:hover{
 
 /* Content */
 div#content{
-	margin:		auto;
-	width:		95%;
-	max-width:	initial;
-	min-width:	initial;
+    margin:        auto;
+    width:        95%;
+    max-width:    initial;
+    min-width:    initial;
 }
 
 /******************************************
 * Styles for the ad window.               *
 ******************************************/
 div#ad{
-	width:		70%;
-	position:	fixed;
-	bottom:		-25em;
-	left:		15%;
-	right:		15%
+    width:        70%;
+    position:    fixed;
+    bottom:        -25em;
+    left:        15%;
+    right:        15%
 }
 
 div#ad h3{
-	margin-top:	0.3em;
+    margin-top:    0.3em;
 }
 
 div#ad div#ad_details{
-	font-size:		90%;
-	margin:			0.3em;
+    font-size:        90%;
+    margin:            0.3em;
 }
 
 div#ad div#ad_details img{
-	height:			1.2em;
-	width:			1.2em;
-	margin: 		0 0.5em 0 0.5em;
+    height:            1.2em;
+    width:            1.2em;
+    margin:         0 0.5em 0 0.5em;
 }
 
 div#ad div.entry div#ad_image_container{
-	max-height:	9.5em;
-	margin:		0.5em 0.6em 0.5em 0.6em;
-	text-align:	center;
+    max-height:    9.5em;
+    margin:        0.5em 0.6em 0.5em 0.6em;
+    text-align:    center;
 }
 
 div#ad div.entry a{
-	font-size:		100%;
+    font-size:        100%;
 }
 
 /******************************************
 * Styles for the annoying cookie popup.   *
 ******************************************/
 div#cookie_popup{
-	font-size:					80%;
-	color:						#dddddd;
-	text-align:					center;
-	position:					fixed;
-	background-color:			#4c9ed8;
-	border:						0.5em solid #265774;
-	padding:					1em 4em 1em 4em;
-	left:						0em;
-	right:						0em;
-	bottom:						0em;
-	-ms-transform:				rotate(0deg); /* IE 9 */
-	-ms-transform-origin:		0% 0%; /* IE 9 */
-	-webkit-transform:			rotate(00deg); /* Chrome, Safari, Opera */
-	-webkit-transform-origin:	0% 0%; /* Chrome, Safari, Opera */
-	-moz-transform:				rotate(00deg); 
-	-moz-transform-origin:		0% 0%; /* Chrome, Safari, Opera */
-	transform:					rotate(00deg);
-	transform-origin:			0% 0%;
-	box-shadow:					0 0 3em #265774;
-	transition:					bottom .5s ease-in-out;
+    font-size:                    80%;
+    color:                        #dddddd;
+    text-align:                    center;
+    position:                    fixed;
+    background-color:            #4c9ed8;
+    border:                        0.5em solid #265774;
+    padding:                    1em 4em 1em 4em;
+    left:                        0em;
+    right:                        0em;
+    bottom:                        0em;
+    -ms-transform:                rotate(0deg); /* IE 9 */
+    -ms-transform-origin:        0% 0%; /* IE 9 */
+    -webkit-transform:            rotate(00deg); /* Chrome, Safari, Opera */
+    -webkit-transform-origin:    0% 0%; /* Chrome, Safari, Opera */
+    -moz-transform:                rotate(00deg); 
+    -moz-transform-origin:        0% 0%; /* Chrome, Safari, Opera */
+    transform:                    rotate(00deg);
+    transform-origin:            0% 0%;
+    box-shadow:                    0 0 3em #265774;
+    transition:                    bottom .5s ease-in-out;
 }

+ 11 - 11
www-admin/css/main.css

@@ -1,25 +1,25 @@
 body{
-	text-align:	center;
+    text-align:    center;
 }
 
 div#section_table{
-	display:	table;
-	width:		100%;
+    display:    table;
+    width:        100%;
 }
 
 div.section_row{
-	display:	table-row;
+    display:    table-row;
 }
 
 div.section_cell{
-	display:	table-cell;
-	width:		50%;
+    display:    table-cell;
+    width:        50%;
 }
 
 div.section{
-	display:		block;
-	vertical-align:	top;
-	text-align:		left;
-/* 	width:			50%; */
-	margin:			2em;
+    display:        block;
+    vertical-align:    top;
+    text-align:        left;
+/*     width:            50%; */
+    margin:            2em;
 }

+ 41 - 41
www-admin/css/miembros.css

@@ -1,65 +1,65 @@
 div#section_table{
-	display:		inline-block;
-	vertical-align:	top;
-	width:			70%;
+    display:        inline-block;
+    vertical-align:    top;
+    width:            70%;
 }
 
 div#section_table_actions{
-	display:		inline-block;
-	vertical-align:	top;
-	width:			20%;
-	margin-left:	5%;
+    display:        inline-block;
+    vertical-align:    top;
+    width:            20%;
+    margin-left:    5%;
 }
 
 table#member_table{
-	line-height:		150%;
-	border-collapse:	collapse;
-	border: 1px solid black;
-	margin-left:	auto;
-	margin-right:	auto;
+    line-height:        150%;
+    border-collapse:    collapse;
+    border: 1px solid black;
+    margin-left:    auto;
+    margin-right:    auto;
 }
 
 table#member_table tr.member_row_even{
-	background-color:	#ddffdd;
+    background-color:    #ddffdd;
 }
 
 table#member_table tr.member_row_odd{
-	background-color:	#bbddbb;
+    background-color:    #bbddbb;
 }
 
 table#member_table td{
-	padding:	0.8em;
-	border:		1px solid black;
+    padding:    0.8em;
+    border:        1px solid black;
 }
 
 table#member_table th{
-	background-color:	#888888;
-	border: 1px solid black;
+    background-color:    #888888;
+    border: 1px solid black;
 }
 
 div#entry_table{
-	text-align:	center;
+    text-align:    center;
 }
 
 div.member_section{
-	display:		inline-block;
-	vertical-align:	top;
-	padding:		2em;
+    display:        inline-block;
+    vertical-align:    top;
+    padding:        2em;
 }
 
 div.member_section h3{
-	margin-left:	-1em;
-	margin-bottom:	1.8em;
+    margin-left:    -1em;
+    margin-bottom:    1.8em;
 }
 
 ul#member_list_activities{
-	display:	inline-block;
-	vertical-align:	top;
+    display:    inline-block;
+    vertical-align:    top;
 }
 
 ul#member_list_days{
-	display:		inline-block;
-	vertical-align:	top;
+    display:        inline-block;
+    vertical-align:    top;
 }
 
 table#member {
@@ -68,29 +68,29 @@ table#member {
 }
 
 div.section{
-	display:	inline-block;
+    display:    inline-block;
 }
 
 td.entry{
-	background-color:	#cccccc;
-	border-radius:		0.2em;
-	padding:			1.8em;
-	margin:				0.2em;
-	border:				0.1em solid #333333;
-	box-shadow:			0 0 1em #222222;
-	transition:			all .3s ease-in-out;
-	vertical-align:		top;
+    background-color:    #cccccc;
+    border-radius:        0.2em;
+    padding:            1.8em;
+    margin:                0.2em;
+    border:                0.1em solid #333333;
+    box-shadow:            0 0 1em #222222;
+    transition:            all .3s ease-in-out;
+    vertical-align:        top;
 }
 
 td.entry:hover{
-	background-color:	#dddddd;
+    background-color:    #dddddd;
 }
 
 td.entry h3{
-	margin-left:	-0.8em;
-	margin-bottom:	1.4em;
+    margin-left:    -0.8em;
+    margin-bottom:    1.4em;
 }
 
 div#member_action{
-	
+    
 }

+ 152 - 152
www-admin/css/ui.css

@@ -2,7 +2,7 @@
 * Hide elements intended for mobile.      *
 ******************************************/
 .mobile{
-	display:	none;
+    display:    none;
 }
 
 /******************************************
@@ -11,8 +11,8 @@
 
 /* Glogal font */
 @font-face{
-	font-family:	font;
-	src:			url('/font/FreeSans.ttf')
+    font-family:    font;
+    src:            url('/font/FreeSans.ttf')
 }
 
 
@@ -23,78 +23,78 @@
 
 /* Links */
 a{
-	color:				#4c9ed9;
-	text-decoration:	none;
-	transition:			all .2s ease-in-out;
+    color:                #4c9ed9;
+    text-decoration:    none;
+    transition:            all .2s ease-in-out;
 }
 
 a:hover{
-	color:				#347;
-	text-shadow:		0 0 0.4em #265885;
-	text-decoration:	underline;
+    color:                #347;
+    text-shadow:        0 0 0.4em #265885;
+    text-decoration:    underline;
 }
 
 /* Fake links */
 .fake_a{
-	color:				#4c9ed9;
-	text-decoration:	none;
-	transition:			all .2s ease-in-out;
+    color:                #4c9ed9;
+    text-decoration:    none;
+    transition:            all .2s ease-in-out;
 }
 
 .fake_a:hover{
-	color:				#347;
-	text-shadow:		0 0 0.4em #265885;
-	text-decoration:	underline;
+    color:                #347;
+    text-shadow:        0 0 0.4em #265885;
+    text-decoration:    underline;
 }
 
 /* Body */
 body{
-	font-family:		font;
-	margin:				0;
-	/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#b5d3e5+0,e5f4ff+10,e5f4ff+90,b5d3e5+100 */
-	background: #b5d3e5; /* Old browsers */
-	background: -moz-linear-gradient(left, #b5d3e5 0%, #e5f4ff 10%, #e5f4ff 90%, #b5d3e5 100%); /* FF3.6-15 */
-	background: -webkit-linear-gradient(left, #b5d3e5 0%,#e5f4ff 10%,#e5f4ff 90%,#b5d3e5 100%); /* Chrome10-25,Safari5.1-6 */
-	background: linear-gradient(to right, #b5d3e5 0%,#e5f4ff 10%,#e5f4ff 90%,#b5d3e5 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
-	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b5d3e5', endColorstr='#b5d3e5',GradientType=1 ); /* IE6-9 */
+    font-family:        font;
+    margin:                0;
+    /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#b5d3e5+0,e5f4ff+10,e5f4ff+90,b5d3e5+100 */
+    background: #b5d3e5; /* Old browsers */
+    background: -moz-linear-gradient(left, #b5d3e5 0%, #e5f4ff 10%, #e5f4ff 90%, #b5d3e5 100%); /* FF3.6-15 */
+    background: -webkit-linear-gradient(left, #b5d3e5 0%,#e5f4ff 10%,#e5f4ff 90%,#b5d3e5 100%); /* Chrome10-25,Safari5.1-6 */
+    background: linear-gradient(to right, #b5d3e5 0%,#e5f4ff 10%,#e5f4ff 90%,#b5d3e5 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
+    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b5d3e5', endColorstr='#b5d3e5',GradientType=1 ); /* IE6-9 */
 
 }
 
 /* WARNING: If styles change dhere, make changes on commment scripts */
-input[type="text"], input[type="number"], input[type="date"]{
-	border-radius:		0.3em;
-	height:				1.5em;
-	border:				0.2em solid #0078ff;
-	color:				#002255;
-	background-color:	#ccddff;
-	margin:				0.1em;
-}
-
-input[type="button"], input[type="submit"], input[type="password"], input[type="file"], select{
-	border-radius:		0.3em;
-	height:				2em;
-	border:				0.2em solid #0078ff;
-	font-weight:		bold;
-	color:				#ffffff;
-	background-color:	#124567;
-	cursor:				pointer;
-	margin:				0.1em;
-	letter-spacing: 	0.1em;
+input[type="text"], input[type="number"], input[type="date"], input[type="password"]{
+    border-radius:        0.3em;
+    height:                1.5em;
+    border:                0.2em solid #0078ff;
+    color:                #002255;
+    background-color:    #ccddff;
+    margin:                0.1em;
+}
+
+input[type="button"], input[type="submit"], input[type="file"], select{
+    border-radius:        0.3em;
+    height:                2em;
+    border:                0.2em solid #0078ff;
+    font-weight:        bold;
+    color:                #ffffff;
+    background-color:    #124567;
+    cursor:                pointer;
+    margin:                0.1em;
+    letter-spacing:     0.1em;
 }
 
 textarea{
-	border-radius:		0.3em;
-	min-height:			2em;
-	max-height:			15em;
-	border:				0.2em solid #0078ff;
-	color:				#002255;
-	background-color:	#ccddff;
-	resize:				vertical;
-	margin:				0.1em;
+    border-radius:        0.3em;
+    min-height:            2em;
+    max-height:            15em;
+    border:                0.2em solid #0078ff;
+    color:                #002255;
+    background-color:    #ccddff;
+    resize:                vertical;
+    margin:                0.1em;
 }
 
 li{
-	list-style-image:	url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAG0lEQVQImWNgIBqU//+PWwKGcUoQVECanVgAAJSsH/KywgEfAAAAAElFTkSuQmCC');
+    list-style-image:    url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAG0lEQVQImWNgIBqU//+PWwKGcUoQVECanVgAAJSsH/KywgEfAAAAAElFTkSuQmCC');
 }
 
 /******************************************
@@ -104,89 +104,89 @@ li{
 
 /* Icon for slider sections */
 img.slid{
-	height:			0.9em;
-	width:			0.9em;
-	padding:		0.1em;
-	cursor:			pointer;
-	vertical-align:	middle;
-	transition:		opacity 0.5s ease-in-out;
+    height:            0.9em;
+    width:            0.9em;
+    padding:        0.1em;
+    cursor:            pointer;
+    vertical-align:    middle;
+    transition:        opacity 0.5s ease-in-out;
 }
 
 /* Elements that should have the cursor as pointer */
 .pointer{
-	cursor:	pointer;
+    cursor:    pointer;
 }
 
 /* Elemnts not to be displayed */
 .hidden{
-	display:	none;
+    display:    none;
 }
 
 /* Elements with an italic font */
 .italic{
-	font-style:	italic;
+    font-style:    italic;
 }
 
 /*Elements with a bold font*/
 .bold{
-	font-weight:	bold;
+    font-weight:    bold;
 }
 
 /*Stroked elements*/
 .stroke{
-	text-decoration:	line-through;
+    text-decoration:    line-through;
 }
 
 /*Underlined elements*/
 .underline{
-	text-decoration:	underline;
+    text-decoration:    underline;
 }
 
 
 /* Content */
 div#content{
-	margin:		3em auto auto auto;
-	width:		90%;
-	max-width:	80em;
-	min-width:	60em;
+    margin:        3em auto auto auto;
+    width:        90%;
+    max-width:    80em;
+    min-width:    60em;
 }
 
 /* Sections */
 div.section{
-	border-left:		0.1em solid #000011;
-	border-right:		0.1em solid #000011;
-	border-bottom:		0.1em solid #000011;
-	border-radius:		1em;
-	padding:			0 0 0.5em 0;
-	background-color:	#98c8ff;
-	-webkit-filter:		drop-shadow(0 0 0.4em #000011);
-	filter:				drop-shadow(0 0 0.4em #000011);
-    -ms-filter:			"progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=0, Color='#000011')";
-    filter:				"progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=0, Color='#000011')";
+    border-left:        0.1em solid #000011;
+    border-right:        0.1em solid #000011;
+    border-bottom:        0.1em solid #000011;
+    border-radius:        1em;
+    padding:            0 0 0.5em 0;
+    background-color:    #98c8ff;
+    -webkit-filter:        drop-shadow(0 0 0.4em #000011);
+    filter:                drop-shadow(0 0 0.4em #000011);
+    -ms-filter:            "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=0, Color='#000011')";
+    filter:                "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=0, Color='#000011')";
 }
 
 /* Title for each section */
 div.section .section_title{
-	font-size:					120%;
-	font-style:					bold;
-	color:						#ffffff;
-	background-color:			#0078ff;
-	padding:					0.5em 2em 0.1em 1.5em;
-	border-top-left-radius:		0.7em;
-	border-top-right-radius:	0.7em;
-	border:						0.1em solid #000011;
-	margin:						0;
+    font-size:                    120%;
+    font-style:                    bold;
+    color:                        #ffffff;
+    background-color:            #0078ff;
+    padding:                    0.5em 2em 0.1em 1.5em;
+    border-top-left-radius:        0.7em;
+    border-top-right-radius:    0.7em;
+    border:                        0.1em solid #000011;
+    margin:                        0;
 }
 
 /* Entries */
 .entry{
-	background-color:	#ffffff;
-	padding:			0.2em;
-	margin:				0.4em;
-	border:				0.1em solid #6D6990;
-	border-radius:		0.3em;
-	box-shadow:			inset 0 0 0.2em #dde;
-	transition:			all .3s ease-in-out;
+    background-color:    #ffffff;
+    padding:            0.2em;
+    margin:                0.4em;
+    border:                0.1em solid #6D6990;
+    border-radius:        0.3em;
+    box-shadow:            inset 0 0 0.2em #dde;
+    transition:            all .3s ease-in-out;
 }
 
 
@@ -194,100 +194,100 @@ div.section .section_title{
 * Main toolbar.                           *
 ******************************************/
 div#member_action input{
-	margin:	0.5em 2em 0.5em 2em;
+    margin:    0.5em 2em 0.5em 2em;
 }
 
 div#toolbar{
-	background-color:	#000000;
-	margin:				0;
-	width:				100%;
-	height:				2em;
-	padding:			0;
+    background-color:    #000000;
+    margin:                0;
+    width:                100%;
+    height:                2em;
+    padding:            0;
 }
 
 div#toolbar img{
-	height:			1.6em;
-	vertical-align:	center;
+    height:            1.6em;
+    vertical-align:    center;
 }
 
 div#toolbar table{
-	width:				90%;
-	height:				100%;
-	margin-left:		auto;
-	margin-right:		auto;
-	border-spacing:		0;
-    border-collapse:	collapse;
-	margin:				0;
-	table-layout:		fixed;
+    width:                90%;
+    height:                100%;
+    margin-left:        auto;
+    margin-right:        auto;
+    border-spacing:        0;
+    border-collapse:    collapse;
+    margin:                0;
+    table-layout:        fixed;
 }
 
 div#toolbar td{
-	color:			#dddddd;
-	font-weight:	bold;
-	text-align:		center;
+    color:            #dddddd;
+    font-weight:    bold;
+    text-align:        center;
 }
 
 div#toolbar td a{
-	color:				#dddddd;
-	font-weight:		bold;
-	text-align:			center;
-	text-shadow:		none;
-	text-decoration:	none;
-	transition:			all .3s ease-in-out;
+    color:                #dddddd;
+    font-weight:        bold;
+    text-align:            center;
+    text-shadow:        none;
+    text-decoration:    none;
+    transition:            all .3s ease-in-out;
 }
 
 /******************************************
 * Secondary toolbars.                     *
 ******************************************/
 div.secondary_toolbar{
-	background-color:	#333333;
-	margin:				0;
-	display:			none;
-	width:				100%;
-	height:				2em; 	
+    background-color:    #333333;
+    margin:                0;
+    display:            none;
+    width:                100%;
+    height:                2em;     
 }
 
 div.secondary_toolbar table{
-	width:			90%;
-	margin-left:	auto;
-	margin-right:	auto;
-	table-layout:	fixed;
+    width:            90%;
+    margin-left:    auto;
+    margin-right:    auto;
+    table-layout:    fixed;
 }
 
 div.secondary_toolbar td{
-	text-align:	center;
+    text-align:    center;
 }
 
 div.secondary_toolbar td a{
-	color:				#dddddd;
-	font-weight:		bold;
-	text-align:			center;
-	text-shadow:		none;
-	text-decoration:	none;
-	transition:			all .3s ease-in-out;
+    color:                #dddddd;
+    font-weight:        bold;
+    text-align:            center;
+    text-shadow:        none;
+    text-decoration:    none;
+    transition:            all .3s ease-in-out;
 }
 
 div.secondary_toolbar td a:hover{
-	color:				#dddddd;
-	text-shadow:		none;
-	text-decoration:	none;
+    color:                #dddddd;
+    text-shadow:        none;
+    text-decoration:    none;
 }
 
 /******************************************
 * Translation elements.                   *
 ******************************************/
 table.translation_table{
-	border-collapse:	collapse;
+    border-collapse:    collapse;
 }
 
 table.translation_table th{
-	font-weight:		bold;
-	font-size:			1.1em;
-	border:	1px solid #000000;
+    font-weight:        bold;
+    font-size:            1.1em;
+    border:    1px solid #000000;
 }
 
 table.translation_table td{
-	border:	1px solid #000000;
+    border:    1px solid #000000;
 }
 
 
@@ -296,23 +296,23 @@ table.translation_table td{
 ******************************************/
 
 div#lang_tabs{
-	margin-top:	2em;
-	margin-bottom:	2em;
+    margin-top:    2em;
+    margin-bottom:    2em;
 }
 
 div#lang_tabs table{
-	width:	100%;
+    width:    100%;
 }
 
 div#lang_tabs td{
-	color:		#555555;
-	font-weight:	bold;
-	width:		33%;
-	border:		0.1em solid black;
-	margin:		0;
+    color:        #555555;
+    font-weight:    bold;
+    width:        33%;
+    border:        0.1em solid black;
+    margin:        0;
 }
 
 div#lang_tabs td.lang_tabs_active{
-	color:		#0078ff;
-	border-bottom:	0.1em solid #ffffff;
+    color:        #0078ff;
+    border-bottom:    0.1em solid #ffffff;
 }

+ 175 - 0
www-admin/estadisticas/web/index.php

@@ -0,0 +1,175 @@
+<?php
+    $http_host = $_SERVER['HTTP_HOST'];
+    $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+?>
+<html>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Estadisticas Web - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/estadisticas.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/estadisticas.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+        <?php include('../../toolbar.php'); ?>
+        <div id='content'>
+            <div id='section_table'>
+                <div class='section_row'>
+                    <div class='section_cell'>
+                        <div class='section'>
+                            <h3 class='section_title'>Visitantes &Uacute;nicos</h3>
+                            <?php
+                                $q_total = mysqli_query($con, "SELECT COUNT(id) AS c FROM stat_visit;");
+                                $q_week = mysqli_query($con, "SELECT COUNT(id) AS c FROM stat_visit WHERE id IN (SELECT visit FROM stat_view WHERE dtime > adddate(curdate(), INTERVAL 1-DAYOFWEEK(curdate()) DAY));");
+                                $q_month = mysqli_query($con, "SELECT COUNT(id) AS c FROM stat_visit WHERE id IN (SELECT visit FROM stat_view WHERE dtime > LAST_DAY(NOW() - INTERVAL 1 MONTH) + INTERVAL 1 DAY);");
+                                $q_year =  mysqli_query($con, "SELECT COUNT(id) AS c FROM stat_visit WHERE id IN (SELECT visit FROM stat_view WHERE dtime > DATE_FORMAT(NOW() ,'%Y-01-01'));");
+                                $r_total = mysqli_fetch_array($q_total);
+                                $r_week = mysqli_fetch_array($q_week);
+                                $r_month = mysqli_fetch_array($q_month);
+                                $r_year = mysqli_fetch_array($q_year);
+                            ?>
+                            <div class='entry'>
+                                <ul>
+                                    <li>Totales: <?php echo($r_total['c']); ?> </li>
+                                    <li>Semana: <?php echo($r_week['c']); ?> </li>
+                                    <li>Mes: <?php echo($r_month['c']); ?> </li>
+                                    <li>A&ntilde;o: <?php echo($r_year['c']); ?> </li>
+                                </ul>
+                            </div> <!-- .entry -->
+                        </div> <!-- .section -->
+                    </div> <!-- .section_cell -->
+                    <div class='section_cell'>
+                        <div class='section'>
+                            <h3 class='section_title'>Gr&aacute;fico</h3>
+                            <div class='entry'>
+<?php
+                                $q_section = mysqli_query($con, "SELECT COUNT(visit) v, section FROM stat_view WHERE section != 'error' AND entry = '' GROUP BY section ORDER BY COUNT(visit)")
+                                $q_blog = mysqli_query($con, "SELECT COUNT(visit) v, section, entry FROM stat_view WHERE section = 'blog' AND entry IS NOT null GROUP section, entry ORDER BY count(visit) DESC LIMIT 4")
+?>
+                            </div> <!-- .entry -->
+                        </div> <!-- .section -->
+                    </div> <!-- .section_cell -->
+                </div> <!-- .section_row -->
+                <div class='section_row'>
+                    <div class='section_cell'>
+                        <div class='section'>
+                            <h3 class='section_title'>Secciones</h3>
+                            <div class='entry'>
+                                TODO
+                            </div> <!-- .entry -->
+                        </div> <!-- .section -->
+                    </div> <!-- ..section_cell -->
+                    <div class='section_cell'>
+                        <div class='section'>
+                            <h3 class='section_title'>Or&iacute;gen</h3>
+                            <div class='entry'>
+                                <canvas id="piechart" width="400" height="400"></canvas>
+                                <ul id='piechart_legent'>
+                                    <li><span id='lori0c'>##</span> <span id='lori0t'></span></li>
+                                    <li><span id='lori1c'>##</span> <span id='lori1t'></span></li>
+                                    <li><span id='lori2c'>##</span> <span id='lori2t'></span></li>
+                                    <li><span id='lori3c'>##</span> <span id='lori3t'></span></li>
+                                    <li><span id='lori4c'>##</span> <span id='lori4t'></span></li>
+                                    <li><span id='lori5c'>##</span> <span id='lori5t'></span></li>
+                                    <li><span id='lori6c'>##</span> <span id='lori6t'></span></li>
+                                    <li><span id='lori7c'>##</span> <span id='lori7t'></span></li>
+                                </ul>
+                                <script type="text/javascript">
+                                    var data = [0, 0, 0, 0, 0, 0, 0];
+                                    var label = ["", "", "", "", "", "", "", ""];
+                                    var colors = ["#CC3333", "#33CC33", "#3333CC", "#CCCC33", "#CC33CC", "#33CCCC", "#CCCCCC", "#333333"];
+<?php
+                                    $q = mysqli_query($con, "SELECT os, browser, COUNT(id) AS c, ROUND(COUNT(id) * 100 / $r_total[c]) AS percent, ROUND(COUNT(id) * 360 / $r_total[c]) AS deg FROM stat_visit GROUP BY os,browser ORDER BY c DESC LIMIT 7;");
+                                    $i = 0;
+                                    $sum = $r_total['c'];
+                                    $sumPercent = 100;
+                                    $sumDeg = 360;
+                                    while ($r = mysqli_fetch_array($q)){
+?>
+                                        data[<?=$i?>] = <?=$r['deg']?>;
+                                        label[<?=$i?>] = "<?=$r['browser']?> en <?=$r['os']?>\n<?=$r['c']?>(<?=$r['percent']?>%)";
+<?php
+                                        $i ++;
+                                        $sum = $sum - $r['c'];
+                                        $sumPercent = $sumPercent - $r['percent'];
+                                        $sumDeg = $sumDeg - $r['deg'];
+                                    }
+?>
+                                    data[<?=$i?>] = <?=$sumDeg?>;
+                                    label[<?=$i?>] = "Otros<?=$sum?> (<?=$sumPercent?>%)";
+
+                                    function drawSegment(canvas, context, i) {
+                                        context.save();
+                                        var centerX = Math.floor(canvas.width / 2);
+                                        var centerY = Math.floor(canvas.height / 2);
+                                        radius = Math.floor(canvas.width / 2);
+
+                                        var startingAngle = degreesToRadians(sumTo(data, i));
+                                        var arcSize = degreesToRadians(data[i]);
+                                        var endingAngle = startingAngle + arcSize;
+
+                                        context.beginPath();
+                                        context.moveTo(centerX, centerY);
+                                        context.arc(centerX, centerY, radius, 
+                                        startingAngle, endingAngle, false);
+                                        context.closePath();
+
+                                        context.fillStyle = colors[i];
+                                        context.fill();
+
+                                        context.restore();
+
+                                        drawSegmentLabel(i);
+                                    }
+
+                                    function drawSegmentLabel(i) {
+
+                                        var dot = document.getElementById("lori" + i + "c");
+                                        var tex = document.getElementById("lori" + i + "t");
+
+                                        dot.style.backgroundColor = colors[i];
+                                        dot.style.color = colors[i];
+                                        tex.innerHTML = label[i];
+                                    }
+
+                                    function degreesToRadians(degrees) {
+                                        return (degrees * Math.PI)/180;
+                                    }
+
+                                    function sumTo(a, i) {
+                                        var sum = 0;
+                                        for (var j = 0; j < i; j++) {
+                                            sum += a[j];
+                                        }
+                                        return sum;
+                                    }
+
+                                    canvas = document.getElementById("piechart");
+                                    var context = canvas.getContext("2d");
+                                    for (var i = 0; i < data.length; i++) {
+                                        drawSegment(canvas, context, i);
+                                    }
+                                </script>
+
+                            </div> <!-- .entry -->
+                        </div> <!-- .section -->
+                    </div> <!-- ..section_cell -->
+                </div> <!-- .section_row -->
+            </div> <!-- #section_table  -->
+        </div> <!-- #content -->
+    </body>
+</html>
+<?php } ?>

+ 270 - 258
www-admin/functions.php

@@ -1,263 +1,275 @@
 <?php
 
-	$IMG_SIZE_PREVIEW = 600;
-	$IMG_SIZE_MINIATURE = 200;
+    $IMG_SIZE_PREVIEW = 600;
+    $IMG_SIZE_MINIATURE = 200;
+    
+    
+    function getProtocol(){
+        if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
+                $protocol = 'https://';
+        }
+        else {
+                $protocol = 'http://';
+        }
+        return $protocol;
+    }
 
-	/****************************************************
-	* This function is called from almost everywhere at *
-	* the beggining of the page. It initializes the     *
-	* session variables, connect to the db, enabling    *
-	* the variable $con for futher use everywhere in    *
-	* the php code, and populates the arrays $user      *
-	* and $permission, with info about the user.        *
-	* @params:                                          *
-	*    mode: (string) Indicates required permissions  *
-	*          on database. 'ro' gives read             *
-	*          permissions, and 'rw' read and write     *
-	*          permissions. Other values will result in *
-	*          errors.                                  *
-	* @return: (db connection): The connection handler. *
-	****************************************************/
-	function startdb($mode = 'ro'){
-		//Include the db configuration file. It's somehow like this
-		/*
-		<?php
-			$host = 'XXXX';
-			$db_name = 'XXXX';
-			$username_ro = 'XXXX';
-			$username_rw = 'XXXX';
-			$pass_ro = 'XXXX';
-			$pass_rw = 'XXXX';
-		?>
-		*/
-		include('.htpasswd');
-		
-		//Connect to to database
-		if ($mode == 'ro')
-			$con = mysqli_connect($host, $username_ro, $pass_ro, $db_name);
-		else if ($mode == 'rw')
-			$con = mysqli_connect($host, $username_rw, $pass_rw, $db_name);
-			
-		// Check connection
-		if (mysqli_connect_errno()){
-			error_log("Failed to connect to database: " . mysqli_connect_error());
-			return -1;
-		}
-		
-		//Set encoding options
-		mysqli_set_charset($con, 'utf-8');
-		header('Content-Type: text/html; charset=utf8');
-		mysqli_query($con, 'SET NAMES utf8;');
-		
-		//Return the db connection
-		return $con;
-	}
-	
-	
-	/****************************************************
-	* This function turns a date string into a human    *
-	* readable string, deppending o the specified       * 
-	* language.                                         *
-	* @params:                                          *
-	*    strdate: (string): Date string.                *
-	*    lang: (string): Language code (es, en, eu).    *
-	*    http_accept_language: (string) Raw header with *
-	*                          info about client        *
-	*                          language preferences.    *
-	*    time: (boolean): Append the time at the end.   *
-	* @return: (string array) List of the languages     *
-	*          offered, sorted by prefference.          *
-	****************************************************/	
-	function formatDate($strdate, $lang, $time = true){
-		$date = strtotime($strdate);
-		$year = date('o', $date);
-		$month = date('n', $date);
-		$month --;
-		$day = date('j', $date);
-		$wday = date('N', $date);
-		$wday --;
-		$hour = date('H', $date);
-		$minute = date('i', $date);
-		switch ($lang){
-			case 'en':
-				$week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
-				$months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
-				if ($time){
-					$str = "$week[$wday], $months[$month] $day, $year at $hour:$minute";
-				}
-				else{
-					$str = "$week[$wday], $months[$month] $day, $year";
-				}
-				break;
-			case 'eu':
-				$week = ['astelehena', 'asteartea', 'asteazkena', 'osteguna', 'ostirala', 'larumbata', 'igandea'];
-				$months = ['urtarrilaren', 'otsailaren', 'martxoaren', 'apirilaren', 'maiatzaren', 'ekainaren', 'uztailaren', 'abuztuaren', 'irailaren', 'urriaren', 'azaroaren', 'abenduaren'];
-				if ($time){
-					$str = $year . "ko $months[$month] $day" . "an, $week[$wday], $hour:$minute";
-				}
-				else{
-					$str = $year . "ko $months[$month] $day" . "an, $week[$wday]";
-				}
-				break;
-			default:
-				$week = ['Lunes', 'Martes', 'Mi&eacute;rcoles', 'Jueves', 'Viernes', 'S&aacute;bado', 'Domingo'];
-				$months = ['enero', ' febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'];
-				if ($time){
-					$str = "$week[$wday] $day de $months[$month] de $year a las $hour:$minute";
-				}
-				else{
-					$str = "$week[$wday] $day de $months[$month] de $year";
-				}
-		}
-		return $str;
-	}
-	
-	/****************************************************
-	* This function turns a date string into a human    *
-	* readable string, deppending o the specified       * 
-	* language. It is designed to be used for festival  *
-	* days only, since it doesnt return the weekday.    *
-	* @params:                                          *
-	*    strdate: (string): Date string.                *
-	*    lang: (string): Language code (es, en, eu).    *
-	*    http_accept_language: (string) Raw header with *
-	*                          info about client        *
-	*                          language preferences.    *
-	* @return: (string array) List of the languages     *
-	*          offered, sorted by prefference.          *
-	****************************************************/	
-	function formatFestivalDate($strdate, $lang){
-		$date = strtotime($strdate);
-		$month = date('n', $date);
-		$month --;
-		$day = date('j', $date);
-		switch ($lang){
-			case 'en':
-				$months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
-				$str = "$months[$month] $day";
-				break;
-			case 'eu':
-				$months = ['urtarrilaren', 'otsailaren', 'martxoaren', 'apirilaren', 'maiatzaren', 'ekainaren', 'uztailaren', 'abuztuaren', 'irailaren', 'urriaren', 'azaroaren', 'abenduaren'];
-				$str = "$months[$month] $day";
-				break;
-			default:
-				$months = ['enero', ' febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'];
-				$str = "$day de $months[$month]";
-		}
-		return $str;
-	}
-	
-	/****************************************************
-	* This function closes all the opened HTML tags in  *
-	* a given string.                                   * 
-	*                                                   *
-	* @params:                                          *
-	*    html: (string): The string with HTML tags      *
- 	****************************************************/
-	function closeTags($html) {
-		preg_match_all('#<(?!meta|img|br|hr|input\b)\b([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result);
-		$openedtags = $result[1];
-		preg_match_all('#</([a-z]+)>#iU', $html, $result);
-		$closedtags = $result[1];
-		$len_opened = count($openedtags);
-		if (count($closedtags) == $len_opened) {
-			return $html;
-		}
-		$openedtags = array_reverse($openedtags);
-		for ($i=0; $i < $len_opened; $i++) {
-			if (!in_array($openedtags[$i], $closedtags)) {
-				$html .= '</'.$openedtags[$i].'>';
-			} else {
-				unset($closedtags[array_search($openedtags[$i], $closedtags)]);
-			}
-		}
-		return $html;
-	} 
-	
-	/****************************************************
-	* Text shortener. Given a string, it trims in the   *
-	* proximity of the desired streng, ut to the next   * 
-	* white character. If indicated, it will append a   *
-	* link to the full text.                            *
-	*                                                   *
-	* @params:                                          *
-	*    text: (string): The text to shorten.           *
-	*    length: (int): The desired length.             *
-	*    linktext: (string): Text fot the link.         *
-	*    link: (string): URI of the full text.          *
- 	****************************************************/
- 	function cutText($text, $length, $linktext, $link){
-		if (strlen($text) < $length){
-			return $text;
-		}
-		$cut = substr($text, 0, strpos($text, " ", $length));
-		$cut = closeTags($cut);
-		if (strlen($cut) == 0){
-			$cut = $text;
-		}
-		if (strlen($text) != strlen($cut)){
-			$cut = $cut . "... <a href='$link'>$linktext</a>";
-		}
-		return $cut;
-	}
-	
-	/****************************************************
-	* Generates a URL-valid string from a regular one.  *
-	*                                                   *
-	* @params:                                          *
-	*    text: (string): Original string.               *
-	* @return: (string): URL-valid string.              *
-	****************************************************/
-	function permalink($text){
-		$unwanted_array = array('Š'=>'S', 'š'=>'s', 'Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
-							'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U',
-							'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c',
-							'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
-							'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y' );
-		$str = strtr( $text, $unwanted_array );
-		$str = preg_replace('/[^\da-zA-Z ]/i', '', $str);
-		$str = str_replace(' ', '-', $str);
-		return $str;
-	}
-	
-	function login($con, $user, $pass){
-		session_start();
-		$q = mysqli_query($con,"SELECT id, md5(salt) AS s, username FROM user WHERE (lower(username) = lower('$user') OR lower(email) = lower('$user')) AND password = md5('$pass');");
-		if (mysqli_num_rows($q) == 1){
-			$r = mysqli_fetch_array($q);
-			$_SESSION['id'] = $r['id'];
-			$_SESSION['salt'] = $r['s'];
-			$_SESSION['name'] = $r['username'];
-			return true;
-		}
-		else{
-			error_log("Invalid login. username = $_SESSION[name], id = $_SESSION[id]");
-			return false;
-		}
-	}
-	
-	function checkSession($con){
-		session_start(['cookie_lifetime' => 1800,]);
-		$qr = mysqli_query($con, "SELECT id FROM user WHERE id = '$_SESSION[id]' AND md5(salt) = '$_SESSION[salt]';");
-		//error_log("SELECT id FROM user WHERE id = '$_SESSION[id]' AND md5(salt) = '$_SESSION[salt]';");
-		if (mysqli_num_rows($qr) == 1)
-			return true;
-		else{
-			return false;
-			error_log("Invalid session. username = $_SESSION[name], id = $_SESSION[id]");
-		}
-	}
-	
 
-	/****************************************************
-	* Increases version value in table settings by one. *
-	* Helpfull for the app to know when to perform a    * 
-	* full sync. Must be called after every INSERT,     *
-	* UPDATE or DELETE query to the database.           *
- 	****************************************************/
-	function version(){
-		$con = startdb('rw');
-		mysqli_query($con, 'UPDATE settings SET value = value + 1 WHERE name = "version";');
-	}
+    /****************************************************
+    * This function is called from almost everywhere at *
+    * the beggining of the page. It initializes the     *
+    * session variables, connect to the db, enabling    *
+    * the variable $con for futher use everywhere in    *
+    * the php code, and populates the arrays $user      *
+    * and $permission, with info about the user.        *
+    * @params:                                          *
+    *    mode: (string) Indicates required permissions  *
+    *          on database. 'ro' gives read             *
+    *          permissions, and 'rw' read and write     *
+    *          permissions. Other values will result in *
+    *          errors.                                  *
+    * @return: (db connection): The connection handler. *
+    ****************************************************/
+    function startdb($mode = 'ro'){
+        //Include the db configuration file. It's somehow like this
+        /*
+        <?php
+            $host = 'XXXX';
+            $db_name = 'XXXX';
+            $username_ro = 'XXXX';
+            $username_rw = 'XXXX';
+            $pass_ro = 'XXXX';
+            $pass_rw = 'XXXX';
+        ?>
+        */
+        include('.htpasswd');
+        
+        //Connect to to database
+        if ($mode == 'ro')
+            $con = mysqli_connect($host, $username_ro, $pass_ro, $db_name);
+        else if ($mode == 'rw')
+            $con = mysqli_connect($host, $username_rw, $pass_rw, $db_name);
+            
+        // Check connection
+        if (mysqli_connect_errno()){
+            error_log("Failed to connect to database: " . mysqli_connect_error());
+            return -1;
+        }
+        
+        //Set encoding options
+        mysqli_set_charset($con, 'utf-8');
+        header('Content-Type: text/html; charset=utf8');
+        mysqli_query($con, 'SET NAMES utf8;');
+        
+        //Return the db connection
+        return $con;
+    }
+    
+    
+    /****************************************************
+    * This function turns a date string into a human    *
+    * readable string, deppending o the specified       * 
+    * language.                                         *
+    * @params:                                          *
+    *    strdate: (string): Date string.                *
+    *    lang: (string): Language code (es, en, eu).    *
+    *    http_accept_language: (string) Raw header with *
+    *                          info about client        *
+    *                          language preferences.    *
+    *    time: (boolean): Append the time at the end.   *
+    * @return: (string array) List of the languages     *
+    *          offered, sorted by prefference.          *
+    ****************************************************/    
+    function formatDate($strdate, $lang, $time = true){
+        $date = strtotime($strdate);
+        $year = date('o', $date);
+        $month = date('n', $date);
+        $month --;
+        $day = date('j', $date);
+        $wday = date('N', $date);
+        $wday --;
+        $hour = date('H', $date);
+        $minute = date('i', $date);
+        switch ($lang){
+            case 'en':
+                $week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
+                $months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
+                if ($time){
+                    $str = "$week[$wday], $months[$month] $day, $year at $hour:$minute";
+                }
+                else{
+                    $str = "$week[$wday], $months[$month] $day, $year";
+                }
+                break;
+            case 'eu':
+                $week = ['astelehena', 'asteartea', 'asteazkena', 'osteguna', 'ostirala', 'larumbata', 'igandea'];
+                $months = ['urtarrilaren', 'otsailaren', 'martxoaren', 'apirilaren', 'maiatzaren', 'ekainaren', 'uztailaren', 'abuztuaren', 'irailaren', 'urriaren', 'azaroaren', 'abenduaren'];
+                if ($time){
+                    $str = $year . "ko $months[$month] $day" . "an, $week[$wday], $hour:$minute";
+                }
+                else{
+                    $str = $year . "ko $months[$month] $day" . "an, $week[$wday]";
+                }
+                break;
+            default:
+                $week = ['Lunes', 'Martes', 'Mi&eacute;rcoles', 'Jueves', 'Viernes', 'S&aacute;bado', 'Domingo'];
+                $months = ['enero', ' febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'];
+                if ($time){
+                    $str = "$week[$wday] $day de $months[$month] de $year a las $hour:$minute";
+                }
+                else{
+                    $str = "$week[$wday] $day de $months[$month] de $year";
+                }
+        }
+        return $str;
+    }
+    
+    /****************************************************
+    * This function turns a date string into a human    *
+    * readable string, deppending o the specified       * 
+    * language. It is designed to be used for festival  *
+    * days only, since it doesnt return the weekday.    *
+    * @params:                                          *
+    *    strdate: (string): Date string.                *
+    *    lang: (string): Language code (es, en, eu).    *
+    *    http_accept_language: (string) Raw header with *
+    *                          info about client        *
+    *                          language preferences.    *
+    * @return: (string array) List of the languages     *
+    *          offered, sorted by prefference.          *
+    ****************************************************/    
+    function formatFestivalDate($strdate, $lang){
+        $date = strtotime($strdate);
+        $month = date('n', $date);
+        $month --;
+        $day = date('j', $date);
+        switch ($lang){
+            case 'en':
+                $months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
+                $str = "$months[$month] $day";
+                break;
+            case 'eu':
+                $months = ['urtarrilaren', 'otsailaren', 'martxoaren', 'apirilaren', 'maiatzaren', 'ekainaren', 'uztailaren', 'abuztuaren', 'irailaren', 'urriaren', 'azaroaren', 'abenduaren'];
+                $str = "$months[$month] $day";
+                break;
+            default:
+                $months = ['enero', ' febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'];
+                $str = "$day de $months[$month]";
+        }
+        return $str;
+    }
+    
+    /****************************************************
+    * This function closes all the opened HTML tags in  *
+    * a given string.                                   * 
+    *                                                   *
+    * @params:                                          *
+    *    html: (string): The string with HTML tags      *
+     ****************************************************/
+    function closeTags($html) {
+        preg_match_all('#<(?!meta|img|br|hr|input\b)\b([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result);
+        $openedtags = $result[1];
+        preg_match_all('#</([a-z]+)>#iU', $html, $result);
+        $closedtags = $result[1];
+        $len_opened = count($openedtags);
+        if (count($closedtags) == $len_opened) {
+            return $html;
+        }
+        $openedtags = array_reverse($openedtags);
+        for ($i=0; $i < $len_opened; $i++) {
+            if (!in_array($openedtags[$i], $closedtags)) {
+                $html .= '</'.$openedtags[$i].'>';
+            } else {
+                unset($closedtags[array_search($openedtags[$i], $closedtags)]);
+            }
+        }
+        return $html;
+    } 
+    
+    /****************************************************
+    * Text shortener. Given a string, it trims in the   *
+    * proximity of the desired streng, ut to the next   * 
+    * white character. If indicated, it will append a   *
+    * link to the full text.                            *
+    *                                                   *
+    * @params:                                          *
+    *    text: (string): The text to shorten.           *
+    *    length: (int): The desired length.             *
+    *    linktext: (string): Text fot the link.         *
+    *    link: (string): URI of the full text.          *
+     ****************************************************/
+     function cutText($text, $length, $linktext, $link){
+        if (strlen($text) < $length){
+            return $text;
+        }
+        $cut = substr($text, 0, strpos($text, " ", $length));
+        $cut = closeTags($cut);
+        if (strlen($cut) == 0){
+            $cut = $text;
+        }
+        if (strlen($text) != strlen($cut)){
+            $cut = $cut . "... <a href='$link'>$linktext</a>";
+        }
+        return $cut;
+    }
+    
+    /****************************************************
+    * Generates a URL-valid string from a regular one.  *
+    *                                                   *
+    * @params:                                          *
+    *    text: (string): Original string.               *
+    * @return: (string): URL-valid string.              *
+    ****************************************************/
+    function permalink($text){
+        $unwanted_array = array('Š'=>'S', 'š'=>'s', 'Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
+                            'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U',
+                            'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c',
+                            'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
+                            'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y' );
+        $str = strtr( $text, $unwanted_array );
+        $str = preg_replace('/[^\da-zA-Z ]/i', '', $str);
+        $str = str_replace(' ', '-', $str);
+        return $str;
+    }
+    
+    function login($con, $user, $pass){
+        session_start();
+        $q = mysqli_query($con,"SELECT id, md5(salt) AS s, username FROM user WHERE (lower(username) = lower('$user') OR lower(email) = lower('$user')) AND password = md5('$pass');");
+        if (mysqli_num_rows($q) == 1){
+            $r = mysqli_fetch_array($q);
+            $_SESSION['id'] = $r['id'];
+            $_SESSION['salt'] = $r['s'];
+            $_SESSION['name'] = $r['username'];
+            return true;
+        }
+        else{
+            error_log("Invalid login. username = $_SESSION[name], id = $_SESSION[id]");
+            return false;
+        }
+    }
+    
+    function checkSession($con){
+        session_start(['cookie_lifetime' => 1800,]);
+        $qr = mysqli_query($con, "SELECT id FROM user WHERE id = '$_SESSION[id]' AND md5(salt) = '$_SESSION[salt]';");
+        //error_log("SELECT id FROM user WHERE id = '$_SESSION[id]' AND md5(salt) = '$_SESSION[salt]';");
+        if (mysqli_num_rows($qr) == 1)
+            return true;
+        else{
+            return false;
+            error_log("Invalid session. username = $_SESSION[name], id = $_SESSION[id]");
+        }
+    }
+    
+
+    /****************************************************
+    * Increases version value in table settings by one. *
+    * Helpfull for the app to know when to perform a    * 
+    * full sync. Must be called after every INSERT,     *
+    * UPDATE or DELETE query to the database.           *
+     ****************************************************/
+    function version(){
+        $con = startdb('rw');
+        mysqli_query($con, 'UPDATE settings SET value = value + 1 WHERE name = "version";');
+    }
 ?>
-	
+    

+ 102 - 1
www-admin/galeria/add/add.php

@@ -1 +1,102 @@
- 
+<?php
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb('rw');
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+        
+        //Get POST data
+        $title_es = mysqli_real_escape_string($con, $_POST['title_es']);
+        $title_eu = mysqli_real_escape_string($con, $_POST['title_eu']);
+        $title_en = mysqli_real_escape_string($con, $_POST['title_en']);
+        $text_es = mysqli_real_escape_string($con, $_POST['text_es']);
+        $text_eu = mysqli_real_escape_string($con, $_POST['text_eu']);
+        $text_en = mysqli_real_escape_string($con, $_POST['text_en']);
+        $comments = mysqli_real_escape_string($con, $_POST['comments']);
+        $visible = mysqli_real_escape_string($con, $_POST['visible']);
+        $public = mysqli_real_escape_string($con, $_POST['public']);
+        $populate = mysqli_real_escape_string($con, $_POST['populate']);
+        
+        //Check spanish title and generate permalink
+        if ($title_es == null){
+            exit();
+        }
+        else{
+            $permalink = permalink($title_es);
+            $i = 2;
+            $ok = false;
+            $tmppermalink = $permalink;
+            while ($ok == false){
+                $query = mysqli_query($con, "SELECT id FROM post WHERE permalink = '$tmppermalink';");
+                if (mysqli_num_rows($query) > 0){
+                    $tmppermalink = $permalink . "-" . $i;
+                    $i ++;
+                }
+                else{
+                    $permalink = $tmppermalink;
+                    $ok = true;
+                }
+            }
+        }
+        
+        //Check titles with no text
+        if (strlen($title_eu) > 0 && strlen($text_eu) < 1)
+            exit();
+        if (strlen($title_en) > 0 && strlen($text_en) < 1)
+            exit();
+        
+        //Check text with no titles
+        if (strlen($text_eu) > 0 && strlen($title_eu) < 1)
+            exit();
+        if (strlen($text_en) > 0 && strlen($title_en) < 1)
+            exit();
+        
+        //Check booleans and assign default values if not
+        if ($comments == 'off')
+            $comments = 0;
+        else
+            $comments = 1;
+        if ($visible == 'off')
+            $visible = 0;
+        else
+            $visible = 1;
+        if ($public == 'on')
+            $public = 1;
+        else
+            $public = 0;
+        if ($populate == 'on')
+            $populate = 1;
+        else
+            $populate = 0;
+    
+        // If no translations, same text in all languages
+        if (strlen($text_eu) == 0){
+            $text_eu = $text_es;
+            $title_eu = $title_es; 
+        }
+        
+        if (strlen($text_en) == 0){
+            $text_en = $text_es;
+            $title_en = $title_es; 
+        }
+        
+        //Insert into database and get id
+        mysqli_query($con, "INSERT INTO album (permalink, title_es, title_eu, title_en, description_es, description_eu, description_en, open) VALUES ('$permalink', '$title_es', '$title_eu', '$title_en', '$text_es', '$text_eu', '$text_en', $public);");
+        $res_album = mysqli_query($con, "SELECT id FROM album WHERE permalink = '$permalink' ORDER BY dtime DESC LIMIT 1;");
+        $row_album = mysqli_fetch_array($res_album);
+        $album_id = $row_album['id'];
+        
+        version();
+        
+        //Redirect
+        if ($populate == 1){
+            header("Location: /galeria/");
+        }
+        else{
+            header("Location: /galeria/upload.php?album=$album_id");
+        }
+    }
+?>

+ 92 - 0
www-admin/galeria/add/index.php

@@ -0,0 +1,92 @@
+<?php
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+?>
+<html>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nuevo &aacute;lbum - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/galeria.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/galeria.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+        <script type="text/javascript" src="/script/ui.js"></script>
+        <script src="../../ckeditor/ckeditor.js"></script>
+    </head>
+    <body>
+        <?php include('../../toolbar.php'); ?>
+        <div id='content'>
+            <div class="section">
+                <h3 class="section_title">Nuevo &aacute;lbum</h3>
+                <form action="add.php" maxlength="120" method="post" enctype="multipart/form-data" onsubmit="return validate_album();">
+                    <div class="entry">
+                        <div id="lang_tabs">
+                            <table>
+                                <tr>
+                                    <td class="pointer lang_tabs_active" id="lang_tab_es" onclick="showLanguage('es');">
+                                        Castellano
+                                    </td>
+                                    <td class="pointer" id="lang_tab_eu" onclick="showLanguage('eu');">
+                                        Euskera
+                                    </td>
+                                    <td class="pointer" id="lang_tab_en" onclick="showLanguage('en');">
+                                        Ingl&eacute;s
+                                    </td>
+                                </tr>
+                            </table>
+                        </div>
+                        <div id="content_lang_es" class="album_add_language">
+                            <input type="text" id="title_es" name="title_es" placeholder="Titulo"/><br/><br/>
+                            <textarea name="text_es" id="text_es" placeholder="Texto"></textarea>
+                            <script>
+                                CKEDITOR.replace('text_es');
+                            </script>
+                        </div>
+                        <div id="content_lang_eu" class="blog_add_language" style="display:none;">
+                            <input type="text" name="title_eu" id="title_eu" placeholder="Titulu"><br/><br/>
+                            <textarea name="text_eu" id="text_eu" placeholder="Textua"></textarea>
+                            <script>
+                                CKEDITOR.replace('text_eu');
+                            </script>
+                        </div>
+                        <div id="content_lang_en" class="blog_add_language" style="display:none;">
+                            <input type="text" name="title_en" id="title_en" placeholder="Titlu"><br><br/>
+                            <textarea name="text_en" id="text_en" placeholder="Content"></textarea>
+                            <script>
+                                CKEDITOR.replace('text_en');
+                            </script>
+                        </div>
+                    </div> <!--Entry-->
+                    <div class="entry" id="settings">
+                        <h4>Ajustes</h4>
+                        <label><input type="checkbox" name="visible" checked/>&Aacute;lbum visible</label><br/><br/>
+                        <label><input type="checkbox" name="comments" checked/>Permitir comentarios</label><br/><br/>
+                        <label><input type="checkbox" name="public" checked/>Permitir que los usuarios suban sus fotos (previa moderaci&oacute;n).</label><br/><br/>
+                        <label><input type="checkbox" name="populate" checked/>A&ntilde;adir fotos en la siguiente pantalla</label>
+                        <br/><br/><br/><br/>
+                        <div id="add_button_container">
+                            <input type="button" value="Previsualizar" onClick="alert(validate_album());"/> <!--TODO-->
+                            <br/>
+                            <input type="submit" value="Publicar"/>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </body>
+</html>
+
+<?php
+    }
+?>

+ 15 - 15
www-admin/galeria/edit/index.php

@@ -1,17 +1,17 @@
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nuevo post - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nuevo post - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+    </body>
 </html>

+ 80 - 14
www-admin/galeria/index.php

@@ -1,15 +1,81 @@
+<?php
+    $http_host = $_SERVER['HTTP_HOST'];
+    $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    include("../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nuevo post - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-	</head>
-	<body>
-	</body>
-</html>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Galeria - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/galeria.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/galeria.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+        <?php include('../toolbar.php'); ?>
+        <div id='content'>
+            <div class="section">
+                <h3 class="section_title">Galer&iacute;a - <a href="/galeria/add/">A&ntilde;adir &aacute;lbum</a></h3>
+                <div class="entry">
+                    <table id='album_list'>
+                        <tr>
+                            <th>Titulo / Texto</th>
+                            <th>Detalles</th>
+                            <th>Traducciones</th>
+                            <th>Accion</th>
+                        </tr>
+                        <?php
+                            $q = mysqli_query($con, "SELECT id, title_es, title_eu, title_en, description_es, description_eu, description_en, user, DATE_FORMAT(dtime, '%b %d, %Y %H:%i:%s') AS ptime, open FROM album ORDER BY dtime DESC;");
+                            while ($r = mysqli_fetch_array($q)){
+                                echo("<tr>\n<td class='album_column_title'>" . cutText($r['title_es'], 35, '', '') . "<br/>$r[dat]");
+                                echo("<br/>" . str_replace('<br/>', ' ', cutText($r['text_es'], 60, '', '')) . "\n</td>\n");
+                                $q_user = mysqli_query($con, "SELECT username FROM user WHERE id = $r[user];");
+                                $r_user = mysqli_fetch_array($q_user);
+                                echo("<td class='activity_column_details'>$r[ptime]<br/>\n");
+                                //Count
+                                $q_photos = mysqli_query($con, "SELECT count(id) AS cnt FROM photo, photo_album where album = $r[id] and photo = id;");
+                                $r_photos = mysqli_fetch_array($q_photos);
+                                echo("$r_photos[cnt] fotos.<br/>");
+                                echo("Por $r_user[username]<br/>");
+                                echo("<br/>P&uacute;blico: ");
+                                                                if ($r['open'] == 1)
+                                                                        echo("S&iacute;");
+                                                                else
+                                                                        echo("No");
+
+                                echo("</td>\n<td class='gallery_column_translations'>\nEuskera: ");
+                                if (strlen($r['description_eu']) == 0 || $r['description_eu'] == $r['description_es'])
+                                    echo("No");
+                                else
+                                    echo("S&iacute;");
+                                echo("<br/>Ingl&eacute;s: ");
+                                    if (strlen($r['description_en']) == 0 || $r['description_en'] == $r['description_es'])
+                                    echo("No");
+                                else
+                                    echo("S&iacute;");
+                                echo("\n</td>\n<td class='album_column_action'>\n<form action='/album/edit/edit.php?p=$r[id]'>\n<input type='submit' value='Editar / Traducir'/>\n</form>\n");
+                                echo("<input type='button' onClick='delete_album($r[id], \"$r[title_es]\");' value='Borrar'/>");
+                                echo("<form action='/album/moderate/moderate.php?p=$r[id]'>\n<input type='submit' value='Moderar comentarios'/>\n</form>");
+                                echo("</td>\n</tr>");
+                            }
+                            
+                        ?>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </body>
+</html>
+<?php } ?>

+ 15 - 15
www-admin/galeria/moderate/index.php

@@ -1,17 +1,17 @@
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nuevo post - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nuevo post - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+    </body>
 </html>

+ 69 - 69
www-admin/galeria/translate/apply.php

@@ -1,71 +1,71 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb('rw');
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	//Get album fields
-	$id = mysqli_real_escape_string($con, $_POST['id']);
-	$title_en = mysqli_real_escape_string($con, $_POST['title_en']);
-	$desc_en = mysqli_real_escape_string($con, $_POST['description_en']);
-	$title_eu = mysqli_real_escape_string($con, $_POST['title_eu']);
-	$desc_eu = mysqli_real_escape_string($con, $_POST['description_eu']);
-	
-	//Get photo fields
-	$q_i = mysqli_query($con, "SELECT * FROM photo, photo_album WHERE photo.id = photo_album.photo AND album = $id;");
-	$i = 0;
-	$total_i = 0;
-	while ($r_i = mysqli_fetch_array($q_i)){
-		$p_id[$i] = $r_i['id'];
-		$p_title_en[$i] = mysqli_real_escape_string($con, $_POST['photo_' . $p_id[$i] . '_title_en']);
-		$p_desc_en[$i] = mysqli_real_escape_string($con, $_POST['photo_' . $p_id[$i] . '_description_en']);
-		$p_title_eu[$i] = mysqli_real_escape_string($con, $_POST['photo_' . $p_id[$i] . '_title_eu']);
-		$p_desc_eu[$i] = mysqli_real_escape_string($con, $_POST['photo_' . $p_id[$i] . '_description_eu']);
-		$i ++;
-		$total_i ++;
-	}
-	
-	//Get current album data
-	$q = mysqli_query($con, "SELECT * FROM album WHERE id = $id");
-	if (mysqli_num_rows($q) > 0){
-		$r = mysqli_fetch_array($q);
-		
-		//Update album fields
-		if (strlen($title_en) > 0 && $title_en != $r['title_en']){
-			mysqli_query($con, "UPDATE album SET title_en = '$title_en' WHERE id = $id;");
-		}
-		if (strlen($desc_en) > 0 && $desc_en != $r['description_en']){
-			mysqli_query($con, "UPDATE album SET description_en = '$desc_en' WHERE id = $id;");
-		}
-		if (strlen($title_eu) > 0 && $title_eu != $r['title_eu']){
-			mysqli_query($con, "UPDATE album SET title_eu = '$title_eu' WHERE id = $id;");
-		}
-		if (strlen($desc_eu) > 0 && $desc_eu != $r['description_eu']){
-			mysqli_query($con, "UPDATE album SET description_eu = '$desc_eu' WHERE id = $id;");
-		}
-		version();
-	}
-	
-	//Update photo entries
-	for ($i = 0; $i < $total_i; $i ++){
-		$q_i = mysqli_query($con, "SELECT * FROM photo WHERE id = $p_id[$i];");
-		if (mysqli_num_rows($q_i) > 0){
-			$r_i = mysqli_fetch_array($q_i);
-			if (strlen($p_title_en[$i]) > 0 && $p_title_en[$i] != $r_i['title_en']){
-				mysqli_query($con, "UPDATE photo SET title_en = '$p_title_en[$i]' WHERE id = $p_id[$i];");
-			}
-			if (strlen($p_desc_en[$i]) > 0 && $p_desc_en[$i] != $r_i['description_en']){
-				mysqli_query($con, "UPDATE photo SET description_en = '$p_desc_en[$i]' WHERE id = $p_id[$i];");
-			}
-			if (strlen($p_title_eu[$i]) > 0 && $p_title_eu[$i] != $r_i['title_un']){
-				mysqli_query($con, "UPDATE photo SET title_eu = '$p_title_eu[$i]' WHERE id = $p_id[$i];");
-			}
-			if (strlen($p_desc_eu[$i]) > 0 && $p_desc_eu[$i] != $r_i['description_eu']){
-				mysqli_query($con, "UPDATE photo SET description_eu = '$p_desc_eu[$i]' WHERE id = $p_id[$i];");
-			}
-		}
-	}
-	header("Location: /galeria/translate/index.php");	
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb('rw');
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    //Get album fields
+    $id = mysqli_real_escape_string($con, $_POST['id']);
+    $title_en = mysqli_real_escape_string($con, $_POST['title_en']);
+    $desc_en = mysqli_real_escape_string($con, $_POST['description_en']);
+    $title_eu = mysqli_real_escape_string($con, $_POST['title_eu']);
+    $desc_eu = mysqli_real_escape_string($con, $_POST['description_eu']);
+    
+    //Get photo fields
+    $q_i = mysqli_query($con, "SELECT * FROM photo, photo_album WHERE photo.id = photo_album.photo AND album = $id;");
+    $i = 0;
+    $total_i = 0;
+    while ($r_i = mysqli_fetch_array($q_i)){
+        $p_id[$i] = $r_i['id'];
+        $p_title_en[$i] = mysqli_real_escape_string($con, $_POST['photo_' . $p_id[$i] . '_title_en']);
+        $p_desc_en[$i] = mysqli_real_escape_string($con, $_POST['photo_' . $p_id[$i] . '_description_en']);
+        $p_title_eu[$i] = mysqli_real_escape_string($con, $_POST['photo_' . $p_id[$i] . '_title_eu']);
+        $p_desc_eu[$i] = mysqli_real_escape_string($con, $_POST['photo_' . $p_id[$i] . '_description_eu']);
+        $i ++;
+        $total_i ++;
+    }
+    
+    //Get current album data
+    $q = mysqli_query($con, "SELECT * FROM album WHERE id = $id");
+    if (mysqli_num_rows($q) > 0){
+        $r = mysqli_fetch_array($q);
+        
+        //Update album fields
+        if (strlen($title_en) > 0 && $title_en != $r['title_en']){
+            mysqli_query($con, "UPDATE album SET title_en = '$title_en' WHERE id = $id;");
+        }
+        if (strlen($desc_en) > 0 && $desc_en != $r['description_en']){
+            mysqli_query($con, "UPDATE album SET description_en = '$desc_en' WHERE id = $id;");
+        }
+        if (strlen($title_eu) > 0 && $title_eu != $r['title_eu']){
+            mysqli_query($con, "UPDATE album SET title_eu = '$title_eu' WHERE id = $id;");
+        }
+        if (strlen($desc_eu) > 0 && $desc_eu != $r['description_eu']){
+            mysqli_query($con, "UPDATE album SET description_eu = '$desc_eu' WHERE id = $id;");
+        }
+        version();
+    }
+    
+    //Update photo entries
+    for ($i = 0; $i < $total_i; $i ++){
+        $q_i = mysqli_query($con, "SELECT * FROM photo WHERE id = $p_id[$i];");
+        if (mysqli_num_rows($q_i) > 0){
+            $r_i = mysqli_fetch_array($q_i);
+            if (strlen($p_title_en[$i]) > 0 && $p_title_en[$i] != $r_i['title_en']){
+                mysqli_query($con, "UPDATE photo SET title_en = '$p_title_en[$i]' WHERE id = $p_id[$i];");
+            }
+            if (strlen($p_desc_en[$i]) > 0 && $p_desc_en[$i] != $r_i['description_en']){
+                mysqli_query($con, "UPDATE photo SET description_en = '$p_desc_en[$i]' WHERE id = $p_id[$i];");
+            }
+            if (strlen($p_title_eu[$i]) > 0 && $p_title_eu[$i] != $r_i['title_un']){
+                mysqli_query($con, "UPDATE photo SET title_eu = '$p_title_eu[$i]' WHERE id = $p_id[$i];");
+            }
+            if (strlen($p_desc_eu[$i]) > 0 && $p_desc_eu[$i] != $r_i['description_eu']){
+                mysqli_query($con, "UPDATE photo SET description_eu = '$p_desc_eu[$i]' WHERE id = $p_id[$i];");
+            }
+        }
+    }
+    header("Location: /galeria/translate/index.php");    
 ?>

+ 80 - 80
www-admin/galeria/translate/index.php

@@ -1,84 +1,84 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{?>
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Taducir galer&iacute; - Administraci&oacute;n</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/galeria.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/galeria.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-		<?php include('../../toolbar.php'); ?>
-		<div id='content'>
-			<div class='section'>
-				<h3>Albums</h3>
-				<div class='entry'>
-					<?php
-						$q = mysqli_query($con, "SELECT * FROM album;");
-						echo "<table class='translation_table'><tr><th>Nombre</th><th>Ingles</th><th>Euskera</th></tr>\n";
-						while ($r = mysqli_fetch_array($q)){
-							echo "<tr><td><a href='http://$http_host/galeria/translate/translate.php?id=$r[id]'>$r[title_es]</a></td>";
-							$total = 1; //Title is mandatory
-							$translated_en = 0;
-							$translated_eu = 0;
-							
-							//Calculate field number
-							if ($r['title_en'] != $r['title_es']){
-								$translated_en ++;
-							}
-							if ($r['title_eu'] != $r['title_es']){
-								$translated_eu ++;
-							}
-							if (strlen($r['description_es']) > 0){
-								if ($r['description_en'] != $r['description_es']){
-									$translated_en ++;
-								}
-								if ($r['description_eu'] != $r['description_es']){
-									$translated_eu ++;
-								}
-							}
-							$q_i = mysqli_query($con, "SELECT title_es, title_en, title_eu, description_es, description_en, description_eu FROM photo, photo_album where photo = id AND album = $r[id]");
-							while ($r_i = mysqli_fetch_array($q_i)){
-								$total ++;
-								if ($r_i['title_en'] != $r_i['title_es']){
-									$translated_en ++;
-								}
-								if ($r_i['title_eu'] != $r_i['title_es']){
-									$translated_eu ++;
-								}
-								if (strlen($r_i['description_es']) > 0){
-									$total ++;
-									if ($r_i['description_en'] != $r_i['description_es']){
-										$translated_en ++;
-									}
-									if ($r_i['description_eu'] != $r_i['description_es']){
-										$translated_eu ++;
-									}
-								}
-							}
-							
-							//Calculate percents
-							echo "<td>" . intval($translated_en * 100 / $total) . "%</td><td>" . intval($translated_eu * 100 / $total) . "%</td></tr>\n";
-						}
-						echo "</table>\n";
-					?>
-				</div>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Taducir galer&iacute; - Administraci&oacute;n</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/galeria.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/galeria.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+        <?php include('../../toolbar.php'); ?>
+        <div id='content'>
+            <div class='section'>
+                <h3>Albums</h3>
+                <div class='entry'>
+                    <?php
+                        $q = mysqli_query($con, "SELECT * FROM album;");
+                        echo "<table class='translation_table'><tr><th>Nombre</th><th>Ingles</th><th>Euskera</th></tr>\n";
+                        while ($r = mysqli_fetch_array($q)){
+                            echo "<tr><td><a href='http://$http_host/galeria/translate/translate.php?id=$r[id]'>$r[title_es]</a></td>";
+                            $total = 1; //Title is mandatory
+                            $translated_en = 0;
+                            $translated_eu = 0;
+                            
+                            //Calculate field number
+                            if ($r['title_en'] != $r['title_es']){
+                                $translated_en ++;
+                            }
+                            if ($r['title_eu'] != $r['title_es']){
+                                $translated_eu ++;
+                            }
+                            if (strlen($r['description_es']) > 0){
+                                if ($r['description_en'] != $r['description_es']){
+                                    $translated_en ++;
+                                }
+                                if ($r['description_eu'] != $r['description_es']){
+                                    $translated_eu ++;
+                                }
+                            }
+                            $q_i = mysqli_query($con, "SELECT title_es, title_en, title_eu, description_es, description_en, description_eu FROM photo, photo_album where photo = id AND album = $r[id]");
+                            while ($r_i = mysqli_fetch_array($q_i)){
+                                $total ++;
+                                if ($r_i['title_en'] != $r_i['title_es']){
+                                    $translated_en ++;
+                                }
+                                if ($r_i['title_eu'] != $r_i['title_es']){
+                                    $translated_eu ++;
+                                }
+                                if (strlen($r_i['description_es']) > 0){
+                                    $total ++;
+                                    if ($r_i['description_en'] != $r_i['description_es']){
+                                        $translated_en ++;
+                                    }
+                                    if ($r_i['description_eu'] != $r_i['description_es']){
+                                        $translated_eu ++;
+                                    }
+                                }
+                            }
+                            
+                            //Calculate percents
+                            echo "<td>" . intval($translated_en * 100 / $total) . "%</td><td>" . intval($translated_eu * 100 / $total) . "%</td></tr>\n";
+                        }
+                        echo "</table>\n";
+                    ?>
+                </div>
+            </div>
+        </div>
+    </body>
 </html>
 <?php } ?>

+ 82 - 82
www-admin/galeria/translate/translate.php

@@ -1,86 +1,86 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	$http_standard = substr($_SERVER['HTTP_HOST'], 0, strrpos($_SERVER['HTTP_HOST'], ':'));
-	include("../../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
-		$id = mysqli_real_escape_string($con, $_GET['id']);
-		$q = mysqli_query($con, "SELECT * FROM album WHERE id = $id");
-		if(mysqli_num_rows($q) == 0){
-			header("Location: $http_host/galeria/translate/");
-			exit (-1);
-		}
-		else{
-			$r = mysqli_fetch_array($q);
-	?>
+    $http_host = $_SERVER['HTTP_HOST'];
+    $http_standard = substr($_SERVER['HTTP_HOST'], 0, strrpos($_SERVER['HTTP_HOST'], ':'));
+    include("../../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+        $id = mysqli_real_escape_string($con, $_GET['id']);
+        $q = mysqli_query($con, "SELECT * FROM album WHERE id = $id");
+        if(mysqli_num_rows($q) == 0){
+            header("Location: $http_host/galeria/translate/");
+            exit (-1);
+        }
+        else{
+            $r = mysqli_fetch_array($q);
+    ?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Taducir <?php echo $r['title_es']; ?> - Administraci&oacute;n</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/galeria.css"/>
-		<!-- Script files -->
-		
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/galeria.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-		<?php include('../../toolbar.php'); ?>
-		<div id='content'>
-			<div class='section'>
-				<?php
-					echo "<h3>Taducir &#8216;$r[title_es]&#8217;</h3>\n";
-					echo "<div id='translation_instructions' class='entry'><h4>C&oacute;mo traducir</h4>\n";
-					echo "<ul><li>Rellena los campos de abajo para el idioma correspondiente (columna de en medio para ingl&eacute;s, derecha para euskera)</li>\n";
-					echo "<li>No es necesario traducir todos los campos ni todos los idiomas. Traduce solo lo que sepas y quieras.</li>\n";
-					echo "<li>Al terminar, recuerda pulsar el boton &#8216;Guardar&#8217; al final de la p&aacute;gina.</li>\n";
-					echo "<li>Muchas gracias por tu trabajo!</li></ul>\n";
-					echo "</div><br/><br/><h3>Taducir detalles del album</h3>\n";
-					echo "<form method='post' action='http://$http_host/galeria/translate/apply.php'>\n";
-					echo "<input type='hidden' name='id' value='$r[id]'/>\n";
-					echo "<table id='table_translate_languages'><tr>\n";
-					
-					echo "<td class='translate_language'><div class='entry translation'>\n";
-					echo "<h3>Castellano</h4><div class='translate_row_title'>\n<span class='bold'>T&iacute;tulo: </span>$r[title_es]</div>\n";
-					echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><p><xmp>$r[description_es]</xmp></p></div>\n";
-					echo "</div></td>\n";
-					
-					echo "<td class='translate_language'><div class='entry translation'>\n";
-					echo "<h3>Ingl&eacute;s</h4>\n<div class='translate_row_title'><span class='bold'>T&iacute;tulo: </span><input type='text' name='title_en' required value='$r[title_en]'/></div>\n";
-					echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><textarea  name='description_en' required>$r[description_en]</textarea></div>\n";
-					echo "</div></td>\n";
-					
-					echo "<td class='translate_language'><div class='entry translation'>\n";
-					echo "<h3>Euskera</h4><div class='translate_row_title'>\n<span class='bold'>T&iacute;tulo: </span><input required type='text' name='title_eu' required value='$r[title_eu]'/></div>\n";
-					echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><textarea name='description_eu' required>$r[description_eu]</textarea></div>\n";
-					echo "</div></td>\n";
-					
-					echo "</tr></table>\n";
-					$q_p = mysqli_query($con,  "SELECT * FROM photo, photo_album WHERE photo.id = photo_album.photo AND album = $r[id] AND (title_es != '' OR description_es != '');"); //TODO continue here
-					if (mysqli_num_rows($q_p) > 0){
-						echo "<h3>Taducir fotograf&iacute;as</h3><span>Nota: Solo se muestran fotograf&iacute;as con t&iacute;tulo o descripci&oacute;n en castellano.</span><br/>\n";
-						echo "<table id='table_translate_photos'>\n";
-						while ($r_p = mysqli_fetch_array($q_p)){
-							echo "<tr><td class='image'><img class='translate_pic' src='http://$http_standard/img/galeria/miniature/$r_p[file]'/></td>\n";
-							echo "<td class='details'><h4>Castellano</h4><h5>$r_p[title_es]</h5><p>$r_p[description_es]</p></td>\n";
-							echo "<td class='details'><h4>Ingl&eacute;s</h4><input required type='text' name='photo_$r_p[id]_title_en' required value='$r_p[title_en]'/><br/><textarea name='photo_$r_p[id]_description_en' required>$r_p[description_en]</textarea></td>\n";
-							echo "<td class='details'><h4>Euskera</h4><input required type='text' name='photo_$r_p[id]_title_eu' required value='$r_p[title_eu]'/><br/><textarea name='photo_$r_p[id]_description_eu' required>$r_p[description_eu]</textarea></td></tr>\n";
-						}
-						echo "</table>\n";
-					}
-					echo "<div id='translate_controls'><input type='submit' value='Guardar'/><input type='button' value='Cancelar y salir' onClick='exitTranslation();'/></div></form>\n";
-				?>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Taducir <?php echo $r['title_es']; ?> - Administraci&oacute;n</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/galeria.css"/>
+        <!-- Script files -->
+        
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/galeria.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+        <?php include('../../toolbar.php'); ?>
+        <div id='content'>
+            <div class='section'>
+                <?php
+                    echo "<h3>Taducir &#8216;$r[title_es]&#8217;</h3>\n";
+                    echo "<div id='translation_instructions' class='entry'><h4>C&oacute;mo traducir</h4>\n";
+                    echo "<ul><li>Rellena los campos de abajo para el idioma correspondiente (columna de en medio para ingl&eacute;s, derecha para euskera)</li>\n";
+                    echo "<li>No es necesario traducir todos los campos ni todos los idiomas. Traduce solo lo que sepas y quieras.</li>\n";
+                    echo "<li>Al terminar, recuerda pulsar el boton &#8216;Guardar&#8217; al final de la p&aacute;gina.</li>\n";
+                    echo "<li>Muchas gracias por tu trabajo!</li></ul>\n";
+                    echo "</div><br/><br/><h3>Taducir detalles del album</h3>\n";
+                    echo "<form method='post' action='http://$http_host/galeria/translate/apply.php'>\n";
+                    echo "<input type='hidden' name='id' value='$r[id]'/>\n";
+                    echo "<table id='table_translate_languages'><tr>\n";
+                    
+                    echo "<td class='translate_language'><div class='entry translation'>\n";
+                    echo "<h3>Castellano</h4><div class='translate_row_title'>\n<span class='bold'>T&iacute;tulo: </span>$r[title_es]</div>\n";
+                    echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><p><xmp>$r[description_es]</xmp></p></div>\n";
+                    echo "</div></td>\n";
+                    
+                    echo "<td class='translate_language'><div class='entry translation'>\n";
+                    echo "<h3>Ingl&eacute;s</h4>\n<div class='translate_row_title'><span class='bold'>T&iacute;tulo: </span><input type='text' name='title_en' required value='$r[title_en]'/></div>\n";
+                    echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><textarea  name='description_en' required>$r[description_en]</textarea></div>\n";
+                    echo "</div></td>\n";
+                    
+                    echo "<td class='translate_language'><div class='entry translation'>\n";
+                    echo "<h3>Euskera</h4><div class='translate_row_title'>\n<span class='bold'>T&iacute;tulo: </span><input required type='text' name='title_eu' required value='$r[title_eu]'/></div>\n";
+                    echo "<div class='translate_row_description'><span class='bold'>Descripci&oacute;n</span><br/><textarea name='description_eu' required>$r[description_eu]</textarea></div>\n";
+                    echo "</div></td>\n";
+                    
+                    echo "</tr></table>\n";
+                    $q_p = mysqli_query($con,  "SELECT * FROM photo, photo_album WHERE photo.id = photo_album.photo AND album = $r[id] AND (title_es != '' OR description_es != '');"); //TODO continue here
+                    if (mysqli_num_rows($q_p) > 0){
+                        echo "<h3>Taducir fotograf&iacute;as</h3><span>Nota: Solo se muestran fotograf&iacute;as con t&iacute;tulo o descripci&oacute;n en castellano.</span><br/>\n";
+                        echo "<table id='table_translate_photos'>\n";
+                        while ($r_p = mysqli_fetch_array($q_p)){
+                            echo "<tr><td class='image'><img class='translate_pic' src='http://$http_standard/img/galeria/miniature/$r_p[file]'/></td>\n";
+                            echo "<td class='details'><h4>Castellano</h4><h5>$r_p[title_es]</h5><p>$r_p[description_es]</p></td>\n";
+                            echo "<td class='details'><h4>Ingl&eacute;s</h4><input required type='text' name='photo_$r_p[id]_title_en' required value='$r_p[title_en]'/><br/><textarea name='photo_$r_p[id]_description_en' required>$r_p[description_en]</textarea></td>\n";
+                            echo "<td class='details'><h4>Euskera</h4><input required type='text' name='photo_$r_p[id]_title_eu' required value='$r_p[title_eu]'/><br/><textarea name='photo_$r_p[id]_description_eu' required>$r_p[description_eu]</textarea></td></tr>\n";
+                        }
+                        echo "</table>\n";
+                    }
+                    echo "<div id='translate_controls'><input type='submit' value='Guardar'/><input type='button' value='Cancelar y salir' onClick='exitTranslation();'/></div></form>\n";
+                ?>
+            </div>
+        </div>
+    </body>
 </html>
 <?php } } ?>

+ 41 - 40
www-admin/index.php

@@ -1,44 +1,45 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("functions.php");
-	$con = startdb();
-	if (checkSession($con)){
-		header("Location: /main.php");
-		exit (-1);
-	}
-	else{?>
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("functions.php");
+    $con = startdb();
+    if (checkSession($con)){
+        header("Location: /main.php");
+        exit (-1);
+    }
+    else{?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Gasteizko Margolariak - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/index.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/index.css"/>
-	</head>
-	<body>
-		<div class='section'>
-			<div class='entry'>
-				<form method='post' action='/login.php'>
-					<table>
-						<tr>
-							<td>Usuario:</td>
-							<td><input name="user" type="text"/></td>
-						</tr>
-						<tr>
-							<td>Contrasena:</td>
-							<td><input name="pass" type="password"/></td>
-						</tr>
-						<tr>
-							<td></td><td><input type="submit" value="Entrar"/></td>
-						</tr>
-					</table>
-				</form>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Gasteizko Margolariak - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/index.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/index.css"/>
+    </head>
+    <body>
+        <div class='section'>
+            <h3 class='section_title'>Credenciales</h3>
+            <div class='entry'>
+                <form method='post' action='/login.php'>
+                    <table>
+                        <tr>
+                            <td>Usuario:</td>
+                            <td><input name="user" type="text"/></td>
+                        </tr>
+                        <tr>
+                            <td>Contrasena:</td>
+                            <td><input name="pass" type="password"/></td>
+                        </tr>
+                        <tr>
+                            <td></td><td><input type="submit" value="Entrar"/></td>
+                        </tr>
+                    </table>
+                </form>
+            </div>
+        </div>
+    </body>
 </html>
 <?php } ?>

+ 15 - 15
www-admin/lablanca/add/index.php

@@ -1,17 +1,17 @@
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nuevo post - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/lablanca.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/lablanca.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nuevo post - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/lablanca.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/lablanca.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+    </body>
 </html>

+ 169 - 169
www-admin/lablanca/calculate.php

@@ -1,171 +1,171 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	$default_host = substr($http_host, 0, strpos($http_host, ':'));
-	include("../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		exit (-1);
-	}
-	else{
-		//Get year
-		$year = date("Y");
-		
-		//Get data to calculate
-		$section = mysqli_real_escape_string($con, $_GET['section']);
-		
-		switch ($section){
-		
-			//Calculate header section. Only the progress window is requires
-			case 'header':
-				echo "<h4>Paso 1: Cabecera de la p&aacute;gina de fiestas</h4>\n";
-// 				echo "<div class='entry status' id='status_header'>\n";
-				echo "Estado:\n";
-				$q = mysqli_query($con, "SELECT * FROM festival WHERE year = $year;");
-				if (mysqli_num_rows($q) == 0){
-					echo "<span class='status_red'> No se ha definido una cabecera</span>\n";
-				}
-				else{
-					$r = mysqli_fetch_array($q);
-					echo "<ul><li>Texto castellano: <span class='status_green'>OK</span></li>\n<li>Traducci&oacute;n ingl&eacute;s: ";
-					if ($r['text_en'] == $r['text_es'] || strlen($r['text_en']) == 0){
-						echo "<span class='status_yellow'>NO</span>\n";
-					}
-					else{
-						echo "<span class='status_green'>OK</span>\n";
-					}
-					echo "</li>\n<li>Traducci&oacute;n euskera: ";
-					if ($r['text_eu'] == $r['text_es'] || strlen($r['text_eu']) == 0){
-						echo "<span class='status_yellow'>NO</span>\n";
-					}
-					else{
-						echo "<span class='status_green'>OK</span>\n";
-					}
-					echo "</li>\n<li>Cartel: ";
-					if (strlen($r['img']) == 0){
-						echo "<span class='status_yellow'>NO</span>\n";
-					}
-					else{
-						echo "<span class='status_green'>OK</span>\n";
-					}
-					echo "</li></ul>\n";
-				}
-				break;
-				
-			//Calculate prices progress section.
-			case 'pricesprogress':
-				echo "Estado:<ul><li>\n";
-				$q = mysqli_query($con, "SELECT * FROM festival_day WHERE year(date) = '$year' AND price > 0;");
-				if (mysqli_num_rows($q) != 6){
-					echo "<span class='status_red'> No se han establecido precios</span>\n";
-				}
-				else{
-					echo "Precios establecidos: <span class='status_green'>OK</span>\n";
-				}
-				echo "</li><li>\n";
-				$prices_wrong = 0;
-				while ($r = mysqli_fetch_array($q)){
-					if ($r['price'] <= 0 || $r['price'] > 200){
-						$prices_wrong ++;
-					}
-				}
-				if ($prices_wrong == 0){
-					echo "Precios v&aacute;lidos: <span class='status_green'>" . (6 - $prices_wrong) . "/6</span>\n";
-				}
-				else{
-					echo "Precios v&aacute;lidos: <span class='status_red'>" . (6 - $prices_wrong) . "/6</span>\n";
-				}
-				echo "</li><li>\n";
-				$q = mysqli_query($con, "SELECT id FROM festival_offer WHERE year = $year AND price > 0;");
-				if (mysqli_num_rows($q) > 0){
-					echo "N&uacute;mero de ofertas: <span class='status_green'>" . mysqli_num_rows($q) . "</span>\n";
-				}
-				else{
-					echo "N&uacute;mero de ofertas: <span class='status_yellow'>" . mysqli_num_rows($q) . "</span>\n";
-				}
-				echo "</li></ul>\n";
-				break;
-		
-			//Calculate offers window
-			case 'pricesoffers':
-				echo "<h4>Ofertas:</h4>\n";
-				$q_offer = mysqli_query($con, "SELECT * FROM festival_offer WHERE year = $year");
-				if (mysqli_num_rows($q_offer) == 0){
-					echo "No se han configurado ofertas<br/>\n";
-				}
-				else{
-					echo "<table id='offers'><tr>";
-					echo "<th>Castellano</th><th>Ingl&eacute;s</th><th>Euskera</th>";
-					echo "<th>D&iacute;as</th><th>Precio</th><th>Acci&oacute;n</th></tr>\n";
-					while ($r_offer = mysqli_fetch_array($q_offer)){
-						if ($r_offer['name_en'] == $r_offer['name_es']){
-							$en = '';
-						}
-						else{
-							$en = $r_offer['name_en'];
-						}
-						if ($r_offer['name_eu'] == $r_offer['name_es']){
-							$eu = '';
-						}
-						else{
-							$eu = $r_offer['name_eu'];
-						}
-						if ($r_offer['description_en'] == $r_offer['description_es']){
-							$den = '';
-						}
-						else{
-							$den = $r_offer['description_en'];
-						}
-						if ($r_offer['description_eu'] == $r_offer['description_es']){
-							$deu = '';
-						}
-						else{
-							$deu = $r_offer['description_eu'];
-						}
-						echo "<tr><td class='large'><input type='text' value='$r_offer[name_es]' onchange='updateField(\"festival_offer\", \"name_es\", this.value, $r_offer[id], \"text\", false);'/><br/>\n";
-						echo "<textarea onchange='updateField(\"festival_offer\", \"description_es\", this.value, $r_offer[id], \"text\", false);'>$r_offer[description_es]</textarea></td>\n"; //TODO onchange
-						echo "<td class='large'><input type='text' value='$en' onchange='updateField(\"festival_offer\", \"name_en\", this.value, $r_offer[id]);'/><br/>\n";
-						echo "<textarea onchange='updateField(\"festival_offer\", \"description_en\", this.value, $r_offer[id]);'>$den</textarea></td>\n";
-						echo "<td class='large'><input type='text' value='$eu' onchange='updateField(\"festival_offer\", \"name_eu\", this.value, $r_offer[id]);'/><br/>\n";
-						echo "<textarea onchange='updateField(\"festival_offer\", \"description_eu\", this.value, $r_offer[id]);'>$deu</textarea></td>\n";
-						echo "<td class='small'><input type='number' value='$r_offer[days]' onchange='updateField(\"festival_offer\", \"days\", this.value, $r_offer[id], \"number\", false);'/></td>\n";
-						echo "<td class='small'><input type='number' value='$r_offer[price]' onchange='updateField(\"festival_offer\", \"price\", this.value, $r_offer[id], \"number\", false);'/>&euro;</td>\n";
-						echo "<td class='small'><input type='button' value='Eliminar' onClick='if(confirm(\"Borrar oferta $r_offer[name_es]?\"))deleteOffer($r_offer[id]);'/></td></tr>"; //TODO onclick
-					}
-					echo "</table>\n";
-				}
-				echo "<input type='button' value='A&ntilde;adir nuevo' onClick='newOffer();'/>\n";
-				break;
-			case 'schedule':
-				$day = $_GET('day');
-				switch($day){
-					case '25':
-						$q = mysqli_query($con, "SELECT * FROM festival_event WHERE gm = 1 AND start > str_to_date('$year-07-25 08:00:00', '%Y-%m-%d %T') AND start < str_to_date('$year-07-26 07:59:59', '%Y-%m-%d %T');");
-						break;
-					case '5':
-					
-						break;
-					case '6':
-					
-						break;
-					case '7':
-					
-						break;
-					case '8':
-					
-						break;
-					case '9':
-					
-						break;
-					default:
-						exit(-1);
-				}
-				//Load schedule tables
-				echo "<table>\n";
-				echo "<tr>\n";
-				echo "<th></th>";
-				echo "<tr/>\n";
-				echo "</table>\n";
-				break;
-		}
-	}
+    $http_host = $_SERVER['HTTP_HOST'];
+    $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    include("../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        exit (-1);
+    }
+    else{
+        //Get year
+        $year = date("Y");
+        
+        //Get data to calculate
+        $section = mysqli_real_escape_string($con, $_GET['section']);
+        
+        switch ($section){
+        
+            //Calculate header section. Only the progress window is requires
+            case 'header':
+                echo "<h4>Paso 1: Cabecera de la p&aacute;gina de fiestas</h4>\n";
+//                 echo "<div class='entry status' id='status_header'>\n";
+                echo "Estado:\n";
+                $q = mysqli_query($con, "SELECT * FROM festival WHERE year = $year;");
+                if (mysqli_num_rows($q) == 0){
+                    echo "<span class='status_red'> No se ha definido una cabecera</span>\n";
+                }
+                else{
+                    $r = mysqli_fetch_array($q);
+                    echo "<ul><li>Texto castellano: <span class='status_green'>OK</span></li>\n<li>Traducci&oacute;n ingl&eacute;s: ";
+                    if ($r['text_en'] == $r['text_es'] || strlen($r['text_en']) == 0){
+                        echo "<span class='status_yellow'>NO</span>\n";
+                    }
+                    else{
+                        echo "<span class='status_green'>OK</span>\n";
+                    }
+                    echo "</li>\n<li>Traducci&oacute;n euskera: ";
+                    if ($r['text_eu'] == $r['text_es'] || strlen($r['text_eu']) == 0){
+                        echo "<span class='status_yellow'>NO</span>\n";
+                    }
+                    else{
+                        echo "<span class='status_green'>OK</span>\n";
+                    }
+                    echo "</li>\n<li>Cartel: ";
+                    if (strlen($r['img']) == 0){
+                        echo "<span class='status_yellow'>NO</span>\n";
+                    }
+                    else{
+                        echo "<span class='status_green'>OK</span>\n";
+                    }
+                    echo "</li></ul>\n";
+                }
+                break;
+                
+            //Calculate prices progress section.
+            case 'pricesprogress':
+                echo "Estado:<ul><li>\n";
+                $q = mysqli_query($con, "SELECT * FROM festival_day WHERE year(date) = '$year' AND price > 0;");
+                if (mysqli_num_rows($q) != 6){
+                    echo "<span class='status_red'> No se han establecido precios</span>\n";
+                }
+                else{
+                    echo "Precios establecidos: <span class='status_green'>OK</span>\n";
+                }
+                echo "</li><li>\n";
+                $prices_wrong = 0;
+                while ($r = mysqli_fetch_array($q)){
+                    if ($r['price'] <= 0 || $r['price'] > 200){
+                        $prices_wrong ++;
+                    }
+                }
+                if ($prices_wrong == 0){
+                    echo "Precios v&aacute;lidos: <span class='status_green'>" . (6 - $prices_wrong) . "/6</span>\n";
+                }
+                else{
+                    echo "Precios v&aacute;lidos: <span class='status_red'>" . (6 - $prices_wrong) . "/6</span>\n";
+                }
+                echo "</li><li>\n";
+                $q = mysqli_query($con, "SELECT id FROM festival_offer WHERE year = $year AND price > 0;");
+                if (mysqli_num_rows($q) > 0){
+                    echo "N&uacute;mero de ofertas: <span class='status_green'>" . mysqli_num_rows($q) . "</span>\n";
+                }
+                else{
+                    echo "N&uacute;mero de ofertas: <span class='status_yellow'>" . mysqli_num_rows($q) . "</span>\n";
+                }
+                echo "</li></ul>\n";
+                break;
+        
+            //Calculate offers window
+            case 'pricesoffers':
+                echo "<h4>Ofertas:</h4>\n";
+                $q_offer = mysqli_query($con, "SELECT * FROM festival_offer WHERE year = $year");
+                if (mysqli_num_rows($q_offer) == 0){
+                    echo "No se han configurado ofertas<br/>\n";
+                }
+                else{
+                    echo "<table id='offers'><tr>";
+                    echo "<th>Castellano</th><th>Ingl&eacute;s</th><th>Euskera</th>";
+                    echo "<th>D&iacute;as</th><th>Precio</th><th>Acci&oacute;n</th></tr>\n";
+                    while ($r_offer = mysqli_fetch_array($q_offer)){
+                        if ($r_offer['name_en'] == $r_offer['name_es']){
+                            $en = '';
+                        }
+                        else{
+                            $en = $r_offer['name_en'];
+                        }
+                        if ($r_offer['name_eu'] == $r_offer['name_es']){
+                            $eu = '';
+                        }
+                        else{
+                            $eu = $r_offer['name_eu'];
+                        }
+                        if ($r_offer['description_en'] == $r_offer['description_es']){
+                            $den = '';
+                        }
+                        else{
+                            $den = $r_offer['description_en'];
+                        }
+                        if ($r_offer['description_eu'] == $r_offer['description_es']){
+                            $deu = '';
+                        }
+                        else{
+                            $deu = $r_offer['description_eu'];
+                        }
+                        echo "<tr><td class='large'><input type='text' value='$r_offer[name_es]' onchange='updateField(\"festival_offer\", \"name_es\", this.value, $r_offer[id], \"text\", false);'/><br/>\n";
+                        echo "<textarea onchange='updateField(\"festival_offer\", \"description_es\", this.value, $r_offer[id], \"text\", false);'>$r_offer[description_es]</textarea></td>\n"; //TODO onchange
+                        echo "<td class='large'><input type='text' value='$en' onchange='updateField(\"festival_offer\", \"name_en\", this.value, $r_offer[id]);'/><br/>\n";
+                        echo "<textarea onchange='updateField(\"festival_offer\", \"description_en\", this.value, $r_offer[id]);'>$den</textarea></td>\n";
+                        echo "<td class='large'><input type='text' value='$eu' onchange='updateField(\"festival_offer\", \"name_eu\", this.value, $r_offer[id]);'/><br/>\n";
+                        echo "<textarea onchange='updateField(\"festival_offer\", \"description_eu\", this.value, $r_offer[id]);'>$deu</textarea></td>\n";
+                        echo "<td class='small'><input type='number' value='$r_offer[days]' onchange='updateField(\"festival_offer\", \"days\", this.value, $r_offer[id], \"number\", false);'/></td>\n";
+                        echo "<td class='small'><input type='number' value='$r_offer[price]' onchange='updateField(\"festival_offer\", \"price\", this.value, $r_offer[id], \"number\", false);'/>&euro;</td>\n";
+                        echo "<td class='small'><input type='button' value='Eliminar' onClick='if(confirm(\"Borrar oferta $r_offer[name_es]?\"))deleteOffer($r_offer[id]);'/></td></tr>"; //TODO onclick
+                    }
+                    echo "</table>\n";
+                }
+                echo "<input type='button' value='A&ntilde;adir nuevo' onClick='newOffer();'/>\n";
+                break;
+            case 'schedule':
+                $day = $_GET('day');
+                switch($day){
+                    case '25':
+                        $q = mysqli_query($con, "SELECT * FROM festival_event WHERE gm = 1 AND start > str_to_date('$year-07-25 08:00:00', '%Y-%m-%d %T') AND start < str_to_date('$year-07-26 07:59:59', '%Y-%m-%d %T');");
+                        break;
+                    case '5':
+                    
+                        break;
+                    case '6':
+                    
+                        break;
+                    case '7':
+                    
+                        break;
+                    case '8':
+                    
+                        break;
+                    case '9':
+                    
+                        break;
+                    default:
+                        exit(-1);
+                }
+                //Load schedule tables
+                echo "<table>\n";
+                echo "<tr>\n";
+                echo "<th></th>";
+                echo "<tr/>\n";
+                echo "</table>\n";
+                break;
+        }
+    }
 ?>

+ 13 - 13
www-admin/lablanca/edit/index.php

@@ -1,15 +1,15 @@
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nuevo post - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/lablanca.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/lablanca.css"/>
-	</head>
-	<body>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nuevo post - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/lablanca.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/lablanca.css"/>
+    </head>
+    <body>
+    </body>
 </html>

+ 43 - 43
www-admin/lablanca/execute.php

@@ -1,45 +1,45 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	$default_host = substr($http_host, 0, strpos($http_host, ':'));
-	include("../functions.php");
-	$con = startdb('rw');
-	if (!checkSession($con)){
-		exit (-1);
-	}
-	else{
-		//Get year
-		$year = date("Y");
-		
-		//Get data to calculate
-		$action = mysqli_real_escape_string($con, $_POST['action']);
-		$table = mysqli_real_escape_string($con, $_POST['table']);
-		$field = mysqli_real_escape_string($con, $_POST['field']);
-		$type = mysqli_real_escape_string($con, $_POST['type']);
-		$id = mysqli_real_escape_string($con, $_POST['id']);
-		$value = mysqli_real_escape_string($con, urldecode($_POST['value']));
-		//Validate tables where values can be inserted
-		if ($table != 'festival' and $table != 'festival_day' and $table != 'festival_event' and $table != 'festival_event_image' and $table != 'festival_offer'){
-			//TODO: If I got here, somebody is doing something nasty. Log it.
-			exit (-1);
-		}
-		
-		switch ($action){
-			case "delete":
-				mysqli_query($con, "DELETE FROM $table WHERE id = $id;");
-				version();
-				break;
-			case "update":
-				switch($type){
-					case "text":
-						mysqli_query($con, "UPDATE $table SET $field = '$value' WHERE id = $id;");
-						version();
-						break;
-					case "number":
-						mysqli_query($con, "UPDATE $table SET $field = $value WHERE id = $id;");
-						version();
-						break;
-					//TODO: add a case for dates
-				}
-		}
-	}
+    $http_host = $_SERVER['HTTP_HOST'];
+    $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    include("../functions.php");
+    $con = startdb('rw');
+    if (!checkSession($con)){
+        exit (-1);
+    }
+    else{
+        //Get year
+        $year = date("Y");
+        
+        //Get data to calculate
+        $action = mysqli_real_escape_string($con, $_POST['action']);
+        $table = mysqli_real_escape_string($con, $_POST['table']);
+        $field = mysqli_real_escape_string($con, $_POST['field']);
+        $type = mysqli_real_escape_string($con, $_POST['type']);
+        $id = mysqli_real_escape_string($con, $_POST['id']);
+        $value = mysqli_real_escape_string($con, urldecode($_POST['value']));
+        //Validate tables where values can be inserted
+        if ($table != 'festival' and $table != 'festival_day' and $table != 'festival_event' and $table != 'festival_event_image' and $table != 'festival_offer'){
+            //TODO: If I got here, somebody is doing something nasty. Log it.
+            exit (-1);
+        }
+        
+        switch ($action){
+            case "delete":
+                mysqli_query($con, "DELETE FROM $table WHERE id = $id;");
+                version();
+                break;
+            case "update":
+                switch($type){
+                    case "text":
+                        mysqli_query($con, "UPDATE $table SET $field = '$value' WHERE id = $id;");
+                        version();
+                        break;
+                    case "number":
+                        mysqli_query($con, "UPDATE $table SET $field = $value WHERE id = $id;");
+                        version();
+                        break;
+                    //TODO: add a case for dates
+                }
+        }
+    }
 ?>

+ 256 - 239
www-admin/lablanca/index.php

@@ -1,244 +1,261 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	$default_host = substr($http_host, 0, strpos($http_host, ':'));
-	include("../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
-	//Get year
-	$year = date("Y");
+    $http_host = $_SERVER['HTTP_HOST'];
+    $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    include("../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+    //Get year
+    $year = date("Y");
 ?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Preparar las fiestas de <?php echo $year; ?> - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/lablanca.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/lablanca.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="script.js"></script>
-		<script type="text/javascript" src="/script/ui.js"></script>
-		<script src="../ckeditor/ckeditor.js"></script>
-	</head>
-	<body onLoad='calculate("all");'>
-		<?php include('../toolbar.php'); ?>
-		<div id='content'>
-			<div class='section' id='section_header'>
-				<h4>Paso 1: Cabecera de la p&aacute;gina de fiestas</h4>
-				<div class='entry status' id='status_header'>
-					...calculando...
-				</div>
-				<div class='entry' id='entry_header'>
-					<div class='header_text'>
-						Texto castellano:
-						<?php
-							$q = mysqli_query($con, "SELECT * FROM festival WHERE year = $year;");
-							$r = mysqli_fetch_array($q);
-							echo "<textarea id='text_es' onChange='updateField(\"festival\", \"text_es\", this.value, $r[id], \"text\", false);calculate(\"header\");'>$r[text_es]</textarea>\n";
-						?>
-						<script>
-							CKEDITOR.replace('text_es');
-						</script>
-					</div>
-					<div class='header_text'>
-						Texto ingl&eacute;s:
-						<?php
-							echo "<textarea id='text_en' onChange='updateField(\"festival\", \"text_en\", this.value, $r[id]);calculate(\"header\");'>$r[text_en]</textarea>\n";
-						?>
-						<script>
-							CKEDITOR.replace('text_en');
-						</script>
-					</div>
-					<div class='header_text'>
-						Texto euskera:
-						<?php
-							echo "<textarea id='text_eu' onChange='updateField(\"festival\", \"text_eu\", this.value, $r[id]);calculate(\"header\");'>$r[text_eu]</textarea>\n";
-						?>
-						<script>
-							CKEDITOR.replace('text_eu');
-						</script>
-					</div>
-					<div id='header_image'>
-						Cartel:<br/>
-						<?php
-							if (mysqli_num_rows($q) > 0){
-								if (strlen($r['img']) == 0){
-									echo "<img id='header_img' src='/img/lablanca/header-null.png'/><br/>\n";
-								}
-								else{
-									echo "<img id='header_img' src='http://$default_host/img/fiestas/miniature/$r[img]'/><br/>\n";
-								}
-							}
-							else{
-								echo "<img id='header_img' src='http://$default_host/img/fiestas/miniature/$r[img]'/><br/>\n";
-							}
-							echo "<input type='file' id='header_img_selector' onChange='uploadHeaderImage(event, $r[id]);calculate(\"header\");'/>\n";
-						?>
-					</div>
-				</div>
-			</div>
-			<div class='section' id='section_prices'>
-				<h4>Paso 2: Seleccionar precios:</h4>
-				<div class='entry status' id='status_prices'>
-					...calculando...
-				</div>
-				<div class='entry' id='entry_prices'>
-					<?php
-						$q = mysqli_query($con, "SELECT * FROM festival_day WHERE year(date) = '$year' AND price > 0;");
-						if (mysqli_num_rows($q) != 6){
-							echo "<input type='button' value='A&ntilde;adir precios'/>\n"; //TODO onclick
-							echo "<input type='button' value='Utilzar precios del a&ntilde;o pasado'/>\n"; //TODO onclick
-						}
-						else{
-							echo "<h4>D&iacute;as sueltos:</h4>";
-							echo "<table id='prices'><tr><th>Fecha</th>";
-							echo "<th>Nombre<br/>castellano</th><th>Nombre<br/>ingl&eacute;s</th><th>Nombre<br/>euskera</th>";
-							echo "<th>Precio</th></tr>\n";
-							$dates = ["25 Jul", "5 Ago", "6 Ago", "7 Ago", "8 Ago", "9 Ago"];
-							$i = 0;
-							while ($r = mysqli_fetch_array($q)){
-								echo "<tr><td>" . $dates[$i];
-								if ($r['name_en'] == $r['name_es']){
-									$en = '';
-								}
-								else{
-									$en = $r['name_en'];
-								}
-								if ($r['name_eu'] == $r['name_es']){
-									$eu = '';
-								}
-								else{
-									$eu = $r['name_eu'];
-								}
-								echo "</td>\n";
-								echo "<td><input type='text' value='$r[name_es]' onchange='updateField(\"festival_day\", \"name_es\", this.value, $r[id]);'/></td>\n";
-								echo "<td><input type='text' value='$en' onchange='updateField(\"festival_day\", \"name_en\", this.value, $r[id]);'/></td>\n";
-								echo "<td><input type='text' value='$eu' onchange='updateField(\"festival_day\", \"name_eu\", this.value, $r[id]);'/></td>\n";
-								echo "<td><input type='number' value='$r[price]' onchange='updateField(\"festival_day\", \"price\", this.value, $r[id], \"number\", false);'/>&euro;</td></tr>";
-								$i = $i + 1;
-							}
-							echo "</table>\n";
-							echo "<div id='prices_offers'>\n";
-							echo "...calculando...\n";
-							echo "</div>\n";
-						}
-					?>
-				</div>
-			</div>
-		
-			<div class='section' id='section_schedule'>
-				<h4>Paso 3: Establecer programa:</h4>
-				<div class='entry status' id='status_schedule'>
-					...calculando...
-				</div>
-				<div class='entry entry_schedule' id='entry_schedule_25'>
-					<h4><img src='/img/misc/slid-right.png' onClick='expandSchedule(25);'/>25 de julio</h4>
-					<div id='list_schedule_25' class='list_schedule'>
-					</div>
-					Nuevo: 
-					<table class='new_event'>
-						<tr class='title'>
-							<th>Castellano</th>
-							<th>Euskera</th>
-							<th>Ingl&eacute;s</th>
-						</tr>
-						<tr>
-							<td>
-								<input type='text' id='new_event_25_name_es' placeholder='Nombre'/><br/>
-								<textarea id='new_event_25_description_es' placeholder='Descripcion'></textarea>
-							</td>
-							<td>
-								<input type='text' id='new_event_25_name_en' placeholder='Nombre'/><br/>
-								<textarea id='new_event_25_description_en' placeholder='Descripcion'></textarea>
-							</td>
-							<td>
-								<input type='text' id='new_event_25_name_eu' placeholder='Nombre'/><br/>
-								<textarea id='new_event_25_description_eu' placeholder='Descripcion'></textarea>
-							</td>
-						</tr>
-						<tr class='title'>
-							<th>Inicio - Fin</th>
-							<th>Organiza</th>
-							<th>Lugar</th>
-						</tr>
-						<tr>
-							<td>
-								<input type='number' value='00' id='new_event_25_start_h'/>:
-								<input type='number' value='00' id='new_event_25_start_m'/> -- 
-								<input type='number' id='new_event_25_end_h'/>:
-								<input type='number' id='new_event_25_end_m'/>
-							</td>
-							<td>
-								<select id='new_event_25_host' class='new_event_host'>
-									<option value='-2' selected='selected'>SELECCIONA...</option>
-									<option value='-1'>A&Ntilde;ADIR NUEVO...</option>
-									<?php
-										$q = mysqli_query($con, "SELECT * FROM people;");
-										while ($r = mysqli_fetch_array($q)){
-											echo "<option value='$r[id]'>$r[name_es]</option>\n";
-										}
-									?>
-								</select>
-							</td>
-							<td>
-								<select id='new_event_25_host' class='new_event_host'>
-									<option value='-2' selected='selected'>SELECCIONA...</option>
-									<option value='-1'>A&Ntilde;ADIR NUEVO...</option>
-									<?php
-										$q = mysqli_query($con, "SELECT * FROM place;");
-										while ($r = mysqli_fetch_array($q)){
-											echo "<option value='$r[id]'>$r[name_es] ($r[address_es])</option>\n";
-										}
-									?>
-								</select>
-							</td>
-						</tr>
-					</table>
-				</div>
-			</div>
-		</div>
-		<div id='screen_cover'></div>
-		<div id='form_new_offer' class='section'>
-			<h3>A&ntilde;adir oferta</h3>
-			<div class='entry'>
-				<table>
-					<tr>
-						<th>Castellano</th><th>Ingl&eacute;s</th><th>Euskera</th><th>D&iacute;as</th><th>Precio</th>
-					</tr>
-					<tr>
-						<td>
-							<input type='text' id='new_offer_title_es'/><br/>
-							<textarea id='new_offer_text_es'></textarea>
-						</td>
-						<td class='large'>
-							<input type='text' id='new_offer_title_en'/><br/>
-							<textarea id='new_offer_text_en'></textarea>
-						</td>
-						<td/>
-							<input type='text' id='new_offer_title_eu'/><br/>
-							<textarea id='new_offer_text_eu'></textarea>
-						</td>
-						<td class='small'>
-							<input type='number' value='1'  id='new_offer_days'/>
-						</td>
-						<td class='small'>
-							<input type='number' value='0'  id='new_offer_price'/>&euro;
-						</td>
-					</tr>
-				</table>
-				<div id='controls'>
-					<input type='button' value='Guardar' onClick='saveNewOffer(<?php echo $year;?>);'/>
-					<input type='button' value='Cancelar' onClick='cancelNewOffer();'/>
-				</div>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Preparar las fiestas de <?php echo $year; ?> - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/lablanca.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/lablanca.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+        <script type="text/javascript" src="/script/ui.js"></script>
+        <script src="../ckeditor/ckeditor.js"></script>
+    </head>
+    <body onLoad='calculate("all");'>
+        <?php include('../toolbar.php'); ?>
+        <div id='content'>
+            <div class='section' id='section_header'>
+                <h3 class='section_title'>Paso 1: Cabecera de la p&aacute;gina de fiestas</h3>
+                <div class='entry status' id='status_header'>
+                    ...calculando...
+                </div>
+                <div class='entry' id='entry_header'>
+                    <div id="lang_tabs">
+                        <table>
+                                <tr>
+                                    <td class="pointer lang_tabs_active" id="lang_tab_es" onclick="showLanguage('es');">
+                                        Castellano
+                                    </td>
+                                    <td class="pointer" id="lang_tab_eu" onclick="showLanguage('eu');">
+                                        Euskera
+                                    </td>
+                                    <td class="pointer" id="lang_tab_en" onclick="showLanguage('en');">
+                                        Ingl&eacute;s
+                                    </td>
+                                </tr>
+                        </table>
+                    </div>
+                    <div id="content_lang_es" class="festival_add_language">
+                        <?php
+                            $q = mysqli_query($con, "SELECT * FROM festival WHERE year = $year;");
+                            $r = mysqli_fetch_array($q);
+                            echo "<textarea id='text_es' onChange='updateField(\"festival\", \"text_es\", this.value, $r[id], \"text\", false);calculate(\"header\");'>$r[text_es]</textarea>\n";
+                        ?>
+                        <script>
+                            CKEDITOR.replace('text_es');
+                        </script>
+                    </div>
+                    <div id="content_lang_en" class="festival_add_language" style="display:none;">
+                        <?php
+                            echo "<textarea id='text_en' onChange='updateField(\"festival\", \"text_en\", this.value, $r[id]);calculate(\"header\");'>$r[text_en]</textarea>\n";
+                        ?>
+                        <script>
+                            CKEDITOR.replace('text_en');
+                        </script>
+                    </div>
+                    <div id="content_lang_eu" class="festival_add_language" style="display:none;">
+                        <?php
+                            echo "<textarea id='text_eu' onChange='updateField(\"festival\", \"text_eu\", this.value, $r[id]);calculate(\"header\");'>$r[text_eu]</textarea>\n";
+                        ?>
+                        <script>
+                            CKEDITOR.replace('text_eu');
+                        </script>
+                    </div>
+                    <div id='header_image'>
+                        Cartel:<br/>
+                        <?php
+                            if (mysqli_num_rows($q) > 0){
+                                if (strlen($r['img']) == 0){
+                                    echo "<img id='header_img' src='/img/lablanca/header-null.png'/><br/>\n";
+                                }
+                                else{
+                                    echo "<img id='header_img' src='http://$default_host/img/fiestas/miniature/$r[img]'/><br/>\n";
+                                }
+                            }
+                            else{
+                                echo "<img id='header_img' src='http://$default_host/img/fiestas/miniature/$r[img]'/><br/>\n";
+                            }
+                            echo "<input type='file' id='header_img_selector' onChange='uploadHeaderImage(event, $r[id]);calculate(\"header\");'/>\n";
+                        ?>
+                    </div>
+                </div>
+            </div>
+            <br/><br/>
+            <div class='section' id='section_prices'>
+                <h3 class="section_title">Paso 2: Seleccionar precios:</h4>
+                <div class='entry status' id='status_prices'>
+                    ...calculando...
+                </div>
+                <div class='entry' id='entry_prices'>
+                    <?php
+                        $q = mysqli_query($con, "SELECT * FROM festival_day WHERE year(date) = '$year' AND price > 0;");
+                        if (mysqli_num_rows($q) != 6){
+                            echo "<input type='button' value='A&ntilde;adir precios'/>\n"; //TODO onclick
+                            echo "<input type='button' value='Utilzar precios del a&ntilde;o pasado'/>\n"; //TODO onclick
+                        }
+                        else{
+                            echo "<h4>D&iacute;as sueltos:</h4>";
+                            echo "<table id='prices'><tr><th>Fecha</th>";
+                            echo "<th>Nombres</th>";
+                            echo "<th>Precio</th></tr>\n";
+                            $dates = ["25 Jul", "5 Ago", "6 Ago", "7 Ago", "8 Ago", "9 Ago"];
+                            $i = 0;
+                            while ($r = mysqli_fetch_array($q)){
+                                echo "<tr><td>" . $dates[$i];
+                                if ($r['name_en'] == $r['name_es']){
+                                    $en = '';
+                                }
+                                else{
+                                    $en = $r['name_en'];
+                                }
+                                if ($r['name_eu'] == $r['name_es']){
+                                    $eu = '';
+                                }
+                                else{
+                                    $eu = $r['name_eu'];
+                                }
+                                echo "</td><td>\n";
+                                echo("<table>\n");
+                                echo("<tr><td>Castellano:</td><td><input type='text' value='$r[name_es]' onchange='updateField(\"festival_day\", \"name_es\", this.value, $r[id]);'/></td></tr>\n");
+                                echo("<tr><td>Euskera:</td><td><input type='text' value='$r[name_en]' onchange='updateField(\"festival_day\", \"name_en\", this.value, $r[id]);'/></td></tr>\n");
+                                echo("<tr><td>Ingl&eacute;s:</td><td><input type='text' value='$r[name_eu]' onchange='updateField(\"festival_day\", \"name_eu\", this.value, $r[id]);'/></td></tr>\n");
+                                echo("</table>\n");
+                                echo "</td>\n<td>\n<input type='number' value='$r[price]' onchange='updateField(\"festival_day\", \"price\", this.value, $r[id], \"number\", false);'/>&euro;</td></tr>";
+                                $i = $i + 1;
+                            }
+                            echo "</table>\n";
+                            echo "<div id='prices_offers'>\n";
+                            echo "...calculando...\n";
+                            echo "</div>\n";
+                        }
+                    ?>
+                </div>
+            </div>
+            <br/><br/>
+            <div class='section' id='section_schedule'>
+                <h3 class='section_title'>Paso 3: Establecer programa:</h4>
+                <div class='entry status' id='status_schedule'>
+                    ...calculando...
+                </div>
+                <div class='entry entry_schedule' id='entry_schedule_25'>
+                    <h3><img src='/img/misc/slid-right.png' onClick='expandSchedule(25);'/>25 de julio</h4>
+                    <div id='list_schedule_25' class='list_schedule'>
+                    </div>
+                    Nuevo: 
+                    <table class='new_event'>
+                        <tr class='title'>
+                            <th>Castellano</th>
+                            <th>Euskera</th>
+                            <th>Ingl&eacute;s</th>
+                        </tr>
+                        <tr>
+                            <td>
+                                <input type='text' id='new_event_25_name_es' placeholder='Nombre'/><br/>
+                                <textarea id='new_event_25_description_es' placeholder='Descripcion'></textarea>
+                            </td>
+                            <td>
+                                <input type='text' id='new_event_25_name_en' placeholder='Nombre'/><br/>
+                                <textarea id='new_event_25_description_en' placeholder='Descripcion'></textarea>
+                            </td>
+                            <td>
+                                <input type='text' id='new_event_25_name_eu' placeholder='Nombre'/><br/>
+                                <textarea id='new_event_25_description_eu' placeholder='Descripcion'></textarea>
+                            </td>
+                        </tr>
+                        <tr class='title'>
+                            <th>Inicio - Fin</th>
+                            <th>Organiza</th>
+                            <th>Lugar</th>
+                        </tr>
+                        <tr>
+                            <td>
+                                <input type='number' value='00' id='new_event_25_start_h'/>:
+                                <input type='number' value='00' id='new_event_25_start_m'/> -- 
+                                <input type='number' id='new_event_25_end_h'/>:
+                                <input type='number' id='new_event_25_end_m'/>
+                            </td>
+                            <td>
+                                <select id='new_event_25_host' class='new_event_host'>
+                                    <option value='-2' selected='selected'>SELECCIONA...</option>
+                                    <option value='-1'>A&Ntilde;ADIR NUEVO...</option>
+                                    <?php
+                                        $q = mysqli_query($con, "SELECT * FROM people;");
+                                        while ($r = mysqli_fetch_array($q)){
+                                            echo "<option value='$r[id]'>$r[name_es]</option>\n";
+                                        }
+                                    ?>
+                                </select>
+                            </td>
+                            <td>
+                                <select id='new_event_25_host' class='new_event_host'>
+                                    <option value='-2' selected='selected'>SELECCIONA...</option>
+                                    <option value='-1'>A&Ntilde;ADIR NUEVO...</option>
+                                    <?php
+                                        $q = mysqli_query($con, "SELECT * FROM place;");
+                                        while ($r = mysqli_fetch_array($q)){
+                                            echo "<option value='$r[id]'>$r[name_es] ($r[address_es])</option>\n";
+                                        }
+                                    ?>
+                                </select>
+                            </td>
+                        </tr>
+                    </table>
+                </div>
+            </div>
+            <br/><br/>
+        </div>
+        <div id='screen_cover'></div>
+        <div id='form_new_offer' class='section'>
+            <h3>A&ntilde;adir oferta</h3>
+            <div class='entry'>
+                <table>
+                    <tr>
+                        <th>Castellano</th><th>Ingl&eacute;s</th><th>Euskera</th><th>D&iacute;as</th><th>Precio</th>
+                    </tr>
+                    <tr>
+                        <td>
+                            <input type='text' id='new_offer_title_es'/><br/>
+                            <textarea id='new_offer_text_es'></textarea>
+                        </td>
+                        <td class='large'>
+                            <input type='text' id='new_offer_title_en'/><br/>
+                            <textarea id='new_offer_text_en'></textarea>
+                        </td>
+                        <td/>
+                            <input type='text' id='new_offer_title_eu'/><br/>
+                            <textarea id='new_offer_text_eu'></textarea>
+                        </td>
+                        <td class='small'>
+                            <input type='number' value='1'  id='new_offer_days'/>
+                        </td>
+                        <td class='small'>
+                            <input type='number' value='0'  id='new_offer_price'/>&euro;
+                        </td>
+                    </tr>
+                </table>
+                <div id='controls'>
+                    <input type='button' value='Guardar' onClick='saveNewOffer(<?php echo $year;?>);'/>
+                    <input type='button' value='Cancelar' onClick='cancelNewOffer();'/>
+                </div>
+            </div>
+        </div>
+        
+    </body>
 </html>
 <?php } ?>

+ 59 - 59
www-admin/lablanca/insertoffer.php

@@ -1,61 +1,61 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	$default_host = substr($http_host, 0, strpos($http_host, ':'));
-	include("../functions.php");
-	$con = startdb('rw');
-	if (!checkSession($con)){
-		exit (-1);
-	}
-	else{
-		$year = mysqli_real_escape_string($con, $_POST['year']);
-		$name_es = mysqli_real_escape_string($con, urldecode($_POST['name_es']));
-		$name_en = mysqli_real_escape_string($con, urldecode($_POST['name_en']));
-		$name_eu = mysqli_real_escape_string($con, urldecode($_POST['name_eu']));
-		$text_es = mysqli_real_escape_string($con, urldecode($_POST['text_es']));
-		$text_en = mysqli_real_escape_string($con, urldecode($_POST['text_en']));
-		$text_eu = mysqli_real_escape_string($con, urldecode($_POST['text_eu']));
-		$price = intval(mysqli_real_escape_string($con, $_POST['price']));
-		$days = intval(mysqli_real_escape_string($con, $_POST['days']));
-		
-		//Verify parameters
-		if (strlen($name_es) <= 0){
-			error_log('GMADMIN: Not inserting an offer with an empty spanish name.');
-			exit(-1);
-		}
-		if(strlen($text_es) <= 0){
-			error_log('GMADMIN: Not inserting an offer with an empty spanish text.');
-			exit(-1);
-		}
-		if ($price < 0){
-			error_log("GMADMIN: Not inserting offer '$name_es' with price $price.");
-			exit(-1);
-		}
-		if ($days < 1){
-			error_log("GMADMIN: Not inserting offer '$name_es' for $days day(s).");
-			exit(-1);
-		}
-		if ($year < 2000){
-			error_log("GMADMIN: Not inserting offer '$name_es' for year $year.");
-			exit(-1);
-		}
-		
-		//Check tanslations
-		if (strlen($name_en) == 0 || $name_en = $name_es){
-			$name_en = $name_es;
-		}
-		if (strlen($name_eu) == 0 || $name_eu = $name_es){
-			$name_eu = $name_es;
-		}
-		if (strlen($text_en) == 0 || $text_en = $text_es){
-			$text_en = $text_es;
-		}
-		if (strlen($text_eu) == 0 || $text_eu = $text_es){
-			$text_eu = $text_es;
-		}
-		
-		//Insert into database
-		mysqli_query($con, "INSERT INTO festival_offer (year, name_es, name_en, name_eu, description_es, description_en, description_eu, days, price) VALUES ($year, '$name_es', '$name_en', '$name_eu', '$text_es', '$text_en', '$text_eu', $days, $price);");
-		
-		version();
-	}
+    $http_host = $_SERVER['HTTP_HOST'];
+    $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    include("../functions.php");
+    $con = startdb('rw');
+    if (!checkSession($con)){
+        exit (-1);
+    }
+    else{
+        $year = mysqli_real_escape_string($con, $_POST['year']);
+        $name_es = mysqli_real_escape_string($con, urldecode($_POST['name_es']));
+        $name_en = mysqli_real_escape_string($con, urldecode($_POST['name_en']));
+        $name_eu = mysqli_real_escape_string($con, urldecode($_POST['name_eu']));
+        $text_es = mysqli_real_escape_string($con, urldecode($_POST['text_es']));
+        $text_en = mysqli_real_escape_string($con, urldecode($_POST['text_en']));
+        $text_eu = mysqli_real_escape_string($con, urldecode($_POST['text_eu']));
+        $price = intval(mysqli_real_escape_string($con, $_POST['price']));
+        $days = intval(mysqli_real_escape_string($con, $_POST['days']));
+        
+        //Verify parameters
+        if (strlen($name_es) <= 0){
+            error_log('GMADMIN: Not inserting an offer with an empty spanish name.');
+            exit(-1);
+        }
+        if(strlen($text_es) <= 0){
+            error_log('GMADMIN: Not inserting an offer with an empty spanish text.');
+            exit(-1);
+        }
+        if ($price < 0){
+            error_log("GMADMIN: Not inserting offer '$name_es' with price $price.");
+            exit(-1);
+        }
+        if ($days < 1){
+            error_log("GMADMIN: Not inserting offer '$name_es' for $days day(s).");
+            exit(-1);
+        }
+        if ($year < 2000){
+            error_log("GMADMIN: Not inserting offer '$name_es' for year $year.");
+            exit(-1);
+        }
+        
+        //Check tanslations
+        if (strlen($name_en) == 0 || $name_en = $name_es){
+            $name_en = $name_es;
+        }
+        if (strlen($name_eu) == 0 || $name_eu = $name_es){
+            $name_eu = $name_es;
+        }
+        if (strlen($text_en) == 0 || $text_en = $text_es){
+            $text_en = $text_es;
+        }
+        if (strlen($text_eu) == 0 || $text_eu = $text_es){
+            $text_eu = $text_es;
+        }
+        
+        //Insert into database
+        mysqli_query($con, "INSERT INTO festival_offer (year, name_es, name_en, name_eu, description_es, description_en, description_eu, days, price) VALUES ($year, '$name_es', '$name_en', '$name_eu', '$text_es', '$text_en', '$text_eu', $days, $price);");
+        
+        version();
+    }
 ?>

+ 13 - 13
www-admin/lablanca/moderate/index.php

@@ -1,15 +1,15 @@
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nuevo post - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-	</head>
-	<body>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nuevo post - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+    </head>
+    <body>
+    </body>
 </html>

+ 200 - 200
www-admin/lablanca/script.js

@@ -1,223 +1,223 @@
 function newOffer(){
-	document.getElementById('screen_cover').style.display = 'block';
-	document.getElementById('form_new_offer').style.display = 'block';
-	document.getElementById('screen_cover').style.opacity = '0.6';
-	document.getElementById('form_new_offer').style.opacity = '1';
+    document.getElementById('screen_cover').style.display = 'block';
+    document.getElementById('form_new_offer').style.display = 'block';
+    document.getElementById('screen_cover').style.opacity = '0.6';
+    document.getElementById('form_new_offer').style.opacity = '1';
 }
 
 function cancelNewOffer(){
-	if (confirm("Oferta no agregada. Descartar cambios?")){
-		closeNewOffer();
-	}
+    if (confirm("Oferta no agregada. Descartar cambios?")){
+        closeNewOffer();
+    }
 }
 
 function closeNewOffer(){
-	document.getElementById('new_offer_title_es').value = '';
-	document.getElementById('new_offer_title_en').value = '';
-	document.getElementById('new_offer_title_eu').value = '';
-	document.getElementById('new_offer_text_es').value = '';
-	document.getElementById('new_offer_text_en').value = '';
-	document.getElementById('new_offer_text_eu').value = '';
-	document.getElementById('new_offer_days').value = '1';
-	document.getElementById('new_offer_price').value = '0';
-	document.getElementById('screen_cover').style.display = 'none';
-	document.getElementById('form_new_offer').style.display = 'none';
-	document.getElementById('screen_cover').style.opacity = '0';
-	document.getElementById('form_new_offer').style.opacity = '0';
+    document.getElementById('new_offer_title_es').value = '';
+    document.getElementById('new_offer_title_en').value = '';
+    document.getElementById('new_offer_title_eu').value = '';
+    document.getElementById('new_offer_text_es').value = '';
+    document.getElementById('new_offer_text_en').value = '';
+    document.getElementById('new_offer_text_eu').value = '';
+    document.getElementById('new_offer_days').value = '1';
+    document.getElementById('new_offer_price').value = '0';
+    document.getElementById('screen_cover').style.display = 'none';
+    document.getElementById('form_new_offer').style.display = 'none';
+    document.getElementById('screen_cover').style.opacity = '0';
+    document.getElementById('form_new_offer').style.opacity = '0';
 }
 
 function saveNewOffer(year){
-	//Get values
-	var name_es = document.getElementById('new_offer_title_es').value;
-	var name_en = document.getElementById('new_offer_title_en').value;
-	var name_eu = document.getElementById('new_offer_title_eu').value;
-	var text_es = document.getElementById('new_offer_text_es').value;
-	var text_en = document.getElementById('new_offer_text_en').value;
-	var text_eu = document.getElementById('new_offer_text_eu').value;
-	var days = document.getElementById('new_offer_days').value;
-	var price = document.getElementById('new_offer_price').value;
-	
-	//Validate values
-	if (name_es.length == 0){
-		alert("Debes introducir el nombre, al menos en castellano.");
-		document.getElementById('new_offer_title_es').focus();
-		return;
-	}
-	if (text_es.length == 0){
-		alert("Debes introducir una descripcion, al menos en castellano.");
-		document.getElementById('new_offer_text_es').focus();
-		return;
-	}
-	if (parseInt(price, 10) <= 0){
-		alert("Debes introducir un precio valido.");
-		document.getElementById('new_offer_price').focus();
-		return;
-	}
-	if (parseInt(price, 10) <= 1 || parseInt(price, 10) > 6){
-		alert("Debes introducir un numer valido de dias.");
-		document.getElementById('new_offer_days').focus();
-		return;
-	}
-	
-	// Encode required values
-	name_es = encodeURI(name_es);
-	name_en = encodeURI(name_en);
-	name_eu = encodeURI(name_eu);
-	text_es = encodeURI(text_es);
-	text_en = encodeURI(text_en);
-	text_eu = encodeURI(text_eu);
-	
-	// Get page
-	if(XMLHttpRequest)
-		var x = new XMLHttpRequest();
-	else 
-		var x = new ActiveXObject("Microsoft.XMLHTTP");
-	x.open("POST", "/lablanca/insertoffer.php", true);
-	var params = "year=" + year + "&name_es=" + name_es + "&name_en=" + name_en + "&name_eu=" + name_eu + "&text_es=" + text_es + "&text_en=" + text_en + "&text_eu=" + text_eu + "&price=" + price + "&days=" + days;
-	x.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
-	x.onreadystatechange = function(){
-	if(x.readyState == 4){
-		if(x.status == 200)
-			closeNewOffer();
-			calculate('prices');
-		}
-	}
-	x.send(params);
+    //Get values
+    var name_es = document.getElementById('new_offer_title_es').value;
+    var name_en = document.getElementById('new_offer_title_en').value;
+    var name_eu = document.getElementById('new_offer_title_eu').value;
+    var text_es = document.getElementById('new_offer_text_es').value;
+    var text_en = document.getElementById('new_offer_text_en').value;
+    var text_eu = document.getElementById('new_offer_text_eu').value;
+    var days = document.getElementById('new_offer_days').value;
+    var price = document.getElementById('new_offer_price').value;
+    
+    //Validate values
+    if (name_es.length == 0){
+        alert("Debes introducir el nombre, al menos en castellano.");
+        document.getElementById('new_offer_title_es').focus();
+        return;
+    }
+    if (text_es.length == 0){
+        alert("Debes introducir una descripcion, al menos en castellano.");
+        document.getElementById('new_offer_text_es').focus();
+        return;
+    }
+    if (parseInt(price, 10) <= 0){
+        alert("Debes introducir un precio valido.");
+        document.getElementById('new_offer_price').focus();
+        return;
+    }
+    if (parseInt(price, 10) <= 1 || parseInt(price, 10) > 6){
+        alert("Debes introducir un numer valido de dias.");
+        document.getElementById('new_offer_days').focus();
+        return;
+    }
+    
+    // Encode required values
+    name_es = encodeURI(name_es);
+    name_en = encodeURI(name_en);
+    name_eu = encodeURI(name_eu);
+    text_es = encodeURI(text_es);
+    text_en = encodeURI(text_en);
+    text_eu = encodeURI(text_eu);
+    
+    // Get page
+    if(XMLHttpRequest)
+        var x = new XMLHttpRequest();
+    else 
+        var x = new ActiveXObject("Microsoft.XMLHTTP");
+    x.open("POST", "/lablanca/insertoffer.php", true);
+    var params = "year=" + year + "&name_es=" + name_es + "&name_en=" + name_en + "&name_eu=" + name_eu + "&text_es=" + text_es + "&text_en=" + text_en + "&text_eu=" + text_eu + "&price=" + price + "&days=" + days;
+    x.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
+    x.onreadystatechange = function(){
+    if(x.readyState == 4){
+        if(x.status == 200)
+            closeNewOffer();
+            calculate('prices');
+        }
+    }
+    x.send(params);
 }
 
 function calculate(section){
-	switch (section){
-		case 'all':
-			calculate('header');
-			calculate('prices');
-			calculate('schedule');
-			break;
-		case 'header':
-			setTimeout(function(){
-				// Get page
-				if(XMLHttpRequest)
-					var x = new XMLHttpRequest();
-				else 
-					var x = new ActiveXObject("Microsoft.XMLHTTP");
-				x.open("GET", "/lablanca/calculate.php?section=header", true);
-				x.send();
-				x.onreadystatechange = function(){
-				if(x.readyState == 4){
-					if(x.status == 200)
-						document.getElementById('status_header').innerHTML = x.responseText;
-					}
-				}
-			}, 500);
-			break;
-		case 'prices':
-			setTimeout(function(){
-				// Get page
-				if(XMLHttpRequest)
-					var x = new XMLHttpRequest();
-				else 
-					var x = new ActiveXObject("Microsoft.XMLHTTP");
-				x.open("GET", "/lablanca/calculate.php?section=pricesprogress", true);
-				x.send();
-				x.onreadystatechange = function(){
-				if(x.readyState == 4){
-					if(x.status == 200)
-						document.getElementById('status_prices').innerHTML = x.responseText;
-					}
-				}
-			}, 500);
-			setTimeout(function(){
-				// Get page
-				if(XMLHttpRequest)
-					var x = new XMLHttpRequest();
-				else 
-					var x = new ActiveXObject("Microsoft.XMLHTTP");
-				x.open("GET", "/lablanca/calculate.php?section=pricesoffers", true);
-				x.send();
-				x.onreadystatechange = function(){
-				if(x.readyState == 4){
-					if(x.status == 200)
-						document.getElementById('prices_offers').innerHTML = x.responseText;
-					}
-				}
-			}, 700);
-			break;
-		case 'schedule':
-			console.log('Recalculating schedule...');
-			break;
-	}
+    switch (section){
+        case 'all':
+            calculate('header');
+            calculate('prices');
+            calculate('schedule');
+            break;
+        case 'header':
+            setTimeout(function(){
+                // Get page
+                if(XMLHttpRequest)
+                    var x = new XMLHttpRequest();
+                else 
+                    var x = new ActiveXObject("Microsoft.XMLHTTP");
+                x.open("GET", "/lablanca/calculate.php?section=header", true);
+                x.send();
+                x.onreadystatechange = function(){
+                if(x.readyState == 4){
+                    if(x.status == 200)
+                        document.getElementById('status_header').innerHTML = x.responseText;
+                    }
+                }
+            }, 500);
+            break;
+        case 'prices':
+            setTimeout(function(){
+                // Get page
+                if(XMLHttpRequest)
+                    var x = new XMLHttpRequest();
+                else 
+                    var x = new ActiveXObject("Microsoft.XMLHTTP");
+                x.open("GET", "/lablanca/calculate.php?section=pricesprogress", true);
+                x.send();
+                x.onreadystatechange = function(){
+                if(x.readyState == 4){
+                    if(x.status == 200)
+                        document.getElementById('status_prices').innerHTML = x.responseText;
+                    }
+                }
+            }, 500);
+            setTimeout(function(){
+                // Get page
+                if(XMLHttpRequest)
+                    var x = new XMLHttpRequest();
+                else 
+                    var x = new ActiveXObject("Microsoft.XMLHTTP");
+                x.open("GET", "/lablanca/calculate.php?section=pricesoffers", true);
+                x.send();
+                x.onreadystatechange = function(){
+                if(x.readyState == 4){
+                    if(x.status == 200)
+                        document.getElementById('prices_offers').innerHTML = x.responseText;
+                    }
+                }
+            }, 700);
+            break;
+        case 'schedule':
+            console.log('Recalculating schedule...');
+            break;
+    }
 }
 
 function uploadHeaderImage(event, id){
-	var selectedFile = event.target.files[0];
-	
-	//Set image on page
-	var reader = new FileReader();
-	var imgtag = document.getElementById("header_img");
-	reader.onload = function(event) {
-		imgtag.src = event.target.result;
-		
-		//Upload image;
-		var formData = new FormData();
-		var file = document.getElementById('header_img_selector').files[0];
-		formData.append('img', selectedFile, selectedFile.name);
-		//for(var pair of formData.entries()) {
-		//	console.log(pair[0]+ ', '+ pair[1]); 
-		//}
-		//console.log("FD" + formData);
-		
-		// Get page
-		if(XMLHttpRequest)
-			var x = new XMLHttpRequest();
-		else 
-			var x = new ActiveXObject("Microsoft.XMLHTTP");
-		x.open("POST", "/lablanca/uploadimage.php?type=header&id=" + id, true);
-		x.onload = function(){
-		if(x.readyState == 4){
-			if(x.status == 200)
-				console.log("TRUE")
-				return true;
-			}
-			else{
-				console.log("FASLE");
-			}
-		}
-		x.send(formData);
-	};
-	reader.readAsDataURL(selectedFile);
+    var selectedFile = event.target.files[0];
+    
+    //Set image on page
+    var reader = new FileReader();
+    var imgtag = document.getElementById("header_img");
+    reader.onload = function(event) {
+        imgtag.src = event.target.result;
+        
+        //Upload image;
+        var formData = new FormData();
+        var file = document.getElementById('header_img_selector').files[0];
+        formData.append('img', selectedFile, selectedFile.name);
+        //for(var pair of formData.entries()) {
+        //    console.log(pair[0]+ ', '+ pair[1]); 
+        //}
+        //console.log("FD" + formData);
+        
+        // Get page
+        if(XMLHttpRequest)
+            var x = new XMLHttpRequest();
+        else 
+            var x = new ActiveXObject("Microsoft.XMLHTTP");
+        x.open("POST", "/lablanca/uploadimage.php?type=header&id=" + id, true);
+        x.onload = function(){
+        if(x.readyState == 4){
+            if(x.status == 200)
+                console.log("TRUE")
+                return true;
+            }
+            else{
+                console.log("FASLE");
+            }
+        }
+        x.send(formData);
+    };
+    reader.readAsDataURL(selectedFile);
 }
 
 function updateField(table, field, value, id, type = 'text', canBeNull = true){
-	// Get page
-	if(XMLHttpRequest)
-		var x = new XMLHttpRequest();
-	else 
-		var x = new ActiveXObject("Microsoft.XMLHTTP");
-	x.open("POST", "/lablanca/execute.php", true);
-	var params = "action=update&table=" + table + "&field=" + field + "&value=" + encodeURI(value) + "&id=" + id + "&type=" + type;
-	x.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
-	x.onreadystatechange = function(){
-	if(x.readyState == 4){
-		if(x.status == 200)
-			return true;
-		}
-	}
-	x.send(params);
+    // Get page
+    if(XMLHttpRequest)
+        var x = new XMLHttpRequest();
+    else 
+        var x = new ActiveXObject("Microsoft.XMLHTTP");
+    x.open("POST", "/lablanca/execute.php", true);
+    var params = "action=update&table=" + table + "&field=" + field + "&value=" + encodeURI(value) + "&id=" + id + "&type=" + type;
+    x.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
+    x.onreadystatechange = function(){
+    if(x.readyState == 4){
+        if(x.status == 200)
+            return true;
+        }
+    }
+    x.send(params);
 }
 
 function deleteOffer(id){
-	// Get page
-	if(XMLHttpRequest)
-		var x = new XMLHttpRequest();
-	else 
-		var x = new ActiveXObject("Microsoft.XMLHTTP");
-	x.open("POST", "/lablanca/execute.php", true);
-	var params = "action=delete&table=festival_offer&id=" + id;
-	x.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
-	x.onreadystatechange = function(){
-	if(x.readyState == 4){
-		if(x.status == 200)
-			calculate('prices');
-		}
-	}
-	x.send(params);
+    // Get page
+    if(XMLHttpRequest)
+        var x = new XMLHttpRequest();
+    else 
+        var x = new ActiveXObject("Microsoft.XMLHTTP");
+    x.open("POST", "/lablanca/execute.php", true);
+    var params = "action=delete&table=festival_offer&id=" + id;
+    x.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
+    x.onreadystatechange = function(){
+    if(x.readyState == 4){
+        if(x.status == 200)
+            calculate('prices');
+        }
+    }
+    x.send(params);
 }

+ 13 - 13
www-admin/lablanca/translate/index.php

@@ -1,15 +1,15 @@
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nuevo post - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-	</head>
-	<body>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nuevo post - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+    </head>
+    <body>
+    </body>
 </html>

+ 75 - 75
www-admin/lablanca/uploadimage.php

@@ -1,77 +1,77 @@
 <?php
-	error_log("starting uploading image");
-	$http_host = $_SERVER['HTTP_HOST'];
-	$default_host = substr($http_host, 0, strpos($http_host, ':'));
-	include("../functions.php");
-	$con = startdb('rw');
-	if (!checkSession($con)){
-		exit (-1);
-	}
-	else{
-		//Get data
-		$type = mysqli_real_escape_string($con, $_GET['type']);
-		$id = mysqli_real_escape_string($con, $_GET['id']);
-		$file = $_FILES['img'];
-		error_log("DFILE: " . $_FILES['img']['tmp_name']);
-		
-		//Check if image file
-		$check = getimagesize($_FILES['img']['tmp_name']);
-		if($check == false) {
-			error_log("Uploading " . $_FILES['img']['tmp_name'] . ": File is not an image - " . $check["mime"] . ".");
-			exit(-1);
-		}
-		
-		error_log("uploading image");
-		
-		//Upload the image to its destination
-		switch ($type){
-			case 'header':
-				$q = mysqli_query($con, "SELECT * FROM festival WHERE id = $id;");
-				if (mysqli_num_rows($q) > 0){
-					$r = mysqli_fetch_array($q);
-					move_uploaded_file($_FILES['img']['tmp_name'], "../../www/img/fiestas/tmp.$r[id].png");
-					error_log($_FILES['img']['tmp_name']. " ../../www/img/fiestas/tmp.$r[id].png");
-					
-					//Get image dimensions
-					$i_w = $check[0];
-					$i_h = $check[1];
-					
-					//Calculate preview and miniature dimensions
-					if ($i_w > $i_h){
-						$p_w = $IMG_SIZE_PREVIEW;
-						$p_h = ceil($i_h * $IMG_SIZE_PREVIEW) / $i_w;
-						$m_w = $IMG_SIZE_MINIATURE;
-						$m_h = ceil($i_h * $IMG_SIZE_MINIATURE) / $i_w;
-					}
-					else{
-						$p_h = $IMG_SIZE_PREVIEW;
-						$p_w = ceil($i_h * $IMG_SIZE_PREVIEW) / $i_h;
-						$m_h = $IMG_SIZE_MINIATURE;
-						$m_w = ceil($i_w * $IMG_SIZE_MINIATURE) / $i_h;
-					}
-					
-					//Convert to png
-					$thumb = new Imagick();
-					$thumb->readImage("../../www/img/fiestas/tmp.$r[id].png");    
-					$thumb->writeImage("../../www/img/fiestas/$r[year].png");
-					$thumb->resizeImage(800,800,Imagick::FILTER_POINT, false);
-					$thumb->writeImage("../../www/img/fiestas/view/$r[year].png");
-					$thumb->resizeImage(600,600,Imagick::FILTER_POINT, false);
-					$thumb->writeImage("../../www/img/fiestas/preview/$r[year].png");
-					$thumb->resizeImage(340,340,Imagick::FILTER_POINT, false);
-					$thumb->writeImage("../../www/img/fiestas/miniature/$r[year].png");
-					$thumb->resizeImage(180,180,Imagick::FILTER_POINT, false);
-					$thumb->writeImage("../../www/img/fiestas/thumb/$r[year].png");
-					$thumb->clear();
-					$thumb->destroy(); 
-					
-					//Update database
-					if (strlen($r['img']) == 0){
-						mysqli_query($con, "UPDATE festival SET img = '$r[year].png' WHERE id = $id;");
-						version();
-					}
-				}
-				break;
-		}
-	}
+    error_log("starting uploading image");
+    $http_host = $_SERVER['HTTP_HOST'];
+    $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    include("../functions.php");
+    $con = startdb('rw');
+    if (!checkSession($con)){
+        exit (-1);
+    }
+    else{
+        //Get data
+        $type = mysqli_real_escape_string($con, $_GET['type']);
+        $id = mysqli_real_escape_string($con, $_GET['id']);
+        $file = $_FILES['img'];
+        error_log("DFILE: " . $_FILES['img']['tmp_name']);
+        
+        //Check if image file
+        $check = getimagesize($_FILES['img']['tmp_name']);
+        if($check == false) {
+            error_log("Uploading " . $_FILES['img']['tmp_name'] . ": File is not an image - " . $check["mime"] . ".");
+            exit(-1);
+        }
+        
+        error_log("uploading image");
+        
+        //Upload the image to its destination
+        switch ($type){
+            case 'header':
+                $q = mysqli_query($con, "SELECT * FROM festival WHERE id = $id;");
+                if (mysqli_num_rows($q) > 0){
+                    $r = mysqli_fetch_array($q);
+                    move_uploaded_file($_FILES['img']['tmp_name'], "../../www/img/fiestas/tmp.$r[id].png");
+                    error_log($_FILES['img']['tmp_name']. " ../../www/img/fiestas/tmp.$r[id].png");
+                    
+                    //Get image dimensions
+                    $i_w = $check[0];
+                    $i_h = $check[1];
+                    
+                    //Calculate preview and miniature dimensions
+                    if ($i_w > $i_h){
+                        $p_w = $IMG_SIZE_PREVIEW;
+                        $p_h = ceil($i_h * $IMG_SIZE_PREVIEW) / $i_w;
+                        $m_w = $IMG_SIZE_MINIATURE;
+                        $m_h = ceil($i_h * $IMG_SIZE_MINIATURE) / $i_w;
+                    }
+                    else{
+                        $p_h = $IMG_SIZE_PREVIEW;
+                        $p_w = ceil($i_h * $IMG_SIZE_PREVIEW) / $i_h;
+                        $m_h = $IMG_SIZE_MINIATURE;
+                        $m_w = ceil($i_w * $IMG_SIZE_MINIATURE) / $i_h;
+                    }
+                    
+                    //Convert to png
+                    $thumb = new Imagick();
+                    $thumb->readImage("../../www/img/fiestas/tmp.$r[id].png");    
+                    $thumb->writeImage("../../www/img/fiestas/$r[year].png");
+                    $thumb->resizeImage(800,800,Imagick::FILTER_POINT, false);
+                    $thumb->writeImage("../../www/img/fiestas/view/$r[year].png");
+                    $thumb->resizeImage(600,600,Imagick::FILTER_POINT, false);
+                    $thumb->writeImage("../../www/img/fiestas/preview/$r[year].png");
+                    $thumb->resizeImage(340,340,Imagick::FILTER_POINT, false);
+                    $thumb->writeImage("../../www/img/fiestas/miniature/$r[year].png");
+                    $thumb->resizeImage(180,180,Imagick::FILTER_POINT, false);
+                    $thumb->writeImage("../../www/img/fiestas/thumb/$r[year].png");
+                    $thumb->clear();
+                    $thumb->destroy(); 
+                    
+                    //Update database
+                    if (strlen($r['img']) == 0){
+                        mysqli_query($con, "UPDATE festival SET img = '$r[year].png' WHERE id = $id;");
+                        version();
+                    }
+                }
+                break;
+        }
+    }
 ?>

+ 8 - 8
www-admin/login.php

@@ -1,10 +1,10 @@
 <?php
-	include('functions.php');
-	$con = startdb();
-	$user = mysqli_real_escape_string($con, $_POST['user']);
-	$pass = mysqli_real_escape_string($con, $_POST['pass']);
-	if (login($con, $user, $pass))
-		header("Location: /main.php");
-	else
-		header("Location: /index.php");
+    include('functions.php');
+    $con = startdb();
+    $user = mysqli_real_escape_string($con, $_POST['user']);
+    $pass = mysqli_real_escape_string($con, $_POST['pass']);
+    if (login($con, $user, $pass))
+        header("Location: /main.php");
+    else
+        header("Location: /index.php");
 ?>

+ 120 - 121
www-admin/main.php

@@ -1,126 +1,125 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	$default_host = substr($http_host, 0, strpos($http_host, ':'));
-	include("functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
+    include("functions.php");
+    $server = getProtocol() . $_SERVER['HTTP_HOST'];
+    $default_host = substr($server, 0, strpos($http_host, ':'));
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
 ?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Gasteizko Margolariak - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/main.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/main.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-		<?php include('toolbar.php'); ?>
-		<div id='content'>
-			<div id='section_table'>
-				<div class='section_row'>
-					<div class='section_cell'>
-						<div class='section'>
-							<h3 class='section_title'>Blog</h3>
-							<div class='entry'>
-								<ul>
-									<li><a href='/blog/add/'>Nuevo post</a></li>
-									<li><a href='/blog/'>Gestionar posts</a></li>
-								</ul>
-							</div>
-						</div>
-					</div>
-					<div class='section_cell'>
-						<div class='section'>
-							<h3 class='section_title'>Actividades</h3>
-							<div class='entry'>
-								<ul>
-									<li><a href='/actividades/add/'>Nueva actividad</a></li>
-									<li><a href='/actividades/'>Gestionar actividades</a></li>
-								</ul>
-							</div>
-						</div>
-					</div>
-				</div>
-				<div class='section_row'>
-					<div class='section_cell'>
-						<div class='section'>
-							<h3 class='section_title'>Galeria</h3>
-							<div class='entry'>
-								<ul>
-									<li><a href='/galeria/add/'>Crear album</a></li>
-									<li><a href='/galeria/'>Gestionar albums</a></li>
-									<li><a href='/galeria/upload/'>Subir fotos</a></li>
-									<li><a href='/galeria/moderate/'>Moderar comentarios</a></li>
-									<li><a href='/galeria/translate/'>Traducir galeria</a></li>
-								</ul>
-							</div>
-						</div>
-					</div>
-					<div class='section_cell'>
-						<div class='section'>
-							<h3 class='section_title'>Fiestas</h3>
-							<div class='entry'>
-								<ul>
-									<li><a href='/lablanca/'>Preparar las fiestas</a></li>
-									<li><a href='/lablanca/prices.php'>Gestionar precios</a></li>
-									<li><a href='/lablanca/schedule.php'>Gestionar programa</a></li>
-								</ul>
-							</div>
-						</div>
-					</div>
-				</div>
-				<div class='section_row'>
-					<div class='section_cell'>
-						<div class='section'>
-							<h3 class='section_title'>Miembros</h3>
-							<div class='entry'>
-								<ul>
-									<li><a href='/miembros/'>Consultar y buscar</a></li>
-									<li><a href='/miembros/add/'>Anadir miembros</a></li>
-									<li><a href='/miembros/editable.php'>Gestionar lista</a></li>
-								</ul>
-							</div>
-						</div>
-					</div>
-					<div class='section_cell'>
-						<div class='section'>
-							<h3 class='section_title'>Estadisticas</h3>
-							<div class='entry'>
-								<ul>
-									<li><a href='/estadisticas/web.php'>Estadisticas Web</a></li>
-									<li><a href='/estadisticas/app.php'>Estadisticas Apps</a></li>
-									<li><a href='/estadisticas/miembros'>Estadisticas miembros</a></li>
-								</ul>
-							</div>
-						</div>
-					</div>
-				</div>
-				<div class='section_row'>
-					<div class='section_cell'>
-						<div class='section'>
-							<h3 class='section_title'>Ajustes</h3>
-							<div class='entry'>
-								<ul>
-									<li><a href=''>Cambiar ajustes</a></li>
-									<li><a href=''>Gestionar usuarios</a></li>
-									<li><a href=''>Salir</a></li>
-								</ul>
-							</div>
-						</div>
-					</div>
-				</div>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Gasteizko Margolariak - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/main.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/main.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+        <?php include('toolbar.php'); ?>
+        <div id='content'>
+            <div id='section_table'>
+                <div class='section_row'>
+                    <div class='section_cell'>
+                        <div class='section'>
+                            <h3 class='section_title'>Blog</h3>
+                            <div class='entry'>
+                                <ul>
+                                    <li><a href='<?=$server?>/blog/add/'>Nuevo post</a></li>
+                                    <li><a href='<?=$server?>/blog/'>Gestionar posts</a></li>
+                                </ul>
+                            </div>
+                        </div>
+                    </div>
+                    <div class='section_cell'>
+                        <div class='section'>
+                            <h3 class='section_title'>Actividades</h3>
+                            <div class='entry'>
+                                <ul>
+                                    <li><a href='<?=$server?>/actividades/add/'>Nueva actividad</a></li>
+                                    <li><a href='<?=$server?>/actividades/'>Gestionar actividades</a></li>
+                                </ul>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class='section_row'>
+                    <div class='section_cell'>
+                        <div class='section'>
+                            <h3 class='section_title'>Galeria</h3>
+                            <div class='entry'>
+                                <ul>
+                                    <li><a href='<?=$server?>/galeria/add/'>Crear album</a></li>
+                                    <li><a href='<?=$server?>/galeria/'>Gestionar albums</a></li>
+                                    <li><a href='<?=$server?>/galeria/upload/'>Subir fotos</a></li>
+                                    <li><a href='<?=$server?>/galeria/moderate/'>Moderar comentarios</a></li>
+                                    <li><a href='<?=$server?>/galeria/translate/'>Traducir galeria</a></li>
+                                </ul>
+                            </div>
+                        </div>
+                    </div>
+                    <div class='section_cell'>
+                        <div class='section'>
+                            <h3 class='section_title'>Fiestas</h3>
+                            <div class='entry'>
+                                <ul>
+                                    <li><a href='<?=$server?>/lablanca/'>Preparar las fiestas</a></li>
+                                    <li><a href='<?=$server?>/lablanca/prices.php'>Gestionar precios</a></li>
+                                    <li><a href='<?=$server?>/lablanca/schedule.php'>Gestionar programa</a></li>
+                                </ul>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class='section_row'>
+                    <div class='section_cell'>
+                        <div class='section'>
+                            <h3 class='section_title'>Miembros</h3>
+                            <div class='entry'>
+                                <ul>
+                                    <li><a href='<?=$server?>/miembros/'>Consultar y buscar</a></li>
+                                    <li><a href='<?=$server?>/miembros/add/'>A&ntilde;adir miembros</a></li>
+                                </ul>
+                            </div>
+                        </div>
+                    </div>
+                    <div class='section_cell'>
+                        <div class='section'>
+                            <h3 class='section_title'>Estadisticas</h3>
+                            <div class='entry'>
+                                <ul>
+                                    <li><a href='<?=$server?>/estadisticas/web/'>Estadisticas Web</a></li>
+                                    <li><a href='<?=$server?>/estadisticas/app/'>Estadisticas Apps</a></li>
+                                    <li><a href='<?=$server?>/estadisticas/miembros/'>Estadisticas miembros</a></li>
+                                </ul>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class='section_row'>
+                    <div class='section_cell'>
+                        <div class='section'>
+                            <h3 class='section_title'>Ajustes</h3>
+                            <div class='entry'>
+                                <ul>
+                                    <li><a href='<?=$server?>/settings/'Ajustes</a></li>
+                                    <li><a href='<?=$server?>/users/'>Gestionar usuarios</a></li>
+                                    <li><a href='<?=$server?>/salir/'>Salir</a></li>
+                                </ul>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </body>
 </html>
 <?php } ?>

+ 13 - 13
www-admin/miembros/add/index.php

@@ -1,15 +1,15 @@
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nuevo post - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-	</head>
-	<body>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nuevo post - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+    </head>
+    <body>
+    </body>
 </html>

+ 13 - 13
www-admin/miembros/edit/index.php

@@ -1,15 +1,15 @@
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nuevo post - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-	</head>
-	<body>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nuevo post - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+    </head>
+    <body>
+    </body>
 </html>

+ 88 - 88
www-admin/miembros/index.php

@@ -1,92 +1,92 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	include("../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{?>
+    $http_host = $_SERVER['HTTP_HOST'];
+    include("../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{?>
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Miembros - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/miembros.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/miembros.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="script.js"></script>
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-		<?php include('../toolbar.php'); ?>
-		<div id='content'>
-			<div class="section" id="section_table">
-				<div class="entry">
-					Filtro: <input type="text" onkeyup='populate_table(this.value)'/>
-				</div><br/>
-				<div class="entry" id="entry_table">
-					<table id="member_table">
-						<tr>
-							<th>Nombre</th>
-							<th>Contacto</th>
-							<th style='display:none;'>details</th>
-							<th>Acciones</th>
-						</tr>
-						<?php
-							$q = mysqli_query($con, "SELECT * FROM member;");
-							$i = 0;
-							while ($r = mysqli_fetch_array($q)){
-								if ($i % 2 == 0)
-									echo "<tr class='member_row_even'>\n";
-								else
-									echo "<tr class='member_row_odd'>\n";
-								$i ++;
-								echo "<td>$r[lname]";
-								if ($r['lname2'] != null)
-									echo " $r[lname2]";
-								echo ", $r[name]";
-								if ($r['alias'] != null)
-									echo "<span style='font-style:italic;'> - ($r[alias])</span>";
-								echo "</td>\n";
-								echo "<td style='text-align:center;'>";
-								if ($r['phone'] != null)
-									echo "$r[phone]<br/>";
-								if ($r['mail'] != null)
-									echo "$r[mail]";
-								echo "</td>\n";
-								echo "<td style='display:none;'>$r[name]$r[lname]$r[lname2]$r[dni],$r[address]</td>\n";
-								echo "<td style='text-align:center;'><a href='http://$http_host/miembros/miembro.php?m=$r[id]'>Ficha completa</a><br/><a href=''>Editar</a></td>\n";
-								echo "</tr>\n";
-							}
-						?>
-					</table>
-				</div>
-			</div>
-			<div class="section" id="section_table_actions">
-				<div class="entry">
-					<h3>Acciones</h3>
-					<ul>
-						<li><a href="<?php echo "http://$http_host/miembros/add/";?>">Anadir miembro</a></li>
-						<li><a href="<?php echo "http://$http_host/miembros/add/batch.php";?>">Anadir miembros en lote</a></li>
-					</ul>
-				</div><br/>
-				<div class="entry">
-					<h3>Recuerda</h3>
-					<p>Estos datos sobre los miembros de Gasteizko Margolariak son confidenciales y estan protegidos bajo la Ley de Proteccion de Datos. Se responsable al utilizarlos.</p>
-					<ul>
-						<li>No los uses para propositos personales o no relacionados con Gasteizko Margolariak</li>
-						<li>No hagas una copia de estos datos</li>
-						<li>No difundas estos a terceras personas</li>
-						<li>El acceso y la modificacion de estos datos es monitorizado por el sistema</li>
-					</ul>
-				</div>
-			</div>
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Miembros - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/miembros.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/miembros.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+        <?php include('../toolbar.php'); ?>
+        <div id='content'>
+            <div class="section" id="section_table">
+                <div class="entry">
+                    Filtro: <input type="text" onkeyup='populate_table(this.value)'/>
+                </div><br/>
+                <div class="entry" id="entry_table">
+                    <table id="member_table">
+                        <tr>
+                            <th>Nombre</th>
+                            <th>Contacto</th>
+                            <th style='display:none;'>details</th>
+                            <th>Acciones</th>
+                        </tr>
+                        <?php
+                            $q = mysqli_query($con, "SELECT * FROM member;");
+                            $i = 0;
+                            while ($r = mysqli_fetch_array($q)){
+                                if ($i % 2 == 0)
+                                    echo "<tr class='member_row_even'>\n";
+                                else
+                                    echo "<tr class='member_row_odd'>\n";
+                                $i ++;
+                                echo "<td>$r[lname]";
+                                if ($r['lname2'] != null)
+                                    echo " $r[lname2]";
+                                echo ", $r[name]";
+                                if ($r['alias'] != null)
+                                    echo "<span style='font-style:italic;'> - ($r[alias])</span>";
+                                echo "</td>\n";
+                                echo "<td style='text-align:center;'>";
+                                if ($r['phone'] != null)
+                                    echo "$r[phone]<br/>";
+                                if ($r['mail'] != null)
+                                    echo "$r[mail]";
+                                echo "</td>\n";
+                                echo "<td style='display:none;'>$r[name]$r[lname]$r[lname2]$r[dni],$r[address]</td>\n";
+                                echo "<td style='text-align:center;'><a href='http://$http_host/miembros/miembro.php?m=$r[id]'>Ficha completa</a><br/><a href=''>Editar</a></td>\n";
+                                echo "</tr>\n";
+                            }
+                        ?>
+                    </table>
+                </div>
+            </div>
+            <div class="section" id="section_table_actions">
+                <div class="entry">
+                    <h3>Acciones</h3>
+                    <ul>
+                        <li><a href="<?php echo "http://$http_host/miembros/add/";?>">Anadir miembro</a></li>
+                        <li><a href="<?php echo "http://$http_host/miembros/add/batch.php";?>">Anadir miembros en lote</a></li>
+                    </ul>
+                </div><br/>
+                <div class="entry">
+                    <h3>Recuerda</h3>
+                    <p>Estos datos sobre los miembros de Gasteizko Margolariak son confidenciales y estan protegidos bajo la Ley de Proteccion de Datos. Se responsable al utilizarlos.</p>
+                    <ul>
+                        <li>No los uses para propositos personales o no relacionados con Gasteizko Margolariak</li>
+                        <li>No hagas una copia de estos datos</li>
+                        <li>No difundas estos a terceras personas</li>
+                        <li>El acceso y la modificacion de estos datos es monitorizado por el sistema</li>
+                    </ul>
+                </div>
+            </div>
+        </div>
+    </body>
 </html>
 <?php } ?>

+ 186 - 186
www-admin/miembros/miembro-bkp.php

@@ -1,189 +1,189 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	$default_host = substr($http_host, 0, strpos($http_host, ':'));
-	include("../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
-		$id = mysqli_real_escape_string($con, $_GET['m']);
-		$q = mysqli_query($con, "SELECT * FROM member WHERE id = $id;");
-		if (mysqli_num_rows($q) == 0){
-			header("Location: /miembros/");
-			exit (-1);
-		}
-		else{
-			$r = mysqli_fetch_array($q); ?>
-		
+    $http_host = $_SERVER['HTTP_HOST'];
+    $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    include("../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+        $id = mysqli_real_escape_string($con, $_GET['m']);
+        $q = mysqli_query($con, "SELECT * FROM member WHERE id = $id;");
+        if (mysqli_num_rows($q) == 0){
+            header("Location: /miembros/");
+            exit (-1);
+        }
+        else{
+            $r = mysqli_fetch_array($q); ?>
+        
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Miembros - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/miembros.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/miembros.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="script.js"></script>
-	</head>
-	<body>
-		<div class="section">
-			<h3><?php echo "$r[name] <span style='font-style:italic;'>$r[alias]</span> $r[lname]";?></h3>
-			<div class="entry member_section" id="member_personal">
-				<h3>Datos personales</h4>
-				<p><span style="font-weight:bold;">Nombre: </span><?php echo $r['name']; ?></p>
-				<p><span style="font-weight:bold;">Primer apellido: </span><?php echo $r['lname']; ?></p>
-				<p><span style="font-weight:bold;">Segundo apellido: </span><?php echo $r['lname2']; ?></p>
-				<p><span style="font-weight:bold;">Alias: </span><?php echo $r['alias']; ?></p>
-				<br/>
-				<p><span style="font-weight:bold;">Fecha de nacimiento: </span>
-				<?php
-					$date = formatDate($r['bdate'], 'es');
-					$date = substr($date, 0, strlen($date) - 12);
-					$dStart = new DateTime($r['bdate']);
-					$dEnd  = new DateTime();
-					$dDiff = $dStart->diff($dEnd);
-					$age =  floor(($dDiff->days) / 365);
-					if ($age < 18)
-						$date = "$date (<span style='color:#aa0000'>$age a&ntilde;os - Menor de edad</span>)";
-					else
-						$date = "$date ($age a&ntilde;os)";
-					echo $date;
-				?>
-				</p>
-				<p><span style="font-weight:bold;">DNI: </span><?php echo $r['dni'];?></p>
-				<p><span style="font-weight:bold;">Direccion: </span><?php echo $r['address'];?></p>
-			</div>
-			<div class="entry member_section" id="member_gm">
-				<h3>En la cuadrilla</h3>
-				<p><span style="font-weight:bold;">Fecha de alta: </span>
-				<?php
-					$date = formatDate($r['jdate'], 'es');
-					$date = substr($date, 0, strlen($date) - 12);
-					echo $date;
-				?>
-				</p>
-				<p><span style="font-weight:bold;">Formulario: </span>
-					<?php
-						switch ($r['joined']){
-							case 'origin':
-								echo "Socio inicial";
-								break;
-							case 'phone':
-								echo "V&iacute;a m&oacute;vil";
-								break;
-							case 'oldweb':
-								echo "V&iacute;a web antigua";
-								break;
-							case 'web':
-								echo "V&iacute;a web";
-								break;
-							default:
-								echo "V&iacute;a hoja de inscripci&oacute;n";
-						}
-					?>
-				</p>
-				<p><span style="font-weight:bold;">Junta directiva: </span>
-				<?php
-					if ($r['board'] == 1)
-						echo "Si";
-					else
-						echo "No";
-				?>
-				</p>
-			</div>
-			<div class="entry member_section" id="member_activities">
-				<h3>Actividades</h3>
-				<ul id="member_list_days">
-					<?php
-						$paid = 0;
-						$unpaid = 0;
-						$q_year = mysqli_query($con, "SELECT year(date) AS year FROM member_day, festival_day WHERE member_day.day = festival_day.id AND member = $r[id] GROUP BY year(date) ORDER BY year(date)");
-						while ($r_year = mysqli_fetch_array($q_year)){
-							echo "<li>Fiestas $r_year[year]:\n";
-							$q_day = mysqli_query($con, "SELECT day(date) AS dat, price, paid FROM festival_day, member_day WHERE member_day.day = festival_day.id AND year(date) = $r_year[year] AND member = $r[id] ORDER BY date;");
-							echo "<ul>\n";
-							while ($r_day = mysqli_fetch_array($q_day)){
-								if ($r_day['paid'] == 1){
-									echo "<li>$r_day[dat]</li>\n";
-									$paid = $paid + intval($r_day['price']);
-								}
-								else{
-									echo "<li>$r_day[dat] - <span style='color:#aa0000'>No pagado</span></li>\n";
-									$unpaid = $unpaid + intval($r_day['price']);
-								}
-									
-							}
-							echo "</ul>\n";
-							echo "</li>\n";
-						}
-					?>
-				</ul>
-				<ul id="member_list_activities">
-					<?php
-						$q_activity = mysqli_query($con, "SELECT title_es, price, year(date) AS year, paid FROM member_activity, activity WHERE member = $r[id] AND activity = activity.id");
-						while ($r_activity = mysqli_fetch_array($q_activity)){
-							if ($r_activity['paid'] == 1){
-									echo "<li>$r_activity[title_es] ($r_activity[year])</li>\n";
-									$paid = $paid + intval($r_activity['price']);
-								}
-								else{
-									echo "<li>$r_activity[title_es] ($r_activity[year]) - <span style='color:#aa0000'>No pagado</span></li>\n";
-									$unpaid = $unpaid + intval($r_activity['price']);
-								}
-						}
-					?>
-				</ul>
-				<div id="activity_count">
-					<hr/>
-					Dinero aportado: <?php echo $paid;?> &euro;
-					<?php
-						if ($unpaid > 0)
-							echo "<br/><span style='color:#aa0000'>Debe: $unpaid &euro;</span>"
-					?>
-				</div>
-			</div>
-			<div class="entry member_section" id="member_social">
-				<h3>Redes sociales</h3>
-				<ul>
-					<?php
-						if ($r['facebook'] == null)
-							echo "<li style='text-decoration: line-through;'>Facebook</li>\n";
-						else
-							echo "<li><a href='$r[facebook]'>Facebook</a></li>\n";
-						if ($r['twitter'] == null)
-							echo "<li style='text-decoration: line-through;'>Twitter</li>\n";
-						else
-							echo "<li><a href='$r[twitter]'>Twitter</a></li>\n";
-						if ($r['googleplus'] == null)
-							echo "<li style='text-decoration: line-through;'>Google+</li>\n";
-						else
-							echo "<li><a href='$r[googleplus]'>Google+</a></li>\n";
-					?>
-				</ul>
-			</div>
-			<div class="entry member_section" id="member_intolerances">
-				<h3>Intolerancias alimenticias</h3>
-				<ul>
-				<?php
-					$q_intolerance = mysqli_query($con, "SELECT element FROM intolerance WHERE member = $r[id];");
-					if (mysqli_num_rows($q_intolerance) == 0)
-						echo "<li>Ninguna</li>\n";
-					else
-						while ($r_intolerance = mysqli_fetch_array($q_intolerance))
-							echo "<li>$r_intolerance[element]</li>\n";
-				?>
-				</ul>
-			</div>
-			
-		</div>
-	</body>
-		
-		<?php }
-	}
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Miembros - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/miembros.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/miembros.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+    </head>
+    <body>
+        <div class="section">
+            <h3><?php echo "$r[name] <span style='font-style:italic;'>$r[alias]</span> $r[lname]";?></h3>
+            <div class="entry member_section" id="member_personal">
+                <h3>Datos personales</h4>
+                <p><span style="font-weight:bold;">Nombre: </span><?php echo $r['name']; ?></p>
+                <p><span style="font-weight:bold;">Primer apellido: </span><?php echo $r['lname']; ?></p>
+                <p><span style="font-weight:bold;">Segundo apellido: </span><?php echo $r['lname2']; ?></p>
+                <p><span style="font-weight:bold;">Alias: </span><?php echo $r['alias']; ?></p>
+                <br/>
+                <p><span style="font-weight:bold;">Fecha de nacimiento: </span>
+                <?php
+                    $date = formatDate($r['bdate'], 'es');
+                    $date = substr($date, 0, strlen($date) - 12);
+                    $dStart = new DateTime($r['bdate']);
+                    $dEnd  = new DateTime();
+                    $dDiff = $dStart->diff($dEnd);
+                    $age =  floor(($dDiff->days) / 365);
+                    if ($age < 18)
+                        $date = "$date (<span style='color:#aa0000'>$age a&ntilde;os - Menor de edad</span>)";
+                    else
+                        $date = "$date ($age a&ntilde;os)";
+                    echo $date;
+                ?>
+                </p>
+                <p><span style="font-weight:bold;">DNI: </span><?php echo $r['dni'];?></p>
+                <p><span style="font-weight:bold;">Direccion: </span><?php echo $r['address'];?></p>
+            </div>
+            <div class="entry member_section" id="member_gm">
+                <h3>En la cuadrilla</h3>
+                <p><span style="font-weight:bold;">Fecha de alta: </span>
+                <?php
+                    $date = formatDate($r['jdate'], 'es');
+                    $date = substr($date, 0, strlen($date) - 12);
+                    echo $date;
+                ?>
+                </p>
+                <p><span style="font-weight:bold;">Formulario: </span>
+                    <?php
+                        switch ($r['joined']){
+                            case 'origin':
+                                echo "Socio inicial";
+                                break;
+                            case 'phone':
+                                echo "V&iacute;a m&oacute;vil";
+                                break;
+                            case 'oldweb':
+                                echo "V&iacute;a web antigua";
+                                break;
+                            case 'web':
+                                echo "V&iacute;a web";
+                                break;
+                            default:
+                                echo "V&iacute;a hoja de inscripci&oacute;n";
+                        }
+                    ?>
+                </p>
+                <p><span style="font-weight:bold;">Junta directiva: </span>
+                <?php
+                    if ($r['board'] == 1)
+                        echo "Si";
+                    else
+                        echo "No";
+                ?>
+                </p>
+            </div>
+            <div class="entry member_section" id="member_activities">
+                <h3>Actividades</h3>
+                <ul id="member_list_days">
+                    <?php
+                        $paid = 0;
+                        $unpaid = 0;
+                        $q_year = mysqli_query($con, "SELECT year(date) AS year FROM member_day, festival_day WHERE member_day.day = festival_day.id AND member = $r[id] GROUP BY year(date) ORDER BY year(date)");
+                        while ($r_year = mysqli_fetch_array($q_year)){
+                            echo "<li>Fiestas $r_year[year]:\n";
+                            $q_day = mysqli_query($con, "SELECT day(date) AS dat, price, paid FROM festival_day, member_day WHERE member_day.day = festival_day.id AND year(date) = $r_year[year] AND member = $r[id] ORDER BY date;");
+                            echo "<ul>\n";
+                            while ($r_day = mysqli_fetch_array($q_day)){
+                                if ($r_day['paid'] == 1){
+                                    echo "<li>$r_day[dat]</li>\n";
+                                    $paid = $paid + intval($r_day['price']);
+                                }
+                                else{
+                                    echo "<li>$r_day[dat] - <span style='color:#aa0000'>No pagado</span></li>\n";
+                                    $unpaid = $unpaid + intval($r_day['price']);
+                                }
+                                    
+                            }
+                            echo "</ul>\n";
+                            echo "</li>\n";
+                        }
+                    ?>
+                </ul>
+                <ul id="member_list_activities">
+                    <?php
+                        $q_activity = mysqli_query($con, "SELECT title_es, price, year(date) AS year, paid FROM member_activity, activity WHERE member = $r[id] AND activity = activity.id");
+                        while ($r_activity = mysqli_fetch_array($q_activity)){
+                            if ($r_activity['paid'] == 1){
+                                    echo "<li>$r_activity[title_es] ($r_activity[year])</li>\n";
+                                    $paid = $paid + intval($r_activity['price']);
+                                }
+                                else{
+                                    echo "<li>$r_activity[title_es] ($r_activity[year]) - <span style='color:#aa0000'>No pagado</span></li>\n";
+                                    $unpaid = $unpaid + intval($r_activity['price']);
+                                }
+                        }
+                    ?>
+                </ul>
+                <div id="activity_count">
+                    <hr/>
+                    Dinero aportado: <?php echo $paid;?> &euro;
+                    <?php
+                        if ($unpaid > 0)
+                            echo "<br/><span style='color:#aa0000'>Debe: $unpaid &euro;</span>"
+                    ?>
+                </div>
+            </div>
+            <div class="entry member_section" id="member_social">
+                <h3>Redes sociales</h3>
+                <ul>
+                    <?php
+                        if ($r['facebook'] == null)
+                            echo "<li style='text-decoration: line-through;'>Facebook</li>\n";
+                        else
+                            echo "<li><a href='$r[facebook]'>Facebook</a></li>\n";
+                        if ($r['twitter'] == null)
+                            echo "<li style='text-decoration: line-through;'>Twitter</li>\n";
+                        else
+                            echo "<li><a href='$r[twitter]'>Twitter</a></li>\n";
+                        if ($r['googleplus'] == null)
+                            echo "<li style='text-decoration: line-through;'>Google+</li>\n";
+                        else
+                            echo "<li><a href='$r[googleplus]'>Google+</a></li>\n";
+                    ?>
+                </ul>
+            </div>
+            <div class="entry member_section" id="member_intolerances">
+                <h3>Intolerancias alimenticias</h3>
+                <ul>
+                <?php
+                    $q_intolerance = mysqli_query($con, "SELECT element FROM intolerance WHERE member = $r[id];");
+                    if (mysqli_num_rows($q_intolerance) == 0)
+                        echo "<li>Ninguna</li>\n";
+                    else
+                        while ($r_intolerance = mysqli_fetch_array($q_intolerance))
+                            echo "<li>$r_intolerance[element]</li>\n";
+                ?>
+                </ul>
+            </div>
+            
+        </div>
+    </body>
+        
+        <?php }
+    }
 ?>

+ 205 - 205
www-admin/miembros/miembro.php

@@ -1,208 +1,208 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	$default_host = substr($http_host, 0, strpos($http_host, ':'));
-	include("../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
-		$id = mysqli_real_escape_string($con, $_GET['m']);
-		$q = mysqli_query($con, "SELECT * FROM member WHERE id = $id;");
-		if (mysqli_num_rows($q) == 0){
-			header("Location: /miembros/");
-			exit (-1);
-		}
-		else{
-			$r = mysqli_fetch_array($q); ?>
-		
+    $http_host = $_SERVER['HTTP_HOST'];
+    $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    include("../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+        $id = mysqli_real_escape_string($con, $_GET['m']);
+        $q = mysqli_query($con, "SELECT * FROM member WHERE id = $id;");
+        if (mysqli_num_rows($q) == 0){
+            header("Location: /miembros/");
+            exit (-1);
+        }
+        else{
+            $r = mysqli_fetch_array($q); ?>
+        
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Miembros - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/miembros.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/miembros.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="script.js"></script>
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body style="text-align:center;">
-		<?php include('../toolbar.php'); ?>
-		<div id='content'>
-			<div class="section">
-				<h3><?php echo "$r[name] <span style='font-style:italic;'>$r[alias]</span> $r[lname]";?></h3>
-				<table id="member">
-					<tr>
-						<td class="entry">
-							<h3>Datos personales</h4>
-							<p><span style="font-weight:bold;">Nombre: </span><?php echo $r['name']; ?></p>
-							<p><span style="font-weight:bold;">Primer apellido: </span><?php echo $r['lname']; ?></p>
-							<p><span style="font-weight:bold;">Segundo apellido: </span><?php echo $r['lname2']; ?></p>
-							<p><span style="font-weight:bold;">Alias: </span><?php echo $r['alias']; ?></p>
-							<br/>
-							<p><span style="font-weight:bold;">Fecha de nacimiento: </span>
-							<?php
-								$date = formatDate($r['bdate'], 'es');
-								$date = substr($date, 0, strlen($date) - 12);
-								$dStart = new DateTime($r['bdate']);
-								$dEnd  = new DateTime();
-								$dDiff = $dStart->diff($dEnd);
-								$age =  floor(($dDiff->days) / 365);
-								if ($age < 18)
-									$date = "$date (<span style='color:#aa0000'>$age a&ntilde;os - Menor de edad</span>)";
-								else
-									$date = "$date ($age a&ntilde;os)";
-								echo $date;
-							?>
-							</p>
-							<p><span style="font-weight:bold;">DNI: </span><?php echo $r['dni'];?></p>
-							<p><span style="font-weight:bold;">Direccion: </span><?php echo $r['address'];?></p>
-						</td>
-						<td class="entry">
-							<h3>En la cuadrilla</h3>
-							<p><span style="font-weight:bold;">Socio: </span>#<?php echo $r['id']; ?>
-							<p><span style="font-weight:bold;">Fecha de alta: </span>
-							<?php
-								$date = formatDate($r['jdate'], 'es');
-								$date = substr($date, 0, strlen($date) - 12);
-								echo $date;
-							?>
-							</p>
-							<p><span style="font-weight:bold;">Formulario: </span>
-								<?php
-									switch ($r['joined']){
-										case 'origin':
-											echo "Socio inicial";
-											break;
-										case 'phone':
-											echo "V&iacute;a m&oacute;vil";
-											break;
-										case 'oldweb':
-											echo "V&iacute;a web antigua";
-											break;
-										case 'web':
-											echo "V&iacute;a web";
-											break;
-										default:
-											echo "V&iacute;a hoja de inscripci&oacute;n";
-									}
-								?>
-							</p>
-							<p><span style="font-weight:bold;">Junta directiva: </span>
-							<?php
-								if ($r['board'] == 1)
-									echo "Si";
-								else
-									echo "No";
-							?>
-							</p>
-						</td>
-					</tr>
-					<tr>
-						<td class="entry">
-							<h3>Actividades</h3>
-							<ul id="member_list_days">
-								<?php
-									$paid = 0;
-									$unpaid = 0;
-									$q_year = mysqli_query($con, "SELECT year(date) AS year FROM member_day, festival_day WHERE member_day.day = festival_day.id AND member = $r[id] GROUP BY year(date) ORDER BY year(date)");
-									while ($r_year = mysqli_fetch_array($q_year)){
-										echo "<li>Fiestas $r_year[year]:\n";
-										$q_day = mysqli_query($con, "SELECT day(date) AS dat, price, paid FROM festival_day, member_day WHERE member_day.day = festival_day.id AND year(date) = $r_year[year] AND member = $r[id] ORDER BY date;");
-										echo "<ul>\n";
-										while ($r_day = mysqli_fetch_array($q_day)){
-											if ($r_day['paid'] == 1){
-												echo "<li>$r_day[dat]</li>\n";
-												$paid = $paid + intval($r_day['price']);
-											}
-											else{
-												echo "<li>$r_day[dat] - <span style='color:#aa0000'>No pagado</span></li>\n";
-												$unpaid = $unpaid + intval($r_day['price']);
-											}
-												
-										}
-										echo "</ul>\n";
-										echo "</li>\n";
-									}
-								?>
-							</ul>
-							<ul id="member_list_activities">
-								<?php
-									$q_activity = mysqli_query($con, "SELECT title_es, price, year(date) AS year, paid FROM member_activity, activity WHERE member = $r[id] AND activity = activity.id");
-									while ($r_activity = mysqli_fetch_array($q_activity)){
-										if ($r_activity['paid'] == 1){
-												echo "<li>$r_activity[title_es] ($r_activity[year])</li>\n";
-												$paid = $paid + intval($r_activity['price']);
-											}
-											else{
-												echo "<li>$r_activity[title_es] ($r_activity[year]) - <span style='color:#aa0000'>No pagado</span></li>\n";
-												$unpaid = $unpaid + intval($r_activity['price']);
-											}
-									}
-								?>
-							</ul>
-							<div id="activity_count">
-								<hr/>
-								Dinero aportado: <?php echo $paid;?> &euro;
-								<?php
-									if ($unpaid > 0)
-										echo "<br/><span style='color:#aa0000'>Debe: $unpaid &euro;</span>"
-								?>
-							</div>
-						</td>
-						<td class="entry">
-							<div>
-								<h3>Redes sociales</h3>
-								<ul>
-									<?php
-										if ($r['facebook'] == null)
-											echo "<li style='text-decoration: line-through;'>Facebook</li>\n";
-										else
-											echo "<li><a href='$r[facebook]'>Facebook</a></li>\n";
-										if ($r['twitter'] == null)
-											echo "<li style='text-decoration: line-through;'>Twitter</li>\n";
-										else
-											echo "<li><a href='$r[twitter]'>Twitter</a></li>\n";
-										if ($r['googleplus'] == null)
-											echo "<li style='text-decoration: line-through;'>Google+</li>\n";
-										else
-											echo "<li><a href='$r[googleplus]'>Google+</a></li>\n";
-									?>
-								</ul>
-							</div>
-							<br/><br/><hr/><br/><br/>
-							<div>
-								<h3>Intolerancias alimenticias</h3>
-								<ul>
-								<?php
-									$q_intolerance = mysqli_query($con, "SELECT element FROM intolerance WHERE member = $r[id];");
-									if (mysqli_num_rows($q_intolerance) == 0)
-										echo "<li>Ninguna</li>\n";
-									else
-										while ($r_intolerance = mysqli_fetch_array($q_intolerance))
-											echo "<li>$r_intolerance[element]</li>\n";
-								?>
-								</ul>
-							</div>
-						</td>
-					</tr>
-				</table>
-			</div>
-			<br/><br/>
-			<div class="section" id="member_action">
-				<input type="button" value="Editar"/>
-				<input type="button" value="Eliminar"/>
-				<input type="button" value="Decargar"/>
-			</div>
-		</div>
-	</body>
-		
-		<?php }
-	}
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Miembros - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/miembros.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/miembros.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="script.js"></script>
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body style="text-align:center;">
+        <?php include('../toolbar.php'); ?>
+        <div id='content'>
+            <div class="section">
+                <h3><?php echo "$r[name] <span style='font-style:italic;'>$r[alias]</span> $r[lname]";?></h3>
+                <table id="member">
+                    <tr>
+                        <td class="entry">
+                            <h3>Datos personales</h4>
+                            <p><span style="font-weight:bold;">Nombre: </span><?php echo $r['name']; ?></p>
+                            <p><span style="font-weight:bold;">Primer apellido: </span><?php echo $r['lname']; ?></p>
+                            <p><span style="font-weight:bold;">Segundo apellido: </span><?php echo $r['lname2']; ?></p>
+                            <p><span style="font-weight:bold;">Alias: </span><?php echo $r['alias']; ?></p>
+                            <br/>
+                            <p><span style="font-weight:bold;">Fecha de nacimiento: </span>
+                            <?php
+                                $date = formatDate($r['bdate'], 'es');
+                                $date = substr($date, 0, strlen($date) - 12);
+                                $dStart = new DateTime($r['bdate']);
+                                $dEnd  = new DateTime();
+                                $dDiff = $dStart->diff($dEnd);
+                                $age =  floor(($dDiff->days) / 365);
+                                if ($age < 18)
+                                    $date = "$date (<span style='color:#aa0000'>$age a&ntilde;os - Menor de edad</span>)";
+                                else
+                                    $date = "$date ($age a&ntilde;os)";
+                                echo $date;
+                            ?>
+                            </p>
+                            <p><span style="font-weight:bold;">DNI: </span><?php echo $r['dni'];?></p>
+                            <p><span style="font-weight:bold;">Direccion: </span><?php echo $r['address'];?></p>
+                        </td>
+                        <td class="entry">
+                            <h3>En la cuadrilla</h3>
+                            <p><span style="font-weight:bold;">Socio: </span>#<?php echo $r['id']; ?>
+                            <p><span style="font-weight:bold;">Fecha de alta: </span>
+                            <?php
+                                $date = formatDate($r['jdate'], 'es');
+                                $date = substr($date, 0, strlen($date) - 12);
+                                echo $date;
+                            ?>
+                            </p>
+                            <p><span style="font-weight:bold;">Formulario: </span>
+                                <?php
+                                    switch ($r['joined']){
+                                        case 'origin':
+                                            echo "Socio inicial";
+                                            break;
+                                        case 'phone':
+                                            echo "V&iacute;a m&oacute;vil";
+                                            break;
+                                        case 'oldweb':
+                                            echo "V&iacute;a web antigua";
+                                            break;
+                                        case 'web':
+                                            echo "V&iacute;a web";
+                                            break;
+                                        default:
+                                            echo "V&iacute;a hoja de inscripci&oacute;n";
+                                    }
+                                ?>
+                            </p>
+                            <p><span style="font-weight:bold;">Junta directiva: </span>
+                            <?php
+                                if ($r['board'] == 1)
+                                    echo "Si";
+                                else
+                                    echo "No";
+                            ?>
+                            </p>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td class="entry">
+                            <h3>Actividades</h3>
+                            <ul id="member_list_days">
+                                <?php
+                                    $paid = 0;
+                                    $unpaid = 0;
+                                    $q_year = mysqli_query($con, "SELECT year(date) AS year FROM member_day, festival_day WHERE member_day.day = festival_day.id AND member = $r[id] GROUP BY year(date) ORDER BY year(date)");
+                                    while ($r_year = mysqli_fetch_array($q_year)){
+                                        echo "<li>Fiestas $r_year[year]:\n";
+                                        $q_day = mysqli_query($con, "SELECT day(date) AS dat, price, paid FROM festival_day, member_day WHERE member_day.day = festival_day.id AND year(date) = $r_year[year] AND member = $r[id] ORDER BY date;");
+                                        echo "<ul>\n";
+                                        while ($r_day = mysqli_fetch_array($q_day)){
+                                            if ($r_day['paid'] == 1){
+                                                echo "<li>$r_day[dat]</li>\n";
+                                                $paid = $paid + intval($r_day['price']);
+                                            }
+                                            else{
+                                                echo "<li>$r_day[dat] - <span style='color:#aa0000'>No pagado</span></li>\n";
+                                                $unpaid = $unpaid + intval($r_day['price']);
+                                            }
+                                                
+                                        }
+                                        echo "</ul>\n";
+                                        echo "</li>\n";
+                                    }
+                                ?>
+                            </ul>
+                            <ul id="member_list_activities">
+                                <?php
+                                    $q_activity = mysqli_query($con, "SELECT title_es, price, year(date) AS year, paid FROM member_activity, activity WHERE member = $r[id] AND activity = activity.id");
+                                    while ($r_activity = mysqli_fetch_array($q_activity)){
+                                        if ($r_activity['paid'] == 1){
+                                                echo "<li>$r_activity[title_es] ($r_activity[year])</li>\n";
+                                                $paid = $paid + intval($r_activity['price']);
+                                            }
+                                            else{
+                                                echo "<li>$r_activity[title_es] ($r_activity[year]) - <span style='color:#aa0000'>No pagado</span></li>\n";
+                                                $unpaid = $unpaid + intval($r_activity['price']);
+                                            }
+                                    }
+                                ?>
+                            </ul>
+                            <div id="activity_count">
+                                <hr/>
+                                Dinero aportado: <?php echo $paid;?> &euro;
+                                <?php
+                                    if ($unpaid > 0)
+                                        echo "<br/><span style='color:#aa0000'>Debe: $unpaid &euro;</span>"
+                                ?>
+                            </div>
+                        </td>
+                        <td class="entry">
+                            <div>
+                                <h3>Redes sociales</h3>
+                                <ul>
+                                    <?php
+                                        if ($r['facebook'] == null)
+                                            echo "<li style='text-decoration: line-through;'>Facebook</li>\n";
+                                        else
+                                            echo "<li><a href='$r[facebook]'>Facebook</a></li>\n";
+                                        if ($r['twitter'] == null)
+                                            echo "<li style='text-decoration: line-through;'>Twitter</li>\n";
+                                        else
+                                            echo "<li><a href='$r[twitter]'>Twitter</a></li>\n";
+                                        if ($r['googleplus'] == null)
+                                            echo "<li style='text-decoration: line-through;'>Google+</li>\n";
+                                        else
+                                            echo "<li><a href='$r[googleplus]'>Google+</a></li>\n";
+                                    ?>
+                                </ul>
+                            </div>
+                            <br/><br/><hr/><br/><br/>
+                            <div>
+                                <h3>Intolerancias alimenticias</h3>
+                                <ul>
+                                <?php
+                                    $q_intolerance = mysqli_query($con, "SELECT element FROM intolerance WHERE member = $r[id];");
+                                    if (mysqli_num_rows($q_intolerance) == 0)
+                                        echo "<li>Ninguna</li>\n";
+                                    else
+                                        while ($r_intolerance = mysqli_fetch_array($q_intolerance))
+                                            echo "<li>$r_intolerance[element]</li>\n";
+                                ?>
+                                </ul>
+                            </div>
+                        </td>
+                    </tr>
+                </table>
+            </div>
+            <br/><br/>
+            <div class="section" id="member_action">
+                <input type="button" value="Editar"/>
+                <input type="button" value="Eliminar"/>
+                <input type="button" value="Decargar"/>
+            </div>
+        </div>
+    </body>
+        
+        <?php }
+    }
 ?>

+ 13 - 13
www-admin/miembros/moderate/index.php

@@ -1,15 +1,15 @@
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nuevo post - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-	</head>
-	<body>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nuevo post - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+    </head>
+    <body>
+    </body>
 </html>

+ 16 - 16
www-admin/miembros/script.js

@@ -1,18 +1,18 @@
 function populate_table(filter){
-	console.log("Filter: " + filter);
-	var table = document.getElementById("member_table");
-	for (var i = 1, row; row = table.rows[i]; i++) {
-		content = row.innerHTML;
-		content = content.substring(0, content.lastIndexOf('<td'));
-		var rex = /(<([^>]+)>)/ig;
-		content = content.replace(rex, "");
-		content = content.replace(" ", "");
-		filter = filter.replace(" ", "");
-		content = content.toLowerCase();
-		filter = filter.toLowerCase();
-		if (content.indexOf(filter) > -1)
-			row.style.display = 'table-row';
-		else
-			row.style.display = 'none';
-	}
+    console.log("Filter: " + filter);
+    var table = document.getElementById("member_table");
+    for (var i = 1, row; row = table.rows[i]; i++) {
+        content = row.innerHTML;
+        content = content.substring(0, content.lastIndexOf('<td'));
+        var rex = /(<([^>]+)>)/ig;
+        content = content.replace(rex, "");
+        content = content.replace(" ", "");
+        filter = filter.replace(" ", "");
+        content = content.toLowerCase();
+        filter = filter.toLowerCase();
+        if (content.indexOf(filter) > -1)
+            row.style.display = 'table-row';
+        else
+            row.style.display = 'none';
+    }
 }

+ 13 - 13
www-admin/miembros/translate/index.php

@@ -1,15 +1,15 @@
 <html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Nuevo post - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-	</head>
-	<body>
-	</body>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Nuevo post - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
+    </head>
+    <body>
+    </body>
 </html>

+ 7 - 0
www-admin/salir/index.php

@@ -0,0 +1,7 @@
+<?php
+    $_SESSION['id'] = $r['_'];
+    $_SESSION['salt'] = $r['_'];
+    $_SESSION['name'] = $r['_'];
+    session_destroy();
+    header("Location: /index.php");
+?>

+ 130 - 130
www-admin/script/blog.js

@@ -1,147 +1,147 @@
 function validate_post(){
-	var text_es = document.getElementById('text_es').value;
-	var text_eu = document.getElementById('text_eu').value;
-	var text_en = document.getElementById('text_en').value;
-	var title_es = document.getElementById('title_es').value;
-	var title_eu = document.getElementById('title_eu').value;
-	var title_en = document.getElementById('title_en').value;
-	result = true;
-	
-	//Spanish fields empty
-	if (title_es.length < 1){
-		result = false;
-		alert("Introduce un titulo en castellano");
-		return false;
-	}
-	if (text_es.length < 1){
-		result = false;
-		alert("Introduce un texto en castellano");
-		return false;
-	}
-	
-	//Titles without texts
-	if (title_eu.length > 0 && text_eu.length < 1){
-		result = false;
-		alert("Introduce un texto o borra el titulo en euskera")
-		return false;
-	}
-	if (title_en.length > 0 && text_en.length < 1){
-		result = false;
-		alert("Introduce un texto o borra el titulo en ingles")
-		return false;
-	}
-	
-	//Text without titles
-	if (text_eu.length > 0 && title_eu.length < 1){
-		result = false;
-		alert("Introduce un titulo o borra el texto en euskera")
-		return false;
-	}
-	if (text_en.length > 0 && title_en.length < 1){
-		result = false;
-		alert("Introduce un titulo o borra el texto en ingles")
-		return false;
-	}
-	return true;
+    var text_es = document.getElementById('text_es').value;
+    var text_eu = document.getElementById('text_eu').value;
+    var text_en = document.getElementById('text_en').value;
+    var title_es = document.getElementById('title_es').value;
+    var title_eu = document.getElementById('title_eu').value;
+    var title_en = document.getElementById('title_en').value;
+    result = true;
+    
+    //Spanish fields empty
+    if (title_es.length < 1){
+        result = false;
+        alert("Introduce un titulo en castellano");
+        return false;
+    }
+    if (text_es.length < 1){
+        result = false;
+        alert("Introduce un texto en castellano");
+        return false;
+    }
+    
+    //Titles without texts
+    if (title_eu.length > 0 && text_eu.length < 1){
+        result = false;
+        alert("Introduce un texto o borra el titulo en euskera")
+        return false;
+    }
+    if (title_en.length > 0 && text_en.length < 1){
+        result = false;
+        alert("Introduce un texto o borra el titulo en ingles")
+        return false;
+    }
+    
+    //Text without titles
+    if (text_eu.length > 0 && title_eu.length < 1){
+        result = false;
+        alert("Introduce un titulo o borra el texto en euskera")
+        return false;
+    }
+    if (text_en.length > 0 && title_en.length < 1){
+        result = false;
+        alert("Introduce un titulo o borra el texto en ingles")
+        return false;
+    }
+    return true;
 }
 
 
 
 function formatText(textarea, format){
-	
-	var text = textarea.value;
-	var selectedText= window.getSelection().toString();
-	event.preventDefault();
-	//IE
-	if (document.selection != undefined){
-		textarea.focus();
-		var selection = document.selection.createRange();
-		selectedText = selection.text;
-	}
-	
-	//Mozilla
-	else if (textarea.selectionStart != undefined){
-		var startPos = textarea.selectionStart;
-		var endPos = textarea.selectionEnd;
-		selectedText = textarea.value.substring(startPos, endPos);
-	}
-	
-	var replace;
-	switch (format){
-		case "italic":
-			replace = "<span style='font-style:italic;'>" + selectedText + "</span>";
-			break;
-		case "bold":
-			replace = "<span style='font-weight:bold;'>" + selectedText + "</span>";
-			break;
-		case "underline":
-			replace = "<span style='text-decoration:underline;'>" + selectedText + "</span>";
-			break;
-		case "stroke":
-			replace = "<span style='text-decoration:line-through;'>" + selectedText + "</span>";
-			break;
-		case "link":
-			replace = "<a href='" + selectedText + "'>" + selectedText + "</a>";
-			break;
-		case "color-red":
-			replace = "<span style='color:#f00;'>" + selectedText + "</span>";
-			break;
-		case "color-green":
-			replace = "<span style='color:#0f0;'>" + selectedText + "</span>";
-			break;
-		case "color-blue":
-			replace = "<span style='color:#00f;'>" + selectedText + "</span>";
-			break;
-		default:
-			replace = selectedText;
-	}
-	
-	if (selectedText.length  >0 && text != replace){
-		text = text.replace(selectedText, replace);
-		textarea.value = text;
-	}
+    
+    var text = textarea.value;
+    var selectedText= window.getSelection().toString();
+    event.preventDefault();
+    //IE
+    if (document.selection != undefined){
+        textarea.focus();
+        var selection = document.selection.createRange();
+        selectedText = selection.text;
+    }
+    
+    //Mozilla
+    else if (textarea.selectionStart != undefined){
+        var startPos = textarea.selectionStart;
+        var endPos = textarea.selectionEnd;
+        selectedText = textarea.value.substring(startPos, endPos);
+    }
+    
+    var replace;
+    switch (format){
+        case "italic":
+            replace = "<span style='font-style:italic;'>" + selectedText + "</span>";
+            break;
+        case "bold":
+            replace = "<span style='font-weight:bold;'>" + selectedText + "</span>";
+            break;
+        case "underline":
+            replace = "<span style='text-decoration:underline;'>" + selectedText + "</span>";
+            break;
+        case "stroke":
+            replace = "<span style='text-decoration:line-through;'>" + selectedText + "</span>";
+            break;
+        case "link":
+            replace = "<a href='" + selectedText + "'>" + selectedText + "</a>";
+            break;
+        case "color-red":
+            replace = "<span style='color:#f00;'>" + selectedText + "</span>";
+            break;
+        case "color-green":
+            replace = "<span style='color:#0f0;'>" + selectedText + "</span>";
+            break;
+        case "color-blue":
+            replace = "<span style='color:#00f;'>" + selectedText + "</span>";
+            break;
+        default:
+            replace = selectedText;
+    }
+    
+    if (selectedText.length  >0 && text != replace){
+        text = text.replace(selectedText, replace);
+        textarea.value = text;
+    }
 }
 
 function preview_image(source, target) {
-	var reader = new FileReader();
-	reader.readAsDataURL(source.files[0]);
+    var reader = new FileReader();
+    reader.readAsDataURL(source.files[0]);
 
-	reader.onload = function (reader_event) {
-		target.src = reader_event.target.result;
-		target.style.border = "2px solid black";
-		target.style.marginTop = 10 + "px";
-		target.style.marginBottom = 10 + "px";
-		target.style.display = "inline";
-	};
+    reader.onload = function (reader_event) {
+        target.src = reader_event.target.result;
+        target.style.border = "2px solid black";
+        target.style.marginTop = 10 + "px";
+        target.style.marginBottom = 10 + "px";
+        target.style.display = "inline";
+    };
 };
 
 function delete_post(id, title){
-	if (confirm("Seguro que deseas borrar el post '" + title + "'? Esta accion es irreversible.")){
-		//window.location.href = "/blog/delete/delete.php?p=" + id;
-		
-		var xmlhttp;
-		if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
-			xmlhttp=new XMLHttpRequest();
-		}
-		else{// code for IE6, IE5
-			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
-		}
-		xmlhttp.onreadystatechange=function(){
-			if (xmlhttp.readyState==4 && xmlhttp.status==200){
-				//document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
-				location.reload();
-			}
-		}
-		xmlhttp.open("GET","/blog/delete/delete.php?p=" + id, true);
-		xmlhttp.send();
-		
-		//location.reload();
-	}
+    if (confirm("Seguro que deseas borrar el post '" + title + "'? Esta accion es irreversible.")){
+        //window.location.href = "/blog/delete/delete.php?p=" + id;
+        
+        var xmlhttp;
+        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
+            xmlhttp=new XMLHttpRequest();
+        }
+        else{// code for IE6, IE5
+            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
+        }
+        xmlhttp.onreadystatechange=function(){
+            if (xmlhttp.readyState==4 && xmlhttp.status==200){
+                //document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
+                location.reload();
+            }
+        }
+        xmlhttp.open("GET","/blog/delete/delete.php?p=" + id, true);
+        xmlhttp.send();
+        
+        //location.reload();
+    }
 }
 
 function delete_image(id, target, button){
-	target.src = "/img/misc/alpha.png";
-	target.style.display = "none";
-	button.style.display = "none";
-	document.getElementById("delete_imamge_" + id).value = "yes";
+    target.src = "/img/misc/alpha.png";
+    target.style.display = "none";
+    button.style.display = "none";
+    document.getElementById("delete_imamge_" + id).value = "yes";
 }

+ 27 - 27
www-admin/script/ui.js

@@ -1,33 +1,33 @@
 function showToolbar(toolbar, from){
-	if(document.getElementById('toolbar_' + toolbar).style.display == 'block'){
-		document.getElementById('toolbar_' + toolbar).style.display = 'none';
-		from.style.backgroundColor = '#000000';
-	}
-	else{
-		var toolbars = document.getElementsByClassName('secondary_toolbar');
-		for (var i = 0; i < toolbars.length; i ++)
-				toolbars.item(i).style.display = 'none';
-		var sections = document.getElementsByClassName('toolbar_section');
-		for (var j = 0; j < sections.length; j ++)
-				sections.item(j).style.backgroundColor = '#000000';
-		
-		document.getElementById('toolbar_' + toolbar).style.display = 'block';
-		from.style.backgroundColor = '#333333';
-	}
+    if(document.getElementById('toolbar_' + toolbar).style.display == 'block'){
+        document.getElementById('toolbar_' + toolbar).style.display = 'none';
+        from.style.backgroundColor = '#000000';
+    }
+    else{
+        var toolbars = document.getElementsByClassName('secondary_toolbar');
+        for (var i = 0; i < toolbars.length; i ++)
+                toolbars.item(i).style.display = 'none';
+        var sections = document.getElementsByClassName('toolbar_section');
+        for (var j = 0; j < sections.length; j ++)
+                sections.item(j).style.backgroundColor = '#000000';
+        
+        document.getElementById('toolbar_' + toolbar).style.display = 'block';
+        from.style.backgroundColor = '#333333';
+    }
 }
 
 
 function showLanguage(lang){
-	switch (lang){
-		case 'es':
-			document.getElementById('content_lang_es').style.display = 'block';
-			document.getElementById('content_lang_eu').style.display = 'none';
-			document.getElementById('content_lang_en').style.display = 'none';
-			document.getElementById('lang_tab_es').classList.add("lang_tabs_active");
-			document.getElementById('lang_tab_eu').classList.remove("lang_tabs_active");
-			document.getElementById('lang_tab_en').classList.remove("lang_tabs_active");
-			break;
-		case 'eu':
+    switch (lang){
+        case 'es':
+            document.getElementById('content_lang_es').style.display = 'block';
+            document.getElementById('content_lang_eu').style.display = 'none';
+            document.getElementById('content_lang_en').style.display = 'none';
+            document.getElementById('lang_tab_es').classList.add("lang_tabs_active");
+            document.getElementById('lang_tab_eu').classList.remove("lang_tabs_active");
+            document.getElementById('lang_tab_en').classList.remove("lang_tabs_active");
+            break;
+        case 'eu':
                         document.getElementById('content_lang_es').style.display = 'none';
                         document.getElementById('content_lang_eu').style.display = 'block';
                         document.getElementById('content_lang_en').style.display = 'none';
@@ -35,13 +35,13 @@ function showLanguage(lang){
                         document.getElementById('lang_tab_eu').classList.add("lang_tabs_active");
                         document.getElementById('lang_tab_en').classList.remove("lang_tabs_active");
                         break;
-		case 'en':
+        case 'en':
                         document.getElementById('content_lang_es').style.display = 'none';
                         document.getElementById('content_lang_eu').style.display = 'none';
                         document.getElementById('content_lang_en').style.display = 'block';
                         document.getElementById('lang_tab_es').classList.remove("lang_tabs_active");
                         document.getElementById('lang_tab_eu').classList.remove("lang_tabs_active");
                         document.getElementById('lang_tab_en').classList.add("lang_tabs_active");
-	}
+    }
 }
 

+ 120 - 119
www-admin/toolbar.php

@@ -1,135 +1,136 @@
 <div id="toolbar">
-	<table>
-		<tr>
-			<td>
-				<img src="/img/misc/logo.png"/><span style='font-weight:normal;font-style:italic;font-size:90%;'><?php echo $_SESSION['name']; ?></span>
-			</td>
-			<td>
-				<a href="/" class="pointer toolbar_section">Inicio</a>
-			</td>
-			<td class="pointer toolbar_section" onClick="showToolbar('blog', this);">
-				Blog
-			</td>
-			<td class="pointer toolbar_section" onClick="showToolbar('actividades', this);">
-				<span class="pointer">Actividades</span>
-			</td>
-			<td class="pointer toolbar_section" onClick="showToolbar('galeria', this);">
-				<span class="pointer">Galer&iacute;a</span>
-			</td>
-			<td class="pointer toolbar_section" onClick="showToolbar('fiestas', this);">
-				<span class="pointer">Fiestas</span>
-			</td>
-			<td class="pointer toolbar_section" onClick="showToolbar('miembros', this);">
-				<span class="pointer">Miembros</span>
-			</td>
-			<td class="pointer toolbar_section" onClick="showToolbar('estadisticas', this);">
-				<span class="pointer">Estad&iacute;sticas</span>
-			</td>
-			<td class="pointer toolbar_section" onClick="showToolbar('ajustes', this);">
-				<span class="pointer">Ajustes</span>
-			</td>
-		</tr>
-	</table>
+    <table>
+        <tr>
+            <td>
+                <img src="<?=$server?>/img/misc/logo.png"/>
+                <span style='font-weight:normal;font-style:italic;font-size:90%;'><?=$_SESSION['name']?></span>
+            </td>
+            <td>
+                <a href="<?=$server?>/" class="pointer toolbar_section">Inicio</a>
+            </td>
+            <td class="pointer toolbar_section" onClick="showToolbar('blog', this);">
+                <span class="pointer">Blog</span>
+            </td>
+            <td class="pointer toolbar_section" onClick="showToolbar('actividades', this);">
+                <span class="pointer">Actividades</span>
+            </td>
+            <td class="pointer toolbar_section" onClick="showToolbar('galeria', this);">
+                <span class="pointer">Galer&iacute;a</span>
+            </td>
+            <td class="pointer toolbar_section" onClick="showToolbar('fiestas', this);">
+                <span class="pointer">Fiestas</span>
+            </td>
+            <td class="pointer toolbar_section" onClick="showToolbar('miembros', this);">
+                <span class="pointer">Miembros</span>
+            </td>
+            <td class="pointer toolbar_section" onClick="showToolbar('estadisticas', this);">
+                <span class="pointer">Estad&iacute;sticas</span>
+            </td>
+            <td class="pointer toolbar_section" onClick="showToolbar('ajustes', this);">
+                <span class="pointer">Ajustes</span>
+            </td>
+        </tr>
+    </table>
 </div>
 <div class="secondary_toolbar" id="toolbar_blog">
-	<table>
-		<tr>
-			<td>
-				<a href="http://<?php echo $http_host; ?>/blog/add/">Nuevo post</a>
-			</td>
-			<td>
-				<a href="http://<?php echo $http_host; ?>/blog/">Gestionar posts</a>
-			</td>
-		</tr>
-	</table>
+    <table>
+        <tr>
+            <td>
+                <a href="<?=$server?>/blog/add/">Nuevo post</a>
+            </td>
+            <td>
+                <a href="<?=$server?>/blog/">Gestionar posts</a>
+            </td>
+        </tr>
+    </table>
 </div>
 <div class="secondary_toolbar" id="toolbar_actividades">
-	<table>
-		<tr>
-			<td>
-				<a href="http://<?php echo $http_host; ?>/actividades/add/">Nueva actividad</a>
-			</td>
-			<td>
-				<a href="http://<?php echo $http_host; ?>/actividades/">Gestionar actividades</a>
-			</td>
-		</tr>
-	</table>
+    <table>
+        <tr>
+            <td>
+                <a href="<?=$server?>/actividades/add/">Nueva actividad</a>
+            </td>
+            <td>
+                <a href="<?=$server?>/actividades/">Gestionar actividades</a>
+            </td>
+        </tr>
+    </table>
 </div>
 <div class="secondary_toolbar" id="toolbar_galeria">
-	<table>
-		<tr>
-			<td>
-				<a href="//">Crear album</a>
-			</td>
-			<td>
-				<a href="//">Gestionar albums</a>
-			</td>
-			<td>
-				<a href="//">Subir fotos</a>
-			</td>
-			<td>
-				<a href="//">Moderar comentarios</a>
-			</td>
-			<td>
-				<a href="//">Traducir galer&iacute;a</a>
-			</td>
-		</tr>
-	</table>
+    <table>
+        <tr>
+            <td>
+                <a href="<?=$server?>/galeria/add/">Crear album</a>
+            </td>
+            <td>
+                <a href="<?=$server?>/galeria/">Gestionar albums</a>
+            </td>
+            <td>
+                <a href="<?=$server?>/galeria/upload/">Subir fotos</a>
+            </td>
+            <td>
+                <a href="<?=$server?>/galeria/moderate/">Moderar comentarios</a>
+            </td>
+            <td>
+                <a href="<?=$server?>/galeria/translate/">Traducir galer&iacute;a</a>
+            </td>
+        </tr>
+    </table>
 </div>
 <div class="secondary_toolbar" id="toolbar_fiestas">
-	<table>
-		<tr>
-			<td>
-				<a href="//">Gestionar precios</a>
-			</td>
-			<td>
-				<a href="//">Gestionar programa</a>
-			</td>
-		</tr>
-	</table>
+    <table>
+        <tr>
+            <td>
+                <a href='<?=$server?>/lablanca/'>Preparar las fiestas</a>
+            </td>
+            <td>
+                <a href='<?=$server?>/lablanca/prices.php'>Gestionar precios</a>
+            </td>
+            <td>
+                <a href='<?=$server?>/lablanca/schedule.php'>Gestionar programa</a>
+            </td>
+        </tr>
+    </table>
 </div>
 <div class="secondary_toolbar" id="toolbar_miembros">
-	<table>
-		<tr>
-			<td>
-				<a href="//">Consultar</a>
-			</td>
-			<td>
-				<a href="//">A&ntilde;adir miembro</a>
-			</td>
-			<td>
-				<a href="//">A&ntilde;adir miembros en lote</a>
-			</td>
-		</tr>
-	</table>
+    <table>
+        <tr>
+            <td>
+                <a href='<?=$server?>/miembros/'>Consultar y buscar</a>
+            </td>
+            <td>
+                <a href='<?=$server?>/miembros/add/'>A&ntilde;adir miembros</a>
+            </td>
+        </tr>
+    </table>
 </div>
 <div class="secondary_toolbar" id="toolbar_estadisticas">
-	<table>
-		<tr>
-			<td>
-				<a href="//">Web</a>
-			</td>
-			<td>
-				<a href="//">Apps</a>
-			</td>
-			<td>
-				<a href="//">Miembros</a>
-			</td>
-		</tr>
-	</table>
+    <table>
+        <tr>
+            <td>
+                <a href='<?=$server?>/estadisticas/web/'>Estadisticas Web</a>
+            </td>
+            <td>
+                <a href='<?=$server?>/estadisticas/app/'>Estadisticas Apps</a>
+            </td>
+            <td>
+                <a href='<?=$server?>/estadisticas/miembros/'>Estadisticas miembros</a>
+            </td>
+        </tr>
+    </table>
 </div>
 <div class="secondary_toolbar" id="toolbar_ajustes">
-	<table>
-		<tr>
-			<td>
-				<a href="//">Cambiar ajustes</a>
-			</td>
-			<td>
-				<a href="//">Gestionar usuarios</a>
-			</td>
-			<td>
-				<a href="//">Salir</a>
-			</td>
-		</tr>
-	</table>
+    <table>
+        <tr>
+            <td>
+                <a href='<?=$server?>/settings/'Ajustes</a>
+            </td>
+            <td>
+                <a href='<?=$server?>/usuarios/'>Gestionar usuarios</a>
+            </td>
+            <td>
+                <a href='<?=$server?>/salir/'>Salir</a>
+            </td>
+        </tr>
+    </table>
 </div>

+ 33 - 0
www-admin/usuarios/index.php

@@ -0,0 +1,33 @@
+<?php
+    $server = get_protocol() . $_SERVER['HTTP_HOST'];
+    $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    include("../functions.php");
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+?>
+<html>
+    <head>
+        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Gasteizko Margolariak - Administracion</title>
+        <!-- CSS files -->
+        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+        <link rel="stylesheet" type="text/css" href="/css/main.css"/>
+        <!-- CSS for mobile version -->
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/main.css"/>
+        <!-- Script files -->
+        <script type="text/javascript" src="/script/ui.js"></script>
+    </head>
+    <body>
+        <?php include('../toolbar.php'); ?>
+        <div id='content'>
+        
+        </div>
+    </body>
+</html>
+<?php } ?>

+ 9 - 2
www/.htaccess

@@ -30,6 +30,8 @@ RewriteRule ^blog/([0-9]+)/$ /blog/index.php?o=$1 [NC]
 
 RewriteRule ^lablanca/([0-9]+)$ /lablanca/index.php?year=$1 [NC]
 
+RewriteRule ^archivo/([A-Z\-a-z0-9]{3,}+)$ /archivo/index.php?file=$1 [NC]
+RewriteRule ^archivo/([A-Z\-a-z0-9]{3,}+)/$ /archivo/index.php?file=$1 [NC]
 
 RewriteRule ^actividades/search/([A-Za-z0-9]+)/([A-Za-z0-9]+)$ /actividades/buscar.php?where=$1&query=$2 [NC]
 RewriteRule ^actividades/search/([A-Za-z0-9]+)/([A-Za-z0-9]+)/$ /actividades/buscar.php?where=$1&query=$2 [NC]
@@ -48,14 +50,19 @@ RewriteRule ^galeria/([A-Z\-a-z0-9{3,}]+)/$ /galeria/album.php?perm=$1 [NC]
 RewriteRule ^galeria/([A-Z\-a-z0-9{3,}]+)/([A-Z\-a-z0-9{3,}]+)$ /galeria/photo.php?album=$2&perm=$1 [NC]
 RewriteRule ^galeria/([A-Z\-a-z0-9{3,}]+)/([A-Z\-a-z0-9{3,}]+)/$ /galeria/photo.php?album=$2&perm=$1 [NC]
 
+RewriteRule ^traducir/eu$ /traducir/index.php?l=eu [NC]
+RewriteRule ^traducir/eu/$ /traducir/index.php?l=eu [NC]
+RewriteRule ^traducir/en$ /traducir/index.php?l=en [NC]
+RewriteRule ^traducir/en/$ /traducir/index.php?l=en [NC]
+
 #API redirections
 #TODO: This changes the url in the browser
 RewriteRule ^API/V([{0-9}]+)/help/([A-Z\-a-z0-9{3,}]+)$ /API/V$1/help/$2.php [NC,QSA,L]
 RewriteRule ^API/V([{0-9}]+)/help/([A-Z\-a-z0-9{3,}]+)/$ /API/V$1/help/$2.php [L,NC]
 
 #Force https TODO
-#RewriteCond %{HTTPS} !=on
-#RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
+RewriteCond %{HTTPS} !=on
+RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
 
 # BEGIN Cache-Control Headers
 <IfModule mod_expires.c>

+ 308 - 308
www/API/v1/comment.php

@@ -1,311 +1,311 @@
 <?php
-	// Gasteizko Margolariak API v1 //
-	
-	//Posible comment target
-	define('TARGET_PHOTO', 'photo');
-	define('TARGET_POST', 'post');
-	define('TARGET_ACTIVITY', 'activity');
-	
-	//Default target
-	define('DEF_TARGET', TARGET_ALL);
-		
-	//$_GET valid parameters
-	define('GET_CLIENT', 'client');
-	define('GET_USER', 'user');
-	define('GET_TARGET', 'target');
-	define('GET_ID', 'id');
-	define('GET_PERMALINK', 'permalink');
-	define('GET_TEXT', 'text');
-	define('GET_USERNAME', 'username');
-	
-	/****************************************************
-	* This function is called from almost everywhere at *
-	* the beggining of the page. It initializes the     *
-	* session variables, connect to the db, enabling    *
-	* the variable $con for futher use everywhere in    *
-	* the php code, and populates the arrays $user      *
-	* and $permission, with info about the user.        *
-	*                                                   *
-	* @return: (db connection): The connection handler. *
-	****************************************************/
-	function startdb(){
-		//Include the db configuration file. It's somehow like this
-		/*
-		<?php
-			$host = 'XXXX';
-			$db_name = 'XXXX';
-			$username_ro = 'XXXX';
-			$username_rw = 'XXXX';
-			$pass_ro = 'XXXX';
-			$pass_rw = 'XXXX';
-		?>
-		*/
-		include('../../.htpasswd');
-		
-		//Connect to to database
-		$con = mysqli_connect($host, $username_rw, $pass_rw, $db_name);
-		
-		//Set encoding options
-		mysqli_set_charset($con, 'utf-8');
-		header('Content-Type: text/html; charset=utf8');
-		mysqli_query($con, 'SET NAMES utf8;');
-		
-		//Return the db connection
-		return $con;
-	}
-	
-	//Connect to the database
-	$con = startdb('rw');
-	
-	//Get data from URL
-	$client = mysqli_real_escape_string($con, $_GET[GET_CLIENT]);
-	$user = mysqli_real_escape_string($con, $_GET[GET_USER]);
-	$target = strtolower(mysqli_real_escape_string($con, $_GET[GET_TARGET]));
-	$id = strtolower(mysqli_real_escape_string($con, $_GET[GET_ID]));
-	$permalink = strtolower(mysqli_real_escape_string($con, $_GET[GET_PERMALINK]));
-	$ink = strtolower(mysqli_real_escape_string($con, $_GET[GET_PERMALINK]));
-	$permalink = strtolower(mysqli_real_escape_string($con, $_GET[GET_PERMALINK]));
-	$username = mysqli_real_escape_string($con, $_GET[GET_USERNAME]);
-	$text = mysqli_real_escape_string($con, $_GET[GET_TEXT]);
-	
-	//Validate data
-	if (strlen($client) < 1){
-		//Bad request
-		http_response_code(400);
-		exit();
-	}
-	if (strlen($user) < 1){
-		$user = '';
-	}
-	if (strlen($target) < 1){
-		//Bad request
-		http_response_code(400);
-		exit();
-	}
-	if ($target != TARGET_PHOTO && $target != TARGET_POST && $target != TARGET_ACTIVITY){
-		//Bad request
-		http_response_code(400);
-		exit();
-	}
-	if (strlen($username) < 1){
-		//Bad request
-		http_response_code(400);
-		exit();
-	}
-	
-	
-	//Check id and/or permalink. Several cases:
-	
-	//1st case: id and permalink empty: Error.
-	if (strlen($id) < 1 && strlen($permalink) < 1){
-		//Bad request
-		http_response_code(400);
-		exit();
-	}
-	
-	//2nd case: Comment for post, permalink and no id.
-	elseif ($target == TARGET_POST && strlen($id) < 1 && strlen($permalink) >= 1){
-	
-		//Check if post exists...
-		$q = mysqli_query($con, "SELECT id, comments FROM post WHERE visible = 1 AND permalink = '$permalink';");
-		if (mysqli_num_rows($q) == 0){
-			//Bad request
-			http_response_code(400);
-			exit();
-		}
-		else{
-		
-			//... and if it does, check if can be commented.
-			$r = mysqli_fetch_array($q);
-			$item_id = $r['id'];
-			if ($r['comments'] != 1){
-				//'Forbidden' status code
-				http_response_code(403);
-				exit();
-			}
-		}
-	}
-	
-	//3rd case: Comment for post, id and no permalink.
-	elseif ($target == TARGET_POST && strlen($id) >= 1 && strlen($permalink) < 1){
-	
-		//Check if post exists...
-		$q = mysqli_query($con, "SELECT id, comments FROM post WHERE visible = 1 AND id = $id;");
-		if (mysqli_num_rows($q) == 0){
-			//Bad request
-			http_response_code(400);
-			exit();
-		}
-		else{
-		
-			//... and if it does, check if can be commented.
-			$r = mysqli_fetch_array($q);
-			$item_id = $r['id'];
-			if ($r['comments'] != 1){
-				//'Forbidden' status code
-				http_response_code(403);
-				exit();
-			}
-		}
-	}
-	
-	//4th case: Comment for post, permalink and id.
-	elseif ($target == TARGET_POST && strlen($id) >= 1 && strlen($permalink) >= 1){
-	
-		//Check if post exists...
-		$q = mysqli_query($con, "SELECT id, comments FROM post WHERE visible = 1 AND permalink = '$permalink' AND id = $id ;");
-		if (mysqli_num_rows($q) == 0){
-			//Bad request
-			http_response_code(400);
-			exit();
-		}
-		else{
-		
-			//... and if it does, check if can be commented.
-			$r = mysqli_fetch_array($q);
-			$item_id = $r['id'];
-			if ($r['comments'] != 1){
-				//'Forbidden' status code
-				http_response_code(403);
-				exit();
-			}
-		}
-	}
-	
-	//5th case: Comment for photo, permalink and no id.
-	elseif ($target == TARGET_PHOTO && strlen($id) < 1 && strlen($permalink) >= 1){
-	
-		//Check if photo exists.
-		$q = mysqli_query($con, "SELECT id FROM photo WHERE approved = 1 AND permalink = '$permalink';");
-		if (mysqli_num_rows($q) == 0){
-			//Bad request
-			http_response_code(400);
-			exit();
-		}
-		else{
-			$item_id = $r['id'];
-		}
-	}
-	
-	//6th case: Comment for photo, id and no permalink.
-	elseif ($target == TARGET_PHOTO && strlen($id) >= 1 && strlen($permalink) < 1){
-	
-		//Check if photo exists.
-		$q = mysqli_query($con, "SELECT id FROM photo WHERE approved = 1 AND id = $id;");
-		if (mysqli_num_rows($q) == 0){
-			//Bad request
-			http_response_code(400);
-			exit();
-		}
-		else{
-			$item_id = $r['id'];
-		}
-	}
-	
-	//7th case: Comment for photo, permalink and id.
-	elseif ($target == TARGET_PHOTO && strlen($id) >= 1 && strlen($permalink) >= 1){
-	
-		//Check if photo exists.
-		$q = mysqli_query($con, "SELECT id FROM photo WHERE approved = 1 AND permalink = '$permalink' AND id = $id;");
-		if (mysqli_num_rows($q) == 0){
-			//Bad request
-			http_response_code(400);
-			exit();
-		}
-		else{
-			$item_id = $r['id'];
-		}
-	}
-	
-	//8nd case: Comment for activity, permalink and no id.
-	elseif ($target == TARGET_ACTIVITY && strlen($id) < 1 && strlen($permalink) >= 1){
-	
-		//Check if activity exists...
-		$q = mysqli_query($con, "SELECT id, comments FROM activity WHERE visible = 1 AND permalink = '$permalink';");
-		if (mysqli_num_rows($q) == 0){
-			//Bad request
-			http_response_code(400);
-			exit();
-		}
-		else{
-		
-			//... and if it does, check if can be commented.
-			$r = mysqli_fetch_array($q);
-			$item_id = $r['id'];
-			if ($r['comments'] != 1){
-				//'Forbidden' status code
-				http_response_code(403);
-				exit();
-			}
-		}
-	}
-	
-	//9rd case: Comment for activity, id and no permalink.
-	elseif ($target == TARGET_ACTIVITY && strlen($id) >= 1 && strlen($permalink) < 1){
-	
-		//Check if activity exists...
-		$q = mysqli_query($con, "SELECT id, comments FROM activity WHERE visible = 1 AND id = $id;");
-		if (mysqli_num_rows($q) == 0){
-			//Bad request
-			http_response_code(400);
-			exit();
-		}
-		else{
-		
-			//... and if it does, check if can be commented.
-			$r = mysqli_fetch_array($q);
-			$item_id = $r['id'];
-			if ($r['comments'] != 1){
-				//'Forbidden' status code
-				http_response_code(403);
-				exit();
-			}
-		}
-	}
-	
-	//10th case: Comment for activity, permalink and id.
-	elseif ($target == TARGET_ACTIVITY && strlen($id) >= 1 && strlen($permalink) >= 1){
-	
-		//Check if activity exists...
-		$q = mysqli_query($con, "SELECT id, comments FROM activity WHERE visible = 1 AND permalink = '$permalink' AND id = $id ;");
-		if (mysqli_num_rows($q) == 0){
-			//Bad request
-			http_response_code(400);
-			exit();
-		}
-		else{
-		
-			//... and if it does, check if can be commented.
-			$r = mysqli_fetch_array($q);
-			$item_id = $r['id'];
-			if ($r['comments'] != 1){
-				//'Forbidden' status code
-				http_response_code(403);
-				exit();
-			}
-		}
-	}
-	
-	//If code gets here, there were no errors. Build query.
-	$query = "INSERT INTO ";
-	$section = "";
-	switch ($target){
-		case TARGET_POST:
-			$query = $query . "post_comment (post";
-			$section = "blog";
-			break;
-		case TARGET_PHOTO:
-			$query = $query . "photo_comment (photo";
-			$section = "gallery";
-			break;
-		case TARGET_ACTIVITY:
-			$query = $query . "activity_comment (activity";
-			$section = "activity";
-			break;
-	}
-	$query = $query . ", text, username, app) VALUES ($item_id, \"$text\", \"$username\", \"client\");";
-	//echo($query);
-	mysqli_query($con, $query);
-	mysqli_query($con, "UPDATE version SET version = version + 1 WHERE section = '$section';");
+    // Gasteizko Margolariak API v1 //
+    
+    //Posible comment target
+    define('TARGET_PHOTO', 'photo');
+    define('TARGET_POST', 'post');
+    define('TARGET_ACTIVITY', 'activity');
+    
+    //Default target
+    define('DEF_TARGET', TARGET_ALL);
+        
+    //$_GET valid parameters
+    define('GET_CLIENT', 'client');
+    define('GET_USER', 'user');
+    define('GET_TARGET', 'target');
+    define('GET_ID', 'id');
+    define('GET_PERMALINK', 'permalink');
+    define('GET_TEXT', 'text');
+    define('GET_USERNAME', 'username');
+    
+    /****************************************************
+    * This function is called from almost everywhere at *
+    * the beggining of the page. It initializes the     *
+    * session variables, connect to the db, enabling    *
+    * the variable $con for futher use everywhere in    *
+    * the php code, and populates the arrays $user      *
+    * and $permission, with info about the user.        *
+    *                                                   *
+    * @return: (db connection): The connection handler. *
+    ****************************************************/
+    function startdb(){
+        //Include the db configuration file. It's somehow like this
+        /*
+        <?php
+            $host = 'XXXX';
+            $db_name = 'XXXX';
+            $username_ro = 'XXXX';
+            $username_rw = 'XXXX';
+            $pass_ro = 'XXXX';
+            $pass_rw = 'XXXX';
+        ?>
+        */
+        include('../../.htpasswd');
+        
+        //Connect to to database
+        $con = mysqli_connect($host, $username_rw, $pass_rw, $db_name);
+        
+        //Set encoding options
+        mysqli_set_charset($con, 'utf-8');
+        header('Content-Type: text/html; charset=utf8');
+        mysqli_query($con, 'SET NAMES utf8;');
+        
+        //Return the db connection
+        return $con;
+    }
+    
+    //Connect to the database
+    $con = startdb('rw');
+    
+    //Get data from URL
+    $client = mysqli_real_escape_string($con, $_GET[GET_CLIENT]);
+    $user = mysqli_real_escape_string($con, $_GET[GET_USER]);
+    $target = strtolower(mysqli_real_escape_string($con, $_GET[GET_TARGET]));
+    $id = strtolower(mysqli_real_escape_string($con, $_GET[GET_ID]));
+    $permalink = strtolower(mysqli_real_escape_string($con, $_GET[GET_PERMALINK]));
+    $ink = strtolower(mysqli_real_escape_string($con, $_GET[GET_PERMALINK]));
+    $permalink = strtolower(mysqli_real_escape_string($con, $_GET[GET_PERMALINK]));
+    $username = mysqli_real_escape_string($con, $_GET[GET_USERNAME]);
+    $text = mysqli_real_escape_string($con, $_GET[GET_TEXT]);
+    
+    //Validate data
+    if (strlen($client) < 1){
+        //Bad request
+        http_response_code(400);
+        exit();
+    }
+    if (strlen($user) < 1){
+        $user = '';
+    }
+    if (strlen($target) < 1){
+        //Bad request
+        http_response_code(400);
+        exit();
+    }
+    if ($target != TARGET_PHOTO && $target != TARGET_POST && $target != TARGET_ACTIVITY){
+        //Bad request
+        http_response_code(400);
+        exit();
+    }
+    if (strlen($username) < 1){
+        //Bad request
+        http_response_code(400);
+        exit();
+    }
+    
+    
+    //Check id and/or permalink. Several cases:
+    
+    //1st case: id and permalink empty: Error.
+    if (strlen($id) < 1 && strlen($permalink) < 1){
+        //Bad request
+        http_response_code(400);
+        exit();
+    }
+    
+    //2nd case: Comment for post, permalink and no id.
+    elseif ($target == TARGET_POST && strlen($id) < 1 && strlen($permalink) >= 1){
+    
+        //Check if post exists...
+        $q = mysqli_query($con, "SELECT id, comments FROM post WHERE visible = 1 AND permalink = '$permalink';");
+        if (mysqli_num_rows($q) == 0){
+            //Bad request
+            http_response_code(400);
+            exit();
+        }
+        else{
+        
+            //... and if it does, check if can be commented.
+            $r = mysqli_fetch_array($q);
+            $item_id = $r['id'];
+            if ($r['comments'] != 1){
+                //'Forbidden' status code
+                http_response_code(403);
+                exit();
+            }
+        }
+    }
+    
+    //3rd case: Comment for post, id and no permalink.
+    elseif ($target == TARGET_POST && strlen($id) >= 1 && strlen($permalink) < 1){
+    
+        //Check if post exists...
+        $q = mysqli_query($con, "SELECT id, comments FROM post WHERE visible = 1 AND id = $id;");
+        if (mysqli_num_rows($q) == 0){
+            //Bad request
+            http_response_code(400);
+            exit();
+        }
+        else{
+        
+            //... and if it does, check if can be commented.
+            $r = mysqli_fetch_array($q);
+            $item_id = $r['id'];
+            if ($r['comments'] != 1){
+                //'Forbidden' status code
+                http_response_code(403);
+                exit();
+            }
+        }
+    }
+    
+    //4th case: Comment for post, permalink and id.
+    elseif ($target == TARGET_POST && strlen($id) >= 1 && strlen($permalink) >= 1){
+    
+        //Check if post exists...
+        $q = mysqli_query($con, "SELECT id, comments FROM post WHERE visible = 1 AND permalink = '$permalink' AND id = $id ;");
+        if (mysqli_num_rows($q) == 0){
+            //Bad request
+            http_response_code(400);
+            exit();
+        }
+        else{
+        
+            //... and if it does, check if can be commented.
+            $r = mysqli_fetch_array($q);
+            $item_id = $r['id'];
+            if ($r['comments'] != 1){
+                //'Forbidden' status code
+                http_response_code(403);
+                exit();
+            }
+        }
+    }
+    
+    //5th case: Comment for photo, permalink and no id.
+    elseif ($target == TARGET_PHOTO && strlen($id) < 1 && strlen($permalink) >= 1){
+    
+        //Check if photo exists.
+        $q = mysqli_query($con, "SELECT id FROM photo WHERE approved = 1 AND permalink = '$permalink';");
+        if (mysqli_num_rows($q) == 0){
+            //Bad request
+            http_response_code(400);
+            exit();
+        }
+        else{
+            $item_id = $r['id'];
+        }
+    }
+    
+    //6th case: Comment for photo, id and no permalink.
+    elseif ($target == TARGET_PHOTO && strlen($id) >= 1 && strlen($permalink) < 1){
+    
+        //Check if photo exists.
+        $q = mysqli_query($con, "SELECT id FROM photo WHERE approved = 1 AND id = $id;");
+        if (mysqli_num_rows($q) == 0){
+            //Bad request
+            http_response_code(400);
+            exit();
+        }
+        else{
+            $item_id = $r['id'];
+        }
+    }
+    
+    //7th case: Comment for photo, permalink and id.
+    elseif ($target == TARGET_PHOTO && strlen($id) >= 1 && strlen($permalink) >= 1){
+    
+        //Check if photo exists.
+        $q = mysqli_query($con, "SELECT id FROM photo WHERE approved = 1 AND permalink = '$permalink' AND id = $id;");
+        if (mysqli_num_rows($q) == 0){
+            //Bad request
+            http_response_code(400);
+            exit();
+        }
+        else{
+            $item_id = $r['id'];
+        }
+    }
+    
+    //8nd case: Comment for activity, permalink and no id.
+    elseif ($target == TARGET_ACTIVITY && strlen($id) < 1 && strlen($permalink) >= 1){
+    
+        //Check if activity exists...
+        $q = mysqli_query($con, "SELECT id, comments FROM activity WHERE visible = 1 AND permalink = '$permalink';");
+        if (mysqli_num_rows($q) == 0){
+            //Bad request
+            http_response_code(400);
+            exit();
+        }
+        else{
+        
+            //... and if it does, check if can be commented.
+            $r = mysqli_fetch_array($q);
+            $item_id = $r['id'];
+            if ($r['comments'] != 1){
+                //'Forbidden' status code
+                http_response_code(403);
+                exit();
+            }
+        }
+    }
+    
+    //9rd case: Comment for activity, id and no permalink.
+    elseif ($target == TARGET_ACTIVITY && strlen($id) >= 1 && strlen($permalink) < 1){
+    
+        //Check if activity exists...
+        $q = mysqli_query($con, "SELECT id, comments FROM activity WHERE visible = 1 AND id = $id;");
+        if (mysqli_num_rows($q) == 0){
+            //Bad request
+            http_response_code(400);
+            exit();
+        }
+        else{
+        
+            //... and if it does, check if can be commented.
+            $r = mysqli_fetch_array($q);
+            $item_id = $r['id'];
+            if ($r['comments'] != 1){
+                //'Forbidden' status code
+                http_response_code(403);
+                exit();
+            }
+        }
+    }
+    
+    //10th case: Comment for activity, permalink and id.
+    elseif ($target == TARGET_ACTIVITY && strlen($id) >= 1 && strlen($permalink) >= 1){
+    
+        //Check if activity exists...
+        $q = mysqli_query($con, "SELECT id, comments FROM activity WHERE visible = 1 AND permalink = '$permalink' AND id = $id ;");
+        if (mysqli_num_rows($q) == 0){
+            //Bad request
+            http_response_code(400);
+            exit();
+        }
+        else{
+        
+            //... and if it does, check if can be commented.
+            $r = mysqli_fetch_array($q);
+            $item_id = $r['id'];
+            if ($r['comments'] != 1){
+                //'Forbidden' status code
+                http_response_code(403);
+                exit();
+            }
+        }
+    }
+    
+    //If code gets here, there were no errors. Build query.
+    $query = "INSERT INTO ";
+    $section = "";
+    switch ($target){
+        case TARGET_POST:
+            $query = $query . "post_comment (post";
+            $section = "blog";
+            break;
+        case TARGET_PHOTO:
+            $query = $query . "photo_comment (photo";
+            $section = "gallery";
+            break;
+        case TARGET_ACTIVITY:
+            $query = $query . "activity_comment (activity";
+            $section = "activity";
+            break;
+    }
+    $query = $query . ", text, username, app) VALUES ($item_id, \"$text\", \"$username\", \"client\");";
+    //echo($query);
+    mysqli_query($con, $query);
+    mysqli_query($con, "UPDATE version SET version = version + 1 WHERE section = '$section';");
 
 ?>

+ 50 - 50
www/API/v1/help/comment.php

@@ -1,56 +1,56 @@
 <?php 
-	$http_host = $_SERVER['HTTP_HOST']; 
-	$v = 1;
+    $http_host = $_SERVER['HTTP_HOST']; 
+    $v = 1;
 ?>
 
 <!DOCTYPE html>
 <html>
-	<head>
-		<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
-		<meta charset="utf-8"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Gasteizko Margolariak API v<?php echo($v); ?> Documentation</title>
-		<link rel="shortcut icon" href="<?php echo "http://$http_host/img/logo/favicon.ico";?>">
-		<!-- CSS files -->
-		<style>
-			<?php 
-				include("../../../css/ui.css"); 
-				include("../../../css/index.css");
-			?>
-		</style>
-		<!-- CSS for mobile version -->
-		<style media="(max-width : 990px)">
-			<?php 
-				include("../../../css/m/ui.css"); 
-				include("../../../css/m/index.css");
-			?>
-		</style>
-		<!-- Script files -->
-		<script type="text/javascript">
-			<?php include("../../../script/ui.js"); ?>
-		</script>
-		<!-- Meta tags -->
-		<link rel="canonical" href="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
-		<link rel="author" href="<?php echo "http://$http_host"; ?>"/>
-		<link rel="publisher" href="<?php echo "http://$http_host"; ?>"/>
-		<meta name="description" content="<?php echo $lng['index_description'];?>"/>
-		<meta property="og:title" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation"/>
-		<meta property="og:url" content="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
-		<meta property="og:description" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation - Index page"/>
-		<meta property="og:image" content="<?php echo "http://$http_host/img/logo/logo-api.png";?>"/>
-		<meta property="og:site_name" content="Gasteizko Margolariak"/>
-		<meta property="og:type" content="website"/>
-		<meta property="og:locale" content="en"/>
-		<meta name="twitter:card" content="summary"/>
-		<meta name="twitter:title" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation""/>
-		<meta name="twitter:description" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation - Index page"/>
-		<meta name="twitter:image" content="<?php echo "http://$http_host/img/logo/logo-api.png";?>"/>
-		<meta name="twitter:url" content="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
-		<meta name="robots" content="index follow"/>
-	</head>
-	<body>
-		<?php include("toolbar.php"); ?>
-		<div id="content">
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
+        <meta charset="utf-8"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Gasteizko Margolariak API v<?php echo($v); ?> Documentation</title>
+        <link rel="shortcut icon" href="<?php echo "http://$http_host/img/logo/favicon.ico";?>">
+        <!-- CSS files -->
+        <style>
+            <?php 
+                include("../../../css/ui.css"); 
+                include("../../../css/index.css");
+            ?>
+        </style>
+        <!-- CSS for mobile version -->
+        <style media="(max-width : 990px)">
+            <?php 
+                include("../../../css/m/ui.css"); 
+                include("../../../css/m/index.css");
+            ?>
+        </style>
+        <!-- Script files -->
+        <script type="text/javascript">
+            <?php include("../../../script/ui.js"); ?>
+        </script>
+        <!-- Meta tags -->
+        <link rel="canonical" href="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
+        <link rel="author" href="<?php echo "http://$http_host"; ?>"/>
+        <link rel="publisher" href="<?php echo "http://$http_host"; ?>"/>
+        <meta name="description" content="<?php echo $lng['index_description'];?>"/>
+        <meta property="og:title" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation"/>
+        <meta property="og:url" content="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
+        <meta property="og:description" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation - Index page"/>
+        <meta property="og:image" content="<?php echo "http://$http_host/img/logo/logo-api.png";?>"/>
+        <meta property="og:site_name" content="Gasteizko Margolariak"/>
+        <meta property="og:type" content="website"/>
+        <meta property="og:locale" content="en"/>
+        <meta name="twitter:card" content="summary"/>
+        <meta name="twitter:title" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation""/>
+        <meta name="twitter:description" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation - Index page"/>
+        <meta name="twitter:image" content="<?php echo "http://$http_host/img/logo/logo-api.png";?>"/>
+        <meta name="twitter:url" content="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
+        <meta name="robots" content="index follow"/>
+    </head>
+    <body>
+        <?php include("toolbar.php"); ?>
+        <div id="content">
+        </div>
+    </body>
 </body>

+ 50 - 50
www/API/v1/help/index.php

@@ -1,56 +1,56 @@
 <?php 
-	$http_host = $_SERVER['HTTP_HOST']; 
-	$v = 1;
+    $http_host = $_SERVER['HTTP_HOST']; 
+    $v = 1;
 ?>
 
 <!DOCTYPE html>
 <html>
-	<head>
-		<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
-		<meta charset="utf-8"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Gasteizko Margolariak API v<?php echo($v); ?> Documentation</title>
-		<link rel="shortcut icon" href="<?php echo "http://$http_host/img/logo/favicon.ico";?>">
-		<!-- CSS files -->
-		<style>
-			<?php 
-				include("../../../css/ui.css"); 
-				include("../../../css/index.css");
-			?>
-		</style>
-		<!-- CSS for mobile version -->
-		<style media="(max-width : 990px)">
-			<?php 
-				include("../../../css/m/ui.css"); 
-				include("../../../css/m/index.css");
-			?>
-		</style>
-		<!-- Script files -->
-		<script type="text/javascript">
-			<?php include("../../../script/ui.js"); ?>
-		</script>
-		<!-- Meta tags -->
-		<link rel="canonical" href="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
-		<link rel="author" href="<?php echo "http://$http_host"; ?>"/>
-		<link rel="publisher" href="<?php echo "http://$http_host"; ?>"/>
-		<meta name="description" content="<?php echo $lng['index_description'];?>"/>
-		<meta property="og:title" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation"/>
-		<meta property="og:url" content="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
-		<meta property="og:description" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation - Index page"/>
-		<meta property="og:image" content="<?php echo "http://$http_host/img/logo/logo-api.png";?>"/>
-		<meta property="og:site_name" content="Gasteizko Margolariak"/>
-		<meta property="og:type" content="website"/>
-		<meta property="og:locale" content="en"/>
-		<meta name="twitter:card" content="summary"/>
-		<meta name="twitter:title" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation""/>
-		<meta name="twitter:description" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation - Index page"/>
-		<meta name="twitter:image" content="<?php echo "http://$http_host/img/logo/logo-api.png";?>"/>
-		<meta name="twitter:url" content="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
-		<meta name="robots" content="index follow"/>
-	</head>
-	<body>
-		<?php include("toolbar.php"); ?>
-		<div id="content">
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
+        <meta charset="utf-8"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Gasteizko Margolariak API v<?php echo($v); ?> Documentation</title>
+        <link rel="shortcut icon" href="<?php echo "http://$http_host/img/logo/favicon.ico";?>">
+        <!-- CSS files -->
+        <style>
+            <?php 
+                include("../../../css/ui.css"); 
+                include("../../../css/index.css");
+            ?>
+        </style>
+        <!-- CSS for mobile version -->
+        <style media="(max-width : 990px)">
+            <?php 
+                include("../../../css/m/ui.css"); 
+                include("../../../css/m/index.css");
+            ?>
+        </style>
+        <!-- Script files -->
+        <script type="text/javascript">
+            <?php include("../../../script/ui.js"); ?>
+        </script>
+        <!-- Meta tags -->
+        <link rel="canonical" href="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
+        <link rel="author" href="<?php echo "http://$http_host"; ?>"/>
+        <link rel="publisher" href="<?php echo "http://$http_host"; ?>"/>
+        <meta name="description" content="<?php echo $lng['index_description'];?>"/>
+        <meta property="og:title" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation"/>
+        <meta property="og:url" content="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
+        <meta property="og:description" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation - Index page"/>
+        <meta property="og:image" content="<?php echo "http://$http_host/img/logo/logo-api.png";?>"/>
+        <meta property="og:site_name" content="Gasteizko Margolariak"/>
+        <meta property="og:type" content="website"/>
+        <meta property="og:locale" content="en"/>
+        <meta name="twitter:card" content="summary"/>
+        <meta name="twitter:title" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation""/>
+        <meta name="twitter:description" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation - Index page"/>
+        <meta name="twitter:image" content="<?php echo "http://$http_host/img/logo/logo-api.png";?>"/>
+        <meta name="twitter:url" content="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
+        <meta name="robots" content="index follow"/>
+    </head>
+    <body>
+        <?php include("toolbar.php"); ?>
+        <div id="content">
+        </div>
+    </body>
 </body>

+ 50 - 50
www/API/v1/help/sync.php

@@ -1,56 +1,56 @@
 <?php 
-	$http_host = $_SERVER['HTTP_HOST']; 
-	$v = 1;
+    $http_host = $_SERVER['HTTP_HOST']; 
+    $v = 1;
 ?>
 
 <!DOCTYPE html>
 <html>
-	<head>
-		<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
-		<meta charset="utf-8"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Gasteizko Margolariak API v<?php echo($v); ?> Documentation</title>
-		<link rel="shortcut icon" href="<?php echo "http://$http_host/img/logo/favicon.ico";?>">
-		<!-- CSS files -->
-		<style>
-			<?php 
-				include("../../../css/ui.css"); 
-				include("../../../css/index.css");
-			?>
-		</style>
-		<!-- CSS for mobile version -->
-		<style media="(max-width : 990px)">
-			<?php 
-				include("../../../css/m/ui.css"); 
-				include("../../../css/m/index.css");
-			?>
-		</style>
-		<!-- Script files -->
-		<script type="text/javascript">
-			<?php include("../../../script/ui.js"); ?>
-		</script>
-		<!-- Meta tags -->
-		<link rel="canonical" href="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
-		<link rel="author" href="<?php echo "http://$http_host"; ?>"/>
-		<link rel="publisher" href="<?php echo "http://$http_host"; ?>"/>
-		<meta name="description" content="<?php echo $lng['index_description'];?>"/>
-		<meta property="og:title" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation"/>
-		<meta property="og:url" content="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
-		<meta property="og:description" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation - Index page"/>
-		<meta property="og:image" content="<?php echo "http://$http_host/img/logo/logo-api.png";?>"/>
-		<meta property="og:site_name" content="Gasteizko Margolariak"/>
-		<meta property="og:type" content="website"/>
-		<meta property="og:locale" content="en"/>
-		<meta name="twitter:card" content="summary"/>
-		<meta name="twitter:title" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation""/>
-		<meta name="twitter:description" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation - Index page"/>
-		<meta name="twitter:image" content="<?php echo "http://$http_host/img/logo/logo-api.png";?>"/>
-		<meta name="twitter:url" content="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
-		<meta name="robots" content="index follow"/>
-	</head>
-	<body>
-		<?php include("toolbar.php"); ?>
-		<div id="content">
-		</div>
-	</body>
+    <head>
+        <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
+        <meta charset="utf-8"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>Gasteizko Margolariak API v<?php echo($v); ?> Documentation</title>
+        <link rel="shortcut icon" href="<?php echo "http://$http_host/img/logo/favicon.ico";?>">
+        <!-- CSS files -->
+        <style>
+            <?php 
+                include("../../../css/ui.css"); 
+                include("../../../css/index.css");
+            ?>
+        </style>
+        <!-- CSS for mobile version -->
+        <style media="(max-width : 990px)">
+            <?php 
+                include("../../../css/m/ui.css"); 
+                include("../../../css/m/index.css");
+            ?>
+        </style>
+        <!-- Script files -->
+        <script type="text/javascript">
+            <?php include("../../../script/ui.js"); ?>
+        </script>
+        <!-- Meta tags -->
+        <link rel="canonical" href="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
+        <link rel="author" href="<?php echo "http://$http_host"; ?>"/>
+        <link rel="publisher" href="<?php echo "http://$http_host"; ?>"/>
+        <meta name="description" content="<?php echo $lng['index_description'];?>"/>
+        <meta property="og:title" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation"/>
+        <meta property="og:url" content="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
+        <meta property="og:description" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation - Index page"/>
+        <meta property="og:image" content="<?php echo "http://$http_host/img/logo/logo-api.png";?>"/>
+        <meta property="og:site_name" content="Gasteizko Margolariak"/>
+        <meta property="og:type" content="website"/>
+        <meta property="og:locale" content="en"/>
+        <meta name="twitter:card" content="summary"/>
+        <meta name="twitter:title" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation""/>
+        <meta name="twitter:description" content="Gasteizko Margolariak API v<?php echo($v); ?> Documentation - Index page"/>
+        <meta name="twitter:image" content="<?php echo "http://$http_host/img/logo/logo-api.png";?>"/>
+        <meta name="twitter:url" content="<?php echo "http://$http_host/API/help/V$v"; ?>"/>
+        <meta name="robots" content="index follow"/>
+    </head>
+    <body>
+        <?php include("toolbar.php"); ?>
+        <div id="content">
+        </div>
+    </body>
 </body>

+ 22 - 22
www/API/v1/help/toolbar.php

@@ -1,27 +1,27 @@
  <div id="header" class="desktop">
-	<div id="header_content">
-		<img src="/img/logo/logo-api.png"/>
-		<div id="header_menu">
-			<table>
-				<tr>
-					<td><a href="http://<?php echo($http_host . "API/help/V$v/"); ?>">API documentation</a></td>
-					<td><a href="http://<?php echo($http_host . "API/help/V$v/sync/"); ?>">Sync</a></td>
-					<td><a href="http://<?php echo($http_host . "API/help/V$v/comment/"); ?>">Comment</a></td>
-					<td><a href="http://<?php echo($http_host); ?>/">Main page</a></td>
-				</tr>
-			</table>
-		</div>
-	</div>
+    <div id="header_content">
+        <img src="/img/logo/logo-api.png"/>
+        <div id="header_menu">
+            <table>
+                <tr>
+                    <td><a href="http://<?php echo($http_host . "API/help/V$v/"); ?>">API documentation</a></td>
+                    <td><a href="http://<?php echo($http_host . "API/help/V$v/sync/"); ?>">Sync</a></td>
+                    <td><a href="http://<?php echo($http_host . "API/help/V$v/comment/"); ?>">Comment</a></td>
+                    <td><a href="http://<?php echo($http_host); ?>/">Main page</a></td>
+                </tr>
+            </table>
+        </div>
+    </div>
 </div>
 <div id="header_m" class="mobile">
-	<img src="/img/logo/logo-api.png" onClick='toggleMobileMenu();' id='mobile_logo'/>
-	<div id="header_menu_m">
-		<div id='header_m_title' onClick='openMobileMenu();' class='pointer'><span><img src='http://<?php echo $http_host; ?>/img/misc/slid-menu.png'/>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $cur_section; ?></span></div>
-		<div class='header_m_link'><a href="http://<?php echo($http_host . "API/help/V$v/"); ?>">API documentation</a></div>
-		<div class='header_m_link'><a href="http://<?php echo($http_host . "API/help/V$v/sync/"); ?>">Sync</a></div>
-		<div class='header_m_link'><a href="http://<?php echo($http_host . "API/help/V$v/comment/"); ?>">Comment</a></div>
-		<div class='header_m_link'><a href="http://<?php echo($http_host); ?>/">Main page</a></div>
-		<div id='header_m_slider' onClick='closeMobileMenu();' class='pointer'><span><img src='http://<?php echo $http_host; ?>/img/misc/slid-top.png'/></span></div>
-	</div><br/><br/>
+    <img src="/img/logo/logo-api.png" onClick='toggleMobileMenu();' id='mobile_logo'/>
+    <div id="header_menu_m">
+        <div id='header_m_title' onClick='openMobileMenu();' class='pointer'><span><img src='http://<?php echo $http_host; ?>/img/misc/slid-menu.png'/>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $cur_section; ?></span></div>
+        <div class='header_m_link'><a href="http://<?php echo($http_host . "API/help/V$v/"); ?>">API documentation</a></div>
+        <div class='header_m_link'><a href="http://<?php echo($http_host . "API/help/V$v/sync/"); ?>">Sync</a></div>
+        <div class='header_m_link'><a href="http://<?php echo($http_host . "API/help/V$v/comment/"); ?>">Comment</a></div>
+        <div class='header_m_link'><a href="http://<?php echo($http_host); ?>/">Main page</a></div>
+        <div id='header_m_slider' onClick='closeMobileMenu();' class='pointer'><span><img src='http://<?php echo $http_host; ?>/img/misc/slid-top.png'/></span></div>
+    </div><br/><br/>
 </div>
 

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott