inicio
This commit is contained in:
2025-05-05 11:03:01 -06:00
commit c73e3f2327
185 changed files with 17573 additions and 0 deletions

20
app/helpers/bitacoras.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
function registrarBitacora($conn, $idUsuario, $email, $ip, $exito, $detalle) {
$sql = "INSERT INTO bitacora_login (id_usuario, email, ip, exito, detalle)
VALUES (?, ?, ?, ?, ?)";
$params = [$idUsuario, $email, $ip, $exito, $detalle];
sqlsrv_query($conn, $sql, $params);
}
function registrar_bitacora_usuario($usuarioId, $accion, $descripcion) {
$conn = getConnection();
$sql = "INSERT INTO bitacora_usuarios (usuario_id, accion, descripcion)
VALUES (?, ?, ?)";
$params = [$usuarioId, $accion, $descripcion];
sqlsrv_query($conn, $sql, $params);
}

12
app/helpers/crypto.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
function encrypt($data) {
$key = $_ENV['ENCRYPTION_KEY'];
$iv = $_ENV['ENCRYPTION_IV'];
return base64_encode(openssl_encrypt($data, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv));
}
function decrypt($data) {
$key = $_ENV['ENCRYPTION_KEY'];
$iv = $_ENV['ENCRYPTION_IV'];
return openssl_decrypt(base64_decode($data), 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
}

11
app/helpers/env.php Normal file
View File

@@ -0,0 +1,11 @@
<?php
function loadEnv($path = __DIR__ . '/../../.env') {
if (!file_exists($path)) return;
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
if (str_starts_with(trim($line), '#')) continue;
list($name, $value) = explode('=', $line, 2);
$_ENV[trim($name)] = trim($value);
}
}

4
app/helpers/session.php Normal file
View File

@@ -0,0 +1,4 @@
<?php
if (session_status() === PHP_SESSION_NONE) {
session_start();
}