<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
&lt;?<br>
/*<br>
##############################################################################<br>
# PLEASE DO NOT REMOVE THIS HEADER!!!<br>
#<br>
# COPYRIGHT NOTICE<br>
#<br>
# FormMail.php v5.0<br>
# Copyright 2000-2004 Ai Graphics and Joe Lumbroso (c) All rights reserved.<br>
# Created 07/06/2000 Last Modified 10/28/2003<br>
# Joseph Lumbroso, http://www.aigraphics.com, http://www.dtheatre.com<br>
# http://www.dtheatre.com/scripts/<br>
##############################################################################<br>
#<br>
# This cannot and will not be inforced but I would appreciate a link back<br>
# to any of these sites:<br>
# http://www.dtheatre.com<br>
# http://www.aigraphics.com<br>
# http://www.dtheatre.com/scripts/<br>
#<br>
# THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
# OTHER DEALINGS IN THE SOFTWARE.<br>
#<br>
##############################################################################<br>
*/
<p>// for ultimate security, use this instead of using the form<br>
  $recipient = &quot;captdick@naturalcharters.com&quot;; // youremail@naturalcharters.com</p>
<p>// bcc emails (separate multiples with commas (,))<br>
  $bcc = &quot;rich@naturalcharters.com&quot;;</p>
<p>// referers.. domains/ips that you will allow forms to<br>
  // reside on.<br>
  $referers = array ('naturalcharters.com', 'www.naturalcharters.com');</p>
<p>// banned emails, these will be email addresses of people<br>
  // who are blocked from using the script (requested)<br>
  // $banlist = array ('*@somedomain.com', 'user@domain.com', 'etc@domains.com');</p>
<p>// field / value seperator<br>
  define(&quot;SEPARATOR&quot;, ($separator)?$separator:&quot;: &quot;);</p>
<p>// content newline<br>
  define(&quot;NEWLINE&quot;, ($newline)?$newline:&quot;\n&quot;);</p>
<p>// formmail version (for debugging mostly)<br>
  define(&quot;VERSION&quot;, &quot;5.0&quot;);<br>
</p>
<p>// our mighty error function..<br>
  function print_error($reason,$type = 0) {<br>
  build_body($title, $bgcolor, $text_color, $link_color, $vlink_color, $alink_color, $style_sheet);<br>
  // for missing required data<br>
  if ($type == &quot;missing&quot;) {<br>
  if ($missing_field_redirect) {<br>
  header(&quot;Location: $missing_field_redirect?error=$reason&quot;);<br>
  exit;<br>
  } else {<br>
  ?&gt;<br>
  The form was not submitted for the following reasons:&lt;p&gt;<br>
&lt;ul&gt;&lt;?<br>
  echo $reason.&quot;\n&quot;;<br>
  ?&gt;&lt;/ul&gt;<br>
  Please use your browser's back button to return to the form and try again.&lt;?<br>
  }<br>
  } else { // every other error<br>
  ?&gt;<br>
  The form was not submitted because of the following reasons:&lt;p&gt;<br>
&lt;?<br>
  }<br>
  echo &quot;&lt;br&gt;&lt;br&gt;\n&quot;;<br>
  echo &quot;&lt;small&gt;This form is powered by &lt;a href=\&quot;http://www.dtheatre.com/scripts/\&quot;&gt;Jack's Formmail.php &quot;.VERSION.&quot;/a&gt;&lt;/small&gt;\n\n&quot;;<br>
  exit;<br>
  }</p>
<p>// function to check the banlist<br>
  // suggested by a whole lot of people.. Thanks<br>
  function check_banlist($banlist, $email) {<br>
  if (count($banlist)) {<br>
  $allow = true;<br>
  foreach($banlist as $banned) {<br>
  $temp = explode(&quot;@&quot;, $banned);<br>
  if ($temp[0] == &quot;*&quot;) {<br>
  $temp2 = explode(&quot;@&quot;, $email);<br>
  if (trim(strtolower($temp2[1])) == trim(strtolower($temp[1])))<br>
  $allow = false;<br>
  } else {<br>
  if (trim(strtolower($email)) == trim(strtolower($banned)))<br>
  $allow = false;<br>
  }<br>
  }<br>
  }<br>
  if (!$allow) {<br>
  print_error(&quot;You are using from a &lt;b&gt;banned email address.&lt;/b&gt;&quot;);<br>
  }<br>
  }</p>
