?php declare(strict_types=1); /* * Configuración pública y privada. * Los valores reales se cargan desde config/config.local.php, protegido por * .htaccess y fuera del acceso público. */ $defaults = [ 'site_url' => 'https://datatobe.com', 'site_name' => 'DataToBe', 'contact_email' => 'contact@datatobe.com', 'default_locale' => 'es', 'integrations' => [ 'n8n_webhook_url' => '', 'n8n_chat_webhook_url' => '', ], 'agent' => [ 'enabled' => true, 'title' => 'Asistente DataToBe', 'intro' => 'Pregunta sobre datos, IA y automatización para tu negocio.', 'embed_url' => '', ], 'analytics' => [ 'consent_required' => true, 'ga4_id' => '' 'gtm_id' => '', 'google_ads_id' => '', 'google_ads_conversion_label' => '', 'meta_pixel_id' => '', ], 'verification' => [ 'google_search_console' => '', 'bing_webmaster' => '', ], 'captcha' => [ 'enabled' => false, 'provider' => 'recaptcha_v3', 'site_key' => '', 'secret_key' => '', 'min_score' => 0.5, ], ]; $localConfig = []; $configCandidates = [__DIR__ . '/config/config.local.php']; foreach ($configCandidates as $candidate) { if (is_file($candidate)) { $loaded = require $candidate; if (is_array($loaded)) { $localConfig = array_replace_recursive($localConfig, $loaded); } } } $DTB_CONFIG = array_replace_recursive($defaults, $localConfig); if (!defined('SITE_URL')) define('SITE_URL', rtrim((string) $DTB_CONFIG['site_url'], '/')); if (!defined('SITE_NAME')) define('SITE_NAME', (string) $DTB_CONFIG['site_name']); if (!defined('CONTACT_EMAIL')) define('CONTACT_EMAIL', (string) $DTB_CONFIG['contact_email']); if (!defined('DEFAULT_LOCALE')) define('DEFAULT_LOCALE', (string) $DTB_CONFIG['default_locale']); // Todas las páginas comparten la sesión para proteger el formulario con CSRF. if (session_status() !== PHP_SESSION_ACTIVE) { $isHttps = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (int) ($_SERVER['SERVER_PORT'] ?? 0) === 443; session_set_cookie_params([ 'httponly' => true, 'secure' => $isHttps, 'samesite' => 'Lax', 'path' => '/', ]); session_start(); } function asset(string $path): string { return '/assets/' . ltrim($path, '/'); } function esc(string $value): string { return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); } function dtb_config(string $path, mixed $fallback = null): mixed { global $DTB_CONFIG; $value = $DTB_CONFIG; foreach (explode('.', $path) as $segment) { if (!is_array($value) || !array_key_exists($segment, $value)) { return $fallback; } $value = $value[$segment]; } return $value; }