BETA: Referrals Mod

Started by karlbenson, May 29, 2007, 10:09:38 PM

Previous topic - Next topic

karlbenson

Edit: This modification has now been approved
See http://www.simplemachines.org/community/index.php?topic=184291.0

nitins60

Wow! I never seen this post! It's amazing! Referral mod will be the SMF top 1 mod. I don't know, how many times it's requested by many users, even few SMF staff. But no one did it.


I would like to ask few questions, what do you mean by tracking by cookies. Remember, many ppl definatly clear thier cookies after thier browsing time. Instead of referredby=587, make it referredid=id of the user (since it's unique).

I think, you can get great help from other developers to fix bugs/help

SlammedDime

Quote from: nitins60 on May 29, 2007, 11:53:53 PM
Wow! I never seen this post! It's amazing! Referral mod will be the SMF top 1 mod. I don't know, how many times it's requested by many users, even few SMF staff. But no one did it.


I would like to ask few questions, what do you mean by tracking by cookies. Remember, many ppl definatly clear thier cookies after thier browsing time. Instead of referredby=587, make it referredid=id of the user (since it's unique).

I think, you can get great help from other developers to fix bugs/help
Tracking by cookies is just as it implies.  A cookie is set when a user visits the site through a referral link that dicates who the user was that referred the person.  As for the 'id of the user'... thats what '587' in your example is, the user id, not the username.

This looks like a nice mod.  When I have some free time this week, I'll poke around at it.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

RIPPeterBrock

please tell me what smf version this is for? im using Powered by SMF 1.1.2

karlbenson

RIPPeterBrock: 1.1.2 is what I've made and tested it on. (it may work on 1.1.1 or other versions aswell)

Matt @ ARTcom is correct.  When some one users the referral link, a cookie is placed on their computer.
It is set to expire in 60 days.
If the user clears their cookies, then obviously it won't be there that long.

The referredby is their referring users ID and not realName or memberName.

RIPPeterBrock

Will install now on my theme and tell you how it goes, it is not the default theme, but it does use some of the default index boards.

RIPPeterBrock

Okay, i upload it and it says this:

---------------------

Error in Package Installation
At least one error was encountered during a test installation of this package. It is strongly recommended that you do not continue with installation unless you know what you are doing, and have made a backup very recently. This error may be caused by a conflict between the package you're trying to install and another package you have already installed, an error in the package, a package which requires another package that you don't have installed yet, or a package designed for another version of SMF.

-------------------

1.     Execute Modification     install.xml     Modification parse error
2.    Execute Modification    -    Modification parse error

karlbenson

what modifications have you got installed?

At the moment I've only tested this mod on clean (no mods, fresh 1.1.2) installation.

RIPPeterBrock

SMF Shoutbox
SMFShop
YouTube BBC Tag (XHTML Compliant)
SMFPets
Xbox Live Gamer Tag
VisualWarning
Custom Profile Field Mod
War(c)hild:IMDB_Tag4Smf
Referrals
Users Online Today Mod

-----------------------------------------

And one or two tiny little shop mod items.

karlbenson

After some research on here, that type of error is todo with server configuration and permissions.
Something preventing the files being extracted from the mod file.

One suggested installing the "no temp directory removal mod"
http://custom.simplemachines.org/mods/index.php?mod=724

RIPPeterBrock

hmm, so i just install this mod and your one should then install?

Edit: Hmm getting the same error, "cries"

RIPPeterBrock

somebody posted this about the G2 GALLERY MOD:

If you're planning to use it in "bridged mode" (where users are redirected to the external gallery instead of having the gallery embedded in SMF), then you should install it in a sub-directory of SMF or the Image Chooser script won't work (it doesn't support a standalone G2 installation being on a separate subdomain). Otherwise you can install it wherever you want as long as it's on the same server and can be accessed by SMF.

The "Modification Parse Error" thing is a bug with PHP 5.2 and is something related to the size of the modification file (we haven't figured it out completely yet). You will need to install it manually (see the "help.txt" file that's included with the package, or http://docs.simplemachines.org/index.php?topic=402) if it won't install through the package manager. Someone has made a PHP 5.2 compatible package, but it is only for the regular version and not the "no-bridge" version. Beta 3.1 of the bridge (which should hopefully be released next week - I just haven't had time to test it) will split the modification into two separate files, which will allow it to install on PHP 5.2.

Hope this helps.

-----------------------------------------

Only problem is, i ain't the best, i don't know how to install this mod manually

RIPPeterBrock

ok i found out why it's doing it, it's to do with PHP5 and PHP4, it's some code you got in a XML file or something which is why most / all of us that are on php5 will not be able to use your mod until you have fixed the code or something along those lines they say.

karlbenson

#13
I'll have a search.

I've actually developed this mod while running php 5.2.2 (with xampplite)

but also tested this on my server running php 4.3

When you installed the  "no temp directory removal mod"
http://custom.simplemachines.org/mods/index.php?mod=724 did you create a 'temp' folder in packages beforehand with permissions set to 777?

Have you got any errors in your error log? (Please copy and paste if you have)

Is Safe Mod Off?

From your phpinfo, whether zlib is installed (What is phpinfo.php?)
[/quote]

SlammedDime

I tested installing this on a virgin 1.1.2 install with PHP 5.2.2 and it worked without error, fyi. ;)
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

SlammedDime

Let me recommend something about your install script.... there is no need to do "<file name="$sourcedir/Load.php">" for every modification to a file... if you have 20 modification for Load.php, put them ALL inside one <file> tag, don't put each one in its own...  ie:

<file = load>
<operation></operation>
<operation></operation>
<operation></operation>
<operation></operation>
<operation></operation>
</file>

not

<file = load>
<operation></operation>
</file>

<file = load>
<operation></operation>
</file>

<file = load>
<operation></operation>
</file>

<file = load>
<operation></operation>
</file>
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

~Unkn0wn~

WOrks on the latest SMF? Fully work? When do the test ends?

karlbenson

Matt: re the files, lol . Yes I do know that. (per most my other mods)

I only do it for BETAs where theres tonnes of modifications to the same file.
If theres a file on the install, i can quickly work out which modification/change within that file is at fault.
(the same for any problems you may encounter with it working for other mods or if you have to manually install, you can see which ones didnt fail.)

Once it gets out of beta, I'll merge the file entries. But for now, it makes absolutely no difference to the install. (although it might look a bit weird)

SlammedDime

SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

karlbenson

The first readme that i did for this file, actually stated that I had done it and the reasons why.

karlbenson

Quote from: assasinkilla on May 30, 2007, 04:09:10 PM
WOrks on the latest SMF? Fully work? When do the test ends?

Part of being a BETA is that it hasnt been tested in a proper environment (with other mods) and whether any parts of the code are buggy or there are security issues with.

The code gets refined, bugs get fixed, changes for integration along with other mods will follow before a proper 1.0 release.

~Unkn0wn~

K, i will wait for release, thanks =) :)

Oldiesmann

Great to see someone has finally made this mod. I'll have to play with it when I have more time.
Michael Eshom
Christian Metal Fans

karlbenson

^ me too.

I have been waiting for it for a long time.

I'm about to upgrade my board and I so I decided to have a go.
it was actually alot easier than i thought.

kerrang!

Hey Karl,

Wonderful mod here buddy. Excellent work! Small question though (if you don't mind)

I have it installed on a site which i've got an integrated script with joomla. The problem is that the link wouldn't work with this, would it be possible to allow the link to be altered to what my sites link is?

example... www.mysite.com/community/index.php?referredby=9
which isn't the path my site links with

which is www.mysite.com/forum/

Would it be possible to take the "referredby=9" and get it to work with the link above? Thanks very much for this mod.

~Kerrang!
I'm my own worst enemy! :P

Css Help <--Having difficulty matching the look of the code function with the style of "quote".. =)

SlammedDime

kerrang! - this should work with a Joomla integration without issue... the link would be, more or less, http://www.mysite.com/index.php?option=com_smf&Itemid=1&referredby=9
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

karlbenson

I've never used an integration/bridge myself.

The link which appears in each persons profile is made up from the $scripturl. with the rest added on.

You could modify in the install.xml (or post install on the profile.template)
echo '<tr>
<td colspan="2"><b>'.$txt['referrals_link'].'</b></td></tr>
<tr><td colspan="2" style="text-align:center;">'.$scripturl.'?referredby='. $context['member']['id'] .'</td>
</tr>';

And replace the $script url with your modified version.

Hope that helps.

kerrang!

Quote from: karlbenson on June 03, 2007, 04:28:25 PM
I've never used an integration/bridge myself.

The link which appears in each persons profile is made up from the $scripturl. with the rest added on.

You could modify in the install.xml (or post install on the profile.template)
echo '<tr>
<td colspan="2"><b>'.$txt['referrals_link'].'</b></td></tr>
<tr><td colspan="2" style="text-align:center;">'.$scripturl.'?referredby='. $context['member']['id'] .'</td>
</tr>';

And replace the $script url with your modified version.

Hope that helps.

Sorry for sounding like a newbie here..
Quote$scripturl.
what would this be changed to? the url?

Thanks for your help :)
I'm my own worst enemy! :P

Css Help <--Having difficulty matching the look of the code function with the style of "quote".. =)

SlammedDime

kerrang! - before trying to mess with and change things, why don't you install the mod and try the link as I suggested above.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

SMdot™

I get an error for Display.template.php

I have these modules installed

1.     vWarn Mod      1.10      
2.    Googlebot & Spiders Mod    2.0.3    
3.    Frequency Bars    1.0    
4.    Referrals    1.0    
5.    Global Headers Footers    1.3    
6.    SMF Arcade    2.0.8    
7.    SMFShop    3.0    
8.    PM On Registration    1.0.2
9.    TinyPortal    0.983    
10.    Media Center    1.0    
11.    Who Voted What?    1.1.2

I've attached my Display.template.php file.



Display.template.php (35.38 KB - downloaded 0 times.)

ArkServer

sounds like a mod we can use, once this mod is a bit "matured" im sure we will use it.

kerrang!

Sorry to be annoying here. :)

Any clues what I change the script link to? (I'm not exactly sure what code goes their) kudos,~Kerrang!
I'm my own worst enemy! :P

Css Help <--Having difficulty matching the look of the code function with the style of "quote".. =)

SlammedDime

#32
Quote from: Matt @ ARTcom on June 03, 2007, 05:18:23 PM
kerrang! - before trying to mess with and change things, why don't you install the mod and try the link as I suggested above.

