Переглянути джерело

Merge branch 'V3' into V3_WEB_OSM

Iñigo Valentin 8 роки тому
батько
коміт
6339494ab6
100 змінених файлів з 3962 додано та 2349 видалено
  1. 7 3
      .gitignore
  2. 6 0
      sql/00_INSTALL.sql
  3. 519 0
      sql/01_STRUCTURE.sql
  4. 3 0
      sql/02_SECURITY.sql
  5. 34 0
      sql/03_SETTINGS.sql
  6. 10 0
      sql/04_INTERNAL.sql
  7. 43 0
      sql/05_PUBLIC.sql
  8. 424 0
      sql/06_TRIGGERS.sql
  9. 0 493
      sql/setup.sql
  10. 33 0
      www-admin/API/v3/auth.php
  11. 188 0
      www-admin/API/v3/functions.php
  12. 126 0
      www-admin/API/v3/sendlocation.php
  13. 132 0
      www-admin/API/v3/sendnotification.php
  14. 50 0
      www-admin/API/v3/sync.php
  15. 47 52
      www-admin/actividades/add/add.php
  16. 9 10
      www-admin/actividades/add/additinerary.php
  17. 9 7
      www-admin/actividades/add/index.php
  18. 70 57
      www-admin/actividades/add/itinerary.php
  19. 24 59
      www-admin/actividades/add/script.js
  20. 2 0
      www-admin/actividades/delete/delete.php
  21. 197 0
      www-admin/actividades/edit.php
  22. 0 11
      www-admin/actividades/edit/edit.php
  23. 0 27
      www-admin/actividades/edit/index.php
  24. 151 71
      www-admin/actividades/index.php
  25. 13 8
      www-admin/actividades/moderate/index.php
  26. 11 1
      www-admin/actividades/moderate/moderate.php
  27. 63 0
      www-admin/actividades/script.js
  28. 63 43
      www-admin/actividades/translate/index.php
  29. 183 71
      www-admin/actividades/translate/translate.php
  30. 7 3
      www-admin/ajustes/index.php
  31. 3 2
      www-admin/blog/add/index.php
  32. 1 3
      www-admin/blog/delete/delete.php
  33. 26 33
      www-admin/blog/edit/edit.php
  34. 120 89
      www-admin/blog/edit/index.php
  35. 35 10
      www-admin/blog/edit/script.js
  36. 114 60
      www-admin/blog/index.php
  37. 14 5
      www-admin/blog/moderate/index.php
  38. 10 10
      www-admin/blog/script.js
  39. 15 16
      www-admin/blog/translate/apply.php
  40. 54 30
      www-admin/blog/translate/index.php
  41. 88 46
      www-admin/blog/translate/translate.php
  42. 66 0
      www-admin/css/actividades.css
  43. 22 0
      www-admin/css/m/actividades.css
  44. 9 218
      www-admin/css/m/ui.css
  45. 12 12
      www-admin/css/ui.css
  46. 27 25
      www-admin/estadisticas/web/index.php
  47. BIN
      www-admin/font/FreeSans.ttf
  48. BIN
      www-admin/font/FreeSansBold.ttf
  49. BIN
      www-admin/font/FreeSansBoldOblique.ttf
  50. BIN
      www-admin/font/FreeSansOblique.ttf
  51. BIN
      www-admin/font/Vera.ttf
  52. BIN
      www-admin/font/VeraBI.ttf
  53. BIN
      www-admin/font/VeraBd.ttf
  54. BIN
      www-admin/font/VeraIt.ttf
  55. BIN
      www-admin/font/VeraMoBI.ttf
  56. BIN
      www-admin/font/VeraMoBd.ttf
  57. BIN
      www-admin/font/VeraMoIt.ttf
  58. BIN
      www-admin/font/VeraMono.ttf
  59. BIN
      www-admin/font/VeraSe.ttf
  60. BIN
      www-admin/font/VeraSeBd.ttf
  61. BIN
      www-admin/font/texgyreadventor-bold.otf
  62. BIN
      www-admin/font/texgyreadventor-bolditalic.otf
  63. BIN
      www-admin/font/texgyreadventor-italic.otf
  64. BIN
      www-admin/font/texgyreadventor-regular.otf
  65. 63 33
      www-admin/functions.php
  66. 15 0
      www-admin/functions/db_update.php
  67. 0 17
      www-admin/galeria/edit/index.php
  68. 81 38
      www-admin/galeria/index.php
  69. 0 17
      www-admin/galeria/moderate/index.php
  70. 4 5
      www-admin/galeria/translate/apply.php
  71. 61 45
      www-admin/galeria/translate/index.php
  72. 6 3
      www-admin/index.php
  73. 0 1
      www-admin/lablanca/add/add.php
  74. 0 17
      www-admin/lablanca/add/index.php
  75. 198 106
      www-admin/lablanca/calculate.php
  76. 0 1
      www-admin/lablanca/delete/delete.php
  77. 0 1
      www-admin/lablanca/edit/edit.php
  78. 0 15
      www-admin/lablanca/edit/index.php
  79. 12 13
      www-admin/lablanca/execute.php
  80. 0 1
      www-admin/lablanca/functions.php
  81. 123 74
      www-admin/lablanca/index.php
  82. 16 19
      www-admin/lablanca/insertoffer.php
  83. 0 15
      www-admin/lablanca/moderate/index.php
  84. 0 1
      www-admin/lablanca/moderate/moderate.php
  85. 38 0
      www-admin/lablanca/script.js
  86. 0 15
      www-admin/lablanca/translate/index.php
  87. 0 1
      www-admin/lablanca/translate/translate.php
  88. 13 21
      www-admin/lablanca/uploadimage.php
  89. 8 6
      www-admin/login.php
  90. 7 3
      www-admin/main.php
  91. 0 1
      www-admin/miembros/add/add.php
  92. 0 15
      www-admin/miembros/add/index.php
  93. 0 1
      www-admin/miembros/delete/delete.php
  94. 0 1
      www-admin/miembros/edit/edit.php
  95. 0 15
      www-admin/miembros/edit/index.php
  96. 77 45
      www-admin/miembros/index.php
  97. 0 189
      www-admin/miembros/miembro-bkp.php
  98. 200 123
      www-admin/miembros/miembro.php
  99. 0 15
      www-admin/miembros/moderate/index.php
  100. 0 1
      www-admin/miembros/moderate/moderate.php

+ 7 - 3
.gitignore

@@ -19,16 +19,20 @@ copy
 remotecopy
 remoteadmin
 www-admin/redirect_s.php
+.project
+.settings/
+bkp/
 
 #SQL data
 sql/dbusers.sql
 sql/*201*
 sql/*row*.sql
+sql/*__PRIVATE.sql
+sql/*__PRE.sql
 
 #Passwords file
-www/.htpasswd
-www-admin/.htpasswd
-www/.htaccess_local
+www/.ht*
+www-admin/.ht*
 
 #Photos and unnecessary images
 www/img/actividades/script

+ 6 - 0
sql/00_INSTALL.sql

@@ -0,0 +1,6 @@
+SOURCE 01_STRUCTURE.sql;
+SOURCE 02_SECURITY.sql;
+SOURCE 03_SETTINGS.sql;
+SOURCE 04_INTERNAL.sql;
+SOURCE 05_PUBLIC.sql;
+SOURCE 06_TRIGGERS.sql;

+ 519 - 0
sql/01_STRUCTURE.sql

@@ -0,0 +1,519 @@
+CREATE DATABASE gm CHARACTER SET utf8 COLLATE utf8_bin;
+
+SET NAMES utf8;
+
+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
+);
+
+DROP TABLE IF EXISTS login_attempts;
+CREATE TABLE login_attempts (
+  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
+);
+
+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
+);
+
+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)
+);
+
+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
+);
+
+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),
+  app_user VARCHAR(64)
+);
+
+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
+);
+
+DROP TABLE IF EXISTS route;
+CREATE TABLE route (
+  id    INT         AUTO_INCREMENT PRIMARY KEY,
+  name  VARCHAR(32),
+  mins  INT,
+  c_lat DOUBLE      NOT NULL,
+  c_lon DOUBLE      NOT NULL,
+  zoom  INT         DEFAULT 16
+);
+
+DROP TABLE IF EXISTS route_point;
+CREATE TABLE route_point (
+  id      INT     AUTO_INCREMENT PRIMARY KEY,
+  route   INT     NOT NULL DEFAULT 0,
+  part    INT     NOT NULL,
+  lat_o   DOUBLE,
+  lon_o   DOUBLE,
+  lat_d   DOUBLE,
+  lon_d   DOUBLE,
+  mins    INT,
+  visible BOOLEAN NOT NULL DEFAULT 1
+);
+
+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),
+  local        BOOLEAN       NOT NULL DEFAULT 1,
+  address_es   VARCHAR(200),
+  address_en   VARCHAR(200),
+  address_eu   VARCHAR(200),
+  link         VARCHAR(300),
+  lat          DOUBLE,
+  lon          DOUBLE,
+  ammount      INT,
+  print        INT           NOT NULL DEFAULT 0,
+  print_static INT           NOT NULL DEFAULT 0,
+  click        INT           NOT NULL 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)
+);
+
+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()
+);
+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),
+  fg     INT         NOT NULL DEFAULT 0,
+  synced BOOLEAN     NOT NULL DEFAULT 0,
+  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
+);
+
+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)
+);
+
+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()
+);
+
+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)
+);
+
+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(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),
+  app_user VARCHAR(64)
+);
+
+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
+);
+
+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)
+);
+
+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
+);
+
+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            REFERENCES place.id,
+  route          INT            REFERENCES route.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),
+  app_user  VARCHAR(64)
+);
+
+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)
+);
+
+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,
+  people     INT         NOT NULL DEFAULT 0,
+  max_people INT         NOT NULL DEFAULT 0
+);
+
+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
+);
+
+DROP TABLE IF EXISTS location;
+CREATE TABLE location (
+  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
+);
+
+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)
+);
+
+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,
+  sponsor        INT           REFERENCES people.id,
+  place          INT           REFERENCES place.id,
+  route          INT           REFERENCES route.id,
+  start          DATETIME      NOT NULL,
+  end            DATETIME,
+  interest       INT           NOT NULL DEFAULT 2
+);
+
+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
+);
+
+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()
+);
+
+DROP TABLE IF EXISTS version;
+CREATE TABLE version (
+  section VARCHAR(128) PRIMARY KEY,
+  version INT          NOT NULL 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)
+);
+
+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)
+);
+
+DROP TABLE IF EXISTS intolerance;
+CREATE TABLE intolerance(
+  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)
+);
+
+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)
+);
+
+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
+);
+
+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
+);
+
+
+# Create views for festival_event
+CREATE OR REPLACE VIEW festival_event_gm AS SELECT id, title_es, title_en, title_eu, description_es, description_en, description_eu, host, sponsor, place, route, start, end, interest FROM festival_event WHERE gm = 1;
+CREATE OR REPLACE VIEW festival_event_city AS SELECT id, title_es, title_en, title_eu, description_es, description_en, description_eu, host, sponsor, place, route, start, end, interest FROM festival_event WHERE gm = 0;

+ 3 - 0
sql/02_SECURITY.sql

@@ -0,0 +1,3 @@
+-- Replace 'XXXXXXXXXX' and 'YYYYYYYYYY' with your own passwords.
+GRANT SELECT, SHOW VIEW ON gm.* TO 'gm'@'localhost' IDENTIFIED BY 'XXXXXXXXXX';
+GRANT SELECT, INSERT, DELETE, UPDATE, SHOW VIEW ON gm.* TO 'gm-w'@'localhost' IDENTIFIED BY 'YYYYYYYYYY';

+ 34 - 0
sql/03_SETTINGS.sql

@@ -0,0 +1,34 @@
+-- Settings and version data
+INSERT INTO `settings` VALUES
+  ('comments','1',0,NOW()),
+  ('festivals','1',0,NOW()),
+  ('photos','1',0,NOW()),
+  ('version','1',0,NOW());
+
+INSERT INTO version VALUES
+  ('activity', 1),
+  ('activity_comment', 1),
+  ('activity_image', 1),
+  ('activity_itinerary', 1),
+  ('activity_tag', 1),
+  ('album', 1),
+  ('festival', 1),
+  ('festival_day', 1),
+  ('festival_event_city', 1),
+  ('festival_event_gm', 1),
+  ('festival_event_image', 1),
+  ('festival_offer', 1),
+  ('people', 1),
+  ('photo', 1),
+  ('photo_album', 1),
+  ('photo_comment', 1),
+  ('place', 1),
+  ('post', 1),
+  ('post_comment', 1),
+  ('post_image', 1),
+  ('post_tag', 1),
+  ('route', 1),
+  ('route_point', 1),
+  ('settings', 1),
+  ('sponsor', 1);
+

+ 10 - 0
sql/04_INTERNAL.sql

@@ -0,0 +1,10 @@
+-- Data for the followin tables goes here:
+--  member
+--  membre_activity
+--  member_day
+--  sponsor
+
+INSERT INTO `member` VALUES ...
+INSERT INTO `member_activity` VALUES ...
+INSERT INTO `member_day` VALUES ...
+INSERT INTO `sponsor` VALUES ...

+ 43 - 0
sql/05_PUBLIC.sql

@@ -0,0 +1,43 @@
+-- Data for the following tables goes here:
+--  activity
+--  activity_image
+--  activity_itinerary
+--  activity_tag
+--  album
+--  festival
+--  festival_day
+--  festival_event
+--  festival_offer
+--  location
+--  notification
+--  people
+--  photo
+--  photo_album
+--  place
+--  post
+--  post_comment
+--  post_image
+--  post_tag
+--  route
+--  route_point
+--  sponsor
+
+INSERT INTO `activity` VALUES ...
+INSERT INTO `activity_image` VALUES ...
+INSERT INTO `activity_itinerary` VALUES ...
+INSERT INTO `activity_tag` VALUES ...
+INSERT INTO `album` VALUES ...
+INSERT INTO `festival` VALUES ...
+INSERT INTO `festival_day` VALUES ...
+INSERT INTO `festival_event` VALUES ...
+INSERT INTO `festival_offer` VALUES ...
+INSERT INTO `location` VALUES ...
+INSERT INTO `notification` VALUES ...
+INSERT INTO `people` VALUES ...
+INSERT INTO `photo` VALUES ...
+INSERT INTO `photo_album` VALUES ...
+INSERT INTO `place` VALUES ...
+INSERT INTO `post` VALUES ...
+INSERT INTO `post_comment` VALUES ...
+INSERT INTO `post_image` VALUES ...
+INSERT INTO `post_tag` VALUES ...

+ 424 - 0
sql/06_TRIGGERS.sql

@@ -0,0 +1,424 @@
+# Triggers to update versions
+
+DELIMITER ;
+DELIMITER //
+
+CREATE PROCEDURE version_up(IN section_name VARCHAR(128))
+  BEGIN
+  UPDATE version SET version = version + 1 WHERE section = section_name;
+  END;
+//
+
+CREATE TRIGGER version_i_activity AFTER INSERT ON activity FOR EACH ROW
+  BEGIN
+  CALL version_up('activity');
+  END;
+//
+
+CREATE TRIGGER version_d_activity AFTER DELETE ON activity FOR EACH ROW
+  BEGIN
+  CALL version_up('activity');
+  END;
+//
+
+CREATE TRIGGER version_u_activity AFTER UPDATE ON activity FOR EACH ROW
+  BEGIN
+  CALL version_up('activity');
+  END;
+//
+
+CREATE TRIGGER version_i_activity_comment AFTER INSERT ON activity_comment FOR EACH ROW
+  BEGIN
+  CALL version_up('activity_comment');
+  END;
+//
+
+CREATE TRIGGER version_d_activity_comment AFTER DELETE ON activity_comment FOR EACH ROW
+  BEGIN
+  CALL version_up('activity_comment');
+  END;
+//
+
+CREATE TRIGGER version_u_activity_comment AFTER UPDATE ON activity_comment FOR EACH ROW
+  BEGIN
+  CALL version_up('activity_comment');
+  END;
+//
+
+CREATE TRIGGER version_i_activity_image AFTER INSERT ON activity_image FOR EACH ROW
+  BEGIN
+  CALL version_up('activity_image');
+  END;
+//
+
+CREATE TRIGGER version_d_activity_image AFTER DELETE ON activity_image FOR EACH ROW
+  BEGIN
+  CALL version_up('activity_image');
+  END;
+//
+
+CREATE TRIGGER version_u_activity_image AFTER UPDATE ON activity_image FOR EACH ROW
+  BEGIN
+  CALL version_up('activity_image');
+  END;
+//
+
+CREATE TRIGGER version_i_activity_itinerary AFTER INSERT ON activity_itinerary FOR EACH ROW
+  BEGIN
+  CALL version_up('activity_itinerary');
+  END;
+//
+
+CREATE TRIGGER version_d_activity_itinerary AFTER DELETE ON activity_itinerary FOR EACH ROW
+  BEGIN
+  CALL version_up('activity_itinerary');
+  END;
+//
+
+CREATE TRIGGER version_u_activity_itinerary AFTER UPDATE ON activity_itinerary FOR EACH ROW
+  BEGIN
+  CALL version_up('activity_itinerary');
+  END;
+//
+
+CREATE TRIGGER version_i_activity_tag AFTER INSERT ON activity_tag FOR EACH ROW
+  BEGIN
+  CALL version_up('activity_tag');
+  END;
+//
+
+CREATE TRIGGER version_d_activity_tag AFTER DELETE ON activity_tag FOR EACH ROW
+  BEGIN
+  CALL version_up('activity_tag');
+  END;
+//
+
+CREATE TRIGGER version_u_activity_tag AFTER UPDATE ON activity_tag FOR EACH ROW
+  BEGIN
+  CALL version_up('activity_tag');
+  END;
+//
+
+CREATE TRIGGER version_i_album AFTER INSERT ON album FOR EACH ROW
+  BEGIN
+  CALL version_up('album');
+  END;
+//
+
+CREATE TRIGGER version_d_album AFTER DELETE ON album FOR EACH ROW
+  BEGIN
+  CALL version_up('album');
+  END;
+//
+
+CREATE TRIGGER version_u_album AFTER UPDATE ON album FOR EACH ROW
+  BEGIN
+  CALL version_up('album');
+  END;
+//
+
+CREATE TRIGGER version_i_festival AFTER INSERT ON festival FOR EACH ROW
+  BEGIN
+  CALL version_up('festival');
+  END;
+//
+
+CREATE TRIGGER version_d_festival AFTER DELETE ON festival FOR EACH ROW
+  BEGIN
+  CALL version_up('festival');
+  END;
+//
+
+CREATE TRIGGER version_u_festival AFTER UPDATE ON festival FOR EACH ROW
+  BEGIN
+  CALL version_up('festival');
+  END;
+//
+
+CREATE TRIGGER version_i_festival_day AFTER INSERT ON festival_day FOR EACH ROW
+  BEGIN
+  CALL version_up('festival_day');
+  END;
+//
+
+CREATE TRIGGER version_d_festival_day AFTER DELETE ON festival_day FOR EACH ROW
+  BEGIN
+  CALL version_up('festival_day');
+  END;
+//
+
+CREATE TRIGGER version_u_festival_day AFTER UPDATE ON festival_day FOR EACH ROW
+  BEGIN
+  CALL version_up('festival_day');
+  END;
+//
+
+CREATE TRIGGER version_i_festival_event AFTER INSERT ON festival_event FOR EACH ROW
+  BEGIN
+  IF NEW.gm = 0 THEN
+    CALL version_up('festival_event_city');
+  ELSE
+    CALL version_up('festival_event_gm');
+  END IF;
+  END;
+//
+
+CREATE TRIGGER version_d_festival_event AFTER DELETE ON festival_event FOR EACH ROW
+  BEGIN
+  IF OLD.gm = 0 THEN
+    CALL version_up('festival_event_city');
+  ELSE
+    CALL version_up('festival_event_gm');
+  END IF;
+  END;
+//
+
+CREATE TRIGGER version_u_festival_event AFTER UPDATE ON festival_event FOR EACH ROW
+  BEGIN
+  IF NEW.gm = 0 THEN
+    CALL version_up('festival_event_city');
+  ELSE
+    CALL version_up('festival_event_gm');
+  END IF;
+  END;
+//
+
+CREATE TRIGGER version_i_festival_event_image AFTER INSERT ON festival_event_image FOR EACH ROW
+  BEGIN
+  CALL version_up('festival_event_image');
+  END;
+//
+
+CREATE TRIGGER version_d_festival_event_image AFTER DELETE ON festival_event_image FOR EACH ROW
+  BEGIN
+  CALL version_up('festival_event_image');
+  END;
+//
+
+CREATE TRIGGER version_u_festival_event_image AFTER UPDATE ON festival_event_image FOR EACH ROW
+  BEGIN
+  CALL version_up('festival_event_image');
+  END;
+//
+
+CREATE TRIGGER version_i_festival_offer AFTER INSERT ON festival_offer FOR EACH ROW
+  BEGIN
+  CALL version_up('festival_offer');
+  END;
+//
+
+CREATE TRIGGER version_d_festival_offer AFTER DELETE ON festival_offer FOR EACH ROW
+  BEGIN
+  CALL version_up('festival_offer');
+  END;
+//
+
+CREATE TRIGGER version_u_festival_offer AFTER UPDATE ON festival_offer FOR EACH ROW
+  BEGIN
+  CALL version_up('festival_offer');
+  END;
+//
+
+CREATE TRIGGER version_i_people AFTER INSERT ON people FOR EACH ROW
+  BEGIN
+  CALL version_up('people');
+  END;
+//
+
+CREATE TRIGGER version_d_people AFTER DELETE ON people FOR EACH ROW
+  BEGIN
+  CALL version_up('people');
+  END;
+//
+
+CREATE TRIGGER version_u_people AFTER UPDATE ON people FOR EACH ROW
+  BEGIN
+  CALL version_up('people');
+  END;
+//
+
+CREATE TRIGGER version_i_photo AFTER INSERT ON photo FOR EACH ROW
+  BEGIN
+  CALL version_up('photo');
+  END;
+//
+
+CREATE TRIGGER version_d_photo AFTER DELETE ON photo FOR EACH ROW
+  BEGIN
+  CALL version_up('photo');
+  END;
+//
+
+CREATE TRIGGER version_u_photo AFTER UPDATE ON photo FOR EACH ROW
+  BEGIN
+  CALL version_up('photo');
+  END;
+//
+
+CREATE TRIGGER version_i_photo_album AFTER INSERT ON photo_album FOR EACH ROW
+  BEGIN
+  CALL version_up('photo_album');
+  END;
+//
+
+CREATE TRIGGER version_d_photo_album AFTER DELETE ON photo_album FOR EACH ROW
+  BEGIN
+  CALL version_up('photo_album');
+  END;
+//
+
+CREATE TRIGGER version_u_photo_album AFTER UPDATE ON photo_album FOR EACH ROW
+  BEGIN
+  CALL version_up('photo_album');
+  END;
+//
+
+CREATE TRIGGER version_i_photo_comment AFTER INSERT ON photo_comment FOR EACH ROW
+  BEGIN
+  CALL version_up('photo_comment');
+  END;
+//
+
+CREATE TRIGGER version_d_photo_comment AFTER DELETE ON photo_comment FOR EACH ROW
+  BEGIN
+  CALL version_up('photo_comment');
+  END;
+//
+
+CREATE TRIGGER version_u_photo_comment AFTER UPDATE ON photo_comment FOR EACH ROW
+  BEGIN
+  CALL version_up('photo_comment');
+  END;
+//
+
+CREATE TRIGGER version_i_place AFTER INSERT ON place FOR EACH ROW
+  BEGIN
+  CALL version_up('place');
+  END;
+//
+
+CREATE TRIGGER version_d_place AFTER DELETE ON place FOR EACH ROW
+  BEGIN
+  CALL version_up('place');
+  END;
+//
+
+CREATE TRIGGER version_u_place AFTER UPDATE ON place FOR EACH ROW
+  BEGIN
+  CALL version_up('place');
+  END;
+//
+
+CREATE TRIGGER version_i_post AFTER INSERT ON post FOR EACH ROW
+  BEGIN
+  CALL version_up('post');
+  END;
+//
+
+CREATE TRIGGER version_d_post AFTER DELETE ON post FOR EACH ROW
+  BEGIN
+  CALL version_up('post');
+  END;
+//
+
+CREATE TRIGGER version_u_post AFTER UPDATE ON post FOR EACH ROW
+  BEGIN
+  CALL version_up('post');
+  END;
+//
+
+CREATE TRIGGER version_i_post_comment AFTER INSERT ON post_comment FOR EACH ROW
+  BEGIN
+  CALL version_up('post_comment');
+  END;
+//
+
+CREATE TRIGGER version_d_post_comment AFTER DELETE ON post_comment FOR EACH ROW
+  BEGIN
+  CALL version_up('post_comment');
+  END;
+//
+
+CREATE TRIGGER version_u_post_comment AFTER UPDATE ON post_comment FOR EACH ROW
+  BEGIN
+  CALL version_up('post_comment');
+  END;
+//
+
+CREATE TRIGGER version_i_post_image AFTER INSERT ON post_image FOR EACH ROW
+  BEGIN
+  CALL version_up('post_image');
+  END;
+//
+
+CREATE TRIGGER version_d_post_image AFTER DELETE ON post_image FOR EACH ROW
+  BEGIN
+  CALL version_up('post_image');
+  END;
+//
+
+CREATE TRIGGER version_u_post_image AFTER UPDATE ON post_image FOR EACH ROW
+  BEGIN
+  CALL version_up('post_image');
+  END;
+//
+
+CREATE TRIGGER version_i_post_tag AFTER INSERT ON post_tag FOR EACH ROW
+  BEGIN
+  CALL version_up('post_tag');
+  END;
+//
+
+CREATE TRIGGER version_d_post_tag AFTER DELETE ON post_tag FOR EACH ROW
+  BEGIN
+  CALL version_up('post_tag');
+  END;
+//
+
+CREATE TRIGGER version_u_post_tag AFTER UPDATE ON post_tag FOR EACH ROW
+  BEGIN
+  CALL version_up('post_tag');
+  END;
+//
+
+CREATE TRIGGER version_i_settings AFTER INSERT ON settings FOR EACH ROW
+  BEGIN
+  CALL version_up('settings');
+  END;
+//
+
+CREATE TRIGGER version_d_settings AFTER DELETE ON settings FOR EACH ROW
+  BEGIN
+  CALL version_up('settings');
+  END;
+//
+
+CREATE TRIGGER version_u_settings AFTER UPDATE ON settings FOR EACH ROW
+  BEGIN
+  CALL version_up('settings');
+  END;
+//
+
+CREATE TRIGGER version_i_sponsor AFTER INSERT ON sponsor FOR EACH ROW
+  BEGIN
+  CALL version_up('sponsor');
+  END;
+//
+
+CREATE TRIGGER version_d_sponsor AFTER DELETE ON sponsor FOR EACH ROW
+  BEGIN
+  CALL version_up('sponsor');
+  END;
+//
+
+CREATE TRIGGER version_u_sponsor AFTER UPDATE ON sponsor FOR EACH ROW
+  BEGIN
+  IF (NEW.print = OLD.print AND NEW.print_static = OLD.print_static AND NEW.click = OLD.click AND NEW.ammount = OLD.ammount) THEN
+    CALL version_up('sponsor');
+  END IF;
+  END;
+//
+
+
+
+DELIMITER ;

+ 0 - 493
sql/setup.sql

@@ -1,493 +0,0 @@
-CREATE DATABASE gm CHARACTER SET utf8 COLLATE utf8_bin;
-
-SET NAMES utf8;
-
-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
-);
-
-DROP TABLE IF EXISTS login_attempts;
-CREATE TABLE login_attempts (
-    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
-);
-
-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
-);
-
-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)
-);
-
-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
-);
-
-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)
-);
-
-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
-);
-
-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
-);
-
-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)
-);
-
-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()
-);
-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)
-);
-
-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
-);
-
-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)
-);
-
-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()
-);
-
-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)
-);
-
-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)
-);
-
-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
-);
-
-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)
-);
-
-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
-);
-
-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
-);
-
-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)
-);
-
-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)
-);
-
-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
-);
-
-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
-);
-
-DROP TABLE IF EXISTS location;
-CREATE TABLE location (
-    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
-);
-
-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)
-);
-
-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
-);
-
-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
-);
-
-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()
-);
-
-DROP TABLE IF EXISTS version;
-CREATE TABLE version (
-    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)
-);
-
-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)
-);
-
-DROP TABLE IF EXISTS intolerance;
-CREATE TABLE intolerance(
-    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)
-);
-
-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)
-);
-
-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
-);
-
-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:
-/*
-GRANT SELECT ON gm.* TO 'XXXX'@'XXXX' IDENTIFIED BY 'XXXX';
-GRANT SELECT, INSERT, DELETE, UPDATE ON gm.* TO 'XXXX'@'XXXX' IDENTIFIED BY 'XXXX';
-*/
-SOURCE dbusers.sql;
-

