vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Display full list of referrers and referrals (https://vborg.vbsupport.ru/showthread.php?t=25173)

Admin 08-11-2001 10:00 PM

To see this in action go here.

Installation:
0. Download the attached zip file and extract it.
1. Create a new file named referrerlist.php and in it put the content of referrerlist.txt in it. Config $shownorefs.
2. Create a new template named reflist and put the content of reflist.txt in it.
3. Create a new template named reflistbit and put the content of reflistbit.txt in it.
4. Add an index to the field referredid in the table user.
5. Add a link to referrerlist.php?s=$session[sessionhash] anywhere you want.

Good luck, and feedback is welcomed! :D

Cold Steel 08-12-2001 08:53 PM

Great hack, thanks!

badmeetsevil- 08-12-2001 09:11 PM

Nice hack, but maybe you should have the names in descending order from the more referrals the have? I would rather have that rather then user ID.

Cold Steel 08-13-2001 01:48 AM

Quote:

You do not want to loop through every user and count their referrers! If you have 10,000 users, that would be 10,000 queries!
Would that happen with this code as well?

Admin 08-13-2001 03:27 AM

Yeah I'm afraid so. :( But I don't know how to do this one in other way. It's not the same. :(

dwh 08-13-2001 04:19 AM

Same problem. I'm sure this code could be extremely simplified. It may take some thinking that I don't have the brain cells for now, but please don't take offense, I wouldn't install this one as is, although the concept is very good.

Edited to explain better. This script misses the whole point of a mysql database. SQL is optimized not to require looping through each member but rather selecting only those records having valid data. You need to learn these sql statements better before writing this kind of script.

Instead of counting the number of users you want to select all users where referrerid!="" select * from user where referrerid>0 or something like that. Look at Freddie's other code to see how he did it.

Try different things. Just go into phpMyAdmin and run the sql query and see what results you get. Fool around w/ your code, w/ Freddie's code. I'm sure you'll figure out the best way to do it.

Admin 08-13-2001 04:29 AM

Thanks for the tips. I'm only starting with these things, so I probably don't know everything. Or know very little. :)
So everyone, don't install this. It's cursed. :p

Thanks :)

dwh 08-13-2001 05:42 AM

Alright, instead of the code for referrerlist.php use this
Code:

<?php
error_reporting(7);
$templatesused='reflistbit,reflist';

require('./global.php');
$max=25; //This number decides how many users to display
$referrers = $DB_site->query("SELECT COUNT(*) AS referrals, user.username, user.userid FROM user AS users
                  LEFT JOIN user ON (users.referrerid = user.userid)
                  WHERE users.referrerid <> 0
                  GROUP BY users.referrerid
                  ORDER BY referrals DESC
                  LIMIT $max");
while ($referrer=$DB_site->fetch_array($referrers)) {
        $referreds = $DB_site->query("SELECT username FROM user WHERE referrerid = '$referrer[userid]'");
        while ($referred = $DB_site->fetch_array($referreds)){
                if ($referrerlist) {
                        $referrerlist.=", ";
                }
                $referrerlist .= $referred[username];
        }
        eval("\$reflistbits .= \"".gettemplate("reflistbit")."\";");
}
eval("dooutput(\"".gettemplate("reflist")."\");");
?>

And replace the code for reflistbit with this
Code:

<tr align="center">
        <td bgcolor="{firstaltcolor}"><smallfont><b><a href="member.php?s=$session[sessionhash]&action=getinfo&userid=$referrer[userid]">$referrer[username]</a></b></smallfont></td>
        <td bgcolor="{secondaltcolor}"><smallfont>$referrer[referrals]</smallfont></td>
        <td bgcolor="{firstaltcolor}"><smallfont>$referrerlist</smallfont></td>
</tr>

and you should be all set. Enjoy.

dwh 08-13-2001 05:46 AM

Note that my code does differ a bit. I don't believe in releasing code like this with the option of displaying users that have no referrals. Why? Because once you have too many users it could be a HUGE page and cause you performance issues.

If you want to hack that back in you'd need to ask help from someone that knows the page navigation code because this code won't break it up into pages. And if you plan to list all the users you better have code to break it up into pages. Alternatively, you could jigger the memberlist page to show referrals. I don't think it'd be that hard.

BTW, I just realized there's a problem with this code, it'll add up all previous referrals, got to work on it some more.

dwh 08-13-2001 06:00 AM

OK, I fixed it. Use the reflistbit template I posted above and use this for the php file:

Code:

<?php
error_reporting(7);
$templatesused='reflistbit,reflist';
require('./global.php');
$max=25; //This number decides how many users to display
$referrers = $DB_site->query("SELECT COUNT(*) AS referrals, user.username, user.userid FROM user AS users
                  LEFT JOIN user ON (users.referrerid = user.userid)
                  WHERE users.referrerid <> 0
                  GROUP BY users.referrerid
                  ORDER BY referrals DESC
                  LIMIT $max");
while ($referrer=$DB_site->fetch_array($referrers)) {
        $referreds = $DB_site->query("SELECT username FROM user WHERE referrerid = '$referrer[userid]'");
        while ($referred = $DB_site->fetch_array($referreds)){
                if ($referrerlist) {
                        $referrerlist.=", $referred[username] ";
                } else {
                        $referrerlist = "$referred[username]";
                }
        }
        eval("\$reflistbits .= \"".gettemplate("reflistbit")."\";");
        $referrerlist="";
}
eval("dooutput(\"".gettemplate("reflist")."\");");
?>



All times are GMT. The time now is 10:30 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01127 seconds
  • Memory Usage 1,750KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete