[ABD] Referral MOD With Contests

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
Locked
User avatar
Jessica
Former Team Member
Posts: 4341
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: [DEV] Referral MOD With Contests

Post by Jessica » Thu Feb 07, 2013 5:05 am

Current top referrers on my board:

TOP 5 REFERRERS
Knight Rider (1), Jessica (4)

is there a way I can list in descending order? From highest to lowest?
Please do not PM me for support unless it is absolutely necessary
Pro-choice, Atheist, Pro-LGBT rights

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein

User avatar
Siropu
Registered User
Posts: 155
Joined: Mon Nov 16, 2009 6:15 pm
Location: Romania
Contact:

Re: [DEV] Referral MOD With Contests

Post by Siropu » Thu Feb 07, 2013 9:04 am

Jessica wrote: I created a contest today, February 1st, at 12:50 pm. Set the duration to 3 months.

So it says the end date is April 1st, 11:50 am. the date is right, but the time isn't. Well, it's just one hour off and I suspect it's something to do with DST? It's really not a big deal and if there's no "fix" that's fine - one hour off is no big deal. Just wondering why it's one hour off.
Open includes/acp/acp_referral.php and search for this code:

Code: Select all

strtotime('+ ' . $contest_duration[0] . ' ' . $contest_duration[1])
Replace with this:

Code: Select all

(strtotime("+ {$contest_duration[0]} {$contest_duration[1]}") + 3600)
This will not affect old contests so when you will add a new contest it sould be ok.
I will make this change in the next release.
Jessica wrote:Current top referrers on my board:

TOP 5 REFERRERS
Knight Rider (1), Jessica (4)

is there a way I can list in descending order? From highest to lowest?
It is set to descending by default. It works fine on my demo: http://www.siropu.com/test/phpBB3

Open index.php and search for:

Code: Select all

ORDER BY user_referrals
What do you see after it, "ASC" or "DESC"? It should be "DESC".
Check out my MODs.

User avatar
Jessica
Former Team Member
Posts: 4341
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: [DEV] Referral MOD With Contests

Post by Jessica » Thu Feb 07, 2013 7:17 pm

Siropu wrote:
Jessica wrote: I created a contest today, February 1st, at 12:50 pm. Set the duration to 3 months.

So it says the end date is April 1st, 11:50 am. the date is right, but the time isn't. Well, it's just one hour off and I suspect it's something to do with DST? It's really not a big deal and if there's no "fix" that's fine - one hour off is no big deal. Just wondering why it's one hour off.
Open includes/acp/acp_referral.php and search for this code:

Code: Select all

strtotime('+ ' . $contest_duration[0] . ' ' . $contest_duration[1])
Replace with this:

Code: Select all

(strtotime("+ {$contest_duration[0]} {$contest_duration[1]}") + 3600)
This will not affect old contests so when you will add a new contest it sould be ok.
I will make this change in the next release.
Thanks!
Siropu wrote:
Jessica wrote:Current top referrers on my board:

TOP 5 REFERRERS
Knight Rider (1), Jessica (4)

is there a way I can list in descending order? From highest to lowest?
It is set to descending by default. It works fine on my demo: http://www.siropu.com/test/phpBB3

Open index.php and search for:

Code: Select all

ORDER BY user_referrals
What do you see after it, "ASC" or "DESC"? It should be "DESC".
Strange, apparently the edit in index.php wasn't correct (not of the latest version). I corrected it, and that fixed the order. Thanks again
Please do not PM me for support unless it is absolutely necessary
Pro-choice, Atheist, Pro-LGBT rights

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein

User avatar
FCproductions
Registered User
Posts: 58
Joined: Sun Feb 03, 2013 8:39 am

Re: [DEV] Referral MOD With Contests

Post by FCproductions » Mon Feb 11, 2013 5:34 am

Qwertyip wrote:Hi there.

