Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Latest Forums Topics Block
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2.08 Mods Completed

Unknown User
2013-06-19 17:08:01
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&amp;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  &nbsp;$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]

latestforum_block.php
Download
latestforum_block.png
latestforum_block.png
Unknown User
2013-06-19 18:15:44
Yes his work , but....

you use mysql_query in 2.08 ?????

He should be SQL_Query_exec .......
Unknown User
2013-06-19 22:31:15
Not to mention the so many query's inside each other and the fact its an active block..

Maybe some point will look at moding this to use an cache atleast... All these query's cant be good on load:(
Unknown User
2013-06-23 01:51:13
Can someone to fix the code to use cache.?
Unknown User
2013-06-23 04:23:27
"zamunda, post: 90898":
Can someone to fix the code to use cache.?
Here you go.. It still uses the multi querys.... but is cached now atleast.[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6789"]latestforum_block.php[/url]
latestforum_block.php
Download
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728