sql_query($sql)) { error_die($db, QUERY_ERROR); } // // Add checking for private forums here!! // // If the query dosan't return any rows this isn't a valid forum. Inform the user. if(!$total_rows = $db->sql_numrows($result)) { error_die($db, "", "The forum you selected does not exist. Please go back and try again."); } $forum_row = $db->sql_fetchrowset($result); if(!$forum_row) { error_die($db, QUERY_ERROR); } $forum_name = stripslashes($forum_row[0]["forum_name"]); $topics_count = $forum_row[0]["forum_topics"]; for($x = 0; $x < $db->sql_numrows($result); $x++) { if($x > 0) $forum_moderators .= ", "; $forum_moderators .= "".$forum_row[$x]["username"].""; } include('includes/page_header.'.$phpEx); if(!isset($start)) { $start = 0; } $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time FROM " . TOPICS_TABLE ." t LEFT JOIN ". USERS_TABLE. " u ON t.topic_poster = u.user_id LEFT JOIN ".POSTS_TABLE." p ON p.post_id = t.topic_last_post_id LEFT JOIN " . USERS_TABLE . " u2 ON p.poster_id = u2.user_id WHERE t.forum_id = '$forum_id' ORDER BY topic_time DESC LIMIT $start, $topics_per_page"; if(!$t_result = $db->sql_query($sql)) { error_die($db, QUERY_ERROR); } $total_topics = $db->sql_numrows(); if($total_topics) { $topic_rowset = $db->sql_fetchrowset($t_result); for($x = 0; $x < $total_topics; $x++) { $topic_title = stripslashes($topic_rowset[$x]["topic_title"]); $topic_id = $topic_rowset[$x]["topic_id"]; $replies = $topic_rowset[$x]["topic_replies"]; if($replies > $posts_per_page) { $goto_page = "   ($l_gotopage: "; $times = 1; for($i = 0; $i < ($replies + 1); $i += $posts_per_page) { if($times > 4) { if(($i + $posts_per_page) >= ($replies + 1)) { $goto_page.=" ... $times"; } } else { if($times != 1) { $goto_page.= ", "; } $goto_page.= "$times"; } $times++; } $goto_page.= ")"; } else { $goto_page = ""; } $topic_poster = stripslashes($topic_rowset[$x]["username"]); $views = $topic_rowset[$x]["topic_views"]; $last_post_time = date($date_format, $topic_rowset[$x]["post_time"]); $last_post_user = $topic_rowset[$x]["user2"]; $folder_img = ""; $template->assign_block_vars("topicrow", array("FORUM_ID" => $forum_id, "POST_TOPIC_URL" => POST_TOPIC_URL, "TOPIC_ID" => $topic_id, "FOLDER" => $folder_img, "TOPIC_POSTER" => "".$topic_poster."", "GOTO_PAGE" => $goto_page, "REPLIES" => $replies, "TOPIC_TITLE" => $topic_title, "VIEWS" => $views, "LAST_POST" => $last_post_time . "
" . $last_post_user ."")); } $count = 1; $next = $start + $topics_per_page; if($topics_count > $topics_per_page) { if($next < $topics_count) { $pagination = "$l_nextpage | "; } for($x = 0; $x < $topics_count; $x++) { if(!($x % $topics_per_page)) { if($x == $start) { $pagination .= "$count"; } else { $pagination .= " $count "; } $count++; if(!($count % 20)) { $pagination .= "
"; } } } } $template->assign_vars(array("PAGINATION" => $pagination)); $template->pparse("body"); } else { error_die($db, NO_POSTS); } include('includes/page_tail.'.$phpEx); ?>