<?php
session_start();
ini_set('display_errors', 1);
error_reporting(E_ALL);

echo "Step 1: session OK<br>";

require_once 'config.php';
echo "Step 2: config OK<br>";

require_once 'functions.php';
echo "Step 3: functions OK<br>";

requireLogin();
echo "Step 4: requireLogin OK<br>";

$user = getConnectedUser($pdo);
echo "Step 5: getConnectedUser OK — " . ($user['username'] ?? 'NULL') . "<br>";

requireAdmin($user);
echo "Step 6: requireAdmin OK<br>";

try {
    $trophies = $pdo->query("SELECT * FROM trophy_levels ORDER BY requirement_value ASC")->fetchAll();
    echo "Step 7: trophy_levels OK — " . count($trophies) . " trophées<br>";
} catch(Exception $e) {
    echo "Step 7: ERREUR trophy_levels — " . $e->getMessage() . "<br>";
}

echo "Step 8: Avant header.php<br>";
include 'header.php';
echo "Step 9: Après header.php<br>";
?>