<p>// function to check the referer for security reasons.<br>
  // contributed by some one who's name got lost.. Thanks<br>
  // goes out to him any way.<br>
  function check_referer($referers) {<br>
  if (count($referers)) {<br>
  $found = false;</p>
<p> $temp = explode(&quot;/&quot;,getenv(&quot;HTTP_REFERER&quot;));<br>
  $referer = $temp[2];<br>
  <br>
  if ($referer==&quot;&quot;) {$referer = $_SERVER['HTTP_REFERER'];<br>
  list($remove,$stuff)=split('//',$referer,2);<br>
  list($home,$stuff)=split('/',$stuff,2);<br>
  $referer = $home;<br>
  }<br>
  <br>
  for ($x=0; $x &lt; count($referers); $x++) {<br>
  if (eregi ($referers[$x], $referer)) {<br>
  $found = true;<br>
  }<br>
  }<br>
  if ($referer ==&quot;&quot;)<br>
  $found = false;<br>
  if (!$found){<br>
  print_error(&quot;You are coming from an &lt;b&gt;unauthorized domain.&lt;/b&gt;&quot;);<br>
  error_log(&quot;[FormMail.php] Illegal Referer. (&quot;.getenv(&quot;HTTP_REFERER&quot;).&quot;)&quot;, 0);<br>
  }<br>
  return $found;<br>
  } else {<br>
  return true; // not a good idea, if empty, it will allow it.<br>
  }<br>
  }<br>
  if ($referers)<br>
  check_referer($referers);</p>
<p>if ($banlist)<br>
  check_banlist($banlist, $email);</p>
<p>// This function takes the sorts, excludes certain keys and <br>
  // makes a pretty content string.<br>
  function parse_form($array, $sort = &quot;&quot;) {<br>
  // build reserved keyword array<br>
  $reserved_keys[] = &quot;MAX_FILE_SIZE&quot;;<br>
  $reserved_keys[] = &quot;required&quot;;<br>
  $reserved_keys[] = &quot;redirect&quot;;<br>
  $reserved_keys[] = &quot;require&quot;;<br>
  $reserved_keys[] = &quot;path_to_file&quot;;<br>
  $reserved_keys[] = &quot;recipient&quot;;<br>
  $reserved_keys[] = &quot;subject&quot;;<br>
  $reserved_keys[] = &quot;sort&quot;;<br>
  $reserved_keys[] = &quot;style_sheet&quot;;<br>
  $reserved_keys[] = &quot;bgcolor&quot;;<br>
  $reserved_keys[] = &quot;text_color&quot;;<br>
  $reserved_keys[] = &quot;link_color&quot;;<br>
  $reserved_keys[] = &quot;vlink_color&quot;;<br>
  $reserved_keys[] = &quot;alink_color&quot;;<br>
  $reserved_keys[] = &quot;title&quot;;<br>
  $reserved_keys[] = &quot;missing_fields_redirect&quot;;<br>
  $reserved_keys[] = &quot;env_report&quot;;<br>
  $reserved_keys[] = &quot;submit&quot;;<br>
  if (count($array)) {<br>
  if (is_array($sort)) {<br>
  foreach ($sort as $field) {<br>
  $reserved_violation = 0;<br>
  for ($ri=0; $ri&lt;count($reserved_keys); $ri++)<br>
  if ($array[$field] == $reserved_keys[$ri]) $reserved_violation = 1;</p>
<p> if ($reserved_violation != 1) {<br>
  if (is_array($array[$field])) {<br>
  for ($z=0;$z&lt;count($array[$field]);$z++)<br>
  $content .= $field.SEPARATOR.$array[$field][$z].NEWLINE;<br>
  } else<br>
  $content .= $field.SEPARATOR.$array[$field].NEWLINE;<br>
  }<br>
  }<br>
  }<br>
  while (list($key, $val) = each($array)) {<br>
  $reserved_violation = 0;<br>
  for ($ri=0; $ri&lt;count($reserved_keys); $ri++)<br>
  if ($key == $reserved_keys[$ri]) $reserved_violation = 1;</p>
<p> for ($ri=0; $ri&lt;count($sort); $ri++)<br>
  if ($key == $sort[$ri]) $reserved_violation = 1;</p>
<p> // prepare content<br>
  if ($reserved_violation != 1) {<br>
  if (is_array($val)) {<br>
  for ($z=0;$z&lt;count($val);$z++)<br>
  $content .= $key.SEPARATOR.$val[$z].NEWLINE;<br>
  } else<br>
  $content .= $key.SEPARATOR.$val.NEWLINE;<br>
  }<br>
  }<br>
  }<br>
  return $content;<br>
  }</p>
