Compare commits
1
Commits
main
..
f0060f3eb8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0060f3eb8 |
@@ -34,7 +34,6 @@ class AcaiAPI
|
|||||||
// ── Cache flags (mirror CocoDB interface) ─────────────────────────
|
// ── Cache flags (mirror CocoDB interface) ─────────────────────────
|
||||||
public static $redis = null;
|
public static $redis = null;
|
||||||
public static $redis_expireTime = 0;
|
public static $redis_expireTime = 0;
|
||||||
public static $redis_no_disponible = false;
|
|
||||||
public static $force_load_cache = false;
|
public static $force_load_cache = false;
|
||||||
public static $force_redis = false;
|
public static $force_redis = false;
|
||||||
public static $force_redis_module = false; // consumed by external cache layer
|
public static $force_redis_module = false; // consumed by external cache layer
|
||||||
@@ -648,29 +647,14 @@ class AcaiAPI
|
|||||||
/** Connect to Redis (idempotent). */
|
/** Connect to Redis (idempotent). */
|
||||||
static function initCache()
|
static function initCache()
|
||||||
{
|
{
|
||||||
// Sin Redis (hosting propio sin el servicio o sin la extensión, o el
|
|
||||||
// servicio caído) la web sigue SIN caché en vez de morir con un fatal:
|
|
||||||
// cacheGet/cacheSet ya no hacen nada si no hay conexión. Se marca para
|
|
||||||
// no reintentar en cada consulta de la misma petición.
|
|
||||||
if (self::$redis_no_disponible) return;
|
|
||||||
if (!class_exists('Redis')) {
|
|
||||||
self::$redis_no_disponible = true;
|
|
||||||
self::$redis = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$redisHost = getenv('REDIS_HOST') ?: '127.0.0.1';
|
$redisHost = getenv('REDIS_HOST') ?: '127.0.0.1';
|
||||||
$redisPort = (int)(getenv('REDIS_PORT') ?: 6379);
|
$redisPort = (int)(getenv('REDIS_PORT') ?: 6379);
|
||||||
|
|
||||||
try {
|
if (!self::$redis) {
|
||||||
if (!self::$redis) self::$redis = new Redis();
|
self::$redis = new Redis();
|
||||||
if (!self::$redis->isConnected() && !self::$redis->connect($redisHost, $redisPort)) {
|
self::$redis->connect($redisHost, $redisPort);
|
||||||
throw new RuntimeException("no se pudo conectar a $redisHost:$redisPort");
|
} elseif (!self::$redis->isConnected()) {
|
||||||
}
|
self::$redis->connect($redisHost, $redisPort);
|
||||||
} catch (Throwable $e) {
|
|
||||||
self::$redis_no_disponible = true;
|
|
||||||
self::$redis = null;
|
|
||||||
error_log('[cache] Redis no disponible, se sigue sin caché: ' . $e->getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ class CocoDB
|
|||||||
public static $trackData = [];
|
public static $trackData = [];
|
||||||
public static $redis = null;
|
public static $redis = null;
|
||||||
public static $redis_expireTime = 0;
|
public static $redis_expireTime = 0;
|
||||||
public static $redis_no_disponible = false;
|
|
||||||
public static $force_load_cache = false;
|
public static $force_load_cache = false;
|
||||||
public static $force_redis = false;
|
public static $force_redis = false;
|
||||||
public static $force_redis_module = false;
|
public static $force_redis_module = false;
|
||||||
@@ -1177,29 +1176,14 @@ class CocoDB
|
|||||||
*/
|
*/
|
||||||
static function initCache()
|
static function initCache()
|
||||||
{
|
{
|
||||||
// Sin Redis (hosting propio sin el servicio o sin la extensión, o el
|
|
||||||
// servicio caído) la web sigue SIN caché en vez de morir con un fatal:
|
|
||||||
// cacheGet/cacheSet ya no hacen nada si no hay conexión. Se marca para
|
|
||||||
// no reintentar en cada consulta de la misma petición.
|
|
||||||
if (self::$redis_no_disponible) return;
|
|
||||||
if (!class_exists('Redis')) {
|
|
||||||
self::$redis_no_disponible = true;
|
|
||||||
self::$redis = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$redisHost = getenv('REDIS_HOST') ?: '127.0.0.1';
|
$redisHost = getenv('REDIS_HOST') ?: '127.0.0.1';
|
||||||
$redisPort = (int)(getenv('REDIS_PORT') ?: 6379);
|
$redisPort = (int)(getenv('REDIS_PORT') ?: 6379);
|
||||||
|
|
||||||
try {
|
if (!self::$redis) {
|
||||||
if (!self::$redis) self::$redis = new Redis();
|
self::$redis = new Redis();
|
||||||
if (!self::$redis->isConnected() && !self::$redis->connect($redisHost, $redisPort)) {
|
self::$redis->connect($redisHost, $redisPort);
|
||||||
throw new RuntimeException("no se pudo conectar a $redisHost:$redisPort");
|
} else if (!self::$redis->isConnected()) {
|
||||||
}
|
self::$redis->connect($redisHost, $redisPort);
|
||||||
} catch (Throwable $e) {
|
|
||||||
self::$redis_no_disponible = true;
|
|
||||||
self::$redis = null;
|
|
||||||
error_log('[cache] Redis no disponible, se sigue sin caché: ' . $e->getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-9
@@ -20,15 +20,7 @@ if (file_exists($filePath)) {
|
|||||||
# <?=strtoupper($configuracionRecord["tienda_nombre_empresa"]);?>
|
# <?=strtoupper($configuracionRecord["tienda_nombre_empresa"]);?>
|
||||||
|
|
||||||
User-agent: *
|
User-agent: *
|
||||||
<?
|
<? if (strpos($_SERVER["HTTP_HOST"], "plandeweb.com")) {?>
|
||||||
// Cerrada mientras no este publicada: la regla es `acaiRobotsBloqueados` del
|
|
||||||
// plugin builder_saas (la misma de header.php y de la puerta de las webs
|
|
||||||
// Astro). Un robots.txt propio de la web manda sobre esto (arriba). Sin el
|
|
||||||
// plugin, como siempre: solo se cierran los dominios de pruebas.
|
|
||||||
$robotsBloqueados = strpos($_SERVER["HTTP_HOST"], "plandeweb.com")
|
|
||||||
|| (function_exists("acaiRobotsBloqueados")
|
|
||||||
&& acaiRobotsBloqueados(is_file(dirname(__DIR__) . "/.acai"), @$configuracionRecord['pagina_publicada']));
|
|
||||||
if ($robotsBloqueados) {?>
|
|
||||||
Disallow: /
|
Disallow: /
|
||||||
<? }?>
|
<? }?>
|
||||||
<? if (@$configuracionRecord['pagina_publicada']) {?>
|
<? if (@$configuracionRecord['pagina_publicada']) {?>
|
||||||
|
|||||||
+2
-18
@@ -78,32 +78,16 @@ $config_header = array(
|
|||||||
// prod + publicada -> se ve
|
// prod + publicada -> se ve
|
||||||
// prod + sin publicar + ?pruebas -> se ve, con el cartel rojo
|
// prod + sin publicar + ?pruebas -> se ve, con el cartel rojo
|
||||||
// prod + sin publicar + visitante -> mantenimiento
|
// prod + sin publicar + visitante -> mantenimiento
|
||||||
//
|
|
||||||
// La tabla de arriba es UNA regla para todas las webs (PHP y Astro) y para el
|
|
||||||
// robots.txt: `acaiVisibilidadWeb` del plugin builder_saas (ws_respond.php),
|
|
||||||
// que se reparte entero a todas las webs. Se llama con function_exists por la
|
|
||||||
// misma razon que la señal va en linea: si una web no trae el plugin, se
|
|
||||||
// queda con la RESERVA de abajo, que es la regla de siempre (y el cartel con
|
|
||||||
// 200, sin las cabeceras 503 de `acaiCabecerasMantenimiento`).
|
|
||||||
$esEntornoLocal = is_file(dirname(__FILE__) . "/.acai");
|
$esEntornoLocal = is_file(dirname(__FILE__) . "/.acai");
|
||||||
|
|
||||||
if (function_exists("acaiVisibilidadWeb")) {
|
if ($esEntornoLocal || @$configuracionRecord["pagina_publicada"] || isset($_SESSION["pruebas"])) {
|
||||||
$visibilidadWeb = acaiVisibilidadWeb($esEntornoLocal, @$configuracionRecord["pagina_publicada"], isset($_SESSION["pruebas"]));
|
|
||||||
} else {
|
|
||||||
// RESERVA (sin el plugin): la misma tabla, en linea.
|
|
||||||
$visibilidadWeb = ($esEntornoLocal || @$configuracionRecord["pagina_publicada"]) ? "visible"
|
|
||||||
: (isset($_SESSION["pruebas"]) ? "pruebas" : "mantenimiento");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($visibilidadWeb !== "mantenimiento") {
|
|
||||||
if (@$customCode) echo modulo('custom-header',$config_header); else echo tpl('cabecera',$config_header);
|
if (@$customCode) echo modulo('custom-header',$config_header); else echo tpl('cabecera',$config_header);
|
||||||
if ($visibilidadWeb === "pruebas") {
|
if (!$esEntornoLocal && isset($_SESSION["pruebas"]) && @$configuracionRecord["pagina_publicada"] == 0) {
|
||||||
?>
|
?>
|
||||||
<div style="position:absolute;top:0px;width:150px;background-color:red;color:#fff;font-size:12px;padding:0 10px;z-index:99999999;transform:translateZ(1000px);">SITIO EN PRUEBAS</div>
|
<div style="position:absolute;top:0px;width:150px;background-color:red;color:#fff;font-size:12px;padding:0 10px;z-index:99999999;transform:translateZ(1000px);">SITIO EN PRUEBAS</div>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (function_exists("acaiCabecerasMantenimiento")) acaiCabecerasMantenimiento();
|
|
||||||
die(tpl('mantenimiento',$config_header));
|
die(tpl('mantenimiento',$config_header));
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user