PDA

View Full Version : Refer A Friend


NOJ75
02-11-2006, 10:12 AM
Hi all,

Can anyone create this, or does anyone know of an existing plugin. Have searched the depths of hell to try and find a refer a friend plugin for SD but to no avail.

Any one help?

Kind regards.

HeavyEddie
02-11-2006, 02:10 PM
What exactly are you looking for?

Are you looking to refer the general website or a news article or something else?

NOJ75
02-11-2006, 02:53 PM
Thanks for replying.

Im looking for an "Recommend This Site To A Friend" type of thing.
So my users can be presented with a form:

Your Name
Your Email
Your Friends Name
Your Friends Email
Message (this needs to be pre-set by me)

Ive tried some that are out there but with no joy. Hence needing an SD plugin version.

Regards

thomas
02-12-2006, 01:37 AM
You can search hotscripts.com for a refer a friend script.

I have used one before, which i have integrated with subdreamer, and if you check out my blog, there is the script in there.

HeavyEddie
02-12-2006, 01:59 AM
OK, this is quick... I hope it works for you. I modified the the contact plugin to do what you want.

Open /plugins/p6_contact_form/contactform.php and modify the following. Make sure you backup your original so you can fallback if you need to.

Find the follwowing...
**if(empty($_POST['p6_fullname']) OR empty($_POST['p6_useremail']) OR empty($_POST['p6_subject']) OR empty($_POST['p6_message']))
**{
****$errors[] = $language['empty_fields'];
**}

