Имам този код за изкарване на новини от форум изкарва целия текст от новината а аз искам примерно от сяка тема да изкарва по 200 синвола от текста ... или поне не целия и да има едно ОЩЕ ПО ТЕМАТА... на края или нещо такова
как да стане
Код:
<?php
$page=$_GET['page'];
if(!$_GET['page'])
{
$page="1";
}
$pp = "5"; //колко новини на страница
$forum = '16'; // от кой форум да чете новините
$limit = ($pp*$page)-$pp;
$broi_bukvi="5"; // do kolko bukvi v zaglaviqta na novinite да показва
$show = 'full'; // How to show the topics? full or blank ('')
$date_time = 'short'; // How to display the date and time if used? short or long
$topic_link = 'topic'; // How top display the topic link if usede? topic or phpbb
$comment = 'topic'; // Comments link - how to send them to comments? topic or reply
$phpbb_root_path = '../forum/'; // Path to your forums directory
#############################################
## No Editing unless you know what your doing
#############################################
if ( !defined('IN_PHPBB') )
{
define('IN_PHPBB', true);
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'config.'.$phpEx);
}
if ($show == '' || $show == 'full')
{
// Select the topic information from the correct forum and set it to $grab_topics
$grab = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}'");
$max=mysql_numrows($grab);
$total=ceil($max/$pp);
$grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' ORDER BY `topic_id` DESC LIMIT $limit,$pp");
}
else if ($show == 'topic')
{
$grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$_GET['t']}' ORDER BY `topic_id` DESC");
}
// Grab the information using an array and set it to $echo_topic
while ($echo_topic = $db->sql_fetchrow($grab_topics))
{
// Select the post information from the correct forum and set it to $grab_posts
$grab_posts = $db->sql_query("SELECT * FROM `{$table_prefix}posts` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$echo_topic['topic_id']}' ORDER BY `post_id` LIMIT 1");
// Grab the information using an array and set it to $echo_post
while ($echo_post = $db->sql_fetchrow($grab_posts))
{
// Now get the post_text using the post_id were looking at and sort it info $grab_posts_text
$grab_posts_text = $db->sql_query("SELECT * FROM `{$table_prefix}posts_text` WHERE `post_id` = '{$echo_post['post_id']}'");
// Grab the information using an array and set it to $echo_text
while($echo_text = $db->sql_fetchrow($grab_posts_text))
{
// Find the user the posted
$find_user = $db->sql_query("SELECT * FROM `{$table_prefix}users` WHERE `user_id` = '{$echo_post['poster_id']}'");
// Sort this users info into array for the post
while ($echo_user = $db->sql_fetchrow($find_user))
{
// Get rid of all those annoying characters from bbcode
$bbcode_uid = $echo_text['bbcode_uid'];
$echo_text = str_replace(":".$bbcode_uid,'',$echo_text);
$echo_text = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $echo_text);
$echo_text = str_replace("[b]","<strong>",$echo_text);
$echo_text = str_replace("[/b]","</strong>",$echo_text);
$echo_text = str_replace("[i]","<em>",$echo_text);
$echo_text = str_replace("[/i]","</em>",$echo_text);
$echo_text = str_replace("[center]","<center>",$echo_text);
$echo_text = str_replace("[/center]","</center>",$echo_text);
$echo_text = str_replace("[u]","<u>",$echo_text);
$echo_text = str_replace("[/u]","</u>",$echo_text);
$echo_text=preg_replace("/\[quote\=\"(.+?)\"](.+?)\[\/quote\]/s","<br /> <small><b>$1 написа:</b></small><table border=\"0\" width=\"100%\" class=\"table1\" bgcolor=\"#F9F9F9\" style=\"border-style: dotted; border-width: 2px; padding: 0\"><tr><td align=\"left\">$2</td></tr></table>",$echo_text);
$echo_text=preg_replace("/\[size\=(.+?)\](.+?)\[\/size\]/s","<font size=\"$1-5\">$2</font>",$echo_text);
$echo_text=preg_replace("/\[color\=(.+?)\](.+?)\[\/color\]/s","<font color=\"$1\">$2</font>",$echo_text);
$echo_text = str_replace("[quote]","<br /> <small><b>Цитат:</b></small><table border=\"0\" width=\"100%\" class=\"table1\" bgcolor=\"#F9F9F9\" style=\"border-style: dotted; border-width: 2px; padding: 0\"><tr><td align=\"left\">",$echo_text);
$echo_text = str_replace("[/quote]","</td></tr></table>",$echo_text);
$echo_text=preg_replace("/\[code\](.+?)\[\/code\]/s","<br /> <small><b>Код:</b></small><table border=\"0\" width=\"100%\" class=\"table1\" bgcolor=\"#F9F9F9\" style=\"border-style: dotted; border-width: 2px; padding: 0\"><tr><td align=\"left\">$1</td></tr></table>",$echo_text);
$echo_text=preg_replace("/\[code\](.+?)\[\/code\]/s","<small><b>Код:</b></small><table border=\"0\" width=\"0\" id=\"table1\" style=\"border-style: dotted; border-width: 2px; padding: 0\"><tr><td>$1</td></tr></table>",$echo_text);
$echo_text = str_replace("[img]","<img border=\"0\" src=\"",$echo_text);
$echo_text = str_replace("[/img]","\" alt=\"Rover Ровър Роувер Сервизи Магазини\" />",$echo_text);
$echo_text = preg_replace('/\[url\](.*)\[\/url\]/Usi','<a class="gensmall" target="_blank" href="$1">$1</a>',$echo_text);
$echo_text = preg_replace('/\[url=(.*)\](.*)\[\/url\]/Usi','<a class="gensmall" target="_blank" href="$1">$2</a>',$echo_text);
$echo_text = preg_replace('/\[list\](.*)\[\/list\]/si',"<center>$1</center>",$echo_text);
$echo_text = preg_replace('/\[list=(.*)\](.*)\[\/list\]/si',"<center>$1</center>",$echo_text);
$echo_text = str_replace("\n", "\n<br />\n", $echo_text);
// Way to display date and time? long
if($date_time == "long")
{
$echo_topic['topic_time'] = strftime("%A %e %B %H:%M",$echo_topic['topic_time']);
}
// short
if ($date_time == "short")
{
$echo_topic['topic_time'] = strftime("%d.%m.%Yг. %H:%M",$echo_topic['topic_time']);
}
// Way to display comment link
// Go right to the topic
if ($comment == 'topic')
{
$comment_link = "{$phpbb_root_path}viewtopic.php?t={$echo_topic['topic_id']}";
}
// This link goes to the actual phpbb topic
if ($topic_link == 'phpbb')
{
$topic_link = "{$phpbb_root_path}viewtopic.php?t={$echo_topic['topic_id']}";
}
##################################
## Edit for look and feel of topic
##################################
// Display just the title
if ($show != 'full' && !isset($_GET['show1']))
{
echo "<a href='{$topic_link}'><font color=\"#CCCCCCF\" >{$echo_text['post_subject']}</a><br /></font>";
}
// Display many topics - for news, shoutbox etc
else if ($show == 'full')
{
echo "
<table align=\"center\" bgcolor=\"#4D4D4D\" width=\"770\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td bgcolor=\"#333333\" width=\"770\" height=\"13\"></font><b><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\">[ Заглавие:</b></font><a href=\"{$comment_link}\" class='menu_link'><font face=\"Verdana\" color=\"#FFAAAA\" size=\"1\"> {$echo_text['post_subject']}</strong><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1.5\"> </font><b><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\">]</b></font></a></td>
</tr>
<tr>
<td height=\"14\"><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\">
{$echo_text['post_text']}
</front></td>
</tr>
<tr>
<td height=\"19\"><b><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\">[ написано от:</b></font><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\"> <strong> {$echo_user['username']}</strong><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1.5\"> </font><b><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\">]</b></font>
<b><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\">[ пуснато на: </b></font><strong>{$echo_topic['topic_time']}</strong> </font><b><font face=\"Verdana\" color=\"#CCCCCC\" size=\"1\">]</b></font>
<a href=\"{$comment_link}\" class='menu_link'> Коментари {$echo_topic['topic_replies']}</a><hr size=\"1\"></td>
</tr>
</table>
";
}
// Display the topic for when used with the one above, click link and go here
if ($_GET['show1'] == 'topic')
{
echo "
<strong><font color=\"#FFFFFF\" >{$echo_text['post_subject']}</font></strong>- <strong>{$echo_topic['topic_time']}</strong>
<br />
<br /><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#CCCCCC\" size=\"1\">
{$echo_text['post_text']}
</font>
<br />
<br />
написано от: <strong>{$echo_user['username']} </strong>
<a href=\"{$comment_link}\" target=\"_blank\">Comments {$echo_topic['topic_replies']}</a>
<hr size=\"1\">
";
}
}
}
}
}
?>