Files
acai-vscode-webbase/lib/variables.php
Jordan DiazandClaude Opus 5 e938135869 feat(cache): las webs nuevas llaman al checkpoint cache
Anade la llamada a addPlugins("cache", ...) al final del bloque CACHE HANDLER,
para que el plugin `cache_handler` pueda gobernar la cache de una web recien
creada sin tener que editarle el variables.php a mano.

El orden es deliberado: el checkpoint va DESPUES del default cableado, asi el
plugin puede apagar tambien lo que se encienda arriba (cache.php fija los
flags de CocoDB explicitamente, no solo cuando activa).

`CocoDB::localCache()` se queda como estaba: es el comportamiento actual de
toda web nueva y quitarlo seria una regresion de rendimiento para quien no
tenga el plugin instalado. Sin plugin, la web se comporta igual que antes de
este commit.

Nota: `lib/variables.php` esta en los excludes del rsync de web-base
(server/handlers/acai.py), asi que esto NO toca ninguna web existente — solo
las que se creen a partir de ahora.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FsEzft5j5tZqxPdTdUXxLK
2026-09-06 13:33:40 +00:00

86 lines
4.0 KiB
PHP

<?php
define("CMS_FOLDER","cms");
define("CMS_VIEWER_LIB",CMS_FOLDER."/lib/viewer_functions.php");
define('USAR_WEBP', false);
require_once str_replace("/lib","",dirname(__FILE__))."/".CMS_VIEWER_LIB;
CocoParser::$parseaCodigosEnLinea = false;
CocoDB::$defaultRelationsDepth = 1;
// if (isset($_REQUEST["enlace"]) && $_REQUEST["enlace"] == "") define("USE_MIN_TAILWIND",true);
define("BUILDER_JSON_RESPONSE",@$_REQUEST["builderJson"] ? true : false);
if(property_exists('CocoDB', 'force_json_cache_uploads')) {
CocoDB::$force_json_cache_uploads = false;
}
// EN SERVIDORES EXTERNOS HAY QUE DEFINIR LA RUTA DE TAILWINDCSS SINO NO FUNCIONARA EL MINCSS
// define("TAILWIND_PATH","./node_modules/.bin/tailwindcss");
/*****************/
/* CACHE HANDLER */
/*****************/
// La cache la puede gobernar el plugin `cache_handler` (catalogo central en
// ws:cms/lib/plugins/cache_handler), que se engancha al checkpoint `cache` y
// se configura desde el dashboard: Ajustes > Configurar plugins.
//
// El orden importa: lo de aqui arriba es el DEFAULT de una web recien creada
// y el checkpoint va DESPUES, para que el plugin — cuando este instalado y
// activo — pueda apagar tambien lo que se haya encendido aqui. Sin el plugin,
// la web se comporta como siempre: solo cache local de consultas.
// define("USE_INFORMATION_SCHEMA_CACHE", true);
// CocoDB::$noCacheURIS = ["\\/mi(s)?-(.*)(\\/)(.*)","\\/hooks\\/(.*)?","\\/login\\/(.*)?"];
// CocoDB::$noCacheTABLES = ["aux_plg_payments","cms_cestas_abandonadas","cms_direcciones","cms_posibles_pedidos","cms_stock","cms_usuarios_metas","cms_usuarios"];
//
// // Cache general de consultas en Redis
// CocoDB::fullCache(3);
//
// Cache local: cachea las consultas repetidas dentro de la misma peticion
CocoDB::localCache();
//
// CocoDB::$force_redis_module = @CocoDB::bloquedCacheByURL($_SERVER["REQUEST_URI"]) ? false : true;
// CocoDB::$force_redis_html = @CocoDB::bloquedCacheByURL($_SERVER["REQUEST_URI"]) ? false : true;
$cacheHandlerVars = array("uri" => @$_SERVER["REQUEST_URI"]);
if (function_exists("addPlugins")) addPlugins("cache", $cacheHandlerVars);
$plantilla = "template/estandar";
define("PLANTILLA",$plantilla);
define("RUTA_PLANTILLA","/".$plantilla);
if (@$_REQUEST["idioma"]=="es") $_REQUEST["idioma"] = "";
if (substr($_SERVER["REQUEST_URI"],0,4)=="/en/") $_REQUEST["idioma"]="en";
if (substr($_SERVER["REQUEST_URI"],0,4)=="/es/") $_REQUEST["idioma"]="es";
if (substr($_SERVER["REQUEST_URI"],0,4)=="/de/") $_REQUEST["idioma"]="de";
if (substr($_SERVER["REQUEST_URI"],0,4)=="/fr/") $_REQUEST["idioma"]="fr";
if (substr($_SERVER["REQUEST_URI"],0,4)=="/pt/") $_REQUEST["idioma"]="pt";
if (substr($_SERVER["REQUEST_URI"],0,4)=="/se/") $_REQUEST["idioma"]="se";
if (substr($_SERVER["REQUEST_URI"],0,5)=="/cat/") $_REQUEST["idioma"]="cat";
if (substr($_SERVER["REQUEST_URI"],0,4)=="/it/") $_REQUEST["idioma"]="it";
if (substr($_SERVER["REQUEST_URI"],0,4)=="/ko/") $_REQUEST["idioma"]="ko";
if (substr($_SERVER["REQUEST_URI"],0,4)=="/ch/") $_REQUEST["idioma"]="ch";
if (substr($_SERVER["REQUEST_URI"],0,4)=="/nu/") $_REQUEST["idioma"]="nu";
if (substr($_SERVER["REQUEST_URI"],0,4)=="/ru/") $_REQUEST["idioma"]="ru";
if (substr($_SERVER["REQUEST_URI"],0,4)=="/ni/") $_REQUEST["idioma"]="ni";
// Seguridad: el idioma puede llegar crudo por ?idioma= (la query string se
// reenvia entera a slug.php via .htaccess). Se refleja sin escapar en varias
// plantillas (RUTA_RAIZ/ROOT, lang="...", vars JS) -> XSS reflejado. Se valida
// contra un allowlist antes de definir constantes y renderizar: cualquier
// valor que no sea un idioma conocido se descarta.
$__idiomasValidos = array("en","es","de","fr","pt","se","cat","it","ko","ch","nu","ru","ni");
if (!in_array(@$_REQUEST["idioma"], $__idiomasValidos, true)) $_REQUEST["idioma"] = "";
if (@$_REQUEST["idioma"]) define("RUTA_RAIZ","/".$_REQUEST["idioma"]); else define("RUTA_RAIZ","");
if (@$_REQUEST["idioma"]) define("ROOT","/".$_REQUEST["idioma"]); else define("ROOT","");
?>