+ 33 - 0
www-admin/API/v3/auth.php

@@ -0,0 +1,33 @@
+ <?php
+    // Gasteizko Margolariak API v3 //
+
+    // $_POST valid parameters
+    define('POST_USER', 'user');
+    define('POST_PASS', 'pass');
+
+    // Error messages
+    define('ERR_USER', '-USER:');
+
+    include('functions.php');
+    $con = startdb();
+
+    // Error control
+    $error = "";
+
+    // Get params
+    $user = mysqli_real_escape_string($con, $_POST[POST_USER]);
+    $pass = mysqli_real_escape_string($con, $_POST[POST_PASS]);
+
+    //Validate user
+    $uid = login($con, $user, $pass);
+    if ($uid == -1){
+        error_log(":SECURITY: Reporting location with wrong credentials (IP $_SERVER[REMOTE_ADDR])");
+        $error = $error . ERR_USER . mysqli_real_escape_string($con, $_POST[GET_USER]);
+        error_log($error);
+        http_response_code(403); // Forbidden
+        exit(-1);
+    }
+    else{
+        http_response_code(204); // No content
+    }
+?>

+ 188 - 0
www-admin/API/v3/functions.php

@@ -0,0 +1,188 @@
+<?php
+
+    $IMG_SIZE_PREVIEW = 600;
+    $IMG_SIZE_MINIATURE = 200;
+
+    /*****************************************************
+     * Finds out the protocol the user is connecting to  *
+     * the site with (http or https)                     *
+     * @return: (string): "http://" or "https://".       *
+     ****************************************************/
+    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;
+    }
+
+    /*****************************************************
+     * Connects to the database, in 'r' or 'rw' mode.    *
+     * @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 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;
+    }
+
+
+    /*****************************************************
+     * Validates a user/password combo.                  *
+     *                                                   *
+     * @params:                                          *
+     *    con: (Mysql connectrion): DB connection.       *
+     *    user: (string): Username.                      *
+     *    pass: (string): Password.                      *
+     * @return: (int): User id, or -1 if the user and    *
+     *          pass didn't match.                       *
+     *****************************************************/
+    function login($con, $user, $pass){
+        session_start();
+        $q = mysqli_query($con,"SELECT id, salt, username AS username, sha1(salt) AS s FROM user WHERE (lower(username) = lower('$user') OR lower(email) = lower('$user')) AND password = sha1(concat('$pass', sha1(salt)));");
+        if (mysqli_num_rows($q) == 1){
+            $r = mysqli_fetch_array($q);
+            $_SESSION['id'] = $r['id'];
+            $_SESSION['salt'] = $r['s'];
+            $_SESSION['name'] = $r['username'];
+            return $r['id'];
+        }
+        else{
+            error_log("Invalid login. username = $user, id = $_SESSION[id]");
+            return -1;
+        }
+    }
+
+    /*****************************************************
+     * Finds out the IP address of the client.           *
+     *                                                   *
+     * @return: (String): Client IP address.             *
+     *****************************************************/
+    function getUserIP(){
+        $client  = @$_SERVER["HTTP_CLIENT_IP"];
+        $forward = @$_SERVER["HTTP_X_FORWARDED_FOR"];
+        $remote  = $_SERVER["REMOTE_ADDR"];
+        if(filter_var($client, FILTER_VALIDATE_IP)){
+            $ip = $client;
+        }
+        elseif(filter_var($forward, FILTER_VALIDATE_IP)){
+            $ip = $forward;
+        }
+        else{
+            $ip = $remote;
+        }
+        return $ip;
+    }
+
+?>

+ 126 - 0
www-admin/API/v3/sendlocation.php

@@ -0,0 +1,126 @@
+<?php
+    // Gasteizko Margolariak API v3 //
+
+    // $_GET valid parameters
+    define('POST_USER', 'user');
+    define('POST_PASS', 'pass');
+    define('GET_ACTION', 'action');
+    define('GET_LAT', 'lat');
+    define('GET_LON', 'lon');
+
+    // Valid values
+    define('ACTION_START', 'start');
+    define('ACTION_REFRESH', 'refresh');
+    define('ACTION_STOP', 'stop');
+    $actions = [ACTION_START, ACTION_REFRESH, ACTION_STOP];
+
+    // Error messages
+    define('ERR_USER', '-USER:');
+    define('ERR_ACTION', '-ACTION:');
+    define('ERR_LOCATION', '-TITLE:');
+
+    include('functions.php');
+
+    $con = startdb('rw');
+    $error = "";
+
+    //Get fields
+    
+    $user = mysqli_real_escape_string($con, $_POST[POST_USER]);
+    $pass = mysqli_real_escape_string($con, $_POST[POST_PASS]);
+    
+    $lat = mysqli_real_escape_string($con, $_GET[GET_LAT]);
+    $lon = mysqli_real_escape_string($con, $_GET[GET_LON]);
+    $action = mysqli_real_escape_string($con, $_GET[GET_ACTION]);
+    
+    //Validate user
+	$uid = login($con, $user, $pass);
+    if ($uid == -1){
+        error_log(":SECURITY: Reporting location with wrong credentials (IP $_SERVER[REMOTE_ADDR])");
+        $error = $error . ERR_USER . mysqli_real_escape_string($con, $user);
+        error_log($error);
+        http_response_code(403); // Forbidden
+        exit(-1);
+    }
+
+    //Validate fields
+    if (!in_array($action, $actions)){
+        http_response_code(400); // Bad request
+        $error = $error . ERR_ACTION . $action;
+        error_log($error);
+        exit(-2);
+    }
+    if (is_numeric($lat) == false || is_numeric($lon) == false){
+        http_response_code(400); // Bad request
+        $error = $error . ERR_LOCATION . '($lat, $lon)';
+        error_log($error);
+        exit(-3);
+    }
+    if (strlen($lat) == 0 xor strlen($lon) == 0){
+        // Only one coordinate.
+        http_response_code(400); // Bad request
+        $error = $error . ERR_LOCATION . '($lat, $lon)';
+        error_log($error);
+        exit(-4);
+    }
+    if (strlen($lat) != 0 && ($lat < -90.0 || $lat > 90.0)){
+        // Invalid latitude
+        http_response_code(400); // Bad request
+        $error = $error . ERR_LOCATION . '(Lat: $lat)';
+        error_log($error);
+        exit(-5);
+    }
+    if (strlen($lon) != 0 && ($lon < -180.0 || $lon > 180.0)){
+        // Invalid longitude
+        http_response_code(400); // Bad request
+        $error = $error . ERR_LOCATION . '(Lon: $lat)';
+        error_log($error);
+        exit(-6);
+    }
+
+    // Discern action
+    switch ($action){
+        case ACTION_START:
+            // Insert
+            mysqli_query($con, "INSERT INTO location (lat, lon, action, user) VALUES ($lat, $lon, 'S', $uid);");
+            break;
+        case ACTION_REFRESH:
+            // Look for start node.
+            $q = mysqli_query($con, "SELECT id, start, action FROM location WHERE user = $uid AND dtime > NOW() - INTERVAL 30 MINUTE ORDER BY dtime DESC LIMIT 1;");
+            if (mysqli_num_rows($q) == 0){
+                // No recent reports. Start anew.
+                mysqli_query($con, "INSERT INTO location (lat, lon, action, user) VALUES ($lat, $lon, 'S', $uid);");
+            }
+            else{
+                $r = mysqli_fetch_array($q);
+                if ($r['action'] == 'F'){
+                    // Previous track was stoped. Start anew.
+                    mysqli_query($con, "INSERT INTO location (lat, lon, action, user) VALUES ($lat, $lon, 'S', $uid);");
+                }
+                else{
+                    // Continue track.
+                    $s = $r['id'];
+                    mysqli_query($con, "INSERT INTO location (lat, lon, action, user, start) VALUES ($lat, $lon, 'R', $uid, $s);");
+                }
+            }
+            break;
+        case ACTION_STOP:
+            // Look for start node.
+            $q = mysqli_query($con, "SELECT id, start FROM location WHERE user = $uid AND dtime > NOW() - INTERVAL 30 MINUTE ORDER BY dtime DESC LIMIT 1;");
+            if (mysqli_num_rows($q) > 0){
+                $r = mysqli_fetch_array($q);
+                if ($r['action'] != 'F'){
+                    // Finish track.
+                    $s = $r['start'];
+                    if (strlen($lat) > 0 && strlen($lon) > 0){
+                        mysqli_query($con, "INSERT INTO location (lat, lon, action, user, start) VALUES ($lat, $lon, 'F', $uid, $s);");
+                    }
+                    else{
+                        mysqli_query($con, "INSERT INTO location (action, user, start) VALUES ('F', $uid, $s);");
+                    }
+                }
+            }
+            break;
+    }
+    http_response_code(204); // No content.
+?>

