sql_query($sql)) { error_die(SQL_QUERY, "Couldn't obtain topic information.", __LINE__, __FILE__); } if(!$total_rows = $db->sql_numrows($result)) { error_die(GENERAL_ERROR, "The forum you selected does not exist. Please go back and try again."); } $forum_row = $db->sql_fetchrowset($result); $topic_title = $forum_row[0]['topic_title']; $forum_id = $forum_row[0]['forum_id']; $forum_name = stripslashes($forum_row[0]['forum_name']); // // Start session management // $userdata = session_pagestart($user_ip, $forum_id, $session_length); init_userprefs($userdata); // // End session management // for($x = 0; $x < $total_rows; $x++) { $moderators[] = array("user_id" => $forum_row[$x]['user_id'], "username" => $forum_row[$x]['username']); if($userdata['user_id'] == $forum_row[$x]['user_id']) { $is_moderator = 1; } } // // Add checking for private forums here // $total_replies = $forum_row[0]['topic_replies'] + 1; if(!isset($start)) { $start = 0; } $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, p.post_time, p.post_id, p.bbcode_uid, pt.post_text FROM ".POSTS_TABLE." p, ".USERS_TABLE." u, ".POSTS_TEXT_TABLE." pt WHERE p.topic_id = $topic_id AND p.poster_id = u.user_id AND p.post_id = pt.post_id ORDER BY p.post_time ASC LIMIT $start, ".$board_config['posts_per_page']; if(!$result = $db->sql_query($sql)) { error_die(SQL_QUERY, "Couldn't obtain post/user information.", __LINE__, __FILE__); } if(!$total_posts = $db->sql_numrows($result)) { error_die(GENERAL_ERROR, "There don't appear to be any posts for this topic.", __LINE__, __FILE__); } $sql = "SELECT * FROM ".RANKS_TABLE." ORDER BY rank_min"; if(!$ranks_result = $db->sql_query($sql)) { error_die(SQL_QUERY, "Couldn't obtain ranks information.", __LINE__, __FILE__); } $postrow = $db->sql_fetchrowset($result); $ranksrow = $db->sql_fetchrowset($ranksresult); // // Post, reply and other URL generation for // templating vars // $new_topic_url = append_sid("posting.".$phpEx."?mode=newtopic&".POST_FORUM_URL."=$forum_id"); $reply_topic_url = append_sid("posting.".$phpEx."?mode=reply&".POST_TOPIC_URL."=$topic_id"); $view_forum_url = append_sid("viewforum.".$phpEx."?".POST_FORUM_URL."=$forum_id"); $view_older_topic_url = append_sid("viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_id."&view=older"); $view_newer_topic_url = append_sid("viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_id."&view=newer"); $template->assign_vars(array( "U_POST_NEW_TOPIC" => $new_topic_url, "U_VIEW_FORUM" => $view_forum_url, "U_VIEW_OLDER_TOPIC" => $view_older_topic_url, "U_VIEW_NEWER_TOPIC" => $view_newer_topic_url, "U_POST_REPLY_TOPIC" => $reply_topic_url)); // // Dump out the page header // include('includes/page_header.'.$phpEx); // // Okay, let's do the loop, yeah come on baby let's do the loop // and it goes like this ... // for($x = 0; $x < $total_posts; $x++) { $poster = stripslashes($postrow[$x]['username']); $poster_id = $postrow[$x]['user_id']; $post_date = create_date($board_config['default_dateformat'], $postrow[$x]['post_time'], $board_config['default_timezone']); $poster_posts = $postrow[$x]['user_posts']; $poster_from = ($postrow[$x]['user_from']) ? "$l_from: ".$postrow[$x]['user_from'] : ""; $poster_joined = create_date($board_config['default_dateformat'], $postrow[$x]['user_regdate'], $board_config['default_timezone']); if($poster_id != ANONYMOUS && $poster_id != DELETED) { if(!$postrow[$x]['user_rank']) { for($i = 0; $i < count($ranksrow); $i++) { if($poster_posts > $ranksrow[$i]['rank_min'] && $poster_posts < $ranksrow[$i]['rank_max']) { $poster_rank = $ranksrow[$i]['rank_title']; $rank_image = ($ranksrow[$x]['rank_image']) ? "" : ""; } } } else { for($i = 0; $i < count($ranksrow); $i++) { if($postrow[$x]['user_rank'] == $ranksrow[$i]['rank_special']) { $poster_rank = $ranksrow[$i]['rank_title']; $rank_image = ($ranksrow[$x]['rank_image']) ? "" : ""; } } } } else { $poster_rank = ""; } $profile_img = "\"$l_profileof"; $email_img = ($postrow[$x]['user_viewemail'] == 1) ? "\"$l_email" : ""; $www_img = ($postrow[$x]['user_website']) ? "\"$l_viewsite\"" : ""; if($postrow[$x]['user_icq']) { $icq_status_img = "\"$l_icqstatus\""; $icq_add_img = "\"$l_icq\""; } else { $icq_status_img = ""; $icq_add_img = ""; } $aim_img = ($postrow[$x]['user_aim']) ? "" : ""; $msn_img = ($postrow[$x]['user_msnm']) ? "" : ""; $yim_img = ($postrow[$x]['user_yim']) ? "" : ""; $edit_img = "\"$l_editdelete\""; $quote_img = "\"$l_replyquote\""; $pmsg_img = "\"$l_sendpmsg\""; if($is_moderator) { $ip_img = "\"$l_viewip\""; $delpost_img = "\"$l_delete\""; } $message = stripslashes($postrow[$x]['post_text']); $bbcode_uid = $postrow[$x]['bbcode_uid']; $user_sig = stripslashes($postrow[$x]['user_sig']); if(!$board_config['allow_html']) { $user_sig = strip_tags($user_sig); $message = strip_tags($message); } if($board_config['allow_bbcode']) { // do bbcode stuff here $sig_uid = make_bbcode_uid(); $user_sig = bbencode_first_pass($user_sig, $sig_uid); $user_sig = bbencode_second_pass($user_sig, $sig_uid); $message = bbencode_second_pass($message, $bbcode_uid); } $message = make_clickable($message); $message = str_replace("\n", "
", $message); if(!($x % 2)) { $color = "#".$theme['td_color1']; } else { $color = "#".$theme['td_color2']; } $message = eregi_replace("\[addsig]$", "
_________________
" . nl2br($user_sig), $message); $template->assign_block_vars("postrow", array( "TOPIC_TITLE" => $topic_title, "POSTER_NAME" => $poster, "POSTER_RANK" => $poster_rank, "RANK_IMAGE" => $rank_image, "ROW_COLOR" => $color, "POSTER_JOINED" => $poster_joined, "POSTER_POSTS" => $poster_posts, "POSTER_FROM" => $poster_from, "POST_DATE" => $post_date, "MESSAGE" => $message, "PROFILE_IMG" => $profile_img, "EMAIL_IMG" => $email_img, "WWW_IMG" => $www_img, "ICQ_STATUS_IMG" => $icq_status_img, "ICQ_ADD_IMG" => $icq_add_img, "AIM_IMG" => $aim_img, "MSN_IMG" => $msn_img, "YIM_IMG" => $yim_img, "EDIT_IMG" => $edit_img, "QUOTE_IMG" => $quote_img, "PMSG_IMG" => $pmsg_img, "IP_IMG" => $ip_img, "DELPOST_IMG" => $delpost_img, "U_POST_ID" => "#".$postrow[$x]['post_id'])); } if($total_replies > $board_config['posts_per_page']) { $times = 0; for($x = 0; $x < $total_replies; $x += $board_config['posts_per_page']) { $times++; } $pages = $times . " $l_pages"; } else { $pages = "1 $l_page"; } $template->assign_vars(array( "PAGES" => $pages, "PAGINATION" => generate_pagination("viewtopic.$phpEx?".POST_TOPIC_URL."=$topic_id", $total_replies, $board_config['posts_per_page'], $start))); $template->pparse("body"); include('includes/page_tail.'.$phpEx); ?>