Пример #1
0
//-- fin mod : topic display order -----------------------------------------------------------------
if ($total_topics) {
    for ($i = 0; $i < $total_topics; $i++) {
        $topic_id = $topic_rowset[$i]['topic_id'];
        $topic_title = count($orig_word) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];
        //-- mod : post description ----------------------------------------------------
        //-- add
        $topic_sub_title = !empty($topic_rowset[$i]['topic_sub_title']) ? count($orig_word) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_sub_title']) : $topic_rowset[$i]['topic_sub_title'] : '';
        //-- fin mod : post description ------------------------------------------------
        //-- mod : quick title edition -------------------------------------------------
        //-- add
        $qte->attr($topic_title, $topic_rowset[$i]['topic_attribute']);
        //-- fin mod : quick title edition ---------------------------------------------
        $replies = $topic_rowset[$i]['topic_replies'];
        $topic_type = $topic_rowset[$i]['topic_type'];
        $topic_type = topic_type_lang($topic_type);
        if ($topic_rowset[$i]['topic_vote']) {
            $topic_type .= $lang['Topic_Poll'] . ' ';
        }
        if ($topic_rowset[$i]['topic_status'] == TOPIC_MOVED) {
            $topic_type = $lang['Topic_Moved'] . ' ';
            $topic_id = $topic_rowset[$i]['topic_moved_id'];
            $folder_image = $images['folder'];
            $folder_alt = $lang['Topics_Moved'];
            $newest_post_img = '';
        } else {
            if ($topic_rowset[$i]['topic_type'] == POST_GLOBAL_ANNOUNCE) {
                $folder = $images['folder_announce'];
                $folder_new = $images['folder_announce_new'];
            } else {
                if ($topic_rowset[$i]['topic_type'] == POST_ANNOUNCE) {
Пример #2
0
function get_related_topics($topic_id)
{
    global $board_config, $db, $lang, $template, $theme, $images, $phpEx;
    global $userdata, $HTTP_COOKIE_VARS;
    global $rcs, $qte;
    //
    // Fetch all words that appear in the title of $topic_id
    //
    $sql = 'SELECT m.word_id FROM ' . SEARCH_MATCH_TABLE . ' m, ' . TOPICS_TABLE . ' t
			WHERE m.post_id = t.topic_first_post_id
				AND t.topic_id = ' . intval($topic_id);
    if (!($result = $db->sql_query($sql, false, 'search_match_t' . intval($topic_id) . '_'))) {
        message_die(GENERAL_ERROR, 'Could not retrieve word matches', '', __LINE__, __FILE__, $sql);
    }
    $word_ids = array(0);
    while ($row = $db->sql_fetchrow($result)) {
        $word_ids[] = intval($row['word_id']);
    }
    $word_id_sql = implode(', ', $word_ids);
    //
    // Only search for related topics in the forums where the user has read access
    //
    $is_auth = array();
    $is_auth = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
    $forum_ids = array(0);
    while (list($forum_id, $forum_auth) = @each($is_auth)) {
        if ($forum_auth['auth_read']) {
            $forum_ids[] = $forum_id;
        }
    }
    $forum_id_sql = implode(', ', $forum_ids);
    $sql = 'SELECT DISTINCT(t.topic_id)
			FROM ' . SEARCH_MATCH_TABLE . ' m, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
			WHERE t.topic_id <> ' . intval($topic_id) . '
				AND t.topic_status <> ' . TOPIC_MOVED . '
				AND p.topic_id = t.topic_id
				AND p.post_id = m.post_id
				AND p.forum_id IN (' . $forum_id_sql . ')
				AND m.title_match = 1
				AND m.word_id IN (' . $word_id_sql . ')
			LIMIT 0, 5';
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not retrieve related topics information', '', __LINE__, __FILE__, $sql);
    }
    $topic_ids = array();
    while ($row = $db->sql_fetchrow($result)) {
        $topic_ids[] = $row['topic_id'];
    }
    $topic_id_sql = implode(', ', $topic_ids);
    //
    // No topics? Exit
    //
    if (count($topic_ids) == 0) {
        return;
    }
    //
    // Output to page
    //
    $template->set_filenames(array('related_topics' => 'viewtopic_related_body.tpl'));
    $template->assign_vars(array('L_RELATED_TOPICS' => $lang['Related_topics'], 'L_AUTHOR' => $lang['Author'], 'L_TOPICS' => $lang['Topics'], 'L_REPLIES' => $lang['Replies'], 'L_VIEWS' => $lang['Views'], 'L_LASTPOST' => $lang['Last_Post']));
    //
    // Define censored word matches
    //
    $orig_word = array();
    $replacement_word = array();
    obtain_word_list($orig_word, $replacement_word);
    //
    // Fetch all topic information
    //
    $sql = 'SELECT t.*,
				u.username, u.user_id, u.user_level, u.user_color, u.user_group_id,
				u2.username as user2, u2.user_id as id2, u2.user_level as level2, u2.user_color as color2, u2.user_group_id as group_id2,
				p.post_username,
				p2.post_username AS post_username2, p2.post_time
			FROM ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . POSTS_TABLE . ' p, ' . POSTS_TABLE . ' p2,
				' . USERS_TABLE . ' u2
			WHERE t.topic_id IN (' . $topic_id_sql . ')
				AND t.topic_poster = u.user_id
				AND p.post_id = t.topic_first_post_id
				AND p2.post_id = t.topic_last_post_id
				AND u2.user_id = p2.poster_id
			ORDER BY t.topic_type DESC, t.topic_last_post_id DESC';
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not retrieve topic information', '', __LINE__, __FILE__, $sql);
    }
    $topic_row = array();
    $topic_row = $db->sql_fetchrowset($result);
    $db->sql_freeresult($result);
    if (count($topic_row) == 0) {
        return;
    }
    $i = 0;
    foreach ($topic_row as $row) {
        $topic_id = $row['topic_id'];
        $forum_id = $row['forum_id'];
        $topic_title = $row['topic_title'];
        $qte->attr($topic_title, $row['topic_attribute']);
        if (count($orig_word)) {
            $topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
        }
        $replies = $row['topic_replies'];
        $views = $row['topic_views'];
        $topic_type = topic_type_lang($row['topic_type']);
        if ($row['topic_vote']) {
            $topic_type .= $lang['Topic_Poll'] . ' ';
        }
        if ($row['topic_type'] == POST_ANNOUNCE) {
            $folder = $images['folder_announce'];
            $folder_new = $images['folder_announce_new'];
        } else {
            if ($row['topic_type'] == POST_STICKY) {
                $folder = $images['folder_sticky'];
                $folder_new = $images['folder_sticky_new'];
            } else {
                if ($row['topic_status'] == TOPIC_LOCKED) {
                    $folder = $images['folder_locked'];
                    $folder_new = $images['folder_locked_new'];
                } else {
                    if ($replies >= $board_config['hot_threshold']) {
                        $folder = $images['folder_hot'];
                        $folder_new = $images['folder_hot_new'];
                    } else {
                        $folder = $images['folder'];
                        $folder_new = $images['folder_new'];
                    }
                }
            }
        }
        $newest_post_img = '';
        $folder_image = pic_for_topic($row);
        $topic_author = $row['user_id'] != ANONYMOUS ? '<a href="' . append_sid("profile.{$phpEx}?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $row['user_id']) . '">' : '';
        $topic_author .= $row['user_id'] != ANONYMOUS ? $rcs->get_colors($row, $row['username']) : ($row['post_username'] != '' ? $row['post_username'] : $lang['Guest']);
        $topic_author .= $row['user_id'] != ANONYMOUS ? '</a>' : '';
        $first_post_time = create_date($board_config['default_dateformat'], $row['topic_time'], $board_config['board_timezone']);
        $last_post_time = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);
        $last_post_author = $row['id2'] == ANONYMOUS ? $row['post_username2'] != '' ? $row['post_username2'] . ' ' : $lang['Guest'] . ' ' : '<a href="' . append_sid("profile.{$phpEx}?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $row['id2']) . '">' . $rcs->get_colors($row, $row['user2'], false, 'group_id2', 'color2', 'level2') . '</a>';
        $last_post_url = '<a href="' . append_sid("viewtopic.{$phpEx}?" . POST_POST_URL . '=' . $row['topic_last_post_id']) . '#' . $row['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" border="0" /></a>';
        $row_color = !($i % 2) ? $theme['td_color1'] : $theme['td_color2'];
        $row_class = !($i % 2) ? $theme['td_class1'] : $theme['td_class2'];
        $template->assign_block_vars('topicrow', array('ROW_COLOR' => '#' . $row_color, 'ROW_CLASS' => $row_class, 'L_TOPIC_FOLDER_ALT' => $folder_alt, 'U_VIEW_TOPIC' => append_sid("viewtopic.{$phpEx}?" . POST_TOPIC_URL . '=' . $row['topic_id']), 'TOPIC_FOLDER_IMG' => $folder_image, 'TOPIC_AUTHOR' => $topic_author, 'REPLIES' => $replies, 'NEWEST_POST_IMG' => $newest_post_img, 'TOPIC_TITLE' => $topic_title, 'TOPIC_TYPE' => $topic_type, 'VIEWS' => $views, 'LAST_POST_TIME' => $last_post_time, 'LAST_POST_AUTHOR' => $last_post_author, 'LAST_POST_IMG' => $last_post_url));
        $i++;
    }
    $template->assign_var_from_handle('RELATED_TOPICS', 'related_topics');
    return;
}
Пример #3
0
     // End Smilies Invasion Mod
     $template->assign_block_vars("searchresults", array('TOPIC_TITLE' => $topic_title, 'FORUM_NAME' => $searchset[$i]['forum_name'], 'POST_SUBJECT' => $post_subject, 'POST_DATE' => $post_date, 'POSTER_NAME' => $poster, 'TOPIC_REPLIES' => $searchset[$i]['topic_replies'], 'TOPIC_VIEWS' => $searchset[$i]['topic_views'], 'MESSAGE' => $message, 'MINI_POST_IMG' => $mini_post_img, 'L_MINI_POST_ALT' => $mini_post_alt, 'U_POST' => $post_url, 'U_TOPIC' => $topic_url, 'U_FORUM' => $forum_url));
     //-- mod : post description ----------------------------------------------------
     //-- add
     display_sub_title('searchresults', $post_sub_title, $board_config['sub_title_length']);
     //-- fin mod : post description ------------------------------------------------
 } else {
     $message = '';
     if (count($orig_word)) {
         $topic_title = preg_replace($orig_word, $replacement_word, $searchset[$i]['topic_title']);
     }
     //-- mod : post description ----------------------------------------------------
     //-- add
     $topic_sub_title = !empty($searchset[$i]['topic_sub_title']) ? count($orig_word) ? preg_replace($orig_word, $replacement_word, $searchset[$i]['topic_sub_title']) : $searchset[$i]['topic_sub_title'] : '';
     //-- fin mod : post description ------------------------------------------------
     $topic_type = topic_type_lang($searchset[$i]['topic_type']);
     if ($searchset[$i]['topic_vote']) {
         $topic_type .= $lang['Topic_Poll'] . ' ';
     }
     $views = $searchset[$i]['topic_views'];
     $replies = $searchset[$i]['topic_replies'];
     if ($replies + 1 > $board_config['posts_per_page']) {
         $total_pages = ceil(($replies + 1) / $board_config['posts_per_page']);
         $goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';
         $times = 1;
         for ($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page']) {
             $goto_page .= '<a href="' . append_sid("viewtopic.{$phpEx}?" . POST_TOPIC_URL . "=" . $topic_id . "&amp;start={$j}") . '">' . $times . '</a>';
             if ($times == 1 && $total_pages > 4) {
                 $goto_page .= ' ... ';
                 $times = $total_pages - 3;
                 $j += ($total_pages - 4) * $board_config['posts_per_page'];
Пример #4
0
     $folder_img = $images['folder_locked'];
     $folder_alt = $lang['Topic_locked'];
 } else {
     if ($row['topic_type'] == POST_ANNOUNCE) {
         $folder_img = $images['folder_announce'];
     } else {
         if ($row['topic_type'] == POST_STICKY) {
             $folder_img = $images['folder_sticky'];
         } else {
             $folder_img = $images['folder'];
         }
     }
     $folder_alt = topic_type_lang($row['topic_type']);
 }
 $topic_id = $row['topic_id'];
 $topic_type = topic_type_lang($row['topic_type'], $row['topic_status']);
 if ($row['topic_vote']) {
     $topic_type .= $lang['Topic_Poll'] . ' ';
 }
 $topic_title = $row['topic_title'];
 //-- mod : quick title edition -------------------------------------------------
 //-- add
 $qte->attr($topic_title, $row['topic_attribute']);
 //-- fin mod : quick title edition ---------------------------------------------
 if (count($orig_word)) {
     $topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
 }
 $u_view_topic = "modcp.{$phpEx}?mode=split&amp;" . POST_TOPIC_URL . "={$topic_id}&amp;sid=" . $userdata['session_id'];
 $topic_replies = $row['topic_replies'];
 //-- mod : rank color system ---------------------------------------------------
 //-- add