+ 132 - 0
www-admin/API/v3/sendnotification.php

@@ -0,0 +1,132 @@
+<?php
+    // Gasteizko Margolariak API v3 //
+
+    // $_GET and $_POST valid parameters
+    define('POST_USER', 'user');
+    define('POST_PASS', 'pass');
+    define('GET_TITLE_ES', 'title_es');
+    define('GET_TITLE_EN', 'title_en');
+    define('GET_TITLE_EU', 'title_eu');
+    define('GET_TEXT_ES', 'text_es');
+    define('GET_TEXT_EN', 'text_en');
+    define('GET_TEXT_EU', 'text_eu');
+    define('GET_DURATION', 'duration');
+    define('GET_ACTION', 'action');
+    define('GET_PERM', 'permalink');
+    define('GET_ID', 'id');
+    define('GET_GM', 'gm');
+
+    // Valid values
+    define('ACTION_TEXT', 'text');
+    define('ACTION_BLOG', 'blog');
+    define('ACTION_ACTIVITIES', 'activities');
+    define('ACTION_GALLERY', 'gallery');
+    define('ACTION_LOCATION', 'location');
+    define('ACTION_LABLANCA', 'lablanca');
+    define('ACTION_SCHEDULE_CITY', 'schedule_city');
+    define('ACTION_SCHEDULE_GM', 'schedule_gm');
+    define('ACTION_US', 'us');
+    $actions = [ACTION_TEXT, ACTION_BLOG, ACTION_ACTIVITIES, ACTION_GALLERY, ACTION_LOCATION, ACTION_LABLANCA, ACTION_SCHEDULE_CITY, ACTION_SCHEDULE_GM, ACTION_US];
+
+    // Default values
+    define('DEF_GM', 0);
+    define('DEF_ACTION', ACTION_TEXT);
+
+    // Error messages
+    define('ERR_USER', '-USER:');
+    define('ERR_ACTION', '-ACTION:');
+    define('ERR_TITLE', '-TITLE:');
+    define('ERR_TEXT', '-TEXT:');
+    define('ERR_DURATION', '-DURATION:');
+    define('ERR_GM', '-GM:');
+    define('ERR_PERM', '-PERM:');
+    define('ERR_ID', '-ID:');
+
+    include('functions.php');
+
+    $con = startdb('rw');
+
+    // Get fields
+    $user = mysqli_real_escape_string($con, $_POST[POST_USER]);
+	$pass = mysqli_real_escape_string($con, $_POST[POST_PASS]);
+    $title_es = urldecode(mysqli_real_escape_string($con, $_GET[GET_TITLE_ES]));
+    $title_en = urldecode(mysqli_real_escape_string($con, $_GET[GET_TITLE_EN]));
+    $title_eu = urldecode(mysqli_real_escape_string($con, $_GET[GET_TITLE_EU]));
+    $text_es = urldecode(mysqli_real_escape_string($con, $_GET[GET_TEXT_ES]));
+    $text_en = urldecode(mysqli_real_escape_string($con, $_GET[GET_TEXT_EN]));
+    $text_eu = urldecode(mysqli_real_escape_string($con, $_GET[GET_TEXT_EU]));
+    $duration = mysqli_real_escape_string($con, $_GET[GET_DURATION]);
+    $action = mysqli_real_escape_string($con, $_GET[GET_ACTION]);
+    $id = mysqli_real_escape_string($con, $_GET[GET_ID]);
+    $perm = mysqli_real_escape_string($con, $_GET[GET_PERM]);
+    $gm = mysqli_real_escape_string($con, $_GET[GET_GM]);
+
+    // Error control
+    $error = "";
+
+    // Validate user/pass
+    $uid = login($con, $user, $pass);
+    if ($uid == -1){
+        error_log(":SECURITY: Reporting location with wrong credentials (IP $_SERVER[REMOTE_ADDR])");
+        $error = $error . ERR_USER . mysqli_real_escape_string($con, $_POST[POST_USER]);
+        error_log($error);
+        http_response_code(403); // Forbidden
+        exit(-1);
+    }
+
+    //Validate fields
+    if (strlen($title_es) == 0){
+        http_response_code(400); // Bad request
+        $error = $error . ERR_TITLE . $title_es;
+        error_log($error);
+        exit(-2);
+    }
+
+    if (strlen($text_es) == 0){
+        http_response_code(400); // Bad request
+        $error = $error . ERR_TEXT . $text_es;
+        error_log($error);
+        exit(-3);
+    }
+
+    if (is_numeric($duration) == false || $duration < 1 && $duration > 48 * 60){
+        http_response_code(400); // Bad request
+        $error = $error . ERR_DURATION . $duration;
+        error_log($error);
+        exit(-4);
+    }
+
+    if (!in_array($action, $actions)){
+        http_response_code(400); // Bad request
+        $error = $error . ERR_ACTION . $action;
+        error_log($error);
+        exit(-5);
+    }
+
+    //Handle translations
+    if (strlen($title_en) == 0){
+        $title_en = $title_es;
+    }
+    if (strlen($title_eu) == 0){
+        $title_eu = $title_es;
+    }
+    if (strlen($text_en) == 0){
+        $text_en = $text_es;
+    }
+    if (strlen($text_eu) == 0){
+        $text_eu = $text_es;
+    }
+
+    //Insert
+    if (strlen($error) == 0){
+        mysqli_query($con, "INSERT INTO notification (user, title_es, title_en, title_eu, text_es, text_en, text_eu, action, duration) VALUES ($_SESSION[id], '$title_es', '$title_en', '$title_eu', '$text_es', '$text_en', '$text_eu', '$action', $duration);");
+        error_log("INSERT INTO notification (user, title_es, title_en, title_eu, text_es, text_en, text_eu, action, duration) VALUES ($_SESSION[id], '$title_es', '$title_en', '$title_eu', '$text_es', '$text_en', '$text_eu', '$action', $duration);");
+        http_response_code(204); // No content;
+        exit(0);
+    }
+    else{
+		http_response_code(400); // Bad request
+        error_log($error);
+        exit(-6);
+    }
+?>

+ 50 - 0
www-admin/API/v3/sync.php

@@ -0,0 +1,50 @@
+ <?php
+    // Gasteizko Margolariak API v3 //
+
+    // $_GET and $_POST valid parameters
+    define('POST_USER', 'user');
+    define('POST_PASS', 'pass');
+    define('GET_TABLES', 'tables');
+    define('GET_WHERE', 'where');
+
+    // Error messages
+    define('ERR_USER', '-USER:');
+    define('ERR_TABLES', '-TABLES:');
+    define('ERR_WHERE', '-WHERE:');
+
+    include('functions.php');
+    $con = startdb();
+
+    // Error control
+    $error = "";
+
+    // Get params
+    $user = mysqli_real_escape_string($con, $_POST[POST_USER]);
+    $pass = mysqli_real_escape_string($con, $_POST[POST_PASS]);
+
+    $tables = mysqli_real_escape_string($con, $_GET[GET_TABLES]);
+    $where = mysqli_real_escape_string($con, $_GET[GET_WHERE]);
+
+    //Validate user
+    $uid = login($con, $user, $pass);
+    if ($uid == -1){
+        error_log(":SECURITY: Reporting location with wrong credentials (IP $_SERVER[REMOTE_ADDR])");
+        $error = $error . ERR_USER . mysqli_real_escape_string($con, $_POST[GET_USER]);
+        error_log($error);
+        http_response_code(403); // Forbidden
+        exit(-1);
+    }
+
+    // Ask server to create a SQLdump
+    $date = date_create();
+    $fname = date_timestamp_get($date);
+    include('../../../www/.htpasswd');
+    exec("mysqldump --single-transaction gm -u $username_ro -p'$pass_ro' > /var/www-dump/$fname.sql");
+
+    // Ask server to encrypt the dump.
+    $pass = mysqli_real_escape_string($con, $_POST[POST_USER]);
+    exec("gpg --batch --yes --passphrase $pass -o /var/www-admin/dump/$fname.gpg -c /var/www-dump/$fname.sql");
+
+    // Make a redirect.
+    header("Location: /dump/$fname.gpg");
+?>

+ 47 - 52
www-admin/actividades/add/add.php

@@ -27,16 +27,15 @@
         $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)
+        if ($title_es == null){
             exit();
+        }
         else{
             $permalink = permalink($title_es);
             $i = 2;
@@ -54,83 +53,79 @@
                 }
             }
         }
-        
-        //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 == '')
+        if ($city == ''){
             $city = 'Vitoria-Gasteiz';
-        
+        }
+
         //Check booleans and assign default values if not
-        if ($comments == 'off')
+        if ($comments == 'off'){
             $comments = 0;
-        else
+        }
+        else{
             $comments = 1;
-        if ($visible == 'off')
+        }
+        if ($visible == 'off'){
             $visible = 0;
-        else
+        }
+        else{
             $visible = 1;
-        if ($admin == 'on')
+        }
+        if ($admin == 'on'){
             $admin = 1;
-        else
+        }
+        else{
             $admin = 0;
-        if ($inscription == 'off')
+        }
+        if ($inscription == 'off'){
             $inscription = 0;
-        else
+        }
+        else{
             $inscription = 1;
-        
-        //TODO:Check valid date
-        if ($day == '' || $month == '' || $year == '')
+        }
+
+        //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; 
+            $title_eu = $title_es;
         }
-        
+
         if (strlen($text_en) == 0){
             $text_en = $text_es;
-            $title_en = $title_es; 
+            $title_en = $title_es;
         }
-        
+
         //Get user
-        if ($admin)
+        if ($admin){
             $user = 0;
+        }
         else{
-            //TODO
-            $user = 0;
+            $user = $_SESSION["id"];
         }
-        
-        // 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');
@@ -145,21 +140,21 @@
                 $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')
+        if ($schedule == 'on'){
             header("Location: /actividades/add/itinerary.php?id=$id");
-        else
+        }
+        else{
             header("Location: /actividades/");
+        }
     }
 ?>

+ 9 - 10
www-admin/actividades/add/additinerary.php

@@ -14,11 +14,11 @@
         header("Location: $http_host/actividades/");
         exit (-1);
     }
-    
+
     //Get date
     $r = mysqli_fetch_array($q);
     $date = $r['date'];
-    
+
     //Initialize data arrays
     $starth = [];
     $startm = [];
@@ -31,10 +31,10 @@
     $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"]);
@@ -47,10 +47,10 @@
         $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] ";
@@ -93,14 +93,13 @@
             $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();
+            mysqli_query($con, $query);
         }
-        
+
         //Redirect
         header("Location: $http_host/actividades/");
     }

+ 9 - 7
www-admin/actividades/add/index.php

@@ -6,7 +6,8 @@
         header("Location: /index.php");
         exit (-1);
     }
-    else{?>
+     else{
+?>
 <html>
     <head>
         <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
@@ -24,7 +25,9 @@
         <script src="../../ckeditor/ckeditor.js"></script>
     </head>
     <body>
-        <?php include('../../toolbar.php'); ?>
+<?php
+        include('../../toolbar.php');
+?>
         <div id='content'>
             <div class="section">
                 <h3 class="section_title">Nueva actividad</h3>
@@ -74,9 +77,6 @@
                         <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>
@@ -117,7 +117,7 @@
                         <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-->
+                            <input type="button" value="Validar" onClick="alert(validateActivity());"/>
                             </br>
                             <input type="submit" value="Publicar"/>
                         </div>
@@ -127,4 +127,6 @@
         </div>
     </body>
 </html>
-<?php } ?>
+<?php
+    }
+?>

+ 70 - 57
www-admin/actividades/add/itinerary.php

@@ -16,7 +16,7 @@
     }
     else{
         $r = mysqli_fetch_array($q);
-    ?>
+?>
 <html>
     <head>
         <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
@@ -42,65 +42,76 @@
                     <div class="entry">
                         <input type='hidden' name='activity' value='<?php echo $id; ?>'/>
                         <table id='itinerary'>
-                        <?php
+<?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;">
-                                                                        <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");
+?>
+                                <tr id='itinerary_row_<?=$i?>' class='itinerary_row'>
+                                    <td class='itinerary_cell time'>
+                                        <h4>Hora y lugar</h4>
+                                        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?>);'/>
+                                        <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?>);'/>
+                                        <br/><br/>
+                                        Lugar*: 
+                                        <select name='place_<?=$i?>' id='place_<?=$i?>' onChange='showNextRow(<?=$i?>);'>
+                                            <option value='-1'>SELECCIONA</option>
+<?php
+                                                mysqli_data_seek($q_place, 0);
+                                                    while ($r_place = mysqli_fetch_array($q_place)){
+?>
+                                                        <option value='<?=$r_place["id"]?>'><?=$r_place["name_es"]?></option>
+<?php
+                                                    }
+?>
+                                        </select>
+                                        <br/>
+                                        <span id='add_place' class='pointer' onClick='addPlace(<?=$i?>);'>A&ntilde;adir nuevo lugar</span>
+                                    </td>
+                                    <td class='itinerary_cell itinerary_cell_content'>
+?>
+                                        <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_<?=$i?>' id='title_es_<?=$i?>' onKeyUp='showNextRow(<?=$i?>'/>
+                                            <h4>Texto</h4>
+                                            <textarea name='text_es_<?=$i?>' id='text_es_<?=$i?>' onKeyUp='showNextRow(<?=$i?>);'/></textarea>
+                                        </div>
+                                        <div id="content_lang_eu" style="display:none;">
+                                            <h4>Titulo</h4>
+                                            <input type='text' name='title_eu_<?=$i?>' id='title_eu_<?=$i?>' onKeyUp='showNextRow(<?=$i?>'/>
+                                            <h4>Textua</h4>
+                                            <textarea name='text_eu_<?=$i?>' id='text_eu_<?=$i?>' onKeyUp='showNextRow(<?=$i?>);'/></textarea>
+                                        </div>
+                                        <div id="content_lang_en" style="display:none;">
+                                            <h4>Title</h4>
+                                            <input type='text' name='title_en_<?=$i?>' id='title_en_<?=$i?>' onKeyUp='showNextRow(<?=$i?>'/>
+                                            <h4>Content</h4>
+                                            <textarea name='text_en_<?=$i?>' id='text_en_<?=$i?>' onKeyUp='showNextRow(<?=$i?>);'/></textarea>
+                                        </div>
+                                    </td>
+                                </tr>
+<?php
                             }
-                        ?>
+?>
                     </table>
                     <input type='submit' id="save_itinerary"  value='Guardar'/>
                 </div> <!--Entry-->
@@ -108,4 +119,6 @@
         </div>
     </body>
 </html>
-<?php } ?>
+<?php
+    }
+?>

+ 24 - 59
www-admin/actividades/add/script.js

