331 lines
11 KiB
PHP
331 lines
11 KiB
PHP
<?php
|
|
/**
|
|
* Sistema de Login del WhatsApp Bot Manager
|
|
* Desarrollado por U-Site.app
|
|
* Con protección contra ataques de fuerza bruta
|
|
*/
|
|
|
|
require_once 'config/config.php';
|
|
|
|
// Verificar si la instalación está completada
|
|
if (!isInstallationCompleted()) {
|
|
header('Location: install.php');
|
|
exit('Sistema no instalado. <a href="install.php">Instalar ahora</a>');
|
|
}
|
|
|
|
// Si ya está logueado, redirigir al panel
|
|
if (isUserLoggedIn()) {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
|
|
$error = '';
|
|
$loginBlocked = false;
|
|
$clientIp = $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0';
|
|
|
|
// 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'] ?? '';
|
|
|
|
if ($username === ADMIN_USERNAME) {
|
|
// Verificar contraseña
|
|
$adminHash = constant('ADMIN_PASSWORD');
|
|
if (password_verify($password, $adminHash)) {
|
|
// Login exitoso
|
|
clearLoginAttempts($clientIp);
|
|
$_SESSION['admin_logged_in'] = true;
|
|
$_SESSION['last_activity'] = time();
|
|
$_SESSION['login_ip'] = $clientIp;
|
|
$_SESSION['login_time'] = time();
|
|
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
}
|
|
|
|
// Login fallido
|
|
recordFailedLogin($clientIp);
|
|
$error = 'Usuario o contraseña incorrectos.';
|
|
|
|
// Verificar si se bloqueó después de este intento
|
|
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;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.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); }
|
|
}
|
|
</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>
|
|
<small class="text-muted">Desarrollado por <strong>U-Site.app</strong></small>
|
|
</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' : '' ?>
|
|
value="admin"
|
|
readonly
|
|
>
|
|
</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>
|
|
|
|
<!-- Error Messages -->
|
|
<?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>
|
|
|
|
<!-- Information -->
|
|
<div class="mt-4">
|
|
<div class="alert alert-info">
|
|
<i class="fas fa-info-circle me-2"></i>
|
|
<strong>Información del Sistema:</strong>
|
|
<ul class="mb-0 mt-2">
|
|
<li>Usuario por defecto: <code>admin</code></li>
|
|
<li>Contraseña generada en la instalación</li>
|
|
<li>Máximo <?= MAX_LOGIN_ATTEMPTS ?> intentos por IP</li>
|
|
<li>Bloqueo de <?= LOGIN_LOCKOUT_TIME / 60 ?> minutos tras fallos</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Links útiles -->
|
|
<div class="mt-4 text-center">
|
|
<div class="d-grid gap-2">
|
|
<a href="test.php" class="btn btn-outline-primary">
|
|
<i class="fas fa-check-circle me-2"></i>Probar Sistema
|
|
</a>
|
|
<?php if (file_exists('CREDENCIALES_SISTEMA.txt')): ?>
|
|
<a href="CREDENCIALES_SISTEMA.txt" class="btn btn-outline-warning btn-sm">
|
|
<i class="fas fa-file-text me-2"></i>Ver Credenciales
|
|
</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Developer Info -->
|
|
<div class="developer-info">
|
|
<h6><i class="fas fa-code me-2"></i>Desarrollado por U-Site.app</h6>
|
|
<p class="mb-2">Sistema profesional de WhatsApp Bot con máxima seguridad</p>
|
|
<div class="d-flex justify-content-center gap-3">
|
|
<a href="https://u-site.app" target="_blank" class="text-white">
|
|
<i class="fas fa-globe me-1"></i>Website
|
|
</a>
|
|
<a href="mailto:support@u-site.app" class="text-white">
|
|
<i class="fas fa-envelope me-1"></i>Soporte
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</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>
|