<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
   if (isset($_POST['captcha_code'],$_SESSION['random_txt']) && md5($_POST['captcha_code']) == $_SESSION['random_txt'])
   {
      unset($_POST['captcha_code'],$_SESSION['random_txt']);
   }
   else
   {
      $errorcode = file_get_contents('./Contact_Us_Failure.html');
      $replace = "##error##";
      $errorcode = str_replace($replace, 'The entered code was wrong.', $errorcode);
      echo $errorcode;
      exit;
   }
}
?>
<?php
   function ValidateEmail($email)
   {
      $pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
      return preg_match($pattern, $email);
   }

   if($_SERVER['REQUEST_METHOD'] == 'POST')
   {
      $mailto = 'mark@srbeach.co.uk';
      $mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
      $subject = 'Sao Rafael Beach Request';
      $message = 'Values submitted from web site form:';
      $success_url = './Contact_Us_Success.html';
      $error_url = './Contact_Us_Failure.html';
      $error = '';
      $eol = "\n";
      $max_filesize = isset($_POST['filesize']) ? $_POST['filesize'] * 1024 : 1024000;
      $boundary = md5(uniqid(time()));

      $header  = 'From: '.$mailfrom.$eol;
      $header .= 'Reply-To: '.$mailfrom.$eol;
      $header .= 'MIME-Version: 1.0'.$eol;
      $header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
      $header .= 'X-Mailer: PHP v'.phpversion().$eol;
      if (!ValidateEmail($mailfrom))
      {
         $error .= "The specified email address is invalid!\n<br>";
      }

      if (!empty($error))
      {
         $errorcode = file_get_contents($error_url);
         $replace = "##error##";
         $errorcode = str_replace($replace, $error, $errorcode);
         echo $errorcode;
         exit;
      }

      $internalfields = array ("submit", "reset", "send", "captcha_code");
      $message .= $eol;
      $message .= "IP Address : ";
      $message .= $_SERVER['REMOTE_ADDR'];
      $message .= $eol;
      foreach ($_POST as $key => $value)
      {
         if (!in_array(strtolower($key), $internalfields))
         {
            if (!is_array($value))
            {
               $message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
            }
            else
            {
               $message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
            }
         }
      }

      $body  = 'This is a multi-part message in MIME format.'.$eol.$eol;
      $body .= '--'.$boundary.$eol;
      $body .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
      $body .= 'Content-Transfer-Encoding: 8bit'.$eol;
      $body .= $eol.stripslashes($message).$eol;
      if (!empty($_FILES))
      {
          foreach ($_FILES as $key => $value)
          {
             if ($_FILES[$key]['error'] == 0 && $_FILES[$key]['size'] <= $max_filesize)
             {
                $body .= '--'.$boundary.$eol;
                $body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
                $body .= 'Content-Transfer-Encoding: base64'.$eol;
                $body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
                $body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol;
             }
         }
      }
      $body .= '--'.$boundary.'--'.$eol;
      mail($mailto, $subject, $body, $header);
      header('Location: '.$success_url);
      exit;
   }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Contact</title>
