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)

george_proost 08-24-2001 07:43 AM

Yip, I agree eva2000.

I am looking for an exciting new alternative which is
'perpetually inclusive', I believe a member should get some credit
for even great-great-..-grand-referals.

I would like to offer prizes every 3 months.
At the start of a given period all RIP totals are 0.

If a referer joins from a related referred member ALL those in the
chain of referral benefit. The referral tree will eventually also be displayed for the period.

So even 1 referal starts it off and puts all members that have
residual RIP's on the prize list already.

dwh 08-24-2001 08:44 AM

I seee...hmm. This isn't too easy in my view and may add significant load on the server. I won't do it for you but I'll give you some direction as to how I'd do it if I was really set on it.

I don't believe you can do this with one sql statement based on the current table layout. But if you add some fields perhaps it can be done. Very complicated though. There may be some code somewhere to handle this. Look in the IPAddress code of vb. The problem is you need to do recursive searching. Or try I think it's php.net for some code.

Personally I think it's way more trouble than it's worth....if you can accept .5 instead of .5 then .25 etc it will be a little bit easier with a new field, but still a royal pain.

futureal 08-31-2001 06:07 AM

I have been trying to play around with this referrer stuff myself, and was wondering:

How difficult would it be to add a user field to the table that keeps track of a user's # of referrals, in addition to keeping track of "who referred who" like it does now?

I would like to be able to add a "Referrals" column to, for example, the Member Listing, without having to loop through the list for each user to see who referred who. Also, I would like to be able to sort the Member Listing based on # of referrals, which I have not been able to do so far (without an absolutely ludicrous amount of database queries). My goal in this regard is strictly numeric; the system already keeps track of who referred who, so all I am looking for a single numeric field that is incremented, say, when somebody registers.

I know you can add fields using the ALTER command though I know very little about it and don't want to screw anything up. It does seem that once a field like that was added, putting the rest together would be very easy.

Am I wrong, or would this be a relatively easy hack?

george_proost 08-31-2001 06:26 AM

I'm busy on a basic spec. It is not too difficult.
This is NOT a program but a way of specing a program.
Ideally it would become php and integrate passively with
vBulletin.

I am not a programmer so it could take yonks to do this.
A pro-programmer could probably do this in 3-4 hours.

It is NOT a hack as NO vBulletin code would be changed,
no new or altered tables nor new columns in tables.

Code:


// userrips.php
//
// the intention of this program is to calculate the number
// of Referral Index Points or RIPs for short.
//    ===================== 
//
// A RIP allows for the correct allocation of credit when even an  n'th
// generation registration occurs. If the referrer is an ancestor of yours you
// still get credit for registration between date ranges
//
// This task needs to run periodically to keep track of things. (cronjob)
// it will probably be too greedy to run 'real-time'.
//
// the process described trickles RIP credits to all members
// for new member registrations within any given period of time 

input parameters from_date, to_date

delete table userrips if it exists

create table userrips columns userid referrerid dateregistered rips

select userid, referrerid, dateregistered from user descending
// user table is no longer used in this program
// it will be queried again when the display needs to be shown
// the display can be a modified clone the current refertally program

insert userid, referrerid, dateregistered rips=0 into userrips

// table userrips will now be acted upon by two separate loops
// loop_1 just keeps the current user being analysed and is looped through
// processing only those users with a referrerid. This is a simple step_process loop.


foreach ( referrerid <> 0 AND dateregistered falls within date rangeparms ) //loop1
  // set up start variables for each itteration of user
  points = 1
  luckyuserid = reffererid     
  // now trickle deminishing credit down the table   
  do while luckyuserid <> 0     
      udpate userrips rips with rips+points where userid = luckyuserid
      select referrerid as luckyuserid from userrips userid = luckyuserid
      points = points / 2
  enddo
endfor

// end spec


Joshs 09-01-2001 07:24 PM

Check this out: http://24.45.176.213:81/forums/referrerlist.php?s=

I have a question, what variable would I use to have it actually display the referred in the drop down menu? I can't figure it out... Right now I am trying the referrer value to make sure that it works and it does. I just cant seem to figure out what variable to use to display the correct information. Any ideas?

My referrer list bit:
PHP Code:

<tr align="center">
    <
td bgcolor="#F1F1F1"><smallfont><b><a href="member.php?s=$session[sessionhash]&action=getinfo&userid=$referrer[userid]">$referrer[username]</a></b></smallfont></td>
    <
td bgcolor="#F1F1F1"><smallfont>$referrer[referrals]</smallfont></td>
    <
form><td bgcolor="#F1F1F1" valign="middle" align="right" nowrap>
<
SELECT NAME="newLoc" onChange="jumpPage(this.form.newLoc)" style="font-size: 7pt; background-color: #dfdfdf; font-family: Arial, Tahoma;" maxlength="20">
<
OPTION VALUE="#">---------------------</OPTION>
<
OPTION VALUE="member.php?s=$session[sessionhash]&action=getinfo&userid=$referrer[userid]">$referrer[username]</OPTION></select></td></form>
</
tr

My referrer list:
PHP Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<
HTML>
<
HEAD><TITLE>$bbtitle Top Referrer List</title>
$headinclude
</head>
<
body>
$header
<!-- breadcrumb -->
<
table border="0" width="100%" cellpadding="0" cellspacing="0"><tr>
<
td width="100%"><img src="images/vb_bullet.gif" align="absmiddle"> <normalfont><b><a href="index.php?s=$session[sessionhash]">$bbtitle</a> &gtTop Referrers</b></normalfont></TD></tr></table>
<!-- /
breadcrumb -->

