<?
    $_id 
= isset($_GET['i']) ? trim($_GET['i']) : '';

    
$community mysql_query("SELECT * FROM community WHERE community_id = " sq($_id));
    if (!
$community_row mysql_fetch_assoc($community))    
    {
        
header('Location: ./?s=communities');
        die;        
    }
    
    
$community_sections mysql_query("SELECT * FROM community_sections WHERE community_id = '" $community_row['community_id'] . "' AND section_deleted = '0'");
    while (
$community_sections_row mysql_fetch_assoc($community_sections))
    {
        
$community_forums mysql_query("SELECT * FROM community_forums WHERE section_id = '" $community_sections_row['section_id'] . "' AND forum_deleted = '0'");
        while (
$community_forums_row mysql_fetch_assoc($community_forums))
        {
            
$community_threads mysql_query("SELECT * FROM community_threads WHERE forum_id = '" $community_forums_row['forum_id'] . "' ORDER BY thread_sticky DESC, thread_last_posted_on DESC LIMIT 0, " COMMUNITY_THREADS_PER_PAGE 2);
            while (
$community_threads_row mysql_fetch_assoc($community_threads))
            {
                
//if ($community_threads_row['thread_sticky'] == 0)
                //{
                    
mysql_query("REPLACE INTO community_threads_pointers SET thread_id = '" $community_threads_row['thread_id'] . "', user_id = '" $GLOBALS['auth']['id'] . "', message_id = '" $community_threads_row['thread_last_message_id'] . "'");
                
//}
            
}
        }
    }
        
    
header('Location: ./?s=community&i=' $community_row['community_id']);
    die;
?>