Autosave: 20260309-105052

This commit is contained in:
Flatlogic Bot 2026-03-09 10:50:52 +00:00
parent 8403eff648
commit 2c3897166c
4 changed files with 550 additions and 476 deletions

146
admin.php
View File

@ -55,6 +55,61 @@ $tab = isset($_GET['tab']) ? $_GET['tab'] : 'project_logs';
// --- HANDLERS ---
// Handle Player Resource Management
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'admin_manage_player_resources') {
$target_type = $_POST['target_type']; // 'single', 'multiple', 'all'
$player_ids = [];
if ($target_type === 'all') {
$stmt = $db->query("SELECT id FROM users");
$player_ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
} else {
$player_ids = isset($_POST['player_ids']) ? (array)$_POST['player_ids'] : [];
}
$resource_id = (int)$_POST['resource_id'];
$amount = (int)$_POST['amount'];
$operation = $_POST['operation']; // 'add', 'remove'
if ($operation === 'remove') {
$amount = -abs($amount);
} else {
$amount = abs($amount);
}
if (!empty($player_ids) && $resource_id > 0 && $amount !== 0) {
$db->beginTransaction();
try {
$stmt_check = $db->prepare("SELECT amount FROM user_resources WHERE user_id = ? AND resource_id = ?");
$stmt_insert = $db->prepare("INSERT INTO user_resources (user_id, resource_id, amount) VALUES (?, ?, ?)");
$stmt_update = $db->prepare("UPDATE user_resources SET amount = GREATEST(0, amount + ?) WHERE user_id = ? AND resource_id = ?");
foreach ($player_ids as $pid) {
$pid = (int)$pid;
$stmt_check->execute([$pid, $resource_id]);
$exists = $stmt_check->fetch();
if ($exists) {
$stmt_update->execute([$amount, $pid, $resource_id]);
} else {
$initial_qty = max(0, $amount);
$stmt_insert->execute([$pid, $resource_id, $initial_qty]);
}
}
$db->commit();
header("Location: admin.php?tab=player&success=1");
exit;
} catch (Exception $e) {
$db->rollBack();
header("Location: admin.php?tab=player&error=db");
exit;
}
} else {
header("Location: admin.php?tab=player&error=missing_fields");
exit;
}
}
// Handle User Role Update
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'update_user_role') {
$target_user_id = (int)$_POST['target_user_id'];
@ -217,7 +272,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["action"]) && $_POST["
$stmt = $db->prepare("UPDATE celestial_object_statuses SET name = ?, slug = ?, color = ?, description = ? WHERE id = ?");
$stmt->execute([$name, $slug, $color, $description, $id]);
} else {
$stmt = $db->prepare("INSERT INTO celestial_object_statuses (name, slug, color, description) VALUES (?, ?, ?, ?)");
$stmt = $db->prepare("INSERT INTO celestial_object_statuses (name, slug, color, description) VALUES (?, ?, ? , ?)");
$stmt->execute([$name, $slug, $color, $description]);
}
header("Location: admin.php?tab=statuses&success=1");
@ -727,6 +782,9 @@ $guild_member_limit = 50;
if ($tab === 'users') {
$users_list = $db->query("SELECT id, username, email, role FROM users ORDER BY username ASC")->fetchAll();
} elseif ($tab === 'player') {
$users_list = $db->query("SELECT id, username FROM users ORDER BY username ASC")->fetchAll();
$resources_list = $db->query("SELECT id, name FROM game_resources ORDER BY name ASC")->fetchAll();
} elseif ($tab === 'objects') {
$objects_list = $db->query("SELECT * FROM celestial_object_types ORDER BY name ASC")->fetchAll();
foreach ($objects_list as &$obj) {
@ -943,8 +1001,12 @@ elseif ($tab === "units") {
</header>
<div class="container">
<?php if (isset($_GET['error']) && $_GET['error'] === 'invalid_amount'): ?>
<?php if (isset($_GET["error"]) && $_GET["error"] === "invalid_amount"): ?>
<div class="success-msg" style="background: #bf616a; color: #fff;"><i class="fa-solid fa-triangle-exclamation"></i> Erreur : La quantité doit être un nombre strictement positif.</div>
<?php elseif (isset($_GET["error"]) && $_GET["error"] === "db"): ?>
<div class="success-msg" style="background: #bf616a; color: #fff;"><i class="fa-solid fa-triangle-exclamation"></i> Erreur Base de Données : L'opération a échoué.</div>
<?php elseif (isset($_GET["error"]) && $_GET["error"] === "missing_fields"): ?>
<div class="success-msg" style="background: #bf616a; color: #fff;"><i class="fa-solid fa-triangle-exclamation"></i> Erreur : Veuillez remplir tous les champs et sélectionner au moins un joueur.</div>
<?php endif; ?>
<?php if (isset($_GET['success'])): ?>
<div class="success-msg"><i class="fa-solid fa-check-circle"></i> Opération effectuée avec succès.</div>
@ -954,6 +1016,7 @@ elseif ($tab === "units") {
<div class="tabs">
<a href="?tab=project_logs" class="tab-link <?php echo $tab === "project_logs" ? "active" : ""; ?>"><i class="fa-solid fa-clipboard-list"></i> Journal de Bord</a>
<a href="?tab=users" class="tab-link <?php echo $tab === 'users' ? 'active' : ''; ?>"><i class="fa-solid fa-users"></i> Utilisateurs</a>
<a href="?tab=player" class="tab-link <?php echo $tab === 'player' ? 'active' : ''; ?>"><i class="fa-solid fa-gamepad"></i> Joueur</a>
<a href="?tab=levels" class="tab-link <?php echo $tab === 'levels' ? 'active' : ''; ?>"><i class="fa-solid fa-layer-group"></i> Niveaux</a>
<a href="?tab=ranks" class="tab-link <?php echo $tab === 'ranks' ? 'active' : ''; ?>"><i class="fa-solid fa-medal"></i> Grades</a>
<a href="?tab=badges" class="tab-link <?php echo $tab === 'badges' ? 'active' : ''; ?>"><i class="fa-solid fa-id-badge"></i> Titres & Badges</a>
@ -972,7 +1035,80 @@ elseif ($tab === "units") {
<a href="?tab=units" class="tab-link <?php echo $tab === 'units' ? 'active' : ''; ?>"><i class="fa-solid fa-rocket"></i> Unité</a>
</div>
<?php if ($tab === 'users'): ?>
<?php if ($tab === 'player'): ?>
<h3 style="color: #88c0d0;">Gestion des Joueurs (Gameplay)</h3>
<div class="form-card">
<h4>Attribuer ou Retirer des Ressources</h4>
<form method="POST">
<input type="hidden" name="action" value="admin_manage_player_resources">
<div class="form-group">
<label>Cibler les joueurs</label>
<select name="target_type" id="player_target_type" onchange="togglePlayerSelection()" required>
<option value="single">Un joueur spécifique</option>
<option value="multiple">Plusieurs joueurs</option>
<option value="all">Tous les joueurs</option>
</select>
</div>
<div id="player_selection_group" class="form-group">
<label>Sélectionner le(s) joueur(s)</label>
<div class="ms-container" id="ms_players">
<div class="ms-display" onclick="toggleMS('ms_players_list')">Choisir...</div>
<div class="ms-dropdown" id="ms_players_list">
<?php foreach ($users_list as $u): ?>
<label class="ms-item">
<input type="checkbox" name="player_ids[]" value="<?php echo $u['id']; ?>" onchange="updateMSLabel('ms_players')">
<?php echo htmlspecialchars($u['username']); ?>
</label>
<?php endforeach; ?>
</div>
</div>
</div>
<div style="display: flex; gap: 20px;">
<div class="form-group" style="flex: 2;">
<label>Ressource</label>
<select name="resource_id" required>
<option value="">-- Sélectionner une ressource --</option>
<?php foreach ($resources_list as $res): ?>
<option value="<?php echo $res['id']; ?>">
<?php echo htmlspecialchars($res['name']); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group" style="flex: 1;">
<label>Action</label>
<select name="operation">
<option value="add">Ajouter (+)</option>
<option value="remove">Retirer (-)</option>
</select>
</div>
<div class="form-group" style="flex: 1;">
<label>Quantité</label>
<input type="number" name="amount" min="1" value="1" required>
</div>
</div>
<button type="submit" class="btn btn-ok" style="width: 100%; margin-top: 10px; height: 40px; font-size: 14px;">
<i class="fa-solid fa-paper-plane"></i> ENVOYER
</button>
</form>
</div>
<script>
function togglePlayerSelection() {
const type = document.getElementById('player_target_type').value;
const group = document.getElementById('player_selection_group');
if (group) {
group.style.display = (type === 'all') ? 'none' : 'block';
}
}
document.addEventListener('DOMContentLoaded', togglePlayerSelection);
</script>
<?php elseif ($tab === 'users'): ?>
<h3 style="color: #88c0d0;">Gestion des Rôles</h3>
<table>
<thead>
@ -1948,7 +2084,7 @@ elseif ($tab === "units") {
</div>
</div>
<div style="display: align-items: center; gap: 10px; padding-top: 15px; margin-top: 15px; border-top: 1px solid #334155;">
<div style="display: flex; align-items: center; gap: 10px; padding-top: 15px; margin-top: 15px; border-top: 1px solid #334155;">
<input type="checkbox" name="is_empty_case" id="rule_empty" style="width: auto;">
<label for="rule_empty" style="margin-bottom: 0; color: #ebcb8b;">Cas "CASE VIDE" (Aucune faction nulle part)</label>
</div>
@ -2873,4 +3009,4 @@ elseif ($tab === "units") {
});
</script>
</body>
</html>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

View File

@ -5,64 +5,76 @@ session_start();
$db = db();
if (!isset($_SESSION['user_id'])) {
header("Location: auth.php");
header('Location: auth.php');
exit;
}
$user_id = $_SESSION['user_id'];
$message = '';
$error = '';
// --- HEADER DATA FETCHING (from index.php) ---
$user_role = 'user';
$stmt = $db->prepare("SELECT u.role, u.display_name, u.username, u.guild_id, l.name as level_raw,
u.selected_title_id, u.selected_badge_id,
t.name as title_name,
b.name as badge_name, b.image_url as badge_image
// Récupérer les informations de l'utilisateur
$stmt = $db->prepare("SELECT u.*, g.name as guild_name, g.owner_id as guild_owner_id
FROM users u
LEFT JOIN levels l ON u.level_id = l.id
LEFT JOIN titles t ON u.selected_title_id = t.id
LEFT JOIN badges b ON u.selected_badge_id = b.id
LEFT JOIN guilds g ON u.guild_id = g.id
WHERE u.id = ?");
$stmt->execute([$user_id]);
$u_data = $stmt->fetch();
$user = $stmt->fetch();
if ($u_data) {
$user_role = $u_data['role'] ?? 'user';
$_SESSION['display_name'] = $u_data['display_name'] ?: $u_data['username'];
$level_num = (int)filter_var($u_data['level_raw'], FILTER_SANITIZE_NUMBER_INT);
$_SESSION['level'] = $level_num;
$_SESSION['guild_id'] = $u_data['guild_id'];
$guild_id = $user['guild_id'];
$is_owner = ($guild_id && $user['id'] == $user['guild_owner_id']);
// Gérer la création de guilde
$error = '';
$success = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['create_guild']) && !$guild_id) {
$name = trim($_POST['guild_name']);
$tag = trim($_POST['guild_tag']);
$_SESSION['selected_title_name'] = $u_data['title_name'];
$_SESSION['selected_badge_name'] = $u_data['badge_name'];
$_SESSION['selected_badge_image'] = $u_data['badge_image'];
$grade_type = ($user_role === 'admin') ? 'admin' : 'utilisateur';
$g_stmt = $db->prepare("SELECT name, image_url FROM grades
WHERE user_type = ?
AND (min_level <= ? OR min_level IS NULL)
AND (max_level >= ? OR max_level IS NULL)
LIMIT 1");
$g_stmt->execute([$grade_type, $level_num, $level_num]);
$grade_data = $g_stmt->fetch();
if ($grade_data) {
$_SESSION['grade_name'] = $grade_data['name'];
$_SESSION['grade_image'] = $grade_data['image_url'];
if (empty($name) || empty($tag)) {
$error = "Le nom et le tag sont obligatoires.";
} else {
$_SESSION['grade_name'] = "Recrue";
$_SESSION['grade_image'] = "assets/images/placeholder_grade.png";
try {
$db->beginTransaction();
$stmt = $db->prepare("INSERT INTO guilds (name, tag, owner_id) VALUES (?, ?, ?)");
$stmt->execute([$name, $tag, $user_id]);
$new_guild_id = $db->lastInsertId();
$stmt = $db->prepare("UPDATE users SET guild_id = ? WHERE id = ?");
$stmt->execute([$new_guild_id, $user_id]);
$stmt = $db->prepare("INSERT INTO guild_members (guild_id, user_id, role) VALUES (?, ?, 'owner')");
$stmt->execute([$new_guild_id, $user_id]);
$db->commit();
header('Location: guilde.php');
exit;
} catch (Exception $e) {
$db->rollBack();
$error = "Erreur lors de la création : " . $e->getMessage();
}
}
}
// Dynamic Resources for Header & Check
// Récupérer les membres si en guilde
$members = [];
if ($guild_id) {
$stmt = $db->prepare("SELECT u.id, u.username, u.display_name, m.role, m.joined_at, l.name as level_name
FROM guild_members m
JOIN users u ON m.user_id = u.id
LEFT JOIN levels l ON u.level_id = l.id
WHERE m.guild_id = ?
ORDER BY CASE WHEN m.role = 'owner' THEN 1 WHEN m.role = 'officer' THEN 2 ELSE 3 END ASC, joined_at ASC");
$stmt->execute([$guild_id]);
$members = $stmt->fetchAll();
}
// Ressources pour le header (copié de index.php)
$resources = [];
$user_resource_amounts = []; // For easier access
$stmt = $db->prepare("
SELECT gr.*, COALESCE(ur.amount, 0) as amount
FROM game_resources gr
LEFT JOIN user_resources ur ON gr.id = ur.resource_id AND ur.user_id = ?
WHERE gr.show_in_header = 1
ORDER BY CASE
WHEN gr.name LIKE 'Crédit%' THEN 1
WHEN gr.name LIKE 'Matériau%' THEN 2
@ -72,432 +84,238 @@ $stmt = $db->prepare("
END ASC, gr.name ASC
");
$stmt->execute([$user_id]);
$all_resources_raw = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($all_resources_raw as $hr) {
$user_resource_amounts[$hr['id']] = (float)$hr['amount'];
if ($hr['show_in_header'] == 1) {
$resources[$hr["name"]] = [
"val" => (string)$hr["amount"],
"prod" => "",
"icon" => $hr["icon"] ?: "fa-gem",
"image" => $hr["image_url"]
];
}
$header_resources = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($header_resources as $hr) {
$resources[$hr["name"]] = [
"val" => (string)$hr["amount"],
"prod" => "",
"icon" => $hr["icon"] ?: "fa-gem",
"image" => $hr["image_url"]
];
}
// --- GUILD SPECIFIC LOGIC ---
// Check if user is in a guild
$stmt = $db->prepare("SELECT u.guild_id, m.role, g.name as guild_name, g.tag as guild_tag, g.description as guild_desc
FROM users u
LEFT JOIN guild_members m ON u.id = m.user_id
LEFT JOIN guilds g ON u.guild_id = g.id
WHERE u.id = ?");
$stmt->execute([$user_id]);
$user_guild_info = $stmt->fetch(PDO::FETCH_ASSOC);
$in_guild = !empty($user_guild_info['guild_id']);
// Fetch member limit
$stmt = $db->query("SELECT value FROM guild_restrictions WHERE restriction_key = 'member_limit'");
$member_limit = (int)($stmt->fetchColumn() ?: 50);
// --- ACTIONS ---
// JOIN GUILD
if (isset($_GET['join']) && !$in_guild) {
$guild_id = (int)$_GET['join'];
$stmt = $db->prepare("SELECT COUNT(*) FROM guild_members WHERE guild_id = ?");
$stmt->execute([$guild_id]);
$current_members = (int)$stmt->fetchColumn();
if ($current_members >= $member_limit) { $error = "Cette guilde est pleine."; } else {
$db->beginTransaction();
try {
$db->prepare("UPDATE users SET guild_id = ? WHERE id = ?")->execute([$guild_id, $user_id]);
$db->prepare("INSERT INTO guild_members (guild_id, user_id, role) VALUES (?, ?, 'membre')")->execute([$guild_id, $user_id]);
$_SESSION['guild_id'] = $guild_id;
$db->commit();
header("Location: guilde.php");
exit;
} catch (Exception $e) { $db->rollBack(); $error = "Erreur : " . $e->getMessage(); }
}
}
// DISBAND GUILD
if (isset($_GET['action']) && $_GET['action'] === 'disband' && $in_guild && $user_guild_info['role'] === 'superviseur') {
$guild_id = $user_guild_info['guild_id'];
$db->beginTransaction();
try {
$db->prepare("UPDATE users SET guild_id = NULL WHERE guild_id = ?")->execute([$guild_id]);
$db->prepare("DELETE FROM guild_members WHERE guild_id = ?")->execute([$guild_id]);
$db->prepare("DELETE FROM guilds WHERE id = ?")->execute([$guild_id]);
$_SESSION['guild_id'] = null;
$db->commit();
header("Location: guilde.php");
exit;
} catch (Exception $e) { $db->rollBack(); $error = "Erreur : " . $e->getMessage(); }
}
// LEAVE GUILD
if (isset($_GET['action']) && $_GET['action'] === 'leave' && $in_guild && $user_guild_info['role'] !== 'superviseur') {
$db->beginTransaction();
try {
$db->prepare("UPDATE users SET guild_id = NULL WHERE id = ?")->execute([$user_id]);
$db->prepare("DELETE FROM guild_members WHERE user_id = ?")->execute([$user_id]);
$_SESSION['guild_id'] = null;
$db->commit();
header("Location: guilde.php");
exit;
} catch (Exception $e) { $db->rollBack(); $error = "Erreur : " . $e->getMessage(); }
}
// KICK MEMBER
if (isset($_GET['kick']) && $in_guild && ($user_guild_info['role'] === 'superviseur' || $user_guild_info['role'] === 'officier')) {
$target_id = (int)$_GET['kick'];
if ($target_id != $user_id) {
$stmt = $db->prepare("SELECT role FROM guild_members WHERE user_id = ? AND guild_id = ?");
$stmt->execute([$target_id, $user_guild_info['guild_id']]);
$target_role = $stmt->fetchColumn();
if ($target_role) {
$can_kick = ($user_guild_info['role'] === 'superviseur') || ($user_guild_info['role'] === 'officier' && $target_role === 'membre');
if ($can_kick) {
$db->prepare("UPDATE users SET guild_id = NULL WHERE id = ?")->execute([$target_id]);
$db->prepare("DELETE FROM guild_members WHERE user_id = ?")->execute([$target_id]);
$message = "Membre exclu.";
} else $error = "Droits insuffisants.";
}
}
}
// UPDATE ROLE
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'update_role' && $in_guild && $user_guild_info['role'] === 'superviseur') {
$target_id = (int)$_POST['target_user_id'];
$new_role = $_POST['new_role'];
if (in_array($new_role, ['membre', 'officier']) && $target_id != $user_id) {
$db->prepare("UPDATE guild_members SET role = ? WHERE user_id = ? AND guild_id = ?")->execute([$new_role, $target_id, $user_guild_info['guild_id']]);
$message = "Grade mis à jour.";
}
}
// CREATE GUILD
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'create_guild' && !$in_guild) {
$name = trim($_POST['name']);
$tag = strtoupper(trim($_POST['tag']));
$description = trim($_POST['description']);
if (strlen($name) < 3) $error = "Nom trop court.";
elseif (strlen($tag) < 2) $error = "Tag trop court.";
else {
$reqs = $db->query("SELECT resource_id, amount FROM guild_creation_requirements WHERE amount > 0")->fetchAll(PDO::FETCH_ASSOC);
$db->beginTransaction();
try {
$can_afford = true;
foreach ($reqs as $req) {
$stmt = $db->prepare("SELECT amount FROM user_resources WHERE user_id = ? AND resource_id = ?");
$stmt->execute([$user_id, $req['resource_id']]);
if (($stmt->fetchColumn() ?: 0) < $req['amount']) { $can_afford = false; break; }
}
if (!$can_afford) { $error = "Ressources insuffisantes."; $db->rollBack(); }
else {
foreach ($reqs as $req) $db->prepare("UPDATE user_resources SET amount = amount - ? WHERE user_id = ? AND resource_id = ?")->execute([$req['amount'], $user_id, $req['resource_id']]);
$db->prepare("INSERT INTO guilds (name, tag, description) VALUES (?, ?, ?)")->execute([$name, $tag, $description]);
$guild_id = $db->lastInsertId();
$db->prepare("INSERT INTO guild_members (guild_id, user_id, role) VALUES (?, ?, 'superviseur')")->execute([$guild_id, $user_id]);
$db->prepare("UPDATE users SET guild_id = ? WHERE id = ?")->execute([$guild_id, $user_id]);
$_SESSION['guild_id'] = $guild_id;
$db->commit();
header("Location: guilde.php");
exit;
}
} catch (Exception $e) { $db->rollBack(); $error = "Erreur : " . $e->getMessage(); }
}
}
// --- DATA FETCHING ---
if ($in_guild) {
$stmt = $db->prepare("SELECT m.*, u.username, u.display_name FROM guild_members m JOIN users u ON m.user_id = u.id WHERE m.guild_id = ? ORDER BY FIELD(role, 'superviseur', 'officier', 'membre'), joined_at ASC");
$stmt->execute([$user_guild_info['guild_id']]);
$guild_members = $stmt->fetchAll(PDO::FETCH_ASSOC);
} else {
$display_reqs = $db->query("SELECT r.id, r.name, r.icon, r.image_url, gr.amount FROM guild_creation_requirements gr JOIN game_resources r ON gr.resource_id = r.id WHERE gr.amount > 0")->fetchAll(PDO::FETCH_ASSOC);
$all_guilds = $db->query("SELECT g.*, (SELECT COUNT(*) FROM guild_members WHERE guild_id = g.id) as member_count FROM guilds g ORDER BY member_count DESC")->fetchAll(PDO::FETCH_ASSOC);
// Check global affordability for create button
$can_afford_creation = true;
foreach ($display_reqs as $req) {
if (($user_resource_amounts[$req['id']] ?? 0) < $req['amount']) {
$can_afford_creation = false;
break;
}
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title><?php echo $in_guild ? htmlspecialchars($user_guild_info['guild_name']) : 'Guildes'; ?> - Nexus</title>
<title>Nexus - Guilde</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<link href="assets/css/custom.css?v=<?php echo time(); ?>" rel="stylesheet">
<style>
body { background: #000; color: #fff; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; }
#main-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
/* HEADER STYLES (MATCHING index.php) */
#top-bar {
background: #0f172a;
border-bottom: 1px solid #1e293b;
padding: 10px 40px;
display: flex;
flex-direction: column;
gap: 10px;
}
.user-auth-bar {
display: flex;
justify-content: flex-end;
align-items: center;
gap: 20px;
font-size: 11px;
color: #8c92a3;
}
body { background: #000; color: #fff; font-family: 'Segoe UI', sans-serif; margin: 0; }
#top-bar { background: #0f172a; border-bottom: 1px solid #1e293b; padding: 10px 40px; display: flex; flex-direction: column; gap: 10px; }
.user-auth-bar { display: flex; justify-content: flex-end; align-items: center; gap: 20px; font-size: 11px; color: #8c92a3; }
.user-auth-bar a { color: #88c0d0; text-decoration: none; font-weight: bold; }
.user-auth-bar .username { color: #ebcb8b; }
.resource-container {
display: flex;
justify-content: center;
align-items: center;
gap: 30px;
flex-wrap: wrap;
}
.resource-box {
display: flex;
align-items: center;
gap: 12px;
background: rgba(30, 41, 59, 0.5);
padding: 6px 15px;
border-radius: 8px;
border: 1px solid #1e293b;
min-width: 140px;
transition: all 0.2s;
}
.resource-box:hover { border-color: #88c0d0; background: rgba(30, 41, 59, 0.8); }
.resource-icon {
width: 32px;
height: 32px;
background: #1e293b;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
color: #88c0d0;
}
.resource-icon img { width: 20px; height: 20px; object-fit: contain; }
.resource-info { display: flex; flex-direction: column; }
.resource-name { font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; margin-bottom: 2px; }
.resource-val-prod { display: flex; align-items: baseline; gap: 6px; }
.resource-container { display: flex; justify-content: center; align-items: center; gap: 30px; }
.resource-box { display: flex; align-items: center; gap: 12px; background: rgba(30, 41, 59, 0.4); padding: 6px 15px; border-radius: 8px; border: 1px solid rgba(136, 192, 208, 0.1); min-width: 140px; }
.resource-icon img { width: 24px; height: 24px; object-fit: contain; }
.resource-value { font-size: 14px; font-weight: bold; color: #f8fafc; }
.resource-prod { font-size: 10px; color: #10b981; }
#main-content { padding: 40px; max-width: 1200px; margin: 0 auto; }
.card { background: rgba(15, 23, 42, 0.8); border: 1px solid #1e293b; border-radius: 12px; padding: 30px; margin-bottom: 30px; backdrop-filter: blur(10px); }
.card-title { font-size: 24px; color: #88c0d0; margin-bottom: 20px; display: flex; align-items: center; gap: 15px; }
.member-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
.member-table th { text-align: left; padding: 15px; border-bottom: 2px solid #1e293b; color: #8c92a3; font-size: 12px; text-transform: uppercase; }
.member-table td { padding: 15px; border-bottom: 1px solid #1e293b; font-size: 14px; }
.role-badge { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: bold; text-transform: uppercase; }
.role-owner { background: rgba(235, 203, 139, 0.2); color: #ebcb8b; border: 1px solid #ebcb8b; }
.role-officer { background: rgba(136, 192, 208, 0.2); color: #88c0d0; border: 1px solid #88c0d0; }
.role-member { background: rgba(148, 163, 184, 0.2); color: #94a3b8; border: 1px solid #94a3b8; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 14px; color: #94a3b8; }
.form-control { width: 100%; background: #0f172a; border: 1px solid #334155; border-radius: 6px; padding: 12px; color: #fff; box-sizing: border-box; }
.btn-primary { background: #88c0d0; color: #0f172a; border: none; padding: 12px 24px; border-radius: 6px; font-weight: bold; cursor: pointer; transition: all 0.2s; }
.btn-primary:hover { background: #a3be8c; transform: translateY(-2px); }
.member-link { color: #88c0d0; text-decoration: none; cursor: pointer; font-weight: bold; }
.member-link:hover { color: #fff; text-decoration: underline; }
#game-container { flex: 1; padding: 30px; display: flex; flex-direction: column; align-items: center; }
/* MODAL STYLES (Copiés de index.php) */
.modal-overlay {
display: none;
position: fixed;
top: 0; left: 0;
width: 100%; height: 100%;
background: rgba(0, 0, 0, 0.85);
backdrop-filter: blur(5px);
z-index: 2000;
align-items: center;
justify-content: center;
}
.modal-container {
background: #0f172a;
border: 1px solid #1e293b;
border-radius: 12px;
width: 600px;
max-height: 90vh;
overflow-y: auto;
position: relative;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
.modal-header {
padding: 20px;
border-bottom: 1px solid #1e293b;
display: flex;
justify-content: space-between;
align-items: center;
background: rgba(30, 41, 59, 0.5);
}
.modal-header h2 { margin: 0; font-size: 20px; color: #88c0d0; }
.modal-close {
background: none; border: none; color: #8c92a3; font-size: 24px; cursor: pointer;
transition: color 0.2s;
}
.modal-close:hover { color: #fff; }
.modal-body { padding: 25px; }
/* GUILD SPECIFIC STYLES */
.guild-content { max-width: 1000px; width: 100%; margin-top: 20px; }
.guild-card { background: rgba(10, 15, 30, 0.95); border: 1px solid #2d3545; padding: 25px; border-radius: 8px; box-shadow: 0 0 30px rgba(0,0,0,0.5); }
h1, h2, h3 { color: #88c0d0; text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid #2d3545; padding-bottom: 10px; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; color: #8c92a3; font-size: 13px; margin-bottom: 5px; }
.form-group input, .form-group textarea { width: 100%; background: #0f172a; border: 1px solid #334155; color: #fff; padding: 10px; box-sizing: border-box; font-family: inherit; border-radius: 4px; }
.btn { border: none; padding: 10px 20px; cursor: pointer; font-weight: bold; border-radius: 4px; text-transform: uppercase; font-family: inherit; text-decoration: none; display: inline-block; font-size: 12px; transition: all 0.2s; }
.btn-primary { background: #88c0d0; color: #000; }
.btn-primary:hover { background: #81a1c1; }
.btn-primary:disabled { background: #4c566a; color: #8c92a3; cursor: not-allowed; }
.btn-danger { background: #bf616a; color: #fff; }
.btn-join { background: #a3be8c; color: #000; }
.error-msg { background: rgba(191, 97, 106, 0.1); color: #bf616a; padding: 12px; border: 1px solid #bf616a; margin-bottom: 20px; border-radius: 4px; }
.success-msg { background: rgba(163, 190, 140, 0.1); color: #a3be8c; padding: 12px; border: 1px solid #a3be8c; margin-bottom: 20px; border-radius: 4px; }
.member-table, .guild-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
.member-table th, .member-table td, .guild-table th, .guild-table td { border-bottom: 1px solid #1e293b; padding: 15px; text-align: left; }
.member-table th, .guild-table th { background: rgba(30, 41, 59, 0.5); color: #88c0d0; font-size: 11px; text-transform: uppercase; }
.role-badge { padding: 3px 10px; border-radius: 12px; font-size: 10px; font-weight: bold; text-transform: uppercase; }
.role-superviseur { background: #ebcb8b; color: #000; }
.role-officier { background: #81a1c1; color: #fff; }
.role-membre { background: #4c566a; color: #fff; }
.req-item { background: #1a202c; padding: 8px 12px; border: 1px solid #2d3545; display: inline-flex; align-items: center; gap: 8px; border-radius: 4px; margin-right: 10px; margin-bottom: 10px;}
.req-item img { width: 18px; height: 18px; }
.req-item.insufficient { border-color: #bf616a; color: #bf616a; }
.loader {
border: 4px solid rgba(136, 192, 208, 0.1);
border-left-color: #88c0d0;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
</style>
</head>
<body>
<div id="main-wrapper">
<header id="top-bar">
<div style="display: flex; align-items: center; gap: 20px;">
<a href="index.php" style="text-decoration:none; color:#8c92a3; font-size:11px; font-weight:bold;"><i class="fa-solid fa-arrow-left"></i> Retour au Nexus</a>
<?php if (isset($_SESSION["user_id"])): ?>
<a href="guilde.php" style="text-decoration:none; color:#88c0d0; font-size:11px; font-weight:bold;"><i class="fa-solid fa-building-shield"></i> <?php echo empty($_SESSION["guild_id"]) ? "Création de guilde" : "Voir ma guilde"; ?></a>
<?php endif; ?>
</div>
<div class="user-auth-bar">
<?php if (isset($_SESSION["user_id"])): ?>
<span>Bienvenue, <span class="username">@<?php echo htmlspecialchars($_SESSION["display_name"] ?? $_SESSION["username"]); ?></span></span>
<a href="project_log.php"><i class="fa-solid fa-clipboard-list"></i> Journal</a> <a href="account.php"><i class="fa-solid fa-user-gear"></i> Mon compte</a>
<a href="auth.php?logout=1" style="color: #bf616a;"><i class="fa-solid fa-right-from-bracket"></i> Déconnexion</a>
<?php endif; ?>
</div>
<div class="resource-container">
<?php foreach($resources as $name => $res): ?>
<div class="resource-box">
<div class="resource-icon">
<?php if (!empty($res["image"])): ?>
<img src="<?php echo htmlspecialchars($res["image"]); ?>?v=<?php echo time(); ?>">
<?php else: ?>
<i class="fa-solid <?php echo htmlspecialchars($res["icon"]); ?>"></i>
<?php endif; ?>
</div>
<div class="resource-info">
<div class="resource-name"><?php echo htmlspecialchars($name); ?></div>
<div class="resource-val-prod">
<span class="resource-value"><?php echo htmlspecialchars($res["val"]); ?></span>
<span class="resource-prod"><?php echo htmlspecialchars($res["prod"]); ?></span>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</header>
<main id="game-container">
<div class="guild-content">
<?php if ($message): ?><div class="success-msg"><?php echo $message; ?></div><?php endif; ?>
<?php if ($error): ?><div class="error-msg"><?php echo $error; ?></div><?php endif; ?>
<div class="guild-card">
<?php if (!$in_guild): ?>
<div style="display: flex; gap: 40px; flex-wrap: wrap;">
<!-- Liste des guildes -->
<div style="flex: 2; min-width: 300px;">
<h2><i class="fa-solid fa-list"></i> Guildes Actives</h2>
<table class="guild-table">
<thead><tr><th>Guilde</th><th>Membres</th><th>Actions</th></tr></thead>
<tbody>
<?php if (empty($all_guilds)): ?>
<tr><td colspan="3" style="text-align:center; color:#8c92a3;">Aucune guilde pour le moment.</td></tr>
<?php endif; ?>
<?php foreach ($all_guilds as $g): ?>
<tr>
<td>
<strong style="color:#ebcb8b;">[<?php echo htmlspecialchars($g['tag']); ?>]</strong>
<strong><?php echo htmlspecialchars($g['name']); ?></strong><br>
<small style="color:#8c92a3;"><?php echo htmlspecialchars(mb_strimwidth($g['description'], 0, 80, "...")); ?></small>
</td>
<td><?php echo $g['member_count']; ?> / <?php echo $member_limit; ?></td>
<td>
<?php if ($g['member_count'] < $member_limit): ?>
<a href="?join=<?php echo $g['id']; ?>" class="btn btn-join">Rejoindre</a>
<?php else: ?>
<span style="color:#bf616a; font-size:11px; font-weight:bold;">PLEINE</span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<!-- Création -->
<div style="flex: 1; min-width: 280px; background: rgba(30, 41, 59, 0.3); padding: 20px; border: 1px solid #2d3545; border-radius: 8px;">
<h3>Fonder une Guilde</h3>
<div style="margin-bottom: 20px;">
<p style="font-size: 13px; color: #8c92a3;">Coût requis :</p>
<?php if (empty($display_reqs)): ?><p style="color:#a3be8c;">Gratuit</p>
<?php else: ?>
<?php foreach ($display_reqs as $req):
$user_has = $user_resource_amounts[$req['id']] ?? 0;
$is_insufficient = $user_has < $req['amount'];
?>
<div class="req-item <?php echo $is_insufficient ? 'insufficient' : ''; ?>" title="Vous avez: <?php echo number_format($user_has); ?>">
<?php if ($req['image_url']): ?><img src="<?php echo htmlspecialchars($req['image_url']); ?>">
<?php else: ?><i class="fa-solid <?php echo htmlspecialchars($req['icon'] ?: 'fa-gem'); ?>"></i><?php endif; ?>
<strong><?php echo number_format($req['amount']); ?></strong>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<form method="POST">
<input type="hidden" name="action" value="create_guild">
<div class="form-group"><label>Nom</label><input type="text" name="name" required placeholder="Nom de votre organisation"></div>
<div class="form-group"><label>Tag (2-5 car.)</label><input type="text" name="tag" required maxlength="5" placeholder="TAG"></div>
<div class="form-group"><label>Description</label><textarea name="description" rows="3" placeholder="Objectifs de la guilde..."></textarea></div>
<button type="submit" class="btn btn-primary" style="width:100%;" <?php echo !$can_afford_creation ? 'disabled' : ''; ?>>
<?php echo $can_afford_creation ? 'Fonder la guilde' : 'Ressources insuffisantes'; ?>
</button>
</form>
</div>
</div>
<header id="top-bar">
<div class="user-auth-bar">
<span>Bienvenue, <span style="color: #ebcb8b;">@<?php echo htmlspecialchars($user['display_name'] ?: $user['username']); ?></span></span>
<a href="index.php"><i class="fa-solid fa-earth-europe"></i> Retour au Nexus</a>
<a href="auth.php?logout=1" style="color: #bf616a;"><i class="fa-solid fa-right-from-bracket"></i> Déconnexion</a>
</div>
<div class="resource-container">
<?php foreach($resources as $name => $res): ?>
<div class="resource-box">
<div class="resource-icon">
<?php if (!empty($res["image"])): ?>
<img src="<?php echo htmlspecialchars($res["image"]); ?>?v=<?php echo time(); ?>">
<?php else: ?>
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #88c0d0; padding-bottom: 15px; margin-bottom: 20px;">
<div>
<span style="color: #ebcb8b; font-weight: bold; font-size: 24px;">[<?php echo htmlspecialchars($user_guild_info['guild_tag']); ?>]</span>
<h1 style="display: inline; border-bottom: none; margin-left: 10px;"><?php echo htmlspecialchars($user_guild_info['guild_name']); ?></h1>
</div>
<div style="color: #8c92a3; font-size: 14px;">Votre grade : <span class="role-badge role-<?php echo $user_guild_info['role']; ?>"><?php echo $user_guild_info['role']; ?></span></div>
</div>
<div style="background: rgba(30, 41, 59, 0.4); border-left: 4px solid #88c0d0; padding: 20px; margin-bottom: 30px; color: #d8dee9; border-radius: 0 4px 4px 0;">
<?php echo nl2br(htmlspecialchars($user_guild_info['guild_desc'] ?: "Pas de description.")); ?>
</div>
<h3>Membres de la Guilde (<?php echo count($guild_members); ?> / <?php echo $member_limit; ?>)</h3>
<table class="member-table">
<thead><tr><th>Membre</th><th>Grade</th><th>Ancienneté</th><?php if ($user_guild_info['role'] === 'superviseur' || $user_guild_info['role'] === 'officier'): ?><th>Gestion</th><?php endif; ?></tr></thead>
<tbody>
<?php foreach ($guild_members as $member): ?>
<tr>
<td>
<strong style="color:<?php echo $member['user_id'] == $user_id ? '#88c0d0' : '#fff'; ?>">
@<?php echo htmlspecialchars($member['display_name'] ?: $member['username']); ?>
<?php if($member['user_id'] == $user_id) echo " (Vous)"; ?>
</strong>
</td>
<td><span class="role-badge role-<?php echo $member['role']; ?>"><?php echo $member['role']; ?></span></td>
<td><?php echo date('d/m/Y', strtotime($member['joined_at'])); ?></td>
<?php if ($user_guild_info['role'] === 'superviseur' || $user_guild_info['role'] === 'officier'): ?>
<td>
<?php if ($member['user_id'] != $user_id): ?>
<?php if ($user_guild_info['role'] === 'superviseur'): ?>
<form method="POST" style="display: inline;">
<input type="hidden" name="action" value="update_role">
<input type="hidden" name="target_user_id" value="<?php echo $member['user_id']; ?>">
<select name="new_role" onchange="this.form.submit()" style="background: #1a202c; color: #fff; border: 1px solid #334155; padding: 4px; font-size: 11px; border-radius: 4px; cursor: pointer;">
<option value="membre" <?php echo $member['role'] === 'membre' ? 'selected' : ''; ?>>Membre</option>
<option value="officier" <?php echo $member['role'] === 'officier' ? 'selected' : ''; ?>>Officier</option>
</select>
</form>
<?php endif; ?>
<?php if ($user_guild_info['role'] === 'superviseur' || ($user_guild_info['role'] === 'officier' && $member['role'] === 'membre')): ?>
<a href="?kick=<?php echo $member['user_id']; ?>" style="color: #bf616a; margin-left: 15px;" onclick="return confirm('Voulez-vous vraiment exclure ce membre ?')" title="Exclure"><i class="fa-solid fa-user-xmark"></i></a>
<?php endif; ?>
<?php endif; ?>
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div style="margin-top: 40px; border-top: 1px solid #1e293b; padding-top: 20px; display: flex; justify-content: flex-end;">
<?php if ($user_guild_info['role'] === 'superviseur'): ?>
<a href="?action=disband" class="btn btn-danger" onclick="return confirm('ATTENTION : Voulez-vous vraiment DISSOUDRE la guilde ? Cette action est irréversible.')">Dissoudre la guilde</a>
<?php else: ?>
<a href="?action=leave" class="btn btn-danger" onclick="return confirm('Quitter la guilde ?')">Quitter la guilde</a>
<?php endif; ?>
</div>
<i class="fa-solid <?php echo htmlspecialchars($res["icon"]); ?>" style="color: #88c0d0;"></i>
<?php endif; ?>
</div>
<div class="resource-info">
<div style="font-size: 9px; text-transform: uppercase; color: #64748b;"><?php echo htmlspecialchars($name); ?></div>
<span class="resource-value"><?php echo htmlspecialchars($res["val"]); ?></span>
</div>
</div>
</main>
<?php endforeach; ?>
</div>
</header>
<main id="main-content">
<?php if ($guild_id): ?>
<div class="card">
<div class="card-title">
<i class="fa-solid fa-building-shield"></i>
<span><?php echo htmlspecialchars($user['guild_name']); ?> [<?php echo htmlspecialchars($members[0]['role'] == 'owner' ? $members[0]['role'] : 'Membre'); ?>]</span>
</div>
<table class="member-table">
<thead>
<tr>
<th>Niveau</th>
<th>Membre</th>
<th>Rang</th>
<th>Date d'arrivée</th>
</tr>
</thead>
<tbody>
<?php foreach ($members as $m): ?>
<tr>
<td style="color: #88c0d0; font-weight: bold;">
<?php echo htmlspecialchars($m['level_name'] ?: 'Niveau 1'); ?>
</td>
<td>
<span class="member-link" onclick="openProfileModal(<?php echo $m['id']; ?>)">
<?php echo htmlspecialchars($m['display_name'] ?: $m['username']); ?>
</span>
</td>
<td>
<span class="role-badge role-<?php echo $m['role']; ?>">
<?php
switch($m['role']) {
case 'owner': echo 'Superviseur'; break;
case 'officer': echo 'Officier'; break;
default: echo 'Explorateur';
}
?>
</span>
</td>
<td style="color: #64748b; font-size: 12px;">
<?php echo date('d/m/Y', strtotime($m['joined_at'])); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div class="card">
<div class="card-title">
<i class="fa-solid fa-plus-circle"></i>
<span>Fonder une nouvelle guilde</span>
</div>
<?php if ($error): ?><div style="color: #bf616a; margin-bottom: 20px; padding: 10px; background: rgba(191,97,106,0.1); border-radius: 6px;"><?php echo $error; ?></div><?php endif; ?>
<form method="POST">
<div class="form-group">
<label>Nom de la guilde</label>
<input type="text" name="guild_name" class="form-control" placeholder="ex: Les Pionniers du Vide" required>
</div>
<div class="form-group">
<label>Tag (3-4 caractères)</label>
<input type="text" name="guild_tag" class="form-control" placeholder="ex: LPV" maxlength="4" required>
</div>
<button type="submit" name="create_guild" class="btn-primary">Fonder la guilde</button>
</form>
</div>
<?php endif; ?>
</main>
<!-- MODAL DE PROFIL (Même structure que index.php) -->
<div id="profileModal" class="modal-overlay" onclick="if(event.target === this) closeProfileModal()">
<div class="modal-container">
<div class="modal-header">
<h2>Profil Public</h2>
<button class="modal-close" onclick="closeProfileModal()">&times;</button>
</div>
<div id="profileModalContent" class="modal-body">
<!-- Le contenu sera chargé ici via AJAX -->
</div>
</div>
</div>
<script>
function openProfileModal(userId) {
const modal = document.getElementById('profileModal');
const content = document.getElementById('profileModalContent');
content.innerHTML = '<div class="loader"></div>';
modal.style.display = 'flex';
fetch(`profile.php?id=${userId}`, {
headers: { 'X-Requested-With': 'XMLHttpRequest' }
})
.then(response => response.text())
.then(html => {
content.innerHTML = html;
})
.catch(error => {
content.innerHTML = '<div style="color: #bf616a; text-align: center;">Erreur lors du chargement du profil.</div>';
console.error('Error:', error);
});
}
function closeProfileModal() {
document.getElementById('profileModal').style.display = 'none';
}
</script>
</body>
</html>

View File

@ -1,49 +1,169 @@
<?php
require_once 'db/config.php';
$username = $_GET['player'] ?? '';
session_start();
$db = db();
$id = $_GET['id'] ?? null;
$username = $_GET['player'] ?? '';
$is_ajax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest';
$user = null;
if (!empty($username)) {
$stmt = $db->prepare("SELECT username, display_name, level, grade FROM users WHERE username = ?");
$stmt->execute([$username]);
if ($id || !empty($username)) {
// Fetch full user data matching the header logic in index.php
$sql = "SELECT u.id, u.role, u.display_name, u.username, u.guild_id, l.name as level_raw,
u.selected_title_id, u.selected_badge_id,
t.name as title_name,
b.name as badge_name, b.image_url as badge_image,
g.name as guild_name, g.tag as guild_tag
FROM users u
LEFT JOIN levels l ON u.level_id = l.id
LEFT JOIN titles t ON u.selected_title_id = t.id
LEFT JOIN badges b ON u.selected_badge_id = b.id
LEFT JOIN guilds g ON u.guild_id = g.id
WHERE " . ($id ? "u.id = ?" : "(u.username = ? OR u.display_name = ?)");
$stmt = $db->prepare($sql);
$params = $id ? [$id] : [$username, $username];
$stmt->execute($params);
$user = $stmt->fetch();
if ($user) {
$level_num = (int)filter_var($user['level_raw'] ?? '1', FILTER_SANITIZE_NUMBER_INT);
$grade_type = ($user['role'] === 'admin') ? 'admin' : 'utilisateur';
$g_stmt = $db->prepare("SELECT name, image_url FROM grades
WHERE user_type = ?
AND (min_level <= ? OR min_level IS NULL)
AND (max_level >= ? OR max_level IS NULL)
LIMIT 1");
$g_stmt->execute([$grade_type, $level_num, $level_num]);
$grade_data = $g_stmt->fetch();
$user['grade_name'] = $grade_data['name'] ?? "Recrue";
$user['grade_image'] = $grade_data['image_url'] ?? "assets/images/placeholder_grade.png";
$user['level_num'] = $level_num ?: 1;
}
}
?>
if ($is_ajax): ?>
<div style="text-align: center; padding: 20px 0;">
<?php if ($user): ?>
<div style="display: flex; align-items: center; justify-content: center; gap: 15px; margin-bottom: 10px;">
<img src="<?php echo htmlspecialchars($user['grade_image']); ?>" style="width: 60px; height: 60px; object-fit: contain;">
<span style="font-size: 28px; font-weight: bold; color: #fff;">
<?php echo htmlspecialchars($user['grade_name']); ?>
<?php echo htmlspecialchars($user['display_name'] ?: $user['username']); ?>
</span>
</div>
<?php if (!empty($user['title_name'])): ?>
<div style="font-size: 14px; font-weight: bold; color: #ebcb8b; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 5px;">
« <?php echo htmlspecialchars($user['title_name']); ?> »
</div>
<?php endif; ?>
<div style="font-size: 16px; color: #88c0d0; opacity: 0.8; margin-bottom: 20px;">
Niveau <?php echo $user['level_num']; ?>
</div>
<?php if (!empty($user['guild_id'])): ?>
<div style="background: rgba(30, 41, 59, 0.3); padding: 10px; border-radius: 8px; border: 1px solid rgba(136, 192, 208, 0.1); display: inline-flex; align-items: center; gap: 8px; margin-bottom: 20px;">
<i class="fa-solid fa-building-shield" style="color: #88c0d0;"></i>
<span style="color: #ebcb8b; font-weight: bold;">[<?php echo htmlspecialchars($user['guild_tag']); ?>]</span>
<span style="color: #fff; font-size: 13px;"><?php echo htmlspecialchars($user['guild_name']); ?></span>
</div>
<?php endif; ?>
<?php if (!empty($user['badge_image'])): ?>
<div style="margin-top: 20px; padding: 15px; background: rgba(30, 41, 59, 0.3); border-radius: 12px; display: block; width: fit-content; margin-left: auto; margin-right: auto;">
<img src="<?php echo htmlspecialchars($user['badge_image']); ?>?v=<?php echo time(); ?>" style="width: 80px; height: 80px; object-fit: contain; filter: drop-shadow(0 0 10px rgba(136, 192, 208, 0.2));" title="<?php echo htmlspecialchars($user['badge_name']); ?>">
<div style="font-size: 10px; color: #8c92a3; margin-top: 8px; text-transform: uppercase;">Badge Équipé</div>
</div>
<?php endif; ?>
<?php else: ?>
<div style="text-align: center; padding: 40px;">
<i class="fa-solid fa-user-slash" style="font-size: 48px; color: #bf616a; margin-bottom: 20px;"></i>
<h2 style="color: #fff;">Joueur introuvable</h2>
</div>
<?php endif; ?>
</div>
<?php exit; endif; ?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Profil Joueur - Nexus</title>
<title>Profil de <?php echo $user ? htmlspecialchars($user['display_name'] ?: $user['username']) : 'Joueur'; ?> - Nexus</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<link href="assets/css/custom.css?v=<?php echo time(); ?>" rel="stylesheet">
<style>
body { background: #000; margin: 0; padding: 20px; font-family: Arial, sans-serif; color: #fff; background-image: radial-gradient(circle at 50% 50%, #1a2a4a 0%, #000 70%); min-height: 100vh; }
.profile-container { background: rgba(10, 15, 30, 0.95); border: 1px solid #4c566a; padding: 30px; width: 100%; max-width: 500px; margin: 0 auto; box-shadow: 0 0 20px rgba(0,0,0,0.8); text-align: center; }
h2 { text-transform: uppercase; color: #88c0d0; margin-bottom: 20px; }
.stat-card { padding: 15px; background: rgba(0,0,0,0.3); border: 1px solid #2d3545; margin-bottom: 15px; text-align: left; }
.stat-card strong { color: #8c92a3; display: block; font-size: 12px; text-transform: uppercase; margin-bottom: 5px; }
.not-found { color: #bf616a; }
.nav-links { margin-top: 25px; font-size: 13px; }
.nav-links a { color: #88c0d0; text-decoration: none; }
body { background: #000; color: #fff; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; background-image: radial-gradient(circle at 50% 50%, #0f172a 0%, #000 100%); }
.profile-card { background: rgba(15, 23, 42, 0.9); border: 1px solid #1e293b; border-radius: 16px; width: 100%; max-width: 550px; padding: 40px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); text-align: center; position: relative; overflow: hidden; }
.profile-card::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: linear-gradient(90deg, #88c0d0, #81a1c1); }
.grade-img { width: 100px; height: 100px; object-fit: contain; margin-bottom: 20px; filter: drop-shadow(0 0 15px rgba(136, 192, 208, 0.3)); }
h1 { margin: 10px 0; font-size: 32px; color: #fff; }
.username { color: #8c92a3; font-size: 16px; margin-bottom: 15px; display: block; }
.title-text { font-size: 16px; font-weight: bold; color: #ebcb8b; text-transform: uppercase; letter-spacing: 0.15em; margin-bottom: 10px; font-style: italic; }
.level-badge { display: inline-block; background: rgba(136, 192, 208, 0.1); color: #88c0d0; padding: 5px 15px; border-radius: 20px; font-weight: bold; font-size: 14px; margin-bottom: 25px; border: 1px solid rgba(136, 192, 208, 0.3); }
.guild-info { background: rgba(30, 41, 59, 0.5); padding: 15px; border-radius: 12px; margin-bottom: 30px; border: 1px solid #1e293b; display: inline-flex; align-items: center; gap: 10px; }
.guild-tag { color: #ebcb8b; font-weight: bold; }
.guild-name { color: #fff; font-weight: 500; }
.badge-display { margin-top: 20px; padding: 20px; background: rgba(0, 0, 0, 0.2); border-radius: 16px; display: inline-block; border: 1px solid rgba(255,255,255,0.05); }
.badge-img { width: 120px; height: 120px; object-fit: contain; filter: drop-shadow(0 0 20px rgba(136, 192, 208, 0.2)); }
.badge-name { font-size: 11px; color: #8c92a3; margin-top: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.btn-back { margin-top: 40px; display: inline-block; color: #8c92a3; text-decoration: none; font-size: 14px; transition: color 0.2s; }
.btn-back:hover { color: #88c0d0; }
.error-container { text-align: center; }
.error-container i { font-size: 64px; color: #bf616a; margin-bottom: 20px; }
</style>
</head>
<body>
<div class="profile-container">
<div class="profile-card">
<?php if ($user): ?>
<h2><i class="fa-solid fa-user"></i> Profil de <?php echo htmlspecialchars($user['display_name']); ?></h2>
<div class="stat-card"><strong>Identifiant</strong> @<?php echo htmlspecialchars($user['username']); ?></div>
<div class="stat-card"><strong>Niveau</strong> <?php echo htmlspecialchars($user['level'] ?? 'N/A'); ?></div>
<div class="stat-card"><strong>Grade</strong> <?php echo htmlspecialchars($user['grade'] ?? 'N/A'); ?></div>
<img src="<?php echo htmlspecialchars($user['grade_image']); ?>" class="grade-img" alt="Grade">
<h1><?php echo htmlspecialchars($user['display_name'] ?: $user['username']); ?></h1>
<span class="username">@<?php echo htmlspecialchars($user['username']); ?></span>
<?php if (!empty($user['title_name'])): ?>
<div class="title-text">« <?php echo htmlspecialchars($user['title_name']); ?> »</div>
<?php endif; ?>
<div class="level-badge">NIVEAU <?php echo $user['level_num']; ?> — <?php echo htmlspecialchars($user['grade_name']); ?></div>
<?php if (!empty($user['guild_id'])): ?>
<br>
<div class="guild-info">
<i class="fa-solid fa-building-shield" style="color: #88c0d0;"></i>
<span class="guild-tag">[<?php echo htmlspecialchars($user['guild_tag']); ?>]</span>
<span class="guild-name"><?php echo htmlspecialchars($user['guild_name']); ?></span>
</div>
<?php endif; ?>
<?php if (!empty($user['badge_image'])): ?>
<div style="display: block;">
<div class="badge-display">
<img src="<?php echo htmlspecialchars($user['badge_image']); ?>?v=<?php echo time(); ?>" class="badge-img" title="<?php echo htmlspecialchars($user['badge_name']); ?>">
<div class="badge-name">Badge de prestige</div>
</div>
</div>
<?php endif; ?>
<?php else: ?>
<h2 class="not-found">Joueur introuvable</h2>
<p>Le profil demandé n'existe pas ou a été supprimé.</p>
<div class="error-container">
<i class="fa-solid fa-user-slash"></i>
<h1>Joueur introuvable</h1>
<p style="color: #8c92a3;">Le profil de @<?php echo htmlspecialchars($username); ?> n'a pas été localisé dans la base de données du Nexus.</p>
</div>
<?php endif; ?>
<div class="nav-links">
<a href="index.php"><i class="fa-solid fa-arrow-left"></i> Retour au Nexus</a>
</div>
<a href="index.php" class="btn-back"><i class="fa-solid fa-arrow-left"></i> Retour au Nexus</a>
</div>
</body>
</html>