=====================================================
  RISUS NOVA 2.0.4 — CHANGELOG
  PHPost | https://phpost.es/
  Fecha: Junio 2026
=====================================================
------------------------------------------------------
  NUEVO — LOGIN CON GOOGLE
------------------------------------------------------
- Los usuarios pueden iniciar sesion con su cuenta
  de Google desde la pagina /login/
- Vinculacion automatica si el email ya existe
- Creacion automatica de cuenta al primer login
- Client ID y Client Secret configurables desde
  Admin -> Configuracion -> Login con Google
- El boton de Google solo aparece si esta configurado
- Columnas google_client_id y google_client_secret
  en w_configuracion
- Columna user_google_id en u_miembros
- Archivo: google_auth.php → raiz del sitio
------------------------------------------------------
  NUEVO — HONEYPOT ANTI-SPAM
------------------------------------------------------
- Campo invisible en el registro que solo los bots
  rellenan — bloquea registros automatizados
- Activable desde Admin -> Configuracion
- Compatible con Turnstile y pregunta de seguridad
- No delata que hay proteccion al bot
- Columna honeypot_activo en w_configuracion
------------------------------------------------------
  NUEVO — POSTS DESTACADOS
------------------------------------------------------
- El admin puede marcar posts como destacados desde
  Admin -> Posts con un clic
- Pagina /destacados/ con todos los posts destacados
- Widget en la sidebar de la home
- Panel Admin -> Destacados para gestionar y quitar
- Badge estrella dorada en posts destacados
- Columnas post_destacado, post_destacado_fecha y
  post_destacado_admin en p_posts
------------------------------------------------------
  NUEVO — HOME POR CATEGORIAS
------------------------------------------------------
- Modo de visualizacion de la home configurable
  desde Admin -> Configuracion:
  * Normal: todos los posts mezclados (por defecto)
  * Por categorias: bloques separados por seccion
  * Ambos: posts normales + bloques por categoria
- Numero de posts por categoria configurable (1-10)
- Automatico: las categorias nuevas aparecen solas
  sin tocar codigo
- Una sola query para todas las categorias
- Compatible con iconos FA7 por categoria
- Columnas home_mode y home_cat_limit en
  w_configuracion
------------------------------------------------------
  NUEVO — NOTIFICACIONES PUSH
------------------------------------------------------
- Sistema de notificaciones push para el navegador
- Los usuarios reciben avisos aunque no tengan el
  sitio abierto (nuevos comentarios, respuestas...)
- Activacion/desactivacion por el usuario desde
  Mi Cuenta -> Privacidad
- Activacion/desactivacion global desde
  Admin -> Configuracion -> Notificaciones Push
- Requiere HTTPS y claves VAPID configuradas
- Compatible con Chrome, Firefox y Edge
- Archivos: sw.js, push.js, ajax.push.php, c.push.php
- Columnas push_activo, push_vapid_pub, push_vapid_priv
  en w_configuracion
- Columna push_activo en u_perfil
- Tabla w_push_subs para suscripciones
------------------------------------------------------
  NUEVO — SISTEMA DE DONACIONES
------------------------------------------------------
- Pagina dedicada /donaciones/ con diseno moderno
- Compatible con PayPal, Ko-fi, Buy Me a Coffee,
  Patreon y Bizum
- Barra de progreso hacia objetivo mensual
- Lista de ultimos donantes con avatar
- Widget en sidebar de la home (solo si hay metodo
  configurado)
- Enlace automatico en menu de navegacion
- Configuracion desde Admin -> Configuracion
- Archivos: donaciones.php, t.donaciones.tpl,
  m.home_donaciones.tpl
- Columnas don_* en w_configuracion
- Tabla w_donaciones para registro de donantes
------------------------------------------------------
  NUEVO — EMAIL SMTP (PHPMailer)
------------------------------------------------------
- Sistema de email completamente reescrito con
  soporte SMTP via PHPMailer
- Compatible con Gmail, Outlook, Yahoo y el email
  del propio hosting
- Configuracion desde Admin -> Configuracion en la
  nueva seccion "Configuracion de Email (SMTP)"
