- Introduced a winter header and benefits section on page-2101.php to promote early bookings for spring-summer 2026. - Enhanced the project inquiry form with additional fields and updated budget ranges for better user experience. - Improved styling and layout for collaboration steps on page-2598.php, including hover effects and responsive design adjustments. - Updated text content for clarity and consistency across both pages.
189 lines
6.9 KiB
PHP
189 lines
6.9 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'phpmailer/class.phpmailer.php';
|
|
require_once 'phpmailer/class.smtp.php';
|
|
|
|
function send_email( $email, $reply, $subject, $text, $attachments = array() )
|
|
{
|
|
$mail = new PHPMailer;
|
|
$mail -> IsSMTP();
|
|
$mail -> SMTPAuth = true;
|
|
$mail -> Host = 'mail.ostal.pl';
|
|
$mail -> Port = 25;
|
|
$mail -> Username = 'konfigurator@ostal.pl';
|
|
$mail -> Password = 'x6rpeUG5tW';
|
|
$mail -> CharSet = "UTF-8";
|
|
$mail -> SMTPOptions = array(
|
|
'ssl' => array(
|
|
'verify_peer' => false,
|
|
'verify_peer_name' => false,
|
|
'allow_self_signed' => true
|
|
)
|
|
);
|
|
$mail -> From = 'konfigurator@ostal.pl';
|
|
$mail -> FromName = 'Ostal';
|
|
$mail -> addAddress( $email, $email );
|
|
$mail -> addReplyTo( $reply, $reply );
|
|
$mail -> isHTML( true );
|
|
$mail -> Subject = $subject;
|
|
$mail -> Body = $text;
|
|
|
|
// Obsługa wielu załączników
|
|
if (is_array($attachments) && count($attachments) > 0) {
|
|
foreach ($attachments as $attachment) {
|
|
if (isset($attachment['tmp_name']) && file_exists($attachment['tmp_name'])) {
|
|
$mail->addAttachment($attachment['tmp_name'], $attachment['name']);
|
|
}
|
|
}
|
|
}
|
|
|
|
return $mail -> send();
|
|
}
|
|
|
|
function validate_file($file) {
|
|
$maxSize = 10 * 1024 * 1024; // 10MB
|
|
$allowedExtensions = array('jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx');
|
|
$allowedMimeTypes = array(
|
|
'image/jpeg',
|
|
'image/jpg',
|
|
'image/png',
|
|
'application/pdf',
|
|
'application/msword',
|
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
'application/vnd.ms-excel',
|
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
);
|
|
|
|
// Sprawdź czy plik istnieje
|
|
if (!isset($file['tmp_name']) || !file_exists($file['tmp_name'])) {
|
|
return array('valid' => false, 'error' => 'Plik nie istnieje');
|
|
}
|
|
|
|
// Sprawdź rozmiar
|
|
if ($file['size'] > $maxSize) {
|
|
return array('valid' => false, 'error' => 'Plik jest za duży (max 10MB)');
|
|
}
|
|
|
|
// Sprawdź rozszerzenie
|
|
$fileExtension = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
|
|
if (!in_array($fileExtension, $allowedExtensions)) {
|
|
return array('valid' => false, 'error' => 'Niedozwolone rozszerzenie pliku');
|
|
}
|
|
|
|
// Sprawdź MIME type
|
|
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
|
$mimeType = finfo_file($finfo, $file['tmp_name']);
|
|
finfo_close($finfo);
|
|
|
|
if (!in_array($mimeType, $allowedMimeTypes)) {
|
|
return array('valid' => false, 'error' => 'Niedozwolony typ pliku');
|
|
}
|
|
|
|
return array('valid' => true);
|
|
}
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$configData = json_decode($_POST['configData'], true);
|
|
|
|
// Pobierz wszystkie załączniki
|
|
$attachments = array();
|
|
$attachments_count = isset($_POST['attachments_count']) ? intval($_POST['attachments_count']) : 0;
|
|
|
|
// Walidacja liczby załączników (max 10)
|
|
if ($attachments_count > 10) {
|
|
echo json_encode(['status' => 'error', 'message' => 'Maksymalnie 10 załączników']);
|
|
exit();
|
|
}
|
|
|
|
for ($i = 0; $i < $attachments_count; $i++) {
|
|
$fileKey = 'attachment_' . $i;
|
|
if (isset($_FILES[$fileKey])) {
|
|
$file = $_FILES[$fileKey];
|
|
|
|
// Walidacja pliku
|
|
$validation = validate_file($file);
|
|
if (!$validation['valid']) {
|
|
echo json_encode(['status' => 'error', 'message' => 'Błąd walidacji pliku: ' . $validation['error']]);
|
|
exit();
|
|
}
|
|
|
|
$attachments[] = $file;
|
|
}
|
|
}
|
|
|
|
$to = 'kontakt@ostal.pl';
|
|
$subject = 'ostal.pl - Konfigurator';
|
|
$message = '<p>' . $configData['step_1'] . '</p>';
|
|
|
|
$message .= '<p>Wymiary</p>';
|
|
$message .= '<ul>';
|
|
if (isset($configData['step_2']['width']) && $configData['step_2']['width']) {
|
|
$message .= '<li>Szerokość X : ' . $configData['step_2']['width'] . 'mm </li>';
|
|
}
|
|
if (isset($configData['step_2']['length']) && $configData['step_2']['length']) {
|
|
$message .= '<li>Głębokość Y : ' . $configData['step_2']['length'] . 'mm </li>';
|
|
}
|
|
if (isset($configData['step_2']['height']) && $configData['step_2']['height']) {
|
|
$message .= '<li>Wysokość Z : ' . $configData['step_2']['height'] . 'mm </li>';
|
|
}
|
|
if (isset($configData['step_2']['entry']) && $configData['step_2']['entry']) {
|
|
$message .= '<li>Wjazd: ' . $configData['step_2']['entry'] . '</li>';
|
|
}
|
|
$message .= '</ul>';
|
|
|
|
$message .= '<p>' . $configData['step_3'] . '</p>';
|
|
|
|
if (isset($configData['step_3_extra']) && $configData['step_3_extra']) {
|
|
$message .= '<p>' . $configData['step_3_extra'] . '</p>';
|
|
}
|
|
|
|
$message .= '<p>Dane kontaktowe</p>';
|
|
$message .= '<ul>';
|
|
$message .= '<li>Miejsce montażu: ' . $configData['step_4']['miejsce_montazu'] . '</li>';
|
|
$message .= '<li>Imię: ' . $configData['step_4']['name'] . '</li>';
|
|
$message .= '<li>E-mail: ' . $configData['step_4']['email'] . '</li>';
|
|
$message .= '<li>Telefon: ' . $configData['step_4']['phone'] . '</li>';
|
|
if (isset($configData['step_4']['planned_season']) && $configData['step_4']['planned_season']) {
|
|
$message .= '<li>Planowany termin realizacji: ' . $configData['step_4']['planned_season'] . '</li>';
|
|
}
|
|
if (isset($configData['step_4']['budget_range']) && $configData['step_4']['budget_range']) {
|
|
$message .= '<li>Budżet inwestycji: ' . $configData['step_4']['budget_range'] . '</li>';
|
|
}
|
|
if (isset($configData['step_4']['is_owner']) && $configData['step_4']['is_owner']) {
|
|
$message .= '<li>Właściciel nieruchomości: ' . $configData['step_4']['is_owner'] . '</li>';
|
|
}
|
|
$message .= '</ul>';
|
|
|
|
if (isset($configData['step_4']['confirm_budget']) || isset($configData['step_4']['confirm_deposit'])) {
|
|
$message .= '<p>Potwierdzenia</p>';
|
|
$message .= '<ul>';
|
|
if (isset($configData['step_4']['confirm_budget']) && $configData['step_4']['confirm_budget']) {
|
|
$message .= '<li>✅ Rozumiem, że realizacje całorocznych ogrodów zimowych zaczynają się od około 120 000 zł netto.</li>';
|
|
}
|
|
if (isset($configData['step_4']['confirm_deposit']) && $configData['step_4']['confirm_deposit']) {
|
|
$message .= '<li>✅ Rozumiem, że do rezerwacji terminu realizacji wymagana jest zaliczka (ok. 40%).</li>';
|
|
}
|
|
$message .= '</ul>';
|
|
}
|
|
|
|
// Dodaj informację o załącznikach
|
|
if (count($attachments) > 0) {
|
|
$message .= '<p>Załączniki (' . count($attachments) . '):</p>';
|
|
$message .= '<ul>';
|
|
foreach ($attachments as $attachment) {
|
|
$fileSize = round($attachment['size'] / 1024, 2); // KB
|
|
$message .= '<li>' . htmlspecialchars($attachment['name']) . ' (' . $fileSize . ' KB)</li>';
|
|
}
|
|
$message .= '</ul>';
|
|
}
|
|
|
|
if (send_email($to, $configData['step_4']['email'], $subject, $message, $attachments)) {
|
|
$_SESSION["configurator_sended"] = true;
|
|
echo json_encode(['status' => 'ok', 'message' => 'Wiadmość wysłana']);
|
|
} else {
|
|
echo json_encode(['status' => 'error', 'message' => 'Wystąpił błąd podczas wysyłania wiadomości']);
|
|
}
|
|
exit();
|
|
} else {
|
|
echo json_encode(['status' => 'error', 'message' => 'Nieprawidłowe żądanie']);
|
|
exit();
|
|
} |