/*
Mail This To A Friend
by Colin Ferm
v 1.0
5/10/00
Page requires inputs for item id (the feature being commented on), table
(the table the feature belongs to), and the url to return the user to.
This page will then resubmit to it's self and then redirect to the page
from which they came.
id = id
url = redirected url
HISTORY
01/12/01 Changed all DB refrences to dbInterface object, changed
text page from newspage.phtml to article.phtml.
06/07/01 Added references to validation object and removed what
what was there.
*/
/*
Below sets up the pages variables, the title, the title text, the text that
needs to change with validation, and whatnot. Of most interest is the content
query that is written to be generic and work with both flicks and tunes
based on the table passed in the "cat" variable.
*/
require($DOCUMENT_ROOT."/libs/constants.inc");
require($DOCUMENT_ROOT."/classes/userObjects.inc");
$privs = new userPermissions();
$layout = new spudCore(0, 0);
if ($privs->isLoggedIn()) {
$user_name = $privs->getName();
$user_email = $privs->getEmail();
}
$page_title = "P R O P A G A N D A";
$buttonText = "S E N D";
$errorMsg = "";
$pass = 1;
$contentQuery = "SELECT sn.title, sn.blurb, snc.id AS section FROM spud_news sn, spud_news_category snc, spud_news_map snm WHERE sn.id = $id AND sn.id = snm.news_id AND snm.category_id = snc.id";
$feature_data = new dbInterface($DB_NAME, $DB_USER, $DB_PASS, $contentQuery);
$feature = $feature_data->getRow();
$feature["url"] = $SITEURL.'article/'.$id.'/'.$feature["section"].'/';
$userNameText = "Your Name:";
$userEmailText = "Your Email:";
$friendEmailText = "Friend's Email:";
$messageText = "Message";
// If the submit button was pushed the folowing happens.
if ($submit == $buttonText) {
// Validation for the message field. Fails on empty string.
$valObj = new validation();
$valObj->check_field("Comment", $message_body, 1, ALPHANUM_PUNCT, 1, 1000);
$valObj->check_field("Your Name", $user_name, 1, ALPHANUM_PUNCT, 1, 30);
$valObj->check_field("Your Email", $user_email, 1, EMAIL, 2, 35);
$friendsEmail = split (',', $to_email);
for ($i = 0; $i <= end($friendsEmail); $i++) {
$valObj->check_field("Friend's Email", $friendsEmail[$i], 1, EMAIL, 2, 35);
}
//$valObj->check_field("Friend's Email", $to_email, 1, EMAIL, 2, 35);
// If the data passes validation
if ($valObj->num_errors() == 0) {
$message = ereg_replace("\\\\", "", $message_body);
$subject = 'A '.$SITENAME.' Recomendation';
$body = $user_name.' thought you might find "'.$feature["title"]."\" stimulating:\n\n\"".$message."\"\n\n".$feature["blurb"]."\n\nSee more at:\n".$feature["url"].$MAIL_FOOTER;
$mail_result = mail($to_email, $subject, $body, "From: $user_name <$user_email>\nReply-To: $user_email\nBcc: colin@lavconsulting.com\n\n");
if ($mail_result) {
header ("Location: ".$feature["url"]."\n\n");
exit;
} else {
$errorMsg .= 'Email did not get sent';
error_log("The Email did not get sent.\n$user_email", 1, $erroremail);
}
}
}
eval($layout->getLayout('Header', 'Standard'));
?>
echo($page_title); ?>
Have a friend, or hell, an enemy that you want to send this to because they'll either love it, or it'll drive them wild? Send it on! We don't mind. You're doing our work for us, and we'll love you more than any other site, if you'll do it.