<?php

// this page sends the email then forwards back to the contact page

$sendTo = array("john.body@thinkplace.com.au");


	if (get_magic_quotes_gpc() == 1) {
		$_GET = rem_magic_quotes($_GET);
		$_POST = rem_magic_quotes($_POST);
		$_COOKIE = rem_magic_quotes($_COOKIE);
	}

	function rem_magic_quotes($arr) {
		foreach ($arr as $key => $value) {
			if (is_array($value)) $cleaned_arr[$key] = rem_magic_quotes($value);
			else $cleaned_arr[$key] = stripslashes($value);
		}
		return $cleaned_arr;
	}    
	


	if (!empty($_POST))
	{
		// build the message

		$topic = "ThinkPlace website enquiry/comment";	

		if (empty($_POST['name'])) $_POST['name'] = "[not specified]";
		if (empty($_POST['company'])) $_POST['company'] = "[not specified]";
		if (empty($_POST['email'])) $_POST['email'] = "[not specified]";
		if (empty($_POST['phone'])) $_POST['phone'] = "[not specified]";
		if (empty($_POST['find'])) $_POST['find'] = "[not specified]";
		if (empty($_POST['subject'])) $_POST['subject'] = "[not specified]";
		if (empty($_POST['message'])) $_POST['message'] = "[not specified]";

		$message = "A website visitor has submitted a enquiry/comment via the website.

		Name: ".$_POST['name']."

		Company: ".$_POST['company']."

		Email: ".$_POST['email']."

		Phone: ".$_POST['phone']."

		Heard About: ".$_POST['find']."

		Subject: ".$_POST['subject']."

		Message: ".$_POST['message']."



		Sent from ".$_SERVER['REMOTE_ADDR']." at ". date("h:i:s A, D jS F, Y", mktime());



		$headers .= "From: ThinkPlace<noreply-website@thinkplace.com.au>\r \n";
		$headers .= "Message-ID: <". md5(rand(1,6500)) ."@thinkplace.com.au>\r \n";
		$headers .= "X-Sender: php-sendmail\n";
		$headers .= "X-Mailer: PHP\r \n"; //mailer
		$headers .= "X-Priority: 3\r \n"; //1 UrgentMessage, 3 Normal
		$headers .= "Return-Path: <noreply-website@thinkplace.com.au>\r \n";
		//Uncomment this to send html format
		$headers .= "Content-Type: text/plain; charset=iso-8859-1\r \n";	


		foreach ($sendTo as $k => $v)
		{
			mail($v, $topic, $message, $headers);
		}

	}




header("Location: ./contact_us.php?sent");
echo "<script type='text/javascript>
location.href = './contact_us.php?sent'
</script>";

echo "<p>Your comment was sent. Your browser was unable to return you to the previous page. <a href='./contact_us.html?sent'>Click here</a> to continue.</p>";

?>