@@ -1,3 +1,8 @@
+/**
+ * Shows a tab to complete a form for the specified language.
+ * 
+ * @param lang Language ('es', 'en' or 'eu').
+ */
 function showTab(lang){
     switch (lang){
         case 'es':
@@ -45,6 +50,12 @@ function showTab(lang){
     }
 }
 
+
+/**
+ * Validates all the fields before adding a new activity.
+ * 
+ * @return true if fields are ok, false otherwise.
+ */
 function validateActivity(){
     var text_es = document.getElementById('text_es').value;
     var text_eu = document.getElementById('text_eu').value;
@@ -65,7 +76,6 @@ function validateActivity(){
         alert("Introduce un texto en castellano");
         return false;
     }
-    
     //Titles without texts
     if (title_eu.length > 0 && text_eu.length < 1){
         result = false;
@@ -77,7 +87,6 @@ function validateActivity(){
         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;
@@ -89,69 +98,19 @@ function validateActivity(){
         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;
-    }
-}
-
+/**
+ * Shows an image that has been just uploaded.
+ * 
+ * @param source Image resource.
+ * @param target img tag to display the image on.
+ * @return true if fields are ok, false otherwise.
+ */
 function previewImage(source, target) {
     var reader = new FileReader();
     reader.readAsDataURL(source.files[0]);
@@ -163,6 +122,12 @@ function previewImage(source, target) {
     };
 };
 
+
+/**
+ * Shows th enext itinerary row.
+ * 
+ * @param current The current row identifier.
+ */
 function showNextRow(current){
     if (document.getElementById('sh_' + current).value != '' ||
         document.getElementById('eh_' + current).value != '' || 

+ 2 - 0
www-admin/actividades/delete/delete.php

@@ -7,5 +7,7 @@
         exit (-1);
     }
     else{
+        $id = mysqli_real_escape_string($con, $_GET['id']);
+        mysqli_query($con, "UPDATE activity SET visible = 0 WHERE id = $id;");
     }
 ?>

+ 197 - 0
www-admin/actividades/edit.php

@@ -0,0 +1,197 @@
+<?php
+    include("../functions.php");
+    $http_host = $_SERVER["HTTP_HOST"];
+    $proto = getProtocol();
+    $default_host = substr($http_host, 0, strpos($http_host, ":"));
+    $server = "$proto$http_host";
+    $default_server = "$proto$default_host";
+    $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) != 1){
+            header("Location: /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><?=$r["title_es"]?> - 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/ui.js'></script>
+        <script type='text/javascript' src='/ckeditor/ckeditor.js'></script>
+        <script type='text/javascript' src='script.js'></script>
+    </head>
+    <body>
+<?php
+        include("../toolbar.php");
+?>
+        <div id='content'>
+            <div class='section'>
+                <h3 class='section_title'>Editar informaci&oacute;n</h3>
+                <div class='entry'>
+                    <h4>Detalles</h4>
+                    Fecha:
+                    <input id='date' type='text' placeholder='yyyy/mm/dd' length='10' onChange='updateActivityDate("<?=$server?>", <?=$id?>, this);'/>
+                    &nbsp;&nbsp;&nbsp;&nbsp;<br class='mobile'/>
+                    Ciudad:
+                    <input id='city' type='text' placeholder='Ciudad' lendth='32' value='<?=$r["city"]?>' onChange='dbUpdate("<?=$server?>", "activity", "city", "VARCHAR", <?=$id?>, this);'/>
+                    <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='activity_add_language'>
+                        <h4>T&iacute;tulo (castellano)</h4>
+                        <input name='title' placeholder='T&iacute;tulo' type='text' value='<?=$r["title_es"]?>' onChange='dbUpdate("<?=$server?>", "activity", "title_es", "VARCHAR", <?=$id?>, this);'/>
+                        <br/>
+                        <h4>Texto (castellano)</h4>
+                        <textarea name='text_es' id='text_es' placeholder='Texto' onChange='dbUpdate("<?=$server?>", "activity", "text_es", "VARCHAR", <?=$id?>, this);'><?=$r["text_es"]?></textarea>
+                        <script>CKEDITOR.replace('text_es');</script>
+                        <br/>
+                        <h4>Texto para despu&eacute;s (castellano)<h4>
+                        <textarea name='after_es' id='after_es' placeholder='Texto para despu&eacute;s' onChange='dbUpdate("<?=$server?>", "activity", "after_es", "VARCHAR", <?=$id?>, this);'><?=$r["after_es"]?></textarea>
+                        <script>CKEDITOR.replace('after_es');</script>
+                    </div>
+                    <div id='content_lang_eu' class='activity_add_language' style='display:none;'>
+                        <h4>T&iacute;tulo (euskera)</h4>
+                        <input name='title' placeholder='T&iacute;tulo' type='text' value='<?=$r["title_eu"]?>' onChange='dbUpdate("<?=$server?>", "activity", "title_eu", "VARCHAR", <?=$id?>, this);'/>
+                        <br/>
+                        <h4>Texto (euskera)</h4>
+                        <textarea name='text_eu' id='text_eu' placeholder='Texto' onChange='dbUpdate("<?=$server?>", "activity", "text_eu", "VARCHAR", <?=$id?>, this)'><?=$r["text_eu"]?></textarea>
+                        <script>CKEDITOR.replace('text_eu');</script>
+                        <br/>
+                        <h4>Texto para despu&eacute;s (euskera)</h4>
+                        <textarea name='after_eu' id='after_eu' placeholder='Texto para despu&eacute;s' onChange='dbUpdate("<?=$server?>", "activity", "after_eu", "VARCHAR", <?=$id?>, this);'><?=$r["after_eu"]?></textarea>
+                        <script>CKEDITOR.replace('after_eu');</script>
+                    </div>
+                    <div id='content_lang_en' class='activity_add_language' style='display:none;'>
+                        <h4>T&iacute;tulo (ingl&eacute;s)</h4>
+                        <input name='title' placeholder='T&iacute;tulo' type='text' value='<?=$r["title_en"]?>' onChange='dbUpdate("<?=$server?>", "activity", "title_en", "VARCHAR", <?=$id?>, this);'/>
+                        <br/>
+                        <h4>Texto (ingl&eacute;s)</h4>
+                        <textarea name='text_en' id='text_en' placeholder='Texto' onChange='dbUpdate("<?=$server?>", "activity", "text_en", "VARCHAR", <?=$id?>, this);'><?=$r["text_en"]?></textarea>
+                        <script>CKEDITOR.replace('text_en');</script>
+                        <br/>
+                        <h4>Texto para despu&eacute;s (ingl&eacute;s)</h4>
+                        <textarea name='after_en' id='after_en' placeholder='Texto para despu&eacute;s' onChange='dbUpdate("<?=$server?>", "activity", "after_en", "VARCHAR", <?=$id?>, this);'><?=$r["after_en"]?></textarea>
+                        <script>CKEDITOR.replace('after_en');</script>
+                    </div>
+                </div> <!-- .entry -->
+                <div class='entry'>
+                    <h3>Itinerario</h3>
+<?php
+                    $q_i = mysqli_query($con, "SELECT * FROM activity_itinerary WHERE activity = $id ORDER BY start;");
+                    $q_p = mysqli_query($con, "SELECT id, name_es FROM place ORDER by name_es");
+                    $q_r = mysqli_query($con, "SELECT id, name FROM route;");
+                    while ($r_i = mysqli_fetch_array($q_i)){
+?>
+                        <div class='itinerary' id='itinerary_<?=$r_i["id"]?>'>
+                            <input type='button' class='delete_itinerary' onClick='deleteItinerary(<?=$r_i["id"]?>);' value='Borrar del itinerario'/>
+                            Inicio:
+                            <input type='text' class='time' length='5' value='<?=substr($r_i["start"], 11, 5)?>' placeholder='HH:MM' onChange='updateItineraryStart("<?=$server?>", <?=$r_i["id"]?>, this)'/>
+                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fin (opcional):
+                            <input type='text' class='time' length='5' value='<?=substr($r_i["end"], 11, 5)?>' placeholder='HH:MM' onChange='updateItineraryEnd("<?=$server?>", <?=$r_i["id"]?>, this)'/>
+                            <br/>Localizaci&oacute;n:
+                            <select onChange='togglePlaceRoute(<?=$r_i["id"]?>, this);'>
+                                <option value='place' selected>Un lugar</option>
+                                <option value='route'>Recorrido (opcional)</option>
+                            </select>
+                            <select id='select_itinerary_<?=$r_i["id"]?>_place' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "place", "NUMBER", <?=$r_i["id"]?>, this);'>
+                                <option value=''></option>
+<?php
+                                mysqli_data_seek($q_p, 0);
+                                while ($r_p = mysqli_fetch_array($q_p)){
+                                    $str_sel = "";
+                                    if ($r_i["place"] == $r_p["id"]){
+                                        $str_sel = "selected";
+                                    }
+?>
+                                    <option value='<?=$r_p["id"]?>' <?=$str_sel?>><?=$r_p["name_es"]?></option>
+<?php
+                                }
+?>
+                            </select>
+                            <select id='select_itinerary_<?=$r_i["id"]?>_route' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "route", "NUMBER", <?=$r_i["id"]?>, this);' style='display:none;'>
+                                <option value=''></option>
+<?php
+                                mysqli_data_seek($q_r, 0);
+                                while ($r_r = mysqli_fetch_array($q_r)){
+                                    $str_sel = "";
+                                    if ($r_i["route"] == $r_r["id"]){
+                                        $str_sel = "selected";
+                                    }
+?>
+                                    <option value='<?=$r_r["id"]?>' <?=$str_sel?>><?=$r_r["name"]?></option>
+<?php
+                                }
+?>
+                            </select>
+                            <br/>
+                            <table>
+                                <tr>
+                                    <td class='itinerary_language'>Castellano<br/>(obligatorio)</td>
+                                    <td class='itinerary_name'>
+                                        <input class='itinerary_name' type='text' value='<?=$r_i["name_es"]?>' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "name_es", "VARCHAR", <?=$r_i["id"]?>, this);'/>
+                                    </td>
+                                    <td class='itinerary_description'>
+                                        <textarea class='itinerary_description' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "description_es", "VARCHAR", <?=$r_i["id"]?>, this);'><?=$r_i["description_es"]?></textarea>
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td class='itinerary_language'>Euskera<br/>(opcional)</td>
+                                    <td class='itinerary_name'>
+                                        <input class='itinerary_name' type='text' value='<?=$r_i["name_eu"]?>' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "name_eu", "VARCHAR", <?=$r_i["id"]?>, this);'/>
+                                    </td>
+                                    <td class='itinerary_description'>
+                                        <textarea class='itinerary_description' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "description_eu", "VARCHAR", <?=$r_i["id"]?>, this);'><?=$r_i["description_eu"]?></textarea>
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td class='itinerary_language'>Ingl&eacute;s<br/>(opcional)</td>
+                                    <td class='itinerary_name'>
+                                        <input class='itinerary_name' type='text' value='<?=$r_i["name_en"]?>' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "name_en", "VARCHAR", <?=$r_i["id"]?>, this);'/>
+                                    </td>
+                                    <td class='itinerary_description'>
+                                        <textarea class='itinerary_description' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "description_en", "VARCHAR", <?=$r_i["id"]?>, this);'><?=$r_i["description_en"]?></textarea>
+                                    </td>
+                                </tr>
+                            </table>
+
+                        </div> <!-- .itinerary -->
+<?php
+                    }
+?>
+                </div>
+            </div> <!-- .section -->
+        </div> <!-- #content -->
+    </body>
+</html>
+<?php
+        }
+    }
+?>

+ 0 - 11
www-admin/actividades/edit/edit.php

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

+ 0 - 27
www-admin/actividades/edit/index.php

@@ -1,27 +0,0 @@
-<?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 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 } ?>

+ 151 - 71
www-admin/actividades/index.php

@@ -1,7 +1,10 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
-    $default_host = substr($http_host, 0, strpos($http_host, ':'));
     include("../functions.php");
+    $http_host = $_SERVER["HTTP_HOST"];
+    $proto = getProtocol();
+    $default_host = substr($http_host, 0, strpos($http_host, ":"));
+    $server = "$proto$http_host";
+    $default_server = "$proto$default_host";
     $con = startdb();
     if (!checkSession($con)){
         header("Location: /index.php");
@@ -11,24 +14,26 @@
 ?>
 <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">
+        <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"/>
+        <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"/>
+        <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>
+        <script type='text/javascript' src='/script/ui.js'></script>
     </head>
     <body>
-        <?php include('../toolbar.php'); ?>
+<?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">
+            <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>
@@ -37,69 +42,144 @@
                             <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";
+<?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)){
+?>
+                            <tr>
+                                <td class='activity_column_title'>
+                                    <?=cutText($r['title_es'], 35, '', '')?>
+                                    <br/><?=$r["dat"]?>
+                                </td>
+                                <td class='activity_column_text'><?=str_replace('<br/>', ' ', cutText($r["text_es"], 60, "", ""))?>
+<?php
+                                    //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){
+?>
+                                        <br/>
+<?php
+                                        while ($r_image = mysqli_fetch_array($q_image)){
+?>
+                                            <img src='<?=$default_server?>/img/actividades/miniature/<?=$r_image["image"]?>'\>
+<?php
+                                        }
+                                    }
+
+                                    //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){
+?>
+                                        <ul>
+                                            <li>Sin itinerario.</li>
+                                        </ul>
+<?php
+                                    }
+                                    elseif ($r_itinerary["count"] == 1){
+?>
+                                        <ul>
+                                            <li>1 entrada de itinerario.</li>
+                                        </ul>
+<?php
+                                    }
+                                    else{
+?>
+                                        <ul>
+                                            <li><?=$r_itinerary["count"]?> entradas de itinerario.</li>
+                                        </ul>
+<?php
+                                    }
+?>
+                                </td>
+<?php
                                 $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>";
-                            }
-                            
-                        ?>
+?>
+                                <td class='activity_column_details'>
+                                    <?=$r["ptime"]?>
+                                    <br/>
+                                    Por <?=$r_user["username"]?>
+                                    <br/>
+                                    Comentarios:
+<?php
+                                    if ($r["comments"] == 1){
+                                        $q_comments = mysqli_query($con, "SELECT id FROM activity_comment WHERE activity = $r[id];");
+?>
+                                        S&iacute; (<?=mysqli_num_rows($q_comments)?>)
+<?php
+                                    }
+                                    else{
+?>
+                                        No
+<?php
+                                    }
+?>
+                                    <br/>
+                                    Visible:
+<?php
+                                    if ($r["visible"] == 1){
+?>
+                                        S&iacute;
+<?php                               }
+                                    else{
+?>
+                                        No
+<?php
+                                    }
+?>
+                                </td>
+                                <td class='activity_column_translations'>
+                                    Euskera:
+<?php
+                                    if (strlen($r["text_eu"]) == 0 || $r["text_eu"] == $r["text_es"]){
+?>
+                                        No
+<?php
+                                    }
+                                    else{
+?>
+                                        S&iacute;
+<?php
+                                    }
+?>
+                                    <br/>
+                                    Ingl&eacute;s:
+<?php
+                                    if (strlen($r["text_en"]) == 0 || $r["text_en"] == $r["text_es"]){
+?>
+                                        No
+<?php
+                                    }
+                                    else{
+?>
+                                        S&iacute;
+<?php
+                                    }
+?>
+                                </td>
+                                <td class='activity_column_action'>
+                                    <form method='get' action='/actividades/edit.php'>
+                                        <input type='hidden' name='id' value='<?=$r["id"]?>'/>
+                                        <input type='submit' value='Editar / Traducir'/>
+                                    </form>
+                                    <input type='button' onClick='delete_activity(<?=$r["id"]?>, "<?=$r["title_es"]?>");' value='Borrar'/>
+                                    <!-- TODO: Uncomment when activity comments are implemented.
+                                    <form action='/actividades/moderate/moderate.php?p<?=$r["id"]?>'>
+                                        <input type='submit' value='Moderar comentarios'/>
+                                    </form>
+                                    -->
+                                </td>
+                            </tr>
+<?php
+                        }
+?>
                     </table>
                 </div>
             </div>
         </div>
     </body>
 </html>
-<?php } ?>
+<?php
+    }
+?>

+ 13 - 8
www-admin/actividades/moderate/index.php

@@ -6,7 +6,8 @@
         header("Location: /index.php");
         exit (-1);
     }
-    else{ ?>
+    else{
+?>
 <html>
     <head>
         <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
@@ -23,14 +24,18 @@
         <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>
+<?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>
 </html>
 
-<?php } ?>
+<?php
+    }
+?>

+ 11 - 1
www-admin/actividades/moderate/moderate.php

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

+ 63 - 0
www-admin/actividades/script.js

@@ -0,0 +1,63 @@
+function togglePlaceRoute(id, src){
+    if (src.value == "route"){
+        document.getElementById("select_itinerary_" + id + "_place").style.display = 'none';
+        document.getElementById("select_itinerary_" + id + "_route").style.display = 'inline';
+    }
+    else{
+        document.getElementById("select_itinerary_" + id + "_place").style.display = 'inline';
+        document.getElementById("select_itinerary_" + id + "_route").style.display = 'none';
+    }
+}
+
+function updateActivityDate(server, id, src){
+    // TODO: Validate date.
+    dbUpdate(server, "activity", "date", "DATE", id, src);
+}
+
+function updateItineraryStart(server, id, src){
+    // TODO: Validate date
+    // TODO: Fetch activity date
+    if (dbUpdate(server, "activity_itinerary", "start", "TIME", id, src)){
+        // TODO: Update input value
+    }
+}
+
+function dbUpdate(server, table, column, type, id, src){
+    var value = src.value;
+    var x = new XMLHttpRequest();
+    x.open("GET", server + "/functions/db_update.php?table=" + table + "&column=" + column + "&type=" + type + "&id=" + id + "&value=" + encodeURI(value), true);
+    x.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+    x.onreadystatechange = function(){
+        if(x.readyState == 4){
+            if(x.status == 200){
+                // TODO; Update src!
+                return true;
+            }
+            else{
+                return false;
+            }
+        }
+    }
+}
+
+function deleteItinerary(id){
+    var value = src.value;
+    var x = new XMLHttpRequest();
+    x.open("GET", server + "/functions/db_delete.php?table=itinerary&id=" + id, true);
+    x.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+    x.onreadystatechange = function(){
+        if(x.readyState == 4){
+            if(x.status == 200){
+                document.getElementById("itinerary_" + id).style.display = 'none';
+                return true;
+            }
+            else{
+                return false;
+            }
+        }
+    }
+}
+
+function refreshItinerary(){
+    //TODO
+}

+ 63 - 43
www-admin/actividades/translate/index.php

@@ -6,7 +6,8 @@
         header("Location: /index.php");
         exit (-1);
     }
