Alpha V2.5.17

This commit is contained in:
Flatlogic Bot 2026-03-11 01:48:01 +00:00
parent 21605b9c4e
commit f4b8494fd3

View File

@ -136,7 +136,40 @@ if (isset($_GET['join']) && !$in_guild) {
} }
} }
// ACCEPT/REFUSE MEMBER (Validation) // 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, recruitment_status) VALUES (?, ?, ?, 'ouvert')")->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(); }
}
}
// ACCEPT/REFUSE MEMBER
if (isset($_GET['validate']) && $in_guild && ($user_guild_info['role'] === 'superviseur' || $user_guild_info['role'] === 'officier')) { if (isset($_GET['validate']) && $in_guild && ($user_guild_info['role'] === 'superviseur' || $user_guild_info['role'] === 'officier')) {
$target_id = (int)$_GET['validate']; $target_id = (int)$_GET['validate'];
$action = $_GET['action_type'] ?? ''; $action = $_GET['action_type'] ?? '';
@ -224,39 +257,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['
} }
} }
// 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, recruitment_status) VALUES (?, ?, ?, 'ouvert')")->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 --- // --- DATA FETCHING ---
if ($in_guild) { if ($in_guild) {
@ -349,7 +349,7 @@ if ($in_guild) {
/* GUILD SPECIFIC STYLES */ /* GUILD SPECIFIC STYLES */
.guild-content { max-width: 1000px; width: 100%; margin-top: 20px; } .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); } .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); margin-bottom: 30px; }
h1, h2, h3 { color: #88c0d0; text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid #2d3545; padding-bottom: 10px; } 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 { margin-bottom: 15px; }
.form-group label { display: block; color: #8c92a3; font-size: 13px; margin-bottom: 5px; } .form-group label { display: block; color: #8c92a3; font-size: 13px; margin-bottom: 5px; }
@ -422,7 +422,7 @@ if ($in_guild) {
<div style="display: flex; align-items: center; gap: 20px;"> <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> <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"])): ?> <?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> <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"]) ? "Gestion de guilde" : "Voir ma guilde"; ?></a>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="user-auth-bar"> <div class="user-auth-bar">
@ -459,19 +459,67 @@ if ($in_guild) {
<?php if ($message): ?><div class="success-msg"><?php echo $message; ?></div><?php endif; ?> <?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; ?> <?php if ($error): ?><div class="error-msg"><?php echo $error; ?></div><?php endif; ?>
<div class="guild-card">
<?php if (!$in_guild): ?> <?php if (!$in_guild): ?>
<div style="display: flex; gap: 40px; flex-wrap: wrap;"> <!-- CADRE 1 : FONDER UNE GUILDE -->
<!-- Liste des guildes --> <div class="guild-card">
<div style="flex: 2; min-width: 300px;"> <h2><i class="fa-solid fa-plus-circle"></i> Fonder une guilde</h2>
<div style="margin-top: 20px;">
<p style="font-size: 13px; color: #8c92a3; margin-bottom: 10px;">Coût requis :</p>
<div style="margin-bottom: 25px;">
<?php if (empty($display_reqs)): ?><p style="color:#a3be8c; font-weight:bold;">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 style="display: flex; gap: 20px; margin-bottom: 15px;">
<div class="form-group" style="flex: 1;">
<label>Tag de la guilde (2-5 car.)</label>
<input type="text" name="tag" required maxlength="5" placeholder="Ex: [BHFR]">
</div>
<div class="form-group" style="flex: 3;">
<label>Nom de la guilde</label>
<input type="text" name="name" required placeholder="Nom de votre organisation">
</div>
</div>
<div class="form-group">
<label>Description des objectifs</label>
<textarea name="description" rows="3" placeholder="Quels sont les buts de votre guilde ?"></textarea>
</div>
<div style="margin-top: 20px;">
<button type="submit" class="btn btn-primary" style="width:100%; padding: 15px; font-size: 14px;" <?php echo !$can_afford_creation ? 'disabled' : ''; ?>>
<?php echo $can_afford_creation ? '<i class="fa-solid fa-hammer"></i> ÉTABLIR LA GUILDE' : '<i class="fa-solid fa-lock"></i> RESSOURCES INSUFFISANTES'; ?>
</button>
</div>
</form>
</div>
</div>
<!-- CADRE 2 : GUILDES ACTIVES -->
<div class="guild-card">
<h2><i class="fa-solid fa-list"></i> Guildes Actives</h2> <h2><i class="fa-solid fa-list"></i> Guildes Actives</h2>
<table class="guild-table" style="table-layout: fixed; width: 100%; border-collapse: collapse;"> <table class="guild-table" style="table-layout: fixed; width: 100%; border-collapse: collapse;">
<thead> <thead>
<tr> <tr>
<th style="width: 45%; color: #88c0d0; text-transform: uppercase; font-size: 11px; padding: 15px; border-bottom: 1px solid #1e293b; background: rgba(30, 41, 59, 0.5);">Guilde</th> <th style="width: 45%;">Guilde</th>
<th style="width: 15%; color: #88c0d0; text-transform: uppercase; font-size: 11px; padding: 15px; border-bottom: 1px solid #1e293b; background: rgba(30, 41, 59, 0.5);">Membres</th> <th style="width: 15%;">Membres</th>
<th style="width: 20%; color: #88c0d0; text-transform: uppercase; font-size: 11px; padding: 15px; border-bottom: 1px solid #1e293b; background: rgba(30, 41, 59, 0.5);">Recrutement</th> <th style="width: 20%;">Recrutement</th>
<th style="width: 20%; color: #88c0d0; text-transform: uppercase; font-size: 11px; padding: 15px; border-bottom: 1px solid #1e293b; background: rgba(30, 41, 59, 0.5);">Actions</th> <th style="width: 20%;">Actions</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -518,38 +566,8 @@ if ($in_guild) {
</tbody> </tbody>
</table> </table>
</div> </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>
<?php else: ?> <?php else: ?>
<div class="guild-card">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #88c0d0; padding-bottom: 15px; margin-bottom: 20px;"> <div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #88c0d0; padding-bottom: 15px; margin-bottom: 20px;">
<div> <div>
<span style="color: #ebcb8b; font-weight: bold; font-size: 24px;">[<?php echo htmlspecialchars($user_guild_info['guild_tag']); ?>]</span> <span style="color: #ebcb8b; font-weight: bold; font-size: 24px;">[<?php echo htmlspecialchars($user_guild_info['guild_tag']); ?>]</span>
@ -643,8 +661,8 @@ if ($in_guild) {
<a href="?action=leave" class="btn btn-danger" onclick="return confirm('Quitter la guilde ?')">Quitter la guilde</a> <a href="?action=leave" class="btn btn-danger" onclick="return confirm('Quitter la guilde ?')">Quitter la guilde</a>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php endif; ?>
</div> </div>
<?php endif; ?>
</div> </div>
</main> </main>
</div> </div>