$value) {
ChromePhp::log($key, $value);
} */
//** /debug
if (!function_exists("dateDiff")) {
function dateDiff($dformat, $endDate, $beginDate) {
if ( ($beginDate=='') || ($endDate=='') ) return false ;
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
$end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
return $end_date - $start_date;
}
} // define dateDiff fn
include_once('./scripts/validation_functions.php') ;
//foreach ( $_POST as $k => $v ) echo "post $k => $v " ;
// form error array and messages
$FormError = array(
'contactNameErr' => 'Please enter a valid contact name.' ,
'emailErr' => 'Please enter a valid email address.' ,
'sourceErr' => 'Please specify the source of your referral.' ,
'addErr' => 'Please specify an address.' ,
'cityErr' => 'Please specify a city.' ,
'zipErr' => 'Please specify a zipcode.' ,
'phoneErr' => 'Please specify a phone number.' ,
'fromDateErr' => 'Please enter valid "From" dates for your trip.' ,
'toDateErr' => 'Please enter valid "To" dates for your trip.' ,
'dateErr' => 'The from and to dates specified are invalid.' ,
'logErr' => 'Error logging form information on server.'
) ;
// init and build indeces for each form POST validity check
$thisFormError = array() ;
foreach ( $FormError as $errName => $errString ) {
${$errName} = $errName ;
}
$onSubmit = false ;
$errEMail = '' ;
if (array_key_exists('submit', $_POST)) {
$onSubmit = true ;
// remove escape characters from POST array
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
}
// list expected fields
$expected = array("source", "sourceTxt", "contactName", "eMail", "Add1", "Add2", "City" , "State", "Zip", "phone", "ephone", "fromMonth", "fromDay", "fromYear", "toMonth", "toDay", "toYear", "nAdults", "nKids");
// set required fields
$required = array( "source", "contactName", "eMail", "Add1", "City" , "State", "Zip", "phone", "fromDate", "toDate");
// create empty array for any missing fields
$missing = array();
// assume that there is nothing suspect
$suspect = false;
// create a pattern to locate suspect phrases
$pattern = '/Content-Type:|Bcc:|Cc:/i';
// function to check for suspect phrases
function isSuspect($val, $pattern, &$suspect) {
// if the variable is an array, loop through each element
// and pass it recursively back to the same function
if (is_array($val)) {
foreach ($val as $item) {
isSuspect($item, $pattern, $suspect);
}
}
else {
// if one of the suspect phrases is found, set Boolean to true
if (preg_match($pattern, $val)) {
$suspect = true;
}
}
}
// check the $_POST array and any subarrays for suspect content
isSuspect($_POST, $pattern, $suspect);
if ($suspect) {
//debug echo " is suspect is true: $suspect ";
$mailSent = false;
unset($missing);
}
else {
// process the $_POST variables
foreach ($_POST as $key => $value) {
// assign to temporary variable and strip whitespace if not an array
$temp = is_array($value) ? $value : trim($value);
// assign to a variable of the same name as $key
if (in_array($key, $expected)) {
${$key} = $temp;
//debug echo " $key => $value" ;
} // elseif
// if empty and required, add to $missing array
if (empty($temp) && in_array($key, $required)) {
array_push($missing, $key);
}
} // foreach
} // else
// validate the email address
if (!empty($email)) {
if ( !verifyEmail($email) ) {
$mailSent = false;
// unset($missing); could reset onSubmit, then malicious attemp is assumed and no sticky form
$thisFormError[$emailErr] = $FormError['emailErr'] ;
}
} // if email not empty
// validate dates. Year not checked.
if (($fromMonth == 'none' ) || ($fromDay == 'none' )) $thisFormError [$fromDateErr] = $FormError['fromDateErr'] ;
if (($toMonth == 'none' ) || ($toDay == 'none' )) $thisFormError [$toDateErr] = $FormError['toDateErr'] ;
if ( !(isset($thisFormError[$fromDateErr])) && !(isset($thisFormError[$toDateErr]))) { // assemble date (leave time to implement db load later . '- 00:00:00'
$fromDate = $fromMonth . '/' . $fromDay . '/' . $fromYear ;
$toDate = $toMonth . '/' . $toDay . '/' . $toYear ;
//echo 'From date = ' . $fromDate . ' To date = ' . $toDate ;
/* if ( dateDiff('/', $toDate, $fromDate ) < 0 ) {
$thisFormError[$dateErr] = $FormError['dateErr'] ;
$datesSpecified = false ;
}
else {
$datesSpecified = true ;
} */
$datesSpecified = true ;
}
// go ahead only if not suspsect and all required fields OK
if ( empty($thisFormError) && empty($missing) ) { // !$suspect
$message = '';
$html_message = '';
$to_ = 'seawitchsailing@aol.com' ;
$to_admin = 'lizmcmahon@comcast.net' ; //'info@thequarrygroup.com' ;
$to_alt = 'susan@abedandbreakfastafloat.com' ;
$subject = 'AbnbA Reservation Request ' . $_SERVER['PHP_SELF'];
// build the message
$message = "\nA reservation request from AbnbA Server: " . $_SERVER['PHP_SELF'] . "\n\n" ;
$message .= "\nName: $contactName\n";
$message .= "Email: $eMail\n\n";
$message .= "Source of referral: $source \n\n";
if ( trim($sourceTxt) != '' ) $message .= "Additional source information: $sourceTxt \n";
$message .= "Address 1: $Add1\n";
if ( trim($Add2) != '' ) $message .= "Address 2: $Add2 \n";
$message .= "City: $City \n";
$message .= "State: $State \n";
$message .= "Zip/Postal: $Zip \n\n";
$message .= "Daytime Phone: $phone \n";
if ( isset($ephone) ) $message .= "Evening Phone: $ephone \n\n";
$message .= "Arrival Date: $fromDate \n";
$message .= "Departure Date: $toDate\n\n";
if ( isset($nAdults) ) $message .= "# of Adults: $nAdults \n";
if ( isset($nKids) ) $message .= "# of Children: $nKids \n";
$message .= "\nEnd of message.\n" ;
$message = wordwrap($message, 70);
// build the html message
$html_message = " A reservation request from AbnbA Server: " . $_SERVER['PHP_SELF'] . " " ;
$html_message .= " Name: $contactName ";
$html_message .= "Email: $eMail ";
$html_message .= "Source of referral: $source ";
if ( trim($sourceTxt) != '' ) $html_message .= "Additional source information: $sourceTxt ";
$html_message .= "Address 1: $Add1 ";
if ( trim($Add2) != '' ) $html_message .= "Address 2: $Add2 ";
$html_message .= "City: $City ";
$html_message .= "State: $State ";
$html_message .= "Zip/Postal: $Zip ";
$html_message .= "Daytime Phone: $phone ";
if ( isset($ephone) ) $html_message .= "Evening Phone: $ephone ";
$html_message .= "Arrival Date: $fromDate ";
$html_message .= "Departure Date: $toDate ";
if ( isset($nAdults) ) $html_message .= "# of Adults: $nAdults ";
if ( isset($nKids) ) $html_message .= "# of Children: $nKids ";
$html_message .= " End of message. " ;
require("./scripts/phpmailer.php");
$mail = new PHPMailer();
// $mail->Host = "alpha.specvest.com"; // 11.07.28 New mail server
$mail->Host = "abedandbreakfastafloat.com"; // 11.07.28 New mail server
$mail->From = "susan@abedandbreakfastafloat.com";
$mail->FromName = "ABnB Contact Form";
//$mail->AddAddress($to_admin,"AbnbAfloat Contact Form");
$mail->AddAddress($to_alt,"AbnbAfloath Recipient");
$mail->AddAddress($to,"AbnbAfloat Contact Form");
$mail->WordWrap = 70;
$mail->IsHTML(true);
$mail->Subject = $subject ;
$mail->Body = $html_message;
$mail->AltBody = $message;
$mail->IsSendmail();
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent sendmail/";
}
/*
$recipient = $to_admin ;
$subject = ' AbnbAfloat@aol.com Contact Form Mail.';
mail($recipient, $subject, $message, "From: AbnbAfloat@aol.com\r\nReply-To: 'AbnbAfloat@aol.com\r\nX-Mailer: DT_formmail");
$recipient = $to;
mail($recipient, $subject, $message, "From: AbnbAfloat@aol.com\r\nReply-To: 'AbnbAfloat@aol.com\r\nX-Mailer: DT_formmail");
$recipient = $to_alt ;
mail($recipient, $subject, $message, "From: AbnbAfloat@aol.com\r\nReply-To: 'AbnbAfloat@aol.com\r\nX-Mailer: DT_formmail");
//$recipient = $to;
$subject = 'Error on mail send: AbnbAfloat@aol.com Form';
$content = $message;
//mail($recipient, $subject, $message, "From: contact@seawitchsailingcharters.com\r\nReply-To: 'Sea Witch Admin\r\nX-Mailer: DT_formmail");
//}
//else {
//$thisFormError[$logErr] = "Message was sent sucessfully. We will be contacting you as soon as possible.";
//document.getElementById('mainFormQuote').reset();
//}
//$thisFormError[$logErr] = "There was an error on the server processing your request. Please send your information to AbnbAfloat@aol.com and we'll be happy to assist you!" ;
// log file for each submit
/* $fp = fopen("abnb_reservationsFormSubmit.txt", "a");
if ($fp) {
fwrite($fp, date("F j, Y, g:i a"));
fwrite($fp, $message);
fclose($fp);
}
else {
$thisFormError[$logErr] = $FormError['logErr'] ;
}
} */ // if no errors, attempt mail
}
header($_SERVER['PHP_SELF'] + '#mainFormQuote');
} // if POST
?>
Martha's Vineyard's A bed and breakfast Afloat
Our season is June 14th to Oct 12th . We are available by phone Monday - Friday from 9am to 4pm EST at 508-650-0466 or email (susan@abedandbreakfastafloat.com ) all winter long.
It's easy to request/confirm a reservation!
Check out our Calendar and select your dates
Complete the reservation request form below
To confirm your dates by credit card , please go to the Rates page and process your credit card for 50% of your stay.
We look forward to having you aboard A Bed and Breakfast Afloat!