Had some time on my hands, so, wrote this little script. Rather simple, and should be relatively straightforward... All you need to do is save as tellafriend.php, functions.php and upload. Then link to it, like so:
PHP Code:
<a href="./tellafriend.php?ref=<?php echo $_SERVER['SCRIPT_NAME']; ?>">Tell a friend</a>
EDIT: Updated to v1.0.1 on June 7, 2006
For some reason, using HTTP_REFERER wouldn't work :s No idea atm, but the above ^^ is a little work-around
tellafriend.php
PHP Code:
<?php
/************************************************** **************************
*
* Author : Eric Sizemore ( www.secondversion.com )
* Package : SV's Tell-a-friend
* Version : 1.0.1
* Copyright: (C) 2005-2006 Eric Sizemore
* Site : www.secondversion.com
* Email : esizemore05@gmail.com
* File : tellafriend.php
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
************************************************** **************************/
// ####################### Define Important Constants #######################
// You'll need to change SITE_NAME, SUBJECT and optionally MSG_WORD_WRAP
define('IN_TAF', true);
define('SITE_NAME', 'YourSite.com');
define('SUBJECT', 'Hello friend! Thought you might be interested in ' . SITE_NAME);
define('MSG_WORD_WRAP', 75);
if (!is_valid_email($email) OR is_email_injection($email) OR !is_valid_email($femail) OR is_email_injection($femail))
{
echo '<br />Your email (or your friends) is either invalid or left blank. Please try again.';
}
else
{
$e = $email;
if ($send)
{
echo '<br />Thank you, ' . $name . ', for telling your friend about us.';
}
else
{
echo '<br />Seems to have been a problem sending the email. Please try again.';
}
}
}
}
// That's all folks!
?>
<p>Powered by <a href="http://www.secondversion.com">SVs Tell-a-friend v1.0.1</a></p>
</body>
</html>
functions.php
PHP Code:
<?php
/************************************************** **************************
*
* Author : Eric Sizemore ( www.secondversion.com )
* Package : SV's Tell-a-friend
* Version : 1.0.1
* Copyright: (C) 2005-2006 Eric Sizemore
* Site : www.secondversion.com
* Email : esizemore05@gmail.com
* File : functions.php
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
************************************************** **************************/
if (!defined('IN_TAF'))
{
die();
}
/*
Strip any unsafe tags/chars/attributes from input data
@param string Data to be cleaned
@param string Level or 'strength' of cleaning - default or light
pretty much the same, but one will remove new lines, and CRLF
@return string
*/
function sanitize($data, $strength)
{
switch ($strength)
{
case '':
case 'default':
$search = array('@<script[^>]*?>.*?</script>@si',
'@<applet[^>]*?>.*?</applet>@si',
'@<object[^>]*?>.*?</object>@si',
'@<iframe[^>]*?>.*?</iframe>@si',
'@<style[^>]*?>.*?</style>@si',
'@<form[^>]*?>.*?</form>@si',
'@<[\/\!]*?[^<>]*?>@si',
'@([\r\n])[\s]+@',
'@&(lt|#60);@i',
'@&(gt|#62);@i'
);
break;
case 'light':
$search = array('@<script[^>]*?>.*?</script>@si',
'@<applet[^>]*?>.*?</applet>@si',
'@<object[^>]*?>.*?</object>@si',
'@<iframe[^>]*?>.*?</iframe>@si',
'@<style[^>]*?>.*?</style>@si',
'@<form[^>]*?>.*?</form>@si',
'@<[\/\!]*?[^<>]*?>@si',
'@&(amp|#38);@i',
'@&(lt|#60);@i',
'@&(gt|#62);@i'
);
break;
}