**if(!ereg("^([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $_POST['p6_useremail']))
**{
****$errors[] = $language['invalid_email'];
**}


Replace it with this...
//Change
****$_POST['p6_subject'] = $_POST['p6_yourname'] . " refered our website to you!";
****$_POST['p6_message'] = $_POST['p6_theirname'] . ', Bla Bla Bla Bla Bla';
****
**if(empty($_POST['p6_yourname']) OR empty($_POST['p6_youremail']) OR empty($_POST['p6_theirname']) OR empty($_POST['p6_theiremail']))
**{
****$errors[] = $language['empty_fields'];
**}

**if(!ereg("^([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $_POST['p6_youremail']))
**{
****$errors[] = $language['invalid_email'];
**}else if(!ereg("^([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $_POST['p6_theiremail']))
**{
****$errors[] = $language['invalid_email'];
****}
//End of Change

OK, now find this...
****$fullname**= unhtmlspecialchars($_POST['p6_fullname']);
****$useremail = unhtmlspecialchars($_POST['p6_useremail']);


Replace it with this...
//Change
****$fullname**= unhtmlspecialchars($_POST['p6_yourname']);
****$useremail = unhtmlspecialchars($_POST['p6_theiremail']);
//End of Change


OK, now find this...
**if($errors)
**{
****$email = array('fullname'**=> $_POST['p6_fullname'],
****************** 'useremail' => $_POST['p6_useremail'],
****************** 'subject'** => $_POST['p6_subject'],
****************** 'message'** => $_POST['p6_message']);
**}
**else
**{
****$email = array('fullname'**=> '',
****************** 'useremail' => '',
****************** 'subject'** => '',
****************** 'message'** => '');
**}

**echo '<form action="' . RewriteLink('index.php?categoryid=' . $categoryid . '&p6_action=sendemail') . '" method="post" enctype="multipart/form-data">

********<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
********<tr>
**********<td style="padding-bottom: 5px;" valign="top" width="100">' . $language['full_name'] . '</td>
**********<td style="padding-bottom: 5px;"><input ' . CheckForEmptyField($email['fullname'], $errors) . ' type="text" name="p6_fullname" value="' . $email['fullname'] . '" size="' . $inputsize . '" /></td>
********</tr>
********<tr>
**********<td style="padding-bottom: 5px;" valign="top" width="100">' . $language['your_email'] . '</td>
**********<td style="padding-bottom: 5px;"><input**' . CheckForEmptyField($email['useremail'], $errors) . ' type="text" name="p6_useremail" value="' . $email['useremail'] . '" size="' . $inputsize . '" /></td>
********</tr>
********<tr>
**********<td style="padding-bottom: 5px;" valign="top" width="100">' . $language['subject'] . '</td>
**********<td style="padding-bottom: 5px;"><input ' . CheckForEmptyField($email['subject'], $errors) . ' type="text" name="p6_subject" value="' . $email['subject'] . '" size="' . $inputsize . '" /></td>
********</tr>
********<tr>
**********<td style="padding-bottom: 5px;" valign="top" width="100">' . $language['message'] . '</td>
**********<td style="padding-bottom: 5px;"><textarea ' . CheckForEmptyField($email['message'], $errors) . ' name="p6_message" rows="10" cols="' . $inputsize . '">' . $email['message'] . '</textarea></td>
********</tr>';


Replace it with this...
//Change
**if($errors)
**{
****$email = array('yourname'******=> $_POST['p6_yourname'],
****************** 'youremail'**** => $_POST['p6_youremail'],
****************** 'theirname'**=> $_POST['p6_theirname'],
****************** 'theiremail' => $_POST['p6_theiremail']);
**}
**else
**{
****$email = array('yourname'******=> '',
****************** 'youremail'**** => '',
****************** 'theirname'**=> '',
****************** 'theiremail' => '');
**}

**echo '<form action="' . RewriteLink('index.php?categoryid=' . $categoryid . '&p6_action=sendemail') . '" method="post" enctype="multipart/form-data">

********<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
********<tr>
**********<td style="padding-bottom: 5px;" valign="top" width="100">' . 'Your name' . '</td>
**********<td style="padding-bottom: 5px;"><input ' . CheckForEmptyField($email['yourname'], $errors) . ' type="text" name="p6_yourname" value="' . $email['yourname'] . '" size="' . $inputsize . '" /></td>
********</tr>
********<tr>
**********<td style="padding-bottom: 5px;" valign="top" width="100">' . 'Your Email' . '</td>
**********<td style="padding-bottom: 5px;"><input**' . CheckForEmptyField($email['youremail'], $errors) . ' type="text" name="p6_youremail" value="' . $email['youremail'] . '" size="' . $inputsize . '" /></td>
********</tr>
********<tr>
**********<td style="padding-bottom: 5px;" valign="top" width="100">' . 'Their name' . '</td>
**********<td style="padding-bottom: 5px;"><input**' . CheckForEmptyField($email['theirname'], $errors) . ' type="text" name="p6_theirname" value="' . $email['theirname'] . '" size="' . $inputsize . '" /></td>
********</tr>
********<tr>
**********<td style="padding-bottom: 5px;" valign="top" width="100">' . 'Their Email' . '</td>
**********<td style="padding-bottom: 5px;"><input**' . CheckForEmptyField($email['theiremail'], $errors) . ' type="text" name="p6_theiremail" value="' . $email['theiremail'] . '" size="' . $inputsize . '" /></td>
********</tr>';
//End Changes

thomas
02-12-2006, 08:04 AM
awsome HeavyEddie.

Woudlnt it be easier, to make a new plugin called refer a friend.

awsome changes

HeavyEddie
02-12-2006, 01:11 PM
This really would be better as an independent plugin. I don't see any reason this wouldn't worked if the original were cloned. There really isn't that many changes in the code... I just felt in this case posting a few larger blocks would be easier that a bunch of small ones.

With a small table in the background you could track referals and ensure someone isn't getting hammered.

If someone else doesn't get to it first, I will put this on my list of projects.

72dpi
02-13-2006, 02:09 AM
Hi heavy,

I would love to work on this one with you, i really need a bitta help with plugins.

I quickly put this one together with an image verification to test:
http://www.72dpi.net.au/testbed/imageverify/poplink.php

It isn't a plugin for Subdreamer yet. i will look at your great code & implement a few of my code additions & see what i come up with.....

If ya want to point me in the right direction, i would love to create my first plugin for Subdreamer :P

HeavyEddie
02-13-2006, 10:35 AM
No problem... heck, it looks like you have the hard part done already :)

I just took apart small existing plugin and went from there. I think I used the breadcrumb navigator.

I started out by creating the install.php first. This allowed me to create the settings and db tables. It is pretty self explanitory.

When creating your primary php file I originally had a ton of problems figuring out what was available for use in terms of global variables and such. Use this (http://www.subdreamer.org/forum/index.php?showtopic=534) & this (http://www.subdreamer.org/forum/index.php?showtopic=514) blog entries... you will find them pretty darned handy.

So far, the only function I really struggled with is rewritelink... but I figured it out.

I will send you a pm with my IM information... anything I can do to help.

I hope one of the first things put in that new manual creator is a dummies guide to building your first plugin. I think it would encourge more people to build.

HeavyEddie
02-13-2006, 04:07 PM
I don't know about you folks... but I'm thinking it would be nice if code would slip into a scrollable window.

72dpi
02-13-2006, 11:43 PM
Cheers for the info Heavy,
I have created all parts for it so far, just going now & making the actual "mailamate" a single file, currently I use 2 files, one for working, one for checking. i will probnably make them case statements (keep it cleaner). the only thing i need to work out is the session variables (for the image generator)

Will work on it tonight.......... Cheers for the links, they are really useful!

IGGY
02-14-2006, 12:33 AM
Damn you guys are fast!