786 lines
28 KiB
PHP
786 lines
28 KiB
PHP
<?php
|
|
/**
|
|
* Login ERP — Laboratorio Ximena Caicedo
|
|
* Con protección contra ataques de fuerza bruta.
|
|
*/
|
|
|
|
require_once 'config/config.php';
|
|
|
|
if (isUserLoggedIn()) {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
|
|
$error = '';
|
|
$success = '';
|
|
$loginBlocked = false;
|
|
$clientIp = $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0';
|
|
|
|
if (isset($_GET['logged_out']) && $_GET['logged_out'] == '1') {
|
|
$success = 'Sesión cerrada correctamente.';
|
|
}
|
|
if (isset($_GET['session_expired']) && $_GET['session_expired'] == '1') {
|
|
$error = 'Su sesión ha expirado por inactividad. Por favor, inicie sesión nuevamente.';
|
|
}
|
|
|
|
if (!checkLoginAttempts($clientIp)) {
|
|
$loginBlocked = true;
|
|
$error = 'Demasiados intentos de login. Inténtalo en ' . (LOGIN_LOCKOUT_TIME / 60) . ' minutos.';
|
|
}
|
|
|
|
if ($_POST && !$loginBlocked) {
|
|
$username = trim($_POST['username'] ?? '');
|
|
$password = $_POST['password'] ?? '';
|
|
$adminUser = authenticateUser($username, $password);
|
|
|
|
if ($adminUser) {
|
|
clearLoginAttempts($clientIp);
|
|
$_SESSION['admin_logged_in'] = true;
|
|
$_SESSION['admin_user'] = $adminUser;
|
|
$_SESSION['last_activity'] = time();
|
|
$_SESSION['login_ip'] = $clientIp;
|
|
$_SESSION['login_time'] = time();
|
|
|
|
$roleSlug = $adminUser['role'] ?? 'admin';
|
|
$modules = $adminUser['modules'] ?? [];
|
|
|
|
if (!empty($adminUser['home_page'])) {
|
|
$safePath = filter_var($adminUser['home_page'], FILTER_SANITIZE_URL);
|
|
if (str_starts_with($safePath, '/') && !str_starts_with($safePath, '//')) {
|
|
header('Location: ' . $safePath);
|
|
exit;
|
|
}
|
|
}
|
|
if ($roleSlug === 'enfermero') {
|
|
header('Location: enfermero_portal.php');
|
|
} elseif (count($modules) === 1 && $modules[0] === 'lab_formularios') {
|
|
header('Location: lab_formularios.php');
|
|
} elseif (count($modules) === 2
|
|
&& in_array('lab_domicilios', $modules, true)
|
|
&& in_array('lab_ordenes', $modules, true)) {
|
|
header('Location: lab_domicilios.php');
|
|
} else {
|
|
header('Location: index.php');
|
|
}
|
|
exit;
|
|
} else {
|
|
recordFailedLogin($clientIp);
|
|
$error = 'Usuario o contraseña incorrectos.';
|
|
if (!checkLoginAttempts($clientIp)) {
|
|
$loginBlocked = true;
|
|
$error = 'Demasiados intentos de login. Cuenta bloqueada por ' . (LOGIN_LOCKOUT_TIME / 60) . ' minutos.';
|
|
}
|
|
}
|
|
}
|
|
|
|
// ── Cargar configuración de la empresa para el branding ────────────────────
|
|
$cfg = [];
|
|
try {
|
|
$db = Database::getInstance();
|
|
$rows = $db->fetchAll('SELECT clave, valor FROM lab_config ORDER BY clave');
|
|
foreach ($rows as $r) {
|
|
$cfg[$r['clave']] = $r['valor'];
|
|
}
|
|
} catch (Exception $e) {
|
|
// BD no disponible: continuar con defaults
|
|
}
|
|
|
|
$empresa = htmlspecialchars($cfg['empresa_nombre'] ?? 'Laboratorio Clínico', ENT_QUOTES, 'UTF-8');
|
|
$subtitulo= htmlspecialchars($cfg['empresa_subtitulo'] ?? 'Sistema de Gestión ERP', ENT_QUOTES, 'UTF-8');
|
|
$color = preg_match('/^#[0-9a-fA-F]{3,8}$/', $cfg['doc_color'] ?? '') ? $cfg['doc_color'] : '#1565c0';
|
|
$logo = $cfg['doc_logo_base64'] ?? '';
|
|
|
|
// Calcular color derivado más oscuro para el gradiente
|
|
function adjustColor(string $hex, int $amount): string {
|
|
$hex = ltrim($hex, '#');
|
|
$r = max(0, min(255, hexdec(substr($hex, 0, 2)) + $amount));
|
|
$g = max(0, min(255, hexdec(substr($hex, 2, 2)) + $amount));
|
|
$b = max(0, min(255, hexdec(substr($hex, 4, 2)) + $amount));
|
|
return sprintf('#%02x%02x%02x', $r, $g, $b);
|
|
}
|
|
$colorDark = adjustColor($color, -40);
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Iniciar Sesión — <?= $empresa ?></title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--brand: <?= htmlspecialchars($color, ENT_QUOTES, 'UTF-8') ?>;
|
|
--brand-dark: <?= htmlspecialchars($colorDark, ENT_QUOTES, 'UTF-8') ?>;
|
|
}
|
|
|
|
* { box-sizing: border-box; }
|
|
|
|
body {
|
|
margin: 0;
|
|
min-height: 100vh;
|
|
font-family: 'Segoe UI', system-ui, sans-serif;
|
|
display: flex;
|
|
overflow: hidden;
|
|
}
|
|
|
|
/* ── Panel izquierdo — branding ─────────────────────── */
|
|
.brand-panel {
|
|
flex: 1;
|
|
background: linear-gradient(145deg, var(--brand-dark) 0%, var(--brand) 60%, color-mix(in srgb, var(--brand) 70%, #fff) 100%);
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 3rem 2.5rem;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
/* Círculos decorativos animados */
|
|
.brand-panel::before,
|
|
.brand-panel::after {
|
|
content: '';
|
|
position: absolute;
|
|
border-radius: 50%;
|
|
background: rgba(255,255,255,0.07);
|
|
animation: float 8s ease-in-out infinite;
|
|
}
|
|
.brand-panel::before {
|
|
width: 420px; height: 420px;
|
|
top: -120px; right: -100px;
|
|
animation-delay: 0s;
|
|
}
|
|
.brand-panel::after {
|
|
width: 280px; height: 280px;
|
|
bottom: -80px; left: -60px;
|
|
animation-delay: 3.5s;
|
|
}
|
|
|
|
@keyframes float {
|
|
0%, 100% { transform: translateY(0) scale(1); }
|
|
50% { transform: translateY(-20px) scale(1.04); }
|
|
}
|
|
|
|
.brand-logo {
|
|
max-height: 90px;
|
|
max-width: 200px;
|
|
object-fit: contain;
|
|
filter: drop-shadow(0 4px 16px rgba(0,0,0,0.18));
|
|
margin-bottom: 1.6rem;
|
|
animation: logoIn 0.7s ease both;
|
|
}
|
|
@keyframes logoIn {
|
|
from { opacity: 0; transform: translateY(-20px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
|
|
.brand-icon-fallback {
|
|
width: 90px; height: 90px;
|
|
border-radius: 22px;
|
|
background: rgba(255,255,255,0.18);
|
|
backdrop-filter: blur(6px);
|
|
display: flex; align-items: center; justify-content: center;
|
|
margin-bottom: 1.6rem;
|
|
font-size: 2.6rem;
|
|
color: #fff;
|
|
animation: logoIn 0.7s ease both;
|
|
}
|
|
|
|
.brand-name {
|
|
font-size: 1.7rem;
|
|
font-weight: 800;
|
|
color: #fff;
|
|
text-align: center;
|
|
line-height: 1.2;
|
|
letter-spacing: -0.01em;
|
|
text-shadow: 0 2px 10px rgba(0,0,0,0.2);
|
|
animation: slideUp 0.6s 0.1s ease both;
|
|
}
|
|
.brand-sub {
|
|
font-size: 1rem;
|
|
color: rgba(255,255,255,0.78);
|
|
text-align: center;
|
|
margin-top: 0.5rem;
|
|
animation: slideUp 0.6s 0.2s ease both;
|
|
}
|
|
.brand-badges {
|
|
display: flex;
|
|
gap: 0.6rem;
|
|
flex-wrap: wrap;
|
|
justify-content: center;
|
|
margin-top: 2.5rem;
|
|
animation: slideUp 0.6s 0.35s ease both;
|
|
}
|
|
.brand-badge {
|
|
background: rgba(255,255,255,0.15);
|
|
backdrop-filter: blur(4px);
|
|
color: #fff;
|
|
border: 1px solid rgba(255,255,255,0.25);
|
|
padding: 5px 14px;
|
|
border-radius: 100px;
|
|
font-size: 0.78rem;
|
|
font-weight: 500;
|
|
}
|
|
|
|
@keyframes slideUp {
|
|
from { opacity: 0; transform: translateY(16px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
|
|
/* ── Panel derecho — formulario ─────────────────────── */
|
|
.form-panel {
|
|
width: 420px;
|
|
min-width: 340px;
|
|
background: #fff;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
padding: 3rem 2.6rem;
|
|
box-shadow: -6px 0 40px rgba(0,0,0,0.10);
|
|
position: relative;
|
|
animation: slideIn 0.5s ease both;
|
|
}
|
|
|
|
@keyframes slideIn {
|
|
from { opacity: 0; transform: translateX(30px); }
|
|
to { opacity: 1; transform: translateX(0); }
|
|
}
|
|
|
|
.form-label {
|
|
font-size: 0.87rem;
|
|
font-weight: 600;
|
|
color: #374151;
|
|
}
|
|
.form-control {
|
|
padding: 0.72rem 1rem;
|
|
border-radius: 10px;
|
|
border: 1.5px solid #e5e7eb;
|
|
font-size: 0.95rem;
|
|
transition: border-color .2s, box-shadow .2s;
|
|
}
|
|
.form-control:focus {
|
|
border-color: var(--brand);
|
|
box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent);
|
|
outline: none;
|
|
}
|
|
.input-group .form-control { border-right: none; border-radius: 10px 0 0 10px; }
|
|
.input-group .btn-eye {
|
|
border: 1.5px solid #e5e7eb;
|
|
border-left: none;
|
|
background: #fff;
|
|
border-radius: 0 10px 10px 0;
|
|
color: #6b7280;
|
|
padding: 0 14px;
|
|
transition: color .2s;
|
|
}
|
|
.input-group .btn-eye:hover { color: var(--brand); }
|
|
|
|
.btn-login {
|
|
background: linear-gradient(135deg, var(--brand), var(--brand-dark));
|
|
border: none;
|
|
color: #fff;
|
|
width: 100%;
|
|
padding: 0.82rem;
|
|
border-radius: 12px;
|
|
font-weight: 700;
|
|
font-size: 1rem;
|
|
letter-spacing: 0.02em;
|
|
transition: transform .18s, box-shadow .18s;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
.btn-login::after {
|
|
content: '';
|
|
position: absolute;
|
|
inset: 0;
|
|
background: rgba(255,255,255,0);
|
|
transition: background .2s;
|
|
}
|
|
.btn-login:hover:not(:disabled) {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 8px 28px color-mix(in srgb, var(--brand) 45%, transparent);
|
|
}
|
|
.btn-login:hover:not(:disabled)::after { background: rgba(255,255,255,0.08); }
|
|
.btn-login:disabled { opacity: 0.65; cursor: not-allowed; }
|
|
|
|
.form-title {
|
|
font-size: 1.5rem;
|
|
font-weight: 800;
|
|
color: #111827;
|
|
margin-bottom: 0.2rem;
|
|
}
|
|
.form-subtitle {
|
|
font-size: 0.88rem;
|
|
color: #6b7280;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.dev-footer {
|
|
position: absolute;
|
|
bottom: 1rem;
|
|
left: 0; right: 0;
|
|
text-align: center;
|
|
font-size: 0.75rem;
|
|
color: #d1d5db;
|
|
}
|
|
.dev-footer a { color: #9ca3af; text-decoration: none; }
|
|
.dev-footer a:hover { color: var(--brand); }
|
|
|
|
/* Mobile */
|
|
@media (max-width: 700px) {
|
|
body { flex-direction: column; overflow: auto; }
|
|
.brand-panel { flex: none; padding: 2.5rem 1.5rem 2rem; min-height: 220px; }
|
|
.brand-panel::before { width: 200px; height: 200px; }
|
|
.brand-panel::after { width: 150px; height: 150px; }
|
|
.brand-name { font-size: 1.3rem; }
|
|
.form-panel { width: 100%; min-width: 0; box-shadow: none; padding: 2rem 1.5rem 3.5rem; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<!-- ══ Panel izquierdo — branding ═══════════════════════════════════════ -->
|
|
<div class="brand-panel">
|
|
<?php if ($logo): ?>
|
|
<img src="<?= htmlspecialchars($logo, ENT_QUOTES, 'UTF-8') ?>" alt="Logo" class="brand-logo">
|
|
<?php else: ?>
|
|
<div class="brand-icon-fallback">
|
|
<i class="fas fa-flask"></i>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="brand-name"><?= $empresa ?></div>
|
|
<div class="brand-sub"><?= $subtitulo ?></div>
|
|
|
|
<div class="brand-badges">
|
|
<span class="brand-badge"><i class="fas fa-vials me-1"></i>Análisis Clínicos</span>
|
|
<span class="brand-badge"><i class="fas fa-house-medical me-1"></i>Domicilios</span>
|
|
<span class="brand-badge"><i class="fas fa-file-invoice me-1"></i>Documentos PDF</span>
|
|
<span class="brand-badge"><i class="fas fa-chart-bar me-1"></i>Reportes</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ══ Panel derecho — formulario ═══════════════════════════════════════ -->
|
|
<div class="form-panel">
|
|
<p class="form-title">Bienvenido</p>
|
|
<p class="form-subtitle">Inicia sesión en el sistema ERP</p>
|
|
|
|
<?php if ($loginBlocked): ?>
|
|
<div class="alert alert-danger d-flex align-items-center gap-2 mb-4" role="alert">
|
|
<i class="fas fa-ban fa-lg"></i>
|
|
<div><?= htmlspecialchars($error, ENT_QUOTES, 'UTF-8') ?></div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($success): ?>
|
|
<div class="alert alert-success d-flex align-items-center gap-2 mb-4">
|
|
<i class="fas fa-check-circle"></i>
|
|
<div><?= htmlspecialchars($success, ENT_QUOTES, 'UTF-8') ?></div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($error && !$loginBlocked): ?>
|
|
<div class="alert alert-danger d-flex align-items-center gap-2 mb-4">
|
|
<i class="fas fa-exclamation-triangle"></i>
|
|
<div><?= htmlspecialchars($error, ENT_QUOTES, 'UTF-8') ?></div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST" id="loginForm" autocomplete="on">
|
|
<div class="mb-3">
|
|
<label for="username" class="form-label">
|
|
<i class="fas fa-user me-1" style="color:var(--brand)"></i> Usuario
|
|
</label>
|
|
<input type="text" class="form-control" id="username" name="username"
|
|
required <?= $loginBlocked ? 'disabled' : '' ?>
|
|
placeholder="Tu usuario"
|
|
value="<?= htmlspecialchars($_POST['username'] ?? '', ENT_QUOTES, 'UTF-8') ?>"
|
|
autofocus>
|
|
</div>
|
|
|
|
<div class="mb-4">
|
|
<label for="password" class="form-label">
|
|
<i class="fas fa-lock me-1" style="color:var(--brand)"></i> Contraseña
|
|
</label>
|
|
<div class="input-group">
|
|
<input type="password" class="form-control" id="password" name="password"
|
|
required <?= $loginBlocked ? 'disabled' : '' ?>
|
|
placeholder="Tu contraseña">
|
|
<button class="btn-eye" type="button" id="togglePwd" <?= $loginBlocked ? 'disabled' : '' ?>>
|
|
<i class="fas fa-eye"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<button type="submit" class="btn-login" <?= $loginBlocked ? 'disabled' : '' ?>>
|
|
<?php if ($loginBlocked): ?>
|
|
<i class="fas fa-ban me-2"></i>Acceso bloqueado
|
|
<?php else: ?>
|
|
<i class="fas fa-arrow-right-to-bracket me-2"></i>Iniciar sesión
|
|
<?php endif; ?>
|
|
</button>
|
|
</form>
|
|
|
|
<div class="dev-footer">
|
|
Desarrollado por <a href="https://u-site.app" target="_blank" rel="noopener">usite.app</a>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.getElementById('togglePwd').addEventListener('click', function () {
|
|
const pwd = document.getElementById('password');
|
|
const icon = this.querySelector('i');
|
|
if (pwd.type === 'password') {
|
|
pwd.type = 'text';
|
|
icon.classList.replace('fa-eye', 'fa-eye-slash');
|
|
} else {
|
|
pwd.type = 'password';
|
|
icon.classList.replace('fa-eye-slash', 'fa-eye');
|
|
}
|
|
});
|
|
<?php if ($loginBlocked): ?>
|
|
document.getElementById('loginForm').addEventListener('submit', e => e.preventDefault());
|
|
<?php endif; ?>
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|
|
|
|
// Con Docker, la instalación siempre está completada
|
|
// El archivo .installation_completed se crea automáticamente o no es necesario
|
|
|
|
// Si ya está logueado, redirigir al panel
|
|
if (isUserLoggedIn()) {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
|
|
$error = '';
|
|
$success = '';
|
|
$loginBlocked = false;
|
|
$clientIp = $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0';
|
|
|
|
// Verificar si viene de logout
|
|
if (isset($_GET['logged_out']) && $_GET['logged_out'] == '1') {
|
|
$success = 'Sesión cerrada correctamente.';
|
|
}
|
|
|
|
// Verificar si la sesión expiró
|
|
if (isset($_GET['session_expired']) && $_GET['session_expired'] == '1') {
|
|
$error = 'Su sesión ha expirado por inactividad. Por favor, inicie sesión nuevamente.';
|
|
}
|
|
|
|
// Verificar si la IP está bloqueada
|
|
if (!checkLoginAttempts($clientIp)) {
|
|
$loginBlocked = true;
|
|
$error = 'Demasiados intentos de login. Inténtalo en ' . (LOGIN_LOCKOUT_TIME / 60) . ' minutos.';
|
|
}
|
|
|
|
// Procesar login
|
|
if ($_POST && !$loginBlocked) {
|
|
$username = trim($_POST['username'] ?? '');
|
|
$password = $_POST['password'] ?? '';
|
|
|
|
// Usar el nuevo sistema de autenticación unificado
|
|
$adminUser = authenticateUser($username, $password);
|
|
|
|
if ($adminUser) {
|
|
// Login exitoso
|
|
clearLoginAttempts($clientIp);
|
|
$_SESSION['admin_logged_in'] = true;
|
|
$_SESSION['admin_user'] = $adminUser;
|
|
$_SESSION['last_activity'] = time();
|
|
$_SESSION['login_ip'] = $clientIp;
|
|
$_SESSION['login_time'] = time();
|
|
|
|
// Redirigir según el rol
|
|
$roleSlug = $adminUser['role'] ?? 'admin';
|
|
$modules = $adminUser['modules'] ?? [];
|
|
|
|
// 1. Página de inicio configurada explícitamente para el rol
|
|
if (!empty($adminUser['home_page'])) {
|
|
$safePath = filter_var($adminUser['home_page'], FILTER_SANITIZE_URL);
|
|
// Solo rutas relativas (evitar redirects abiertos)
|
|
if (str_starts_with($safePath, '/') && !str_starts_with($safePath, '//')) {
|
|
header('Location: ' . $safePath);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
// 2. Reglas heredadas (compatibilidad hacia atrás)
|
|
if ($roleSlug === 'enfermero') {
|
|
header('Location: enfermero_portal.php');
|
|
} elseif (count($modules) === 1 && $modules[0] === 'lab_formularios') {
|
|
header('Location: lab_formularios.php');
|
|
} elseif (count($modules) === 2
|
|
&& in_array('lab_domicilios', $modules, true)
|
|
&& in_array('lab_ordenes', $modules, true)) {
|
|
header('Location: lab_domicilios.php');
|
|
} else {
|
|
header('Location: index.php');
|
|
}
|
|
exit;
|
|
} else {
|
|
// Login fallido
|
|
recordFailedLogin($clientIp);
|
|
$error = 'Usuario o contraseña incorrectos.';
|
|
if (!checkLoginAttempts($clientIp)) {
|
|
$loginBlocked = true;
|
|
$error = 'Demasiados intentos de login. Cuenta bloqueada por ' . (LOGIN_LOCKOUT_TIME / 60) . ' minutos.';
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>🔐 Login - WhatsApp Bot Manager</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--primary-color: #25d366;
|
|
--secondary-color: #075e54;
|
|
--bg-gradient: linear-gradient(135deg, #25d366 0%, #075e54 100%);
|
|
}
|
|
body {
|
|
background: var(--bg-gradient);
|
|
min-height: 100vh;
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 0.75rem;
|
|
padding: 2rem 1rem;
|
|
}
|
|
.login-card {
|
|
background: rgba(255,255,255,0.95);
|
|
border-radius: 20px;
|
|
backdrop-filter: blur(10px);
|
|
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
width: 100%;
|
|
max-width: 400px;
|
|
}
|
|
.btn-login {
|
|
background: var(--bg-gradient);
|
|
border: none;
|
|
color: white;
|
|
padding: 12px;
|
|
border-radius: 10px;
|
|
font-weight: 600;
|
|
width: 100%;
|
|
}
|
|
.btn-login:hover {
|
|
transform: translateY(-2px);
|
|
color: white;
|
|
box-shadow: 0 8px 25px rgba(37, 211, 102, 0.3);
|
|
}
|
|
.btn-login:disabled {
|
|
background: #6c757d;
|
|
transform: none;
|
|
box-shadow: none;
|
|
}
|
|
.form-control {
|
|
padding: 12px;
|
|
border-radius: 10px;
|
|
border: 2px solid #e9ecef;
|
|
}
|
|
.form-control:focus {
|
|
border-color: var(--primary-color);
|
|
box-shadow: 0 0 0 0.2rem rgba(37, 211, 102, 0.25);
|
|
}
|
|
.logo-icon {
|
|
font-size: 4rem;
|
|
background: var(--bg-gradient);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
background-clip: text;
|
|
}
|
|
.developer-info {
|
|
background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
border-radius: 15px;
|
|
padding: 1rem;
|
|
margin-top: 2rem;
|
|
text-align: center;
|
|
}
|
|
.security-badge {
|
|
background: #28a745;
|
|
color: white;
|
|
padding: 5px 10px;
|
|
border-radius: 15px;
|
|
font-size: 0.8rem;
|
|
margin: 2px;
|
|
display: inline-block;
|
|
}
|
|
.attempts-warning {
|
|
background: linear-gradient(45deg, #ff6b6b, #ee5a24);
|
|
color: white;
|
|
border-radius: 10px;
|
|
padding: 15px;
|
|
animation: pulse 2s infinite;
|
|
}
|
|
@keyframes pulse {
|
|
0% { transform: scale(1); }
|
|
50% { transform: scale(1.05); }
|
|
100% { transform: scale(1); }
|
|
}
|
|
|
|
/* Pie de desarrollador discreto */
|
|
.developer-footer {
|
|
font-size: 0.85rem;
|
|
color: rgba(31,41,55,0.65);
|
|
text-align: center;
|
|
width: 100%;
|
|
max-width: 420px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-card p-5">
|
|
<!-- Header -->
|
|
<div class="text-center mb-4">
|
|
<i class="fab fa-whatsapp logo-icon"></i>
|
|
<h2 class="mt-3 fw-bold">WhatsApp Bot Manager</h2>
|
|
<p class="text-muted mb-0">Panel de Administración</p>
|
|
</div>
|
|
|
|
<!-- Características de Seguridad -->
|
|
<div class="mb-4 text-center">
|
|
<span class="security-badge"><i class="fas fa-shield-alt me-1"></i>Protección Brute Force</span>
|
|
<span class="security-badge"><i class="fas fa-lock me-1"></i>Sesiones Seguras</span>
|
|
<span class="security-badge"><i class="fas fa-user-shield me-1"></i>Control de Acceso</span>
|
|
</div>
|
|
|
|
<!-- Error de bloqueo -->
|
|
<?php if ($loginBlocked): ?>
|
|
<div class="attempts-warning mb-4">
|
|
<div class="text-center">
|
|
<i class="fas fa-ban fa-2x mb-2"></i>
|
|
<h5>Acceso Bloqueado</h5>
|
|
<p class="mb-0"><?= htmlspecialchars($error) ?></p>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- Formulario de Login -->
|
|
<form method="POST" id="loginForm">
|
|
<!-- Campo Usuario -->
|
|
<div class="mb-3">
|
|
<label for="username" class="form-label">
|
|
<i class="fas fa-user me-2"></i>Usuario
|
|
</label>
|
|
<input
|
|
type="text"
|
|
class="form-control"
|
|
id="username"
|
|
name="username"
|
|
required
|
|
<?= $loginBlocked ? 'disabled' : '' ?>
|
|
placeholder="Ingresa tu usuario"
|
|
value="<?= htmlspecialchars($_POST['username'] ?? '') ?>"
|
|
>
|
|
</div>
|
|
|
|
<!-- Campo Contraseña -->
|
|
<div class="mb-3">
|
|
<label for="password" class="form-label">
|
|
<i class="fas fa-lock me-2"></i>Contraseña
|
|
</label>
|
|
<div class="input-group">
|
|
<input
|
|
type="password"
|
|
class="form-control"
|
|
id="password"
|
|
name="password"
|
|
required
|
|
<?= $loginBlocked ? 'disabled' : '' ?>
|
|
placeholder="Ingresa tu contraseña"
|
|
>
|
|
<button
|
|
class="btn btn-outline-secondary"
|
|
type="button"
|
|
id="togglePassword"
|
|
<?= $loginBlocked ? 'disabled' : '' ?>
|
|
>
|
|
<i class="fas fa-eye"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Success conversations -->
|
|
<?php if ($success): ?>
|
|
<div class="alert alert-success">
|
|
<i class="fas fa-check-circle me-2"></i>
|
|
<?= htmlspecialchars($success) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- Error conversations -->
|
|
<?php if ($error && !$loginBlocked): ?>
|
|
<div class="alert alert-danger">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>
|
|
<?= htmlspecialchars($error) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- Submit Button -->
|
|
<button
|
|
type="submit"
|
|
class="btn-login"
|
|
<?= $loginBlocked ? 'disabled' : '' ?>
|
|
>
|
|
<?php if ($loginBlocked): ?>
|
|
<i class="fas fa-ban me-2"></i>Acceso Bloqueado
|
|
<?php else: ?>
|
|
<i class="fas fa-sign-in-alt me-2"></i>Iniciar Sesión
|
|
<?php endif; ?>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Pequeño pie discreto del desarrollador -->
|
|
<div class="developer-footer mt-3">
|
|
<small style="color: rgba(246, 247, 248, 0.65); text-align: center;">Desarrollado con ❤️ por <a href="https://u-site.app" target="_blank" rel="noopener noreferrer" style="text-decoration: underline; color:white;">usite</a></small>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script>
|
|
// Toggle password visibility
|
|
document.getElementById('togglePassword').addEventListener('click', function() {
|
|
const password = document.getElementById('password');
|
|
const icon = this.querySelector('i');
|
|
|
|
if (password.type === 'password') {
|
|
password.type = 'text';
|
|
icon.classList.remove('fa-eye');
|
|
icon.classList.add('fa-eye-slash');
|
|
} else {
|
|
password.type = 'password';
|
|
icon.classList.remove('fa-eye-slash');
|
|
icon.classList.add('fa-eye');
|
|
}
|
|
});
|
|
|
|
// Auto-focus en password field
|
|
<?php if (!$loginBlocked): ?>
|
|
document.getElementById('password').focus();
|
|
<?php endif; ?>
|
|
|
|
// Disable form on blocked
|
|
<?php if ($loginBlocked): ?>
|
|
document.getElementById('loginForm').addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
return false;
|
|
});
|
|
<?php endif; ?>
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</html>
|