Forums Logo
 
Reply to this topicStart new topic
> Seeders/Leechers/Completed Stats in Forum View, Only works for first post & first torrent.
Farjad
post Jul 18 2006, 01:13 AM
Post #1


Member
**

Group: Members
Posts: 28
Joined: 23-June 06
Member No.: 333



TESTED & WORKING!

Edit action_public/forums.php

Find:
CODE
    function render_entry($topic)
    {



Add Under:
CODE
        //-----------------------------------------
        // Torrent Thingy by Farjad
        //-----------------------------------------

        if ( $topic['topic_hasattach'] )
        {
            $torrent_query = "SELECT a.attach_pid, a.torrent_id, a.attach_ext, x.* FROM ibf_attachments a
                              LEFT JOIN torrents x ON(a.torrent_id=x.fid) WHERE a.attach_pid = '".$topic['topic_firstpost']."' AND a.attach_ext like '%torrent%' LIMIT 1";
            $torrent_sql = mysql_query($torrent_query, $this->ipsclass->DB->connection_id);
        
            if ($torrent_sql == null) echo mysql_error();
            while($torrent_row = mysql_fetch_array( $torrent_sql )) {
                if( $torrent_row['seeders'] !== "0") {
                    $torrent_row['seeders'] = "<span style='color: #008000; font-weight: bold;'>".$torrent_row['seeders']."</span>";
                } else {
                    $torrent_row['seeders'] = "<span style='color: #FF0000; font-weight: bold;'>".$torrent_row['seeders']."</span>";
                }

                $topic['seeders'] = "S: ".$torrent_row['seeders']." -";
                $topic['leechers'] = " L: <b>".$torrent_row['leechers']."</b> -";
                $topic['completed'] = " C: <b>".$torrent_row['completed']."</b> &nbsp;&nbsp; ";
            }
        }


---------------------------------------------------------------------------
Template Edits:
Forum Index-->render_forum_row

Find:
CODE
<div style='float:right'>{$data['_rate_img']}</div>


Replace with:
CODE
<div style='float:right'>{$data['seeders']}{$data['leechers']}{$data['completed']}{$data['_rate_img']}</div>
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post
Jaggi
post Jul 18 2006, 03:18 AM
Post #2


Administrator
***

Group: Project Developer
Posts: 350
Joined: 31-March 06
Member No.: 1



interesting sql query... never seen one like that before... interesting approach. I dont like the idea of this mod cus technically its buggy cus it only shows one torrent from the post. Had a hr "discussion" with beeman about this tonite so wont go any further into it... but i won and thats the important thing tongue.gif.
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post
toolmanwill
post Jul 18 2006, 01:58 PM
Post #3


Advanced Member
***

Group: Beta Tester
Posts: 63
Joined: 20-April 06
Member No.: 5



Applied, works good, we only have 1 torrent per thread so it shows stats correctly

Thank you
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post
Eddie
post Jul 18 2006, 03:30 PM
Post #4


Advanced Member
***

Group: Xtra Member
Posts: 53
Joined: 13-May 06
Member No.: 73



thanks for filling my request. i'm next to useless when it comes to writing my own php but do you think you could make it so that the torrent info could be put into a small table format so it's seperated from the topic title?
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post
Farjad
post Jul 20 2006, 03:11 AM
Post #5


Member
**

Group: Members
Posts: 28
Joined: 23-June 06
Member No.: 333



that shoudnt be much hard.. i think you need to edit PageTop & render_forum_row and just add the <tr> stuff.. so its seperated.. but i dont prefer that way because it will also come in other thread (which do not have torrents).
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post
Eddie
post Jul 20 2006, 02:17 PM
Post #6


Advanced Member
***

Group: Xtra Member
Posts: 53
Joined: 13-May 06
Member No.: 73



alright thanks for info smile.gif
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post
r5a
post Aug 21 2006, 12:53 AM
Post #7


Member
**

Group: Members
Posts: 14
Joined: 20-August 06
Member No.: 499



Thanks! Worked great on IPB 2.1.4!
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post
gollum
post Aug 30 2006, 03:32 AM
Post #8


Advanced Member
***

Group: Members
Posts: 63
Joined: 29-April 06
Member No.: 33



Ok, I re-did the skin a bit on my forum, and i thought i would try to give back to the community and share it with others here. smile.gif
This is how it will look:
IPB Image

Assuming that you already have Farjad's version installed,
  1. In */sources/action_public/forums.php, find:
    CODE
                    $topic['seeders'] = "S: ".$torrent_row['seeders']." -";
                    $topic['leechers'] = " L: <b>".$torrent_row['leechers']."</b> -";
                    $topic['completed'] = " C: <b>".$torrent_row['completed']."</b>    ";
  2. Then Replace with this:
    CODE
                    $topic['slc'] = "<div class=\"quotemain\"><b>Torrent Stats:</b> ".$torrent_row['seeders']." Seeder(s), <b>".$torrent_row['leechers']."</b> Leecher(s), <b>".$torrent_row['completed']."</b> Complete(s)</div>";

  3. Now un-do Farjad's edits in Forum Index-->render_forum_row
  4. Then find:
    CODE
                <div class="desc"><span onclick='return span_desc_to_input("{$data['tid']}");' id='tid-desc-{$data['tid']}'>{$data['description']}</span></div>
  5. and add this below:
    CODE
                {$data['slc']}
Here are some other versions.
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
IPB Image
Same procedures as the above, just replace the step #2 code with:
CODE
                $topic['slc'] = "<fieldset><legend>Torrent Stats:</legend>".$torrent_row['seeders']." Seeder(s), <b>".$torrent_row['leechers']."</b> Leecher(s), <b>".$torrent_row['completed']."</b> Complete(s)</fieldset>";

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
IPB Image
Same procedures as the above, just replace the step #2 code with:
CODE
                <div>$topic['slc'] = "<p><b>Torrent Stats:</b> ".$torrent_row['seeders']." Seeder(s), <b>".$torrent_row['leechers']."</b> Leecher(s), <b>".$torrent_row['completed']."</b> Complete(s)</p></div>";

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
and use the "if" codes around the render_forum_row edits (#3) to hide the stats from guests:
CODE
<if="ipb.member['id'] > 0"></if>


hope this helps. cool.gif

This post has been edited by gollum: Aug 30 2006, 07:59 AM
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post
gollum
post Aug 30 2006, 04:25 AM
Post #9


Advanced Member
***

Group: Members
Posts: 63
Joined: 29-April 06
Member No.: 33



hmm..
Maybe we can use ajax to display the torrent size or even the torrent stats themselves instead of having them below each topic title...

This post has been edited by gollum: Aug 30 2006, 04:55 AM
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post
Jaggi
post Aug 30 2006, 03:08 PM
Post #10


Administrator
***

Group: Project Developer
Posts: 350
Joined: 31-March 06
Member No.: 1



ok gollum you've done it backwards tongue.gif your aim is make sure NO HTML is in the php files, it goes against the entire concept of IPB. All should be in the skin files though u can get away with small stuff like font edits etc.

@ farjad : i was doing my own version of this mod the other day for someone and relised so problems with it, i then looked at your version farjad and i think you've been caught in the same way not sure i haven't tested it to be honest. The query gets looped through each time so if someone has this and turns on full debug mode in IPB you'll notice you have the query ran for each of the rows. So if you have 25 rows you'll be running 25 queries... ohmy.gif .

EDIT: Ok i went and tested your version farjad, you have to make a modification to the code to see the debug data you have to replace mysql_query with $this->ipsclass->DB->query. Sure enough theres a query for each row.
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post
gollum
post Aug 30 2006, 09:54 PM
Post #11


Advanced Member
***

Group: Members
Posts: 63
Joined: 29-April 06
Member No.: 33



QUOTE(Jaggi @ Aug 30 2006, 07:08 AM) *

ok gollum you've done it backwards tongue.gif your aim is make sure NO HTML is in the php files, it goes against the entire concept of IPB. All should be in the skin files though u can get away with small stuff like font edits etc.

Yeah, i did it through the skin @ first, but that will make them apear on non torrents topics as well; the way i did it will only display the stats on topics with torrents, and not display anything on non-torrent topics, and i thought this way would be easier and it works. smile.gif
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post
Jaggi
post Aug 31 2006, 02:42 PM
Post #12


Administrator
***

Group: Project Developer
Posts: 350
Joined: 31-March 06
Member No.: 1



ah ok you coulda have added an if around it then unset the variables if it wasn't torrent but yea makes sense, See my topics.php edit if you wanna see how.
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post
Farjad
post Sep 2 2006, 11:02 PM
Post #13


Member
**

Group: Members
Posts: 28
Joined: 23-June 06
Member No.: 333



QUOTE(Jaggi @ Aug 30 2006, 01:08 PM) *

ok gollum you've done it backwards tongue.gif your aim is make sure NO HTML is in the php files, it goes against the entire concept of IPB. All should be in the skin files though u can get away with small stuff like font edits etc.

@ farjad : i was doing my own version of this mod the other day for someone and relised so problems with it, i then looked at your version farjad and i think you've been caught in the same way not sure i haven't tested it to be honest. The query gets looped through each time so if someone has this and turns on full debug mode in IPB you'll notice you have the query ran for each of the rows. So if you have 25 rows you'll be running 25 queries... ohmy.gif .

EDIT: Ok i went and tested your version farjad, you have to make a modification to the code to see the debug data you have to replace mysql_query with $this->ipsclass->DB->query. Sure enough theres a query for each row.



Well I did that because I did not understand how IPB itself did it lmao.. so then I just ended up adding 1 more query for each row.. I knew that would come.. but.. well IPB's query was a bit confusing otherwise I would've left joined it.. or something

QUOTE(gollum @ Aug 30 2006, 01:32 AM) *

and use the "if" codes around the render_forum_row edits (#3) to hide the stats from guests:
CODE
<if="ipb.member['id'] > 0"></if>


hope this helps. cool.gif


Ermm .. when not just add
if($ipsclass->member['id'] > "0")
{

before the whole stats come in the file and after add a
} so your server load from guest decreases aswell..

This post has been edited by Farjad: Sep 2 2006, 11:02 PM
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post

Fast ReplyReply to this topicStart new topic
1 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
1 Members: OPPZeroCool

 

Lo-Fi Version 0.1334 sec    0.08    10 queries    GZIP Enabled
Time is now: 9th October 2006 - 11:51 PM