Autosave: 20260316-225413

This commit is contained in:
Flatlogic Bot 2026-03-16 22:54:13 +00:00
parent 8e37245007
commit e3787e5b78
3 changed files with 102 additions and 24 deletions

59
api/get_profile.php Normal file
View File

@ -0,0 +1,59 @@
<?php
require_once __DIR__ . '/../db/config.php';
session_start();
$db = db();
if (!isset($_GET['user_id'])) {
http_response_code(400);
echo json_encode(['error' => 'Missing user_id']);
exit;
}
$user_id = (int)$_GET['user_id'];
$stmt = $db->prepare("SELECT u.username, u.display_name, u.level_id, u.guild_id,
l.name as level_name, 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,
(SELECT name FROM levels WHERE id = u.level_id) as grade_name,
(SELECT image_url FROM levels WHERE id = u.level_id) as grade_image
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 = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$u) {
http_response_code(404);
echo json_encode(['error' => 'User not found']);
exit;
}
ob_start();
?>
<div class="profile-top-section">
<div style="display: flex; align-items: center; justify-content: center; margin-bottom: 5px;">
<img src="<?php echo htmlspecialchars($u["grade_image"] ?? "assets/images/placeholder_grade.png"); ?>" class="profile-grade-img">
<span class="profile-username"><?php echo htmlspecialchars($u["grade_name"] ?? "Recrue"); ?> <?php echo htmlspecialchars($u["display_name"] ?? $u["username"]); ?></span>
</div>
<?php if (!empty($u['title_name'])): ?><span class="profile-title-text">— <?php echo htmlspecialchars($u['title_name']); ?> —</span><?php endif; ?>
<span class="profile-level-text">Niveau <?php echo htmlspecialchars($u["level_name"] ?? "1"); ?></span>
</div>
<div class="profile-section-header">Guilde</div>
<div class="guild-info-box">
<?php if (!empty($u['guild_id'])): ?>
<div class="guild-display"><div class="guild-icon-placeholder"><i class="fa-solid fa-building-shield"></i></div><span class="guild-tag-display">[<?php echo htmlspecialchars($u['guild_tag']); ?>]</span><span class="guild-name-display"><?php echo htmlspecialchars($u['guild_name']); ?></span></div>
<?php else: ?><div class="guild-display" style="opacity: 0.5;"><div class="guild-icon-placeholder"><i class="fa-solid fa-user"></i></div><span class="guild-name-display" style="font-style: italic;">Aucune guilde</span></div>
<?php endif; ?>
</div>
<div class="profile-bottom-grid">
<div class="profile-left-col"><div style="width: 100%; height: 100%; opacity: 0.1; background: url('https://www.transparenttextures.com/patterns/stardust.png');"></div></div>
<div class="profile-right-col"><div class="profile-section-header">Insigne Équipé</div><div class="badge-info-section">
<?php if (!empty($u['badge_image'])): ?><img src="<?php echo htmlspecialchars($u['badge_image']); ?>?v=<?php echo time(); ?>" class="badge-img-display" title="<?php echo htmlspecialchars($u['badge_name'] ?? ''); ?>"><span class="badge-name-display"><?php echo htmlspecialchars($u['badge_name'] ?? ''); ?></span>
<?php else: ?><div style="width: 80px; height: 80px; display: flex; align-items: center; justify-content: center; opacity: 0.2; margin-bottom: 15px;"><i class="fa-solid fa-medal fa-3x"></i></div><span class="badge-name-display" style="opacity: 0.5; font-style: italic;">Aucun insigne</span><?php endif; ?>
</div></div>
</div>
<?php
$html = ob_get_clean();
echo json_encode(['html' => $html]);

View File

@ -11,29 +11,48 @@ document.addEventListener('DOMContentLoaded', () => {
chatMessages.scrollTop = chatMessages.scrollHeight;
};
chatForm.addEventListener('submit', async (e) => {
e.preventDefault();
const message = chatInput.value.trim();
if (!message) return;
if (chatForm) {
chatForm.addEventListener('submit', async (e) => {
e.preventDefault();
const message = chatInput.value.trim();
if (!message) return;
appendMessage(message, 'visitor');
chatInput.value = '';
appendMessage(message, 'visitor');
chatInput.value = '';
try {
const response = await fetch('api/chat.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message })
});
const data = await response.json();
// Artificial delay for realism
setTimeout(() => {
appendMessage(data.reply, 'bot');
}, 500);
} catch (error) {
console.error('Error:', error);
appendMessage("Désolé, une erreur est survenue. Veuillez réessayer.", 'bot');
}
});
try {
const response = await fetch('api/chat.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message })
});
const data = await response.json();
// Artificial delay for realism
setTimeout(() => {
appendMessage(data.reply, 'bot');
}, 500);
} catch (error) {
console.error('Error:', error);
appendMessage("Désolé, une erreur est survenue. Veuillez réessayer.", 'bot');
}
});
}
});
async function loadProfile(userId) {
const modal = document.getElementById('profileModal');
const content = document.getElementById('profileModalContent');
if (!modal || !content) return;
try {
const response = await fetch('api/get_profile.php?user_id=' + userId);
const data = await response.json();
if (data.html) {
content.innerHTML = data.html;
modal.style.display = 'flex';
}
} catch (error) {
console.error('Error loading profile:', error);
}
}

View File

@ -223,7 +223,7 @@ if ($in_guild) {
<tbody>
<?php foreach ($guild_members as $member): ?>
<tr>
<td>@<?php echo htmlspecialchars($member['display_name'] ?: $member['username']); ?></td>
<td><a href="javascript:void(0)" onclick="loadProfile(<?php echo (int)$member["user_id"]; ?>)">@<?php echo htmlspecialchars($member["display_name"] ?: $member["username"]); ?></a></td>
<td><span class="role-badge role-<?php echo str_replace(' ', '-', $member['role']); ?>"><?php echo $member['role']; ?></span></td>
<td>
<?php if ($member['user_id'] == $user_id && $member['role'] !== 'superviseur'): ?><a href="?action=leave" class="btn btn-danger" onclick="return confirm('Quitter ?')">Quitter</a><?php endif; ?>