222 lines
7.2 KiB
PHP
222 lines
7.2 KiB
PHP
<?php
|
|
$nombre = $config['nombre_plataforma'] ?? 'Sistema Integral para Importadores de Hidrocarburos';
|
|
$siglas = $config['siglas'] ?? 'SIIH';
|
|
$logo = $config['logo_url'] ?? 'assets/img/logo_siih.png';
|
|
$color1 = explode(',', $config['colores_primarios'] ?? '#003366,#0055A5')[0];
|
|
$color2 = explode(',', $config['colores_primarios'] ?? '#003366,#0055A5')[1];
|
|
$mantenimiento = $config['modo_mantenimiento'] ?? 0;
|
|
$mensajeMantenimiento = $config['mensaje_mantenimiento'] ?? 'El sistema se encuentra en mantenimiento temporal. Por favor, vuelve más tarde.';
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title><?= htmlspecialchars($siglas) ?> | Recuperación de Contraseña</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" rel="stylesheet">
|
|
|
|
<style>
|
|
body {
|
|
background-color: #f4f6f9;
|
|
font-family: 'Segoe UI', sans-serif;
|
|
position: relative;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.navbar {
|
|
background-color: #fff;
|
|
}
|
|
|
|
.navbar .nav-link, .navbar-brand {
|
|
color: <?= $color1 ?> !important;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.logo-siih {
|
|
height: 90px;
|
|
margin-right: 10px;
|
|
}
|
|
|
|
.login-container {
|
|
max-width: 420px;
|
|
margin: 80px auto;
|
|
background: white;
|
|
padding: 40px;
|
|
border-radius: 12px;
|
|
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
|
|
z-index: 10;
|
|
position: relative;
|
|
}
|
|
|
|
.form-control {
|
|
border-radius: 6px;
|
|
}
|
|
|
|
footer {
|
|
background-color: #e9ecef;
|
|
padding: 20px;
|
|
text-align: center;
|
|
font-size: 14px;
|
|
color: #666;
|
|
margin-top: 60px;
|
|
}
|
|
|
|
/* Contenedor de fondo semitransparente para las vistas */
|
|
.overlay {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background: rgba(0, 0, 0, 0.5);
|
|
z-index: 5;
|
|
pointer-events: none; /* Para que no interfiera con los clics */
|
|
}
|
|
#mensaje {
|
|
transition: opacity 0.3s ease;
|
|
}
|
|
@media (max-height: 600px) {
|
|
footer {
|
|
position: static !important;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<!-- Navbar institucional -->
|
|
<nav class="navbar navbar-expand-lg">
|
|
<div class="container">
|
|
<a class="navbar-brand d-flex align-items-center text-dark" href="#">
|
|
<img src="/IMPORTADORES/public/<?= htmlspecialchars($logo) ?>" alt="Logo" class="logo-siih">
|
|
| Inicio de Importador
|
|
</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse justify-content-end" id="navbarNav">
|
|
<ul class="navbar-nav">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/IMPORTADORES/">Inicio</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link " aria-current="page" href="/IMPORTADORES/registro">Registro</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link active" href="/IMPORTADORES/login">Inicio sesión</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<?php if ($mantenimiento): ?>
|
|
<div class="container mt-4">
|
|
<div class="alert alert-danger text-center" role="alert">
|
|
<i class="fas fa-triangle-exclamation me-2"></i>
|
|
<?= htmlspecialchars($mensajeMantenimiento) ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- Overlay (fondo semitransparente) que cubre la pantalla -->
|
|
<div class="overlay"></div>
|
|
|
|
<!-- Formulario de validación de código -->
|
|
<div class="login-container">
|
|
<h4 class="mb-4 text-center text-dark">Verifica tu código</h4>
|
|
|
|
<?php
|
|
if (!isset($_SESSION['email_recuperacion'])) {
|
|
// Si no hay correo en sesión, redirige a solicitar código
|
|
header('Location: /IMPORTADORES/login/recuperar');
|
|
exit;
|
|
}
|
|
?>
|
|
<!-- Formulario para verificar el código -->
|
|
<form id="formCodigo" action="/IMPORTADORES/login/verificarCodigo" method="POST">
|
|
<div class="mb-3">
|
|
<label class="form-label" for="codigo">Código recibido por correo</label>
|
|
<input type="text" id="codigo" name="codigo" class="form-control" required pattern="\d{6}" maxlength="6" placeholder="Ej. 123456">
|
|
</div>
|
|
<button type="submit" class="btn btn-primary w-100">Verificar código</button>
|
|
</form>
|
|
|
|
<!-- Mostrar mensajes -->
|
|
<div id="mensaje" class="mt-3 text-center fw-bold">
|
|
<?php if (isset($_SESSION['codigo_error'])): ?>
|
|
<div class="text-danger"><?= $_SESSION['codigo_error'] ?></div>
|
|
<?php unset($_SESSION['codigo_error']); ?>
|
|
<?php elseif (isset($_SESSION['codigo_exito'])): ?>
|
|
<div class="text-success"><?= $_SESSION['codigo_exito'] ?></div>
|
|
<?php unset($_SESSION['codigo_exito']); ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- FOOTER -->
|
|
<footer class="fixed-bottom">
|
|
© <?= date('Y') ?> <?= htmlspecialchars($siglas) ?> · <?= htmlspecialchars($nombre) ?>
|
|
</footer>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const form = document.getElementById('formCodigo');
|
|
const mensaje = document.getElementById('mensaje');
|
|
const inputCodigo = form.querySelector('input[name="codigo"]');
|
|
|
|
inputCodigo.addEventListener('input', () => {
|
|
mensaje.innerHTML = '';
|
|
mensaje.classList.remove("text-danger", "text-success");
|
|
});
|
|
|
|
form.addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
|
|
const codigo = inputCodigo.value.trim();
|
|
if (!codigo || codigo.length !== 6) {
|
|
mensaje.textContent = "❌ Ingresa un código de 6 dígitos.";
|
|
mensaje.classList.add("text-danger");
|
|
return;
|
|
}
|
|
|
|
const formData = new FormData();
|
|
formData.append('codigo', codigo);
|
|
|
|
fetch('/IMPORTADORES/login/verificarCodigo', {
|
|
method: 'POST',
|
|
body: formData,
|
|
credentials: 'same-origin' // ✅ Importante para mantener sesión
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
mensaje.textContent = data.message;
|
|
mensaje.classList.remove("text-danger");
|
|
mensaje.classList.add("text-success");
|
|
|
|
// Redirigir al formulario de cambio de contraseña
|
|
setTimeout(() => {
|
|
window.location.href = '/IMPORTADORES/login/cambiarPasswordVista';
|
|
}, 1500);
|
|
} else {
|
|
mensaje.textContent = "❌ " + data.message;
|
|
mensaje.classList.remove("text-success");
|
|
mensaje.classList.add("text-danger");
|
|
}
|
|
})
|
|
.catch(() => {
|
|
mensaje.textContent = "❌ Error al verificar el código.";
|
|
mensaje.classList.remove("text-success");
|
|
mensaje.classList.add("text-danger");
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|