<?
    $_back 
= isset($_GET['b']) ? str_replace('@''&'trim(strval($_GET['b']))) : '';
    
$_id = isset($_GET['i']) ? trim($_GET['i']) : '';
    
    
$community mysql_query("SELECT * FROM community_threads, community_forums, community_sections, community WHERE community_threads.thread_id = " sq($_id) . " AND community_threads.forum_id = community_forums.forum_id AND community_forums.section_id = community_sections.section_id AND community_sections.community_id = community.community_id");
    if (!
$community_row mysql_fetch_assoc($community))    
    {
        
header('Location: ./?s=communities');
        die;        
    }

    require_once(
'include/functions/community_banned.php');
    
community_banned($community_row['community_id']);
    require_once(
'include/functions/community_permissions.php');    
    
community_permissions($community_row['community_id'], $community_row['section_id'], $community_row['forum_id']);

    if (!
$GLOBALS['auth']['community']['thread_sticky'])
    {
        
make_cookie('notice''You do not have access to un/sticky a thread in this forum.');
        
header('Location: ./?s=community_thread&i=' $community_row['thread_id']);
        die;
    }

    
$sticky false;
    if (isset(
$_GET['stick']))
    {
        
$sticky 1;
    }
    elseif (isset(
$_GET['unstick']))
    {
        
$sticky 0;
    }
    if (
$sticky !== false)
    {
        
mysql_query("UPDATE community_threads SET thread_sticky = '" $sticky "' WHERE thread_id = '" $community_row['thread_id'] . "'");
    }

    
header('Location: ./?' . ($_back $_back 's=community_thread&i=' $community_row['thread_id']));
?>