/**********|| Page to show individual forums || ********************************\ Things to expect in $_GET: ForumID: ID of the forum curently being browsed page: The page the user's on. page = 1 is the same as no page ********************************************************************************/ //---------- Things to sort out before it can start printing/generating content // Check for lame SQL injection attempts $ForumID = $_GET['forumid']; if(!is_number($ForumID)) { error(0); } if (isset($LoggedUser['PostsPerPage'])) { $PerPage = $LoggedUser['PostsPerPage']; } else { $PerPage = POSTS_PER_PAGE; } list($Page,$Limit) = page_limit(TOPICS_PER_PAGE); //---------- Get some data to start processing // Caching anything beyond the first page of any given forum is just wasting ram // users are more likely to search then to browse to page 2 if($Page==1) { list($Forum,,,$Stickies) = $Cache->get_value('forums_'.$ForumID); } if(!isset($Forum) || !is_array($Forum)) { $DB->query("SELECT t.ID, t.Title, t.AuthorID, author.Username AS AuthorUsername, t.IsLocked, t.IsSticky, t.NumPosts, t.LastPostID, t.LastPostTime, t.LastPostAuthorID, last_author.Username AS LastPostUsername FROM forums_topics AS t LEFT JOIN users_main AS last_author ON last_author.ID = t.LastPostAuthorID LEFT JOIN users_main AS author ON author.ID = t.AuthorID WHERE t.ForumID = '$ForumID' ORDER BY t.IsSticky DESC, t.LastPostTime DESC LIMIT $Limit"); // Can be cached until someone makes a new post $Forum = $DB->to_array('ID',MYSQLI_ASSOC); if($Page==1) { $DB->query("SELECT COUNT(ID) FROM forums_topics WHERE ForumID='$ForumID' AND IsSticky='1'"); list($Stickies) = $DB->next_record(); $Cache->cache_value('forums_'.$ForumID, array($Forum,'',0,$Stickies), 0); } } if(!isset($Forums[$ForumID])) { error(404); } // Make sure they're allowed to look at the page if (!check_perms('site_moderate_forums')) { if (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] === 0) { error(403); } } if($LoggedUser['CustomForums'][$ForumID] != 1 && $Forums[$ForumID]['MinClassRead'] > $LoggedUser['Class']) { error(403); } // Start printing show_header('Forums > '. $Forums[$ForumID]['Name']); ?>
Latest | Replies | Author | |
No threads to display in this forum! | |||
$TopicLength=75-(2*count($PageLinks)); unset($PageLinks); ?> =display_str(cut_string($Title, $TopicLength)) ?> =$PagesText?> if(!empty($LastRead[$TopicID])) { ?> } ?> by =format_username($LastAuthorID, $LastAuthorName)?> =time_diff($LastTime,1)?> | =number_format($PostCount-1)?> | =format_username($AuthorID, $AuthorName)?> |