| Build Rate: | ";
$itemLabel3 = "| Main Bedroom: | ";
$itemLabel4 = "
| Ensuite: | ";
$itemLabel5 = "
| Walk-in Dresser: | ";
$itemLabel6 = "
| Bedroom (1): | ";
$itemLabel7 = "
| Ensuite (1): | ";
$itemLabel8 = "
| Walk-in Dresser (1): | ";
$itemLabel9 = "
| Bedroom (2): | ";
$itemLabel10 = "
| Ensuite (2): | ";
$itemLabel11 = "
| Walk-in Dresser (2): | ";
$itemLabel12 = "
| Study: | ";
$itemLabel13 = "
| General Bathroom (full): | ";
$itemLabel14 = "
| Guest Loo: | ";
$itemLabel15 = "
| Lounge / Living: | ";
$itemLabel16 = "
| Dining: | ";
$itemLabel17 = "
| Entertainment: | ";
$itemLabel18 = "
| Kitchen: | ";
$itemLabel19 = "
| Scullery: | ";
$itemLabel20 = "
| Pantry: | ";
$itemLabel21 = "
| Outbuilding: | ";
$itemLabel22 = "
| Carport: | ";
$itemLabel23 = "
| Garage: | ";
$itemPoolLabel = "
| Pool: | ";
$blankLine = "
|
";
$totalLabel1 = "
| Total Area: | ";
$totalLabel2 = "
| Fee Estimation: | ";
$totalLabel3 = "
| Build Estimation: | ";
$itemValue1 = filter_var($_POST["subSum1"], FILTER_SANITIZE_STRING);
if (($itemValue1) == 0) {
$itemLabel1 = "";
$itemValue1 = "";
} else {
$itemValue1 = "" .$itemValue1 . " sqm |
";
}
$itemValue2 = filter_var($_POST["subSum2"], FILTER_SANITIZE_STRING);
if (($itemValue2) == 0) {
$itemLabel2 = "";
$itemValue2 = "";
} else {
$itemValue2 = "R " .$itemValue2 . " /sqm | ";
}
$itemValue3 = filter_var($_POST["subSum3"], FILTER_SANITIZE_STRING);
if (($itemValue3) == 0) {
$itemLabel3 = "";
$itemValue3 = "";
} else {
$itemValue3 = "" .$itemValue3 . " sqm | ";
}
$itemValue4 = filter_var($_POST["subSum4"], FILTER_SANITIZE_STRING);
if (($itemValue4) == 0) {
$itemLabel4 = "";
$itemValue4 = "";
} else {
$itemValue4 = "" .$itemValue4 . " sqm | ";
}
$itemValue5 = filter_var($_POST["subSum5"], FILTER_SANITIZE_STRING);
if (($itemValue5) == 0) {
$itemLabel5 = "";
$itemValue5 = "";
} else {
$itemValue5 = "" .$itemValue5 . " sqm | ";
}
$itemValue6 = filter_var($_POST["subSum6"], FILTER_SANITIZE_STRING);
if (($itemValue6) == 0) {
$itemLabel6 = "";
$itemValue6 = "";
} else {
$itemValue6 = "" .$itemValue6 . " sqm | ";
}
$itemValue7 = filter_var($_POST["subSum7"], FILTER_SANITIZE_STRING);
if (($itemValue7) == 0) {
$itemLabel7 = "";
$itemValue7 = "";
} else {
$itemValue7 = "" .$itemValue7 . " sqm | ";
}
$itemValue8 = filter_var($_POST["subSum8"], FILTER_SANITIZE_STRING);
if (($itemValue8) == 0) {
$itemLabel8 = "";
$itemValue8 = "";
} else {
$itemValue8 = "" .$itemValue8 . " sqm | ";
}
$itemValue9 = filter_var($_POST["subSum9"], FILTER_SANITIZE_STRING);
if (($itemValue9) == 0) {
$itemLabel9 = "";
$itemValue9 = "";
} else {
$itemValue9 = "" .$itemValue9 . " sqm | ";
}
$itemValue10 = filter_var($_POST["subSum10"], FILTER_SANITIZE_STRING);
if (($itemValue10) == 0) {
$itemLabel10 = "";
$itemValue10 = "";
} else {
$itemValue10 = "" .$itemValue10 . " sqm | ";
}
$itemValue11 = filter_var($_POST["subSum11"], FILTER_SANITIZE_STRING);
if (($itemValue11) == 0) {
$itemLabel11 = "";
$itemValue11 = "";
} else {
$itemValue11 = "" .$itemValue11 . " sqm | ";
}
$itemValue12 = filter_var($_POST["subSum12"], FILTER_SANITIZE_STRING);
if (($itemValue12) == 0) {
$itemLabel12 = "";
$itemValue12 = "";
} else {
$itemValue12 = "" .$itemValue12 . " sqm | ";
}
$itemValue13 = filter_var($_POST["subSum13"], FILTER_SANITIZE_STRING);
if (($itemValue13) == 0) {
$itemLabel13 = "";
$itemValue13 = "";
} else {
$itemValue13 = "" .$itemValue13 . " sqm | ";
}
$itemValue14 = filter_var($_POST["subSum14"], FILTER_SANITIZE_STRING);
if (($itemValue14) == 0) {
$itemLabel14 = "";
$itemValue14 = "";
} else {
$itemValue14 = "" .$itemValue14 . " sqm | ";
}
$itemValue15 = filter_var($_POST["subSum15"], FILTER_SANITIZE_STRING);
if (($itemValue15) == 0) {
$itemLabel15 = "";
$itemValue15 = "";
} else {
$itemValue15 = "" .$itemValue15 . " sqm | ";
}
$itemValue16 = filter_var($_POST["subSum16"], FILTER_SANITIZE_STRING);
if (($itemValue16) == 0) {
$itemLabel16 = "";
$itemValue16 = "";
} else {
$itemValue16 = "" .$itemValue16 . " sqm | ";
}
$itemValue17 = filter_var($_POST["subSum17"], FILTER_SANITIZE_STRING);
if (($itemValue17) == 0) {
$itemLabel17 = "";
$itemValue17 = "";
} else {
$itemValue17 = "" .$itemValue17 . " sqm | ";
}
$itemValue18 = filter_var($_POST["subSum18"], FILTER_SANITIZE_STRING);
if (($itemValue18) == 0) {
$itemLabel18 = "";
$itemValue18 = "";
} else {
$itemValue18 = "" .$itemValue18 . " sqm | ";
}
$itemValue19 = filter_var($_POST["subSum19"], FILTER_SANITIZE_STRING);
if (($itemValue19) == 0) {
$itemLabel19 = "";
$itemValue19 = "";
} else {
$itemValue19 = "" .$itemValue19 . " sqm | ";
}
$itemValue20 = filter_var($_POST["subSum20"], FILTER_SANITIZE_STRING);
if (($itemValue20) == 0) {
$itemLabel20 = "";
$itemValue20 = "";
} else {
$itemValue20 = "" .$itemValue20 . " sqm | ";
}
$itemValue21 = filter_var($_POST["subSum21"], FILTER_SANITIZE_STRING);
if (($itemValue21) == 0) {
$itemLabel21 = "";
$itemValue21 = "";
} else {
$itemValue21 = "" .$itemValue21 . " sqm | ";
}
$itemValue22 = filter_var($_POST["subSum22"], FILTER_SANITIZE_STRING);
if (($itemValue22) == 0) {
$itemLabel22 = "";
$itemValue22 = "";
} else {
$itemValue22 = "" .$itemValue22 . " sqm | ";
}
$itemValue23 = filter_var($_POST["subSum23"], FILTER_SANITIZE_STRING);
if (($itemValue23) == 0) {
$itemLabel23 = "";
$itemValue23 = "";
} else {
$itemValue23 = "" .$itemValue23 . " sqm | ";
}
$itemPoolValue = filter_var($_POST["extraOption1"], FILTER_SANITIZE_STRING);
if (($itemPoolValue) == 0) {
$itemPoolLabel = "";
$itemPoolValue = "";
} else {
$itemPoolValue = "True | ";
}
$totalSum1 = filter_var($_POST["totalDue"], FILTER_SANITIZE_STRING);
$totalSum1 = "" . $totalSum1 . " sqm | ";
$totalSum2 = filter_var($_POST["totalDue1"], FILTER_SANITIZE_STRING);
$totalSum2 = "R " .$totalSum2 . " | ";
$totalSum3 = filter_var($_POST["totalDue2"], FILTER_SANITIZE_STRING);
$totalSum3 = "R " .$totalSum3 . " | ";
$additional = filter_var($_POST["inputMessage"], FILTER_SANITIZE_STRING);
$subjectTotal = filter_var($_POST["totalDue"], FILTER_SANITIZE_STRING);
$subject = "Potential Client - " . $subjectTotal. "sqm - Residential (New Build)";
$toEmail = "info@blackhoundenterprises.com";
$EchoSession = session_id();
$file = "../../listing-Client/Temp-Client/" .$EchoSession.".php";
if (file_exists($file)) {
unlink($file);
file_put_contents("../../listing-Client/Temp-Client/" .$EchoSession. ".php", "");
// Get the IP and location of the user
$ip = $_SERVER['REMOTE_ADDR'];
$url = "http://ip-api.com/json/" . $ip;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$location = curl_exec($ch);
curl_close($ch);
$location = json_decode($location, true);
$City = $location["city"];
$Region = $location["regionName"];
$Country =$location["country"];
$isp =$location["isp"];
$org =$location["org"];
$Services = "Services: Residential (New build)";
$Contacts = "../listing-Client/Temp-Client/" .$EchoSession.".php";
$Contactlist = $name. "\n" .$email. "\n" .$contact. "\n" .$address. "\n" ;
file_put_contents($Contacts, $Contactlist, FILE_APPEND);
// Save the data to ContactList
$Contactlist = $City. ", " .$Region. ", " .$Country. "\n" . $Services;
file_put_contents($Contacts, $Contactlist, FILE_APPEND);
}
$additional = nl2br($additional);
$name = trim($name, " \t\n\r\0\x0B");
$email = trim($email, " \t\n\r\0\x0B");
$message = "" . "Comments:" . "
"
.$message .
$additional. "
Required Spaces:
" .
$itemLabel1 .$itemValue1.
$itemLabel2 .$itemValue2.
$blankLine . $blankLine.
$blankLine . $blankLine.
$itemLabel3 .$itemValue3.
$itemLabel4 .$itemValue4.
$itemLabel5 .$itemValue5.
$itemLabel6 .$itemValue6.
$itemLabel7 .$itemValue7.
$itemLabel8 .$itemValue8.
$itemLabel9 .$itemValue9.
$itemLabel10 .$itemValue10.
$itemLabel11 .$itemValue11.
$itemLabel12 .$itemValue12.
$itemLabel13 .$itemValue13.
$itemLabel14 .$itemValue14.
$itemLabel15 .$itemValue15.
$itemLabel16 .$itemValue16.
$itemLabel17 .$itemValue17.
$itemLabel18 .$itemValue18.
$itemLabel19 .$itemValue19.
$itemLabel20 .$itemValue20.
$itemLabel21 .$itemValue21.
$itemLabel22 .$itemValue22.
$itemLabel23 .$itemValue23.
$itemPoolLabel .$itemPoolValue.
$blankLine . $blankLine.
$blankLine . $blankLine.
$totalLabel1 .$totalSum1.
$totalLabel2 .$totalSum2.
$totalLabel3 .$totalSum3."
" .
"
" . "Contact Details:" . "
" .
"Name: " .$name. "
" .
"No.: " .$contact. "
" .
"Email: " .$email. "
" .
"Address: " .$address;
$mail = new PHPMailer(true);
// Define the directory to search
$directory = '../../listing-Client/Temp-Client/';
// Function to check if a string contains the specific email address
function containsSpecificEmail($string, $emailer) {
return strpos($string, $emailer) !== false;
}
// Open the directory
if ($handle = opendir($directory)) {
// Loop through the files in the directory
while (false !== ($file = readdir($handle))) {
// Skip the current and parent directory entries
if ($file != "." && $file != "..") {
$filePath = $directory . DIRECTORY_SEPARATOR . $file;
// Ensure it's a file and not a directory
if (is_file($filePath)) {
$containsEmail = false;
// Open the file for reading
$fileHandle = fopen($filePath, 'r');
if ($fileHandle) {
// Read the file line by line
while (($line = fgets($fileHandle)) !== false) {
// Check if the line contains the specific email address
if (containsSpecificEmail($line, $email)) {
$containsEmail = true;
break;
}
}
fclose($fileHandle);
}
// If the specific email address was found, delete the file and perform an action
if ($containsEmail) {
// Delete the file
unlink($filePath);
}
}
}
}
// Close the directory handle
closedir($handle);
} else {
echo "Could not open directory: $directory\n";
}
header('Content-Type: application/json'); // Ensure the response is JSON
try {
//Server settings
$mail->SMTPDebug = 0;
$mail->isSMTP();
$mail->Host = 'mail.blackhoundenterprises.com';
$mail->SMTPAuth = true;
$mail->Username = 'info@blackhoundenterprises.com';
$mail->Password = base64_decode("cjBOPW1ycCVsMTIy");
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->Port = 465;
// Email content
$mail->setFrom('info@blackhoundenterprises.com', 'Blackhound | Architecture & Rendering');
$mail->addAddress($toEmail);
$mail->Subject = $subject;
$mail->isHTML(true);
$mail->Body = $message;
$mail->send();
$response["emailStatus"] = "Email Sent";
} catch (Exception $e) {
$response["error"] = "Email not sent: " . $mail->ErrorInfo;
}
// Clean output buffer
$buffer = ob_get_clean();
if (!empty($buffer)) {
// Log unexpected output to a file for debugging
file_put_contents('debug_output.txt', $buffer);
}
// Output JSON response
header('Content-Type: application/json');
echo json_encode($response);
exit();
}
// If no POST request
$response = ["message" => "Form submission failed."];
echo json_encode($response);
exit();
?>