Code: Selecteer alles
<?php
/***************************************************************************
* fetchposts.php
* -------------------
* begin : Dinsdag, 13 Augustus, 2002
* copyright : (C) 2002 Smartor
* e-mail : smartor_xp@hotmail.com
* vertaling : Admiral Rob
* e-mail : admiralrob@phpbb-nl.com
* origineel werk : Volker Rattel <ca5ey@clanunity.net>
*
* $Id: fetchposts.php,v 2.0.0 2002/9/20, 18:10:04 Smartor Exp $
*
*
***************************************************************************/
/***************************************************************************
*
* Dit programma is gratis software; je kunt het verdelenen/of aanpassen
* onder de regels van de GNU General Public License zoals gemaakt door
* de Free Software Foundation; of versie 2 van de lecentie of
* (bij Uw optie) elke latere versie.
*
***************************************************************************/
/***************************************************************************
*
* Bijna alle codes in dit bestand heb ik geleend van de phpBB Fetch Posts mod en dan
* aangepast om aan mijn benodigdheden te voldoen... Met dank aan Ca5ey voor de geweldige mod :)
*
***************************************************************************/
if ( !defined('IN_PHPBB') )
{
die("Hacking attempt");
}
error_reporting(E_ERROR | E_WARNING | E_PARSE);
set_magic_quotes_runtime(0);
include_once($phpbb_root_path . 'includes/bbcode.'.$phpEx);
function phpbb_fetch_posts($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_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;
}
//
// doorzoek de database
//
if(!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not query announcements information', '', __LINE__, __FILE__, $sql);
}
//
// haal alle posts op
//
$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'];
//
// doe een beetje magie
// pas op: een deel van dit komt van mds' nieuws script and sommige andere magie van 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 tekst voor nieuws
{
$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']);
//
// stel gecensueerde woorden match in
//
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
//
// censueer de tekst en titel
//
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));
}
//
// terug naar het resultaat
//
return $posts;
} // phpbb_fetch_posts
function phpbb_fetch_poll($forum_sql)
{
global $db;
$sql = 'SELECT
t.*,
vd.*
FROM
' . TOPICS_TABLE . ' AS t,
' . VOTE_DESC_TABLE . ' AS vd
WHERE
t.forum_id IN (' . $forum_sql . ') AND
t.topic_status <> 1 AND
t.topic_status <> 2 AND
t.topic_vote = 1 AND
t.topic_id = vd.topic_id
ORDER BY
t.topic_time DESC
LIMIT
0,1';
if (!$query = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query poll information', '', __LINE__, __FILE__, $sql);
}
$result = $db->sql_fetchrow($query);
if ($result)
{
$sql = 'SELECT
*
FROM
' . VOTE_RESULTS_TABLE . '
WHERE
vote_id = ' . $result['vote_id'] . '
ORDER BY
vote_option_id';
if (!$query = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query vote result information', '', __LINE__, __FILE__, $sql);
}
while ($row = $db->sql_fetchrow($query))
{
$result['options'][] = $row;
}
}
return $result;
} // end func phpbb_fetch_poll
//
// Functie strip alle BBcodes (geleend van Mouse Hove Topic Preview mod)
//
function bbencode_strip($text, $uid)
{
// Markeer het zodat we het versil tussen FALSE en het matchen van de eerste char (index 0).
// Dit is belangrijk; bbencode_quote(), bbencode_list(), en bbencode_code() hangen er vanaf.
$text = " " . $text;
// Als eerste: Als dit geen a "[" en a "]" is in het bericht, laat maar.
if (! (strpos($text, "[") && strpos($text, "]")) )
{
// verwijder padding, keer terug.
$text = substr($text, 1);
return $text;
}
$text = str_replace("[code:1:$uid]","", $text);
$text = str_replace("[/code:1:$uid]", "", $text);
$text = str_replace("[code:$uid]", "", $text);
$text = str_replace("[/code:$uid]", "", $text);
$text = str_replace("[quote:1:$uid]","", $text);
$text = str_replace("[/quote:1:$uid]", "", $text);
$text = str_replace("[quote:$uid]", "", $text);
$text = str_replace("[/quote:$uid]", "", $text);
// Een nieuwe regel om af te handelen met het openen van quotes met gebruikersnamen
// Vervang de 2 lijnen versie die ik hiervoor had..
$text = preg_replace("/\[quote:$uid=(?:\"?([^\"]*)\"?)\]/si", "", $text);
$text = preg_replace("/\[quote:1:$uid=(?:\"?([^\"]*)\"?)\]/si", "", $text);
// [list] en [list=x] voor (niet) geordende lijsten.
// niet geordende lijst
$text = str_replace("[list:$uid]", "", $text);
// li tags
$text = str_replace("[*:$uid]", "", $text);
// beeindigen tags
$text = str_replace("[/list:u:$uid]", "", $text);
$text = str_replace("[/list:o:$uid]", "", $text);
// geordende lijsten
$text = preg_replace("/\[list=([a1]):$uid\]/si", "", $text);
// kleuren
$text = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+):$uid\]/si", "", $text);
$text = str_replace("[/color:$uid]", "", $text);
// url #2
$text = str_replace("[url]","", $text);
$text = str_replace("[/url]", "", $text);
// url /\[url=([a-z0-9\-\.,\?!%\*_\/:;~\\&$@\/=\+]+)\](.*?)\[/url\]/si
$text = preg_replace("/\[url=([a-z0-9\-\.,\?!%\*_\/:;~\\&$@\/=\+]+)\]/si", "", $text);
$text = str_replace("[/url:$uid]", "", $text);
// plaatje
$text = str_replace("[img:$uid]","", $text);
$text = str_replace("[/img:$uid]", "", $text);
// email
$text = str_replace("[email:$uid]","", $text);
$text = str_replace("[/email:$uid]", "", $text);
// grootte
$text = preg_replace("/\[size=([\-\+]?[1-2]?[0-9]):$uid\]/si", "", $text);
$text = str_replace("[/size:$uid]", "", $text);
// uitlijning
$text = preg_replace("/\[align=(left|right|center|justify):$uid\]/si", "", $text);
$text = str_replace("[/align:$uid]", "", $text);
// [b] en [/b] voor het dik maken van tekst.
$text = str_replace("[b:$uid]","", $text);
$text = str_replace("[/b:$uid]", "", $text);
// [u] en [/u] voor het onderstrepen van tekst.
$text = str_replace("[u:$uid]", "", $text);
$text = str_replace("[/u:$uid]", "", $text);
// [i] en [/i] voor het cursief zetten van tekst.
$text = str_replace("[i:$uid]", "", $text);
$text = str_replace("[/i:$uid]", "", $text);
// Verwijder onze padding van het string..
$text = substr($text, 1);
return $text;
}
?>