- Boton de test de envio desde el panel admin
- Fallback automatico a mail() si SMTP no esta
  configurado o falla
- Templates de email modernos en HTML con diseno
  responsive para registro, recuperacion de
  contrasena y bienvenida
- Columnas smtp_host, smtp_user, smtp_pass,
  smtp_port y smtp_from en w_configuracion
------------------------------------------------------
  NUEVO — PREGUNTA DE SEGURIDAD EN REGISTRO
------------------------------------------------------
- Alternativa al Turnstile para hostings sin
  allow_url_fopen activo
- Si hay Turnstile configurado se usa Turnstile;
  si no, se muestra la pregunta de seguridad
- Pregunta y respuesta configurables desde
  Admin -> Configuracion
- Columnas reg_pregunta y reg_respuesta en
  w_configuracion
------------------------------------------------------
  NUEVO — SOPORTE POR TICKETS
------------------------------------------------------
- Sistema completo de soporte en /soporte/
- Prioridades: baja, media, alta, urgente
- Categorias: tecnico, cuenta, contenido, pagos, otro
- Estados: abierto, en proceso, resuelto, cerrado
- Panel admin con estadisticas, filtros por estado
  y tabla con avatar del usuario que envio el ticket
- Chat estilo mensajeria en la vista del ticket
- Notificacion automatica al usuario al responder
- Valoracion del ticket por el usuario (resuelto /
  sin resolver)
- Tablas s_tickets y s_mensajes
------------------------------------------------------
  NUEVO — ZONA VIP
------------------------------------------------------
- Pagina exclusiva /vip/ para miembros con acceso
- Panel admin en /admin/vip con estadisticas
- Asignacion VIP manual por usuario o por rango
  completo con fecha de expiracion opcional
- Posts VIP — solo visibles para miembros VIP,
  excluidos de la home, tops y comentarios recientes
- Badge dorado en el perfil de usuarios VIP
- Notificacion automatica al asignar acceso VIP
- Fallback automatico si el mod no esta instalado
  (detecta columna post_vip via information_schema)
- Tablas u_vip y u_vip_rangos
------------------------------------------------------
  NUEVO — LOGIN Y REGISTRO EN PAGINAS DEDICADAS
------------------------------------------------------
- Paginas /login/ y /registro/ con diseno carta
  aerea estilo dos columnas
- Registro en 3 pasos (Cuenta, Perfil, Confirmar)
  con validacion en tiempo real de nick y email
- Validacion de contrasenas tanto en JS como en
  servidor (c.registro.php)
- Fix critico: id="password" duplicado en login_box
  causaba error "Las contrasenas no coinciden"
  corregido cambiando a id="login_password"
------------------------------------------------------
  NUEVO — OTRAS FUNCIONES
------------------------------------------------------
- Filtro de posts por pais del autor con banderas
- Filtro de posts por inicial del titulo (A-Z, 0-9)
- Buscador con 3 pestanas: Posts, Comunidades y Google
- Sistema En Vivo en /en-vivo/ con feed de actividad
  en tiempo real (posts, comentarios, comunidades,
  nuevos usuarios) y widget en columna lateral
- Estrellas de reputacion con FA7 — niveles Normal
  y Premium, detecta Admin y Moderador por rango
- Lazy loading automatico en imagenes de posts
- Subida de imagenes en CKEditor 5 via
  upload_images.php con validacion GD
- Meta description dinamica — slogan en home,
  extracto de 160 chars en posts individuales
------------------------------------------------------
  CORRECCIONES
------------------------------------------------------
- perfil.js: global_data is not defined corregido
  con retry de 100ms hasta que este disponible
- c.registro.php: estado (region) ahora opcional,
  no bloquea el formulario si no carga
- m.post_autor.tpl: botones seguir/dejar de seguir
  ya no se renderizan los dos a la vez
- getLastPosts: INNER JOIN cuando hay filtro de pais
- getLastPosts: user_rango != 3 para excluir
  usuarios eliminados de los resultados
- posts.php: En Vivo se carga condicionalmente con
  file_exists() — no falla si no esta instalado
- registro.js: eliminados console.log y alert de
  debug que quedaron de pruebas de desarrollo
