Code: Alles auswählen
function phpbb_fetch_announcements($forum_sql, $number_of_posts, $text_length)
{
global $db, $board_config;
$sql = 'SELECT
t.topic_id,
t.topic_time,
t.topic_title,
pt.post_text,
u.username,
u.user_id,
t.topic_replies,
pt.bbcode_uid,
t.forum_id,
t.topic_poster,
t.topic_first_post_id,
t.topic_status,
pt.post_id,
p.post_id,
p.enable_smilies
FROM
' . TOPICS_TABLE . ' AS t,
' . USERS_TABLE . ' AS u,
' . POSTS_TEXT_TABLE . ' AS pt,
' . POSTS_TABLE . ' AS p
WHERE
t.forum_id IN (' . $forum_sql . ') AND
t.topic_type = 2 AND
t.topic_time <= ' . time() . ' AND
t.topic_poster = u.user_id AND
t.topic_first_post_id = pt.post_id AND
t.topic_first_post_id = p.post_id AND
t.topic_status <> 2
ORDER BY
t.topic_time DESC';
if ($number_of_posts != 0)
{
$sql .= '
LIMIT
0,' . $number_of_posts;
}
//
// query the database
//
if(!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not query announcements information', '', __LINE__, __FILE__, $sql);
}
//
// fetch all postings
//
$posts = array();
if ($row = $db->sql_fetchrow($result))
{
$i = 0;
do
{
$posts[$i]['bbcode_uid'] = $row['bbcode_uid'];
$posts[$i]['enable_smilies'] = $row['enable_smilies'];
$posts[$i]['post_text'] = $row['post_text'];
$posts[$i]['topic_id'] = $row['topic_id'];
$posts[$i]['topic_replies'] = $row['topic_replies'];
$posts[$i]['topic_time'] = create_date($board_config['default_dateformat'], $row['topic_time'], $board_config['board_timezone']);
$posts[$i]['topic_title'] = $row['topic_title'];
$posts[$i]['user_id'] = $row['user_id'];
$posts[$i]['username'] = $row['username'];
//
// do a little magic
// note: part of this comes from mds' news script and some additional magics from Smartor
//
stripslashes($posts[$i]['post_text']);
if (($text_length == 0) or (strlen($posts[$i]['post_text']) <= $text_length))
{
$posts[$i]['post_text'] = bbencode_second_pass($posts[$i]['post_text'], $posts[$i]['bbcode_uid']);
$posts[$i]['striped'] = 0;
}
else // strip text for news
{
$posts[$i]['post_text'] = bbencode_strip($posts[$i]['post_text'], $posts[$i]['bbcode_uid']);
$posts[$i]['post_text'] = substr($posts[$i]['post_text'], 0, $text_length) . '...';
$posts[$i]['striped'] = 1;
}
//
// Smilies
//
if ($posts[$i]['enable_smilies'] == 1)
{
$posts[$i]['post_text'] = smilies_pass($posts[$i]['post_text']);
}
$posts[$i]['post_text'] = make_clickable($posts[$i]['post_text']);
//
// define censored word matches
//
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
//
// censor text and title
//
if (count($orig_word))
{
$posts[$i]['topic_title'] = preg_replace($orig_word, $replacement_word, $posts[$i]['topic_title']);
$posts[$i]['post_text'] = preg_replace($orig_word, $replacement_word, $posts[$i]['post_text']);
}
$posts[$i]['post_text'] = nl2br($posts[$i]['post_text']);
$i++;
}
while ($row = $db->sql_fetchrow($result));
}
//
// return the result
//
return $posts;
} // phpbb_fetch_announcements