Alpha V2.5.6

This commit is contained in:
Flatlogic Bot 2026-03-06 10:39:15 +00:00
parent 43773ce2c0
commit c7144cbd7e

View File

@ -17,6 +17,16 @@ $stmt = $db->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$user = $stmt->fetch();
// Fetch available titles
$stmt = $db->prepare("SELECT * FROM titles WHERE (allowed_user_type = 'all' OR allowed_user_type = ?) AND required_level <= ? ORDER BY name ASC");
$stmt->execute([$user['user_type'] ?? 'user', $user['level_id'] ?? 1]);
$available_titles = $stmt->fetchAll();
// Fetch available badges
$stmt = $db->prepare("SELECT * FROM badges WHERE (allowed_user_type = 'all' OR allowed_user_type = ?) AND required_level <= ? ORDER BY name ASC");
$stmt->execute([$user['user_type'] ?? 'user', $user['level_id'] ?? 1]);
$available_badges = $stmt->fetchAll();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$action = $_POST['action'] ?? '';
@ -57,10 +67,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
} elseif ($action === 'update_display_name') {
$display_name = trim($_POST['display_name'] ?? '');
$selected_title_id = $_POST['selected_title_id'] ?? null;
$selected_badge_id = $_POST['selected_badge_id'] ?? null;
if ($selected_title_id === '') $selected_title_id = null;
if ($selected_badge_id === '') $selected_badge_id = null;
if (!empty($display_name)) {
$stmt = $db->prepare("UPDATE users SET display_name = ? WHERE id = ?");
$stmt->execute([$display_name, $user_id]);
$_SESSION["display_name"] = $display_name; $success = "Nom affiché mis à jour avec succès.";
$stmt = $db->prepare("UPDATE users SET display_name = ?, selected_title_id = ?, selected_badge_id = ? WHERE id = ?");
$stmt->execute([$display_name, $selected_title_id, $selected_badge_id, $user_id]);
$_SESSION["display_name"] = $display_name;
$success = "Informations de jeu mises à jour avec succès.";
$stmt = $db->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$user_id]);
@ -89,7 +106,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
.tab-content.active { display: block; }
.form-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 5px; color: #8c92a3; font-size: 14px; }
input { width: 100%; padding: 10px; background: #000; border: 1px solid #4c566a; color: #fff; box-sizing: border-box; }
input, select { width: 100%; padding: 10px; background: #000; border: 1px solid #4c566a; color: #fff; box-sizing: border-box; }
.inline-form { display: flex; gap: 10px; align-items: end; }
.inline-form input { flex-grow: 1; }
.inline-form button { width: auto; padding: 10px 20px; }
@ -101,6 +118,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
.alert-success { background: rgba(163, 190, 140, 0.2); border: 1px solid #a3be8c; color: #a3be8c; }
.nav-links { display: flex; justify-content: space-between; margin-top: 25px; border-top: 1px solid #2d3545; padding-top: 15px; font-size: 13px; }
.nav-links a { color: #88c0d0; text-decoration: none; }
.badge-preview { margin-top: 10px; text-align: center; background: rgba(0,0,0,0.5); padding: 10px; border: 1px dashed #4c566a; display: none; }
.badge-preview img { max-width: 64px; max-height: 64px; }
</style>
</head>
<body>
@ -117,13 +136,43 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<h2><i class="fa-solid fa-chart-line"></i> Vue d\'ensemble</h2>
<div class="stat-card"><strong>Pseudo de compte:</strong> @<?php echo htmlspecialchars($user['username']); ?></div>
<form method="POST" class="form-group">
<form method="POST">
<input type="hidden" name="action" value="update_display_name">
<label>Nom affiché (Jeu)</label>
<div class="inline-form">
<input type="text" name="display_name" value="<?php echo htmlspecialchars($user['display_name']); ?>">
<button type="submit">Sauvegarder</button>
<div class="form-group">
<label>Nom affiché (Jeu)</label>
<input type="text" name="display_name" value="<?php echo htmlspecialchars($user['display_name'] ?? ''); ?>">
</div>
<div class="form-group">
<label>Titre</label>
<select name="selected_title_id">
<option value="">Aucun titre</option>
<?php foreach ($available_titles as $title): ?>
<option value="<?php echo $title['id']; ?>" <?php echo ($user['selected_title_id'] == $title['id']) ? 'selected' : ''; ?> >
<?php echo htmlspecialchars($title['name']); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label>Badge</label>
<select name="selected_badge_id" id="badge-selector" onchange="updateBadgePreview()">
<option value="" data-img="">Aucun badge</option>
<?php foreach ($available_badges as $badge): ?>
<option value="<?php echo $badge['id']; ?>" data-img="<?php echo htmlspecialchars($badge['image_url']); ?>" <?php echo ($user['selected_badge_id'] == $badge['id']) ? 'selected' : ''; ?> >
<?php echo htmlspecialchars($badge['name']); ?>
</option>
<?php endforeach; ?>
</select>
<div id="badge-preview-container" class="badge-preview">
<label style="margin-bottom: 10px;">Aperçu du badge</label>
<img id="badge-preview-img" src="" alt="Badge Preview">
</div>
</div>
<button type="submit">Sauvegarder tout</button>
</form>
</div>
@ -163,6 +212,26 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
document.getElementById(id).classList.add('active');
event.currentTarget.classList.add('active');
}
function updateBadgePreview() {
const selector = document.getElementById('badge-selector');
const selectedOption = selector.options[selector.selectedIndex];
const imgUrl = selectedOption.getAttribute('data-img');
const previewContainer = document.getElementById('badge-preview-container');
const previewImg = document.getElementById('badge-preview-img');
if (imgUrl) {
previewImg.src = imgUrl;
previewContainer.style.display = 'block';
} else {
previewContainer.style.display = 'none';
}
}
// Initialize preview on load
window.onload = function() {
updateBadgePreview();
};
</script>
</body>
</html>
</html>