viewing paste Unknown #51567 | PHP

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
function HTFV_Change($topic = 0, $hide_topic = false)
{
        global $user_info, $smcFunc;
 
        // Abort if we are not supposed to be here!
        if (empty($user_info['id']) || empty($topic))
                fatal_lang_error('no_topic_id', false);
        
        // Get the board number that this topic resides in:
        $request = $smcFunc['db_query']('', '
                SELECT id_board
                FROM {db_prefix}topics
                WHERE id_topic IN ({int:id_topic})',
                array(
                        'id_topic' => $topic = (int) $topic,
                )
        );
        list($board) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);
 
        // Remove any existing entries for this topic:
        $smcFunc['db_query']('', '
                DELETE FROM {db_prefix}hide_topics
                WHERE id_member = {int:id_member}
                        AND id_topic = {int:id_topic}',
                array(
                        'id_member' => (int) $user_info['id'],
                        'id_topic' => (int) $topic,
                )
        );
 
        // Are we being requested to hide the specified topic?
        if ($hide_topic)
        {
                // Can't do anything if the board ID is empty, either....
                $user = (int) $user_info['id'];
                if (empty($board))
                        continue;
 
                // Insert the row into the hide_topics table:
                $smcFunc['db_insert']('insert',
                        '{db_prefix}hide_topics',
                        array('id_member' => 'int', 'id_topic' => 'int', 'id_board' => 'int'),
                        array($user, $topic, (int) $board),
                        array('id_member', 'id_topic', 'id_board')
                );
        }
 
        // Force recache of the hidden topics for this user, then go to the board:
        unset($_SESSION['hide_topics']);
        return $board;
}
Viewed 300 times, submitted by Guest.