/********************************************
* Page for emailing image URL to a 'friend' *
* *
* Brian Aitken, TheGlasgowStory, 0404 *
********************************************/
//disabled due to spammers using the script
/*
//check that inum passed, if not then display error
if(!$inum)
{
echo("
ErrorError, no image selected.
");
exit;
}
//check that image is available in the database
include("staff/connect.php");
$inum = htmlspecialchars($inum);
$checkinum = mysql_query("select count(*) from image where inum = '$inum' and keyadd = 'A'");
$checkinum = mysql_result($checkinum,0,0);
if($checkinum<1)
{
echo("ErrorError, image unavailable.
");
exit;
}
//get webtitle of the image
$title = mysql_query("select webtitle from image where inum = '$inum'");
$title = mysql_result($title,0,0);
//this bit will run if submit pressed
if($sent)
{
//check required fields contain info
if(!$to || !$from || !$name)
{
$error = "Problem sending email.
You must complete the boxes marked with a red asterisk (*) before the email can be sent.
";
unset($sent);
}
else
{
//add htmlspecialchars
$to = htmlspecialchars($to);
$name = htmlspecialchars($name);
$from = htmlspecialchars($from);
$msg = htmlspecialchars($msg);
if($msg)
$msg.="\n---\n";
$body = $msg.$name." found the image \"".stripslashes($title)."\" on www.theglasgowstory.com and thought you might like to see it.\n\nClick on the link below to view the image:\n\nhttp://www.theglasgowstory.com/image.php?inum=".$inum."\n\nThis email was sent to you from the www.theglasgowstory.com website.";
//send the email
mail($to, "TheGlasgowStory: ".stripslashes($title), stripslashes($body), "From: ".$name." <".$from.">");
$success=true;
$isip = session_is_registered("userip");
if (!$isip)
{
session_register("userip");
if (getenv(HTTP_X_FORWARDED_FOR))
$userip=getenv(HTTP_X_FORWARDED_FOR);
else
$userip=getenv(REMOTE_ADDR);
}
$now = date(U);
$log = mysql_query("insert into accesslog set ip = '$userip', uname = '$user', logdate = '$now',
actiontype = 'Email to Friend', details = '$inum'");
//now record sent info in DB
$insert = mysql_query("insert into imagemail set to_mail = '$to', from_name = '$name', from_mail = '$from', msg = '$msg', inum = '$inum', sentdate = '$now'");
if($success==true)
{
?>
Your Email has been sent
exit;
}
else
{
$error = "Problem sending email.
Unable to send your email at the moment. Please try again.
";
unset($sent);
}
}
}
if(!$sent)
{
?>
Email Image to a Friend
Email "" to a friend