Pour affiché un bloc en accueil qui reprend les derniers posts des forums phpBB3, j'ai repris celui de bbtonuke auquel j'ai apporté les modifications nécessaires.
Quelqu'un pourrait-il zieuter mon code pour comprendre pour $topic_id ne renvoie rien ?
- Code: Tout sélectionner
<?php
defined('MAXIMUS') or die ('Access denied block forums MAXIMUS directly...');
/*if ( $content = opencacheb ( 'Forums', 'html' , "".CACHE_BL_FORUM."", '1' ) ) {
} else {*/
global $user, $cookie, $sitename, $prefix, $user_prefix, $db, $sitename, $forum_name, $admin, $module_name, $ThemeSel, $bgcolor1, $bgcolor2;
$prefixphpbb3 = "monprefixphpbb3";
$HideViewReadOnly = 1;
$Last_New_Topics = 10; // Nombre de messages affichés
/* Total Amount of Topics */
$result = $db->sql_query( "SELECT * FROM ".$prefixphpbb3."_topics");
$Amount_Of_Topics = $db->sql_numrows( $result );
/* Total Amount of Posts */
$result = $db->sql_query( "SELECT * FROM ".$prefixphpbb3."_posts");
$Amount_Of_Posts = $db->sql_numrows( $result );
/* Total Amount of Topic Views */
$Amount_Of_Topic_Views = 0;
$result = $db->sql_query( "SELECT topic_views FROM ".$prefixphpbb3."_topics");
while( list( $topic_views ) = $db->sql_fetchrow( $result ) )
{
$Amount_Of_Topic_Views = $Amount_Of_Topic_Views + $topic_views;
}
$result = $db->sql_query( "SELECT * FROM ".$prefix."_users" );
$Amount_Of_Members = $db->sql_numrows( $result );
$Count_Topics = 0;
//$Topic_Buffer = "";
$result1 = $db->sql_query( "SELECT t.topic_id, f.forum_name, f.forum_id, t.topic_last_post_id, t.topic_title, t.topic_poster, t.topic_views, t.topic_replies, t.topic_moved_id FROM ".$prefixphpbb3."_topics t, ".$prefixphpbb3."_forums f where t.forum_id=f.forum_id ORDER BY topic_last_post_id DESC" );
while( list( $topic_id, $forum_name, $forum_id, $topic_last_post_id, $topic_title, $topic_poster, $topic_views, $topic_replies, $topic_moved_id ) = $db->sql_fetchrow( $result1 ) )
{
$skip_display = 0;
if( $HideViewReadOnly == 1 )
{
$result5 = $db->sql_query( "SELECT auth_view, auth_read FROM ".$prefixphpbb3."_forums where forum_id = '$forum_id'" );
list( $auth_view, $auth_read ) = $db->sql_fetchrow( $result5 );
if( ( $auth_view != 0 ) or ( $auth_read != 0 ) ) { $skip_display = 1; }
}
if( $topic_moved_id != 0 )
{
// Shadow Topic !!
$skip_display = 1;
}
if( $skip_display == 0 )
{
$Count_Topics += 1;
$result2 = $db->sql_query( "SELECT topic_id, poster_id, FROM_UNIXTIME(post_time,'%d/%m/%Y') as post_time FROM ".$prefix."_posts where post_id = '$topic_last_post_id'" );
list( $topic_id, $poster_id, $post_time ) = $db->sql_fetchrow( $result2 );
$result5 = $db->sql_fetchrow( $db->sql_query( "SELECT FROM_UNIXTIME(post_time,'%H:%i') as post_time FROM ".$prefix."_posts where post_id = '$topic_last_post_id'" ));
$post_time2 = $result5['post_time'];
if ($post_time == date('d/m/Y'))
$post_time = "<font color=\"#FF3300\">Aujourd'hui</font> <font color=\"#6C6C6C\">$post_time2</font>";
elseif ($post_time == date('d/m/Y', time() - 60*60*24))
$post_time = "<font color=\"#3E81C4\">Hier</font> <font color=\"#6C6C6C\">$post_time2</font>";
elseif ($post_time == date('d/m/Y', time() - 60*60*24*2))
$post_time = "<font color=\"#8BBF42\">Avant-hier</font> <font color=\"#6C6C6C\">$post_time2</font>";
else
$post_time = "<font color=\"#6c6c6c\">le $post_time</font>";
$result3 = $db->sql_query( "SELECT username, user_id FROM ".$prefix."_users where user_id='$poster_id'" );
list( $username, $user_id ) = $db->sql_fetchrow( $result3 );
$LastPoster = "<a href=\"modules.php?name=Forums&file=profile&mode=viewprofile&u=$user_id\">$username</a>";
$result4 = $db->sql_query( "SELECT username, user_id FROM ".$prefix."_users where user_id='$topic_poster'" );
list( $username, $user_id ) = $db->sql_fetchrow( $result4 );
$result3 = $db->sql_fetchrow($db->sql_query("SELECT user_id, username, user_avatar FROM ".$user_prefix."_users where user_id='$poster_id'" ));
$uname1 = stripslashes($result3['username']);
$uname1a = substr($uname1,0,20);
$uid = intval($result3['user_id']);
$user_avatar1 = stripslashes($result3['user_avatar']);
$user_avatar1a=strstr($user_avatar1,'http');
if ($user_avatar1a != "") {
$LastPoster ="<a href=\"modules.php?name=Forums&file=profile&mode=viewprofile&u=$uid\">$uname1a</a>";
} else {
$LastPoster ="<a href=\"modules.php?name=Forums&file=profile&mode=viewprofile&u=$uid\">$uname1a</a>";
}
$result4 = $db->sql_fetchrow($db->sql_query( "SELECT user_id, name, username, user_avatar FROM ".$user_prefix."_users where user_id='$topic_poster'" ));
$name2 = stripslashes($result4['name']);
$uname2 = stripslashes($result4['username']);
$uname2a = substr($uname2,0,20);
$uid2 = intval($result4['user_id']);
$user_avatar2 = stripslashes($result4['user_avatar']);
$user_avatarb2a=strstr($user_avatar2,'http');
if ($uname2 == "Anonymous") {$uname2a = "$name2";}
$TopicTitleShow = "<a href=\"phpBB3/viewtopic.php?f=$forum_id&t=$topic_id#$topic_last_post_id\" style=\"text-decoration: none\"> $topic_title</a>";
$Topic_Buffer .= "<tr>
<td align=\"left\" valign=\"middle\" height=\"30\"><img border=\"0\" width=\"11\" height=\"13\" src=\"images/blocks/puceforum.gif\" align=\"left\" alt=\"Voir le sujet\" /><strong>$TopicTitleShow</strong><br />
<a href=\"phpBB3/viewforum.php?f=$forum_id\" style=\"font-size:9px; color:#6c6c6c;\"><i>$forum_name</i></a></td>
<td align=\"center\" valign=\"middle\"><font color=\"#6c6c6c\">$topic_views</font></td>
<td align=\"center\" valign=\"middle\"><font color=\"#6c6c6c\">$topic_replies</font></td>
<td align=\"center\" valign=\"top\"><font size=\"1\"><b>$LastPoster</b><br /><i>$post_time</i></font></td>
</tr>";
}
if( $Last_New_Topics == $Count_Topics ) { break 1; }
}
$cat = $db->sql_query("SELECT * FROM ".$prefix."_categories");
/* Write Table to Screen */
$content .= "<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"100%\">
<tr>
<td align=\"left\" valign=\"top\" height=\"20\"><b><font face=\"Arial\" size=\"2\" color=\"#6c6c6c\">Sujets</font></b></td>
<td align=\"center\" valign=\"top\" width=\"45\" height=\"20\"><b><font face=\"Arial\" size=\"2\" color=\"#6c6c6c\">Vus</font></b></td>
<td align=\"center\" valign=\"top\" width=\"45\" height=\"20\"><b><font face=\"Arial\" size=\"2\" color=\"#6c6c6c\">Rep.</font></b></td>
<td align=\"center\" valign=\"top\" width=\"127\" height=\"20\"><b><font face=\"Arial\" size=\"2\" color=\"#6c6c6c\">Dernier message</font></b></td>
</tr>
$Topic_Buffer
</table>
<table border=\"0\" cellpadding=\"0\" cellspacing=\"5\" width=\"100%\">
<tr>
<td width=\"140\" align=\"right\" valign=\"middle\"><a href=\"\" title=\"Abonnez-vous à ce fil RSS\"><img border=\"0\" width=\"26\" height=\"31\" src=\"images/blocks/rss.gif\" alt=\"Abonnez-vous à ce fil RSS\" /></a></td>
<td valign=\"top\" align=\"center\"><font color=\"#6c6c6c\">[ <a href=\"modules.php?name=Forums\">Parcourir le Forum</a> ] [ <a href=\"phpBB3/search.php\">Rechercher</a> ]</font>
<br /><font size=\"1\" color=\"#6c6c6c\"><b>$Amount_Of_Topics</b> Sujets <b>|</b> <b>$Amount_Of_Posts</b> Messages</font></td>
<td width=\"120\"></td>
</tr>
</table>";
/*
closecacheb ( "".$content."", 'Forums', 'html' , "".CACHE_BL_FORUM."", '1' );
}*/



News