Alpha V2.5.5

This commit is contained in:
Flatlogic Bot 2026-03-06 10:36:29 +00:00
parent 81cfad2a9e
commit 43773ce2c0
3 changed files with 249 additions and 4 deletions

253
admin.php
View File

@ -125,6 +125,76 @@ if (isset($_GET['delete_object'])) {
exit;
}
// Handle Title CRUD
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'upsert_title') {
$id = (int)$_POST['id'];
$name = $_POST["name"];
$slug = $_POST['slug'];
$allowed_user_type = $_POST['allowed_user_type'];
$required_level = (int)$_POST['required_level'];
if ($id > 0) {
$stmt = $db->prepare("UPDATE titles SET name = ?, slug = ?, allowed_user_type = ?, required_level = ? WHERE id = ?");
$stmt->execute([$name, $slug, $allowed_user_type, $required_level, $id]);
} else {
$stmt = $db->prepare("INSERT INTO titles (name, slug, allowed_user_type, required_level) VALUES (?, ?, ?, ?)");
$stmt->execute([$name, $slug, $allowed_user_type, $required_level]);
}
header("Location: admin.php?tab=badges&success=1");
exit;
}
// Handle Badge CRUD
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'upsert_badge') {
$id = (int)$_POST['id'];
$name = $_POST["name"];
$slug = $_POST['slug'];
$allowed_user_type = $_POST['allowed_user_type'];
$required_level = (int)$_POST['required_level'];
$image_url = null;
if ($id > 0) {
$stmt_img = $db->prepare("SELECT image_url FROM badges WHERE id = ?");
$stmt_img->execute([$id]);
$image_url = $stmt_img->fetchColumn();
}
if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) {
$ext = pathinfo($_FILES['image']["name"], PATHINFO_EXTENSION);
$filename = "badge_" . $slug . "_" . time() . "." . $ext;
$target = "assets/images/badges/" . $filename;
if (!is_dir("assets/images/badges/")) mkdir("assets/images/badges/", 0775, true);
if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {
$image_url = $target;
}
}
if ($id > 0) {
$stmt = $db->prepare("UPDATE badges SET name = ?, slug = ?, allowed_user_type = ?, required_level = ?, image_url = ? WHERE id = ?");
$stmt->execute([$name, $slug, $allowed_user_type, $required_level, $image_url, $id]);
} else {
$stmt = $db->prepare("INSERT INTO badges (name, slug, allowed_user_type, required_level, image_url) VALUES (?, ?, ?, ?, ?)");
$stmt->execute([$name, $slug, $allowed_user_type, $required_level, $image_url]);
}
header("Location: admin.php?tab=badges&success=1");
exit;
}
// Handle Title/Badge Deletion
if (isset($_GET['delete_title'])) {
$id = (int)$_GET['delete_title'];
$db->prepare("DELETE FROM titles WHERE id = ?")->execute([$id]);
header("Location: admin.php?tab=badges&success=deleted");
exit;
}
if (isset($_GET['delete_badge'])) {
$id = (int)$_GET['delete_badge'];
$db->prepare("DELETE FROM badges WHERE id = ?")->execute([$id]);
header("Location: admin.php?tab=badges&success=deleted");
exit;
}
// Handle Status CRUD
if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["action"]) && $_POST["action"] === "upsert_status") {
$id = (int)$_POST["id"];
@ -574,6 +644,8 @@ $factions_list = [];
$resources_list = [];
$lootboxes_list = [];
$project_logs_list = [];
$titles_list = [];
$badges_list = [];
$levels_list = [];
$ranks_list = [];
$guild_requirements = [];
@ -615,6 +687,9 @@ if ($tab === 'users') {
$resources_list = $db->query("SELECT * FROM game_resources ORDER BY name ASC")->fetchAll();
} elseif ($tab === 'project_logs') {
$project_logs_list = $db->query("SELECT * FROM project_logs ORDER BY created_at DESC")->fetchAll();
} elseif ($tab === 'badges') {
$titles_list = $db->query("SELECT * FROM titles ORDER BY name ASC")->fetchAll();
$badges_list = $db->query("SELECT * FROM badges ORDER BY name ASC")->fetchAll();
} elseif ($tab === 'ranks') {
$ranks_list = $db->query("SELECT * FROM grades ORDER BY user_type DESC, min_level ASC")->fetchAll();
} elseif ($tab === 'lootboxes') {
@ -987,13 +1062,150 @@ if ($tab === 'users') {
<button type="submit" class="btn btn-add" style="margin-top: 15px;">ENREGISTRER</button>
</form>
</div>
<?php elseif ($tab === 'badges'): ?>
<?php elseif ($tab === 'badges'): ?>
<h3 style="color: #88c0d0;">Titres & Badges</h3>
<div class="form-card">
<p><i class="fa-solid fa-info-circle"></i> À configurer</p>
<div style="display: flex; gap: 20px; align-items: flex-start;">
<!-- COLONNE GAUCHE : TITRES -->
<div style="flex: 1; background: #0a1420; padding: 20px; border: 1px solid #2d3545; border-radius: 4px;">
<h4 style="color: #88c0d0; border-bottom: 1px solid #2d3545; padding-bottom: 10px; margin-bottom: 20px;">
<i class="fa-solid fa-id-card"></i> Gestion des Titres
</h4>
<form method="POST" id="titleForm" class="form-card" style="margin-bottom: 20px;">
<input type="hidden" name="action" value="upsert_title">
<input type="hidden" name="id" id="title_id" value="0">
<div class="form-group">
<label>Nom du titre</label>
<input type="text" name="name" id="title_name" required placeholder="Ex: Pionnier du Nexus">
</div>
<div class="form-group">
<label>Slug (Identifiant technique)</label>
<input type="text" name="slug" id="title_slug" required placeholder="Ex: pioneer">
</div>
<div class="form-group">
<label>Type d'utilisateur autorisé</label>
<select name="allowed_user_type" id="title_allowed_type">
<option value="all">Tous (all)</option>
<option value="user">Utilisateurs standards</option>
<option value="gm">Maîtres de jeu (GM)</option>
<option value="admin">Administrateurs</option>
</select>
</div>
<div class="form-group">
<label>Niveau minimum requis</label>
<input type="number" name="required_level" id="title_req_level" value="0" min="0">
</div>
<div style="display: flex; gap: 10px;">
<button type="submit" class="btn btn-add" style="flex: 1;">ENREGISTRER</button>
<button type="button" class="btn" style="background: #4c566a; color: #fff;" onclick="resetTitleForm()">ANNULER</button>
</div>
</form>
<table style="font-size: 13px;">
<thead>
<tr>
<th>Titre</th>
<th>Slug</th>
<th>Niveau</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($titles_list as $t): ?>
<tr>
<td><strong><?php echo htmlspecialchars($t['name']); ?></strong></td>
<td><code style="color: #ebcb8b;"><?php echo htmlspecialchars($t['slug']); ?></code></td>
<td><?php echo $t['required_level']; ?></td>
<td>
<button class="btn btn-edit" onclick='editTitle(<?php echo json_encode($t); ?>)'>Edit</button>
<a href="?tab=badges&delete_title=<?php echo $t['id']; ?>" class="btn btn-del" onclick="return confirm('Supprimer ce titre ?')">X</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<!-- COLONNE DROITE : BADGES -->
<div style="flex: 1; background: #0a1420; padding: 20px; border: 1px solid #2d3545; border-radius: 4px;">
<h4 style="color: #88c0d0; border-bottom: 1px solid #2d3545; padding-bottom: 10px; margin-bottom: 20px;">
<i class="fa-solid fa-id-badge"></i> Gestion des Badges
</h4>
<form method="POST" id="badgeForm" class="form-card" enctype="multipart/form-data" style="margin-bottom: 20px;">
<input type="hidden" name="action" value="upsert_badge">
<input type="hidden" name="id" id="badge_id" value="0">
<div style="display: flex; gap: 10px;">
<div class="form-group" style="flex: 2;">
<label>Image du badge</label>
<input type="file" name="image" accept="image/*">
</div>
<div id="badge_preview_container" style="flex: 1; text-align: center; background: #0f172a; border: 1px solid #334155; border-radius: 4px; padding: 5px; display: none;">
<img id="badge_preview" src="" style="max-height: 50px; max-width: 50px;">
</div>
</div>
<div class="form-group">
<label>Nom du badge</label>
<input type="text" name="name" id="badge_name" required placeholder="Ex: Fondateur">
</div>
<div class="form-group">
<label>Slug (Identifiant technique)</label>
<input type="text" name="slug" id="badge_slug" required placeholder="Ex: founder">
</div>
<div class="form-group">
<label>Type d'utilisateur autorisé</label>
<select name="allowed_user_type" id="badge_allowed_type">
<option value="all">Tous (all)</option>
<option value="user">Utilisateurs standards</option>
<option value="gm">Maîtres de jeu (GM)</option>
<option value="admin">Administrateurs</option>
</select>
</div>
<div class="form-group">
<label>Niveau minimum requis</label>
<input type="number" name="required_level" id="badge_req_level" value="0" min="0">
</div>
<div style="display: flex; gap: 10px;">
<button type="submit" class="btn btn-add" style="flex: 1;">ENREGISTRER</button>
<button type="button" class="btn" style="background: #4c566a; color: #fff;" onclick="resetBadgeForm()">ANNULER</button>
</div>
</form>
<table style="font-size: 13px;">
<thead>
<tr>
<th>Visuel</th>
<th>Badge</th>
<th>Slug</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($badges_list as $b): ?>
<tr>
<td style="text-align: center;">
<img src="<?php echo htmlspecialchars($b['image_url']); ?>" style="max-height: 30px; max-width: 30px;">
</td>
<td><strong><?php echo htmlspecialchars($b['name']); ?></strong></td>
<td><code style="color: #ebcb8b;"><?php echo htmlspecialchars($b['slug']); ?></code></td>
<td>
<button class="btn btn-edit" onclick='editBadge(<?php echo json_encode($b); ?>)'>Edit</button>
<a href="?tab=badges&delete_badge=<?php echo $b['id']; ?>" class="btn btn-del" onclick="return confirm('Supprimer ce badge ?')">X</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php elseif ($tab === 'objects'): ?>
<?php elseif ($tab === 'objects'): ?>
<h3 style="color: #88c0d0;">Objets Célestes</h3>
<div class="form-card">
<h4>Ajouter / Modifier un Objet</h4>
@ -2017,6 +2229,39 @@ function editStatus(data) {
updateMSLabel('ms_orb');
updateMSLabel('ms_terr');
}
function editTitle(data) {
document.getElementById('title_id').value = data.id;
document.getElementById('title_name').value = data.name;
document.getElementById('title_slug').value = data.slug;
document.getElementById('title_allowed_type').value = data.allowed_user_type;
document.getElementById('title_req_level').value = data.required_level;
window.scrollTo({ top: 0, behavior: 'smooth' });
}
function resetTitleForm() {
document.getElementById('titleForm').reset();
document.getElementById('title_id').value = 0;
}
function editBadge(data) {
document.getElementById('badge_id').value = data.id;
document.getElementById('badge_name').value = data.name;
document.getElementById('badge_slug').value = data.slug;
document.getElementById('badge_allowed_type').value = data.allowed_user_type;
document.getElementById('badge_req_level').value = data.required_level;
if (data.image_url) {
document.getElementById('badge_preview').src = data.image_url;
document.getElementById('badge_preview_container').style.display = 'block';
} else {
document.getElementById('badge_preview_container').style.display = 'none';
}
window.scrollTo({ top: 0, behavior: 'smooth' });
}
function resetBadgeForm() {
document.getElementById('badgeForm').reset();
document.getElementById('badge_id').value = 0;
document.getElementById('badge_preview_container').style.display = 'none';
}
</script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB