query("SELECT * FROM servers LIMIT 10")->fetchAll(); $active_server_id = $_GET['server_id'] ?? ($servers[0]['id'] ?? 1); // Fetch channels $stmt = db()->prepare("SELECT * FROM channels WHERE server_id = ?"); $stmt->execute([$active_server_id]); $channels = $stmt->fetchAll(); $active_channel_id = $_GET['channel_id'] ?? ($channels[0]['id'] ?? 1); // Fetch messages $stmt = db()->prepare(" SELECT m.*, u.username, u.avatar_url FROM messages m JOIN users u ON m.user_id = u.id WHERE m.channel_id = ? ORDER BY m.created_at ASC LIMIT 50 "); $stmt->execute([$active_channel_id]); $messages = $stmt->fetchAll(); $current_channel_name = 'general'; foreach($channels as $c) if($c['id'] == $active_channel_id) $current_channel_name = $c['name']; // SEO & Env tags $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Discord-like messaging app built with PHP'; $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; ?>