diff --git a/tiny.php b/tiny.php new file mode 100644 index 0000000..a357b26 --- /dev/null +++ b/tiny.php @@ -0,0 +1,454 @@ +file($file['tmp_name']); + $allowedTypes = [ + 'image/jpeg' => 'jpg', + 'image/png' => 'png', + 'image/webp' => 'webp', + 'image/gif' => 'gif' + ]; + + if (!array_key_exists($mimeType, $allowedTypes)) { + $errors[] = 'Die Datei "' . htmlspecialchars($file['name']) . '" ist kein unterstütztes Bildformat.'; + return null; + } + + ensureDirectory($targetDir); + $extension = $allowedTypes[$mimeType]; + $filename = sanitizeFileName(pathinfo($file['name'], PATHINFO_FILENAME)); + if ($filename === '') { + $filename = 'upload_' . time(); + } + $destination = rtrim($targetDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $filename . '_' . uniqid() . '.' . $extension; + + if (!move_uploaded_file($file['tmp_name'], $destination)) { + $errors[] = 'Die Datei "' . htmlspecialchars($file['name']) . '" konnte nicht gespeichert werden.'; + return null; + } + + return [ + 'path' => $destination, + 'original' => $file['name'], + 'type' => $mimeType + ]; +} + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $company = trim($_POST['company'] ?? ''); + $contactEmail = filter_var($_POST['email'] ?? '', FILTER_VALIDATE_EMAIL) ? $_POST['email'] : ''; + $website = trim($_POST['website'] ?? ''); + $message = trim($_POST['message'] ?? ''); + $bannerLink = trim($_POST['banner_link'] ?? ''); + + if ($company === '') { + $errors[] = 'Bitte geben Sie den Namen Ihres Unternehmens oder Projekts an.'; + } + + if ($contactEmail === '') { + $errors[] = 'Bitte geben Sie eine gültige E-Mail-Adresse an.'; + } + + if ($bannerLink === '') { + $errors[] = 'Bitte geben Sie den Link an, der Ihrem Banner zugeordnet werden soll.'; + } + + $uploadedImage = handleUpload('project_image', __DIR__ . '/uploads/images', $errors); + $uploadedBanner = handleUpload('banner_image', __DIR__ . '/uploads/banners', $errors); + + if (!$errors) { + $boundary = '=_TinyHome_' . md5((string) microtime(true)); + $headers = []; + $fromAddress = $contactEmail ?: 'no-reply@tinyhome.local'; + $headers[] = 'From: ' . $fromAddress; + $headers[] = 'Reply-To: ' . $fromAddress; + $headers[] = 'MIME-Version: 1.0'; + $headers[] = 'Content-Type: multipart/mixed; boundary="' . $boundary . '"'; + + $bodyParts = []; + $text = "Neue TinyHome-Anfrage\n\n"; + $text .= "Unternehmen/Projekt: $company\n"; + $text .= "Kontakt-E-Mail: $contactEmail\n"; + if ($website !== '') { + $text .= "Website: $website\n"; + } + $text .= "Banner-Link: $bannerLink\n\n"; + if ($message !== '') { + $text .= "Nachricht:\n$message\n\n"; + } + if ($uploadedImage) { + $text .= 'Projektbild gespeichert unter: ' . $uploadedImage['path'] . "\n"; + } + if ($uploadedBanner) { + $text .= 'Banner gespeichert unter: ' . $uploadedBanner['path'] . "\n"; + } + + $bodyParts[] = '--' . $boundary; + $bodyParts[] = 'Content-Type: text/plain; charset="UTF-8"'; + $bodyParts[] = 'Content-Transfer-Encoding: 8bit'; + $bodyParts[] = ''; + $bodyParts[] = $text; + + foreach ([$uploadedImage, $uploadedBanner] as $upload) { + if (!$upload) { + continue; + } + $fileContent = file_get_contents($upload['path']); + if ($fileContent === false) { + $errors[] = 'Die Datei "' . htmlspecialchars($upload['original']) . '" konnte nicht für den Mailversand gelesen werden.'; + continue; + } + $bodyParts[] = '--' . $boundary; + $bodyParts[] = 'Content-Type: ' . $upload['type'] . '; name="' . sanitizeFileName($upload['original']) . '"'; + $bodyParts[] = 'Content-Transfer-Encoding: base64'; + $bodyParts[] = 'Content-Disposition: attachment; filename="' . sanitizeFileName($upload['original']) . '"'; + $bodyParts[] = ''; + $bodyParts[] = chunk_split(base64_encode($fileContent)); + } + + $bodyParts[] = '--' . $boundary . '--'; + $body = implode("\r\n", $bodyParts); + + if (!$errors) { + $mailSent = mail( + $recipient, + 'Neue TinyHome-Anfrage von ' . $company, + $body, + implode("\r\n", $headers) + ); + + if ($mailSent) { + $successMessage = 'Vielen Dank! Ihre Anfrage wurde erfolgreich übermittelt.'; + } else { + $errors[] = 'Ihre Anfrage konnte leider nicht versendet werden. Bitte versuchen Sie es später erneut.'; + } + } + } +} +?> + + + + + + TinyHome Plattform – Natürlich. Minimalistisch. Erschwinglich. + + + +
+
+

TinyHome Plattform

+

Minimalistisches Wohnen im Einklang mit der Natur – wir verbinden Hersteller, Planer:innen und Menschen, die erschwingliche, hochwertige Tiny Houses suchen.

+ Jetzt Projekt einreichen +
+
+
+
+

Warum TinyHomes?

+
+
+

Naturnah leben

+

Unsere Plattform bündelt Anbieter, die nachhaltige Materialien und ökologische Bauweisen priorisieren.

+
+
+

Minimale Baukosten

+

Smarter Grundriss, effiziente Energie, faire Preise: TinyHomes machen Wohnen wieder erschwinglich.

+
+
+

Flexibel kombinierbar

+

Vom Wochenend-Retreat bis zum ganzjährigen Zuhause – konfigurieren Sie Ihr TinyHome passend zu Ihrem Lebensstil.

+
+
+

Direkter Kontakt

+

Sie erhalten maßgeschneiderte Angebote von geprüften Hersteller:innen aus der DACH-Region.

+
+
+
+ +
+

Projekt vorstellen & Banner übermitteln

+

Übermitteln Sie uns Ihr TinyHome-Konzept – inklusive Banner-Link, damit wir Bestellungen eindeutig zuordnen können. Wir melden uns persönlich bei Ihnen.

+ + +
+ + + +
+
    + +
  • + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+ + +