Location: PHPKode > projects > Spam free PHP GuestBook > Spam free PHP GuestBook-1.2beta/gb/mail.php
<?php
session_start();
if(!(isset($_SESSION['fw_user']))||($_SESSION['fw_user']!==md5($_SERVER['REMOTE_ADDRESS']))){
echo '<h1>Your session has been expired!</h1><p>Please <a href="../index.php">Click here</a>to start a new session.</p>';
exit;}
include "include/functions.php";
include "include/connection.php";
$db=new connection('');
$blocksite=$db->siteinf('blocksite');
if($blocksite=='Y'){exit;}
$allowemail=$db->siteinf('allowemail');
if($allowemail!='Y'){echo '<h1>Email system disabled</h1><p>Email system has been disabled by the administrator.</p>'; exit;}
if(empty($_POST['uid'])){include "include/contactform.php";}
else{
$id=$_POST['uid'];
$subject=trim(fw_strip_slashes(rawurldecode($_POST['subject'])));
$from=trim(fw_strip_slashes(rawurldecode($_POST['from'])));
$message=trim(fw_strip_slashes(rawurldecode($_POST['message'])));
$message=fw_remove_smarttag($message);
$message.="\n\n--------------------------------------\n\nThis message is sent from http://".getenv('HTTP_HOST')."/\n";
$message.="Sender I.P. ".$_SERVER['REMOTE_ADDRESS'];
$message.="\nIf you do not want to receive any further email from this site please login to your user control panel and uncheck \"Receive email\" option.\n";
$message.="http://".getenv('HTTP_HOST').fw_get_docroot()."gb/user/index.php";
$verify=trim(fw_strip_slashes(rawurldecode($_POST['verify'])));
if((empty($_SESSION['fw_email_code']))||(md5($verify)!==($_SESSION['fw_email_code']))){
echo '<span style="color:red; background-color:white;">Error! wrong verification code. Please try again.</span>';
exit;}
unset($_SESSION['fw_email_code']);
$prefix=$db->get_prefix();
$query=sprintf("SELECT name, email FROM ".$prefix."user WHERE id=%d AND allowemail = 'Y'",$id);
$result = @mysql_query($query);
$num=@mysql_num_rows($result);
if($num<1){echo '<span style="color:red; background-color:white;">Sorry! unable to sent message.</span>';exit;}
$row = @mysql_fetch_array($result, MYSQL_ASSOC);
if(@mail($row['email'],$subject, $message, 'From: '.$from)){echo '<span style="color:green">Message has been successfully sent.</span>';}
else{echo '<span style="color:red">System error! please try again later.</span>';}
}
?>
Return current item: Spam free PHP GuestBook