<!--
Begin-->
<
br>

<
table cellpadding="0" cellspacing="0" border="0" bgcolor="#555576"  width="100%" align="center"><tr><td>
<
table cellpadding="4" cellspacing="1" border="0"  width="100%">
<
tr align="center">
    <
td bgcolor="#DFDFDF"><smallfont><a href="memberlist.php?s=$session[sessionhash]&action=search"><b>Advanced Search</b></a></smallfont></td>
    <
td bgcolor="#DFDFDF"><smallfont><a href="memberlist.php?s=$session[sessionhash]&what=topposters&perpage=$memberlisttopposters"><b>Top $memberlisttopposters Posters</b></a></smallfont></td>
    <
td bgcolor="#DFDFDF"><smallfont><a href="memberlist.php?s=$session[sessionhash]"><b>List Alphabetically</b></a></smallfont></td>
    <
td bgcolor="#DFDFDF"><smallfont><a href="memberlist.php?s=$session[sessionhash]&what=datejoined"><b>List by Date Joined</b></a></smallfont></td>
<!-- 
Begin Referrals -->
<
td bgcolor="#F1F1F1"><smallfont><a href="referrerlist.php?s=$session[sessionhash]"><b>Referrals</b></a></smallfont></td>
<!-- 
End Referrals -->
<!-- 
Begin Forum Leaders -->
<
td bgcolor="#DFDFDF"><smallfont><a href="showmods.php?s=$session[sessionhash]"><b>Forum Leaders</b></a></smallfont></td>
<!-- 
End Forum Leaders -->
</
tr>
</
table>
</
td></tr></table>

<
br>
<!--
End-->

<!-- 
main -->
<!--
<
table cellpadding="0" cellspacing="0" border="0"  width="250" align="center"><tr>
    <
td><div align="center">$topreferrer</div></td>
</
tr></table>
-->
<
p align="center">$topreferrer</p>
<
table cellpadding="0" cellspacing="0" border="0" bgcolor="#555576"  width="250" align="center"><tr><td>
<
table cellpadding="4" cellspacing="1" border="0"  width="250">
<
tr align="center">
  <
td bgcolor="#8080A6" align="center" width="100"><smallfont color="#EEEEFF"><b>Member</b></smallfont></td>
  <
td bgcolor="#8080A6" align="center" width="50"><smallfont color="#EEEEFF"><b>Referrals</b></smallfont></td>
  <
td bgcolor="#8080A6" align="center" width="100"><smallfont color="#EEEEFF"><b>Members Referred</b></smallfont></td>
</
tr>
$reflistbits
</table>
</
td></tr></table>

<
p align="center">$forumjump</p>

<!-- /
main -->
$footer
</body></html


dwh 09-01-2001 08:45 PM

Nice work. But the answer to your question is a bit involved and you'll have to play with it to get it right. You need to get the option statement out of the template and into the code. You need the option statement in a repeated loop or else you will only be able to get one username. I'm amazed that it isn't messing you up more.

Joshs 09-01-2001 10:14 PM

I think I have to make a new variable in the php file, but I dont know what to do. It is just the variable I need to figure out...

dwh 09-02-2001 03:18 AM

Nope that's not the case. You aren't looking for a variable, you need to move the html for the drop down box into the code.

Why? When the reflistbit is called it runs one line, 3 <TD>'s. But you need to loop through the last <TD> containing the list of referrers as many times as there are referrers. So your <option> html HAS to be in the code not in the template. You don't need a new variable name. The same one will do but you need the html inside the code.

Joshs 09-02-2001 03:38 AM

Okay I know that this code (below) will contain the $referrerlist I dont know what I have to incorporate into the php file, but I have no clue how to do it.

PHP Code:

<OPTION VALUE="member.php?s=$session[sessionhash]&action=getinfo&userid=$referrer[userid]">$referrer[username]</OPTION


dwh 09-02-2001 04:06 AM

I'm not using the topreferrer code and I looked at the code most of you are using but it was taking too long to adjust. So I'll post my code which is working great and hopefully you can figure it out.

BTW, looking at the code that was written for the top referrer, there was an unneeded template and an unneeded sql call.

The top referrer is the first userid that comes out in the loop. Simply set a variable the first time it is run then pull out all the sql code and extra template. So something like

if (!$topdone) {
$ref[userid]=$referred[userid];
$topdone=1;
}
placed right after the first fetch array should enable you to get rid of a bunch of code...

Anyways here's the code I'm using:
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,userid FROM user WHERE referrerid = '$referrer[userid]'");
        $referrerlist = "<SELECT NAME='newLoc' onChange='jumpPage(this.form.newLoc)' style='font-size: 7pt; background-color: #dfdfdf; font-family: Arial, Tahoma;' maxlength='20'><OPTION VALUE='#'>----------Select----------</OPTION>";
        while ($referred = $DB_site->fetch_array($referreds)){
                if ($referrerlist) {
                        $referrerlist.="<OPTION VALUE='member.php?s=$session[sessionhash]&action=getinfo&userid=$referred[userid]'>$referred[username]</OPTION>";
                }
        }
        $referrerlist.="</select>";
        eval("\$reflistbits .= \"".gettemplate("reflistbit")."\";");
        $referrerlist="";
}
eval("dooutput(\"".gettemplate("reflist")."\");");
?>



All times are GMT. The time now is 06:54 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.01255 seconds
  • Memory Usage 1,834KB
  • 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
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)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