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
Last Forum Post on Index [TTv3]
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

2019-04-19 04:59:09
credit to original author

// Last forum post on index
begin_frame("Recent Fourum Post ");
print("<b>Last posts on Forum</b><br>");
print("<table align=center cellpadding=1 cellspacing=0 style='border-collapse: collapse' bordercolor=#646262 width=100% border=1 ><tr>".
"<td bgcolor=#5c5c5c align=left  width=100%><b>Title</b></td>".
"<td bgcolor=#5c5c5c align=center width=47><b>Replys</b></td>".
"<td bgcolor=#5c5c5c align=center width=47><b>Views</b></td>".
"<td bgcolor=#5c5c5c align=center width=85><b>Auther</b></td>".
"<td bgcolor=#5c5c5c align=right width=85><b>Last Post</b></td>".
"</tr>");


/// HERE GOES THE QUERY TO RETRIEVE DATA FROM THE DATABASE AND WE START LOOPING ///
$for = SQL_Query_exec("SELECT * FROM forum_topics ORDER BY lastpost DESC LIMIT 5");

while ($topicarr = mysqli_fetch_assoc($for)) {
// Set minclass
$res = SQL_Query_exec("SELECT name,minclassread,guest_read FROM forum_forums WHERE id=$topicarr[forumid]") or sqlerr();
$forum = mysqli_fetch_assoc($res);

if (get_user_class() >= $forum["minclassread"] || $forum["guest_read"] == "yes") {
$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"];
// Topic Views
$views = $topicarr["views"];
// End

/// GETTING TOTAL NUMBER OF POSTS ///
$res = SQL_Query_exec("SELECT COUNT(*) FROM forum_posts WHERE topicid=$topicid") or sqlerr(__FILE__, __LINE__);
$arr = mysqli_fetch_row($res);
$posts = $arr[0];
$replies = max(0, $posts - 1);

/// GETTING USERID AND DATE OF LAST POST ///
$res = SQL_Query_exec("SELECT * FROM forum_posts WHERE topicid=$topicid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
$arr = mysqli_fetch_assoc($res);
$postid = 0 + $arr["id"];
$userid = 0 + $arr["userid"];
$added = "<nobr>" . $arr["added"] . "</nobr>";

/// GET NAME OF LAST POSTER ///
$res = SQL_Query_exec("SELECT id, username FROM users WHERE id=$userid") or sqlerr(__FILE__, __LINE__);
if (mysqli_num_rows($res) == 1) {
$arr = mysqli_fetch_assoc($res);
$username = "<a href=account-details.php?id=$userid>".class_user($arr['username'])."</a>";
}
else
$username = "Inconnu[$topic_userid]";

/// GET NAME OF THE AUTHOR ///
$res = SQL_Query_exec("SELECT username FROM users WHERE id=$topic_userid") or sqlerr(__FILE__, __LINE__);
if (mysqli_num_rows($res) == 1) {
$arr = mysqli_fetch_assoc($res);
$author = "<a href=account-details.php?id=$topic_userid>".class_user($arr['username'])."</a>";
}
else
$author = "Inconnu[$topic_userid]";

/// GETTING THE LAST INFO AND MAKE THE TABLE ROWS ///
$r = SQL_Query_exec("SELECT lastpostread FROM forum_readposts WHERE userid=$userid AND topicid=$topicid") or sqlerr(__FILE__, __LINE__);
$a = mysqli_fetch_row($r);
$new = !$a || $postid > $a[0];
$subject = "<a href=forums.php?action=viewtopic&topicid=$topicid><b>" . stripslashes(encodehtml($topicarr["subject"])) . "</b></a>";

print("<tr class=alt1><td style='padding-right: 5px'>$subject</td>".
"<td class=alt2 align=center>$replies</td>" .
"<td class=alt1 align=center>$views</td>" .
"<td class=alt1 align=center>$author</td>" .
"<td class=alt2 align=right><nobr><small>By&nbsp;$username<br>$added</small></nobr></td>");

print("</tr>");
} // while
}
print("</table><br>");
end_frame();
2020-03-22 07:21:15
Thank you
2020-03-22 10:45:41
thanks you!
2020-03-23 03:48:18
I’ve made changes, just not finish yet, I’ll post here
2020-03-23 06:39:43
You can strip out the extra HTML, this is my template but don't want to break the mod removing markup. This is how it looks on my end.


<?
   
$forum_table_header = 0; // Enable/Disable table header
   
// Community Forum Posts - Sidebar - March 22, 2020 - BETA
   print("<div ng-repeat=\"item in items\" class=\"col\" style=\"margin-left:5px;padding-bottom:10px;width:463px\"><article itemprop=\"itemListElement\" itemscope=\"\" itemtype=\"http://schema.org/Article\" class=\"card\" style=\"padding:0px;margin:0px\"><table>");
   if ($forum_table_header == 1){
   print("<tr><td style='text-align:center;background:#FFF;width:100%'>Community Topic</td>
          <td bgcolor=#ffffff align=left width=47>Replies</td>
          <td bgcolor=#ffffff align=center width=47>Views</td>
          <td bgcolor=#ffffff align=center width=85>Author</td>
          <td bgcolor=#ffffff align=left width=85>Last Post</td></tr>");
   }      
   $for = SQL_Query_exec("SELECT * FROM forum_topics ORDER BY lastpost DESC LIMIT 5");
   while ($topicarr = mysql_fetch_assoc($for)) {
       $res   = SQL_Query_exec("SELECT name, minclassread, guest_read FROM forum_forums WHERE id=$topicarr[forumid]");
       $forum = mysql_fetch_assoc($res);
       if (get_user_class() >= $forum["minclassread"] || $forum["guest_read"] == "yes") {
           $forumname    = "<a href='$site_config[SITEURL]/community/?action=viewforum&amp;forumid=$topicarr[forumid]'>" . htmlspecialchars($forum["name"]) . "</a>";
           $topicid      = $topicarr["id"];
           $topic_title  = stripslashes($topicarr["subject"]);
           $topic_userid = $topicarr["userid"];
           $views        = $topicarr["views"];
           $res          = SQL_Query_exec("SELECT COUNT(*) FROM forum_posts WHERE topicid=$topicid");
           $arr          = mysql_fetch_row($res);
           $posts        = $arr[0];
           $replies      = max(0, $posts - 1);
           $res          = SQL_Query_exec("SELECT * FROM forum_posts WHERE topicid=$topicid ORDER BY id DESC LIMIT 1");
           $arr          = mysql_fetch_assoc($res);
           $postid       = 0 + $arr["id"];
           $userid       = 0 + $arr["userid"];
           $added        = date("M d, Y", utc_to_tz_time($arr["added"])); // Updated for clean dates
           $res          = SQL_Query_exec("SELECT id, avatar, username FROM users WHERE id=$userid");
           if (mysql_num_rows($res) == 1) {
               $arr      = mysql_fetch_assoc($res);
               $username = "<a href='$site_config[SITEURL]/user/?id=$userid'><img src='$site_config[SITEURL]/$arr[avatar]' style='width:40px;height:40px;border-radius:50%' /></a>";
           } else
               $username = "Unknown[$topic_userid]";
           $res = SQL_Query_exec("SELECT avatar FROM users WHERE id=$topic_userid");
           if (mysql_num_rows($res) == 1) {
               $arr    = mysql_fetch_assoc($res);
               $author = "<a href='$site_config[SITEURL]/user/?id=$topic_userid'><img src='$site_config[SITEURL]/$arr[avatar]' style='width:40px;height:40px;border-radius:50%' /></a>";
           } else
               $author = "Unknown[$topic_userid]";
           $r         = SQL_Query_exec("SELECT lastpostread FROM forum_readposts WHERE userid=$userid AND topicid=$topicid");
           $a         = mysql_fetch_row($r);
           $new       = !$a || $postid > $a[0];
           $cutstring = 19;
           $subject   = "<i class='material-icons' style='color:#FFF;vertical-align:middle;padding-left:3px'>forum</i> <a title='Topic: $topic_title' href='$site_config[SITEURL]/community/?action=viewtopic&topicid=$topicid' style='font-family:arial,helvetica,sans-serif;color:#FFF;font-weight:bold;font-size:16px;padding-left:3px'>" . htmlspecialchars(CutName($topicarr["subject"], $cutstring)) . "</a>";
           
           print("<tr>
                  <td style='color:#FFF;background:#ED2324;text-align:left;height:0px;box-shadow: inset 1px 5px 7px -6px #000000;_border-bottom:1px solid #FFF'>$subject</td>
                  <td class=alt2 align=center style='background:#e6e6e6;border-bottom:1px solid #FFF'>
                          <i class='material-icons' style='color:rgba(231,34,37,1);vertical-align:middle'>flash_on</i> <a href='$site_config[SITEURL]/community/?action=viewtopic&topicid=$topicid' style='font-family:arial,helvetica,sans-serif;color:#000;font-weight:bold;font-size:16px'>$replies</a>
                  </td>
                  <td style='background:#e6e6e6;border-bottom:1px solid #FFF;pointer-events:none'>
                          <span style='color:#FFF;background:#ED2324;padding:8px;border-radius:50%;text-align:center;width:30px;height:30px;box-shadow: inset 1px 5px 7px -6px #000000'>$views</span>
                  </td>
                  <td class=alt1 align=center style='background:#e6e6e6;border-bottom:1px solid #FFF'>$author</td>
                 
                  <td style='background:#e6e6e6;border-bottom:1px solid #FFF;pointer-events:none'><i class='material-icons' style='color:#242424'>swap_horiz</i></td>
                 
                  <td class=alt2 align=center style='background:#e6e6e6;border-bottom:1px solid #FFF;text-align:center'>$username</td>");
           print("</tr>");
       }
   }
   print("</table></article></div>");
?>


<!-- https://codepen.io/camcom/pen/ENRmmN -->
<style>.bolt:after{content:"";top:-9px;left:-8px;border:5px solid transparent;border-bottom:25px solid #ed2324;transform:rotateZ(4deg);padding:0;width:0;height:0;position:absolute;margin:0;overflow:visible;border-top:0 solid;border-radius:0;transform-origin:50% 50% 0}</style>



[ATTACH type="full" alt="example_1.png"]5403[/ATTACH]
example_1.png
example_1.png
2022-01-07 17:10:57
thank you   😀  ðŸ˜€  ðŸ˜€
2022-10-29 12:00:42
does this code go into index.php or does it need to be added to blocks/ownfile.php
2022-10-29 12:44:36
In index.php mate
2022-10-29 12:51:04
thanks m-jay :)
2023-06-19 12:27:59
When i click on forum from index it just sends me to that forum topic not the last post in that topic.

2023-06-19 18:30:25
Change:

$subject = "<a href=forums.php?action=viewtopic&topicid=$topicid><b>" . stripslashes(encodehtml($topicarr["subject"])) . "</b></a>";


to

$subject = "<a href=forums.php?action=viewtopic&topicid=$topicid&page=last#last> " . stripslashes(encodehtml($topicarr["subject"])) . " </a>";


Regards


www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2024-05-13 13:31:31

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, resource given in /www/wwwroot/tt208.local/index.php on line 88
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: 2
  • Members: 0
  • Guests online: 2
  • Comments: 3
  • Messages: 1,728