Referral System

Started by SMFHacks.com Team, March 03, 2008, 01:02:01 PM

Previous topic - Next topic

jaa

Thanks Fustrate, ill try it.. :)

Eclipse16V

Hi Fustrate,

I become this error when i will create a test account on my SMF 2.0RC1 with my as Referral (normal, not in the ACP):

QuoteThe database value you're trying to insert does not exist: referred_by

The Datebase is ok. :(
I worked with:
SMF 2 in German

Shop:
SID Giessen

Fustrate

is there a referred_by column in your members table? You can check with phpMyAdmin or any other database management software.
Steven Hoffman
Former Team Member, 2009-2012

genusis

#503
hello I just installed this and tested it i get two errors, when a new user goes to the original site link with no referrals link and registers and writes in the referrals name i get this error

error, your db is not excepting referel_id.

when i use the referral link http://spirea.kozlowski.ws/forum/index.php?referredby=1
I get this error when registering

Wrong value type sent to the database. Integer expected. (p_referrals_no)

Any ideas on how to fix these, and thanl you if we can find a fix for this.



To help you out more i went and check my error report and heres the information it gives me

Only show the error messages of this member  Guest 

Reverse chronological order of list 

Today at 09:34:20 AM

Only show the error messages of this IP address \\\\\\\\\\\\\

Only show the error messages of this session 38e10c636aea877128e7894f77de5b8f
 
Only show the errors of this type Type of error: Critical

Only show the error messages of this URL http://spirea.kozlowski.ws/forum/index.php?action=register2

Only show the errors with the same message
Wrong value type sent to the database. Integer expected. (p_referrals_no)
Function: updatememberdata

Only show the errors from this file

File: forum/Sources/Subs.php
Line: 535

   
Only show the error messages of this member Guest

Reverse chronological order of list

Today at 09:17:34 AM

Only show the error messages of this IP address ////////////

Only show the error messages of this session ebde5b482b58979eb0882f2999e1f5ad

  Only show the errors of this type Type of error: Critical

Only show the error messages of this URL http://spirea.kozlowski.ws/forum/index.php?action=register2

Only show the errors with the same message

The database value you're trying to insert does not exist: referred_by
Function: registermember

Only show the errors from this file
File: forum/Sources/Subs-Members.php
Line: 743
hello I am Genusis
this is my site
http://spirean.com

Eclipse16V

Quote from: Fustrate on April 22, 2009, 11:00:53 AM
is there a referred_by column in your members table? You can check with phpMyAdmin or any other database management software.
Yes is it. All columns are in the member table.
I worked with:
SMF 2 in German

Shop:
SID Giessen

genusis

@Eclipse16V

go into ./Sources/Load.php

Find

   if ($set == 'normal')
{
$select_columns = '


and under that look for
mem.referrals_no, mem.referred_by, mem.referred_on, mem.referrals_hits,


If there isn't one there add that.


then Find

elseif ($set == 'profile')
{
$select_columns = '

and under that look for
mem.referrals_no, mem.referrals_hits, mem.referred_on, mem.referred_by,

then find

elseif ($set == 'minimal')
{
$select_columns = '

under it look for
mem.referrals_no, mem.referred_by, mem.referrals_hits, mem.referred_on,

If there not there add those.

The look for

function loadReferral(){
replace the whole sub with

function loadReferral(){
global $smcFunc, $context, $user_info;

// Guests only!
if (!$user_info['is_guest'])
return;

if (isset($_GET['referredby'])){
// Sanitize - must be a valid number id
$referrer = (int) $_GET['referredby'];

// If not a valid id, then just return
if (empty($referrer)){
setcookie("smf_referrals", "", time() - 90000);
return;
}

$result = $smcFunc['db_query']('', '
SELECT real_name
FROM {db_prefix}members
WHERE id_member = {int:ref}',
array(
'ref' => $referrer
)
);

if ($smcFunc['db_num_rows']($result) < 1){
$smcFunc['db_free_result']($result);
setcookie("smf_referrals", "", time() - 90000);
return;
}

list ($name) = $smcFunc['db_fetch_row']($result);

$smcFunc['db_free_result']($result);

// If Cookie doesn't already exist, count it as a referral hit
if (empty($_COOKIE['smf_referrals'])){
// Increase referral hits by 1 for the referrer
updateMemberData($referrer, array('referrals_hits' => '+'));

# @ Hidden Easter Eggs @
# Use to give rewards for each referral hit
# Uncomment the line by removing // from the beginning of the line

# Reward with Karma
// updateMemberData($referrer, array('karma_good' => 'karma_good + 25'));

# Using SMF Shop? Give them money
// updateMemberData($referrer, array('money' => 'money + 100'));
}

// Set a ReferralCookie (overriding any existing one to extend the 60 days)
setcookie("smf_referrals", ($referrer . '#' . time()), (time() + (86400 * 60)));

// $user_info has more staying power at this point
$user_info['was_referred'] = array(
'referred_timestamp' => time(),
'referred_date' => timeformat(time()),
'referred_by_id' => $referrer,
'referred_by_name' => $name,
);
} else {
// Must contain hash, and not be empty
if (!eregi("([0-9]{1,8})#([0-9]{9,10})", $_COOKIE['smf_referrals'], $parts)){
setcookie("smf_referrals", "", time() - 90000);
return;
}

// Set a cookie, extending any existing one
setcookie("smf_referrals", $parts[0], (time() + (86400 * 60)));

$result = $smcFunc['db_query']('', '
SELECT real_name
FROM {db_prefix}members
WHERE id_member = {int:ref}',
array(
'ref' => $parts[1]
)
);

if ($smcFunc['db_num_rows']($result) < 1){
$smcFunc['db_free_result']($result);
setcookie("smf_referrals", "", time() - 90000);
return;
}

list ($name) = $smcFunc['db_fetch_row']($result);

$smcFunc['db_free_result']($result);

// $user_info has more staying power at this point
$user_info['was_referred'] = array(
'referred_timestamp' => $parts[2],
'referred_date' => timeformat($parts[2]),
'referred_by_id' => $parts[1],
'referred_by_name' => $name,
);
}
}


other than that that's should be all the is causing it.
hello I am Genusis
this is my site
http://spirean.com

Eclipse16V

@ genusis
What does it do?
It´s the same Code how the Code in the Mod.  ;)
I don´t replace because it is the same Code.
I worked with:
SMF 2 in German

Shop:
SID Giessen

Fustrate

#507
I've fixed both errors, just packaging it up now.

Upgrade to 2.2.6 now :)
Steven Hoffman
Former Team Member, 2009-2012

Eclipse16V

Thanks
With 2.2.6 it run.

Cool  :D
I worked with:
SMF 2 in German

Shop:
SID Giessen

Eclipse16V

Here is it in German:

// Referrals MOD
$txt['referrals_findreferrer'] = 'Werber suchen';
$txt['referrals_who'] = 'Geworben von:';
$txt['referrals_who_description'] = 'Wurdest Du von einem User geworben? Hier bitte eintragen oder einen User suchen.';
$txt['referrals_on'] = 'Am';
$txt['referrals_referrer_not_found'] = 'Der User der dich geworben hat, konnte nicht gefunden werden. Bitte &uuml;berprüfe deine Eingabe noch einmal oder einfach dieses Feld leer lassen.';
$txt['referrals_youwerereferred_by'] = 'von';
$txt['referrals_referrals'] = 'Geworbene User:';
$txt['referrals_referrals_hits'] = 'Werbelink Aufrufe:';
$txt['referrals_noneyet'] = 'Zurzeit keine Informationen vorhanden';
$txt['referrals_top5referrers'] = 'Top 5 Werber (Geworbene User)';
$txt['referrals_top5referrersbyposts'] = 'Top 5 Geworbene (Beitr&auml;ge geworbener User)';
$txt['referrals_referralsstats'] = 'Referrals';
$txt['referrals_referred_by'] = 'Geworben von:';
$txt['referrals_link'] = 'Werbelink:';
$txt['referrals_membersreferred'] = 'Geworbene User';
I worked with:
SMF 2 in German

Shop:
SID Giessen

Fustrate

Thanks :) I'll add it to the package when I get home in a few hours
Steven Hoffman
Former Team Member, 2009-2012

genusis

thanks man, @Eclipse16V  well i asked for it just to make sure because i know when i changed one variable in that area it caused that error for me XD.
hello I am Genusis
this is my site
http://spirean.com

Filipina

#512
http://www.melindaspenpals.com/penpal-community/index.php?action=stats

off the top of your head do you have any idea why i am seeing this extra table trying to show on my stats page.  It is racking my brain  :)

// Start of Referrals Mod Stats
echo '
</table>
</td>
</tr><tr>
<td class="catbg" colspan="2" width="50%"><b>', $txt['referrals_top5referrers'], '</b></td>
<td class="catbg" colspan="2" width="50%"><b>', $txt['referrals_top5referrersbyposts'], '</b></td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_info.gif" width="20" height="20" alt="" /></td>
<td class="windowbg2" width="50%" valign="top">
<table border="0" cellpadding="1" cellspacing="0" width="100%">';

if (empty($context['total_referrals']))
echo '
<tr>
<td valign="top" style="text-align:center">', $txt['referrals_noneyet'], '</td>
</tr>';
else
foreach ($context['top_referrers'] as $referrer)
echo '
<tr>
<td width="60%" valign="top">', $referrer['link'], '</td>
<td width="20%" align="left" valign="top">', $referrer['referrals_no'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $referrer['referrals_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
<td width="20%" align="right" valign="top">', $referrer['referrals_no'], '</td>
</tr>';

echo '
</table>
</td>
<td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_info.gif" width="20" height="20" alt="" /></td>
<td class="windowbg2" width="50%" valign="top">
<table border="0" cellpadding="1" cellspacing="0" width="100%">';

if (empty($context['total_referrals_posts']))
echo '
<tr>
<td valign="top" style="text-align:center">', $txt['referrals_noneyet'], '</td>
</tr>';
else
foreach ($context['top_referrers_by_posts'] as $referrer)
echo '
<tr>
<td width="60%" valign="top">', $referrer['link'], '</td>
<td width="20%" align="left" valign="top">', $referrer['posts'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $referrer['referralsposts_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
<td width="20%" align="right" valign="top">', $referrer['posts'], '</td>
</tr>';


EDIT

one more thing I cannot figure out when someone uses this link below they end up somewhere strange... hmmmm could this be because of my Simple Portal and any idea how I can change where they land to either the forum main page or the Portal Front? Thanks for any assistance :)

