3) {
$phone_list=$locations_info[3];
}
}
if ($_POST['email'] == "" || !strpos($_POST['email'], "@")) {
$from_email = $email_list;
} else {
$from_email = $_POST['email'];
}
if(!(empty($name) || empty($phone) || empty($from_email) || empty($location)) && strlen(trim($name)) != 0 && strlen(trim($email)) != 0){
$canSend = true;
$recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify'; // URL to the reCAPTCHA server
$recaptcha_secret = '6LelbGQqAAAAACb0NoS-FZyFeZAJ2TJfDzgY-rxX'; // Secret key
$recaptcha_response = $_POST['g-recaptcha-response']; // Response from reCAPTCHA server, added to the form during processing
$recaptcha = file_get_contents($recaptcha_url.'?secret='.$recaptcha_secret.'&response='.$recaptcha_response); // Send request to the server
$recaptcha = json_decode($recaptcha); // Decode the JSON response
$recaptcha_score = strval($recaptcha->score);
if ($recaptcha->score <= .5 || $recaptcha->score > 1) {
$canSend = false;
$response = "
There was an error processing the form, please try again
";
}
if(!validateParams($_POST)){
$canSend = false;
$response = "
Please remove any HTML tags or URLs from your information.
";
}
if(!compareParams(Array($email, $name, $phone, $year, $make, $model, $questions))){
$canSend = false;
$response = "
There were errors on the form. Please check your information for duplicate entries.
";
}
$params = array (
1 => array("value" => $name, "length" => 40),
array("value" => $email, "length" => 40),
array("value" => $phone, "length" => 20),
array("value" => $year, "length" => 4),
array("value" => $make, "length" => 40),
array("value" => $model, "length" => 40));
if(!checkLength($params)){
$canSend = false;
$response = "
There were errors on the form. Please fill in all required fields.
";
}
if(!empty($year) && !is_numeric($year)) {
$canSend = false;
$response = "
Please enter a valid year.
";
}
if(!validatePhone($phone)) {
$canSend = false;
$response = "
Please enter a valid phone number.
";
}
if(!validateMyURL($my_url)) {
$canSend = false;
$response = "
There were errors on the form.
";
}
if(validateParamsForBlock($_POST)) {
$email_list="strickland@wingswept.com,allison.lehman@wingswept.com,danielle.key@wingswept.com";
}
if ($canSend) {
$emailParams = array (1 => array("header" => "Date:", "value" => $date),
array("header" => "From:", "value" => $name),
array("header" => "Email:", "value" => $email),
array("header" => "Phone:", "value" => $phone),
array("header" => "Year:", "value" => $year),
array("header" => "Make:", "value" => $make),
array("header" => "Model:", "value" => $model),
array("header" => "Questions:", "value" => $questions));
if (!file_exists('../formArchive')) {
mkdir('../formArchive', 0755, true);
}
$myfile = fopen("../formArchive/6654.txt", "a") or die("Unable to open file!");
$date = new DateTime();
$content = "";
$index = 0;
foreach($emailParams as $Key => $Value){
$content .= $emailParams[$Key]["header"] . " " . $emailParams[$Key]["value"] . "
";
$index = $Key;
}
foreach($_POST as $key =>$value){
if (!($key == "location" || $key == "name" || $key == "email" || $key == "phone" || $key == "year" || $key == "make" || $key == "model" || $key == "questions" || $key == "submit" || $key == "my_url" || $key == "g-recaptcha-response" || $key == "recaptchaScore" || $key == "recaptchaResponse" || $key == "captchaFormName" || $key == "recaptcha-v3-token" || $key == "captchaFormId")) {
$content .= $key . ": " . $value . "";
$emailParams[$index + 1]["header"] = $key . ": ";
$emailParams[$index + 1]["value"] = $value;
$index != 1;
}
}
$arr = array ('date'=>$date,'form'=>'Contact','content'=>$content,'locationId'=>$locationId,'recaptcha_score'=>$recaptcha_score);
$txt = json_encode($arr) . ", ";
fwrite($myfile, $txt);
fclose($myfile);
doEmail($email_list, "noreply@repairshopwebsites.com", "*** " . $subjectLocation . " WEBSITE CONTACT from " . $name . " ***", $emailParams, "
Thank You!
Someone will get back to you soon with a response.
" .
$additional_response);
if(strcmp("1", "1") == 0) {
$hoursStart = "13";
$hoursEnd = "20";
$currentHour = date('H');
$sendText = true;
if(!empty($hoursStart) && !empty($hoursEnd) && ($currentHour < $hoursStart || $currentHour >= $hoursEnd) ) {
$sendText = false;
// TODO: notify somebody send text is selected, but required fields may not be set in Edit
}
$date = new DateTime();
$summaryMsg = 'Full form submission data is available in your email.';
$textSummary = 'General Request Form Submission' . PHP_EOL;
$textSummary .= 'From: ' . $name . PHP_EOL;
$textSummary .= 'Phone: ' . $phone . PHP_EOL;
$textSummary .= 'Message: ' . $questions . PHP_EOL;
if ($sendText) {
$phone_list_array = explode(",",$phone_list);
foreach ($phone_list_array as $tmpPhone) {
mail($tmpPhone, "", $textSummary, "From: Repair Shop Websites
", '-fnoreply@repairshopwebsites.com');
mail($tmpPhone, "", $summaryMsg, "From: Repair Shop Websites ", '-fnoreply@repairshopwebsites.com');
}
} else {
if (!file_exists('../messageQueue')) {
mkdir('../messageQueue', 0755, true);
}
$date = new DateTime();
$timestamp = $date->getTimestamp();
$myfile = fopen("../messageQueue/6654.requestQuote." . $date->getTimestamp() . ".txt", "a") or die("Unable to open file!");
$textArr = array ('hoursStart'=>$hoursStart,'hoursEnd'=>$hoursEnd,'phoneList'=>$phone_list,'from'=>"Repair Shop Websites ",'textSummary'=>$textSummary, 'summaryMsg'=>$summaryMsg, 'content'=>$questions);
$textTxt = json_encode($textArr);
fwrite($myfile, $textTxt);
fclose($myfile);
}
}
} else {
print_form($response);
}
} else {
$response = "There are errors on the form. Please fill in all required fields.
";
print_form($response);
}
} else {
print_form("");
}
function print_form($error){
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$year = $_POST['year'];
$make = $_POST['make'];
$model = $_POST['model'];
$questions = $_POST['questions'];
}else{
$name = "";
$email = "";
$phone = "";
$year = "";
$make = "";
$model = "";
$questions = "";
}
$nameErr = "";
$emailErr = "";
$phoneErr = "";
//check for errors with form input values - if method = POST
if($_SERVER['REQUEST_METHOD'] == 'POST'){
if($name == null || strlen(trim($name)) == 0){ $nameErr = "*"; }
if($email == null || strlen(trim($email)) == 0){ $emailErr = "*"; }
if($phone == null || strlen($phone) == 0){ $phoneErr = "*"; }
}
$publickey = "6LcEdLwSAAAAAHp4MTljGMG_gBlPHPZ-Nu1RACUY";
$recap = recaptcha_get_html($publickey);
echo <<
END;
}//end print_form
?>