82 lines
3.3 KiB
PHP
82 lines
3.3 KiB
PHP
<?php
|
|
$skipAdminAuth = true;
|
|
require_once __DIR__ . '/../includes/admin_bootstrap.php';
|
|
require_once __DIR__ . '/../config/database.php';
|
|
|
|
if (isLoggedIn()) {
|
|
redirect(BASE_URL . '/admin/index.php');
|
|
}
|
|
|
|
$error = null;
|
|
$return = $_GET['return'] ?? BASE_URL . '/admin/index.php';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$usuario = trim($_POST['usuario'] ?? '');
|
|
$password = $_POST['password'] ?? '';
|
|
$return = $_POST['return'] ?? $return;
|
|
|
|
if ($usuario === '' || $password === '') {
|
|
$error = 'Ingrese usuario y contraseña.';
|
|
} else {
|
|
$db = getDB();
|
|
if (loginUser($db, $usuario, $password)) {
|
|
redirect($return);
|
|
}
|
|
$error = 'Usuario o contraseña incorrectos.';
|
|
}
|
|
}
|
|
|
|
$pageTitle = 'Iniciar sesión';
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?= h($pageTitle) ?> - <?= h(APP_NAME) ?></title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined" rel="stylesheet">
|
|
<link href="<?= BASE_URL ?>/assets/css/style.css" rel="stylesheet">
|
|
</head>
|
|
<body class="bg-light">
|
|
<div class="container">
|
|
<div class="row justify-content-center align-items-center min-vh-100">
|
|
<div class="col-md-5 col-lg-4">
|
|
<div class="card shadow-sm">
|
|
<div class="card-body p-4">
|
|
<div class="text-center mb-4">
|
|
<?php if (file_exists(dirname(__DIR__) . '/NEM.png')): ?>
|
|
<img src="<?= BASE_URL ?>/NEM.png" alt="Logo" style="height:56px" class="mb-2">
|
|
<?php endif; ?>
|
|
<h4 class="mb-0"><?= h(APP_NAME) ?></h4>
|
|
<small class="text-muted">Panel de administración</small>
|
|
</div>
|
|
|
|
<?php if ($error): ?>
|
|
<div class="alert alert-danger py-2"><?= h($error) ?></div>
|
|
<?php endif; ?>
|
|
|
|
<form method="post">
|
|
<input type="hidden" name="return" value="<?= h($return) ?>">
|
|
<div class="mb-3">
|
|
<label for="usuario" class="form-label">Usuario</label>
|
|
<input type="text" class="form-control" id="usuario" name="usuario"
|
|
autocomplete="username" required autofocus>
|
|
</div>
|
|
<div class="mb-4">
|
|
<label for="password" class="form-label">Contraseña</label>
|
|
<input type="password" class="form-control" id="password" name="password"
|
|
autocomplete="current-password" required>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary w-100 py-2">
|
|
<span class="material-symbols-outlined align-middle me-1" style="font-size:20px">login</span>
|
|
Entrar
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|