示例#1
0
                $sql = 'SELECT COUNT(post_id) AS number_items_total
					FROM ' . POSTS_TABLE . '
					WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
                break;
            case 'topic_posts':
                $sql = 'SELECT topic_replies AS number_items_total
					FROM ' . TOPICS_TABLE . '
					WHERE topic_id = ' . $topic_id;
                break;
            case 'topics':
                $sql = 'SELECT COUNT(topic_id) AS number_items_total
					FROM ' . TOPICS_TABLE . '
					WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
                break;
            case 'pm':
                $folder = convert_pm_folder_value($folder);
                $sql = 'SELECT pm_count AS number_items_total
					FROM ' . PRIVMSGS_FOLDER_TABLE . "\n\t\t\t\t\tWHERE folder_id = {$folder}\n\t\t\t\t\t\tAND user_id = " . (int) $user->data['user_id'];
                break;
        }
        $result = $db->sql_query($sql, $config['syndication_ttl']);
        $number_items_total = $db->sql_fetchfield('number_items_total', 0, $result);
        $db->sql_freeresult($result);
        if ($number_items_total > $number_items_current) {
            get_content_data($content, $feed_data, $number_items_current, $number_items);
            $cache->feed_save($feed_data, $feed_identifier, $config['syndication_ttl']);
        }
    } else {
        if ($number_items_current > $number_items) {
            $content_items = array();
            for ($i = 0; $i < $number_items; $i++) {
示例#2
0
/**
* get actual data about topics or posts
*/
function get_content_data($content, &$feed_data, $start, $end)
{
    global $global, $number_items, $board_url, $config, $phpEx, $db;
    switch ($content) {
        case 'posts':
        case 'topic_posts':
            if ($content == 'posts') {
                global $forum_ids;
                $where_sql = $db->sql_in_set('forum_id', $forum_ids);
            } else {
                global $topic_id;
                $where_sql = 'topic_id = ' . $topic_id;
            }
            $sql = 'SELECT topic_id, forum_id, post_id, post_text, post_username, post_time, post_subject, bbcode_bitfield, bbcode_uid, enable_bbcode, enable_smilies, enable_magic_url, username
				FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u\n\t\t\t\tWHERE {$where_sql}\n\t\t\t\t\tAND p.poster_id = u.user_id\n\t\t\t\t\tAND post_approved = 1\n\t\t\t\tORDER BY post_time DESC";
            $result = $db->sql_query_limit($sql, $end, $start, $config['syndication_ttl']);
            while ($row = $db->sql_fetchrow($result)) {
                $link = "{$board_url}/viewtopic.{$phpEx}?f={$row['forum_id']}&amp;p={$row['post_id']}#p{$row['post_id']}";
                $feed_data['items'][] = array('author' => !empty($row['post_username']) ? $row['post_username'] : $row['username'], 'time' => $row['post_time'], 'link' => $link, 'identifier' => $link, 'title' => $row['post_subject'], 'text' => array($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['enable_bbcode'], $row['enable_smilies'], $row['enable_magic_url']));
            }
            $db->sql_freeresult($result);
            break;
        case 'topics':
            global $forum_ids;
            $sql = 'SELECT t.topic_id, t.forum_id, topic_title, topic_first_poster_name, topic_time, post_text, bbcode_uid, bbcode_bitfield, enable_bbcode, enable_smilies, enable_magic_url
				FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
				WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . '
					AND p.post_id = t.topic_first_post_id
					AND p.post_approved = 1
					AND t.topic_approved = 1
					AND t.topic_moved_id = 0
				ORDER BY post_time DESC';
            $result = $db->sql_query_limit($sql, $end, $start, $config['syndication_ttl']);
            while ($row = $db->sql_fetchrow($result)) {
                $link = "{$board_url}/viewtopic.{$phpEx}?f={$row['forum_id']}&amp;t={$row['topic_id']}";
                $feed_data['items'][] = array('author' => $row['topic_first_poster_name'], 'time' => $row['topic_time'], 'link' => $link, 'identifier' => $link, 'title' => $row['topic_title'], 'text' => array($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['enable_bbcode'], $row['enable_smilies'], $row['enable_magic_url']));
            }
            $db->sql_freeresult($result);
            break;
        case 'pm':
            global $user, $folder;
            // convert to corresponding integer value
            $folder = convert_pm_folder_value($folder);
            $sql = 'SELECT p.msg_id, message_text, p.author_id, message_time, message_subject, bbcode_bitfield, bbcode_uid, enable_bbcode, enable_smilies, enable_magic_url, u.username
				FROM ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TO_TABLE . ' t, ' . USERS_TABLE . ' u
				WHERE p.author_id = u.user_id
					AND u.user_id = ' . (int) $user->data['user_id'] . "\n\t\t\t\t\tAND t.msg_id = p.msg_id\n\t\t\t\t\tAND t.folder_id = {$folder}\n\t\t\t\tORDER BY message_time DESC";
            $result = $db->sql_query_limit($sql, $end, $start, $config['syndication_ttl']);
            while ($row = $db->sql_fetchrow($result)) {
                $link = "{$board_url}/ucp.{$phpEx}?i=pm&amp;mode=view&amp;f={$folder}&amp;p={$row['msg_id']}";
                $feed_data['items'][] = array('author' => $row['username'], 'time' => $row['message_time'], 'link' => $link, 'identifier' => $link, 'title' => $row['message_subject'], 'text' => array($row['message_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['enable_bbcode'], $row['enable_smilies'], $row['enable_magic_url']));
            }
            $db->sql_freeresult($result);
            break;
    }
    // running generate_text_for_display within a database loop always crashes, so do it seperately. Although this is not the way I like it...
    for ($i = 0; $i < ($size = sizeof($feed_data['items'])); $i++) {
        $current_item = $feed_data['items'][$i]['text'];
        $feed_data['items'][$i]['text'] = parse_message($current_item[0], $current_item[1], $current_item[2], $current_item[3], $current_item[4], $current_item[5]);
    }
}