function show_topic($db, $topic_id, $user_id, $limit = 25) { echo breadcrumb($db, $topic_id, 'P'); if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; } $start = ($page - 1) * $limit; if (isset($_SESSION['user_id'])) { echo topic_reply_bar($db, $topic_id, get_forum_id($db, $topic_id)); } $sql = 'SELECT SQL_CALC_FOUND_ROWS p.id, p.subject, p.body, p.date_posted, p.date_updated, u.name as author, u.id as author_id, u.signature as sig, c.post_count as postcount, p.forum_id as forum_id, f.forum_moderator as moderator, p.update_id, u2.name as updated_by FROM frm_forum f JOIN frm_posts p ON f.id = p.forum_id JOIN frm_users u ON u.id = p.author_id LEFT JOIN frm_users u2 ON u2.id = p.update_id LEFT JOIN frm_post_count c ON u.id = c.user_id WHERE p.topic_id = ' . $topic_id . ' OR p.id = ' . $topic_id . ' ORDER BY p.topic_id, p.date_posted LIMIT ' . $start . ', ' . $limit; $result = mysql_query($sql, $db) or die(mysql_error($db)); $page_links = paginate($db, $limit); if (mysql_num_rows($result) == 0) { $msg = "There are currently no posts. Would you " . "like to be the first person to create a thread?"; $title = "No Posts..."; $dest = "frm_compose.php?forumid=" . $forum_id; echo msg_box($msg, $title, $dest); } else { echo '<table style="width: 80%;">'; echo '<tr>'; echo '<th>Author</th>'; echo '<th style="width: 85%;">Post</th>'; echo '</tr>'; $rowclass = ''; while ($row = mysql_fetch_array($result)) { $lastupdate = ''; $editlink = ''; $dellink = ''; $replylink = ' '; $pcount = ''; $pdate = ''; $sig = ''; $body = $row['body']; if (isset($_SESSION['user_id'])) { $replylink = '<a href="frm_compose.php?forumid=' . $row['forum_id'] . '&topicid=' . $topic_id . '&reid=' . $row['id'] . '">REPLY</a> '; } else { $replylink = ''; } if ($row['update_id'] > 0) { $lastupdate = '<p>Last updated: ' . $row['date_updated'] . ' by ' . $row['updated_by'] . '</p>'; } if ($user_id == $row['author_id'] || $user_id == $row['moderator'] || isset($_SESSION['access_lvl']) && $_SESSION['access_lvl'] > 2) { $editlink = '<a href="frm_compose.php?a=edit&post=' . $row['id'] . '">EDIT</a> '; $dellink = '<a href="frm_transact_affirm.php?' . 'action=deletepost&id=' . $row['id'] . '">DELETE</a> '; } $pcount = '<br/>Posts: ' . ($row['postcount'] == '' ? 0 : $row['postcount']); $pdate = $row['date_posted']; $sig = ($row['sig'] != '' ? '<p class="sig">' . bbcode($db, nl2br($row['sig'])) : '') . '</p>'; $rowclass = $rowclass == 'odd_row' ? 'even_row' : 'odd_row'; echo '<tr class="' . $rowclass . '">'; echo '<td>' . $row['author']; echo $pcount; echo '</td><td><p>'; if (isset($_SESSION['user_id']) && $_SESSION['last_login'] < $row['date_posted']) { echo NEWPOST . ' '; } if (isset($_GET['page'])) { $pagelink = '&page=' . $_GET['page']; } else { $pagelink = ''; } echo '<a name="post' . $row['id'] . '" href="frm_view_topic.php?t=' . $topic_id . $pagelink . '#post' . $row['id'] . '">' . POSTLINK . '</a>'; if (isset($row['subject'])) { echo ' <strong>' . $row['subject'] . '</strong>'; } echo '</p><p>' . bbcode($db, nl2br(htmlspecialchars($body))) . '</p>'; echo $sig; echo $lastupdate; echo '</td>'; echo '</tr><tr class="' . $rowclass . '">'; echo '<td>' . $pdate . '</td>'; echo '<td style="text-align: right;">'; echo $replylink; echo $editlink; echo $dellink; echo '</td></tr>'; } echo '</table>'; echo $pagelink; echo '<p>' . NEWPOST . ' = New Post '; echo POSTLINK . ' = Post link (use to bookmark)</p>'; } }
t.forum_id = ' . $forumid . ' AND t.topic_id = 0 GROUP BY t.id ORDER BY re_posted DESC LIMIT ' . $start . ', ' . $limit; $result = mysql_query($sql, $db) or die(mysql_error($db)); $numrows = mysql_num_rows($result); if ($numrows == 0) { $msg = 'There are currently no posts. Would you like to be the first ' . 'person to create a thread?'; $title = 'Welcome to ' . $forum['name']; $dest = 'frm_compose.php?forumid=' . $forumid; echo msg_box($msg, $title, $dest); } else { if (isset($_SESSION['user_id'])) { echo topic_reply_bar($db, 0, $_GET['f']); } ?> <table style="width: 80%;"> <tr> <th style="width: 50%;">Thread</th> <th>Author</th> <th>Replies</th> <th>Last Post</th> </tr> <?php $rowclass = ''; while ($row = mysql_fetch_array($result)) { $rowclass = $rowclass == 'odd_row' ? 'even_row' : 'odd_row'; if ($row['re_posted'] == '') { $lastpost = $row['t_posted'];