<p>// mail the content we figure out in the following steps<br>
  function mail_it($content, $subject, $email, $recipient) {<br>
  global $attachment_chunk, $attachment_name, $attachment_type, $attachment_sent, $bcc;</p>
<p> $ob = &quot;----=_OuterBoundary_000&quot;;<br>
  $ib = &quot;----=_InnerBoundery_001&quot;;<br>
  <br>
  $headers = &quot;MIME-Version: 1.0\r\n&quot;; <br>
  $headers .= &quot;From: &quot;.$email.&quot;\n&quot;; <br>
  $headers .= &quot;To: &quot;.$recipient.&quot;\n&quot;; <br>
  $headers .= &quot;Reply-To: &quot;.$email.&quot;\n&quot;;<br>
  if ($bcc) $headers .= &quot;Bcc: &quot;.$bcc.&quot;\n&quot;; <br>
  $headers .= &quot;X-Priority: 1\n&quot;; <br>
  $headers .= &quot;X-Mailer: DT Formmail&quot;.VERSION.&quot;\n&quot;; <br>
  $headers .= &quot;Content-Type: multipart/mixed;\n\tboundary=\&quot;&quot;.$ob.&quot;\&quot;\n&quot;;<br>
  <br>
  <br>
  $message = &quot;This is a multi-part message in MIME format.\n&quot;;<br>
  $message .= &quot;\n--&quot;.$ob.&quot;\n&quot;;<br>
  $message .= &quot;Content-Type: multipart/alternative;\n\tboundary=\&quot;&quot;.$ib.&quot;\&quot;\n\n&quot;;<br>
  $message .= &quot;\n--&quot;.$ib.&quot;\n&quot;;<br>
  $message .= &quot;Content-Type: text/plain;\n\tcharset=\&quot;iso-8859-1\&quot;\n&quot;;<br>
  $message .= &quot;Content-Transfer-Encoding: quoted-printable\n\n&quot;;<br>
  $message .= $content.&quot;\n\n&quot;;<br>
  $message .= &quot;\n--&quot;.$ib.&quot;--\n&quot;;<br>
  if ($attachment_name &amp;&amp; !$attachment_sent) {<br>
  $message .= &quot;\n--&quot;.$ob.&quot;\n&quot;;<br>
  $message .= &quot;Content-Type: $attachment_type;\n\tname=\&quot;&quot;.$attachment_name.&quot;\&quot;\n&quot;;<br>
  $message .= &quot;Content-Transfer-Encoding: base64\n&quot;;<br>
  $message .= &quot;Content-Disposition: attachment;\n\tfilename=\&quot;&quot;.$attachment_name.&quot;\&quot;\n\n&quot;;<br>
  $message .= $attachment_chunk;<br>
  $message .= &quot;\n\n&quot;;<br>
  $attachment_sent = 1;<br>
  }<br>
  $message .= &quot;\n--&quot;.$ob.&quot;--\n&quot;;<br>
  <br>
  mail($recipient, $subject, $message, $headers);<br>
  }</p>
<p>// take in the body building arguments and build the body tag for page display<br>
  function build_body($title, $bgcolor, $text_color, $link_color, $vlink_color, $alink_color, $style_sheet) {<br>
  if ($style_sheet)<br>
  echo &quot;&lt;LINK rel=STYLESHEET href=\&quot;$style_sheet\&quot; Type=\&quot;text/css\&quot;&gt;\n&quot;;<br>
  if ($title)<br>
  echo &quot;&lt;title&gt;$title&lt;/title&gt;\n&quot;;<br>
  if (!$bgcolor)<br>
  $bgcolor = &quot;#FFFFFF&quot;;<br>
  if (!$text_color)<br>
  $text_color = &quot;#000000&quot;;<br>
  if (!$link_color)<br>
  $link_color = &quot;#0000FF&quot;;<br>
  if (!$vlink_color)<br>
  $vlink_color = &quot;#FF0000&quot;;<br>
  if (!$alink_color)<br>
  $alink_color = &quot;#000088&quot;;<br>
  if ($background)<br>
  $background = &quot;background=\&quot;$background\&quot;&quot;;<br>
  echo &quot;&lt;body bgcolor=\&quot;$bgcolor\&quot; text=\&quot;$text_color\&quot; link=\&quot;$link_color\&quot; vlink=\&quot;$vlink_color\&quot; alink=\&quot;$alink_color\&quot; $background&gt;\n\n&quot;;<br>
  }</p>
