include "_header.php";
drawHeader('Contact Us','');
function sanitize($txt){
  return trim(strip_tags(stripslashes($txt)));
}
$notice='';
if(!empty($_POST['subject']) && !empty($_POST['email']) && !empty($_POST['message'])){
    if(empty($_POST['cv']) || $_POST['cv']!='click'){
	print_r($_POST);
	print "
Sorry, your request could not be processed at this time
";
	include "_footer.php"; 
	exit;	
    }
    $to=$_VAR['SITE_CONTACT_EMAIL'];
    $_POST['subject']=sanitize($_POST['subject']);
    $_POST['email']=sanitize($_POST['email']);
    $_POST['message']=sanitize($_POST['message']);
    $_POST['name']=sanitize($_POST['name']);
    
    // send email to recipient
    $headers = "From: {$_POST['name']} <{$_POST['email']}>\r\n";
    $cpymsg=$_POST['message']."\n\n\n";
    $cpymsg.="THIS EMAIL WAS SENT VIA MAIL-FORM AT ".strtoupper($_SERVER['SERVER_NAME'])."\n";
    $cpymsg.="----------------------------------------------------------\n";
    $cpymsg.="SENDER INFORMATION \n";
    $cpymsg.="Name/Email:    {$_POST['name']} <{$_POST['email']}>\n";
    $cpymsg.="Host Name/IP:  ".$_SERVER['REMOTE_ADDR']." ".@gethostbyaddr($_SERVER['REMOTE_ADDR'])."\n";
    $cpymsg.="User Agent:    ".$_SERVER['HTTP_USER_AGENT']."\n";
    $cpymsg.="----------------------------------------------------------\n\n";
    
    if(preg_match('/Content-Type|MIME-Version|Transfer-Encoding/i',@implode('',$_POST))){
         die('
Sorry, Invalid Email Contents
');
    }
    mail($to,stripslashes('* GPP CONTACT FORM - '.$_POST['subject']),$cpymsg, $headers,"-f{$_POST['email']}");
    // send cc to recipient
    $headers = "From: webmaster@{$_SERVER['SERVER_NAME']}\r\n";
    $cpymsg=$_POST['message']."\n\n\n";
    $cpymsg.="COPY OF EMAIL SENT VIA MAIL-FORM AT ".strtoupper($_SERVER['SERVER_NAME'])."\n";
    $cpymsg.="----------------------------------------------------------\n";
    $cpymsg.="SENDER INFORMATION \n";
    $cpymsg.="Name/Email:    {$_POST['name']} <{$_POST['email']}>\n";
    $cpymsg.="Host Name/IP:  ".$_SERVER['REMOTE_ADDR']." ".@gethostbyaddr($_SERVER['REMOTE_ADDR'])."\n";
    $cpymsg.="User Agent:    ".$_SERVER['HTTP_USER_AGENT']."\n";
    $cpymsg.="----------------------------------------------------------\n\n";
    mail($_POST['email'],"CPY: ".stripslashes($_POST['subject']),$cpymsg,$headers);
    $notice='Thank You.  Your message has been sent.
A copy of the message was as also sent to the email address you supplied.';
    @syslog(LOG_NOTICE, "PHP-MAIL {$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}-{$_SERVER[REMOTE_ADDR]} {$_POST['email']} -> $to");
}
print "
";
startFrame('','100%');
print "";
if(!empty($notice)){
        print "$notice
";
   }
   
print "You may use the form below to contact us with any question you may have.";
if(empty($_VAR['SITE_CONTACT_EMAIL'])){
	print "
This site is not currently configured to display a contact email.  Website administrators should edit their website preferences.";
	endFrame();
	include "_footer.php";
	exit;
}
?>
 include "_footer.php"; ?>