Compare commits
4
Commits
80b6541e30
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dabdfa1354 | ||
|
|
bb532515ce | ||
|
|
d1235f2e20 | ||
|
|
cb03ecd239 |
@@ -34,6 +34,7 @@ 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
|
||||||
@@ -647,14 +648,29 @@ 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);
|
||||||
|
|
||||||
if (!self::$redis) {
|
try {
|
||||||
self::$redis = new Redis();
|
if (!self::$redis) self::$redis = new Redis();
|
||||||
self::$redis->connect($redisHost, $redisPort);
|
if (!self::$redis->isConnected() && !self::$redis->connect($redisHost, $redisPort)) {
|
||||||
} elseif (!self::$redis->isConnected()) {
|
throw new RuntimeException("no se pudo conectar a $redisHost:$redisPort");
|
||||||
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,6 +14,7 @@ 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;
|
||||||
@@ -1176,14 +1177,29 @@ 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);
|
||||||
|
|
||||||
if (!self::$redis) {
|
try {
|
||||||
self::$redis = new Redis();
|
if (!self::$redis) self::$redis = new Redis();
|
||||||
self::$redis->connect($redisHost, $redisPort);
|
if (!self::$redis->isConnected() && !self::$redis->connect($redisHost, $redisPort)) {
|
||||||
} else if (!self::$redis->isConnected()) {
|
throw new RuntimeException("no se pudo conectar a $redisHost:$redisPort");
|
||||||
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-1
@@ -20,7 +20,15 @@ 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']) {?>
|
||||||
|
|||||||
+18
-2
@@ -78,16 +78,32 @@ $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 ($esEntornoLocal || @$configuracionRecord["pagina_publicada"] || isset($_SESSION["pruebas"])) {
|
if (function_exists("acaiVisibilidadWeb")) {
|
||||||
|
$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 (!$esEntornoLocal && isset($_SESSION["pruebas"]) && @$configuracionRecord["pagina_publicada"] == 0) {
|
if ($visibilidadWeb === "pruebas") {
|
||||||
?>
|
?>
|
||||||
<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