<?php
require_once __DIR__ . '/../inc/bootstrap.php';
header('Content-Type: text/plain; charset=utf-8');

$user = $_GET['user'] ?? 'admin';
$pass = $_GET['pass'] ?? '';

$st = $pdo->prepare("SELECT id, username, password_hash, CHAR_LENGTH(password_hash) AS len, rol, activo FROM usuarios WHERE username=? LIMIT 1");
$st->execute([$user]);
$row = $st->fetch(PDO::FETCH_ASSOC);

if (!$row) { echo "No existe username='$user'\n"; exit; }

echo "username: {$row['username']}\n";
echo "len(hash): {$row['len']}\n";
echo "activo: {$row['activo']}\n";
echo "rol: {$row['rol']}\n";

if ($pass !== '') {
  $ok = password_verify($pass, $row['password_hash']);
  echo "password_verify: " . ($ok ? "OK" : "FALLÓ") . "\n";
} else {
  echo "Pasa ?pass=TuClave para verificar.\n";
}