Great Mod, I needed it for a 'Referral:' Box on the registration page, but i liked how simple it is. So i used it and put a referral box on the registration page myself.
(Im not very good with php though, but i think i've done okay.)

I see there was some requests for it, so here's how i did it.

Image

Information:
  • Auto-fill 'Referral' box if you were referred by the referall link.
  • If the referral is edited to a different name, It will over-ride the referal link and use the new name the user entered. E.g, The name is wrong and you want your friend as the Referrer.
  • If the name is deleted out of the textbox, the link referrer still gets credit for the referral.
  • If user wasn't referrer by link, and fills referral box. Named user will get referral credit.
  • If user wasn't referred by link, and leaves box empty. Registration continues as normal.
includes/ucp/ucp_register.php
FIND

Code: Select all

'tz'				=> request_var('tz', (float) $timezone),
ADD BELOW

Code: Select all

'referrer'			=> request_var('referrer', ''),
...
FIND

Code: Select all

		// Check and initialize some variables if needed
		if ($submit)
ADD ABOVE

Code: Select all

		$rid = request_var($config['cookie_name'] . '_referrer_id', '', false, true);

		if (!empty($rid))
		{
			$sql = 'SELECT username, user_referrals
				FROM ' . USERS_TABLE . '
				WHERE user_id = ' . $rid;
			$result = $db->sql_query($sql);
			$row = $db->sql_fetchrow($result);
			$db->sql_freeresult($result);
			
			$referrer = $row['username'];
		}
...
FIND

Code: Select all

			if (!sizeof($error))
			{
				if ($data['new_password'] != $data['password_confirm'])
				{
ADD ABOVE

Code: Select all

			/*Referrer input Box*/
			if ($data['referrer']) {
				
				$sql_array_ref = array(
					'username'    => $data['referrer'],
				);
				
				$sql = 'SELECT user_id 
						FROM ' . USERS_TABLE . ' 
						WHERE ' . $db->sql_build_array('SELECT', $sql_array_ref);
				$result = $db->sql_query($sql);
				$row = $db->sql_fetchrow($result);
				$db->sql_freeresult($result);
				
				if (!$row)
				{
					$error[] = $user->lang['NO_REFFERER_WITH_NAME'];
				}
			}
...
FIND

Code: Select all

				// Begin Referral MOD
				$rid = request_var($config['cookie_name'] . '_referrer_id', '', false, true);

				if (!empty($rid))
				{
REPLACE WITH

Code: Select all

				// Begin Referral MOD
				if ($referrer || $data['referrer'])
				{
					if (!$referrer && $data['referrer'] || ($referrer && $data['referrer']) && ($referrer != $data['referrer']))
					{
						$sql_array = array(
							'username'    => $data['referrer'],
						);
						
						$sql = 'SELECT user_id
							FROM ' . USERS_TABLE . '
							WHERE ' . $db->sql_build_array('SELECT', $sql_array);
						$result = $db->sql_query($sql);
						$row = $db->sql_fetchrow($result);
						$db->sql_freeresult($result);
						
						$rid = $row['user_id'];
					}
...
FIND

Code: Select all

'EMAIL_CONFIRM'		=> $data['email_confirm'],
ADD AFTER

Code: Select all

'REFERRER'			=> $data['referrer'] ? $data['referrer'] : $referrer,
------------------------
language/en/common.php
FIND

Code: Select all

'REFERRALS' => 'Referrals',
ADD AFTER

Code: Select all

	'REFERRER'	=> 'Referrer',
	'NO_REFFERER_WITH_NAME'	=> 'Referral: No user with that username',
-------------------------
styles/NAME(prosilver)/template/ucp_register.html
FIND

Code: Select all

	<dl>
		<dt><label for="tz">{L_TIMEZONE}:</label></dt>
		<dd><select name="tz" id="tz" tabindex="6" class="autowidth">{S_TZ_OPTIONS}</select></dd>
	</dl>
ADD ABOVE

Code: Select all

	<dl>
		<dt><label for="referrer">{L_REFERRER}:</label></dt>
		<dd><input type="text" tabindex="5" name="referrer" id="referrer" size="25" maxlength="50" value="{REFERRER}" class="inputbox autowidth" title="{L_REFERRER}" /></dd>
	</dl>

	<hr />

The last edit to the template is purely up to you where you put it, My registration form is heavly modded now so the above 'FIND' may not work for you.

I believe thats all the modifications I made, If anyone has any problems, Just say, i may have missed something, I'm pritty tired :)

-Qwertyip
P.S. Great Mod, Thanks.. Just what i was looking for :)
Do you think you can alter this for subsilver as well? THIS was something I overlooked before I installed mod, and you pretty much made it come full circle. If you could convert this to subsilver, I would be so greatful!

boolee
Registered User
Posts: 10
Joined: Wed Mar 13, 2013 12:19 pm

Re: [DEV] Referral MOD With Contests

Post by boolee » Fri Mar 22, 2013 12:50 pm

Please help, need to make something like this.

http://prntscr.com/xc08v

When you click on the icon gets copy-paste this code ...

Code: Select all

<a href="http://www.erepublik.com/en/referrer/Boolee" target="_blank" > <img src="http://erepublik.com/images/badges/erepublik-badge-125x80.gif"></a>
How get from mysql a referrer link. I packed it all in on the bb code in a post on Forum

boolee
Registered User
Posts: 10
Joined: Wed Mar 13, 2013 12:19 pm

Re: [DEV] Referral MOD With Contests

Post by boolee » Fri Mar 22, 2013 11:18 pm

Please anyone help me , please.

wooting
Registered User
Posts: 2
Joined: Tue Mar 26, 2013 10:26 pm

Re: [DEV] Referral MOD With Contests

Post by wooting » Tue Mar 26, 2013 10:32 pm

hi Siropu,

i love the screenshots and i want to use your mod(ver 1.1.4).. but when i install it using automod i end up in this

"The MOD requires an external installer to finish installation. Click here to continue to that step."

when i click it it tells me

"Not Found
The requested URL /Array was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

im new to this, im using phpbb3 3.0.11 prosilver
Please give advice..

thank you

User avatar
Siropu
Registered User
Posts: 155
Joined: Mon Nov 16, 2009 6:15 pm
Location: Romania
Contact:

Re: [DEV] Referral MOD With Contests

Post by Siropu » Wed Mar 27, 2013 11:14 am

wooting wrote:when i install it using automod i end up in this

"The MOD requires an external installer to finish installation. Click here to continue to that step."

when i click it it tells me

"Not Found
The requested URL /Array was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
I don't know why, but sometimes that happens.

Run the installer by going to:

Code: Select all

your-board-url/referral_mod_install.php
Check out my MODs.

yf_pro
Registered User
Posts: 73
Joined: Sat Feb 16, 2013 4:59 am

Re: [DEV] Referral MOD With Contests

Post by yf_pro » Wed Apr 03, 2013 5:31 am

Good mod!

Quick question. I have tested this invite friends function using any email in the box. So basically it uses forum email to send invitations on behalf of whatever emails you typed in the "your email" box. I tested with my emails and random emails that dont exist. they seem to work but then my email provider would blacklist the makeup emails in junk folder.

Basically my major concern with this function is if I use my personal emails to invite friends (100 people), would my forum email or personal email get blacklisted? Thats usually what they do when an email repeatedly sends over multiple recipient.

User avatar
Siropu
Registered User
Posts: 155
Joined: Mon Nov 16, 2009 6:15 pm
Location: Romania
Contact:

Re: [DEV] Referral MOD With Contests

Post by Siropu » Wed Apr 03, 2013 1:25 pm

I don't think your email will get blacklisted if you send invitations to multiple recipients. Try it and see for yourself. In case it does happen, ask your friends to mark the email as "not spam".
Check out my MODs.

yf_pro
Registered User
Posts: 73
Joined: Sat Feb 16, 2013 4:59 am

Re: [DEV] Referral MOD With Contests

Post by yf_pro » Wed Apr 03, 2013 10:25 pm

the point is this mod use forum's admin email to send invitation so if its gets blacklisted it will affect registration emails, pm notification emails and etc dont you think?

User avatar
Siropu
Registered User
Posts: 155
Joined: Mon Nov 16, 2009 6:15 pm
Location: Romania
Contact:

Re: [DEV] Referral MOD With Contests

Post by Siropu » Wed Apr 03, 2013 10:53 pm

No, it uses the email specified by the member who sent the invitation.
Check out my MODs.

yf_pro
Registered User
Posts: 73
Joined: Sat Feb 16, 2013 4:59 am

Re: [DEV] Referral MOD With Contests

Post by yf_pro » Thu Apr 04, 2013 3:33 pm

Not really, it sends email using forum admin email on behalf of whatever email you put in the box so technically it uses forum domain email.

User avatar
Siropu
Registered User
Posts: 155
Joined: Mon Nov 16, 2009 6:15 pm
Location: Romania
Contact:

Re: [DEV] Referral MOD With Contests

Post by Siropu » Thu Apr 04, 2013 4:40 pm

Have you looked at the email headers in your email account? The "from:" header is the email address specified by the one who sent the invitation, not the board email address.
yf_pro wrote:Not really, it sends email using forum admin email on behalf of whatever email you put in the box so technically it uses forum domain email.
This happens when you email a member or when the forum sends email notifications (new PM, new reply, etc) and that has nothing to do with this MOD.
Check out my MODs.

User avatar
Geolim4
Former Team Member
Posts: 1965
Joined: Sat Sep 11, 2010 3:28 pm
Location: Nantes, France
Name: Georges
Contact:

Re: [DEV] Referral MOD With Contests

Post by Geolim4 » Thu Apr 04, 2013 8:15 pm

Hello,
Look good with some suggestions:
  • subsilver2.xml should be in contrib folder (linked from/to main XML install)
  • Images from your mod in /images folder should be placed in a dedicated subfolder like ./images/rmwc/ for avoid any conflict :)
  • language\en\mods\info_ucp_referral.php

    Code: Select all

    	'NO_REFERRALS'       => 'You don\'t have any referrals yet.',
    Escaped quote is no longer allowed following phpbb's guideline :)
    Use the special quote instead: :mrgreen:
  • includes\acp\acp_referral.php

    Code: Select all

    		                $template->assign_vars(array(
    			                'VIEW_STATS'  => true,
                                )
    		                );
    You can use the simple method for single assigned var:

    Code: Select all

    $template->assign_var('VIEW_STATS', true);

    Code: Select all

    			            WHERE username="' . $search_referrer . '" AND user_referrals >=1 ORDER BY user_referrals DESC';
    (Many similar occurrences found)
    You just forgot to use $db->sql_escapd($data) in your query

    Code: Select all

    			            WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') AND user_referrals >=1 ORDER BY user_referrals DESC';
    (Many similar occurrences found)
    You can use sql_in_set method here:

    Code: Select all

    			            WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)). ' AND user_referrals >=1 ORDER BY user_referrals DESC';
    (Many similar occurrences found)

    Code: Select all

    			                WHERE referrer_id=' . $rid;
    Here also $rid should be casted using (int) ;)
    (Many similar occurrences found)
  • includes\ucp\ucp_referral.php

    Code: Select all

    				$subject      = utf8_normalize_nfc(request_var('subject',''));
    				$message      = utf8_normalize_nfc(request_var('message',''));
    When you call utf8_normalize_nfc() the third parameter of request_var() should be trye (multibytes)

    Code: Select all

    					    $template->assign_vars(array(
    			                'FORM_ERROR'      => true,
    		                ));
    Here can be used as single vars too.
Otherwise, great mod :)
phpBB-fr Former MOD Team Leader / Website Team Member

Locked

Return to “[3.0.x] Abandoned MODs”

Who is online

Users browsing this forum: No registered users and 14 guests