-    else{?>
+    else{
+?>
 <html>
     <head>
         <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
@@ -27,66 +28,85 @@
             <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";
+<?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;");
+?>
+                    <table class='translation_table'>
+                        <tr>
+                            <th>Nombre</th>
+                            <th>Fecha</th>
+                            <th>Ingles</th>
+                            <th>Euskera</th>
+                        </tr>
+<?php
                         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']){
+?>
+                            <tr>
+                                <td>
+                                    <a href='/actividades/translate/translate.php?id=<?=$r["id"]?>'><?=$r["title_es"]?></a>
+                                </td>
+                                <td><?=$r["dat"]</td>
+<?php
+                                $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['after_eu'] != $r['after_es']){
+                                if ($r['title_eu'] != $r['title_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']){
+                                if ($r['text_en'] != $r['text_es']){
                                     $translated_en ++;
                                 }
-                                if ($r_i['title_eu'] != $r_i['title_es']){
+                                if ($r['text_eu'] != $r['text_es']){
                                     $translated_eu ++;
                                 }
-                                if (strlen($r_i['description_es']) > 0){
+                                if (strlen($r['after_es']) > 0){
                                     $total ++;
-                                    if ($r_i['description_en'] != $r_i['description_es']){
+                                    if ($r['after_en'] != $r['after_es']){
                                         $translated_en ++;
                                     }
-                                    if ($r_i['description_eu'] != $r_i['description_es']){
+                                    if ($r['after_eu'] != $r['after_es']){
                                         $translated_eu ++;
                                     }
                                 }
-                            }
-                            
-                            //Calculate percents
-                            echo "<td>" . intval($translated_en * 100 / $total) . "%</td><td>" . intval($translated_eu * 100 / $total) . "%</td></tr>\n";
+                                $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
+?>
+                                <td><?=intval($translated_en * 100 / $total)?>%</td>
+                                <td><?=intval($translated_eu * 100 / $total)?>%</td>
+                            </tr>
+<?php
                         }
-                        echo "</table>\n";
-                    ?>
+?>
+                        </table>
                 </div>
             </div>
         </div>
     </body>
 </html>
-<?php } ?>
+<?php
+    }
+?>

+ 183 - 71
www-admin/actividades/translate/translate.php

@@ -10,17 +10,17 @@
         $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/");
+            header("Location: /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>
+        <title>Traducir <?=$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"/>
@@ -33,77 +33,189 @@
         <script src="../../ckeditor/ckeditor.js"></script>
     </head>
     <body>
-        <?php include('../../toolbar.php'); ?>
+<?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";
-                ?>
+                <h3>Taducir &#8216;<?=$r["title_es"]?>&#8217;</h3>
+                <div id='translation_instructions' class='entry'>
+                    <h4>C&oacute;mo traducir</h4>
+                    <ul>
+                        <li>Rellena los campos de abajo para el idioma correspondiente (columna de en medio para ingl&eacute;s, derecha para euskera)</li>
+                        <li>No es necesario traducir todos los campos ni todos los idiomas. Traduce solo lo que sepas y quieras.</li>
+                        <li>Al terminar, recuerda pulsar el boton &#8216;Guardar&#8217; al final de la p&acute;gina.</li>
+                        <li>Muchas gracias por tu trabajo!</li>
+                    </ul>
+                </div>
+                <br/><br/>
+                <form method='post' action='/actividades/translate/apply.php'>
+                    <input type='hidden' name='id' value='<?=$r["id"]?>'/>
+                    <table id='table_translate_languages'>
+                        <tr>
+                            <td class='translate_language'>
+                                <div class='entry translation'>
+                                    <h3>Castellano</h3>
+                                    <div class='translate_row_title'>
+                                        <span class='bold'>T&iacute;tulo: </span><?=$r["title_es"]?>
+                                    </div>
+                                    <div class='translate_row_description'>
+                                        <span class='bold'>Descripci&oacute;n</span>
+                                        <br/>
+                                        <p><?=$r["text_es"]?></p>
+                                    </div>
+<?php
+                                    if (strlen($r['after_es']) > 0){
+?>
+                                        <div class='translate_row_after'>
+                                            <span class='bold'>Texto para despu&eacute;s</span>
+                                            <br/>
+                                            <p><?=$r["after_es"]?></p>
+                                        </div>
+<?php
+                                    }
+                                    $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){
+?>
+                                        <div class='translate_row_itinerary'>
+                                            <span class='bold'>Itinerario<br/></span>
+                                            <table id='table_translate_itinerary'>
+<?php
+                                                while ($r_i = mysqli_fetch_array($q_i)){
+?>
+                                                    <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>
+<?php
+                                                }
+?>
+                                            </table>
+                                        </div>
+<?php
+                                    }
+?>
+                                </div>
+                            </td>
+                            <td class='translate_language'>
+                                <div class='entry translation'>
+                                    <h3>Ingl&eacute;s</h3>
+                                    <div class='translate_row_title'>
+                                        <span class='bold'>T&iacute;tulo: </span>
+                                        <input required type='text' name='title_en' required value='<?=$r["title_en"]?>'/>
+                                    </div>
+                                    <div class='translate_row_description'>
+                                        <span class='bold'>Descripci&oacute;n</span>
+                                        <br/>
+                                        <textarea name='text_en' required><?=$r["text_en"]?></textarea>
+                                    </div>
+                                    <script>CKEDITOR.replace('text_en');</script>
+<?php
+                                    if (strlen($r['after_es']) > 0){
+?>
+                                        <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>
+                                        <script>CKEDITOR.replace('after_en');</script>
+<?php
+                                    }
+                                    $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){
+?>
+                                        <div class='translate_row_itinerary'>
+                                            <span class='bold'>Itinerario</span>
+                                            <br/>
+                                            <table id='table_translate_itinerary'>
+<?php
+                                                while ($r_i = mysqli_fetch_array($q_i)){
+?>
+                                                    <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>
+<?php
+                                                }
+?>
+                                            </table>
+                                        </div>
+<?php
+                                    }
+?>
+                                </div>
+                            </td>
+                            <td class='translate_language'>
+                                <div class='entry translation'>
+                                    <h3>Euskera</h3>
+                                    <div class='translate_row_title'>
+                                        <span class='bold'>T&iacute;tulo: </span>
+                                        <input required type='text' name='title_eu' required value='<?=$r["title_eu"]?>'/>
+                                    </div>
+                                    <div class='translate_row_description'>
+                                        <span class='bold'>Descripci&oacute;n</span>
+                                        <br/>
+                                        <textarea name='text_eu' required><?=$r["text_eu"]?></textarea>
+                                    </div>
+                                    <script>CKEDITOR.replace('text_eu');</script>
+<?php
+                                    if (strlen($r['after_es']) > 0){
+?>
+                                        <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>
+                                        <script>CKEDITOR.replace('after_eu');</script>
+<?php
+                                    }
+                                    $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){
+?>
+                                        <div class='translate_row_itinerary'>
+                                            <span class='bold'>Itinerario</span>
+                                            <br/>
+                                            <table id='table_translate_itinerary'>
+<?php
+                                                while ($r_i = mysqli_fetch_array($q_i)){
+?>
+                                                    <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>
+<?php
+                                                }
+?>
+                                            </table>
+                                        </div>
+<?php
+                                    }
+?>
+                                </div>
+                            </td>
+                        </tr>
+                    </table>
+                    <div id='translate_controls'>
+                        <input type='submit' value='Guardar'/>
+                        <input type='button' value='Cancelar y salir' onClick='exitTranslation();'/>
+                    </div>
+                </form>
+?>
             </div>
         </div>
     </body>
 </html>
-<?php } } ?>
+<?php
+    }
+?>

+ 7 - 3
www-admin/ajustes/index.php

@@ -1,7 +1,7 @@
 <?php
+    include("../functions.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");
@@ -29,7 +29,9 @@
         </script>
     </head>
     <body>
-        <?php include('../toolbar.php'); ?>
+<?php
+        include('../toolbar.php');
+?>
         <div id='content'>
             <div class='section'>
                 <h3 class='section_title'>Ajustes</h3>
@@ -55,4 +57,6 @@
         </div>
     </body>
 </html>
-<?php } ?>
+<?php
+    }
+?>

+ 3 - 2
www-admin/blog/add/index.php

@@ -1,5 +1,4 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
     include("../../functions.php");
     $con = startdb();
     if (!checkSession($con)){
@@ -25,7 +24,9 @@
         <script src="../../ckeditor/ckeditor.js"></script>
     </head>
     <body>
-        <?php include('../../toolbar.php'); ?>
+<?php
+        include('../../toolbar.php');
+?>
         <div id='content'>
             <div class="section">
                 <h3 class="section_title">Nuevo post</h3>

+ 1 - 3
www-admin/blog/delete/delete.php

@@ -8,9 +8,7 @@
     }
     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;");
+        mysqli_query($con, "UPDATE post SET visible = 0 WHERE id = $id;");
         version();
     }
 ?>

+ 26 - 33
www-admin/blog/edit/edit.php

@@ -7,7 +7,7 @@
         exit (-1);
     }
     else{
-        
+
         //Get POST data
         $id = mysqli_real_escape_string($con, $_POST['id']);
         $title_es = mysqli_real_escape_string($con, $_POST['title_es']);
@@ -24,48 +24,43 @@
         $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)
+        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')
+        if ($comments == 'off'){
             $comments = 0;
-        else
+           }
+        else{
             $comments = 1;
-        if ($visible == 'off')
+        }
+        if ($visible == 'off'){
             $visible = 0;
-        else
+        }
+        else{
             $visible = 1;
-        if ($admin == 'on')
+        }
+        if ($admin == 'on'){
             $admin = 1;
-        else
+        }
+        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)
@@ -95,15 +90,14 @@
         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');
@@ -118,15 +112,14 @@
                 $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();
+
     }
 ?>

+ 120 - 89
www-admin/blog/edit/index.php

@@ -1,14 +1,14 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
-    $default_host = substr($http_host, 0, strpos($http_host, ':'));
     include("../../functions.php");
+    $server = get_protocol() . $_SERVER['HTTP_HOST'];
+    $default_server = get_protocol() . substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':'));
     $con = startdb();
     if (!checkSession($con)){
         header("Location: /index.php");
         exit (-1);
     }
     else{
-        $id = mysqli_real_escape_string($con, $_GET['p']);
+        $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/");
@@ -36,87 +36,89 @@
 
 <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">
+        <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"/>
+        <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>
+        <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"/>
+        <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>
+        <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">
+            <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();'>
+                    <input type='hidden' name='id' value='<?=$id?>'/>
+                    <div class='entry'>
+                        <div id='lang_tabs'>
                             <table>
                                 <tr>
-                                    <td class="pointer lang_tabs_active" id="lang_tab_es" onclick="showLanguage('es');">
+                                    <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');">
+                                    <td class='pointer' id='lang_tab_eu' onclick='showLanguage("eu");'>
                                         Euskera
                                     </td>
-                                    <td class="pointer" id="lang_tab_en" onclick="showLanguage('en');">
+                                    <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>
+                        <div id='content_lang_es' class='blog_add_language'>
+                            <input type='text' id='title_es' name='title_es' placeholder='Titulo' value='<?=$title_es?>'/><br/><br/>
+                            <textarea name='text_es' id='text_es' placeholder='Texto'><?=$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>
+                        <div id='content_lang_eu' class='blog_add_language' style='display:none;'>
+                            <input type='text' name='title_eu' id='title_eu' placeholder='Titulu' value='<?=$title_eu?>'/><br/><br/>
+                            <textarea name='text_eu' id='text_eu' placeholder='Textua'><?=$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>
+                        <div id='content_lang_en' class='blog_add_language' style='display:none;'>
+                            <input type='text' name='title_en' id='title_en' placeholder='Title' value='<?=$title_en?>'/><br><br/>
+                            <textarea name='text_en' id='text_en' placeholder='Content'><?=$text_en?></textarea>
                             <script>
                                 CKEDITOR.replace('text_es');
                             </script>
                         </div>
                     </div> <!--Entry-->
-                    <div class="entry" id="images">
+                    <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'";
-                                        }
-                                    ?>
+                                <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){
+?>
+                                        <img class='image_upload_preview' id='image_preview_0' src='/img/misc/alpha.png'/>
+                                        <input type='button' style='display:none;' onClick='delete_image(0, image_preview_0, this);' value='Eliminar'/>
+<?php
+                                    }
+                                    else{
+                                        $r_img = mysqli_fetch_array($q_img);
+?>
+                                        <img class='image_upload_preview' style='display:block;' id='image_preview_0' src='<?=$default_server?>/img/blog/miniature/<?=$r_img["image"]?>'/>
+                                        <input type='button' style='display:block;' onClick='delete_image(0, image_preview_0, this);' value='Eliminar'/>
+<?php
+                                    }
+?>
                                     <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"/>
@@ -125,66 +127,95 @@
                             <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'";
-                                        }
-                                    ?>
+<?php
+                                    $q_img = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id AND idx = 1");
+                                    if (mysqli_num_rows($q_img) == 0){
+?>
+                                        <img class='image_upload_preview' id='image_preview_1' src='/img/misc/alpha.png'/>
+                                        <input type='button' style='display:none;' onClick='delete_image(1, image_preview_1, this);' value='Eliminar'/>
+<?php
+                                    }
+                                    else{
+                                        $r_img = mysqli_fetch_array($q_img);
+?>
+                                        <img class='image_upload_preview' style='display:block;' id='image_preview_1' src='<?=$default_server?>/img/blog/miniature/<?=$r_img["image"]?>'/>\n";
+                                        <input type='button' style='display:block;' onClick='delete_image(1, image_preview_1, this);' value='Eliminar'/>
+<?php
+                                    }
+?>
                                     <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'";
-                                        }
-                                    ?>
+<?php
+                                    $q_img = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id AND idx = 2");
+                                    if (mysqli_num_rows($q_img) == 0){
+?>
+                                        <img class='image_upload_preview' id='image_preview_2' src='/img/misc/alpha.png'/>
+                                        <input type='button' style='display:none;' onClick='delete_image(2, image_preview_2, this);' value='Eliminar'/>
+<?php
+                                    }
+                                    else{
+                                        $r_img = mysqli_fetch_array($q_img);
+?>
+                                        <img class='image_upload_preview' style='display:block;' id='image_preview_2' src='<?=$default_server?>/img/blog/miniature/<?=$r_img["image"]?>'/>\n";
+                                        <input type='button' style='display:block;' onClick='delete_image(2, image_preview_2, this);' value='Eliminar'/>
+<?php
+                                    }
+?>
                                     <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"/>
+                                    <input id="image_2" onchange="preview_image(2, this, image_preview_2);" 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'";
-                                        }
-                                    ?>
+<?php
+                                    $q_img = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id AND idx = 3");
+                                    if (mysqli_num_rows($q_img) == 0){
+?>
+                                        <img class='image_upload_preview' id='image_preview_3' src='/img/misc/alpha.png'/>
+                                        <input type='button' style='display:none;' onClick='delete_image(3, image_preview_3, this);' value='Eliminar'/>
+<?php
+                                    }
+                                    else{
+                                        $r_img = mysqli_fetch_array($q_img);
+?>
+                                        <img class='image_upload_preview' style='display:block;' id='image_preview_3' src='<?=$default_server?>/img/blog/miniature/<?=$r_img["image"]?>'/>\n";
+                                        <input type='button' style='display:block;' onClick='delete_image(3, image_preview_3, this);' value='Eliminar'/>
+<?php
+                                    }
+?>
                                     <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"/>
+                                    <input id="image_3" onchange="preview_image(3, 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" <?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/>
+<?php
+                        $v_checked = "";
+                        if ($r['visible'] == 1){
+                            $v_checked = 'checked';
+                        }
+                        $c_checked = "";
+                        if ($r['comments'] == 1){
+                            $c_checked = 'checked';
+                        }
+?>
+                        <label>
+                            <input type="checkbox" name="visible" <?=$v_checked?>/>
+                            Post visible
+                        </label>
+                        <br/><br/>
+                        <label>
+                            <input type="checkbox" name="comments" <?=$c_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-->
+                            <input type="button" value="Previsualizar" onClick="alert(validate_post());"/>
                             <br/>
                             <input type="submit" value="Publicar"/>
                         </div>

+ 35 - 10
www-admin/blog/edit/script.js

@@ -1,3 +1,8 @@
+/**
+ * Validates the form fields.
+ * 
+ * @return true if fields are OK, flase otherwise.
+ */
 function validate_post(){
     var text_es = document.getElementById('text_es').value;
     var text_eu = document.getElementById('text_eu').value;
@@ -6,7 +11,7 @@ function validate_post(){
     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;
@@ -18,7 +23,7 @@ function validate_post(){
         alert("Introduce un texto en castellano");
         return false;
     }
-    
+
     //Titles without texts
     if (title_eu.length > 0 && text_eu.length < 1){
         result = false;
@@ -30,7 +35,7 @@ function validate_post(){
         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;
@@ -46,9 +51,15 @@ function validate_post(){
 }
 
 
-
+/**
+ * Adds HTML tags to format the text in a a textarea.
+ * 
+ * @param textarea The textarea to select the text from.
+ * @param format Format tag: 'italic', 'bold', 'underline', 'stroke', 'link', 'color-[red|green|blue]'
+ * @return Formatted text.
+ */
 function formatText(textarea, format){
-    
+
     var text = textarea.value;
     var selectedText= window.getSelection().toString();
     event.preventDefault();
@@ -58,14 +69,14 @@ function formatText(textarea, format){
         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":
@@ -95,14 +106,21 @@ function formatText(textarea, format){
         default:
             replace = selectedText;
     }
-    
+
     if (selectedText.length  >0 && text != replace){
         text = text.replace(selectedText, replace);
         textarea.value = text;
     }
 }
 
-function preview_image(id, source, target, button) {
+
+/**
+ * Previews an image that has been just uploaded to the server.
+ * @param id ID of the image.
+ * @param source Image resource.
+ * @param target img tag to preview the photo in.
+ */
+function preview_image(id, source, target) {
     var reader = new FileReader();
     reader.readAsDataURL(source.files[0]);
 
@@ -116,9 +134,16 @@ function preview_image(id, source, target, button) {
     };
 };
 
+
+/**
+ * Deletes an uploaded image and it's preview.
+ * @param id ID of the image.
+ * @param target img tag to preview the photo in.
+ * @param button Button used to clear the image.
+ */
 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";
-}
+}

+ 114 - 60
www-admin/blog/index.php

@@ -1,6 +1,9 @@
 <?php
     $http_host = $_SERVER['HTTP_HOST'];
+    $proto = getProtocol();
     $default_host = substr($http_host, 0, strpos($http_host, ':'));
+    $server = "$proto$http_host";
+    $default_server = "$proto$default_host";
     include("../functions.php");
     $con = startdb();
     if (!checkSession($con)){
@@ -25,7 +28,9 @@
         <script type="text/javascript" src="/script/ui.js"></script>
     </head>
     <body>
-        <?php include('../toolbar.php'); ?>
+<?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>
@@ -38,70 +43,119 @@
                             <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";
+<?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)){
+?>
+                            <tr>
+                                <td class='blog_column_title'>
+                                    <a target='blank' href='<?=$default_server?>/blog/<?=$r["permalink"]?>'><?=cutText($r["title_es"], 35, "", "")?></a>
+                                </td>
+                                <td class='blog_column_text'>
+                                    <?=str_replace("<br/>", " ", cutText($r["text_es"], 60, "", ""))?>
+<?php
+                                    $q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $r[id] ORDER BY idx;");
+                                    if (mysqli_num_rows($q_image) > 0){
+?>
+                                        <br/>
+<?php
+                                        while ($r_image = mysqli_fetch_array($q_image)){
+?>
+                                            <img src='<?=$default_server?>/img/blog/miniature/<?=$r_image["image"]?>'/>
+<?php
+                                        }
+                                    }
+?>
+                                </td>
+<?php
                                 $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>";
-                            }
-                            
-                        ?>
+?>
+                                <td class='blog_column_details'>
+                                    <?=$r["ptime"]?><br/>
+                                    Por <?=$r_user["username"]?><br/>
+                                    Comentarios:
+<?php
+                                    if ($r['comments'] == 1){
+                                        $q_comments = mysqli_query($con, "SELECT id FROM post_comment WHERE post = $r[id];");
+?>
+                                        S&iacute; (<?=mysqli_num_rows($q_comments)?>)
+<?php
+                                    }
+                                    else{
+?>
+                                        No
+<?php
+                                    }
+                                    echo "<br/>Visible: ";
+                                    if ($r['visible'] == 1){
+?>
+                                        S&iacute;
+<?php
+                                    }
+                                    else{
+?>
+                                        No
+<?php
+                                    }
+                                    {
+                                        $q_comments = mysqli_query($con, "SELECT id FROM post_comment WHERE post = $r[id];");
+?>
+                                        S&iacute; (<?=mysqli_num_rows($q_comments)?>)
+<?php
+                                    }
+                                    else{
+?>
+                                        No
+<?php
+                                    }
+?>
+                                </td>
+                                <td class='blog_column_translations'>
+<?php
+                                    $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
+?>
+                                    Ingl&eacute;s: <?=intval($translated_en * 100 / $total)?>%
+                                    <br/>
+                                    Euskera: <?=intval($translated_eu * 100 / $total)?>%
+                                </td>
+                                <td class='blog_column_action'>
+                                    <form method='get' action='<?=server?>/blog/edit/index.php'>
+                                        <input type='submit' value='Editar / Traducir'/>
+                                        <input type='hidden' name='p' value='<?=$r["id"]?>'/>
+                                    </form>
+                                    <input type='button' onClick='delete_post(<?=$r["id"]?>, "<?=$r["title_es"]?>");' value='Borrar'/>
+                                    <form action='<?=$server?>/blog/moderate/moderate.php?p=<?=$r["id"]?>'>
+                                        <input type='submit' value='Moderar comentarios'/>
+                                    </form>
+                                </td>
+                            </tr>";
+                        }
+?>
                     </table>
                 </div>
             </div>
         </div>
     </body>
 </html>
-<?php } ?>
+<?php
+    }
+?>

