0) { $postInfo = forum_post_find($postId); if (!empty($postInfo['target_topic_id'])) { $topicId = (int)$postInfo['target_topic_id']; } } $topic = forum_topic_fetch($topicId); $perms = $topic ? forum_perms_get_user(MSZ_FORUM_PERMS_GENERAL, $topic['forum_id'], user_session_current('user_id', 0)) : 0; if (user_warning_check_restriction(user_session_current('user_id', 0))) { $perms &= ~MSZ_FORUM_PERM_SET_WRITE; } if (!$topic || ($topic['topic_deleted'] !== null && !perms_check($perms, MSZ_FORUM_PERM_DELETE_TOPIC))) { echo render_error(404); return; } if (!perms_check($perms, MSZ_FORUM_PERM_VIEW_FORUM)) { echo render_error(403); return; } $topicPagination = pagination_create($topic['topic_post_count'], 10); if (isset($postInfo['preceeding_post_count'])) { $postsPage = floor($postInfo['preceeding_post_count'] / $topicPagination['range']) + 1; } $postsOffset = pagination_offset($topicPagination, $postsPage ?? pagination_param()); if (!pagination_is_valid_offset($postsOffset)) { echo render_error(404); return; } tpl_var('topic_perms', $perms); $posts = forum_post_listing( $topic['topic_id'], $postsOffset, $topicPagination['range'], perms_check($perms, MSZ_FORUM_PERM_DELETE_ANY_POST) ); if (!$posts) { echo render_error(404); return; } $canReply = empty($topic['topic_archived']) && empty($topic['topic_locked']) && empty($topic['topic_deleted']) && perms_check($perms, MSZ_FORUM_PERM_CREATE_POST); forum_topic_mark_read(user_session_current('user_id', 0), $topic['topic_id'], $topic['forum_id']); echo tpl_render('forum.topic', [ 'topic_breadcrumbs' => forum_get_breadcrumbs($topic['forum_id']), 'global_accent_colour' => forum_get_colour($topic['forum_id']), 'topic_info' => $topic, 'topic_posts' => $posts, 'can_reply' => $canReply, 'topic_pagination' => $topicPagination, ]);