<?php

function containsSpam($post_text)
   {
   $isSpam = FALSE;
   $arr = array("[/url]",
		"online pharmacy",
		"</",
		"http://",
		"cialis",
		"didrex",
		"levitra",
		"butalbital",
		"tramadol",
		"lortab",
		"diazepam",
		"adipex",
		"ephedrine",
		"xanax",
		"hydrocodone",
		"ultram",
		"propecia",
		"butalbital",
		"fioricet",
		"ambien",
		"viagra",
		"my site",
		"casino",
		"phentermine");

   foreach ($arr as $val) 
      {
      if (strstr($post_text,$val))
         {
         $isSpam = TRUE;
         break;
         }
      }

   return $isSpam;
   }

$title = "WebFu Contact Page";
$tagline = "Contact";
include "begin.php";

$submit_key = "Send Email";
if ($_POST['submitbutton'] == $submit_key)
  {
  $greg_email = "email@greghowley.com";
  $replyto = $_POST['email'];
  if ($replyto == ""){$replyto=$name;}
  $name = $_POST['name'];
  $subject = "Web Design Contact: " . $_POST['subject'];
  $body = $_POST['msg'];
  $extras = "From: $name\r\n" .
     "Reply-To: $replyto\r\n" .
     "X-Mailer: PHP/" . phpversion();

  if (containsSpam($body))
	{die("<p class=\"spaced\">Your email has been interpreted as spam.</p>");}
	 
  $success = mail ($greg_email, $subject, $body, $extras);
  if ($success)
    {
    echo("<p class=\"spaced\">Mail successfully sent.</p>");
	include "end.php";
	die();
    }
  else
    {
    die("<p class=\"spaced\">Error sending email. ($success)</p>");
    }
  }

//Move on - not submitted yet  
?>

<script type="text/javascript">
<!--
function validateSubmit()
  {
  if (document.forms['contactGreg'].name.value == '')
    {
    alert('Name is a required field');
    return false;
    }
  if (document.forms['contactGreg'].email.value == '')
    {
    return confirm('Without an email address, I will be unable to reply. Continue?');
    }
  if (document.forms['contactGreg'].msg.value == '')
    {
    alert('You did not enter a message!');
    return false;
    }
  }
-->
</script>

<div id="main" class="contact">

<div id="side">
You may contact Greg Howley using this form. <!--If you're interested in a quote for web design pricing, you may be better off using the <a href="http://webfu.greghowley.com/design#quote">Web Design Quotation Form</a>.-->
</div>

<div id="body_main">
	<form id="contactGreg" action="<?=$PHP_SELF?>" method="post">
	
	<div class="inpt_lbl">Name:</div>
	<input type="text" name="name" />
	
	<div class="inpt_lbl">EMail:</div>
	<input type="text" name="email" />
	
	<div class="inpt_lbl">Subject:</div>
	<input type="text" name="subject" />
	
	<textarea rows="12" cols="55" name="msg"></textarea>
	
	<input class="submit" name="submitbutton" type="submit" value="<?=$submit_key?>" onclick="return validateSubmit()" />
	</form>
</div> <!-- end form holder -->

</div> <!-- end main -->
<?php include "end.php"; ?>