+ 14 - 5
www-admin/blog/moderate/index.php

@@ -1,11 +1,15 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
     include("../../functions.php");
     $con = startdb();
     if (!checkSession($con)){
         header("Location: /index.php");
         exit (-1);
     }
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
 ?>
 
 <html>
@@ -24,12 +28,17 @@
         <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>
+<?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>
 </html>
+<?php
+    }
+?>

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

@@ -1,23 +1,23 @@
+
+/**
+ * Deletes a post from the database.
+ * 
+ * @param id Post id.
+ * @param title Post title.
+ */
 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
+        if (window.XMLHttpRequest){
             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();
     }
-}
+}

+ 15 - 16
www-admin/blog/translate/apply.php

@@ -1,38 +1,37 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
+    $http_host = $_SERVER["HTTP_HOST"];
     include("../../functions.php");
-    $con = startdb('rw');
+    $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']);
-    
+    $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']){
+        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']){
+        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']){
+        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']){
+        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");    
+
+    header("Location: /blog/translate/index.php");
 ?>

+ 54 - 30
www-admin/blog/translate/index.php

@@ -1,12 +1,12 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
     include("../../functions.php");
     $con = startdb();
     if (!checkSession($con)){
         header("Location: /index.php");
         exit (-1);
     }
-    else{?>
+    else{
+?>
 <html>
     <head>
         <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
@@ -22,42 +22,66 @@
         <script type="text/javascript" src="/script/ui.js"></script>
     </head>
     <body>
-        <?php include('../../toolbar.php'); ?>
+<?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";
+<?php
+                    $q = mysqli_query($con, "SELECT * FROM post;");
+?>
+                    <table class='translation_table'>
+                        <tr>
+                            <th>Nombre</th>
+                            <th>Ingles</th>
+                            <th>Euskera</th>
+                        </tr>
+<?php
                         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";
+?>
+                            <tr>
+                                <td>
+                                    <a href='/blog/translate/translate.php?id=<?=$r["id"]?>'><?=$r["title_es"]?></a>
+                                </td>
+<?php
+                                $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
+?>
+                                <td>
+                                    <?=intval($translated_en * 100 / $total)?>%
+                                </td>
+                                <td>
+                                    <?=intval($translated_eu * 100 / $total)?>%
+                                </td>
+                            </tr>
+<?php
                         }
-                        echo "</table>\n";
-                    ?>
+?>
+                    </table>
                 </div>
             </div>
         </div>
     </body>
 </html>
-<?php } ?>
+<?php
+    }
+?>

+ 88 - 46
www-admin/blog/translate/translate.php

@@ -1,5 +1,6 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
+    
+    = $_SERVER['HTTP_HOST'];
     include("../../functions.php");
     $con = startdb();
     if (!checkSession($con)){
@@ -10,65 +11,106 @@
         $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/");
+            header("Location: /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>
+        <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 <?=$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"/>
+        <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"/>
+        <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>
+        <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'); ?>
+<?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";
-                ?>
+                <h3>Taducir &#8216;<?=$r["title_es"]?>&#8217;</h3>
+                <div id='translation_instructions' class='entry'>
+                    <h4>C&oacute;mo traducir</h4>
+                    <ul>
+                        <li>Rellena los campos de abajo para el idioma correspondiente (columna de en medio para ingl&eacute;s, derecha para euskera)</li>
+                        <li>No es necesario traducir todos los campos ni todos los idiomas. Traduce solo lo que sepas y quieras.</li>
+                        <li>Al terminar, recuerda pulsar el boton &#8216;Guardar&#8217; al final de la p&acute;gina.</li>
+                        <li>Muchas gracias por tu trabajo!</li>
+                    </ul>
+                </div>
+                <br/><br/>
+                <form method='post' action='/blog/translate/apply.php'>
+                    <input type='hidden' name='id' value='<?=$r["id"]?>'/>
+                    <table id='table_translate_languages'>
+                        <tr>
+                            <td class='translate_language'>
+                                <div class='entry translation'>
+                                    <h3>Castellano</h3>
+                                    <div class='translate_row_title'>
+                                        <span class='bold'>T&iacute;tulo: </span>
+                                        <?=$r["title_es"]?>
+                                    </div>
+                                    <div class='translate_row_description'>
+                                        <span class='bold'>Descripci&oacute;n</span>
+                                        <br/>
+                                        <p><?=$r["text_es"]?></p>
+                                    </div>
+                                </div>
+                            </td>
+                            <td class='translate_language'>
+                                <div class='entry translation'>
+                                    <h3>Ingl&eacute;s</h3>
+                                    <div class='translate_row_title'>
+                                        <span class='bold'>T&iacute;tulo: </span>
+                                        <input type='text' name='title_en' required value='<?=$r["title_en"]?>'/>
+                                    </div>
+                                    <div class='translate_row_description'>
+                                        <span class='bold'>Descripci&oacute;n</span>
+                                        <br/>
+                                        <textarea  name='text_en' required><?=$r["text_en"]?></textarea>
+                                    </div>
+                                    <script>CKEDITOR.replace('text_en');</script>
+                                </div>
+                            </td>
+                            <td class='translate_language'>
+                                <div class='entry translation'>
+                                    <h3>Euskera</h3>
+                                    <div class='translate_row_title'>
+                                        <span class='bold'>T&iacute;tulo: </span>
+                                        <input required type='text' name='title_eu' required value='<?=$r["title_eu"]?>'/>
+                                    </div>
+                                    <div class='translate_row_description'>
+                                        <span class='bold'>Descripci&oacute;n</span>
+                                        <br/>
+                                        <textarea name='text_eu' required><?=$r["text_eu"]?></textarea>
+                                    </div>
+                                    <script>CKEDITOR.replace('text_eu');</script>
+                                </div>
+                            </td>
+                        </tr>
+                    </table>
+                    <div id='translate_controls'>
+                        <input type='submit' value='Guardar'/>
+                        <input type='button' value='Cancelar y salir' onClick='exitTranslation();'/>
+                    </div>
+                </form>
+?>
             </div>
         </div>
     </body>
 </html>
-<?php } } ?>
+<?php
+        }
+    }
+?>

+ 66 - 0
www-admin/css/actividades.css

@@ -306,3 +306,69 @@ div#translate_controls input{
     width:        100%;
     margin-top:    1em;
 }
+
+
+/* /actividades/edit.php */
+
+input#date{
+    width: 8em;
+}
+
+input#city{
+    width: 16em;
+}
+
+div.activity_add_language h4{
+    margin-left: 1em;
+}
+
+div.activity_add_language input[type="text"], div.cke{
+    width: 80%;
+    margin: 0 10% 3em 10%;
+}
+
+div.itinerary{
+    margin: 1em;
+    border-radius: 0.5em;
+    padding: 0.5em;
+    border-left: solid 0.4em #0078ff;
+}
+
+div.itinerary input.delete_itinerary{
+    float: right;
+    border: 0.2em solid #ff7800;
+    background-color: #674512;
+}
+
+div.itinerary input.time{
+    width: 5em;
+}
+
+div.itinerary table{
+    width: 100%;
+}
+
+div.itinerary table td{
+    border: 0.1em solid #aaaaaa;
+}
+
+div.itinerary table td.itinerary_language{
+    width: 15%;
+}
+
+div.itinerary table td.itinerary_name{
+    width: 25%;
+}
+
+div.itinerary table td.itinerary_description{
+    width: 60%;
+}
+
+div.itinerary table td textarea.itinerary_description, input.itinerary_name{
+    width: 100%;
+}
+
+div.itinerary table td textarea.itinerary_description{
+    height: 4em;
+    resize: vertical;
+}

+ 22 - 0
www-admin/css/m/actividades.css

@@ -0,0 +1,22 @@
+/* /actividades/edit.php */
+
+input#date{
+    width: 8em;
+}
+
+input#city{
+    width: 16em;
+}
+
+div.activity_add_language h4{
+    margin-left: 1em;
+}
+
+div.activity_add_language input[type="text"], div.cke{
+    width: 90%;
+    margin: 0 5% 4em 5%;
+}
+
+div.itinerary table td textarea.itinerary_description{
+    resize: none;
+}

+ 9 - 218
www-admin/css/m/ui.css

@@ -3,163 +3,11 @@
 * show elements for mobile.               *
 ******************************************/
 .mobile{
-    display:    initial;
+    display: initial;
 }
 
 .desktop{
-    display:    none !important;
-}
-
-
-/******************************************
-* Styles for the site header that is      *
-* always visible.                         *
-******************************************/
-
-/* Header top container */
-div#header_m{
-    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%;
-}
-
-div#header_menu_m div{
-    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;
-}
-
-div#header_menu_m div#header_m_slider img{
-    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
-}
-
-div#header_menu_m div#header_m_title span {
-    display:    block;
-    margin:        0.4em;
-}
-
-div#header_menu_m div#header_m_title span img{
-    vertical-align:    middle;
-}
-
-div#header_menu_m div#header_m_title img{
-    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;
-}
-
-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;
-}
-
-/******************************************
-* Styles for the site footer that is      *
-* always visible.                         *
-******************************************/
-
-/* Table containing the footer elemnts */
-div#footer div#footer_table{
-    display:    block;
-}
-
-div#footer div#footer_table div.tr{
-    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;
-}
-
-/* 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;
-}
-
-img.lang:hover{
-     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;
-}
-
-img.app:hover{
-    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;
-}
-
-img.footer_social_icon:hover{
-    -webkit-filter:    drop-shadow(0 0 0.2em #444444);/*NONE*/
-    filter:            drop-shadow(0 0 0.2em #444444);/*NONE*/
+    display: none !important;
 }
 
 
@@ -171,70 +19,13 @@ img.footer_social_icon:hover{
 
 /* Content */
 div#content{
-    margin:        auto;
-    width:        95%;
-    max-width:    initial;
-    min-width:    initial;
+    margin: 2em auto auto 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%
-}
-
-div#ad h3{
-    margin-top:    0.3em;
-}
-
-div#ad div#ad_details{
-    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;
-}
-
-div#ad div.entry div#ad_image_container{
-    max-height:    9.5em;
-    margin:        0.5em 0.6em 0.5em 0.6em;
-    text-align:    center;
-}
-
-div#ad div.entry a{
-    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;
+div#toolbar img{
+    margin-bottom: -1em;
+    opacity: 0.3;
 }

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

@@ -145,10 +145,10 @@ img.slid{
 
 /* 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 */
@@ -211,14 +211,14 @@ div#toolbar img{
 }
 
 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: 100%;
+    height: 100%;
+    margin-left: auto;
+    margin-right: auto;
+    border-spacing: 0;
+    border-collapse: collapse;
+    margin: 0;
+    table-layout: fixed;
 }
 
 div#toolbar td{

+ 27 - 25
www-admin/estadisticas/web/index.php

@@ -1,6 +1,4 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
-    $default_host = substr($http_host, 0, strpos($http_host, ':'));
     include("../../functions.php");
     $con = startdb();
     if (!checkSession($con)){
@@ -11,42 +9,44 @@
 ?>
 <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">
+        <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"/>
+        <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"/>
+        <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>
+        <script type='text/javascript' src='/script/ui.js'></script>
     </head>
     <body>
-        <?php include('../../toolbar.php'); ?>
+<?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);
-                            ?>
+<?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>
+                                    <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 -->
@@ -172,4 +172,6 @@
         </div> <!-- #content -->
     </body>
 </html>
-<?php } ?>
+<?php
+    }
+?>

BIN
www-admin/font/FreeSans.ttf


BIN
www-admin/font/FreeSansBold.ttf


BIN
www-admin/font/FreeSansBoldOblique.ttf


BIN
www-admin/font/FreeSansOblique.ttf


BIN
www-admin/font/Vera.ttf


BIN
www-admin/font/VeraBI.ttf


BIN
www-admin/font/VeraBd.ttf


BIN
www-admin/font/VeraIt.ttf


BIN
www-admin/font/VeraMoBI.ttf


BIN
www-admin/font/VeraMoBd.ttf


BIN
www-admin/font/VeraMoIt.ttf


BIN
www-admin/font/VeraMono.ttf


BIN
www-admin/font/VeraSe.ttf


BIN
www-admin/font/VeraSeBd.ttf


BIN
www-admin/font/texgyreadventor-bold.otf


BIN
www-admin/font/texgyreadventor-bolditalic.otf


BIN
www-admin/font/texgyreadventor-italic.otf


BIN
www-admin/font/texgyreadventor-regular.otf


+ 63 - 33
www-admin/functions.php

@@ -2,8 +2,7 @@
 
     $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://';
@@ -43,32 +42,32 @@
         ?>
         */
         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       * 
+    * readable string, deppending o the specified       *
     * language.                                         *
     * @params:                                          *
     *    strdate: (string): Date string.                *
@@ -79,7 +78,7 @@
     *    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);
@@ -123,10 +122,11 @@
         }
         return $str;
     }
-    
+
+
     /****************************************************
     * This function turns a date string into a human    *
-    * readable string, deppending o the specified       * 
+    * readable string, deppending o the specified       *
     * language. It is designed to be used for festival  *
     * days only, since it doesnt return the weekday.    *
     * @params:                                          *
@@ -137,7 +137,7 @@
     *                          language preferences.    *
     * @return: (string array) List of the languages     *
     *          offered, sorted by prefference.          *
-    ****************************************************/    
+    ****************************************************/
     function formatFestivalDate($strdate, $lang){
         $date = strtotime($strdate);
         $month = date('n', $date);
@@ -158,10 +158,10 @@
         }
         return $str;
     }
-    
+
     /****************************************************
     * This function closes all the opened HTML tags in  *
-    * a given string.                                   * 
+    * a given string.                                   *
     *                                                   *
     * @params:                                          *
     *    html: (string): The string with HTML tags      *
@@ -184,11 +184,13 @@
             }
         }
         return $html;
-    } 
-    
+    }
+
+
+
     /****************************************************
     * Text shortener. Given a string, it trims in the   *
-    * proximity of the desired streng, ut to the next   * 
+    * proximity of the desired streng, ut to the next   *
     * white character. If indicated, it will append a   *
     * link to the full text.                            *
     *                                                   *
@@ -212,7 +214,8 @@
         }
         return $cut;
     }
-    
+
+
     /****************************************************
     * Generates a URL-valid string from a regular one.  *
     *                                                   *
@@ -231,7 +234,8 @@
         $str = str_replace(' ', '-', $str);
         return $str;
     }
-    
+
+
     function login($con, $user, $pass){
         session_start();
         $q = mysqli_query($con,"SELECT id, salt, username AS username, sha1(salt) AS s FROM user WHERE (lower(username) = lower('$user') OR lower(email) = lower('$user')) AND password = sha1(concat('$pass', sha1(salt)));");
@@ -243,11 +247,12 @@
             return true;
         }
         else{
-            error_log("Invalid login. username = $_SESSION[name], id = $_SESSION[id]");
+            error_log("Invalid login. username = $user, id = $id");
             return false;
         }
     }
-    
+
+
     function checkSession($con){
         session_start(['cookie_lifetime' => 1800,]);
         $qr = mysqli_query($con, "SELECT id FROM user WHERE id = '$_SESSION[id]' AND sha1(salt) = '$_SESSION[salt]';");
@@ -259,17 +264,42 @@
             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";');
+    function db_update($con, $s_table, $s_column, $type, $s_value, $id){
+        $table = mysqli_real_escape_string($con, $s_table);
+        $column = mysqli_real_escape_string($con, $s_column);
+        switch (strtoupper($type)){
+            case "NULL":
+                $value = "null";
+                break;
+            case "VARCHAR":
+                $value = "'" . mysqli_real_escape_string($con, $s_value) . "'";
+                break;
+            case "NUMBER":
+                $value = intval(mysqli_real_escape_string($con, $s_value));
+                break;
+            case "DATE":
+                if (!preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) \d{2}:\d{2}:\d{2}$/",$s_value)){
+                    return -2;
+                }
+                $value = "str_to_date('$s_value', '%Y-%m-%d')";
+                break;
+            case "TIME":
+                if (!preg_match("^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) (0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$",$s_value)){
+                    return -2;
+                }
+                $value = "str_to_date('$s_value', '%Y-%m-%d %H:%i:%s')";
+                break;
+            default:
+                return -1;
+        }
+        $q = mysqli_query($con, "UPDATE $table SET $column = $value WHERE id = $id;");
+        return 0;
+    }
+
+    function db_delete($con, $s_table, $id){
+        $table = mysqli_real_escape_string($con, $s_table);
+        $q = mysqli_query($con, "DELETE FROM $table WHERE id = $id;");
+        return 0;
     }
 ?>
-    

+ 15 - 0
www-admin/functions/db_update.php

@@ -0,0 +1,15 @@
+<?php
+    include("../functions.php");
+    $con = startdb("rw");
+    if (!checkSession($con)){
+        error_log("Error updating $_GET[table].$_GET[column] : Session has expired.");
+        http_response_code(403); // Forbidden
+        exit (-1);
+    }
+    else{
+        if (db_update($con, $_GET["table"], $_GET["column"], $_GET["type"], $_GET["value"], $_GET["id"]) != 0){
+            error_log("Error updating $_GET[table].$_GET[column] ($_GET[type]) to '$_GET[value] for id $_GET[id]' : Bad request");
+            http_response_code(400); // Bad request
+        }
+    }
+?>

+ 0 - 17
www-admin/galeria/edit/index.php

@@ -1,17 +0,0 @@
-<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>
-</html>

+ 81 - 38
www-admin/galeria/index.php

@@ -1,6 +1,4 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
-    $default_host = substr($http_host, 0, strpos($http_host, ':'));
     include("../functions.php");
     $con = startdb();
     if (!checkSession($con)){
@@ -24,7 +22,9 @@
         <script type="text/javascript" src="/script/ui.js"></script>
     </head>
     <body>
-        <?php include('../toolbar.php'); ?>
+<?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>
@@ -36,46 +36,89 @@
                             <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");
+<?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)){
+?>
+                            <tr>
+                                <td class='album_column_title'>
+                                    <?=cutText($r["title_es"], 35, "", "")?>"<br/>
+                                    <?=$r["dat"]?>
+                                    <br/><?=str_replace("<br/>", " ", cutText($r["text_es"], 60, "", ""))?>
+                                </td>
+<?php
                                 $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>");
-                            }
-                            
-                        ?>
+?>
+                                <td class='activity_column_details'><?=$r["ptime"]?><br/>
+<?php
+                                    //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);
+?>
+                                    <?=$r_photos["cnt"]?> fotos.<br/>
+                                    Por <?=$r_user["username"]?><br/>
+                                    <br/>P&uacute;blico:
+<?php
+                                        if ($r['open'] == 1){
+?>
+                                                S&iacute;
+<?php
+                                        }
+                                        else{
+?>
+                                                No
+<?php
+                                        }
+?>
+                                </td>
+                                <td class='gallery_column_translations'>
+                                    Euskera:
+<?php
+                                    if (strlen($r['description_eu']) == 0 || $r['description_eu'] == $r['description_es']){
+?>
+                                        No
+<?php
+                                    }
+                                    else{
+?>
+                                        S&iacute;
+<?php
+                                    }
+?>
+                                    <br/>
+                                    Ingl&eacute;s:
+<?php
+                                    if (strlen($r['description_en']) == 0 || $r['description_en'] == $r['description_es']){
+?>
+                                        No
+<?php
+                                    }
+                                    else{
+?>
+                                        S&iacute;
+<?php
+                                    }
+?>
+                                </td>
+                                <td class='album_column_action'>
+                                    <form action='/album/edit/edit.php?p=<?=$r["id"]?>'>
+                                        <input type='submit' value='Editar / Traducir'/>
+                                    </form>
+                                    <input type='button' onClick='delete_album(<?=$r["id"]?>, "<?=$r["title_es"]?>");' value='Borrar'/>
+                                    <form action='/album/moderate/moderate.php?p=<?=$r["id"]?>'>
+                                        <input type='submit' value='Moderar comentarios'/>
+                                    </form>
+                                </td>
+                            </tr>
+                        }
+?>
                     </table>
                 </div>
             </div>
         </div>
     </body>
 </html>
-<?php } ?>
+<?php
+    }
+?>

+ 0 - 17
www-admin/galeria/moderate/index.php

@@ -1,17 +0,0 @@
-<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>
-</html>

+ 4 - 5
www-admin/galeria/translate/apply.php

@@ -1,5 +1,4 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
     include("../../functions.php");
     $con = startdb('rw');
     if (!checkSession($con)){
@@ -12,7 +11,7 @@
     $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;
@@ -26,12 +25,12 @@
         $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;");
@@ -47,7 +46,7 @@
         }
         version();
     }
-    
+
     //Update photo entries
     for ($i = 0; $i < $total_i; $i ++){
         $q_i = mysqli_query($con, "SELECT * FROM photo WHERE id = $p_id[$i];");

+ 61 - 45
www-admin/galeria/translate/index.php

@@ -6,79 +6,95 @@
         header("Location: /index.php");
         exit (-1);
     }
-    else{?>
+    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">
+        <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"/>
+        <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"/>
+        <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>
+        <script type='text/javascript' src='/script/ui.js'></script>
     </head>
     <body>
-        <?php include('../../toolbar.php'); ?>
+<?php
+        include("../../toolbar.php");
+?>
         <div id='content'>
             <div class='section'>
                 <h3>Albums</h3>
                 <div class='entry'>
-                    <?php
+                    <table class='translation_table'>
+                        <tr>
+                            <th>Nombre</th>
+                            <th>Ingles</th>
+                            <th>Euskera</th>
+                        </tr>
+<?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']){
+?>
+                            <tr>
+                                <td>
+                                    <a href='/galeria/translate/translate.php?id=<?=$r["id"]?>'><?=$r["title_es"]?></a>
+                                </td>
+<?php
+                                $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['description_eu'] != $r['description_es']){
+                                if ($r["title_eu"] != $r["title_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["description_es"]) > 0){
+                                    if ($r["description_en"] != $r["description_es"]){
+                                        $translated_en ++;
+                                    }
+                                    if ($r["description_eu"] != $r["description_es"]){
+                                        $translated_eu ++;
+                                    }
                                 }
-                                if (strlen($r_i['description_es']) > 0){
+                                $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['description_en'] != $r_i['description_es']){
+                                    if ($r_i["title_en"] != $r_i["title_es"]){
                                         $translated_en ++;
                                     }
-                                    if ($r_i['description_eu'] != $r_i['description_es']){
+                                    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";
+?>
+                                <td><?=intval($translated_en * 100 / $total)?>%</td>
+                                <td><?=intval($translated_eu * 100 / $total)?>%</td>
+                            </tr>\n";
                         }
-                        echo "</table>\n";
-                    ?>
+                    </table>
+?>
                 </div>
             </div>
         </div>
     </body>
 </html>
-<?php } ?>
+<?php
+    }
+?>

+ 6 - 3
www-admin/index.php

@@ -6,7 +6,8 @@
         header("Location: /main.php");
         exit (-1);
     }
-    else{?>
+    else{
+?>
 <html>
     <head>
         <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
@@ -30,7 +31,7 @@
                             <td><input name="user" type="text"/></td>
                         </tr>
                         <tr>
-                            <td>Contrasena:</td>
+                            <td>Contrase&ntilde;a:</td>
                             <td><input name="pass" type="password"/></td>
                         </tr>
                         <tr>
@@ -42,4 +43,6 @@
         </div>
     </body>
 </html>
-<?php } ?>
+<?php
+    }
+?>

+ 0 - 1
www-admin/lablanca/add/add.php

@@ -1 +0,0 @@
- 

+ 0 - 17
www-admin/lablanca/add/index.php

@@ -1,17 +0,0 @@
-<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>
-</html>

+ 198 - 106
www-admin/lablanca/calculate.php

@@ -1,6 +1,4 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
-    $default_host = substr($http_host, 0, strpos($http_host, ':'));
     include("../functions.php");
     $con = startdb();
     if (!checkSession($con)){
@@ -11,129 +9,221 @@
         $year = date("Y");
 
         //Get data to calculate
-        $section = mysqli_real_escape_string($con, $_GET['section']);
+        $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";
+            case "header":
+?>
+                <h4>Paso 1: Cabecera de la p&aacute;gina de fiestas</h4>";
+                Estado:
+<?php
                 $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";
+?>
+                    <span class='status_red'> No se ha definido una cabecera</span>
+<?php
                 }
                 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";
+?>
+                    <ul>
+                        <li>
+                            Texto castellano: <span class='status_green'>OK</span>
+                        </li>
+                        <li>
+                            Traducci&oacute;n ingl&eacute;s:
+<?php
+                            if ($r['text_en'] == $r['text_es'] || strlen($r['text_en']) == 0){
+?>
+                                <span class='status_yellow'>NO</span>
+<?php
+                            }
+                            else{
+?>
+                                <span class='status_green'>OK</span>
+<?php
+                            }
+?>
+                        </li>
+                        <li>
+                            Traducci&oacute;n euskera:
+<?php
+                            if ($r['text_eu'] == $r['text_es'] || strlen($r['text_eu']) == 0){
+?>
+                                <span class='status_yellow'>NO</span>
+<?php
+                            }
+                            else{
+?>
+                                <span class='status_green'>OK</span>
+<?php
+                            }
+?>
+                        </li>
+                        <li>
+                            Cartel:
+<?php
+                            if (strlen($r['img']) == 0){
+?>
+                                <span class='status_yellow'>NO</span>
+<?php
+                            }
+                            else{
+?>
+                                <span class='status_green'>OK</span>
+<?php
+                            }
+?>
+                        </li>
+                    </ul>
+<?php
                 }
                 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 = '';
+            case "pricesprogress":
+?>
+                Estado:
+                <ul>
+                    <li>
+<?php
+                        $q = mysqli_query($con, "SELECT * FROM festival_day WHERE year(date) = '$year' AND price > 0;");
+                        if (mysqli_num_rows($q) != 6){
+?>
+                            <span class='status_red'> No se han establecido precios</span>
+<?php
                         }
                         else{
-                            $en = $r_offer['name_en'];
-                        }
-                        if ($r_offer['name_eu'] == $r_offer['name_es']){
-                            $eu = '';
+?>
+                            "Precios establecidos: <span class='status_green'>OK</span>
+<?php
                         }
-                        else{
-                            $eu = $r_offer['name_eu'];
+?>
+                    </li>
+                    <li>
+<?php
+                        $prices_wrong = 0;
+                        while ($r = mysqli_fetch_array($q)){
+                            if ($r['price'] <= 0 || $r['price'] > 200){
+                                $prices_wrong ++;
+                            }
                         }
-                        if ($r_offer['description_en'] == $r_offer['description_es']){
-                            $den = '';
+                        if ($prices_wrong == 0){
+?>
+                            Precios v&aacute;lidos: 
+                            <span class='status_green'><?=(6 - $prices_wrong)?>/6</span>
+<?php
                         }
                         else{
-                            $den = $r_offer['description_en'];
+?>
+                            Precios v&aacute;lidos: 
+                            <span class='status_red'><?=(6 - $prices_wrong)?>/6</span>
+<?php
                         }
-                        if ($r_offer['description_eu'] == $r_offer['description_es']){
-                            $deu = '';
+?>
+                    </li>
+                    <li>
+<?php
+                        $q = mysqli_query($con, "SELECT id FROM festival_offer WHERE year = $year AND price > 0;");
+                        if (mysqli_num_rows($q) > 0){
+?>
+                            N&uacute;mero de ofertas: <span class='status_green'><?=mysqli_num_rows($q)?></span>
+<?php
                         }
                         else{
-                            $deu = $r_offer['description_eu'];
+?>
+                            N&uacute;mero de ofertas: <span class='status_yellow'><?=mysqli_num_rows($q)?></span>
+<?php
+                        }
+?>
+                    </li>
+                </ul>
+<?php
+            break;
+
+            //Calculate offers window
+            case "pricesoffers":
+?>
+                <h4>Ofertas:</h4>
+<?php
+                $q_offer = mysqli_query($con, "SELECT * FROM festival_offer WHERE year = $year");
+                if (mysqli_num_rows($q_offer) == 0){
+?>
+                    No se han configurado ofertas<br/>
+<?php
+                }
+                else{
+?>
+                    <table id='offers'>
+                        <tr>
+                            <th>Castellano</th>
+                            <th>Ingl&eacute;s</th>
+                            <th>Euskera</th>
+                            <th>D&iacute;as</th>
+                            <th>Precio</th>
+                            <th>Acci&oacute;n</th>
+                        </tr>
+<?php
+                        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"];
+                            }
+?>
+                            <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/>
+                                    <textarea onchange='updateField("festival_offer", "description_es", this.value, <?=$r_offer["id"]?>, "text", false);'><?=$r_offer["description_es"]?></textarea>
+                                </td>
+                                <td class='large'>
+                                    <input type='text' value='<?=$en?>' onchange='updateField("festival_offer", "name_en", this.value, <?=$r_offer["id"]?>);'/><br/>
+                                    <textarea onchange='updateField("festival_offer", "description_en", this.value, <?=$r_offer["id"]?>);'><?=$den?></textarea>
+                                </td>
+                                <td class='large'>
+                                    <input type='text' value='<?=$eu?>' onchange='updateField("festival_offer", "name_eu", this.value, <?=$r_offer["id"]?>);'/><br/>
+                                    <textarea onchange='updateField("festival_offer", "description_eu", this.value, <?=$r_offer["id"]?>);'><?=$deu?></textarea>
+                                </td>
+                                <td class='small'>
+                                    <input type='number' value='<?=$r_offer["days"]?>' onchange='updateField("festival_offer", "days", this.value, <?=$r_offer["id"]?>, "number", false);'/>
+                                </td>
+                                <td class='small'>
+                                    <input type='number' value='<?=$r_offer["price"]?>' onchange='updateField("festival_offer", "price", this.value, <?=$r_offer["id"]?>, "number", false);'/>&euro;
+                                </td>
+                                <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?> -->
+<?php
                         }
-                        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";
+?>
+                     </table>
+<?php
                 }
-                echo "<input type='button' value='A&ntilde;adir nuevo' onClick='newOffer();'/>\n";
+?>
+                <input type='button' value='A&ntilde;adir nuevo' onClick='newOffer();'/>
+<?php
                 break;
             case 'schedule':
                 $day = $_GET('day');
@@ -155,11 +245,13 @@
                         exit(-1);
                 }
                 //Load schedule tables
-                echo "<table>\n";
-                echo "<tr>\n";
-                echo "<th></th>";
-                echo "<tr/>\n";
-                echo "</table>\n";
+?>
+                <table>
+                    <tr>
+                        <th></th>
+                    <tr/>
+                </table>
+<?php
                 break;
         }
     }

+ 0 - 1
www-admin/lablanca/delete/delete.php

@@ -1 +0,0 @@
- 

+ 0 - 1
www-admin/lablanca/edit/edit.php

@@ -1 +0,0 @@
- 

+ 0 - 15
www-admin/lablanca/edit/index.php

@@ -1,15 +0,0 @@
-<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>
-</html>

+ 12 - 13
www-admin/lablanca/execute.php

@@ -1,28 +1,26 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
-    $default_host = substr($http_host, 0, strpos($http_host, ':'));
     include("../functions.php");
-    $con = startdb('rw');
+    $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']));
+        $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'){
+        if ($table != "festival"  $table != "festival_day" && $table != "festival_event" && $table != "festival_event_image" && $table != "festival_offer"){
             //TODO: If I got here, somebody is doing something nasty. Log it.
-            exit (-1);
+            exit (-2);
         }
-        
+
         switch ($action){
             case "delete":
                 mysqli_query($con, "DELETE FROM $table WHERE id = $id;");
@@ -40,6 +38,7 @@
                         break;
                     //TODO: add a case for dates
                 }
+                break;
         }
     }
 ?>

+ 0 - 1
www-admin/lablanca/functions.php

@@ -1 +0,0 @@
-DELETE me

+ 123 - 74
www-admin/lablanca/index.php

@@ -1,7 +1,10 @@
 <?php
+    include("../functions.php");
+    $proto = getProtocol();
     $http_host = $_SERVER['HTTP_HOST'];
     $default_host = substr($http_host, 0, strpos($http_host, ':'));
-    include("../functions.php");
+    $server = $proto . $http_host;
+    $server_default = $proto . $default_host;
     $con = startdb();
     if (!checkSession($con)){
         header("Location: /index.php");
@@ -13,22 +16,24 @@
 ?>
 <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">
+        <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"/>
+        <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"/>
+        <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>
+        <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'); ?>
+<?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>
@@ -36,7 +41,7 @@
                     ...calculando...
                 </div>
                 <div class='entry' id='entry_header'>
-                    <div id="lang_tabs">
+                    <div id='lang_tabs''>
                         <table>
                                 <tr>
                                     <td class="pointer lang_tabs_active" id="lang_tab_es" onclick="showLanguage('es');">
@@ -52,47 +57,52 @@
                         </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";
-                        ?>
+<?php
+                        $q = mysqli_query($con, "SELECT * FROM festival WHERE year = $year;");
+                        $r = mysqli_fetch_array($q);
+?>
+                        <textarea id='text_es' onChange='updateField("festival", "text_es", this.value, <?=$r["id"]?>, "text", false);calculate("header");'><?=$r["text_es"]?></textarea>
                         <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";
-                        ?>
+                        <textarea id='text_en' onChange='updateField("festival", "text_en", this.value, <?=$r["id"]?>);calculate("header");'><?=$r["text_en"]?></textarea>
                         <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";
-                        ?>
+                        <textarea id='text_eu' onChange='updateField("festival", "text_eu", this.value, <?=$r["id"]?>);calculate("header");'><?=$r["text_eu"]?></textarea>
                         <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";
-                                }
+<?php
+                        if (mysqli_num_rows($q) > 0){
+                            if (strlen($r['img']) == 0){
+?>
+                                <img id='header_img' src='/img/lablanca/header-null.png'/>
+                                <br/>
+<?php
                             }
                             else{
-                                echo "<img id='header_img' src='http://$default_host/img/fiestas/miniature/$r[img]'/><br/>\n";
+?>
+                                <img id='header_img' src='<?=$server_default?>/img/fiestas/miniature/<?=$r["img"]?>'/>
+                                <br/>
+<?php
                             }
-                            echo "<input type='file' id='header_img_selector' onChange='uploadHeaderImage(event, $r[id]);calculate(\"header\");'/>\n";
-                        ?>
+                        }
+                        else{
+?>
+                            <img id='header_img' src='<?=$server_default?>/img/fiestas/miniature/<?=$r["img"]?>'/>
+                            <br/>
+<?php
+                        }
+?>
+                        <input type='file' id='header_img_selector' onChange='uploadHeaderImage(event, <?=$r["id"]?>);calculate("header");'/>
                     </div>
                 </div>
             </div>
@@ -103,21 +113,27 @@
                     ...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";
+<?php
+                    $q = mysqli_query($con, "SELECT * FROM festival_day WHERE year(date) = '$year' AND price > 0;");
+                    if (mysqli_num_rows($q) != 6){
+?>
+                        <input type='button' value='A&ntilde;adir precios'/> <!-- TODO onclick -->
+                        <input type='button' value='Utilzar precios del a&ntilde;o pasado'/> <!-- TODO onclick -->
+<?php
+                    }
+                    else{
+?>
+                        <h4>D&iacute;as sueltos:</h4>
+                        <table id='prices'>
+                            <tr>
+                                <th>Fecha</th>
+                                <th>Nombres</th>
+                                <th>Precio</th>
+                            </tr>
+<?php
                             $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 = '';
                                 }
@@ -130,21 +146,44 @@
                                 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>";
+?>
+                                <tr>
+                                    <td><?=$dates[$i]?></td>
+                                    <td>
+                                        <table>
+                                            <tr>
+                                                <td>Castellano:</td>
+                                                <td>
+                                                    <input type='text' value='<?=$r["name_es"]?>' onchange='updateField("festival_day", "name_es", this.value, <?=$r["id"]?>);'/>
+                                                </td>
+                                            </tr>
+                                            <tr>
+                                                <td>Euskera:</td>
+                                                <td>
+                                                    <input type='text' value='<?=$r["name_en"]?>' onchange='updateField("festival_day", "name_en", this.value, <?=$r["id"]?>);'/>
+                                                </td>
+                                            </tr>
+                                            <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>
+                                        </table>
+                                    </td>
+                                    <td>
+                                        <input type='number' value='<?=$r["price"]?>' onchange='updateField("festival_day", "price", this.value, <?=$r["id"]?>, "number", false);'/>&euro;
+                                    </td>
+                                </tr>
+<?php
                                 $i = $i + 1;
                             }
-                            echo "</table>\n";
-                            echo "<div id='prices_offers'>\n";
-                            echo "...calculando...\n";
-                            echo "</div>\n";
-                        }
-                    ?>
+?>
+                        </table>
+                        <div id='prices_offers'>...calculando...</div>
+<?php
+                    }
+?>
                 </div>
             </div>
             <br/><br/>
@@ -194,24 +233,28 @@
                                 <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";
-                                        }
-                                    ?>
+<?php
+                                    $q = mysqli_query($con, "SELECT * FROM people;");
+                                    while ($r = mysqli_fetch_array($q)){
+?>
+                                        <option value='<?=$r["id"]?>'><?=$r["name_es"]?></option>
+<?php
+                                    }
+?>
                                 </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";
-                                        }
-                                    ?>
+<?php
+                                    $q = mysqli_query($con, "SELECT * FROM place;");
+                                    while ($r = mysqli_fetch_array($q)){
+?>
+                                        <option value='<?=$r["id"]?>'><?=$r["name_es"]?> (<?=$r["address_es"]?>)</option>
+<?php
+                                    }
+?>
                                 </select>
                             </td>
                         </tr>
@@ -226,7 +269,11 @@
             <div class='entry'>
                 <table>
                     <tr>
-                        <th>Castellano</th><th>Ingl&eacute;s</th><th>Euskera</th><th>D&iacute;as</th><th>Precio</th>
+                        <th>Castellano</th>
+                        <th>Ingl&eacute;s</th>
+                        <th>Euskera</th>
+                        <th>D&iacute;as</th>
+                        <th>Precio</th>
                     </tr>
                     <tr>
                         <td>
@@ -250,11 +297,13 @@
                     </tr>
                 </table>
                 <div id='controls'>
-                    <input type='button' value='Guardar' onClick='saveNewOffer(<?php echo $year;?>);'/>
+                    <input type='button' value='Guardar' onClick='saveNewOffer(<?p=$year?>);'/>
                     <input type='button' value='Cancelar' onClick='cancelNewOffer();'/>
                 </div>
             </div>
         </div>
     </body>
 </html>
-<?php } ?>
+<?php
+    }
+?>

+ 16 - 19
www-admin/lablanca/insertoffer.php

@@ -1,8 +1,6 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
-    $default_host = substr($http_host, 0, strpos($http_host, ':'));
     include("../functions.php");
-    $con = startdb('rw');
+    $con = startdb("rw");
     if (!checkSession($con)){
         exit (-1);
     }
@@ -16,46 +14,45 @@
         $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);
+            exit(-2);
         }
         if(strlen($text_es) <= 0){
             error_log('GMADMIN: Not inserting an offer with an empty spanish text.');
-            exit(-1);
+            exit(-3);
         }
         if ($price < 0){
             error_log("GMADMIN: Not inserting offer '$name_es' with price $price.");
-            exit(-1);
+            exit(-4);
         }
-        if ($days < 1){
+        if ($days < 1 || $days > 6){
             error_log("GMADMIN: Not inserting offer '$name_es' for $days day(s).");
-            exit(-1);
+            exit(-5);
         }
-        if ($year < 2000){
+        if ($year < 2013){
             error_log("GMADMIN: Not inserting offer '$name_es' for year $year.");
-            exit(-1);
+            exit(-6);
         }
-        
+
         //Check tanslations
-        if (strlen($name_en) == 0 || $name_en = $name_es){
+        if (strlen($name_en) == 0){
             $name_en = $name_es;
         }
-        if (strlen($name_eu) == 0 || $name_eu = $name_es){
+        if (strlen($name_eu) == 0){
             $name_eu = $name_es;
         }
-        if (strlen($text_en) == 0 || $text_en = $text_es){
+        if (strlen($text_en) == 0){
             $text_en = $text_es;
         }
-        if (strlen($text_eu) == 0 || $text_eu = $text_es){
+        if (strlen($text_eu) == 0){
             $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();
+
     }
 ?>

+ 0 - 15
www-admin/lablanca/moderate/index.php

@@ -1,15 +0,0 @@
-<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>

+ 0 - 1
www-admin/lablanca/moderate/moderate.php

@@ -1 +0,0 @@
- 

+ 38 - 0
www-admin/lablanca/script.js

@@ -1,3 +1,6 @@
+/**
+ * Opens a form to add a new offer.
+ */
 function newOffer(){
     document.getElementById('screen_cover').style.display = 'block';
     document.getElementById('form_new_offer').style.display = 'block';
@@ -5,12 +8,20 @@ function newOffer(){
     document.getElementById('form_new_offer').style.opacity = '1';
 }
 
+
+/**
+ * Cancels a offer that is being edited, and it is not yet saved.
+ */
 function cancelNewOffer(){
     if (confirm("Oferta no agregada. Descartar cambios?")){
         closeNewOffer();
     }
 }
 
+
+/**
+ * Closes the new offer form.
+ */
 function closeNewOffer(){
     document.getElementById('new_offer_title_es').value = '';
     document.getElementById('new_offer_title_en').value = '';
@@ -26,6 +37,11 @@ function closeNewOffer(){
     document.getElementById('form_new_offer').style.opacity = '0';
 }
 
+
+/**
+ * Validates and saves a new offer.
+ * @param year Year for the offer.
+ */
 function saveNewOffer(year){
     //Get values
     var name_es = document.getElementById('new_offer_title_es').value;
@@ -85,6 +101,12 @@ function saveNewOffer(year){
     x.send(params);
 }
 
+
+/**
+ * Recalculates the status header for a section.
+ * 
+ * @param section 'all', 'header', 'prices', 'schedule'.
+ */
 function calculate(section){
     switch (section){
         case 'all':
@@ -147,6 +169,16 @@ function calculate(section){
     }
 }
 
+/**
+ * Updates an entry in the database.
+ * 
+ * @param table Name of the table
+ * @param field Name of the column
+ * @param value New value
+ * @param id Identifier of the entry
+ * @param type Type of the value
+ * @param canBeNull Indicates nullable values.
+ */
 function updateField(table, field, value, id, type = 'text', canBeNull = true){
     // Get page
     if(XMLHttpRequest)
@@ -165,6 +197,12 @@ function updateField(table, field, value, id, type = 'text', canBeNull = true){
     x.send(params);
 }
 
+
+/**
+ * Deletes an offer from the database.
+ * 
+ * @param id Offer ID.
+ */
 function deleteOffer(id){
     // Get page
     if(XMLHttpRequest)

+ 0 - 15
www-admin/lablanca/translate/index.php

@@ -1,15 +0,0 @@
-<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>

+ 0 - 1
www-admin/lablanca/translate/translate.php

@@ -1 +0,0 @@
- 

+ 13 - 21
www-admin/lablanca/uploadimage.php

@@ -1,28 +1,21 @@
 <?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');
+    $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']);
-        
+        $type = mysqli_real_escape_string($con, $_GET["type"]);
+        $id = mysqli_real_escape_string($con, $_GET["id"]);
+        $file = $_FILES["img"];
+
         //Check if image file
-        $check = getimagesize($_FILES['img']['tmp_name']);
+        $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);
+            exit(-2);
         }
-        
-        error_log("uploading image");
-        
+
         //Upload the image to its destination
         switch ($type){
             case 'header':
@@ -30,12 +23,11 @@
                 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;
@@ -49,7 +41,7 @@
                         $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");    
@@ -64,9 +56,9 @@
                     $thumb->writeImage("../../www/img/fiestas/thumb/$r[year].png");
                     $thumb->clear();
                     $thumb->destroy(); 
-                    
+
                     //Update database
-                    if (strlen($r['img']) == 0){
+                    if (strlen($r["img"]) == 0){
                         mysqli_query($con, "UPDATE festival SET img = '$r[year].png' WHERE id = $id;");
                         version();
                     }

+ 8 - 6
www-admin/login.php

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

+ 7 - 3
www-admin/main.php

@@ -24,7 +24,9 @@
         <script type="text/javascript" src="/script/ui.js"></script>
     </head>
     <body>
-        <?php include('toolbar.php'); ?>
+<?php
+        include('toolbar.php');
+?>
         <div id='content'>
             <div id='section_table'>
                 <div class='section_row'>
@@ -110,7 +112,7 @@
                             <h3 class='section_title'>Ajustes</h3>
                             <div class='entry'>
                                 <ul>
-                                    <li><a href='<?=$server?>/settings/'Ajustes</a></li>
+                                    <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>
@@ -122,4 +124,6 @@
         </div>
     </body>
 </html>
-<?php } ?>
+<?php
+    }
+?>

+ 0 - 1
www-admin/miembros/add/add.php

@@ -1 +0,0 @@
- 

+ 0 - 15
www-admin/miembros/add/index.php

@@ -1,15 +0,0 @@
-<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>

+ 0 - 1
www-admin/miembros/delete/delete.php

@@ -1 +0,0 @@
- 

+ 0 - 1
www-admin/miembros/edit/edit.php

@@ -1 +0,0 @@
- 

+ 0 - 15
www-admin/miembros/edit/index.php

@@ -1,15 +0,0 @@
-<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>

+ 77 - 45
www-admin/miembros/index.php

@@ -1,69 +1,99 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
     include("../functions.php");
     $con = startdb();
     if (!checkSession($con)){
         header("Location: /index.php");
         exit (-1);
     }
-    else{?>
+    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">
+        <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"/>
+        <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"/>
+        <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>
+        <script type='text/javascript' src='script.js'></script>
+        <script type='text/javascript' src='/script/ui.js'></script>
     </head>
     <body>
-        <?php include('../toolbar.php'); ?>
+<?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 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">
+                <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";
+<?php
+                        $q = mysqli_query($con, "SELECT * FROM member;");
+                        $i = 0;
+                        while ($r = mysqli_fetch_array($q)){
+                            if ($i % 2 == 0){
+                                $row_type = "even";
+                            }
+                            else{
+                                $row_type = "odd";
                             }
-                        ?>
+                            $i ++;
+?>                            
+                            <tr class='member_row_<?=$row_type>?>'>
+                                <td>
+                                    <?=$r["lname"]?>
+<?php
+                                    if ($r['lname2'] != null){
+?>
+                                        <?=$r["lname2"]?>
+<?php
+                                    }
+?>
+                                    , <?=$r["name"]?>
+<?php
+                                    if ($r['alias'] != null){
+?>
+                                        <span style='font-style:italic;'> - (<?=$r["alias"]?>)</span>
+<?php
+                                    }
+?>
+                                </td>
+                                <td style='text-align:center;'>
+<?php
+                                    if ($r['phone'] != null){
+?>
+                                        <?=$r["phone"]?><br/>
+<?php
+                                    }
+                                    if ($r['mail'] != null){
+?>
+                                        <?=$r["mail"]?>
+<?php
+                                    }
+?>
+                                </td>
+                                <td style='display:none;'><?=$r[name]?> <?=$r[lname]?> <?=$r[lname2]?> <?=$r[dni]?>, <?=$r[address]?></td>
+                                <td style='text-align:center;'>
+                                    <a href='/miembros/miembro.php?m=$r[id]'>Ficha completa</a>
+                                    <br/>
+                                    <a href=''>Editar</a> <!-- TODO -->
+                                </td>
+                            </tr>
+<?php
+                        }
+?>
                     </table>
                 </div>
             </div>
@@ -71,8 +101,8 @@
                 <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>
+                        <li><a href="/miembros/add/">Anadir miembro</a></li>
+                        <li><a href="/miembros/add/batch.php">Anadir miembros en lote</a></li>
                     </ul>
                 </div><br/>
                 <div class="entry">
@@ -89,4 +119,6 @@
         </div>
     </body>
 </html>
-<?php } ?>
+<?php
+    }
+?>

+ 0 - 189
www-admin/miembros/miembro-bkp.php

@@ -1,189 +0,0 @@
-<?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); ?>
-        
-<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 }
-    }
-?>

