View Full Version : Referrals In Postbit Template
I am not a master hacker *lol* and I spent a while trying to figure out how to get this damn thing to work!
Requested By : Mist
What Does It Do?
Simply allows you to use $referrals in the postbit template. This will display the users total number of referrals.
Hack temporarily Retracted ;)
Freddie Bingham
04-01-2002, 03:51 PM
This is a *bad idea*.
Recluse
04-01-2002, 03:55 PM
Originally posted by freddie
This is a *bad idea*.
why? just wondering :lick:
I was about to ask the same *lol*
Admin
04-01-2002, 04:14 PM
Originally posted by freddie
This is a *bad idea*.
I haven't seen the file but I guess it adds a query per user on showthread.php.
Anyway, Matt, take a look at freddie's query here:
https://vborg.vbsupport.ru/showthread.php?s=&threadid=25170 (when I started and had no clue :eek: )
It should give you a basic idea of how to implement this.
Thanks for replying, Freddie vanished after he said that and I was totally confused by what he meant.
It did add a query per user yes. I will have a look into trying to get rid of that, just being new to all of this I saw it worked and posted. :(
Thanks again!
*goes off to try and fix it*
I was actually thinking of just creating a new table in user and storing the total referrals, as then I could just pull it out with the rest. Is that a bad idea?
Admin
04-01-2002, 04:21 PM
It's either that or another query in showthread.php. I really don't know enough to tell you what's better performance wise, but I do have a feeling another field on the already busy user table for larger boards would be bad.
Thanks. I am just confused as to how you can get the info I need without looping through the members.
Admin
04-01-2002, 04:38 PM
Ok, here's the query for showthread.php:
$refcounts = $DB_site->query("
SELECT COUNT(*) AS referrals,user.userid
FROM user AS users
LEFT JOIN user ON (users.referrerid=user.userid)
WHERE users.referrerid<>0
AND user.userid IN ($postuserids)
GROUP BY users.referrerid
");
$referrals = array(0 => 0);
while ($refcount = $DB_site->fetch_array($refcounts)) {
$referrals[$refcount['userid']] = $refcount['referrals'];
}
BEFORE doing that, you need to change the part invloves $getpostids to also catch the userid's of the posts, and store then in a comma separated list $postuserids that starts with 0: "0,3,7,23,75,12"
Sadie Frost
04-01-2002, 06:01 PM
Okay - non-hacker here (notice hacks=0 :D) so I'm sure this is a really stupid statement, but in any case - if referrals is already displayed when you view profile, isn't there a way to "copy" whatever it is that makes the profile display the number to the postbit?
lol - No Sadie ;) That would be way too easy :D
Dean C
04-01-2002, 07:24 PM
lol this hack must be the hardest hack to make ...
sure is creatin a few problems for people ...
I don't think its that its hard, its just that I am clueless. I know some PHP but not loads and so I am still having to look things up and try and understand them ;)
Sadie Frost
04-01-2002, 07:42 PM
Originally posted by Matt
lol - No Sadie ;) That would be way too easy :D
Yeah, that's what I figured...:D
Admin
04-02-2002, 04:59 AM
Matt, I posted 80% of the hack in my pervious post, you can figure the rest out I'm sure. :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.