Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
AVIDOTAPP
/
controllers
:
AuthController.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php class AuthController { public function index() { include 'views/auth/login.php'; } public function login() { if ($_SERVER['REQUEST_METHOD'] == 'POST') { // ── Verificación reCAPTCHA v2 ────────────────────────────────────── $recaptchaSecret = '6LcUafsrAAAAAL2xMNSvimYvzrMlC3YFSgUJGQPx'; // <-- tu secret key $recaptchaResponse = $_POST['g-recaptcha-response'] ?? ''; if (empty($recaptchaResponse)) { echo "<script>alert('Por favor completa el reCAPTCHA.'); window.location.href='index.php';</script>"; return; } $verifyUrl = 'https://www.google.com/recaptcha/api/siteverify'; $data = [ 'secret' => $recaptchaSecret, 'response' => $recaptchaResponse, 'remoteip' => $_SERVER['REMOTE_ADDR'] ]; $options = [ 'http' => [ 'method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => http_build_query($data) ] ]; $context = stream_context_create($options); $result = file_get_contents($verifyUrl, false, $context); $recaptchaCheck = json_decode($result, true); if (!$recaptchaCheck['success']) { echo "<script>alert('reCAPTCHA inválido. Intenta de nuevo.'); window.location.href='index.php';</script>"; return; } // ────────────────────────────────────────────────────────────────── // Validación de usuario y contraseña $user = trim($_POST['user']); $pass = trim($_POST['pass']); $userModel = new UserModel(); $datosUsuario = $userModel->login($user, $pass); if ($datosUsuario) { $_SESSION['DIGITA'] = $user; $_SESSION['GRADO'] = $datosUsuario['GRADO']; header("Location: index.php?controller=Dashboard&action=index"); } else { echo "<script>alert('Datos incorrectos'); window.location.href='index.php';</script>"; } } } public function logout() { session_destroy(); header("Location: index.php"); } } ?>