------------------------------------------------------
  PARCHE 2.0.4 — SEGURIDAD
------------------------------------------------------
- Headers HTTP de seguridad en header.php:
  X-Frame-Options, X-Content-Type-Options,
  X-XSS-Protection, Referrer-Policy,
  Permissions-Policy y HSTS (solo HTTPS)
- Cookies de sesion protegidas con httponly y
  samesite=Lax
- Rate limiting en login: maximo 5 intentos por
  nick y 10 por IP en 10 minutos
  Tabla w_login_attempts anadida
- Clase tsSeguridad con prepared statements,
  sanitizacion mejorada y tokens CSRF
- getIP() corregido: no acepta HTTP_CLIENT_IP
- X_FORWARDED_FOR corregido en c.posts.php,
  c.fotos.php, c.cuenta.php, c.mensajes.php
- REMOTE_ADDR validado con FILTER_VALIDATE_IP
- Inputs sin sanitizar corregidos en c.mensajes.php
- Contrasenas limitadas a 72 caracteres en
  c.cuenta.php para evitar DoS por bcrypt
- XSS corregido en ajax.borradores.php
------------------------------------------------------
  PARCHE 2.0.3
------------------------------------------------------
- Corregido array $files indefinido en ajax.feed.php
- Corregido nivel de acceso en ajax.feed.php
- Corregida URL AJAX del comprobador de versiones
------------------------------------------------------
  PARCHE 2.0.1
------------------------------------------------------
- public array $permisos declarado como propiedad
  tipada en tsUser (PHP 8 estricto)
- jQuery movido al head para scripts inline del body
- Font Awesome 6 eliminado de m.agregar.form.tpl
- Columnas p_fondo y p_fondoper anadidas a u_perfil
------------------------------------------------------
  COMPATIBILIDAD PHP 8
------------------------------------------------------
- Compatibilidad total con PHP 8.3+
- Migracion de Smarty 2 a Smarty 4.5.6
- Contrasenas migradas de MD5 a bcrypt con migracion
  automatica al iniciar sesion
- Sistema de sesiones con random_bytes()
- Correcciones de TypeError, warnings y claves
  indefinidas en todo el sistema
------------------------------------------------------
  BASE DE DATOS
------------------------------------------------------
- Tabla w_push_subs para suscripciones push
- Tabla w_donaciones para registro de donantes
- Columnas push en w_configuracion:
  push_activo, push_vapid_pub, push_vapid_priv
- Columna push_activo en u_perfil
- Columnas donaciones en w_configuracion:
  don_paypal, don_kofi, don_bmac, don_patreon,
  don_bizum, don_transferencia, don_objetivo,
  don_recaudado
- Columnas SMTP en w_configuracion:
  smtp_host, smtp_user, smtp_pass, smtp_port,
  smtp_from
- Columnas pregunta seguridad en w_configuracion:
  reg_pregunta, reg_respuesta
- Tablas nuevas: s_tickets, s_mensajes (soporte),
  u_vip, u_vip_rangos (zona vip),
  w_login_attempts (rate limiting)
- Columna post_vip en p_posts
- Indices FULLTEXT en p_posts
- Columna post_image en p_posts
- Columna user_pwtype en u_miembros
------------------------------------------------------
  OTROS
------------------------------------------------------
- Nuevos botones de compartir en redes sociales
- RSS feed implementado
- Sistema de avatares mejorado
- Sitemap XML dinamico en /sitemap.xml
- Nuevo editor CKEditor 5
- Instalador completamente reescrito (6 pasos)
- Limpieza de archivos y librerias innecesarias
=====================================================
  NOTAS DE ACTUALIZACION DESDE VERSION ANTERIOR