<p>// check for a recipient email address and check the validity of it<br>
  // Thanks to Bradley miller (bradmiller@accesszone.com) for pointing<br>
  // out the need for multiple recipient checking and providing the code.<br>
  $recipient_in = split(',',$recipient);<br>
  for ($i=0;$i&lt;count($recipient_in);$i++) {<br>
  $recipient_to_test = trim($recipient_in[$i]);<br>
  if (!eregi(&quot;^[_\\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\\.)+[a-z]{2,6}$&quot;, $recipient_to_test)) {<br>
  print_error(&quot;b&gt;I NEED VALID RECIPIENT EMAIL ADDRESS ($recipient_to_test) TO CONTINUE&lt;/b&gt;&quot;);<br>
  }<br>
  }</p>
<p>// This is because I originally had it require but too many people<br>
  // were used to Matt's Formmail.pl which used required instead.<br>
  if ($required)<br>
  $require = $required;<br>
  // handle the required fields<br>
  if ($require) {<br>
  // seperate at the commas<br>
  $require = ereg_replace( &quot; +&quot;, &quot;&quot;, $require);<br>
  $required = split(&quot;,&quot;,$require);<br>
  for ($i=0;$i&lt;count($required);$i++) {<br>
  $string = trim($required[$i]);<br>
  // check if they exsist<br>
  if((!(${$string})) || (!(${$string}))) {<br>
  // if the missing_fields_redirect option is on: redirect them<br>
  if ($missing_fields_redirect) {<br>
  header (&quot;Location: $missing_fields_redirect&quot;);<br>
  exit;<br>
  }<br>
  $require;<br>
  $missing_field_list .= &quot;&lt;b&gt;Missing: $required[$i]&lt;/b&gt;&lt;br&gt;\n&quot;;<br>
  }<br>
  }<br>
  // send error to our mighty error function<br>
  if ($missing_field_list)<br>
  print_error($missing_field_list,&quot;missing&quot;);<br>
  }</p>
<p>// check the email fields for validity<br>
  if (($email) || ($EMAIL)) {<br>
  $email = trim($email);<br>
  if ($EMAIL) $email = trim($EMAIL);<br>
  if (!eregi(&quot;^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,6}$&quot;, $email))<br>
  print_error(&quot;your b&gt;email address&lt;/b&gt; is invalid&quot;);<br>
  $EMAIL = $email;<br>
  }</p>
<p>// check zipcodes for validity<br>
  if (($ZIP_CODE) || ($zip_code)) {<br>
  $zip_code = trim($zip_code);<br>
  if ($ZIP_CODE) $zip_code = trim($ZIP_CODE);<br>
  if (!ereg(&quot;(^[0-9]{5})-([0-9]{4}$)&quot;, trim($zip_code)) &amp;&amp; (!ereg(&quot;^[a-zA-Z][0-9][a-zA-Z][[:space:]][0-9][a-zA-Z][0-9]$&quot;, trim($zip_code))) &amp;&amp; (!ereg(&quot;(^[0-9]{5})&quot;, trim($zip_code))))<br>
  print_error(&quot;your &lt;b&gt;zip/postal code&lt;/b&gt; is invalid&quot;);<br>
  }</p>
<p>// check phone for validity<br>
  if (($PHONE_NO) || ($phone_no)) {<br>
  $phone_no = trim($phone_no);<br>
  if ($PHONE_NO) $phone_no = trim($PHONE_NO);<br>
  if (!ereg(&quot;(^(.*)[0-9]{3})(.*)([0-9]{3})(.*)([0-9]{4}$)&quot;, $phone_no))<br>
  print_error(&quot;your &lt;b&gt;phone number&lt;/b&gt; is invalid&quot;);<br>
  }</p>
<p>// check phone for validity<br>
  if (($FAX_NO) || ($fax_no)) {<br>
  $fax_no = trim($fax_no);<br>
  if ($FAX_NO) $fax_no = trim($FAX_NO);<br>
  if (!ereg(&quot;(^(.*)[0-9]{3})(.*)([0-9]{3})(.*)([0-9]{4}$)&quot;, $fax_no))<br>
  print_error(&quot;your &lt;b&gt;fax number&lt;/b&gt; is invalid&quot;);<br>
  }</p>
<p>// sort alphabetic or prepare an order<br>
  if ($sort == &quot;alphabetic&quot;) {<br>
  uksort($HTTP_POST_VARS, &quot;strnatcasecmp&quot;);<br>
  } elseif ((ereg('^order:.*,.*', $sort)) &amp;&amp; ($list = explode(',', ereg_replace('^order:', '', $sort)))) {<br>
  $sort = $list;<br>
  }<br>
  <br>
  // prepare the content<br>
  $content = parse_form($HTTP_POST_VARS, $sort);</p>
<p>// check for an attachment if there is a file upload it<br>
  if ($attachment_name) {<br>
  if ($attachment_size &gt; 0) {<br>
  if (!$attachment_type) $attachment_type = &quot;application/unknown&quot;;<br>
  $content .= &quot;Attached File: &quot;.$attachment_name.&quot;\n&quot;;<br>
  $fp = fopen($attachment, &quot;r&quot;);<br>
  $attachment_chunk = fread($fp, filesize($attachment));<br>
  $attachment_chunk = base64_encode($attachment_chunk);<br>
  $attachment_chunk = chunk_split($attachment_chunk);<br>
  }<br>
  }</p>
<p>// check for a file if there is a file upload it<br>
  if ($file_name) {<br>
  if ($file_size &gt; 0) {<br>
  if (!ereg(&quot;/$&quot;, $path_to_file))<br>
  $path_to_file = $path_to_file.&quot;/&quot;;<br>
  $location = $path_to_file.$file_name;<br>
  if (file_exists($path_to_file.$file_name))<br>
  $location = $path_to_file.rand(1000,3000).&quot;.&quot;.$file_name;<br>
  copy($file,$location);<br>
  unlink($file);<br>
  $content .= &quot;Uploaded File: &quot;.$location.&quot;\n&quot;;<br>
  }<br>
  }</p>
<p>// second file (see manual for instructions on how to add more.)<br>
  if ($file2_name) {<br>
  if ($file_size &gt; 0) {<br>
  if (!ereg(&quot;/$&quot;, $path_to_file))<br>
  $path_to_file = $path_to_file.&quot;/&quot;;<br>
  $location = $path_to_file.$file2_name;<br>
  if (file_exists($path_to_file.$file2_name))<br>
  $location = $path_to_file.rand(1000,3000).&quot;.&quot;.$file2_name;<br>
  copy($file2,$location);<br>
  unlink($file2);<br>
  $content .= &quot;Uploaded File: &quot;.$location.&quot;\n&quot;;<br>
  }<br>
  }</p>
<p>// if the env_report option is on: get eviromental variables<br>
  if ($env_report) {<br>
  $env_report = ereg_replace( &quot; +&quot;, &quot;&quot;, $env_report);<br>
  $env_reports = split(&quot;,&quot;,$env_report);<br>
  $content .= &quot;\n------ eviromental variables ------\n&quot;;<br>
  for ($i=0;$i&lt;count($env_reports);$i++) {<br>
  $string = trim($env_reports[$i]);<br>
  if ($env_reports[$i] == &quot;REMOTE_HOST&quot;)<br>
  $content .= &quot;REMOTE HOST: &quot;.$REMOTE_HOST.&quot;\n&quot;;<br>
  if ($env_reports[$i] == &quot;REMOTE_USER&quot;)<br>
  $content .= &quot;REMOTE USER: &quot;. $REMOTE_USER.&quot;\n&quot;;<br>
  if ($env_reports[$i] == &quot;REMOTE_ADDR&quot;)<br>
  $content .= &quot;REMOTE ADDR: &quot;. $REMOTE_ADDR.&quot;\n&quot;;<br>
  if ($env_reports[$i] == &quot;HTTP_USER_AGENT&quot;)<br>
  $content .= &quot;BROWSER: &quot;. $HTTP_USER_AGENT.&quot;\n&quot;;<br>
  }<br>
  }</p>
<p>// send it off<br>
  mail_it(stripslashes($content), ($subject)?stripslashes($subject):&quot;Form Submission&quot;, $email, $recipient);<br>
  if (file_exists($ar_file)) {<br>
  $fd = fopen($ar_file, &quot;rb&quot;);<br>
  $ar_message = fread($fd, filesize($ar_file));<br>
  fclose($fd);<br>
  mail_it($ar_message, ($ar_subject)?stripslashes($ar_subject):&quot;RE: Form Submission&quot;, ($ar_from)?$ar_from:$recipient, $email);<br>
  }</p>
<p>// if the redirect option is set: redirect them<br>
  if ($redirect) {<br>
  header(&quot;Location: $redirect&quot;);<br>
  exit;<br>
  } else {<br>
  echo &quot;Thank you for your submission\n&quot;;<br>
  echo &quot;&lt;br&gt;&lt;br&gt;\n&quot;;<br>
  echo &quot;&lt;small&gt;This form is powered by &lt;a href=\&quot;http://www.dtheatre.com/scripts/\&quot;&gt;Jack's Formmail.php &quot;.VERSION.&quot;!&lt;/a&gt;&lt;/small&gt;\n\n&quot;;<br>
  exit;<br>
  }</p>
<p>// &lt;---------- THE END ----------&gt; // </p>

</body>
</html>
