ujp
This commit is contained in:
@@ -19,6 +19,7 @@ define('DB_CHARSET', 'utf8mb4');
|
||||
define('ADMIN_PASSWORD', '$2y$10$IXCY8Sm1xFkfhC6Y67Ahn.QLHxE.sjWfmTEOKFZdCN2a9s9YLVuGW'); // password123
|
||||
|
||||
// Función para cargar archivo .env
|
||||
if (!function_exists('loadEnvFile')) {
|
||||
function loadEnvFile($path) {
|
||||
if (!file_exists($path)) {
|
||||
return false;
|
||||
@@ -41,22 +42,27 @@ function loadEnvFile($path) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Cargar .env si existe
|
||||
loadEnvFile(__DIR__ . '/../.env');
|
||||
|
||||
// Función helper para obtener variables de entorno
|
||||
if (!function_exists('env')) {
|
||||
function env($key, $default = null) {
|
||||
return $_ENV[$key] ?? getenv($key) ?: $default;
|
||||
}
|
||||
}
|
||||
|
||||
// Incluir clase Database
|
||||
require_once __DIR__ . '/../classes/Database.php';
|
||||
|
||||
// Función para verificar si la instalación está completada
|
||||
if (!function_exists('isInstallationCompleted')) {
|
||||
function isInstallationCompleted() {
|
||||
return file_exists(dirname(__DIR__) . '/.installation_completed');
|
||||
}
|
||||
}
|
||||
|
||||
// Función para obtener configuración desde base de datos
|
||||
function getConfigFromDB($key, $default = null) {
|
||||
@@ -516,11 +522,14 @@ function getAdminUsers() {
|
||||
}
|
||||
|
||||
// Función para verificar login
|
||||
if (!function_exists('isUserLoggedIn')) {
|
||||
function isUserLoggedIn() {
|
||||
return isset($_SESSION['admin_logged_in']) && $_SESSION['admin_logged_in'] === true;
|
||||
}
|
||||
}
|
||||
|
||||
// Función para verificar intentos de login
|
||||
if (!function_exists('checkLoginAttempts')) {
|
||||
function checkLoginAttempts($ip) {
|
||||
$attemptsFile = dirname(__DIR__) . '/.login_attempts.json';
|
||||
|
||||
@@ -544,8 +553,10 @@ function checkLoginAttempts($ip) {
|
||||
|
||||
return $ipData['attempts'] < MAX_LOGIN_ATTEMPTS;
|
||||
}
|
||||
}
|
||||
|
||||
// Función para registrar intento de login fallido
|
||||
if (!function_exists('recordFailedLogin')) {
|
||||
function recordFailedLogin($ip) {
|
||||
$attemptsFile = dirname(__DIR__) . '/.login_attempts.json';
|
||||
|
||||
@@ -566,8 +577,10 @@ function recordFailedLogin($ip) {
|
||||
|
||||
file_put_contents($attemptsFile, json_encode($attempts));
|
||||
}
|
||||
}
|
||||
|
||||
// Función para limpiar intentos de login exitoso
|
||||
if (!function_exists('clearLoginAttempts')) {
|
||||
function clearLoginAttempts($ip) {
|
||||
$attemptsFile = dirname(__DIR__) . '/.login_attempts.json';
|
||||
|
||||
@@ -577,6 +590,7 @@ function clearLoginAttempts($ip) {
|
||||
file_put_contents($attemptsFile, json_encode($attempts));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Autoloader
|
||||
spl_autoload_register(function ($class) {
|
||||
@@ -782,6 +796,7 @@ function validateWhatsAppConfig() {
|
||||
}
|
||||
|
||||
// Función para logging centralizado
|
||||
if (!function_exists('writeLog')) {
|
||||
function writeLog($level, $message, $context = []) {
|
||||
if (!ENABLE_LOGGING) return;
|
||||
|
||||
@@ -803,6 +818,7 @@ function writeLog($level, $message, $context = []) {
|
||||
|
||||
file_put_contents($logDir . '/system.log', $logMessage, FILE_APPEND | LOCK_EX);
|
||||
}
|
||||
}
|
||||
|
||||
// Crear directorios necesarios
|
||||
$requiredDirs = [
|
||||
|
||||
Reference in New Issue
Block a user