kerrand! - if you have a bridged site, you should not be accessing the standalone forum... ie: if your bridge link is http://www.myurl.com/index.php?option=com_smf&Itemid=26, and your standalone forum link is http://www.myurl.com/forum, you should not be linking users to http://www.myurl.com/forum
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

kerrang!

Quote from: Matt @ ARTcom on June 08, 2007, 04:32:36 AM
Quote from: Matt @ ARTcom on June 03, 2007, 05:18:23 PM
kerrang! - before trying to mess with and change things, why don't you install the mod and try the link as I suggested above.

kerrand! - if you have a bridged site, you should not be accessing the standalone forum... ie: if your bridge link is http://www.myurl.com/index.php?option=com_smf&Itemid=26, and your standalone forum link is http://www.myurl.com/forum, you should not be linking users to http://www.myurl.com/forum

I have SEF urls setup so it's changed the link from /options=com_smf&itemid=26/ - /forum/

:)
I'm my own worst enemy! :P

Css Help <--Having difficulty matching the look of the code function with the style of "quote".. =)

Fustrate

#34
Are there any plans to have it be a referral by name?

If not, where could I manually make that modification to the code?

Thanks :)

Oh, and it works fine on a forum with 5 other mods -

1.     Country Flags
2.    SMF Arcade
3.    Create Topic on Report to Moderator
4.    Topic Solved
5.    Admin Notepad

and a fairly heavily modified custom theme (though I only had to change that one line in Display.template.php)

oh, and what about a referral field in the registration area, so they can just manually type a name?
Steven Hoffman
Former Team Member, 2009-2012

nitins60

It's not possible to do via name! Because in SMF, you can change your name (user), so how can you give referral to him?

Fustrate

#36
I thought you could only change your display name, not your login name...

is it possible if you have name changes turned off?

(Just looked in MySQL. There's two rows in the smf_members table that have to do with the name, memberName and realName - is it possible to go by one of those? As I recall, only one of those changes when a name is changed. I'll test it in a minute.)

EDIT: memberName stays the same :) realName changes.
Steven Hoffman
Former Team Member, 2009-2012

xxkylexx

Using this mod. Works good so far.

Fustrate

#38
I'm going to go ahead and try to make the changes for it to work with memberName from the database ;)

