Original topic : [url="https://www.torrenttrader.org/topic/10318-last-forum-block/"]https://www.torrenttrader.org/topic/10318-last-forum-block/[/url]
I just made some changes
Requirement :
1. class color function.
Class Colors Function for 2.08 : [url="https://www.torrenttrader.org/topic/17452-class-colors-function-for-208/"]https://www.torrenttrader.org/topic/17452-class-colors-function-for-208/[/url]
You can use Attach File OR Create a file called latestforum_block.php
<?php
begin_block("Latest Forum Topics");
/// HERE GOES THE QUERY TO RETRIEVE DATA FROM THE DATABASE AND WE START LOOPING ///
$for = mysql_query("SELECT * FROM forum_topics ORDER BY lastpost DESC LIMIT 7");
while ($topicarr = mysql_fetch_assoc($for)) {
// Set minclass
$res = mysql_query("SELECT name,minclassread FROM forum_forums WHERE id=$topicarr[forumid]") or sqlerr();
$forum = mysql_fetch_assoc($res);
//if ($forum["minclassread"] > '0') {
if (($forum["minclassread"] >= '1') && ($forum["minclassread"] < '5')) {
$forumname = "<a href=?action=viewforum&forumid=$topicarr[forumid]><b>" . htmlspecialchars($forum["name"]) . "</b></a>";
$topicid = $topicarr["id"];
$topic_title = stripslashes($topicarr["subject"]);
$topic_userid = $topicarr["userid"];
/// GETTING USERID AND DATE OF LAST POST ///
$res = mysql_query("SELECT * FROM forum_posts WHERE topicid=$topicid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_assoc($res);
$postid = 0 + $arr["id"];
$userid = 0 + $arr["userid"];
$added = "<nobr>" . $arr["added"] . "</nobr>";
/// GETTING THE LAST INFO AND MAKE THE TABLE ROWS ///
$r = mysql_query("SELECT lastpostread FROM forum_readposts WHERE userid=$userid AND topicid=$topicid") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r);
$new = !$a || $postid > $a[0];
$char1 = 60; //cut length
$subject = "<a href=forums.php?action=viewtopic&topicid=$topicid><b>" . CutName(htmlspecialchars($topicarr["subject"]), $char1) . "</b></a>";
/// GET NAME OF THE AUTHOR ///
$res = mysql_query("SELECT id, username, class FROM users WHERE id=$topic_userid") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) == 1) {
$arr = mysql_fetch_assoc($res);
$author = "<a href=account-details.php?id=$topic_userid>".class_user($arr[username])."</a>";
}
else
$author = "Unknown[$topic_userid]";
/// GETTING THE LAST INFO AND MAKE THE TABLE ROWS ///
$r = mysql_query("SELECT lastpostread FROM forum_readposts WHERE userid=$userid AND topicid=$topicid") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r);
$new = !$a || $postid > $a[0];
$subject = "<a href=forums.php?action=viewtopic&topicid=$topicid><b>" . stripslashes(encodehtml($topicarr["subject"])) . "</b></a>";
/// GET NAME OF LAST POSTER ///
$res = mysql_query("SELECT id, username, class FROM users WHERE id=$userid") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) == 1) {
$arr = mysql_fetch_assoc($res);
$username = "<a href=account-details.php?id=$userid>".class_user($arr[username])."</a>";
}
else
$username = "Unknown[$topic_userid]";
echo ("<left>Author : $author<br>Subject :$subject<br>Last Replies : $replies $username<br>On : $added</left><hr>");
}
}
end_block();
?>
This is working on v2.08 & Tested.
[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6784"]latestforum_block.php[/url]
I just made some changes
Requirement :
1. class color function.
Class Colors Function for 2.08 : [url="https://www.torrenttrader.org/topic/17452-class-colors-function-for-208/"]https://www.torrenttrader.org/topic/17452-class-colors-function-for-208/[/url]
You can use Attach File OR Create a file called latestforum_block.php
<?php
begin_block("Latest Forum Topics");
/// HERE GOES THE QUERY TO RETRIEVE DATA FROM THE DATABASE AND WE START LOOPING ///
$for = mysql_query("SELECT * FROM forum_topics ORDER BY lastpost DESC LIMIT 7");
while ($topicarr = mysql_fetch_assoc($for)) {
// Set minclass
$res = mysql_query("SELECT name,minclassread FROM forum_forums WHERE id=$topicarr[forumid]") or sqlerr();
$forum = mysql_fetch_assoc($res);
//if ($forum["minclassread"] > '0') {
if (($forum["minclassread"] >= '1') && ($forum["minclassread"] < '5')) {
$forumname = "<a href=?action=viewforum&forumid=$topicarr[forumid]><b>" . htmlspecialchars($forum["name"]) . "</b></a>";
$topicid = $topicarr["id"];
$topic_title = stripslashes($topicarr["subject"]);
$topic_userid = $topicarr["userid"];
/// GETTING USERID AND DATE OF LAST POST ///
$res = mysql_query("SELECT * FROM forum_posts WHERE topicid=$topicid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_assoc($res);
$postid = 0 + $arr["id"];
$userid = 0 + $arr["userid"];
$added = "<nobr>" . $arr["added"] . "</nobr>";
/// GETTING THE LAST INFO AND MAKE THE TABLE ROWS ///
$r = mysql_query("SELECT lastpostread FROM forum_readposts WHERE userid=$userid AND topicid=$topicid") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r);
$new = !$a || $postid > $a[0];
$char1 = 60; //cut length
$subject = "<a href=forums.php?action=viewtopic&topicid=$topicid><b>" . CutName(htmlspecialchars($topicarr["subject"]), $char1) . "</b></a>";
/// GET NAME OF THE AUTHOR ///
$res = mysql_query("SELECT id, username, class FROM users WHERE id=$topic_userid") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) == 1) {
$arr = mysql_fetch_assoc($res);
$author = "<a href=account-details.php?id=$topic_userid>".class_user($arr[username])."</a>";
}
else
$author = "Unknown[$topic_userid]";
/// GETTING THE LAST INFO AND MAKE THE TABLE ROWS ///
$r = mysql_query("SELECT lastpostread FROM forum_readposts WHERE userid=$userid AND topicid=$topicid") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r);
$new = !$a || $postid > $a[0];
$subject = "<a href=forums.php?action=viewtopic&topicid=$topicid><b>" . stripslashes(encodehtml($topicarr["subject"])) . "</b></a>";
/// GET NAME OF LAST POSTER ///
$res = mysql_query("SELECT id, username, class FROM users WHERE id=$userid") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) == 1) {
$arr = mysql_fetch_assoc($res);
$username = "<a href=account-details.php?id=$userid>".class_user($arr[username])."</a>";
}
else
$username = "Unknown[$topic_userid]";
echo ("<left>Author : $author<br>Subject :$subject<br>Last Replies : $replies $username<br>On : $added</left><hr>");
}
}
end_block();
?>
This is working on v2.08 & Tested.
[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6784"]latestforum_block.php[/url]