prepare('SELECT Membership FROM users WHERE UserId = :userId LIMIT 1'); $stmt->bindParam(':userId', $userId, PDO::PARAM_INT); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); $membership = isset($row['Membership']) ? (int)$row['Membership'] : 0; } else { $membership = 0; } $isAdmin = 0; if (isset($_COOKIE['_ROBLOSECURITY'])) { $userInfo = getuserinfo($_COOKIE['_ROBLOSECURITY']); $currentPage = basename($_SERVER['PHP_SELF']); } $filter_forum_id = isset($_GET['ForumID']) ? (int)$_GET['ForumID'] : null; $sql = "SELECT f.id AS post_id, f.isPinned, f.Subject, f.UserId, f.Views, f.PostedAt, f.ForumId, u.Username FROM forums AS f LEFT JOIN users AS u ON f.UserId = u.UserId"; if ($filter_forum_id !== null) { $sql .= " WHERE f.ForumId = :forumId"; } $sql .= " ORDER BY f.isPinned DESC, f.PostedAt DESC"; $stmt = null; try { $stmt = $pdo->prepare($sql); if ($filter_forum_id !== null) { $stmt->bindParam(':forumId', $filter_forum_id, PDO::PARAM_INT); } $stmt->execute(); $posts = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { echo "Error fetching forum posts: " . $e->getMessage(); } finally { if (isset($stmt)) { $stmt->closeCursor(); } } $forumGroups = [ 1 => [ 46 => 'All Things Afterworld', 14 => 'Help (Technical Support and Account Issues)', 21 => 'Suggestions & Ideas', 54 => 'Game Nights & Afterworld events', ], 2 => [ 13 => 'Afterworld Talk', 18 => 'Off Topic', 32 => 'Clans & Guilds', 35 => "Let's Make a Deal", ], 9 => [ 62 => 'Game Marketing', 40 => 'Game Design', 33 => 'Scripters', ], 6 => [ 42 => 'Video Game Central', 52 => 'Video Creation with Afterworld', 26 => 'Ro-Sports', 24 => 'Pop-Culture (Music/Books/Movies/TV)', 23 => 'Role-Playing', ], ]; $forumId = isset($_GET['ForumID']) ? (int)$_GET['ForumID'] : 0; if (!isset($_COOKIE['_ROBLOSECURITY']) || !($userInfo = getuserinfo($_COOKIE['_ROBLOSECURITY'])) || !isset($userInfo['UserId'])) { die("You must be logged in to post."); } $UserId = (int)$userInfo['UserId']; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $title = trim($_POST['title'] ?? ''); $content = trim($_POST['content'] ?? ''); if ($forumId && $title !== '' && $content !== '') { $stmt = $pdo->prepare("INSERT INTO forums (UserId, ForumId, PostedAt, Closed, Subject, Message, isPinned, Views) VALUES (:UserId, :ForumId, :PostedAt, 0, :Subject, :Message, 0, 0)"); $stmt->execute([':UserId' => $UserId, ':ForumId' => $forumId, ':PostedAt' => time(), ':Subject' => $title, ':Message' => $content,]); $postId = $pdo->lastInsertId(); header("Location: /Forum/ShowPost.aspx?PostID=$postId"); exit; } else { echo "

Please fill in all fields.

"; } } ?> Afterworld - Forum