I'll reply here with what happens.

Part 1 (Show <select> with names): Done!
Part 2 (Make it do the referral): Done!

It uses a <select> in this format:
<select name="referredby">
<option></option>
<option value="ID_MEMBER">memberName</option>
<option value="ID_MEMBER">memberName</option>
<option value="ID_MEMBER">memberName</option>
</select>
<input type="hidden" name="referredon" value="time()" />

to allow members to select a referrer.

It's then a little modification to the Sources/Register.php file and you're done!

This can be used even if you allow members to change their names, because it works off of their login name, and changes dynamically along with login name changes.

I'll post the changes here in a minute, I need to clean up the code, it has akward spacing.

Changes to $themedir/Register.template.php or default/Register.template.php
// IF REFERRAL INFORMATION IS SET IT WILL HAVE BEEN PASSED USING THIS VARIABLE
global $referrals;
if (isset($referrals))
{
echo ' <tr>
<td width="40%"><b>'.$txt['referrals_information'].'</b></td>
<td>'. $txt['referrals_youwerereferredby'].' '. $referrals['referredbyname'].
' '.$txt['referrals_on'].' '. date('d-m-Y',$referrals['referredon']);

// NOW WRITE THE INFORMATION INTO HIDDEN INPUTS TO BE PASSED TO THE NEXT FUNCTION
echo ' <input type="hidden" name="referredby" value="'.$referrals['referredbyid'].'"/>
<input type="hidden" name="referredon" value="'.$referrals['referredon'].'"/>
</td>
</tr>';
}
}

change to
// IF REFERRAL INFORMATION IS SET IT WILL HAVE BEEN PASSED USING THIS VARIABLE
global $referrals;
if (isset($referrals))
{
echo ' <tr>
<td width="40%"><b>'.$txt['referrals_information'].'</b></td>
<td>'. $txt['referrals_youwerereferredby'].' '. $referrals['referredbyname'].
' '.$txt['referrals_on'].' '. date('d-m-Y',$referrals['referredon']);

// NOW WRITE THE INFORMATION INTO HIDDEN INPUTS TO BE PASSED TO THE NEXT FUNCTION
echo ' <input type="hidden" name="referredby" value="'.$referrals['referredbyid'].'"/>
<input type="hidden" name="referredon" value="'.$referrals['referredon'].'"/>
</td>
</tr>';
} else {



// MODIFICATION


echo '
<tr valign="top" width="100%">
<td width="40%" align="top">
<b>Referred by: </b></td>
<td>
<select name="referredby">
<option value="0"></option>';

$con = mysql_connect($db_server, $db_user, $db_passwd);
if (!$con)  echo 'Could not connect: ' . mysql_error();

mysql_select_db($db_name, $con);

$result = mysql_query("SELECT * FROM {$db_prefix}members ORDER BY memberName");

while($row = mysql_fetch_array($result))
  {
  echo "
<option value=\"{$row['ID_MEMBER']}\">" . $row['memberName'] . "</option>";
  }

mysql_close($con);

echo '
</select>
<input type="hidden" value="' . time() . '" name="referredon"/>
</td>
</tr>';
}


Changes to $sourcedir/Register.php
// CHECKS FOR OUR COOKIE
global $referrals;
if(isset($_COOKIE['smfreferrals']))
{
$referrals = array();
$temp = explode("#", $_COOKIE['smfreferrals']);
$referrals['referredbyid'] = (int) $temp[0];
$referrals['referredon'] = (int) $temp[1];

if ($referrals['referredbyid'] != 0)
{
// QUERY IF THE USER ACTUALLY EXISTS
$request = db_query("
SELECT memberName
FROM {$db_prefix}members
WHERE ID_MEMBER = " . (int) $referrals['referredbyid'] . "
", __FILE__, __LINE__);

if (mysql_num_rows($request) != 0) {
// SET THE MEMBERNAME INTO THE ARRAY AS WE WILL SHOW THAT ON THE FORM
list ($referrals['referredbyname']) = mysql_fetch_row($request);
} else {
// NO USER EXISTS BY THAT NAME, SO UNSET IT
unset($referrals);
}
mysql_free_result($request);
}
}}