+ 200 - 123
www-admin/miembros/miembro.php

@@ -1,6 +1,4 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
-    $default_host = substr($http_host, 0, strpos($http_host, ':'));
     include("../functions.php");
     $con = startdb();
     if (!checkSession($con)){
@@ -8,46 +6,57 @@
         exit (-1);
     }
     else{
-        $id = mysqli_real_escape_string($con, $_GET['m']);
+        $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); ?>
-        
+            $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">
+        <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"/>
+        <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"/>
+        <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>
+        <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'); ?>
+    <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">
+            <div class='section'>
+                <h3><?=$r["name"]?> <span style='font-style:italic;'><?=$r["alias"]?></span><?=$r["lname"]?>></h3>
+                <table id='member'>
                     <tr>
-                        <td class="entry">
+                        <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>
+                            <p>
+                                <span style='font-weight:bold;'>Nombre: </span><?=$r["name"]?>
+                            </p>
+                            <p>
+                                <span style='font-weight:bold;'>Primer apellido: </span><?=$r["lname"]?>
+                            </p>
+                            <p>
+                                <span style='font-weight:bold;'>Segundo apellido: </span><?=$r["lname2"]?>
+                            </p>
+                            <p>
+                                <span style='font-weight:bold;'>Alias: </span><?=$r["alias"]?>
+                            </p>
                             <br/>
-                            <p><span style="font-weight:bold;">Fecha de nacimiento: </span>
-                            <?php
+                            <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']);
@@ -58,49 +67,76 @@
                                     $date = "$date (<span style='color:#aa0000'>$age a&ntilde;os - Menor de edad</span>)";
                                 else
                                     $date = "$date ($age a&ntilde;os)";
-                                echo $date;
-                            ?>
+?>
+                                <?=$date?>
+                            </p>
+                            <p>
+                                <span style='font-weight:bold;'>DNI: </span>
+                                <?=$r["dni"]?>
+                            </p>
+                            <p>
+                                <span style='font-weight:bold;'>Direccion: </span>
+                                <?=$r["address"]?>
                             </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
+                            <p>
+                                <span style="font-weight:bold;">Socio: </span>
+                                #<?=$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;
-                            ?>
+?>
+                                <?=$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>
+                                <span style="font-weight:bold;">Formulario: </span>
+<?php
+                                switch ($r['joined']){
+                                    case 'origin':
+?>
+                                        Socio inicial
+<?php
+                                        break;
+                                    case 'phone':
+?>
+                                        V&iacute;a m&oacute;vil
+<?php
+                                        break;
+                                    case 'oldweb':
+?>
+                                        V&iacute;a web antigua
+<?php
+                                        break;
+                                    case 'web':
+?>
+                                        V&iacute;a web
+<?php
+                                        break;
+                                    default:
+?>
+                                        V&iacute;a hoja de inscripci&oacute;n
+<?php
+                                }
+?>
                             </p>
-                            <p><span style="font-weight:bold;">Junta directiva: </span>
-                            <?php
-                                if ($r['board'] == 1)
-                                    echo "Si";
-                                else
-                                    echo "No";
-                            ?>
+                            <p>
+                                <span style="font-weight:bold;">Junta directiva: </span>
+<?php
+                                if ($r['board'] == 1)}
+?>
+                                        S&iacute;
+<?php
+                                }
+                                else{
+?>
+                                        No
+<?php
+                                }
+?>
                             </p>
                         </td>
                     </tr>
@@ -108,86 +144,126 @@
                         <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']);
+<?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)){
+?>
+                                    <li>Fiestas <?=$r_year["year"]?>:
+                                        <ul>
+<?php
+                                            $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;");
+                                            while ($r_day = mysqli_fetch_array($q_day)){
+                                                if ($r_day['paid'] == 1){
+?>
+                                                    <li><?=$r_day["dat"]?></li>
+<?php
+                                                    $paid = $paid + intval($r_day['price']);
+                                                }
+                                                else{
+?>
+                                                    <li><?=$r_day["dat"]?> - <span style='color:#aa0000'>No pagado</span></li>
+<?php
+                                                    $unpaid = $unpaid + intval($r_day['price']);
+                                                }
                                             }
-                                                
-                                        }
-                                        echo "</ul>\n";
-                                        echo "</li>\n";
-                                    }
-                                ?>
+?>
+                                        </ul>
+                                    </li>
+<?php
+                                }
+?>
                             </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']);
-                                            }
-                                    }
-                                ?>
+<?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){
+?>
+                                            <li><?=$r_activity["title_es"]?> (<?=$r_activity["year"]?>)</li>
+<?php
+                                            $paid = $paid + intval($r_activity['price']);
+                                        }
+                                        else{
+?>
+                                            <li><?=$r_activity["title_es"]?> (<?=$r_activity["year"]?>) - <span style='color:#aa0000'>No pagado</span></li>
+<?php
+                                            $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>"
-                                ?>
+                                Dinero aportado: <?=$paid?> &euro;
+<?php
+                                if ($unpaid > 0){
+?>
+                                    <br/>
+                                    <span style='color:#aa0000'>Debe: $unpaid &euro;</span>
+<?php
+                                }
+?>+
                             </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";
-                                    ?>
+<?php
+                                    if ($r["facebook"] == null){
+?>
+                                        <li style='text-decoration: line-through;'>Facebook</li>
+<?php
+                                    }
+                                    else{
+?>
+                                        <li><a href='<?=$r["facebook"]?>'>Facebook</a></li>
+<?php
+                                    }
+                                    if ($r["twitter"] == null){
+?>
+                                        <li style='text-decoration: line-through;'>Twitter</li>
+<?php
+                                    }
+                                    else{
+?>
+                                        <li><a href='<?=$r["twitter"]?>'>Twitter</a></li>
+<?php
+                                    }
+                                    if ($r["googleplus"] == null){
+?>
+                                        <li style='text-decoration: line-through;'>Google+</li>
+<?php
+                                    }
+                                    else{
+?>
+                                        <li><a href='<?=$r["googleplus"]?>'>Google+</a></li>
+<?php
+                                    }
+?>
                                 </ul>
                             </div>
                             <br/><br/><hr/><br/><br/>
                             <div>
                                 <h3>Intolerancias alimenticias</h3>
                                 <ul>
-                                <?php
+<?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";
-                                ?>
+                                    if (mysqli_num_rows($q_intolerance) == 0){
+?>
+                                        <li>Ninguna</li>
+<?php
+                                    }
+                                    else{
+                                        while ($r_intolerance = mysqli_fetch_array($q_intolerance)){
+?>
+                                            <li><?=$r_intolerance["element"]?></li>
+<?php
+                                        }
+                                    }
+?>
                                 </ul>
                             </div>
                         </td>
@@ -202,7 +278,8 @@
             </div>
         </div>
     </body>
-        
-        <?php }
+
+<?php
+        }
     }
 ?>

+ 0 - 15
www-admin/miembros/moderate/index.php

@@ -1,15 +0,0 @@
-<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>

+ 0 - 1
www-admin/miembros/moderate/moderate.php

@@ -1 +0,0 @@
- 

Деякі файли не було показано, через те що забагато файлів було змінено