PDA

View Full Version : переделка блока вывода новостей


Episod
26.03.2006, 19:03
Нашел я очень красивый блок вывода последних сообщений с форума !
Пытался его переделать в блок вывода последних новостей,но ничего не получилось...
Может кто возьмется переделать ?
Было бы не плохо если бы еще и по темам разделял..
Вот код :
<?php
global $prefix, $dbi, $sitename, $bgcolor1, $bgcolor2;
$HideViewReadOnly = 1;
$Last_New_Topics = 15;
$border = 1;
$cellspacing = 1;
$result = sql_query( "SELECT * FROM ".$prefix."_bbtopics", $dbi );
$Amount_Of_Topics = sql_num_rows( $result );
$result = sql_query( "SELECT * FROM ".$prefix."_bbposts", $dbi );
$Amount_Of_Posts = sql_num_rows( $result );
$Amount_Of_Topic_Views = 0;
$result = sql_query( "SELECT topic_views FROM ".$prefix."_bbtopics", $dbi );
while( list( $topic_views ) = sql_fetch_row( $result, $dbi ) )
{
$Amount_Of_Topic_Views = $Amount_Of_Topic_Views + $topic_views;
}
$Amount_Of_Topic_Replies = 0;
$result = sql_query( "SELECT topic_replies FROM ".$prefix."_bbtopics", $dbi );
while( list( $topic_replies ) = sql_fetch_row( $result, $dbi ) )
{
$Amount_Of_Topic_Replies = $Amount_Of_Topic_Replies + $topic_replies;
}
$result = sql_query( "SELECT * FROM ".$prefix."_users", $dbi );
$Amount_Of_Members = sql_num_rows( $result );
$Count_Topics = 0;
$Topic_Buffer = "";
$result1 = sql_query( "SELECT topic_id, forum_id, topic_last_post_id, topic_title, topic_poster, topic_views, topic_replies, topic_moved_id FROM ".$prefix."_bbtopics ORDER BY topic_last_post_id DESC", $dbi );
while( list( $topic_id, $forum_id, $topic_last_post_id, $topic_title, $topic_poster, $topic_views, $topic_replies, $topic_moved_id ) = sql_fetch_row( $result1, $dbi ) )
{
$skip_display = 0;
if( $HideViewReadOnly == 1 )
{
$result5 = sql_query( "SELECT auth_view, auth_read FROM ".$prefix."_bbforums where forum_id = '$forum_id'", $dbi );
list( $auth_view, $auth_read ) = sql_fetch_row( $result5, $dbi );
if( ( $auth_view != 0 ) or ( $auth_read != 0 ) ) { $skip_display = 1; }
}
if( $topic_moved_id != 0 )
{
$skip_display = 1;
}
if( $skip_display == 0 )
{
$Count_Topics += 1;
$result2 = sql_query( "SELECT topic_id, poster_id, FROM_UNIXTIME( post_time,'%d/%m/%Y') as post_time FROM ".$prefix."_bbposts where post_id = '$topic_last_post_id'", $dbi );
list( $topic_id, $poster_id, $post_time ) = sql_fetch_row( $result2, $dbi );
$result3 = sql_query( "SELECT username, user_id FROM ".$prefix."_users where user_id='$poster_id'", $dbi );
list( $username, $user_id ) = sql_fetch_row( $result3, $dbi );
$LastPoster = "<A class=block2 HREF=\"modules.php?name=Forums&file=profile&mode=viewprofile&u=$user_id\"STYLE=\"text-decoration: none\"> $username </a>";
$result4 = sql_query( "SELECT username, user_id FROM ".$prefix."_users where user_id='$topic_poster'", $dbi );
list( $username, $user_id ) = sql_fetch_row( $result4, $dbi );
$OrigPoster = "<A class=block2 HREF=\"modules.php?name=Forums&file=profile&mode=viewprofile&u=$user_id\"STYLE=\"text-decoration: none\"> $username </a>";
$TopicTitleShow = "<a CLASS=block2 href=\"modules.php?name=Forums&amp;file=viewtopic&amp;p=$topic_last_post_id#$topic_last_post_id\"STYLE=\"text-decoration: none\">$topic_title</a>";
$Topic_Buffer .= "<tr><td bgcolor=\"$bgcolor1\">&nbsp;$TopicTitleShow</td><td bgcolor=\"$bgcolor1\"><div align=\"center\"><font class=block>$OrigPoster</font></div></td><td bgcolor=\"$bgcolor1\"><div align=\"center\"><font class=block><b>$topic_views</b></font></div></td><td bgcolor=\"$bgcolor1\"><div align=\"center\"><font class=block><b>$topic_replies</b></font></div></td><td align=\"center\" bgcolor=\"$bgcolor1\"><font class=block>$LastPoster</font></td></tr>";
}
if( $Last_New_Topics == $Count_Topics ) { break 1; }
}
$content = "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\" bgcolor=\"$bgcolor2\">";
$content .= "<tr><td style=\"cursor:help\"
width=\"100%\" height=\"18\" colspan=\"5\" align=\"center\" bgcolor=\"#000000\"><font class=block></font></td></tr>";
$content .= "<tr><td style=\"cursor:hand\"
align=\"center\" bgcolor=\"#333333\" height=\"18\"><font class=block><b>Тема</b></font></td><td style=\"cursor:hand\"
align=\"center\" bgcolor=\"#333333\"><font class=block><b>Автор</b></font></td><td style=\"cursor:hand\"
align=\"center\" bgcolor=\"#333333\"><font class=block><b>Просм</b></font></td><td style=\"cursor:hand\"
align=\"center\" bgcolor=\"#333333\"><font class=block><b>Отв</b></font></td><td style=\"cursor:hand\"
align=\"center\" bgcolor=\"#333333\"><font class=block><b>Ответил</b></font></td></tr>";
$content .= "$Topic_Buffer";
$content .= "<tr><td style=\"cursor:hand\"
align=\"center\" colspan=\"5\" bgcolor=\"$bgcolor2\" height=\"18\"><font class=block><b>Тем: <b>$Amount_Of_Topics</b>&nbsp;<b>|</b>&nbsp;Сообщений <b>$Amount_Of_Posts</b>&nbsp;<b>|</b>&nbsp;Просмотров <b>$Amount_Of_Topic_Views</b>&nbsp;<b>|</b>&nbsp;Ответов <b>$Amount_Of_Topic_Replies</b></center></font></td></tr>";
$content .= "</table><br>";
?>

Cybermama
17.04.2006, 05:17
вообще я хочу себе блок новостей сделать...потом поделюь кодом, а чем примечателен тот блок вывода последних сообщений с форума...где-нит ьможно посмотреть его в действии? или хотя бв как он называется?