=====================================================
1. Sube todos los archivos al servidor
2. Ejecuta el upgrade desde /upgrade/
3. Ejecuta en phpMyAdmin:

   -- Login con Google
   ALTER TABLE w_configuracion
     ADD COLUMN IF NOT EXISTS google_client_id varchar(255) NOT NULL DEFAULT '',
     ADD COLUMN IF NOT EXISTS google_client_secret varchar(255) NOT NULL DEFAULT '';
   ALTER TABLE u_miembros
     ADD COLUMN IF NOT EXISTS user_google_id varchar(50) NOT NULL DEFAULT '';

   -- Honeypot
   ALTER TABLE w_configuracion
     ADD COLUMN IF NOT EXISTS honeypot_activo tinyint(1) NOT NULL DEFAULT 0;

   -- Posts Destacados
   ALTER TABLE p_posts
     ADD COLUMN IF NOT EXISTS post_destacado tinyint(1) NOT NULL DEFAULT 0,
     ADD COLUMN IF NOT EXISTS post_destacado_fecha int(11) NOT NULL DEFAULT 0,
     ADD COLUMN IF NOT EXISTS post_destacado_admin int(11) NOT NULL DEFAULT 0;

   -- Home por categorias
   ALTER TABLE w_configuracion
     ADD COLUMN IF NOT EXISTS home_mode tinyint(1) NOT NULL DEFAULT 0,
     ADD COLUMN IF NOT EXISTS home_cat_limit tinyint(2) NOT NULL DEFAULT 5;

   -- Push Notifications
   ALTER TABLE w_configuracion
     ADD COLUMN IF NOT EXISTS push_activo tinyint(1) NOT NULL DEFAULT 0,
     ADD COLUMN IF NOT EXISTS push_vapid_pub varchar(255) NOT NULL DEFAULT '',
     ADD COLUMN IF NOT EXISTS push_vapid_priv varchar(255) NOT NULL DEFAULT '';
   ALTER TABLE u_perfil
     ADD COLUMN IF NOT EXISTS push_activo tinyint(1) NOT NULL DEFAULT 1;
   CREATE TABLE IF NOT EXISTS w_push_subs (
     sub_id int(11) NOT NULL AUTO_INCREMENT,
     user_id int(11) NOT NULL,
     endpoint text NOT NULL,
     p256dh varchar(255) NOT NULL DEFAULT '',
     auth varchar(100) NOT NULL DEFAULT '',
     fecha int(11) NOT NULL DEFAULT 0,
     PRIMARY KEY (sub_id),
     KEY user_id (user_id)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

   -- Donaciones
   ALTER TABLE w_configuracion
     ADD COLUMN IF NOT EXISTS don_paypal varchar(255) NOT NULL DEFAULT '',
     ADD COLUMN IF NOT EXISTS don_kofi varchar(255) NOT NULL DEFAULT '',
     ADD COLUMN IF NOT EXISTS don_bmac varchar(255) NOT NULL DEFAULT '',
     ADD COLUMN IF NOT EXISTS don_patreon varchar(255) NOT NULL DEFAULT '',
     ADD COLUMN IF NOT EXISTS don_bizum varchar(20) NOT NULL DEFAULT '',
     ADD COLUMN IF NOT EXISTS don_transferencia tinyint(1) NOT NULL DEFAULT 0,
     ADD COLUMN IF NOT EXISTS don_objetivo decimal(8,2) NOT NULL DEFAULT 0.00,
     ADD COLUMN IF NOT EXISTS don_recaudado decimal(8,2) NOT NULL DEFAULT 0.00;
   CREATE TABLE IF NOT EXISTS w_donaciones (
     don_id int(11) NOT NULL AUTO_INCREMENT,
     don_nombre varchar(64) NOT NULL DEFAULT '',
     don_cantidad decimal(8,2) NOT NULL DEFAULT 0.00,
     don_metodo varchar(30) NOT NULL DEFAULT '',
     don_mensaje varchar(255) NOT NULL DEFAULT '',
     don_fecha int(11) NOT NULL DEFAULT 0,
     don_activo tinyint(1) NOT NULL DEFAULT 1,
     don_mostrar_cantidad tinyint(1) NOT NULL DEFAULT 1,
     PRIMARY KEY (don_id)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

   -- SMTP
   ALTER TABLE w_configuracion
     ADD COLUMN IF NOT EXISTS smtp_host varchar(120) NOT NULL DEFAULT '',
     ADD COLUMN IF NOT EXISTS smtp_user varchar(120) NOT NULL DEFAULT '',
     ADD COLUMN IF NOT EXISTS smtp_pass varchar(120) NOT NULL DEFAULT '',
     ADD COLUMN IF NOT EXISTS smtp_port smallint(5) NOT NULL DEFAULT 587,
     ADD COLUMN IF NOT EXISTS smtp_from varchar(120) NOT NULL DEFAULT '';

   -- Pregunta de seguridad
   ALTER TABLE w_configuracion
     ADD COLUMN IF NOT EXISTS reg_pregunta varchar(255) NOT NULL DEFAULT '',
     ADD COLUMN IF NOT EXISTS reg_respuesta varchar(100) NOT NULL DEFAULT '';

   -- Zona VIP
   CREATE TABLE IF NOT EXISTS u_vip (
     vip_id int(11) NOT NULL AUTO_INCREMENT,
     user_id int(11) NOT NULL,
     vip_tipo tinyint(1) NOT NULL DEFAULT 1,
     vip_inicio int(11) NOT NULL DEFAULT 0,
     vip_expira int(11) NOT NULL DEFAULT 0,
     vip_notas varchar(255) NOT NULL DEFAULT '',
     vip_admin int(11) NOT NULL DEFAULT 0,
     PRIMARY KEY (vip_id),
     UNIQUE KEY user_id (user_id)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
   CREATE TABLE IF NOT EXISTS u_vip_rangos (
     vr_id int(11) NOT NULL AUTO_INCREMENT,
     rango_id int(11) NOT NULL,
     PRIMARY KEY (vr_id),
     UNIQUE KEY rango_id (rango_id)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
   ALTER TABLE p_posts ADD COLUMN IF NOT EXISTS post_vip tinyint(1) NOT NULL DEFAULT 0;

   -- Soporte
   CREATE TABLE IF NOT EXISTS s_tickets (
     ticket_id int(11) NOT NULL AUTO_INCREMENT,
     user_id int(11) NOT NULL,
     asunto varchar(120) NOT NULL DEFAULT '',
     categoria varchar(30) NOT NULL DEFAULT 'tecnico',
     prioridad tinyint(1) NOT NULL DEFAULT 2,
     estado tinyint(1) NOT NULL DEFAULT 1,
     fecha int(11) NOT NULL DEFAULT 0,
     fecha_update int(11) NOT NULL DEFAULT 0,
     leido_admin tinyint(1) NOT NULL DEFAULT 0,
     leido_user tinyint(1) NOT NULL DEFAULT 1,
     valoracion tinyint(1) NOT NULL DEFAULT 0,
     PRIMARY KEY (ticket_id)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
   CREATE TABLE IF NOT EXISTS s_mensajes (
     msg_id int(11) NOT NULL AUTO_INCREMENT,
     ticket_id int(11) NOT NULL,
     user_id int(11) NOT NULL,
     cuerpo text NOT NULL,
     es_admin tinyint(1) NOT NULL DEFAULT 0,
     fecha int(11) NOT NULL DEFAULT 0,
     PRIMARY KEY (msg_id)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

   -- Rate limiting
   CREATE TABLE IF NOT EXISTS w_login_attempts (
     id int(11) NOT NULL AUTO_INCREMENT,
     ip varchar(45) NOT NULL DEFAULT '',
     nick varchar(50) NOT NULL DEFAULT '',
     fecha int(11) NOT NULL DEFAULT 0,
     PRIMARY KEY (id)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

   -- Indices FULLTEXT
   ALTER TABLE p_posts ADD FULLTEXT KEY ft_tags (post_tags);
   ALTER TABLE p_posts ADD FULLTEXT KEY ft_title_body (post_title, post_body);

4. Sube la carpeta inc/ext/phpmailer/ (3 archivos)
5. Sube sw.js y ajax.push.php a la raiz del sitio
6. Borra las carpetas /cache/ y /templates_c/
7. Configura SMTP en Admin -> Configuracion
8. Configura Push en Admin -> Configuracion (opcional)
9. Configura Donaciones en Admin -> Configuracion (opcional)
=====================================================
  CREDITOS
=====================================================
PHPost Team | https://phpost.es/
Basado en T!Script por Tronlar
=====================================================