http://www.melindaspenpals.com/penpal-community/index.php?referredby=1


Filipina

Ok I got the errors on the stats page fixed but I notice I only have one row of referral stats while I notice the picture on the MOD page shows two rows of referrals stats. Could it be because I do not have any stats to show for the second row so there is none?

Besides that the only other thing is maybe i need to alter the referral link due to the Portal? Thanks :)

Fustrate

Being a Simple Portal beta tester, I have no clue how it works :) odd, eh? I'm going to have to start beta testing so that I can answer your question... and about the first thing, are you sure the edits were done to Stats.php and Stats.template.php?
Steven Hoffman
Former Team Member, 2009-2012

Filipina

Quote from: Fustrate on April 25, 2009, 01:34:50 PM
and about the first thing, are you sure the edits were done to Stats.php and Stats.template.php?

Thanks.... yes i just double checked using the parser and made the edits again and I am still missing the bottom row of referral stats... i must be screwing something up but cannot figure it out.

Would it be ok to attach the files here for review?  Let me know thanks

Fustrate

so you're talking about the "Posts by reffered members"-ish column?
Steven Hoffman
Former Team Member, 2009-2012

Moneymaker13

You said something like you can see the "Top Five Referrers"?

Where can I see that?

Fustrate

Steven Hoffman
Former Team Member, 2009-2012

Filipina

wow frustrate so sorry i thought there were 4 different stats but i looked at the picture again and there is  "Top 5 Referrers (By Referrals)"  and "Top 5 Referrers (By Referred Members Posts)" and I already have this!  I looked at the image you had on the mod page wrong sorry, so all is fine.

If you are able to come up with something with the referral link let me know... I thought of just trying to change it to "index.php?action=forum?referredby=1" instead of "index.php?referredby=1" but something tells me it is not that easy :)

Advertisement: