From 83107ef847f07e01833e5ed39a0c48a4fa1ca627 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Mon, 23 Feb 2026 02:03:41 +0000 Subject: [PATCH] Autosave: 20260223-020340 --- admin.php | 25 ++++++++++++++++++++----- db/add_show_in_header_to_resources.php | 17 +++++++++++++++++ index.php | 15 +++++++-------- 3 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 db/add_show_in_header_to_resources.php diff --git a/admin.php b/admin.php index 51b5060..0596acc 100644 --- a/admin.php +++ b/admin.php @@ -211,6 +211,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST[' $slug = $_POST['slug']; $icon = $_POST['icon']; $description = $_POST['description']; + $show_in_header = isset($_POST["show_in_header"]) ? 1 : 0; $image_url = null; if ($id > 0) { @@ -232,11 +233,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST[' } if ($id > 0) { - $stmt = $db->prepare("UPDATE game_resources SET name = ?, slug = ?, icon = ?, description = ?, image_url = ? WHERE id = ?"); - $stmt->execute([$name, $slug, $icon, $description, $image_url, $id]); + $stmt = $db->prepare("UPDATE game_resources SET name = ?, slug = ?, icon = ?, description = ?, image_url = ?, show_in_header = ? WHERE id = ?"); + $stmt->execute([$name, $slug, $icon, $description, $image_url, $show_in_header, $id]); } else { - $stmt = $db->prepare("INSERT INTO game_resources (name, slug, icon, description, image_url) VALUES (?, ?, ?, ?, ?)"); - $stmt->execute([$name, $slug, $icon, $description, $image_url]); + $stmt = $db->prepare("INSERT INTO game_resources (name, slug, icon, description, image_url, show_in_header) VALUES (?, ?, ?, ?, ?, ?)"); + $stmt->execute([$name, $slug, $icon, $description, $image_url, $show_in_header]); } header("Location: admin.php?tab=resources&success=1"); @@ -791,13 +792,19 @@ if ($tab === 'users') { +
+ +
- + @@ -812,6 +819,13 @@ if ($tab === 'users') { +
VisuelNomSlugActions
VisuelNomSlugHeader?Actions
+ + + + + + Suppr @@ -1010,6 +1024,7 @@ if ($tab === 'users') { document.getElementById('res_slug').value = data.slug; document.getElementById('res_icon').value = data.icon || ''; document.getElementById('res_desc').value = data.description || ''; + document.getElementById('res_show').checked = (data.show_in_header == 1); window.scrollTo(0,0); } function resetResourceForm() { document.getElementById('resourceForm').reset(); document.getElementById('res_id').value = 0; } diff --git a/db/add_show_in_header_to_resources.php b/db/add_show_in_header_to_resources.php new file mode 100644 index 0000000..13631c5 --- /dev/null +++ b/db/add_show_in_header_to_resources.php @@ -0,0 +1,17 @@ +query("SHOW COLUMNS FROM game_resources LIKE 'show_in_header'")->fetchAll(); + if (empty($columns)) { + $db->exec("ALTER TABLE game_resources ADD COLUMN show_in_header TINYINT(1) DEFAULT 0"); + echo "Column 'show_in_header' added successfully to 'game_resources'.\n"; + } else { + echo "Column 'show_in_header' already exists.\n"; + } +} catch (PDOException $e) { + echo "Error: " . $e->getMessage() . "\n"; +} + diff --git a/index.php b/index.php index 26fa3e8..f8effc5 100644 --- a/index.php +++ b/index.php @@ -36,13 +36,8 @@ $factions_map = []; foreach($factions_db as $f) $factions_map[$f['id']] = $f; $grid_size = 36; // Mock Resources -$resources = [ - 'Metal' => ['val' => '136 053', 'max' => '1 210 000', 'prod' => '+1 980', 'icon' => 'fa-cube'], - 'Crystal' => ['val' => '127 322', 'max' => '1 010 000', 'prod' => '+1 703', 'icon' => 'fa-gem'], - 'Deuterium' => ['val' => '32 277', 'max' => '50 000', 'prod' => '+28', 'icon' => 'fa-flask'], - 'Energy' => ['val' => '2 100', 'max' => '2 100', 'prod' => '', 'icon' => 'fa-bolt'], - 'Dark Matter' => ['val' => '4 930', 'max' => '', 'prod' => '', 'icon' => 'fa-atom'] -]; +$header_resources = $db->query("SELECT * FROM game_resources WHERE show_in_header = 1 ORDER BY name ASC")->fetchAll(PDO::FETCH_ASSOC); +$resources = []; foreach($header_resources as $hr) { $resources[$hr["name"]] = ["val" => "0", "prod" => "", "icon" => $hr["icon"] ?: "fa-gem", "image" => $hr["image_url"]]; } if ($view === 'sector') { $stmt = $db->prepare("SELECT * FROM planets WHERE galaxy_id = ? AND sector_id = ? AND slot BETWEEN 1 AND ?"); @@ -437,7 +432,11 @@ function getStatusColor($status, $statuses_map) {
- + + ?v=" style="position: absolute; right: -15px; top: 5px; max-width: 25px; max-height: 25px; opacity: 0.6;"> + + "> +