<meta name="generator" content="WYSIWYG Web Builder - http://www.wysiwygwebbuilder.com">
<style type="text/css">
div#container
{
   width: 768px;
   position: relative;
   margin-top: 0px;
   margin-left: auto;
   margin-right: auto;
   text-align: left;
}
body
{
   text-align: center;
   margin: 0;
   background-color: #9D9D9D;
   color: #000000;
}
</style>
<style type="text/css">
a
{
   color: #0000FF;
   outline: none;
   text-decoration: underline;
}
a:visited
{
   color: #800080;
}
a:active
{
   color: #FF0000;
}
a:hover
{
   color: #376BAD;
   text-decoration: underline;
}
</style>
<style type="text/css">
#Image1
{
   border: 0px #000000 solid;
}
#Image2
{
   border: 0px #000000 solid;
}
#Image4
{
   border: 0px #000000 solid;
}
#Image7
{
   border: 0px #000000 solid;
}
#wb_Text1 
{
   background-color: transparent;
   border: 0px #000000 solid;
   padding: 0;
}
#wb_Text1 div
{
   text-align: center;
}
#wb_Form1
{
   background-color: #FAFAFA;
   border: 0px #000000 solid;
}
#wb_Text2 
{
   background-color: transparent;
   border: 0px #000000 solid;
   padding: 0;
}
#wb_Text2 div
{
   text-align: left;
}
#Editbox1
{
   border: 1px #C0C0C0 solid;
   background-color: #FFFFFF;
   color :#000000;
   font-family: Arial;
   font-size: 13px;
   text-align: left;
   vertical-align: middle;
}
#wb_Text3 
{
   background-color: transparent;
   border: 0px #000000 solid;
   padding: 0;
}
#wb_Text3 div
{
   text-align: left;
}
#Editbox2
{
   border: 1px #C0C0C0 solid;
   background-color: #FFFFFF;
   color :#000000;
   font-family: Arial;
   font-size: 13px;
   text-align: left;
   vertical-align: middle;
}
#Button1
{
   color: #000000;
   font-family: Arial;
   font-size: 13px;
}
#wb_Text5 
{
   background-color: transparent;
   border: 0px #000000 solid;
   padding: 0;
}
#wb_Text5 div
{
   text-align: left;
}
#Captcha1Edit
{
   border: 1px #C0C0C0 solid;
   background-color: #FFFFFF;
   color :#000000;
   font-family: Arial;
   font-size: 13px;
   text-align: left;
   vertical-align: middle;
}
#wb_Text6 
{
   background-color: transparent;
   border: 0px #000000 solid;
   padding: 0;
}
#wb_Text6 div
{
   text-align: left;
}
#TextArea1
{
   border: 1px #C0C0C0 solid;
   background-color: #FFFFFF;
   color :#000000;
   font-family: Arial;
   font-size: 13px;
   text-align: left;
}
#wb_Text4 
{
   background-color: transparent;
   border: 0px #000000 solid;
   padding: 0;
}
#wb_Text4 div
{
   text-align: left;
}
</style>
</head>
<body>
<div id="container">
<div id="wb_Image1" style="position:absolute;left:1px;top:783px;width:1059px;height:53px;z-index:9;padding:0;">
<img src="images/BOTTOM_01.GIF" id="Image1" alt="" border="0" style="width:1059px;height:53px;"></div>
<div id="wb_Image2" style="position:absolute;left:0px;top:214px;width:1060px;height:42px;z-index:10;padding:0;">
<img src="images/BG_MENU_01.JPG" id="Image2" alt="" border="0" style="width:1060px;height:42px;"></div>
<div id="wb_Image4" style="position:absolute;left:0px;top:255px;width:1060px;height:527px;z-index:11;padding:0;">
<img src="images/bg_content_01.gif" id="Image4" alt="" border="0" style="width:1060px;height:527px;"></div>
<div id="wb_Image7" style="position:absolute;left:0px;top:0px;width:1060px;height:214px;z-index:12;padding:0;">
<img src="images/TOP_02.JPG" id="Image7" alt="" border="0" style="width:1060px;height:214px;"></div>
<div id="wb_Image10" style="position:absolute;left:639px;top:4px;width:206px;height:162px;z-index:13;padding:0;">
<img src="images/img0220.png" id="Image10" alt="" border="0" style="width:206px;height:162px;"></div>
<div id="wb_Image8" style="position:absolute;left:505px;top:38px;width:198px;height:146px;z-index:14;padding:0;">
<img src="images/img0221.png" id="Image8" alt="" border="0" style="width:198px;height:146px;"></div>
<div id="wb_Image9" style="position:absolute;left:352px;top:7px;width:218px;height:218px;z-index:15;padding:0;">
<img src="images/img0222.png" id="Image9" alt="" border="0" style="width:218px;height:218px;"></div>
<div id="wb_Image12" style="position:absolute;left:803px;top:0px;width:202px;height:156px;z-index:16;padding:0;">
<img src="images/img0223.png" id="Image12" alt="" border="0" style="width:202px;height:156px;"></div>
<div id="wb_Image11" style="position:absolute;left:860px;top:71px;width:193px;height:129px;z-index:17;padding:0;">
<img src="images/img0224.png" id="Image11" alt="" border="0" style="width:193px;height:129px;"></div>
<div id="wb_Extension1" style="position:absolute;left:85px;top:213px;width:160px;height:29px;z-index:18;padding:0;">
<script language="JavaScript" type="text/javascript">
<!--
GlassButton15 = new Image();
GlassButton15.src = "images/img0225_hover.png";
//-->
</script>
<a href="./Apartment.html">
<img src="images/img0225.png" id="GlassButton15" width="160" height="29" alt="The Apartment" border="0" onMouseOver="this.src='images/img0225_hover.png'" onMouseOut="this.src='images/img0225.png'">
</a>
</div>
<div id="wb_Extension4" style="position:absolute;left:240px;top:213px;width:160px;height:29px;z-index:19;padding:0;">
<script language="JavaScript" type="text/javascript">
<!--
GlassButton17 = new Image();
GlassButton17.src = "images/img0226_hover.png";
//-->
</script>
<a href="./Facilities.html">
<img src="images/img0226.png" id="GlassButton17" width="160" height="29" alt="Facilities" border="0" onMouseOver="this.src='images/img0226_hover.png'" onMouseOut="this.src='images/img0226.png'">
</a>
</div>
<div id="wb_Extension2" style="position:absolute;left:396px;top:213px;width:160px;height:29px;z-index:20;padding:0;">
<script language="JavaScript" type="text/javascript">
<!--
GlassButton10 = new Image();
GlassButton10.src = "images/img0227_hover.png";
//-->
</script>
<a href="./Attractions.html">
<img src="images/img0227.png" id="GlassButton10" width="160" height="29" alt="Local Attractions" border="0" onMouseOver="this.src='images/img0227_hover.png'" onMouseOut="this.src='images/img0227.png'">
</a>
</div>
<div id="wb_Extension3" style="position:absolute;left:84px;top:241px;width:160px;height:29px;z-index:21;padding:0;">
<script language="JavaScript" type="text/javascript">
<!--
GlassButton16 = new Image();
GlassButton16.src = "images/img0228_hover.png";
//-->
</script>
<a href="./Availability.html">
<img src="images/img0228.png" id="GlassButton16" width="160" height="29" alt="Availability" border="0" onMouseOver="this.src='images/img0228_hover.png'" onMouseOut="this.src='images/img0228.png'">
</a>
</div>
<div id="wb_Extension5" style="position:absolute;left:240px;top:241px;width:160px;height:29px;z-index:22;padding:0;">
<script language="JavaScript" type="text/javascript">
<!--
GlassButton18 = new Image();
GlassButton18.src = "images/img0229_hover.png";
//-->
</script>
<a href="./Prices.html">
<img src="images/img0229.png" id="GlassButton18" width="160" height="29" alt="Prices" border="0" onMouseOver="this.src='images/img0229_hover.png'" onMouseOut="this.src='images/img0229.png'">
</a>
</div>
<div id="wb_Extension6" style="position:absolute;left:396px;top:241px;width:160px;height:29px;z-index:23;padding:0;">
<script language="JavaScript" type="text/javascript">
<!--
GlassButton19 = new Image();
GlassButton19.src = "images/img0230_hover.png";
//-->
</script>
<a href="./Flights.html">
<img src="images/img0230.png" id="GlassButton19" width="160" height="29" alt="Flights" border="0" onMouseOver="this.src='images/img0230_hover.png'" onMouseOut="this.src='images/img0230.png'">
</a>
</div>
<div id="wb_Extension7" style="position:absolute;left:552px;top:213px;width:160px;height:29px;z-index:24;padding:0;">
<script language="JavaScript" type="text/javascript">
<!--
GlassButton20 = new Image();
GlassButton20.src = "images/img0231_hover.png";
//-->
</script>
<a href="./Beaches.html">
<img src="images/img0231.png" id="GlassButton20" width="160" height="29" alt="Beaches" border="0" onMouseOver="this.src='images/img0231_hover.png'" onMouseOut="this.src='images/img0231.png'">
</a>
</div>
<div id="wb_Extension8" style="position:absolute;left:552px;top:241px;width:160px;height:29px;z-index:25;padding:0;">
<script language="JavaScript" type="text/javascript">
<!--
GlassButton21 = new Image();
GlassButton21.src = "images/img0232_hover.png";
//-->
</script>
<a href="./Transfers.html">
<img src="images/img0232.png" id="GlassButton21" width="160" height="29" alt="Airport Transfers" border="0" onMouseOver="this.src='images/img0232_hover.png'" onMouseOut="this.src='images/img0232.png'">
</a>
</div>
<div id="wb_Extension9" style="position:absolute;left:706px;top:213px;width:160px;height:29px;z-index:26;padding:0;">
<script language="JavaScript" type="text/javascript">
<!--
GlassButton22 = new Image();
GlassButton22.src = "images/img0233_hover.png";
//-->
</script>
<a href="./Eating.html">
<img src="images/img0233.png" id="GlassButton22" width="160" height="29" alt="Eating Out" border="0" onMouseOver="this.src='images/img0233_hover.png'" onMouseOut="this.src='images/img0233.png'">
</a>
</div>
<div id="wb_Extension10" style="position:absolute;left:863px;top:213px;width:160px;height:29px;z-index:27;padding:0;">
<script language="JavaScript" type="text/javascript">
<!--
GlassButton23 = new Image();
GlassButton23.src = "images/img0234_hover.png";
//-->
</script>
<a href="./Maps.html">
<img src="images/img0234.png" id="GlassButton23" width="160" height="29" alt="Local Maps" border="0" onMouseOver="this.src='images/img0234_hover.png'" onMouseOut="this.src='images/img0234.png'">
</a>
</div>
<div id="wb_Extension11" style="position:absolute;left:706px;top:241px;width:160px;height:29px;z-index:28;padding:0;">
<script language="JavaScript" type="text/javascript">
<!--
GlassButton24 = new Image();
GlassButton24.src = "images/img0235_hover.png";
//-->
</script>
<a href="./Downloads.html">
<img src="images/img0235.png" id="GlassButton24" width="160" height="29" alt="Downloads" border="0" onMouseOver="this.src='images/img0235_hover.png'" onMouseOut="this.src='images/img0235.png'">
</a>
</div>
<div id="wb_Extension12" style="position:absolute;left:862px;top:241px;width:160px;height:29px;z-index:29;padding:0;">
<script language="JavaScript" type="text/javascript">
<!--
GlassButton25 = new Image();
GlassButton25.src = "images/img0236_hover.png";
//-->
</script>
<a href="./Contact.html">
<img src="images/img0236.png" id="GlassButton25" width="160" height="29" alt="Contact Us" border="0" onMouseOver="this.src='images/img0236_hover.png'" onMouseOut="this.src='images/img0236.png'">
</a>
</div>
<img src="images/img0237.png" align="top" alt="" title="" border="0" width="316" height="153" style="position:absolute;left:16px;top:30px;width:316px;height:153px;z-index:30">
<div id="wb_Text1" style="position:absolute;left:88px;top:69px;width:155px;height:72px;text-align:center;z-index:31;">
<span style="color:#000080;font-family:Verdana;font-size:16px;letter-spacing:1px;"><strong>Sao Rafael Beach Resort<br><br>Apartment 34b</strong></span></div>
<div id="wb_Form1" style="position:absolute;left:87px;top:334px;width:835px;height:318px;z-index:32;">
<form name="contact" method="post" action="<?php echo basename(__FILE__); ?>" enctype="multipart/form-data" id="Form1">
<div id="wb_Text2" style="position:absolute;left:18px;top:16px;width:69px;height:16px;z-index:0;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Name:</span></div>
<input type="text" id="Editbox1" style="position:absolute;left:172px;top:15px;width:198px;height:23px;line-height:23px;z-index:1;" name="name" value="">
<div id="wb_Text3" style="position:absolute;left:19px;top:46px;width:69px;height:16px;z-index:2;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Email:</span></div>
<input type="text" id="Editbox2" style="position:absolute;left:172px;top:45px;width:198px;height:23px;line-height:23px;z-index:3;" name="email" value="">
<div id="wb_Text5" style="position:absolute;left:14px;top:197px;width:148px;height:16px;z-index:4;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Please enter password :</span></div>
<div id="wb_Captcha1" style="position:absolute;left:170px;top:188px;width:198px;height:36px;z-index:5;padding:0;">
<img src="captcha1.php" alt="Click for new image" title="Click for new image" style="cursor:pointer;width:100px;height:38px;" onclick="this.src='captcha1.php?'+Math.random()">
<input type="text" id="Captcha1Edit" style="position:absolute;left:105px;top:16px;width:98px;height:20px;line-height:20px;;" name="captcha_code" value=""></div>
<div id="wb_Text6" style="position:absolute;left:16px;top:75px;width:69px;height:16px;z-index:6;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Comments</span></div>
<textarea name="TextArea1" id="TextArea1" style="position:absolute;left:172px;top:78px;width:198px;height:98px;z-index:7;" rows="5" cols="27"></textarea>
<input type="submit" id="Button1" name="" value="Send" style="position:absolute;left:176px;top:257px;width:96px;height:25px;z-index:8;">
</form>
</div>
<div id="wb_Text4" style="position:absolute;left:90px;top:285px;width:561px;height:22px;z-index:33;">
<span style="color:#00008B;font-family:Arial;font-size:19px;"><u>Please feel free to contact us with any query or booking request</u></span></div>
</div>
</body>
</html>