<?php
  $to='contact@getthinapp.com';
  $messageSubject='Message Notification from GetThinApp';
  $confirmationSubject='ThinApp Receipt Confirmation';
  $confirmationBody="Your message was received and if it requires immediate attention someone will be in touch with you shortly. Thanks, Opinyun Team!";
  $email='';
  $body='';
  $displayForm=true;
  if ($_POST){
    $email=stripslashes($_POST['email']);
    $body=stripslashes($_POST['body']);
    // validate e-mail address
    $valid=eregi('^([0-9a-z]+[-._+&])*[0-9a-z]+@([-0-9a-z]+[.])+[a-z]{2,6}$',$email);
    $crack=eregi("(\r|\n)(to:|from:|cc:|bcc:)",$body);
    if ($email && $body && $valid && !$crack){
      if (mail($to,$messageSubject,$body,'From: '.$email."\r\n")
          && mail($email,$confirmationSubject,$confirmationBody.$body,'From:contact@getthinapp.com\r\nReply-To:'.$email."\r\n")){
        $displayForm=false;
?>
<p>
  Your message was successfully sent.
  In addition, a confirmation copy was sent to your e-mail address.
  Your message is shown below.
</p>
<?php
        echo '<p><strong>'.htmlspecialchars($body).'</strong></p>';
        echo '<br /><br />';
        echo '<a href="http:/getthinapp.com/contact" style="font-weight:bold; color:#0000ff;">Show the Contact Form again &raquo;</a>';
      }else{ // the messages could not be sent
?>
<p>
  Something went wrong when the server tried to send your message.
  This is usually due to a server error, and is probably not your fault.
  We apologize for any inconvenience.
</p>
<?php
      }
    }else if ($crack){ // cracking attempt
?>
<p><strong>
  Your message contained e-mail headers within the message body.
  This seems to be a cracking attempt and the message has not been sent.
</strong></p>
<?php
    }else{ // form not complete
?>
<p><strong>
  Your message could not be sent.
  You must include both a valid e-mail address and a message.
</strong></p>
<?php
    }
  }
  if ($displayForm){
?>

<center>
<div id="cta" style="display:none; border:1px solid #ccc; border-radius:10px; max-width:770px; width:auto; margin:0 auto; display:block;
box-sizing:border-box; -moz-box-sizing:border-box; -webkit-box-sizing:border-box; margin-left:20px; margin-right:20px;">
	<center style="font-size:17px; font-weight:300; padding:0 20px; color:#777; line-height:28px;">
		<span style="font-size:24px; font-weight:500; color:#ff6600;">Have an iPhone and want to see the base ThinApp (ie. uncustomized) + 
		iOS App Wrapper?</span><br />
		Just enter your email below &amp; we&rsquo;ll email you an invite to install (it on your phone) 
		the app we start each project from. 
	</center>
	<br />
	<div style="width:auto; max-width:320px; margin:0 auto;">
		<form action="/contact" method="post">
		 
				<label for="email" style="float:left; line-height:40px; display:none;">E-mail: </label>
			  
				<input type="text" name="email" id="email" placeholder="your email" 
				value="<?php echo htmlspecialchars($email); ?>" size="30" 
				style="border:1px solid #aaa; margin-bottom:10px; display:block; width:95%; padding:11px 7px;
				font-size:17px; font-weight:300;">
				<textarea name="body" id="body" rows="5" 
				style="display:none; width:90%; max-width:500px; margin-right:20px; padding:7px;">
				<?php echo htmlspecialchars($body); ?>
				</textarea>
				<button class="greensubmit" type="submit" style="max-width:270px; font-size:16px; font-weight:300">Submit</button>
				<div class="clear"></div>	      
		</form>
	</div>
</div>
</center>
<?php
  }
?>	