change to
    // CHECKS FOR OUR COOKIE
    global $referrals;

    if(isset($_POST['referredby'])){
        $referrals = array();
        if(isset($_COOKIE['smfreferrals'])){
            $temp = explode("#", $_COOKIE['smfreferrals']);
            $referrals['referredbyid'] = (int) $temp[0];
            $referrals['referredon'] = (int) $temp[1];
        } else {
            // MODIFICATION
            $referrals['referredbyid'] = (int) $_POST['referredby'];
            $referrals['referredon'] = (int) $_POST['referredon'];
        }
        if ($referrals['referredbyid'] != 0){
            // QUERY IF THE USER ACTUALLY EXISTS
            $request = db_query("SELECT memberName FROM {$db_prefix}members WHERE ID_MEMBER = " . (int) $referrals['referredbyid'] . "", __FILE__, __LINE__);
            if (mysql_num_rows($request) != 0) {
                // SET THE MEMBERNAME INTO THE ARRAY
                list ($referrals['referredbyname']) = mysql_fetch_row($request);     } else {
                // NO USER EXISTS BY THAT NAME, SO UNSET IT
                unset($referrals);
            }
            mysql_free_result($request);
        }
    }
}


I can't guarantee that those were the starting pieces of code, but they're going to be damn close. If you're going to try this, PLEASE BACK UP YOUR FILES. I can't guarantee that this will work for everyone, just that it worked for me.

Example (please don't register, this is for a game)
http://www.yodaofdarkness.com/forums/index.php?action=register
Steven Hoffman
Former Team Member, 2009-2012

Fustrate

I've now gone through a dozen referrals on my site, from both the cookie and the dropdown list.

I've also tried changing people's display names, and the list changes with them (but still refers the right person). If you wanted to change this to something like the popup box for PMs (where it inputs the most likely name), I'm willing to bet it's possible. Heck, anything's possible, I guess...

Hopefully this will make it into the final release of the mod, as I'm sure it would be used :) Thanks for the awesome mod btw!
Steven Hoffman
Former Team Member, 2009-2012

Super-Man

How can I get my hands on the V1.1 since the Mod says this when I try to download:
An Error Has Occurred!
The mod you have requested has not been approved yet for downloads

I really liked the first version, and I want to use the v1.1, can I get a download link or something, please?

ormuz

The external download link isn't the last version?

ormuz

Just work by "proxy browsing", in normal connections don't work! why?

trenchteam

This mod is great!! 1.1.3  I'm using it at www.shoyoroll.com

ormuz

It's great but, with joomla+smf and SEF urls (Matt hack) it's not so easy to apply!

Fustrate

An easy fix for that would be to use the changes I posted on the last page so that you don't have to use the link - just tell the prospective members to use the dropdown list ;)
Steven Hoffman
Former Team Member, 2009-2012

ormuz

choose the members in a dropdown menu, isn't a solution... I want users register in the site, but they don't have to know that they are referred by someone!

But if I can't, I would try that!

Pranav

I get this error on installation :

Quote16.     Execute Modification     ./Themes/default/Display.template.php     Test failed

_Danny_

can someone help people who are struggling to get this to install please?

Im 99.9% certain my directorys are cmodded perfectly.

But get these errors :

2.     Execute Modification     ./Sources/Load.php     Test failed
16.     Execute Modification     .\Themes\default/Display.template.php     Test failed

any ideas?

~Unkn0wn~

When beta will finish and work in 1.1.3?

nitins60

Quote from: _Danny_ on July 15, 2007, 04:40:34 PM
can someone help people who are struggling to get this to install please?

Im 99.9% certain my directorys are cmodded perfectly.

But get these errors :

2.     Execute Modification     ./Sources/Load.php     Test failed
16.     Execute Modification     .\Themes\default/Display.template.php     Test failed

any ideas?
that's because of some other mods which are conflicting.
@display.template.php, i think you are using custom profile fields mod?

karlbenson

I'll take a look at the mod right now.

Pranav

ok..pls tell us when it's fixed.

~Unkn0wn~

Works good in dilber MC and smf 1.1.3?

RustyBarnacle

Thanks for the great mod.  My only request would be for integration with SMFShop so that admin can reward people for referrals.

karlbenson

It wouldnt be that dfficult.
In fact I hid some code to increase the referring persons karma

Since this mod has been approved I'm going to close this topic, please continue any posts to that topic
http://www.simplemachines.org/community/index.php?topic=184291.0;topicseen

Advertisement: