prepare("SELECT role FROM users WHERE id = ?"); $stmt->execute([$_SESSION['user_id']]); $u_data = $stmt->fetch(); $user_role = $u_data['role'] ?? 'user'; } $view = isset($_GET['view']) ? $_GET['view'] : 'sector'; $galaxy_id = isset($_GET['galaxy_id']) ? (int)$_GET['galaxy_id'] : 1; $sector_id = isset($_GET['sector_id']) ? (int)$_GET['sector_id'] : 1; // Fetch Dynamic Types and Statuses $object_types_db = $db->query("SELECT * FROM celestial_object_types")->fetchAll(PDO::FETCH_ASSOC); $statuses_db = $db->query("SELECT * FROM celestial_object_statuses")->fetchAll(PDO::FETCH_ASSOC); $object_types_map = []; foreach($object_types_db as $ot) $object_types_map[$ot['slug']] = $ot; $statuses_map = []; foreach($statuses_db as $s) $statuses_map[$s['slug']] = $s; // Grid size: 6x6 = 36 slots per sector $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'] ]; if ($view === 'sector') { $stmt = $db->prepare("SELECT p.*, c.name as city_name, c.type as city_type FROM planets p LEFT JOIN cities c ON p.id = c.planet_id WHERE p.galaxy_id = ? AND p.sector_id = ? AND p.slot BETWEEN 1 AND ?"); $stmt->execute([$galaxy_id, $sector_id, $grid_size]); $objects_raw = $stmt->fetchAll(); $grid = array_fill(1, $grid_size, null); foreach ($objects_raw as $obj) { $grid[$obj['slot']] = $obj; } $stmt = $db->prepare("SELECT name FROM sectors WHERE id = ?"); $stmt->execute([$sector_id]); $sector_info = $stmt->fetch(); $sector_display_name = $sector_info['name'] ?? "Secteur $sector_id"; $page_title = "$sector_display_name [G$galaxy_id]"; } else { $stmt = $db->prepare("SELECT sector_id, slot, status, type FROM planets WHERE galaxy_id = ? ORDER BY sector_id, slot ASC"); $stmt->execute([$galaxy_id]); $all_planets = $stmt->fetchAll(); $sector_data = []; $active_sectors = []; foreach ($all_planets as $p) { $sector_data[$p['sector_id']][$p['slot']] = ['status' => $p['status'], 'type' => $p['type']]; if (!in_array($p['sector_id'], $active_sectors)) { $active_sectors[] = (int)$p['sector_id']; } } $page_title = "Galaxie $galaxy_id"; } function getStatusColor($status, $statuses_map) { return $statuses_map[$status]['color'] ?? 'rgba(255,255,255,0.05)'; } ?> <?php echo $page_title; ?>
$res): ?>