Стоит phpbb 3 + danneo. На главной сайта хочу вывести название темы + текст первого сообщения (блок новости).
В общем все сделал, кроме вырезания bb кода.
Вот полный текст кода:
Код: Выделить всё
<?php
/* ==================================================== ##
## COPYRIGHTS © DANNEO PHP TEAM ##
## ==================================================== ##
## PRODUCT : CMS(CONTENT MANAGEMENT SYSTEM) ##
## LICENSE : GNU 2(General Public License v.2) ##
## TECHNOLOGIES : PHP & MySQL ##
## WWW : www.danneo.com | www.danneo.org ##
## E-MAIL : help@danneo.com ##
## ==================================================== */
if(!defined("DNREAD")) exit();
global $db,$conf,$api;
$forum_style = "prosilver"; //Cтиль форума
$limit = 5; //Количество последних сообщений
$forum_pref = "phpbb_"; //Префикс таблиц форума
$date_format = 1; // Формат даты (0 - дата без времени, 1 - дата с временем)
$only_forums = '25'; // выводить темы из форумов с данными ИД, разделять запятыми
$block_cont = "";
$block_cont.="<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">";
$inq = $db->query( "
SELECT t.forum_id, t.topic_id, t.topic_last_post_id, t.topic_title, t.topic_views, t.topic_replies, t.topic_last_post_time,
t.topic_last_poster_id, t.topic_last_poster_name, t.topic_poster, t.topic_first_poster_name, t.topic_last_post_subject, t.topic_time, t.topic_first_post_id, p.post_text, p.post_id
FROM ".$forum_pref."topics AS t , ".$forum_pref."posts AS p
WHERE t.forum_id in (" . $only_forums .") AND p.post_id = t.topic_first_post_id
ORDER BY topic_time DESC LIMIT 0, $limit");
while ($row = $db->fetchrow($inq)) {
if(strlen($row['topic_title']) > 100) {
$title_topic = "".substr($row['topic_title'], 0, 90)."...";
} else {
$title_topic = $row['topic_title'];
}
if(strlen($row['post_text']) > 260) {
$text_post = "".substr($row['post_text'], 0, 255)."...";
} else {
$text_post = $row['post_text'];
}
$textpop = preg_replace('/\[b\](.*?)\[\/b\]/is', '', $text_post);
$block_cont.="";
$block_cont.="<tr><td class=\"myforum\" align=\"left\" ><b>".$api->sitetime($row[topic_time],$date_format)." : ";
$block_cont.="<a href=\"".$conf['site_url']."/forum3/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]\" title=\"$row[topic_title]\">$title_topic</a></b></td></tr>";
$block_cont.="<tr><td><br>$textpop</td></tr>";
$block_cont.="<tr><td><br></td></tr>";
$block_cont.="<tr><td class=\"myforum\"><div style=\"float: left;\">Автор: <a href=\"".$conf['site_url']."/forum3/memberlist.php?mode=viewprofile&u=$row[topic_poster]\"> $row[topic_first_poster_name]</a>, Просмотров: $row[topic_views], <a href=\"".$conf['site_url']."/forum3/posting.php?mode=reply&f=$row[forum_id]&t=$row[topic_id]\" title=\"Нажмите, чтобы оставить свой комментарий\">Комментариев</a>: $row[topic_replies]<br></div><div align=\"right\"><a href=\"".$conf['site_url']."/forum3/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]\"><b>Прочесть</b></a></div></td></tr><tr><td><hr></td></tr>";
}
$block_cont.="<tr><td><a href=\"".$conf['site_url']."/forum3/posting.php?mode=post&f=$row[forum_id]\" title=\"Для добавления новостей необходима регистрация\">Добавить новость</a> / Архивные новости <a href=\"".$conf['site_url']."/forum3/viewtopic.php?f=$row[forum_id]\">здесь</a></td></tr>";
$block_cont.="</table>";
return $block_cont;
?>
Код: Выделить всё
$textpop = preg_replace('/\[b\](.*?)\[\/b\]/is', '', $text_post);

